XOOPS  2.6.0
item.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10  */
11 
24 
30 {
31 
38  private $_confOptions = array();
39 
43  public function __construct()
44  {
45  $this->initVar('conf_id', XOBJ_DTYPE_INT, null, false);
46  $this->initVar('conf_modid', XOBJ_DTYPE_INT, null, false);
47  $this->initVar('conf_uid', XOBJ_DTYPE_INT, null, false);
48  $this->initVar('conf_name', XOBJ_DTYPE_OTHER);
49  $this->initVar('conf_title', XOBJ_DTYPE_TXTBOX);
50  $this->initVar('conf_value', XOBJ_DTYPE_TXTAREA);
51  $this->initVar('conf_desc', XOBJ_DTYPE_OTHER);
52  $this->initVar('conf_formtype', XOBJ_DTYPE_OTHER);
53  $this->initVar('conf_valuetype', XOBJ_DTYPE_OTHER);
54  $this->initVar('conf_order', XOBJ_DTYPE_INT);
55  }
56 
61  public function id($format = 'n')
62  {
63  return $this->getVar('conf_id', $format);
64  }
65 
70  public function conf_id($format = '')
71  {
72  return $this->getVar('conf_id', $format);
73  }
74 
79  public function conf_modid($format = '')
80  {
81  return $this->getVar('conf_modid', $format);
82  }
83 
88  public function conf_uid($format = '')
89  {
90  return $this->getVar('conf_uid', $format);
91  }
92 
97  public function conf_name($format = '')
98  {
99  return $this->getVar('conf_name', $format);
100  }
101 
106  public function conf_title($format = '')
107  {
108  return $this->getVar('conf_title', $format);
109  }
110 
115  public function conf_value($format = '')
116  {
117  return $this->getVar('conf_value', $format);
118  }
119 
124  public function conf_desc($format = '')
125  {
126  return $this->getVar('conf_desc', $format);
127  }
128 
133  public function conf_formtype($format = '')
134  {
135  return $this->getVar('conf_formtype', $format);
136  }
137 
142  public function conf_valuetype($format = '')
143  {
144  return $this->getVar('conf_valuetype', $format);
145  }
146 
151  public function conf_order($format = '')
152  {
153  return $this->getVar('conf_order', $format);
154  }
155 
161  public function getConfValueForOutput()
162  {
163  switch ($this->getVar('conf_valuetype')) {
164  case 'int':
165  return intval($this->getVar('conf_value', 'n'));
166  break;
167  case 'array':
168  $value = @unserialize($this->getVar('conf_value', 'n'));
169  return $value ? $value : array();
170  case 'float':
171  $value = $this->getVar('conf_value', 'n');
172  return (float)$value;
173  break;
174  case 'textarea':
175  return $this->getVar('conf_value');
176  default:
177  return $this->getVar('conf_value', 'n');
178  break;
179  }
180  }
181 
188  public function setConfValueForInput(&$value, $force_slash = false)
189  {
190  switch ($this->getVar('conf_valuetype')) {
191  case 'array':
192  if (!is_array($value)) {
193  $value = explode('|', trim($value));
194  }
195  $this->setVar('conf_value', serialize($value), $force_slash);
196  break;
197  case 'text':
198  $this->setVar('conf_value', trim($value), $force_slash);
199  break;
200  default:
201  $this->setVar('conf_value', $value, $force_slash);
202  break;
203  }
204  }
205 
211  public function setConfOptions($option)
212  {
213  if (is_array($option)) {
214  $count = count($option);
215  for ($i = 0; $i < $count; ++$i) {
216  $this->setConfOptions($option[$i]);
217  }
218  } else {
219  if (is_object($option)) {
220  $this->_confOptions[] = $option;
221  }
222  }
223  }
224 
230  public function getConfOptions()
231  {
232  return $this->_confOptions;
233  }
234 
240  public function clearConfOptions()
241  {
242  $this->_confOptions = array();
243  }
244 }
245 
247 {
253  public function __construct(Connection $db = null)
254  {
255  parent::__construct($db, 'userconfigs_item', 'UserconfigsItem', 'conf_id', 'conf_name');
256  }
257 }
conf_id($format= '')
Definition: item.php:70
conf_valuetype($format= '')
Definition: item.php:142
conf_formtype($format= '')
Definition: item.php:133
$i
Definition: dialog.php:68
setConfOptions($option)
Definition: item.php:211
id($format= 'n')
Definition: item.php:61
conf_desc($format= '')
Definition: item.php:124
conf_order($format= '')
Definition: item.php:151
getVar($key, $format= 's')
setConfValueForInput(&$value, $force_slash=false)
Definition: item.php:188
getConfOptions()
Definition: item.php:230
conf_value($format= '')
Definition: item.php:115
clearConfOptions()
Definition: item.php:240
getConfValueForOutput()
Definition: item.php:161
const XOBJ_DTYPE_TXTAREA
Definition: XoopsObject.php:21
conf_uid($format= '')
Definition: item.php:88
__construct(Connection $db=null)
Definition: item.php:253
conf_title($format= '')
Definition: item.php:106
setVar($key, $value, $not_gpc=false)
initVar($key, $data_type, $value=null, $required=false, $maxlength=null, $options= '')
conf_name($format= '')
Definition: item.php:97
conf_modid($format= '')
Definition: item.php:79