XOOPS  2.6.0
configitem.php
Go to the documentation of this file.
1 <?php
23 
28 define('XOOPS_CONF', 1);
29 define('XOOPS_CONF_USER', 2);
30 define('XOOPS_CONF_METAFOOTER', 3);
31 define('XOOPS_CONF_CENSOR', 4);
32 define('XOOPS_CONF_SEARCH', 5);
33 define('XOOPS_CONF_MAILER', 6);
34 define('XOOPS_CONF_AUTH', 7);
42 {
43 
50  private $_confOptions = array();
51 
55  public function __construct()
56  {
57  $this->initVar('conf_id', XOBJ_DTYPE_INT, null, false);
58  $this->initVar('conf_modid', XOBJ_DTYPE_INT, null, false);
59  $this->initVar('conf_catid', XOBJ_DTYPE_INT, null, false);
60  $this->initVar('conf_name', XOBJ_DTYPE_OTHER);
61  $this->initVar('conf_title', XOBJ_DTYPE_TXTBOX);
62  $this->initVar('conf_value', XOBJ_DTYPE_TXTAREA);
63  $this->initVar('conf_desc', XOBJ_DTYPE_OTHER);
64  $this->initVar('conf_formtype', XOBJ_DTYPE_OTHER);
65  $this->initVar('conf_valuetype', XOBJ_DTYPE_OTHER);
66  $this->initVar('conf_order', XOBJ_DTYPE_INT);
67  }
68 
73  public function id($format = 'n')
74  {
75  return $this->getVar('conf_id', $format);
76  }
77 
82  public function conf_id($format = '')
83  {
84  return $this->getVar('conf_id', $format);
85  }
86 
91  public function conf_modid($format = '')
92  {
93  return $this->getVar('conf_modid', $format);
94  }
95 
100  public function conf_catid($format = '')
101  {
102  return $this->getVar('conf_catid', $format);
103  }
104 
109  public function conf_name($format = '')
110  {
111  return $this->getVar('conf_name', $format);
112  }
113 
118  public function conf_title($format = '')
119  {
120  return $this->getVar('conf_title', $format);
121  }
122 
127  public function conf_value($format = '')
128  {
129  return $this->getVar('conf_value', $format);
130  }
131 
136  public function conf_desc($format = '')
137  {
138  return $this->getVar('conf_desc', $format);
139  }
140 
145  public function conf_formtype($format = '')
146  {
147  return $this->getVar('conf_formtype', $format);
148  }
149 
154  public function conf_valuetype($format = '')
155  {
156  return $this->getVar('conf_valuetype', $format);
157  }
158 
163  public function conf_order($format = '')
164  {
165  return $this->getVar('conf_order', $format);
166  }
167 
173  public function getConfValueForOutput()
174  {
175  switch ($this->getVar('conf_valuetype')) {
176  case 'int':
177  return intval($this->getVar('conf_value', 'n'));
178  break;
179  case 'array':
180  $value = @unserialize($this->getVar('conf_value', 'n'));
181  return $value ? $value : array();
182  case 'float':
183  $value = $this->getVar('conf_value', 'n');
184  return (float)$value;
185  break;
186  case 'textarea':
187  return $this->getVar('conf_value');
188  default:
189  return $this->getVar('conf_value', 'n');
190  break;
191  }
192  }
193 
200  public function setConfValueForInput(&$value, $force_slash = false)
201  {
202  switch ($this->getVar('conf_valuetype')) {
203  case 'array':
204  if (!is_array($value)) {
205  $value = explode('|', trim($value));
206  }
207  $this->setVar('conf_value', serialize($value), $force_slash);
208  break;
209  case 'text':
210  $this->setVar('conf_value', trim($value), $force_slash);
211  break;
212  default:
213  $this->setVar('conf_value', $value, $force_slash);
214  break;
215  }
216  }
217 
223  public function setConfOptions($option)
224  {
225  if (is_array($option)) {
226  $count = count($option);
227  for ($i = 0; $i < $count; ++$i) {
228  $this->setConfOptions($option[$i]);
229  }
230  } else {
231  if (is_object($option)) {
232  $this->_confOptions[] = $option;
233  }
234  }
235  }
236 
242  public function getConfOptions()
243  {
244  return $this->_confOptions;
245  }
246 
252  public function clearConfOptions()
253  {
254  $this->_confOptions = array();
255  }
256 }
257 
268 {
274  public function __construct(Connection $db = null)
275  {
276  parent::__construct($db, 'config', 'XoopsConfigItem', 'conf_id', 'conf_name');
277  }
278 }
conf_value($format= '')
Definition: configitem.php:127
conf_title($format= '')
Definition: configitem.php:118
$i
Definition: dialog.php:68
conf_order($format= '')
Definition: configitem.php:163
conf_desc($format= '')
Definition: configitem.php:136
getVar($key, $format= 's')
conf_catid($format= '')
Definition: configitem.php:100
setConfOptions($option)
Definition: configitem.php:223
const XOBJ_DTYPE_TXTAREA
Definition: XoopsObject.php:21
conf_name($format= '')
Definition: configitem.php:109
conf_valuetype($format= '')
Definition: configitem.php:154
__construct(Connection $db=null)
Definition: configitem.php:274
conf_id($format= '')
Definition: configitem.php:82
setVar($key, $value, $not_gpc=false)
initVar($key, $data_type, $value=null, $required=false, $maxlength=null, $options= '')
id($format= 'n')
Definition: configitem.php:73
conf_modid($format= '')
Definition: configitem.php:91
conf_formtype($format= '')
Definition: configitem.php:145
setConfValueForInput(&$value, $force_slash=false)
Definition: configitem.php:200