Skip to content
Permalink
Browse files

Templates parsing fix

  • Loading branch information...
sergejey committed Apr 8, 2019
1 parent e2c2b8f commit 43e0837c8d629b61b8d7441d45092cbb48539fae
Showing with 241 additions and 245 deletions.
  1. +76 −80 lib/objects.class.php
  2. +165 −165 lib/parser.class.php
@@ -1124,95 +1124,92 @@ function processTitle($title, $object = 0)
$title = $jTempl->result;
endMeasure('processTitleJTemplate');
return $title;
}
$title = preg_replace('/%rand%/is', rand(), $title);
$title=preg_replace('/%([\w\d\.]+?)\.([\w\d\.]+?)\|(\d+)%/uis', '%\1.\2%', $title);
// return $title;
} else {
$title = preg_replace('/%rand%/is', rand(), $title);
$title=preg_replace('/%([\w\d\.]+?)\.([\w\d\.]+?)\|(\d+)%/uis', '%\1.\2%', $title);
if (preg_match_all('/%([\w\d\.]+?)\.([\w\d\.]+?)%/uis', $title, $m))
{
startMeasure('processTitleProperties');
$total = count($m[0]);
if (preg_match_all('/%([\w\d\.]+?)\.([\w\d\.]+?)%/uis', $title, $m))
{
startMeasure('processTitleProperties');
$total = count($m[0]);
for ($i = 0; $i < $total; $i++)
{
$title = str_replace($m[0][$i], getGlobal($m[1][$i] . '.' . $m[2][$i]), $title);
}
for ($i = 0; $i < $total; $i++)
{
$title = str_replace($m[0][$i], getGlobal($m[1][$i] . '.' . $m[2][$i]), $title);
}
endMeasure('processTitleProperties');
}
if (preg_match_all('/%([\w\d\.]+?)\.([\w\d\.]+?)\|"(.+?)"%/uis', $title, $m))
{
startMeasure('processTitlePropertiesReplace');
$total = count($m[0]);
for ($i = 0; $i < $total; $i++)
{
$data=getGlobal($m[1][$i] . '.' . $m[2][$i]);
if ($data == '') $data = 0;
$descr=$m[3][$i];
$tmp=explode(';', $descr);
$totald=count($tmp);
$hsh=array();
if ($totald==1) {
if ($data!='') {
$hsh[$data]=$descr;
} else {
$hsh[$data]='';
}
} else {
for($id=0;$id<$totald;$id++) {
$item=trim($tmp[$id]);
if (preg_match('/(.+?)=(.+)/uis', $item, $md)) {
$search_value=$md[1];
$search_replace=$md[2];
} else {
$search_value=$id;
$search_replace=$item;
}
$hsh[$search_value]=$search_replace;
}
}
$title = str_replace($m[0][$i], $hsh[$data], $title);
}
endMeasure('processTitleProperties');
}
if (preg_match_all('/%([\w\d\.]+?)\.([\w\d\.]+?)\|"(.+?)"%/uis', $title, $m))
{
startMeasure('processTitlePropertiesReplace');
$total = count($m[0]);
for ($i = 0; $i < $total; $i++)
{
$data=getGlobal($m[1][$i] . '.' . $m[2][$i]);
if ($data == '') $data = 0;
$descr=$m[3][$i];
$tmp=explode(';', $descr);
$totald=count($tmp);
$hsh=array();
if ($totald==1) {
if ($data!='') {
$hsh[$data]=$descr;
} else {
$hsh[$data]='';
}
} else {
for($id=0;$id<$totald;$id++) {
$item=trim($tmp[$id]);
if (preg_match('/(.+?)=(.+)/uis', $item, $md)) {
$search_value=$md[1];
$search_replace=$md[2];
} else {
$search_value=$id;
$search_replace=$item;
}
$hsh[$search_value]=$search_replace;
}
}
$title = str_replace($m[0][$i], $hsh[$data], $title);
}
endMeasure('processTitlePropertiesReplace');
}
if (preg_match_all('/%([\w\d\.]+?)\.([\w\d\.]+?)\|(\w+?)%/uis', $title, $m)) {
startMeasure('processTitlePropertiesFunction');
$total = count($m[0]);
for($i=0;$i<$total;$i++) {
$data = getGlobal($m[1][$i] . '.' . $m[2][$i]);
if (function_exists($m[3][$i])) {
$data=call_user_func($m[3][$i],$data);
endMeasure('processTitlePropertiesReplace');
}
if (preg_match_all('/%([\w\d\.]+?)\.([\w\d\.]+?)\|(\w+?)%/uis', $title, $m)) {
startMeasure('processTitlePropertiesFunction');
$total = count($m[0]);
for($i=0;$i<$total;$i++) {
$data = getGlobal($m[1][$i] . '.' . $m[2][$i]);
if (function_exists($m[3][$i])) {
$data=call_user_func($m[3][$i],$data);
}
$title = str_replace($m[0][$i], $data, $title);
}
endMeasure('processTitlePropertiesFunction');
}
if (preg_match_all('/%([\w\d\.]+?)%/is', $title, $m))
{
$total = count($m[0]);
for ($i = 0; $i < $total; $i++)
{
if (preg_match('/^%\d/is', $m[0][$i]))
{
continue; // dirty hack, sorry for that
}
$title = str_replace($m[0][$i], getGlobal($m[1][$i]), $title);
}
$title = str_replace($m[0][$i], $data, $title);
}
endMeasure('processTitlePropertiesFunction');
}
if (preg_match_all('/%([\w\d\.]+?)%/is', $title, $m))
{
$total = count($m[0]);
for ($i = 0; $i < $total; $i++)
{
if (preg_match('/^%\d/is', $m[0][$i]))
{
continue; // dirty hack, sorry for that
}
$title = str_replace($m[0][$i], getGlobal($m[1][$i]), $title);
}
}
if (preg_match_all('/<#LANG_(\w+?)#>/is', $title, $m))
{
$total = count($m[0]);
@@ -1222,7 +1219,6 @@ function processTitle($title, $object = 0)
$title = str_replace($m[0][$i], constant('LANG_' . $m[1][$i]), $title);
}
}
if (preg_match_all('/\&#060#LANG_(.+?)#\&#062/is', $title, $m))
{
$total = count($m[0]);
Oops, something went wrong.

0 comments on commit 43e0837

Please sign in to comment.
You can’t perform that action at this time.