XOOPS  2.6.0
DtypeTextarea.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 's':
42  case 'show':
43  $html = !empty($obj->vars['dohtml']['value']) ? 1 : 0;
44  $xcode = (!isset($obj->vars['doxcode']['value']) || $obj->vars['doxcode']['value'] == 1) ? 1 : 0;
45  $smiley = (!isset($obj->vars['dosmiley']['value']) || $obj->vars['dosmiley']['value'] == 1) ? 1 : 0;
46  $image = (!isset($obj->vars['doimage']['value']) || $obj->vars['doimage']['value'] == 1) ? 1 : 0;
47  $br = (!isset($obj->vars['dobr']['value']) || $obj->vars['dobr']['value'] == 1) ? 1 : 0;
48  return $this->ts->displayTarea($value, $html, $smiley, $xcode, $image, $br);
49 
50  case 'e':
51  case 'edit':
52  return htmlspecialchars($value, ENT_QUOTES);
53  case 'p':
54  case 'preview':
55  $html = !empty($obj->vars['dohtml']['value']) ? 1 : 0;
56  $xcode = (!isset($obj->vars['doxcode']['value']) || $obj->vars['doxcode']['value'] == 1) ? 1 : 0;
57  $smiley = (!isset($obj->vars['dosmiley']['value']) || $obj->vars['dosmiley']['value'] == 1) ? 1 : 0;
58  $image = (!isset($obj->vars['doimage']['value']) || $obj->vars['doimage']['value'] == 1) ? 1 : 0;
59  $br = (!isset($obj->vars['dobr']['value']) || $obj->vars['dobr']['value'] == 1) ? 1 : 0;
60  return $this->ts->previewTarea($value, $html, $smiley, $xcode, $image, $br);
61  case 'f':
62  case 'formpreview':
63  return htmlspecialchars($this->ts->stripSlashesGPC($value), ENT_QUOTES);
64  case 'n':
65  case 'none':
66  default:
67  return $value;
68  }
69  }
70 
78  public function cleanVar(XoopsObject $obj, $key, $quote = true)
79  {
80  $value = $obj->vars[$key]['value'];
81  if ($obj->vars[$key]['required'] && $value != '0' && $value == '') {
82  $obj->setErrors(sprintf(\XoopsLocale::F_IS_REQUIRED, $key));
83  return $value;
84  }
85  if (!$obj->vars[$key]['not_gpc']) {
86  $value = $this->ts->stripSlashesGPC($this->ts->censorString($value));
87  } else {
88  $value = $this->ts->censorString($value);
89  }
90  if ($quote) {
91  $value = str_replace('\\"', '"', $this->db->quote($value));
92  }
93  return $value;
94  }
95 }
db()
Definition: Xoops.php:175
cleanVar(XoopsObject $obj, $key, $quote=true)
if(empty($image_id)) $image
Definition: image.php:37
if(!$xoops->security() ->validateToken(@$_POST['token'], false)) $html
const F_IS_REQUIRED
Definition: en_US.php:418
getVar(XoopsObject $obj, $key, $format)