25 public $mTextFilter =
null;
31 public $mMakeClickablePostFilter =
null;
37 public $mXoopsCodePostFilter =
null;
53 $this->mMakeClickablePostFilter->register(
'MyTextSanitizer.MakeClickablePostFilter');
56 $this->mXoopsCodePostFilter->register(
'MyTextSanitizer.XoopsCodePostFilter');
58 $root =& XCube_Root::getSingleton();
59 $this->mTextFilter =& $root->getTextFilter();
73 if (!isset($instance)) {
86 return $this->mTextFilter->getSmileys();
97 $text = $this->mTextFilter->smiley($text);
109 $text = $this->mTextFilter->makeClickable($text);
116 $this->mMakeClickablePostFilter->call(
new XCube_Ref($text));
130 $text = $this->mTextFilter->convertXCode($text, $allowimage);
138 $this->mXoopsCodePostFilter->call(
new XCube_Ref($text), $allowimage);
166 if (preg_match(
"/[\\0-\\31]/", $text)) {
170 return !preg_match(
'/^(javascript|vbscript|about):/i', $text);
182 $ret = $this->mTextFilter->nl2Br($text);
195 if (!mb_check_encoding($text,
'UTF-8')) {
196 $text = mb_convert_encoding($text,
'UTF-8',
'auto');
200 if (function_exists(
'mb_ereg_replace')) {
201 return mb_ereg_replace(
'([\'\"\\\\])',
'\\\\\\1', $text);
203 return addslashes($text);
214 public function &stripSlashesGPC($text)
217 $text = (string)$text;
220 if (!mb_check_encoding($text,
'UTF-8')) {
221 $text = mb_convert_encoding($text,
'UTF-8',
'auto');
225 if (function_exists(
'mb_ereg_replace')) {
226 $text = mb_ereg_replace(
'\\\\([\'\"\\\\])',
'\\1', (
string)$text);
240 public function &htmlSpecialChars($text, $forEdit=
false)
243 $ret = $this->mTextFilter->toShow($text,
true);
245 $ret = $this->mTextFilter->toEdit($text);
259 $ret = preg_replace([
'/>/i',
'/</i',
'/"/i',
'/'/i'], [
'>',
'<',
'"',
"'"], $text);
276 public function _ToShowTarea($text, $html = 0, $smiley = 1, $xcode = 1, $image = 1, $br = 1)
280 $text = $this->htmlSpecialChars($text);
284 $text = $this->
smiley($text);
290 $text = $this->
nl2Br($text);
292 $text = $this->codeConv($text, $xcode, $image);
307 public function &
displayTarea($text, $html = 0, $smiley = 1, $xcode = 1, $image = 1, $br = 1)
309 $text = $this->mTextFilter->toShowTarea($text, $html, $smiley, $xcode, $image, $br,
true);
324 public function &
previewTarea($text, $html = 0, $smiley = 1, $xcode = 1, $image = 1, $br = 1)
326 $text =& $this->stripSlashesGPC($text);
327 $text = $this->mTextFilter->toPreviewTarea($text, $html, $smiley, $xcode, $image, $br,
true);
341 if (!isset($this->censorConf)) {
342 $config_handler =& xoops_gethandler(
'config');
343 $this->censorConf =& $config_handler->getConfigsByCat(XOOPS_CONF_CENSOR);
345 if (1 == $this->censorConf[
'censor_enable']) {
346 $replacement = $this->censorConf[
'censor_replace'];
347 foreach ($this->censorConf[
'censor_words'] as $bad) {
349 $bad = quotemeta($bad);
350 $patterns[] =
"/(\s)".$bad .
'/siU';
351 $replacements[] =
"\\1".$replacement;
352 $patterns[] =
'/^' . $bad .
'/siU';
353 $replacements[] = $replacement;
354 $patterns[] =
"/(\n)".$bad .
'/siU';
355 $replacements[] =
"\\1".$replacement;
356 $patterns[] =
'/]' . $bad .
'/siU';
357 $replacements[] =
']' . $replacement;
358 $text = preg_replace($patterns, $replacements, $text);
374 $text = $this->mTextFilter->preConvertXCode($text, $xcode);
379 public function codeConv($text, $xcode = 1, $image = 1)
382 $text = $this->mTextFilter->postConvertXCode($text, $xcode);
387##################### Deprecated Methods ######################
399 $text = $this->
_ToShowTarea($text, $allowhtml, $smiley, $bbcode, 1, 1);
403 public function sanitizeForPreview($text, $allowhtml = 0, $smiley = 1, $bbcode = 1)
405 $text = $this->oopsStripSlashesGPC($text);
406 $text = $this->
_ToShowTarea($text, $allowhtml, $smiley, $bbcode, 1, 1);
410 public function makeTboxData4Save($text)
415 public function makeTboxData4Show($text, $smiley=0)
417 return $this->mTextFilter->toShow($text,
true);
420 public function makeTboxData4Edit($text)
422 return $this->mTextFilter->toEdit($text);
425 public function makeTboxData4Preview($text, $smiley=0)
427 $text = $this->stripSlashesGPC($text);
428 $text = $this->mTextFilter->toShow($text,
true);
432 public function makeTboxData4PreviewInForm($text)
434 $text = $this->stripSlashesGPC($text);
435 return $this->mTextFilter->toEdit($text);
438 public function makeTareaData4Save($text)
443 public function &makeTareaData4Show($text, $html=1, $smiley=1, $xcode=1)
445 $ret = $this->
displayTarea($text, $html, $smiley, $xcode);
449 public function makeTareaData4Edit($text)
451 return $this->mTextFilter->toEdit($text);
454 public function &makeTareaData4Preview($text, $html=1, $smiley=1, $xcode=1)
456 $ret = $this->
previewTarea($text, $html, $smiley, $xcode);
460 public function makeTareaData4PreviewInForm($text)
463 $text = $this->stripSlashesGPC($text);
464 return $this->mTextFilter->toEdit($text);
467 public function makeTareaData4InsideQuotes($text)
469 return $this->mTextFilter->toShow($text,
true);
472 public function &oopsStripSlashesGPC($text)
474 $ret = $this->stripSlashesGPC($text);
478 public function &oopsStripSlashesRT($text)
480 if (get_magic_quotes_runtime()) {
481 $text =& stripslashes($text);
486 public function &oopsAddSlashes($text)
492 public function &oopsHtmlSpecialChars($text)
494 $ret = $this->mTextFilter->toShow($text,
true);
498 public function &oopsNl2Br($text)
500 $ret = $this->nl2br($text);
504 public static function &getInstance()
sanitizeForDisplay($text, $allowhtml=0, $smiley=1, $bbcode=1)
& displayTarea($text, $html=0, $smiley=1, $xcode=1, $image=1, $br=1)
_ToShowTarea($text, $html=0, $smiley=1, $xcode=1, $image=1, $br=1)
& xoopsCodeDecode($text, $allowimage=1)
& previewTarea($text, $html=0, $smiley=1, $xcode=1, $image=1, $br=1)
codePreConv($text, $xcode=1)