Permalink
Browse files

[legacy] make new static function for delegate Legacy_TextFilter.Make...

New static functions
 - Legacy_TextFilter::sMakeClickableConvertTable
 - Legacy_TextFilter::sMakeXCodeConvertTable
 - Legacy_TextFilter::sMakeXCodeCheckImgPatterns
 - Legacy_TextFilter::sMakePreXCodeConvertTable
 - Legacy_TextFilter::sMakePostXCodeConvertTable

Deprecated functions
 - Legacy_TextFilter::makeClickableConvertTable
 - Legacy_TextFilter::makeXCodeConvertTable
 - Legacy_TextFilter::makeXCodeCheckImgPatterns
 - Legacy_TextFilter::makePreXCodeConvertTable
 - Legacy_TextFilter::makePostXCodeConvertTable
  • Loading branch information...
nao-pon committed Apr 19, 2015
1 parent ddc51e7 commit 3c5b707f751d11f08df1242e4fada503a2535526
Showing with 41 additions and 11 deletions.
  1. +41 −11 html/modules/legacy/kernel/Legacy_TextFilter.class.php
@@ -82,23 +82,23 @@ function Legacy_TextFilter()
{
$obj = $this->mMakeClickableConvertTable = new XCube_Delegate;
$obj->register('Legacy_TextFilter.MakeClickableConvertTable');
$obj->add('Legacy_TextFilter::makeClickableConvertTable', XCUBE_DELEGATE_PRIORITY_2);
$obj->add('Legacy_TextFilter::sMakeClickableConvertTable', XCUBE_DELEGATE_PRIORITY_2);
$obj = $this->mMakeXCodeConvertTable = new XCube_Delegate;
$obj->register('Legacy_TextFilter.MakeXCodeConvertTable');
$obj->add('Legacy_TextFilter::makeXCodeConvertTable', XCUBE_DELEGATE_PRIORITY_2);
$obj->add('Legacy_TextFilter::sMakeXCodeConvertTable', XCUBE_DELEGATE_PRIORITY_2);
$obj = $this->mMakeXCodeCheckImgPatterns = new XCube_Delegate;
$obj->register('Legacy_TextFilter.MakeXCodeCheckImgPatterns');
$obj->add('Legacy_TextFilter::makeXCodeCheckImgPatterns', XCUBE_DELEGATE_PRIORITY_2);
$obj->add('Legacy_TextFilter::sMakeXCodeCheckImgPatterns', XCUBE_DELEGATE_PRIORITY_2);
$obj = $this->mMakePreXCodeConvertTable = new XCube_Delegate;
$obj->register('Legacy_TextFilter.MakePreXCodeConvertTable');
$obj->add('Legacy_TextFilter::makePreXCodeConvertTable', XCUBE_DELEGATE_PRIORITY_2);
$obj->add('Legacy_TextFilter::sMakePreXCodeConvertTable', XCUBE_DELEGATE_PRIORITY_2);
$obj = $this->mMakePostXCodeConvertTable = new XCube_Delegate;
$obj->register('Legacy_TextFilter.MakePostXCodeConvertTable');
$obj->add('Legacy_TextFilter::makePostXCodeConvertTable', XCUBE_DELEGATE_PRIORITY_2);
$obj->add('Legacy_TextFilter::sMakePostXCodeConvertTable', XCUBE_DELEGATE_PRIORITY_2);
//@deprecated
//Todo: For keeping compatible with XC2.1 Beta3
@@ -294,7 +294,7 @@ public function makeClickable($text) {
return $text;
}
public function makeClickableConvertTable(&$patterns, &$replacements) {
public static function sMakeClickableConvertTable(&$patterns, &$replacements) {
// URI accept class ref. RFC 1738 (but not strict here)
$hpath = "[-_.!~*\'()a-z0-9;\/?:\@&=+\$,%#]+";
$patterns[] = "/(^|[^]_a-z0-9-=\"'\/])([a-z]+?):\/\/($hpath)/i";
@@ -306,6 +306,12 @@ public function makeClickableConvertTable(&$patterns, &$replacements) {
$patterns[] = "/(^|[^]_a-z0-9-=\"'\/:\.])([a-z0-9\-_\.]+?)@([a-z0-9!#\$%&'\*\+\-\/=\?^_\`{\|}~\.]+)/i";
$replacements[] = "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>";
}
/**
* @deprecated
**/
public function makeClickableConvertTable(&$patterns, &$replacements) {
self::sMakeClickableConvertTable($patterns, $replacements);
}
/**
* Replace XoopsCodes with their equivalent HTML formatting
@@ -376,11 +382,17 @@ function convertXCode($text, $allowimage = 1) {
return $text;
}
public function makeXCodeCheckImgPatterns(&$patterns) {
public static function sMakeXCodeCheckImgPatterns(&$patterns) {
$patterns[] = "/\[img( align=\w+)]([^\"\(\)\?\&'<>]*)\[\/img\]/sU";
}
/**
* @deprecated
**/
public function makeXCodeCheckImgPatterns(&$patterns) {
self::sMakeXCodeCheckImgPatterns($patterns);
}
public function makeXCodeConvertTable(&$patterns, &$replacements) {
public static function sMakeXCodeConvertTable(&$patterns, &$replacements) {
$patterns[] = "/\[siteurl\=(['\"]?)([^\"'<>]*)\\1\](.*)\[\/siteurl\]/sU";
$replacements[0][] = $replacements[1][] = '<a href="'.XOOPS_URL.'/\\2" rel="external">\\3</a>';
$patterns[] = "/\[url\=(['\"]?)(http[s]?:\/\/[^\"'<>]*)\\1\](.*)\[\/url\]/sU";
@@ -426,6 +438,12 @@ public function makeXCodeConvertTable(&$patterns, &$replacements) {
$patterns[] = "/about:/si";
$replacements[0][] = $replacements[1][] = "about :";
}
/**
* @deprecated
**/
public function makeXCodeConvertTable(&$patterns, &$replacements) {
self::sMakeXCodeConvertTable($patterns, $replacements);
}
/**
* Filters out invalid strings included in URL, if any
@@ -514,10 +532,16 @@ function preConvertXCode($text, $xcode = 1) {
return $text;
}
public function makePreXCodeConvertTable(&$patterns, &$replacements) {
public function sMakePreXCodeConvertTable(&$patterns, &$replacements) {
$patterns[] = "/\[code\](.*)\[\/code\]/sU";
$replacements[] = create_function('$m', 'return \'[code]\'.base64_encode($m[1]).\'[/code]\';');
}
/**
* @deprecated
**/
public function makePreXCodeConvertTable(&$patterns, &$replacements) {
self::sMakePreXCodeConvertTable($patterns, $replacements);
}
/**
* Post XCode Convering
@@ -574,18 +598,24 @@ function postConvertXCode($text, $xcode=1, $image=1){
return $text;
}
public function makePostXCodeConvertTable(&$patterns, &$replacements) {
public static function sMakePostXCodeConvertTable(&$patterns, &$replacements) {
$patterns[] = "/\[code\](.*)\[\/code\]/sU";
if (version_compare(PHP_VERSION, '5.2.3', '>=')) {
$replacements[0][] = 'Legacy_TextFilter::codeSanitizerCallback0';
$replacements[1][] = 'Legacy_TextFilter::codeSanitizerCallback1';
} else {
$root =& XCube_Root::getSingleton();
$me =& $root->getTextFilter();
$replacements[0][] = array(&$me, 'Legacy_TextFilter::codeSanitizerCallback0');
$replacements[0][] = array(&$me, 'Legacy_TextFilter::codeSanitizerCallback0');
$replacements[1][] = array(&$me, 'Legacy_TextFilter::codeSanitizerCallback1');
}
}
/**
* @deprecated
**/
public function makePostXCodeConvertTable(&$patterns, &$replacements) {
self::sMakePostXCodeConvertTable($patterns, $replacements);
}
private function codeSanitizerCallback($m, $image) {
$text = $this->convertXCode(htmlspecialchars(base64_decode($m[1]), ENT_QUOTES, _CHARSET), $image);

0 comments on commit 3c5b707

Please sign in to comment.