1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15:
16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
17:
18: 19: 20: 21: 22: 23:
24: class cApiContainerCollection extends ItemCollection {
25:
26: 27: 28: 29: 30: 31:
32: public function __construct($select = false) {
33: global $cfg;
34: parent::__construct($cfg['tab']['container'], 'idcontainer');
35: $this->_setItemClass('cApiContainer');
36:
37:
38: $this->_setJoinPartner('cApiTemplateCollection');
39:
40: if ($select !== false) {
41: $this->select($select);
42: }
43: }
44:
45: 46: 47: 48:
49: public function clearAssignments($idtpl) {
50: $this->deleteBy('idtpl', (int) $idtpl);
51: }
52:
53: 54: 55: 56: 57: 58:
59: public function assignModule($idtpl, $number, $idmod) {
60: $this->select('idtpl = ' . (int) $idtpl . ' AND number = ' . (int) $number);
61: if (($item = $this->next()) !== false) {
62: $item->set('idmod', $idmod);
63: $item->store();
64: } else {
65: $this->create($idtpl, $number, $idmod);
66: }
67: }
68:
69: 70: 71:
72: public function assignModul($idtpl, $number, $idmod) {
73: cDeprecated("The method assignModul() is deprecated. Use assignModule() instead.");
74: $this->assignModule($idtpl, $number, $idmod);
75: }
76:
77: 78: 79: 80: 81: 82: 83: 84:
85: public function create($idtpl, $number, $idmod) {
86: $item = parent::createNewItem();
87:
88: $item->set('idtpl', $idtpl);
89: $item->set('number', $number);
90: $item->set('idmod', $idmod);
91: $item->store();
92:
93: return $item;
94: }
95: }
96:
97: 98: 99: 100: 101: 102:
103: class cApiContainer extends Item {
104:
105: 106: 107: 108: 109:
110: public function __construct($mId = false) {
111: global $cfg;
112: parent::__construct($cfg['tab']['container'], 'idcontainer');
113: $this->setFilters(array(), array());
114: if ($mId !== false) {
115: $this->loadByPrimaryKey($mId);
116: }
117: }
118:
119: 120: 121: 122: 123: 124: 125: 126:
127: public function setField($name, $value, $bSafe = true) {
128: switch ($name) {
129: case 'idtpl':
130: case 'number':
131: case 'idmod':
132: $value = (int) $value;
133: break;
134: }
135:
136: parent::setField($name, $value, $bSafe);
137: }
138: }
139: