Fix some deprecated create_function for theme templates
parent
13cb905610
commit
31ec02e169
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
Class name: Themes
|
Class name: Themes
|
||||||
Class autor: Victor De la Rocha http//mis-algoritmos.com/themes-class
|
Class autor: Victor De la Rocha http//mis-algoritmos.com/themes-class
|
||||||
Email: vyk2rr [at] gmail [dot] com
|
Email: vyk2rr [at] gmail [dot] com
|
||||||
*/
|
*/
|
||||||
class themes
|
class themes
|
||||||
{
|
{
|
||||||
|
|
@ -80,15 +80,78 @@ class themes
|
||||||
$this->output = $headers.trim($this->output);
|
$this->output = $headers.trim($this->output);
|
||||||
|
|
||||||
//finding IFs sentences and converting to php code
|
//finding IFs sentences and converting to php code
|
||||||
|
//echo htmlspecialchars($this->output);
|
||||||
#$this->output = preg_replace_callback("/{if ([^}]+)}/",create_function('$arr','return "\";if(".stripslashes($arr[1])."){echo\"";'),$this->output);
|
#$this->output = preg_replace_callback("/{if ([^}]+)}/",create_function('$arr','return "\";if(".stripslashes($arr[1])."){echo\"";'),$this->output);
|
||||||
$this->output = preg_replace_callback("/{if ([^}]+)}/", create_function('$arr', 'return "\";if(".stripslashes(preg_replace(array("/\\\\$([a-zA-Z0-9_]+)/s","/\\\\\\$this->vars\[\\\'([a-zA-Z0-9_]+)\\\'\]\.([a-zA-Z0-9_]+)/s"),array("\$this->vars[\'\$1\']","\\\\\\$this->vars[\\\'$1\\\'][\\\'$2\\\']"),$arr[1]))."){echo\"";'), $this->output);
|
// $this->output = preg_replace_callback("/{if ([^}]+)}/", create_function('$arr', 'return "\";if(".stripslashes(preg_replace(array("/\\\\$([a-zA-Z0-9_]+)/s","/\\\\\\$this->vars\[\\\'([a-zA-Z0-9_]+)\\\'\]\.([a-zA-Z0-9_]+)/s"),array("\$this->vars[\'\$1\']","\\\\\\$this->vars[\\\'$1\\\'][\\\'$2\\\']"),$arr[1]))."){echo\"";'), $this->output);
|
||||||
|
// echo htmlspecialchars($this->output);
|
||||||
|
$this->output = preg_replace_callback("/{if ([^}]+)}/", function ($arr) {
|
||||||
|
return "\"; if (" . stripslashes(preg_replace(
|
||||||
|
array("/\\$([a-zA-Z0-9_]+)/s", "/\\\$this->vars\['([a-zA-Z0-9_]+)'\]\.([a-zA-Z0-9_]+)/s"),
|
||||||
|
array("\$this->vars['\$1']", "\\\$this->vars['$1']['$2']"),
|
||||||
|
$arr[1]
|
||||||
|
)) . ") { echo \"";
|
||||||
|
}, $this->output);
|
||||||
|
|
||||||
$this->output = preg_replace("/{else}/", "\";}else{echo\"", $this->output);
|
$this->output = preg_replace("/{else}/", "\";}else{echo\"", $this->output);
|
||||||
$this->output = preg_replace_callback("/{elseif ([^}]+)}/", create_function('$arr', 'return "\";}elseif(".stripslashes(preg_replace(array("/\\\\$([a-zA-Z0-9]+)/s","/\\\\\\$this->vars\[\\\'([a-zA-Z0-9]+)\\\'\]\.([a-zA-Z0-9]+)/s"),array("\$this->vars[\'\$1\']","\\\\\\$this->vars[\\\'$1\\\'][\\\'$2\\\']"),$arr[1]))."){echo\"";'), $this->output);
|
// $this->output = preg_replace_callback("/{elseif ([^}]+)}/", create_function('$arr', 'return "\";}elseif(".stripslashes(preg_replace(array("/\\\\$([a-zA-Z0-9]+)/s","/\\\\\\$this->vars\[\\\'([a-zA-Z0-9]+)\\\'\]\.([a-zA-Z0-9]+)/s"),array("\$this->vars[\'\$1\']","\\\\\\$this->vars[\\\'$1\\\'][\\\'$2\\\']"),$arr[1]))."){echo\"";'), $this->output);
|
||||||
$this->output = preg_replace("/{\/if}/", "\";} echo \"", $this->output);
|
|
||||||
|
|
||||||
|
$this->output = preg_replace_callback(
|
||||||
|
"/{elseif ([^}]+)}/",
|
||||||
|
function ($arr) {
|
||||||
|
return "\";}elseif(".stripslashes(preg_replace(
|
||||||
|
["/\\$([a-zA-Z0-9_]+)/s", "/\\\$this->vars\['([a-zA-Z0-9_]+)'\]\.([a-zA-Z0-9_]+)/s"],
|
||||||
|
["\$this->vars['\$1']", "\\\$this->vars['\$1']['\$2']"],
|
||||||
|
$arr[1]
|
||||||
|
))."){echo\"";
|
||||||
|
},
|
||||||
|
$this->output
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$this->output = preg_replace("/{\/if}/","\";} echo \"",$this->output);
|
||||||
|
|
||||||
//finding FOREACHs or BLOCKs sentences and converting to php code
|
//finding FOREACHs or BLOCKs sentences and converting to php code
|
||||||
$this->output = preg_replace_callback("/{block ([^}]+) as ([^}]+)=>[\$]([^}]+)}/", create_function('$arr', 'return "\";foreach(".stripslashes(preg_replace(array("/\\\\$([a-zA-Z0-9_]+)/s","/\\\\\\$this->vars\[\\\'([a-zA-Z0-9_]+)\\\'\]\.([a-zA-Z0-9_]+)/s"),array("\$this->vars[\'\$1\']","\\\\\\$this->vars[\\\'$1\\\'][\\\'$2\\\']"),$arr[1]))." as ".stripslashes(preg_replace(array("/\\\\$([a-zA-Z0-9_]+)/s","/\\\\\\$this->vars\[\\\'([a-zA-Z0-9_]+)\\\'\]\.([a-zA-Z0-9_]+)/s"),array("\$this->vars[\'\$1\']","\\\\\\$this->vars[\\\'$1\\\'][\\\'$2\\\']"),$arr[2]))."=>\$this->vars[\'".stripslashes(preg_replace(array("/\\\\$([a-zA-Z0-9_]+)/s","/\\\\\\$this->vars\[\\\'([a-zA-Z0-9_]+)\\\'\]\.([a-zA-Z0-9_]+)/s"),array("\$this->vars[\'\$1\']","\\\\\\$this->vars[\\\'$1\\\'][\\\'$2\\\']"),$arr[3]))."\']){echo\"";'), $this->output);
|
// $this->output = preg_replace_callback("/{block ([^}]+) as ([^}]+)=>[\$]([^}]+)}/", create_function('$arr', 'return "\";foreach(".stripslashes(preg_replace(array("/\\\\$([a-zA-Z0-9_]+)/s","/\\\\\\$this->vars\[\\\'([a-zA-Z0-9_]+)\\\'\]\.([a-zA-Z0-9_]+)/s"),array("\$this->vars[\'\$1\']","\\\\\\$this->vars[\\\'$1\\\'][\\\'$2\\\']"),$arr[1]))." as ".stripslashes(preg_replace(array("/\\\\$([a-zA-Z0-9_]+)/s","/\\\\\\$this->vars\[\\\'([a-zA-Z0-9_]+)\\\'\]\.([a-zA-Z0-9_]+)/s"),array("\$this->vars[\'\$1\']","\\\\\\$this->vars[\\\'$1\\\'][\\\'$2\\\']"),$arr[2]))."=>\$this->vars[\'".stripslashes(preg_replace(array("/\\\\$([a-zA-Z0-9_]+)/s","/\\\\\\$this->vars\[\\\'([a-zA-Z0-9_]+)\\\'\]\.([a-zA-Z0-9_]+)/s"),array("\$this->vars[\'\$1\']","\\\\\\$this->vars[\\\'$1\\\'][\\\'$2\\\']"),$arr[3]))."\']){echo\"";'), $this->output);
|
||||||
$this->output = preg_replace_callback("/{block ([^}]+) as ([^}]+)}/", create_function('$arr', 'return "\";foreach(".stripslashes(preg_replace(array("/\\\\$([a-zA-Z0-9_]+)/s","/\\\\\\$this->vars\[\\\'([a-zA-Z0-9_]+)\\\'\]\.([a-zA-Z0-9_]+)/s"),array("\$this->vars[\'\$1\']","\\\\\\$this->vars[\\\'$1\\\'][\\\'$2\\\']"),$arr[1]))." as ".stripslashes(preg_replace(array("/\\\\$([a-zA-Z0-9_]+)/s","/\\\\\\$this->vars\[\\\'([a-zA-Z0-9_]+)\\\'\]\.([a-zA-Z0-9_]+)/s"),array("\$this->vars[\'\$1\']","\\\\\\$this->vars[\\\'$1\\\'][\\\'$2\\\']"),$arr[2]))."){echo\"";'), $this->output);
|
|
||||||
|
$this->output = preg_replace_callback(
|
||||||
|
"/{block ([^}]+) as ([^}]+)=>[\$]([^}]+)}/",
|
||||||
|
function ($arr) {
|
||||||
|
$var1 = preg_quote($arr[1], '/');
|
||||||
|
$var2 = preg_quote($arr[2], '/');
|
||||||
|
$var3 = preg_quote($arr[3], '/');
|
||||||
|
return "\";foreach(\$this->vars['$var1'] as \$var2=>\$this->vars['$var3']){echo\""; // Removed unnecessary stripslashes
|
||||||
|
},
|
||||||
|
$this->output
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// $this->output = preg_replace_callback("/{block ([^}]+) as ([^}]+)}/", create_function('$arr', 'return "\";foreach(".stripslashes(preg_replace(array("/\\\\$([a-zA-Z0-9_]+)/s","/\\\\\\$this->vars\[\\\'([a-zA-Z0-9_]+)\\\'\]\.([a-zA-Z0-9_]+)/s"),array("\$this->vars[\'\$1\']","\\\\\\$this->vars[\\\'$1\\\'][\\\'$2\\\']"),$arr[1]))." as ".stripslashes(preg_replace(array("/\\\\$([a-zA-Z0-9_]+)/s","/\\\\\\$this->vars\[\\\'([a-zA-Z0-9_]+)\\\'\]\.([a-zA-Z0-9_]+)/s"),array("\$this->vars[\'\$1\']","\\\\\\$this->vars[\\\'$1\\\'][\\\'$2\\\']"),$arr[2]))."){echo\"";'), $this->output);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$this->output = preg_replace_callback(
|
||||||
|
"/{block ([^}]+) as ([^}]+)}/",
|
||||||
|
function ($arr) {
|
||||||
|
return "\";foreach(".stripslashes(preg_replace(
|
||||||
|
["/\\$([a-zA-Z0-9_]+)/s", "/\\\$this->vars\['([a-zA-Z0-9_]+)'\]\.([a-zA-Z0-9_]+)/s"],
|
||||||
|
["\$this->vars['\$1']", "\\\$this->vars['\$1']['\$2']"],
|
||||||
|
$arr[1]
|
||||||
|
))." as ".stripslashes(preg_replace(
|
||||||
|
["/\\$([a-zA-Z0-9_]+)/s", "/\\\$this->vars\['([a-zA-Z0-9_]+)'\]\.([a-zA-Z0-9_]+)/s"],
|
||||||
|
["\$this->vars['\$1']", "\\\$this->vars['\$1']['\$2']"],
|
||||||
|
$arr[2]
|
||||||
|
))."){echo\"";
|
||||||
|
},
|
||||||
|
$this->output
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$this->output = preg_replace("/{\/block}/", "\";} echo \"", $this->output);
|
$this->output = preg_replace("/{\/block}/", "\";} echo \"", $this->output);
|
||||||
|
|
||||||
//Converting the $this->vars[\'variable\'] format to {$this->vars['variable']}
|
//Converting the $this->vars[\'variable\'] format to {$this->vars['variable']}
|
||||||
|
|
@ -96,7 +159,7 @@ class themes
|
||||||
$this->output = preg_replace("/[\$]this->vars\[\\\'([^ \.\\\]+)\\\'\]/", "{\$this->vars['$1']}", $this->output);
|
$this->output = preg_replace("/[\$]this->vars\[\\\'([^ \.\\\]+)\\\'\]/", "{\$this->vars['$1']}", $this->output);
|
||||||
|
|
||||||
//Convertin the {__(\'word\')} format to {__('word')}
|
//Convertin the {__(\'word\')} format to {__('word')}
|
||||||
#$this->output = preg_replace("/[\$]this->vars\[\\\'([^ \.\\\]+)\\\'\]/","{\$this->vars['$1']}",$this->output);
|
$this->output = preg_replace("/[\$]this->vars\[\\\'([^ \.\\\]+)\\\'\]/","{\$this->vars['$1']}",$this->output);
|
||||||
}
|
}
|
||||||
|
|
||||||
//sustituye las variables en el output del template
|
//sustituye las variables en el output del template
|
||||||
|
|
@ -149,4 +212,4 @@ class themes
|
||||||
$this->output = preg_replace("/{__\((?:'|\")$v(?:'|\")\)}/", __($v), $this->output);
|
$this->output = preg_replace("/{__\((?:'|\")$v(?:'|\")\)}/", __($v), $this->output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue