php_cs_fix

This commit is contained in:
Mitan Omar
2020-09-21 22:57:54 +02:00
parent 3941cae94b
commit 625d14ffcc

View File

@@ -9,8 +9,7 @@
//no direct access
if (! defined('IN_COMMON'))
{
if (! defined('IN_COMMON')) {
exit;
}
@@ -31,8 +30,7 @@ class kleeja_style
global $config, $THIS_STYLE_PATH_ABS, $STYLE_PATH_ADMIN_ABS, $DEFAULT_PATH_ADMIN_ABS;
if (! ($template_path = $this->template_exists($template_name, $style_path)))
{
if (! ($template_path = $this->template_exists($template_name, $style_path))) {
big_error('No Template !', 'Requested <b>"' . $template_name . '"</b> template doesnt exist!');
}
@@ -41,8 +39,7 @@ class kleeja_style
$html = "<!-- file generated by kleeja {kleeja.net} -->\n" . $html;
//use 'b' to force binary mode
if ($filename = @fopen(PATH . 'cache/tpl_' . $this->re_name_tpl($template_name, $style_path) . '.php', 'wb'))
{
if ($filename = @fopen(PATH . 'cache/tpl_' . $this->re_name_tpl($template_name, $style_path) . '.php', 'wb')) {
is_array($plugin_run_result = Plugins::getInstance()->run('style_load_template_func', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
@@ -70,13 +67,10 @@ class kleeja_style
$style_path = str_replace(DIRECTORY_SEPARATOR, '/', $style_path);
//admin template always begin with admin_
if (substr($template_name, 0, 6) == 'admin_')
{
if (substr($template_name, 0, 6) == 'admin_') {
$current_style_path = ! empty($style_path) ? $style_path : $STYLE_PATH_ADMIN_ABS;
$is_admin_template = true;
}
else
{
} else {
$current_style_path = ! empty($style_path) ? $style_path : $THIS_STYLE_PATH_ABS;
}
@@ -88,29 +82,21 @@ class kleeja_style
$is_tpl_exist = file_exists($template_path);
if (! $is_tpl_exist)
{
if (trim($config['style_depend_on']) != '')
{
if (! $is_tpl_exist) {
if (trim($config['style_depend_on']) != '') {
$template_path_alternative = str_replace('/' . $config['style'] . '/', '/' . $config['style_depend_on'] . '/', $template_path);
if (file_exists($template_path_alternative))
{
if (file_exists($template_path_alternative)) {
$template_path = $template_path_alternative;
$is_tpl_exist = true;
}
}
elseif ($is_admin_template)
{
} elseif ($is_admin_template) {
$template_path = $DEFAULT_PATH_ADMIN_ABS . $template_name . '.html';
$is_tpl_exist = true;
}
elseif ($config['style'] != 'default' && ! $is_admin_template)
{
} elseif ($config['style'] != 'default' && ! $is_admin_template) {
$template_path_alternative = str_replace('/' . $config['style'] . '/', '/default/', $template_path);
if (file_exists($template_path_alternative))
{
if (file_exists($template_path_alternative)) {
$template_path = $template_path_alternative;
$is_tpl_exist = true;
}
@@ -130,19 +116,19 @@ class kleeja_style
is_array($plugin_run_result = Plugins::getInstance()->run('style_parse_func', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
$html = preg_replace_callback('/<IGNORE>(.*?)<\/IGNORE>/is', function($m) {
$html = preg_replace_callback('/<IGNORE>(.*?)<\/IGNORE>/is', function ($m) {
return '<STRREV>' . strrev($m[1]) . '</STRREV>';
}, $html);
$html = preg_replace(['#<([\?%])=?.*?\1>#s', '#<script\s+language\s*=\s*(["\']?)php\1\s*>.*?</script\s*>#s', '#<\?php(?:\r\n?|[ \n\t]).*?\?>#s'], '', $html);
$html = preg_replace_callback('/\(([{A-Z0-9_\.}\s!=<>]+)\?(.*):(.*)\)/iU', function($m) {
$html = preg_replace_callback('/\(([{A-Z0-9_\.}\s!=<>]+)\?(.*):(.*)\)/iU', function ($m) {
return '<IF NAME="' . $m[1] . '">' . $m[2] . '<ELSE>' . $m[3] . '</IF>';
}, $html);
$html = preg_replace_callback('/<(IF|ELSEIF|UNLESS) (.+)>/iU', ['kleeja_style', '_if_callback'], $html);
$html = preg_replace_callback('/<LOOP\s+NAME\s*=\s*(\"|)+([a-z0-9_\.]{1,})+(\"|)\s*>/i', function($m) {
$html = preg_replace_callback('/<LOOP\s+NAME\s*=\s*(\"|)+([a-z0-9_\.]{1,})+(\"|)\s*>/i', function ($m) {
return '<?php foreach($this->vars["' . (strpos($m[2], '.') !== false ? str_replace('.', '"]["', $m[2]) : $m[2]) . '"] as $key=>$value){ ?>';
}, $html);
$html = preg_replace_callback(kleeja_style::reg('var'), ['kleeja_style', '_vars_callback'], $html);
$html = preg_replace_callback('/<STRREV>(.*?)<\/STRREV>/is', function($m) {
$html = preg_replace_callback('/<STRREV>(.*?)<\/STRREV>/is', function ($m) {
return strrev($m[1]);
}, $html);
@@ -174,10 +160,8 @@ class kleeja_style
foreach ([
'NAME' => '', 'LOOP' => '', 'AND' => ' && ', 'OR' => ' || ', 'ISSET' => ' isset', 'EMPTY' => ' empty'
] as $attribute=>$separator)
{
if (isset($atts[$attribute]))
{
] as $attribute=>$separator) {
if (isset($atts[$attribute])) {
$haveParentheses = in_array($attribute, ['ISSET', 'EMPTY']);
$condition .= $separator . ($haveParentheses ? '(' : '') .
@@ -197,30 +181,25 @@ class kleeja_style
$char = [' eq ', ' lt ', ' gt ', ' lte ', ' gte ', ' neq ', '==', '!=', '>=', '<=', '<', '>'];
$reps = ['==', '<', '>', '<=', '>=', '!=', '==', '!=', '>=', '<=', '<', '>'];
if (trim($condition) == '')
{
if (trim($condition) == '') {
return '';
}
$con = str_replace('$this->vars', '[----this-vars----]', $condition);
if (preg_match('/(.*)(' . implode('|', $char) . ')(.*)/i', $con, $arr))
{
if (preg_match('/(.*)(' . implode('|', $char) . ')(.*)/i', $con, $arr)) {
$arr[1] = trim($arr[1]);
$var1 = $arr[1][0] != '$' ? call_user_func(['kleeja_style', '_var_callback'], (! $is_loop ? '{' . $arr[1] . '}' : '{{' . $arr[1] . '}}')) : $arr[1];
$opr = str_replace($char, $reps, $arr[2]);
$var2 = trim($arr[3]);
//check for type
if ($var2[0] != '$' && ! preg_match('/[0-9]/', $var2))
{
if ($var2[0] != '$' && ! preg_match('/[0-9]/', $var2)) {
$var2 = '"' . str_replace('"', '\"', $var2) . '"';
}
$con = "$var1 $opr $var2";
}
elseif ($con[0] !== '$' && strpos($con, '(') === false)
{
} elseif ($con[0] !== '$' && strpos($con, '(') === false) {
$con = call_user_func(['kleeja_style', '_var_callback'], (! $is_loop ? '{' . $con . '}' : '{{' . $con . '}}'));
}
@@ -237,8 +216,7 @@ class kleeja_style
{
$variable = call_user_func(['kleeja_style', '_var_callback'], $matches);
if (strpos($matches[0], '{lang') !== false || strpos($matches[0], '{olang') !== false)
{
if (strpos($matches[0], '{lang') !== false || strpos($matches[0], '{olang') !== false) {
return '<?=' . $variable . ' ?? \'' . $matches[0] . '\'?>';
}
@@ -253,15 +231,13 @@ class kleeja_style
*/
protected function _var_callback($matches)
{
if (! is_array($matches))
{
if (! is_array($matches)) {
preg_match(kleeja_style::reg('var'), $matches, $matches);
}
$var = trim(! empty($matches[2]) ? str_replace('.', '\'][\'', $matches[2]) : '');
if (empty($var))
{
if (empty($var)) {
return '';
}
@@ -302,8 +278,7 @@ class kleeja_style
$attributes = [];
for ($i = 0; $i < count($attribute[1]); $i++)
{
for ($i = 0; $i < count($attribute[1]); $i++) {
$att = strtoupper($attribute[1][$i]);
$attributes[$att] = preg_replace_callback(kleeja_style::reg('var'), ['kleeja_style', '_var_callback'], $attribute[2][$i]);
@@ -335,8 +310,7 @@ class kleeja_style
$this->vars = &$GLOBALS;
//is there ?
if (! file_exists(PATH . 'cache/tpl_' . $this->re_name_tpl($template_name, $style_path) . '.php') || ! $this->caching)
{
if (! file_exists(PATH . 'cache/tpl_' . $this->re_name_tpl($template_name, $style_path) . '.php') || ! $this->caching) {
$this->_load_template($template_name, $style_path);
}
@@ -364,12 +338,9 @@ class kleeja_style
ob_start();
if ($eval_on)
{
if ($eval_on) {
eval(' ?' . '>' . $parsed_html . '<' . '?php ');
}
else
{
} else {
$path = PATH . 'cache/tpl_' . md5($parsed_html) . '.php';
file_put_contents($path, $parsed_html);
include_once $path;