"array_not_empty", "count" => "array_not_empty", ]; // These are individual strings within the standard templates that will get corrected. $string_replace = [ '$root.page.paginate' => 'true', '$root.page_attr[0].mobileswap' => '$mobileswap', '$category_selected[\'Title\'] == Tags' => '$category_selected[\'Title\'] == "Tags"', '"class" =>category_model_thumb' => '"class" => "category_model_thumb"', '"class" => dvd_box' => '"class" => "dvd_box"', ]; // tag_list.tpl has different token replacement and string replacement than other files. if (basename($l) == "tag_list.tpl") { $string_replace = [ 'if (!sizeof($count))' => 'if (!$count)', ]; $token_string_replace = []; } foreach ($tokens as $token) { if (is_array($token)) { if (token_name($token[0]) == "T_STRING" && isset($token_string_replace[$token[1]])) { echo "\n CHANGE " . $token[1] . " to " . $token_string_replace[$token[1]]; $out .= $token_string_replace[$token[1]]; } else { //echo "\n$l Line {$token[2]}: " . token_name($token[0]) . " ({$token[1]})"; $out .= $token[1]; } } else { // echo "\nNON-ARRAY TOKEN:"; // var_dump($token); $out .= $token; } } foreach ($string_replace as $string_from => $string_to) { if (stripos($out, $string_from) !== false) { $out = str_replace($string_from, $string_to, $out); echo "\n CHANGE " . $string_from . " to " . $string_to; } } if (!file_put_contents($l, $out)) { echo "\nERROR: File $l cannot be written to disk. Please check file permissions"; } } echo "\n\n"; exit;