/** * returns a specific variable for the object in a proper format * * We had to put this method in the icms_ipf_Object because the XOBJ_DTYPE_ARRAY does not work properly * at least on PHP 5.1. So we have created a new type XOBJ_DTYPE_SIMPLE_ARRAY to handle 1 level array * as a string separated by | * * @access public * @param string $key key of the object's variable to be returned * @param string $format format to use for the output * @return mixed formatted value of the variable */ public function getVar($key, $format = 's') { global $myts; $ret = $this->vars[$key]['value']; switch ($this->vars[$key]['data_type']) { case XOBJ_DTYPE_TXTBOX: switch (strtolower($format)) { case 's': case 'show': // ML Hack by marcan $ret = icms_core_DataFilter::htmlSpecialChars($ret); if (method_exists($myts, 'formatForML')) { return $ts->formatForML($ret); } else { return $ret; } break 1; // End of ML Hack by marcan // End of ML Hack by marcan case 'clean': $ret = icms_html2text($ret); $ret = icms_purifyText($ret); return $ret; break 1; // End of ML Hack by marcan // End of ML Hack by marcan case 'e': case 'edit': return icms_core_DataFilter::htmlSpecialChars($ret); break 1; case 'p': case 'preview': case 'f': case 'formpreview': return icms_core_DataFilter::htmlSpecialChars(icms_core_DataFilter::stripSlashesGPC($ret)); break 1; case 'n': case 'none': default: break 1; } break; case XOBJ_DTYPE_LTIME: switch (strtolower($format)) { case 's': case 'show': case 'p': case 'preview': case 'f': case 'formpreview': $ret = formatTimestamp($ret, _DATESTRING); return $ret; break 1; case 'n': case 'none': case 'e': case 'edit': break 1; default: break 1; } break; case XOBJ_DTYPE_STIME: switch (strtolower($format)) { case 's': case 'show': case 'p': case 'preview': case 'f': case 'formpreview': $ret = formatTimestamp($ret, _SHORTDATESTRING); return $ret; break 1; case 'n': case 'none': case 'e': case 'edit': break 1; default: break 1; } break; case XOBJ_DTYPE_TIME_ONLY: switch (strtolower($format)) { case 's': case 'show': case 'p': case 'preview': case 'f': case 'formpreview': $ret = formatTimestamp($ret, 'G:i'); return $ret; break 1; case 'n': case 'none': case 'e': case 'edit': break 1; default: break 1; } break; case XOBJ_DTYPE_CURRENCY: $decimal_section_original = strstr($ret, '.'); $decimal_section = $decimal_section_original; if ($decimal_section) { if (strlen($decimal_section) == 1) { $decimal_section = '.00'; } elseif (strlen($decimal_section) == 2) { $decimal_section = $decimal_section . '0'; } $ret = str_replace($decimal_section_original, $decimal_section, $ret); } else { $ret = $ret . '.00'; } break; case XOBJ_DTYPE_TXTAREA: switch (strtolower($format)) { case 's': case 'show': $ts = icms_core_Textsanitizer::getInstance(); $html = !empty($this->vars['dohtml']['value']) ? 1 : 0; $xcode = !isset($this->vars['doxcode']['value']) || $this->vars['doxcode']['value'] == 1 ? 1 : 0; $smiley = !isset($this->vars['dosmiley']['value']) || $this->vars['dosmiley']['value'] == 1 ? 1 : 0; $image = !isset($this->vars['doimage']['value']) || $this->vars['doimage']['value'] == 1 ? 1 : 0; $br = !isset($this->vars['dobr']['value']) || $this->vars['dobr']['value'] == 1 ? 1 : 0; if (defined('XOOPS_EDITOR_IS_HTML')) { $br = false; } if ($html) { return $ts->displayTarea($ret, $html, $smiley, $xcode, $image, $br); } else { return icms_core_DataFilter::checkVar($ret, 'text', 'output'); } break 1; case 'e': case 'edit': return htmlspecialchars($ret, ENT_QUOTES); break 1; case 'p': case 'preview': $ts = icms_core_Textsanitizer::getInstance(); $html = !empty($this->vars['dohtml']['value']) ? 1 : 0; $xcode = !isset($this->vars['doxcode']['value']) || $this->vars['doxcode']['value'] == 1 ? 1 : 0; $smiley = !isset($this->vars['dosmiley']['value']) || $this->vars['dosmiley']['value'] == 1 ? 1 : 0; $image = !isset($this->vars['doimage']['value']) || $this->vars['doimage']['value'] == 1 ? 1 : 0; $br = !isset($this->vars['dobr']['value']) || $this->vars['dobr']['value'] == 1 ? 1 : 0; if ($html) { return $ts->previewTarea($ret, $html, $smiley, $xcode, $image, $br); } else { return icms_core_DataFilter::checkVar($ret, 'text', 'output'); } break 1; case 'f': case 'formpreview': return htmlspecialchars(icms_core_DataFilter::stripSlashesGPC($ret), ENT_QUOTES); break 1; case 'n': case 'none': default: break 1; } break; case XOBJ_DTYPE_SIMPLE_ARRAY: $ret =& explode('|', $ret); break; case XOBJ_DTYPE_ARRAY: $ret =& unserialize($ret); break; case XOBJ_DTYPE_SOURCE: switch (strtolower($format)) { case 's': case 'show': break 1; case 'e': case 'edit': return htmlspecialchars($ret, ENT_QUOTES); break 1; case 'p': case 'preview': return icms_core_DataFilter::stripSlashesGPC($ret); break 1; case 'f': case 'formpreview': return htmlspecialchars(icms_core_DataFilter::stripSlashesGPC($ret), ENT_QUOTES); break 1; case 'n': case 'none': default: break 1; } break; default: if ($this->vars[$key]['options'] != '' && $ret != '') { switch (strtolower($format)) { case 's': case 'show': $selected = explode('|', $ret); $options = explode('|', $this->vars[$key]['options']); $i = 1; $ret = array(); foreach ($options as $op) { if (in_array($i, $selected)) { $ret[] = $op; } $i++; } return implode(', ', $ret); case 'e': case 'edit': $ret = explode('|', $ret); break 1; default: break 1; } } break; } return $ret; }
/** * * @param $document * @return string Converted text */ public function html2text($document) { return icms_html2text($document); }