From cf71821b9edeca77e60818dfd17456c1a5fcc640 Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Sun, 16 Jun 2013 17:24:28 +0300 Subject: [PATCH] style fixes --- ipf/template.php | 28 ++++++++++++---------------- ipf/template/compiler.php | 21 ++++++++++----------- 2 files changed, 22 insertions(+), 27 deletions(-) diff --git a/ipf/template.php b/ipf/template.php index 8ccf7f2..850dd4d 100644 --- a/ipf/template.php +++ b/ipf/template.php @@ -49,7 +49,7 @@ function IPF_Template_htmlspecialchars($string) function IPF_Template_dateFormat($date, $format='%b %e, %Y') { if (substr(PHP_OS,0,3) == 'WIN') { - $_win_from = array ('%e', '%T', '%D'); + $_win_from = array ('%e', '%T', '%D'); $_win_to = array ('%#d', '%H:%M:%S', '%m/%d/%y'); $format = str_replace($_win_from, $_win_to, $format); } @@ -57,28 +57,24 @@ function IPF_Template_dateFormat($date, $format='%b %e, %Y') return strftime($format, strtotime($date)); } -function IPF_Template_timeFormat($time, $format='Y-m-d H:i:s'){ +function IPF_Template_timeFormat($time, $format='Y-m-d H:i:s') +{ return date($format, $time); } -function IPF_Template_floatFormat($number, $decimals=2, $dec_point='.', $thousands_sep=','){ +function IPF_Template_floatFormat($number, $decimals=2, $dec_point='.', $thousands_sep=',') +{ return number_format($number, $decimals, $dec_point, $thousands_sep); } function IPF_Template_safeEcho($mixed, $echo=true) { - if (!is_object($mixed) or 'IPF_Template_SafeString' !== get_class($mixed)) { - if ($echo) { - echo htmlspecialchars((string) $mixed, ENT_COMPAT, 'UTF-8'); - } else { - return htmlspecialchars((string) $mixed, ENT_COMPAT, 'UTF-8'); - } - } else { - if ($echo) { - echo $mixed->value; - } else { - return $mixed->value; - } - } + $result = (is_object($mixed) and 'IPF_Template_SafeString' === get_class($mixed)) + ? $mixed->value + : htmlspecialchars((string) $mixed, ENT_COMPAT, 'UTF-8'); + if ($echo) + echo $result; + else + return $result; } diff --git a/ipf/template/compiler.php b/ipf/template/compiler.php index 9a53508..04ae8a6 100644 --- a/ipf/template/compiler.php +++ b/ipf/template/compiler.php @@ -187,7 +187,7 @@ class IPF_Template_Compiler } } - function _callback($matches) + private function _callback($matches) { list(,$tag, $firstcar) = $matches; if (!preg_match('/^\$|[\'"]|[a-zA-Z\/]$/', $firstcar)) { @@ -221,7 +221,7 @@ class IPF_Template_Compiler } } - function _parseVariable($expr) + private function _parseVariable($expr) { $tok = explode('|', $expr); $res = $this->_parseFinal(array_shift($tok), $this->_allowedInVar); @@ -231,10 +231,9 @@ class IPF_Template_Compiler return ''; } $targs = array($res); - if(isset($m[2])){ + if (isset($m[2])) { $res = $this->_modifier[$m[1]].'('.$res.','.$m[2].')'; - } - else if (isset($this->_modifier[$m[1]])) { + } elseif (isset($this->_modifier[$m[1]])) { $res = $this->_modifier[$m[1]].'('.$res.')'; } else { trigger_error(sprintf(__('Unknown modifier: (%s) %s'), $expr, $m[1]), E_USER_ERROR); @@ -247,7 +246,7 @@ class IPF_Template_Compiler return $res; } - function _parseFunction($name, $args) + private function _parseFunction($name, $args) { switch ($name) { case 'if': @@ -302,9 +301,9 @@ class IPF_Template_Compiler $res = $this->_parseFinal($args, $this->_allowedAssign).'; '; break; case 'literal': - if(count($this->_literals)){ + if (count($this->_literals)) { $res = '?>'.array_shift($this->_literals).'_extendBlocks[$args])) - $res = '?>'.$this->_extendBlocks[$args].'_extendBlocks[$args])) + $res = '?>'.$this->_extendBlocks[$args].'~~{~~superblock~~}~~