Permalink
Browse files

[php56] static method MyTextSanitizer::sGetInstance()

recomend replace `MyTextSanitizer::getInstance()` to
`MyTextSanitizer::sGetInstance()` in any module.

ex.

`$ts =& MyTextSanitizer::getInstance();`

to

`(method_exists('MyTextSanitizer', 'sGetInstance') and $ts =&
MyTextSanitizer::sGetInstance()) || $ts =&
MyTextSanitizer::getInstance();`
  • Loading branch information...
nao-pon committed Apr 14, 2015
1 parent 2e75024 commit 73e5e54328a062f277e29744e140977a87c11457
View
@@ -280,7 +280,7 @@ function clickbanner($bid)
} elseif (!empty($_GET['op'])) {
$op = $_GET['op'];
}
-$myts =& MyTextSanitizer::getInstance();
+$myts =& MyTextSanitizer::sGetInstance();
switch ( $op ) {
case "click":
$bid = 0;
@@ -74,7 +74,7 @@ function XoopsErrorHandler()
*
* @access public
*/
- function &getInstance()
+ static public function &getInstance()
{
static $instance = null;
if (empty($instance)) {
@@ -98,7 +98,7 @@ function MyTextSanitizer()
* @static
* @staticvar object
*/
- public function &getInstance()
+ static public function &sGetInstance()
{
static $instance;
if (!isset($instance)) {
@@ -497,6 +497,12 @@ function &oopsNl2Br($text)
$ret = $this->nl2br($text);
return $ret;
}
+
+ public function &getInstance()
+ {
+ $ret = self::sGetInstance();
+ return $ret;
+ }
/**#@-*/
}
?>
@@ -409,7 +409,7 @@ function renderValidationJS( $withtags = true ) {
if ( $withtags ) {
$js .= "\n<!-- Start Form Vaidation JavaScript //-->\n<script type='text/javascript'>\n<!--//\n";
}
- $myts =& MyTextSanitizer::getInstance();
+ $myts =& MyTextSanitizer::sGetInstance();
$formname = $this->getName();
$required =& $this->getRequired();
$reqcount = count($required);
@@ -556,7 +556,7 @@ function &getHtmlList()
function &getUserRankList()
{
$db =& Database::getInstance();
- $myts =& MyTextSanitizer::getInstance();
+ $myts =& MyTextSanitizer::sGetInstance();
$sql = "SELECT rank_id, rank_title FROM ".$db->prefix("ranks")." WHERE rank_special = 1";
$ret = array();
$result = $db->query($sql);
@@ -165,7 +165,7 @@ function setComments($value)
function store($approved=false)
{
//$newpost = 0;
- $myts =& MyTextSanitizer::getInstance();
+ $myts =& MyTextSanitizer::sGetInstance();
$title =$myts->censorString($this->title);
$hometext =$myts->censorString($this->hometext);
$bodytext =$myts->censorString($this->bodytext);
@@ -273,7 +273,7 @@ function uname()
function title($format="Show")
{
- $myts =& MyTextSanitizer::getInstance();
+ $myts =& MyTextSanitizer::sGetInstance();
$smiley = 1;
if ( $this->nosmiley() ) {
$smiley = 0;
@@ -297,7 +297,7 @@ function title($format="Show")
function hometext($format="Show")
{
- $myts =& MyTextSanitizer::getInstance();
+ $myts =& MyTextSanitizer::sGetInstance();
$html = 1;
$smiley = 1;
$xcodes = 1;
@@ -326,7 +326,7 @@ function hometext($format="Show")
function bodytext($format="Show")
{
- $myts =& MyTextSanitizer::getInstance();
+ $myts =& MyTextSanitizer::sGetInstance();
$html = 1;
$smiley = 1;
$xcodes = 1;
@@ -94,7 +94,7 @@ function usePermission($mid)
function store()
{
- $myts =& MyTextSanitizer::getInstance();
+ $myts =& MyTextSanitizer::sGetInstance();
$title = "";
$imgurl = "";
if ( isset($this->topic_title) && $this->topic_title != "" ) {
@@ -204,7 +204,7 @@ function topic_pid()
function topic_title($format="S")
{
- $myts =& MyTextSanitizer::getInstance();
+ $myts =& MyTextSanitizer::sGetInstance();
switch($format){
case "S":
$title = $myts->makeTboxData4Show($this->topic_title);
@@ -224,7 +224,7 @@ function topic_title($format="S")
function topic_imgurl($format="S")
{
- $myts =& MyTextSanitizer::getInstance();
+ $myts =& MyTextSanitizer::sGetInstance();
switch($format){
case "S":
$imgurl= $myts->makeTboxData4Show($this->topic_imgurl);
@@ -319,7 +319,7 @@ function &getTopicsList()
{
$result = $this->db->query('SELECT topic_id, topic_pid, topic_title FROM '.$this->table);
$ret = array();
- $myts =& MyTextSanitizer::getInstance();
+ $myts =& MyTextSanitizer::sGetInstance();
while ($myrow = $this->db->fetchArray($result)) {
$ret[$myrow['topic_id']] = array('title' => $myts->htmlSpecialChars($myrow['topic_title']), 'pid' => $myrow['topic_pid']);
}
View
@@ -128,7 +128,7 @@ function getPathFromId($sel_id, $title, $path="")
return $path;
}
list($parentid,$name) = $this->db->fetchRow($result);
- $myts =& MyTextSanitizer::getInstance();
+ $myts =& MyTextSanitizer::sGetInstance();
$name = $myts->makeTboxData4Show($name);
$path = "/".$name.$path."";
if ( $parentid == 0 ) {
@@ -146,7 +146,7 @@ function makeMySelBox($title,$order="",$preset_id=0, $none=0, $sel_name="", $onc
if ( $sel_name == "" ) {
$sel_name = $this->id;
}
- $myts =& MyTextSanitizer::getInstance();
+ $myts =& MyTextSanitizer::sGetInstance();
echo "<select name='".$sel_name."'";
if ( $onchange != "" ) {
echo " onchange='".$onchange."'";
@@ -190,7 +190,7 @@ function getNicePathFromId($sel_id, $title, $funcURL, $path="")
return $path;
}
list($parentid,$name) = $this->db->fetchRow($result);
- $myts =& MyTextSanitizer::getInstance();
+ $myts =& MyTextSanitizer::sGetInstance();
$name = $myts->makeTboxData4Show($name);
$path = "<a href='".$funcURL."&amp;".$this->id."=".$sel_id."'>".$name."</a>&nbsp;:&nbsp;".$path."";
if ( $parentid == 0 ) {
@@ -105,7 +105,7 @@
if ('system' != $xoopsModule->getVar('dirname')) {
$comment_config = $xoopsModule->getInfo('comments');
if (isset($comment_config['extraParams']) && is_array($comment_config['extraParams'])) {
- $myts =& MyTextSanitizer::getInstance();
+ $myts =& MyTextSanitizer::sGetInstance();
foreach ($comment_config['extraParams'] as $extra_param) {
// This routine is included from forms accessed via both GET and POST
if (isset($_POST[$extra_param])) {
@@ -61,7 +61,7 @@
if (isset($com_replytext)) {
themecenterposts($com_replytitle, $com_replytext);
}
- $myts =& MyTextSanitizer::getInstance();
+ $myts =& MyTextSanitizer::sGetInstance();
$com_title = $myts->htmlSpecialChars($com_replytitle);
if (!preg_match("/^re:/i", $com_title)) {
$com_title = "Re: ".xoops_substr($com_title, 0, 56);
@@ -61,7 +61,7 @@
$com_modid = $xoopsModule->getVar('mid');
$redirect_page = $comment_config['pageName'].'?';
if (isset($comment_config['extraParams']) && is_array($comment_config['extraParams'])) {
- $myts =& MyTextSanitizer::getInstance();
+ $myts =& MyTextSanitizer::sGetInstance();
foreach ($comment_config['extraParams'] as $extra_param) {
$extra_params .= isset($_POST[$extra_param]) ? $extra_param.'='.$myts->stripSlashesGPC($_POST[$extra_param]).'&amp;' : $extra_param.'=&amp;';
}
@@ -112,7 +112,7 @@
include XOOPS_ROOT_PATH.'/include/comment_delete.php';
break;
case "preview":
- $myts =& MyTextSanitizer::getInstance();
+ $myts =& MyTextSanitizer::sGetInstance();
$doimage = 1;
$com_title = $myts->htmlSpecialChars($myts->stripSlashesGPC($_POST['com_title']));
if ($dohtml != 0) {
@@ -648,7 +648,7 @@ function &xoops_getmodulehandler($name = null, $module_dir = null, $optional = f
function xoops_getrank($rank_id =0, $posts = 0)
{
$db =& Database::getInstance();
- $myts =& MyTextSanitizer::getInstance();
+ $myts =& MyTextSanitizer::sGetInstance();
$rank_id = (int)$rank_id;
if ($rank_id != 0) {
$sql = 'SELECT rank_title AS title, rank_image AS image, rank_id AS id FROM '.$db->prefix('ranks').' WHERE rank_id = '.$rank_id;
@@ -80,7 +80,7 @@ function xoopsCodeTarea($textarea_id, $cols=60, $rows=15, $suffix=null)
*/
function xoopsSmilies($textarea_id)
{
- $myts =& MyTextSanitizer::getInstance();
+ $myts =& MyTextSanitizer::sGetInstance();
$smiles = $myts->getSmileys();
if (empty($smiles)) {
$db =& Database::getInstance();
@@ -45,7 +45,7 @@ function TextSanitizer()
}
- function &getInstance()
+ static public function &getInstance()
{
static $instance;
if (!isset($instance)) {
View
@@ -13,7 +13,7 @@
*------------------------------------------------------------------------*/
if (version_compare(PHP_VERSION, '5.4.0', '>=') && error_reporting() === E_ALL) {
- error_reporting(E_ALL ^ E_STRICT);
+ error_reporting(E_ALL ^ E_STRICT ^ E_DEPRECATED);
}
include_once './passwd.php';
View
@@ -146,10 +146,10 @@ function &getContent($format = 'S', $c_type = 'T')
ob_end_clean();
$ret = str_replace('{X_SITEURL}', XOOPS_URL.'/', $content);
} elseif ( $c_type == 'S' ) {
- $myts =& MyTextSanitizer::getInstance();
+ $myts =& MyTextSanitizer::sGetInstance();
$ret = str_replace('{X_SITEURL}', XOOPS_URL.'/', $myts->displayTarea($this->get('content'), 1, 1));
} else {
- $myts =& MyTextSanitizer::getInstance();
+ $myts =& MyTextSanitizer::sGetInstance();
$ret = str_replace('{X_SITEURL}', XOOPS_URL.'/', $myts->displayTarea($this->get('content'), 1, 0));
}
break;
View
@@ -142,29 +142,22 @@ function getRoledModuleList()
*
* @return string
*/
- function &getConfValueForOutput()
+ function getConfValueForOutput()
{
switch ($this->getVar('conf_valuetype')) {
case 'int':
- $ret = (int)$this->getVar('conf_value', 'N');
- return $ret;
+ return (int)$this->getVar('conf_value', 'N');
case 'array':
- $ret = unserialize($this->getVar('conf_value', 'N'));
- return $ret;
+ return unserialize($this->getVar('conf_value', 'N'));
case 'float':
- $ret = (float)$this->getVar('conf_value', 'N');
- return $ret;
+ return (float)$this->getVar('conf_value', 'N');
case 'textarea':
return $this->getVar('conf_value');
case 'encrypt':
- $ret = XCube_Utils::decrypt($this->getVar('conf_value', 'N'));
- return $ret;
+ return XCube_Utils::decrypt($this->getVar('conf_value', 'N'));
default:
return $this->getVar('conf_value', 'N');
}
-
- $ret = null;
- return $ret;
}
/**
View
@@ -133,7 +133,7 @@ function &getUserByEmail($email)
{
$returnUser = null;
- $myts =& MyTextSanitizer::getInstance(); ///< @todo not depends
+ $myts =& MyTextSanitizer::sGetInstance(); ///< @todo not depends
$users =& $this->getUsers(new Criteria('email', $myts->addSlashes($email)));
if(!is_array($users)) {
View
@@ -343,13 +343,13 @@ function &getVar($key, $format = 's')
case 'show':
case 'e':
case 'edit':
- $ts =& MyTextSanitizer::getInstance();
+ $ts =& MyTextSanitizer::sGetInstance();
return $ts->htmlSpecialChars($ret);
case 'p':
case 'preview':
case 'f':
case 'formpreview':
- $ts =& MyTextSanitizer::getInstance();
+ $ts =& MyTextSanitizer::sGetInstance();
return $ts->htmlSpecialChars($ts->stripSlashesGPC($ret));
default:
return $ret;
@@ -358,7 +358,7 @@ function &getVar($key, $format = 's')
switch (strtolower($format)) {
case 's':
case 'show':
- $ts =& MyTextSanitizer::getInstance();
+ $ts =& MyTextSanitizer::sGetInstance();
$vars =&$this->vars;
$html = !empty($vars['dohtml']['value']) ? 1 : 0;
$xcode = (!isset($vars['doxcode']['value']) || $vars['doxcode']['value'] == 1) ? 1 : 0;
@@ -372,7 +372,7 @@ function &getVar($key, $format = 's')
return $ret;
case 'p':
case 'preview':
- $ts =& MyTextSanitizer::getInstance();
+ $ts =& MyTextSanitizer::sGetInstance();
$vars =&$this->vars;
$html = !empty($vars['dohtml']['value']) ? 1 : 0;
$xcode = (!isset($vars['doxcode']['value']) || $vars['doxcode']['value'] == 1) ? 1 : 0;
@@ -382,7 +382,7 @@ function &getVar($key, $format = 's')
return $ts->previewTarea($ret, $html, $smiley, $xcode, $image, $br);
case 'f':
case 'formpreview':
- $ts =& MyTextSanitizer::getInstance();
+ $ts =& MyTextSanitizer::sGetInstance();
return htmlspecialchars($ts->stripSlashesGPC($ret), ENT_QUOTES);
default:
return $ret;
@@ -397,11 +397,11 @@ function &getVar($key, $format = 's')
return htmlspecialchars($ret, ENT_QUOTES);
case 'p':
case 'preview':
- $ts =& MyTextSanitizer::getInstance();
+ $ts =& MyTextSanitizer::sGetInstance();
return $ts->stripSlashesGPC($ret);
case 'f':
case 'formpreview':
- $ts =& MyTextSanitizer::getInstance();
+ $ts =& MyTextSanitizer::sGetInstance();
$ret = htmlspecialchars($ts->stripSlashesGPC($ret), ENT_QUOTES);
return $ret;
default:
@@ -487,7 +487,7 @@ function getProperties()
*/
function cleanVars()
{
- $ts =& MyTextSanitizer::getInstance();
+ $ts =& MyTextSanitizer::sGetInstance();
foreach ($this->vars as $k => $v) {
$cleanv = $v['value'];
if (!$v['changed']) {
@@ -63,7 +63,9 @@ <h3 class="admintitle"><{$smarty.const._MI_LEGACY_MENU_MODULELIST}></h3>
<tr class="<{cycle values='odd,even'}>">
<{/if}>
<td class="legacy_list_id"><{$module->getVar('mid')}></td>
- <td class="legacy_list_image"><img src="<{$xoops_url}>/modules/<{$module->getVar('dirname')}>/<{$module->modinfo.image}>" alt="<{$module->getVar('name')}>" /><br />
+ <td class="legacy_list_image">
+ <{if $module->getVar('hasadmin')}><a href="<{$xoops_url}>/modules/<{$module->getVar('dirname')}>/<{$module->modinfo.adminindex}>"><{/if}><img src="<{$xoops_url}>/modules/<{$module->getVar('dirname')}>/<{$module->modinfo.image}>" alt="<{$module->getVar('name')}>" /><{if $module->getVar('hasadmin')}></a><{/if}>
+ <br />
<input type="text" size="24" name="name[<{$module->getVar('mid')}>]" value="<{$module->getVar('name')}>" /></td>
<td class="legacy_list_order">
<{if $module->hasNeedUpdate()}>
@@ -22,7 +22,7 @@
function b_legacy_siteinfo_show($options) {
global $xoopsConfig, $xoopsUser;
$xoopsDB =& Database::getInstance();
- $myts =& MyTextSanitizer::getInstance();
+ $myts =& MyTextSanitizer::sGetInstance();
$block = array();
if (!empty($options[3])) {
$block['showgroups'] = true;
@@ -73,7 +73,7 @@ function loadStatus()
function getVar($key)
{
if ($key == 'com_text') {
- $ts =& MyTextSanitizer::getInstance();
+ $ts =& MyTextSanitizer::sGetInstance();
return $ts->displayTarea($this->get($key), $this->get('dohtml'), $this->get('dosmiley'), $this->get('doxcode'), $this->get('doimage'), $this->get('dobr'));
}
else {
@@ -48,7 +48,7 @@ function fetch()
$t_queries = array();
- $myts =& MyTextSanitizer::getInstance();
+ $myts =& MyTextSanitizer::sGetInstance();
if ($this->get('andor') == 'exact' && strlen($this->get('query')) >= $this->_mKeywordMin) {
$this->mQueries[] = $myts->addSlashes($this->get('query'));
}
@@ -485,7 +485,7 @@ function sendHeader()
function showXoopsHeader($closeHead=true)
{
global $xoopsConfig;
- $myts =& MyTextSanitizer::getInstance();
+ $myts =& MyTextSanitizer::sGetInstance();
if ($xoopsConfig['gzip_compression'] == 1) {
ob_start('ob_gzhandler');
} else {

0 comments on commit 73e5e54

Please sign in to comment.