XOOPS  2.6.0
DtypeArray.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 
12 namespace Xoops\Core\Kernel\Dtype;
13 
16 
29 {
37  public function getVar(XoopsObject $obj, $key, $format)
38  {
39  $value = $obj->vars[$key]['value'];
40  switch (strtolower($format)) {
41  case 'n':
42  case 'none':
43  return $value;
44  default:
45  if (!is_array($value)) {
46  if ($value != '') {
47  $value = unserialize($value);
48  }
49  $value = is_array($value) ? $value : array();
50  }
51  return $value;
52  }
53  }
54 
62  public function cleanVar(XoopsObject $obj, $key, $quote = true)
63  {
64  $value = $obj->vars[$key]['value'];
65  $value = (array)$value;
66  if (!$obj->vars[$key]['not_gpc']) {
67  $value = array_map(array(&$this->ts, "stripSlashesGPC"), $value);
68  }
69  foreach (array_keys($value) as $key) {
70  if ($quote) {
71  $value[$key] = str_replace('\\"', '"', addslashes($value[$key]));
72  }
73  }
74  // TODO: Not encoding safe, should try base64_encode -- phppp
75  $value = serialize($value);
76  return $value;
77  }
78 }
getVar(XoopsObject $obj, $key, $format)
Definition: DtypeArray.php:37
cleanVar(XoopsObject $obj, $key, $quote=true)
Definition: DtypeArray.php:62