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 cApiContainerConfigurationCollection extends ItemCollection {
25:
26: 27: 28: 29: 30: 31:
32: public function __construct($select = false) {
33: global $cfg;
34: parent::__construct($cfg['tab']['container_conf'], 'idcontainerc');
35: $this->_setItemClass('cApiContainerConfiguration');
36:
37:
38: $this->_setJoinPartner('cApiTemplateConfigurationCollection');
39:
40: if ($select !== false) {
41: $this->select($select);
42: }
43: }
44:
45: 46: 47: 48: 49: 50: 51:
52: public function create($idtplcfg, $number, $container) {
53: $item = $this->createNewItem();
54:
55: $item->set('idtplcfg', $idtplcfg);
56: $item->set('number', $number);
57: $item->set('container', $container);
58: $item->store();
59:
60: return $item;
61: }
62:
63: 64: 65: 66: 67: 68: 69:
70: public function getByTemplateConfiguration($idtplcfg) {
71: $configuration = array();
72:
73: $this->select('idtplcfg = ' . (int) $idtplcfg, '', 'number ASC');
74: while (($item = $this->next()) !== false) {
75: $configuration[(int) $item->get('number')] = $item->get('container');
76: }
77:
78: return $configuration;
79: }
80: }
81:
82: 83: 84: 85: 86: 87:
88: class cApiContainerConfiguration extends Item {
89:
90: 91: 92: 93: 94:
95: public function __construct($mId = false) {
96: global $cfg;
97: parent::__construct($cfg['tab']['container_conf'], 'idcontainerc');
98: $this->setFilters(array(), array());
99: if ($mId !== false) {
100: $this->loadByPrimaryKey($mId);
101: }
102: }
103:
104: 105: 106: 107: 108: 109: 110: 111:
112: public function setField($name, $value, $bSafe = true) {
113: switch ($name) {
114: case 'idtplcfg':
115: case 'number':
116: $value = cSecurity::toInteger($value);
117: break;
118: }
119:
120: parent::setField($name, $value, $bSafe);
121: }
122:
123: 124: 125: 126: 127: 128: 129: 130:
131: public static function addContainerValue($container, $key, $value) {
132: $container .= $key . '=' . urlencode(stripslashes($value)) . '&';
133: return $container;
134: }
135:
136: 137: 138: 139: 140:
141: public static function parseContainerValue($value) {
142: $vars = array();
143:
144: $value = preg_replace('/&$/', '', $value);
145: $parts = preg_split('/&/', $value);
146: foreach ($parts as $key1 => $value1) {
147: $param = explode('=', $value1);
148: foreach ($param as $key2 => $value2) {
149: $vars[$param[0]] = urldecode($param[1]);
150: }
151: }
152:
153: return $vars;
154: }
155:
156: }
157: