1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18:
19:
20: namespace Xoops\Core\Kernel\Handlers;
21:
22: use Xoops\Core\Kernel\Dtype;
23: use Xoops\Core\Kernel\XoopsObject;
24:
25: 26: 27: 28:
29: define('XOOPS_CONF', 1);
30: define('XOOPS_CONF_USER', 2);
31: define('XOOPS_CONF_METAFOOTER', 3);
32: define('XOOPS_CONF_CENSOR', 4);
33: define('XOOPS_CONF_SEARCH', 5);
34: define('XOOPS_CONF_MAILER', 6);
35: define('XOOPS_CONF_AUTH', 7);
36:
37: 38: 39: 40: 41: 42: 43: 44: 45: 46:
47: class XoopsConfigItem extends XoopsObject
48: {
49:
50: 51: 52: 53: 54:
55: private $configurationOptions = array();
56:
57: 58: 59:
60: public function __construct()
61: {
62: $this->initVar('conf_id', Dtype::TYPE_INTEGER, null, false);
63: $this->initVar('conf_modid', Dtype::TYPE_INTEGER, null, false);
64: $this->initVar('conf_catid', Dtype::TYPE_INTEGER, null, false);
65: $this->initVar('conf_name', Dtype::TYPE_OTHER);
66: $this->initVar('conf_title', Dtype::TYPE_TEXT_BOX);
67: $this->initVar('conf_value', Dtype::TYPE_TEXT_AREA);
68: $this->initVar('conf_desc', Dtype::TYPE_OTHER);
69: $this->initVar('conf_formtype', Dtype::TYPE_OTHER);
70: $this->initVar('conf_valuetype', Dtype::TYPE_OTHER);
71: $this->initVar('conf_order', Dtype::TYPE_INTEGER);
72: }
73:
74: 75: 76: 77: 78: 79: 80:
81: public function id($format = Dtype::FORMAT_NONE)
82: {
83: return $this->getVar('conf_id', $format);
84: }
85:
86: 87: 88: 89: 90: 91: 92:
93: public function conf_id($format = '')
94: {
95: return $this->getVar('conf_id', $format);
96: }
97:
98: 99: 100: 101: 102: 103: 104:
105: public function conf_modid($format = '')
106: {
107: return $this->getVar('conf_modid', $format);
108: }
109:
110: 111: 112: 113: 114: 115: 116:
117: public function conf_catid($format = '')
118: {
119: return $this->getVar('conf_catid', $format);
120: }
121:
122: 123: 124: 125: 126: 127: 128:
129: public function conf_name($format = '')
130: {
131: return $this->getVar('conf_name', $format);
132: }
133:
134: 135: 136: 137: 138: 139: 140:
141: public function conf_title($format = '')
142: {
143: return $this->getVar('conf_title', $format);
144: }
145:
146: 147: 148: 149: 150: 151: 152:
153: public function conf_value($format = '')
154: {
155: return $this->getVar('conf_value', $format);
156: }
157:
158: 159: 160: 161: 162: 163: 164:
165: public function conf_desc($format = '')
166: {
167: return $this->getVar('conf_desc', $format);
168: }
169:
170: 171: 172: 173: 174: 175: 176:
177: public function conf_formtype($format = '')
178: {
179: return $this->getVar('conf_formtype', $format);
180: }
181:
182: 183: 184: 185: 186: 187: 188:
189: public function conf_valuetype($format = '')
190: {
191: return $this->getVar('conf_valuetype', $format);
192: }
193:
194: 195: 196: 197: 198: 199: 200:
201: public function conf_order($format = '')
202: {
203: return $this->getVar('conf_order', $format);
204: }
205:
206: 207: 208: 209: 210:
211: public function getConfValueForOutput()
212: {
213: switch ($this->getVar('conf_valuetype')) {
214: case 'int':
215: return (int)($this->getVar('conf_value', 'n'));
216: break;
217: case 'array':
218: $value = @unserialize($this->getVar('conf_value', 'n'));
219: return $value ? $value : array();
220: case 'float':
221: $value = $this->getVar('conf_value', 'n');
222: return (float)$value;
223: break;
224: case 'textarea':
225: return $this->getVar('conf_value');
226: default:
227: return $this->getVar('conf_value', 'n');
228: break;
229: }
230: }
231:
232: 233: 234: 235: 236: 237: 238:
239: public function setConfValueForInput(&$value)
240: {
241: switch ($this->getVar('conf_valuetype')) {
242: case 'array':
243: if (!is_array($value)) {
244: $value = explode('|', trim($value));
245: }
246: $this->setVar('conf_value', serialize($value));
247: break;
248: case 'text':
249: $this->setVar('conf_value', trim($value));
250: break;
251: default:
252: $this->setVar('conf_value', $value);
253: break;
254: }
255: }
256:
257: 258: 259: 260: 261: 262: 263:
264: public function setConfOptions($option)
265: {
266: if (is_array($option)) {
267: $count = count($option);
268: for ($i = 0; $i < $count; ++$i) {
269: $this->setConfOptions($option[$i]);
270: }
271: } else {
272: if (is_object($option)) {
273: $this->configurationOptions[] = $option;
274: }
275: }
276: }
277:
278: 279: 280: 281: 282:
283: public function getConfOptions()
284: {
285: return $this->configurationOptions;
286: }
287:
288: 289: 290: 291: 292:
293: public function clearConfOptions()
294: {
295: $this->configurationOptions = array();
296: }
297: }
298: