1: <?php
2: /**
3: * This file contains Plugin Manager Relations recipient class.
4: *
5: * @package Plugin
6: * @subpackage PluginManager
7: * @author Frederic Schneider
8: * @copyright four for business AG <www.4fb.de>
9: * @license http://www.contenido.org/license/LIZENZ.txt
10: * @link http://www.4fb.de
11: * @link http://www.contenido.org
12: */
13:
14: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
15:
16: /**
17: * Plugin Manager Relations recipient class.
18: *
19: * @package Plugin
20: * @subpackage PluginManager
21: * @author Frederic Schneider
22: */
23: class PimPluginRelationsCollection extends ItemCollection {
24:
25: /**
26: * Constructor Function
27: *
28: * @param none
29: */
30: public function __construct() {
31: global $cfg;
32: parent::__construct($cfg['tab']['plugins_rel'], 'idpluginrelation');
33: $this->_setItemClass('PimPluginRelations');
34: }
35:
36: /**
37: * Create a new plugin
38: *
39: * @param $idItem int Is equivalent to idarea or idnavm
40: * @param $idPlugin int Plugin Id
41: * @param $type string Relation to tables *_area and *_nav_main
42: */
43: public function create($idItem, $idPlugin, $type) {
44:
45: // create a new entry
46: $item = $this->createNewItem();
47: $item->set('iditem', $idItem);
48: $item->set('idplugin', $idPlugin);
49: $item->set('type', $type);
50:
51: $item->store();
52:
53: return $item;
54: }
55:
56: }
57:
58: /**
59: * Single Plugin Manager Relations Item
60: */
61: class PimPluginRelations extends Item {
62:
63: /**
64: * @var string Error storage
65: */
66: protected $_sError;
67:
68: /**
69: * Constructor Function
70: *
71: * @param mixed $id Specifies the id of item to load
72: */
73: public function __construct($id = false) {
74: global $cfg;
75: parent::__construct($cfg['tab']['plugins_rel'], 'idpluginrelation');
76: $this->_sError = '';
77: if ($id !== false) {
78: $this->loadByPrimaryKey($id);
79: }
80: }
81:
82: /**
83: * Userdefined setter for pim relations fields.
84: *
85: * @param string $name
86: * @param mixed $value
87: * @param bool $bSafe Flag to run defined inFilter on passed value
88: */
89: public function setField($name, $value, $bSafe = true) {
90: switch ($name) {
91: case 'iditem':
92: $value = (int) $value;
93: break;
94: case 'idplugin':
95: $value = (int) $value;
96: break;
97: }
98:
99: return parent::setField($name, $value, $bSafe);
100: }
101:
102: }
103: