function html2text($document) { return smart_html2text($document); }
/** * returns a specific variable for the object in a proper format * * We had to put this method in the SmartObject 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 */ 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 $ts =& MyTextSanitizer::getInstance(); $ret = $ts->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': $ts =& MyTextSanitizer::getInstance(); $ret = smart_html2text($ret); $ret = smart_purifyText($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 'e': case 'edit': $ts =& MyTextSanitizer::getInstance(); return $ts->htmlSpecialChars($ret); break 1; case 'p': case 'preview': case 'f': case 'formpreview': $ts =& MyTextSanitizer::getInstance(); return $ts->htmlSpecialChars($ts->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 =& MyTextSanitizer::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; /** * Hack by marcan <INBOX> for SCSPRO * Setting mastop as the main editor */ if (defined('XOOPS_EDITOR_IS_HTML')) { $br = false; } /** * Hack by marcan <INBOX> for SCSPRO * Setting mastop as the main editor */ return $ts->displayTarea($ret, $html, $smiley, $xcode, $image, $br); break 1; case 'e': case 'edit': return htmlspecialchars($ret, ENT_QUOTES); break 1; case 'p': case 'preview': $ts =& MyTextSanitizer::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; return $ts->previewTarea($ret, $html, $smiley, $xcode, $image, $br); break 1; case 'f': case 'formpreview': $ts =& MyTextSanitizer::getInstance(); return htmlspecialchars($ts->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': $ts =& MyTextSanitizer::getInstance(); return $ts->stripSlashesGPC($ret); break 1; case 'f': case 'formpreview': $ts =& MyTextSanitizer::getInstance(); return htmlspecialchars($ts->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; }