XOOPS  2.6.0
DtypeAbstract.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 
13 
15 
27 abstract class DtypeAbstract
28 {
32  protected $db;
33 
37  protected $ts;
38 
42  public function init()
43  {
44  $this->db = \Xoops::getInstance()->db();
45  $this->ts = \MyTextSanitizer::getInstance();
46  }
47 
55  public function cleanVar(XoopsObject $obj, $key, $quote = true)
56  {
57  $value = $obj->vars[$key]['value'];
58  if ($quote) {
59  $value = str_replace('\\"', '"', $this->db->quote($value));
60  }
61  return $value;
62  }
63 
71  public function getVar(XoopsObject $obj, $key, $format)
72  {
73  $value = $obj->vars[$key]['value'];
74  if ($obj->vars[$key]['options'] != '' && $value != '') {
75  switch (strtolower($format)) {
76  case 's':
77  case 'show':
78  $selected = explode('|', $value);
79  $options = explode('|', $obj->vars[$key]['options']);
80  $i = 1;
81  $ret = array();
82  foreach ($options as $op) {
83  if (in_array($i, $selected)) {
84  $ret[] = $op;
85  }
86  ++$i;
87  }
88  return implode(', ', $ret);
89  case 'e':
90  case 'edit':
91  return explode('|', $value);
92  default:
93  }
94  }
95  return $value;
96  }
97 }
db()
Definition: Xoops.php:175
$i
Definition: dialog.php:68
static getInstance()
Definition: Xoops.php:160
getVar(XoopsObject $obj, $key, $format)
$options['editor']
cleanVar(XoopsObject $obj, $key, $quote=true)
$op