1: <?php
2: /**
3: * This file contains Plugin Manager Relations recipient class.
4: *
5: * @package Plugin
6: * @subpackage PluginManager
7: * @version SVN Revision $Rev:$
8: *
9: * @author Frederic Schneider
10: * @copyright four for business AG <www.4fb.de>
11: * @license http://www.contenido.org/license/LIZENZ.txt
12: * @link http://www.4fb.de
13: * @link http://www.contenido.org
14: */
15:
16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
17:
18: /**
19: * Plugin Manager Relations recipient class.
20: *
21: * @package Plugin
22: * @subpackage PluginManager
23: * @author Frederic Schneider
24: */
25: class PimPluginRelationsCollection extends ItemCollection {
26:
27: /**
28: * Constructor Function
29: *
30: * @param none
31: */
32: public function __construct() {
33: global $cfg;
34: parent::__construct($cfg['tab']['plugins_rel'], 'idpluginrelation');
35: $this->_setItemClass('PimPluginRelations');
36: }
37:
38: /**
39: * Create a new plugin
40: *
41: * @param $idItem int Is equivalent to idarea or idnavm
42: * @param $idPlugin int Plugin Id
43: * @param $type string Relation to tables *_area and *_nav_main
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: