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: * @return Item
44: */
45: public function create($idItem, $idPlugin, $type) {
46:
47: // create a new entry
48: $item = $this->createNewItem();
49: $item->set('iditem', $idItem);
50: $item->set('idplugin', $idPlugin);
51: $item->set('type', $type);
52:
53: $item->store();
54:
55: return $item;
56: }
57:
58: }
59:
60: /**
61: * Single Plugin Manager Relations Item
62: */
63: class PimPluginRelations extends Item {
64:
65: /**
66: * @var string Error storage
67: */
68: protected $_sError;
69:
70: /**
71: * Constructor Function
72: *
73: * @param mixed $id Specifies the id of item to load
74: */
75: public function __construct($id = false) {
76: global $cfg;
77: parent::__construct($cfg['tab']['plugins_rel'], 'idpluginrelation');
78: $this->_sError = '';
79: if ($id !== false) {
80: $this->loadByPrimaryKey($id);
81: }
82: }
83:
84: /**
85: * Userdefined setter for pim relations fields.
86: *
87: * @param string $name
88: * @param mixed $value
89: * @param bool $bSafe Flag to run defined inFilter on passed value
90: */
91: public function setField($name, $value, $bSafe = true) {
92: switch ($name) {
93: case 'iditem':
94: $value = (int) $value;
95: break;
96: case 'idplugin':
97: $value = (int) $value;
98: break;
99: }
100:
101: return parent::setField($name, $value, $bSafe);
102: }
103:
104: }
105: