]> git.andy128k.dev Git - ipf-template.git/commitdiff
style fixes
authorAndrey Kutejko <andy128k@gmail.com>
Sun, 16 Jun 2013 14:24:28 +0000 (17:24 +0300)
committerAndrey Kutejko <andy128k@gmail.com>
Sun, 16 Jun 2013 14:24:28 +0000 (17:24 +0300)
ipf/template.php
ipf/template/compiler.php

index 8ccf7f2953646ab0faf3ea2ce6b57275fd99993d..850dd4d0b909a4d3309e5e7ed62671662ec76770 100644 (file)
@@ -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;
 }
 
index 9a53508b1178ef431b977502777a7cc06724d5cd..04ae8a606b6f47bbb8e7fdf7598409851e8d4d15 100644 (file)
@@ -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).'<?php ';
-            }else{
+            } else {
                 trigger_error(__('End tag of a block missing: literal'), E_USER_ERROR);
             }
             break;
@@ -312,10 +311,10 @@ class IPF_Template_Compiler
             trigger_error(__('Start tag of a block missing: literal'), E_USER_ERROR);
             break;
         case 'block':
-               if (isset($this->_extendBlocks[$args]))
-               $res = '?>'.$this->_extendBlocks[$args].'<?php ';
+            if (isset($this->_extendBlocks[$args]))
+                $res = '?>'.$this->_extendBlocks[$args].'<?php ';
             else
-               $res = '';
+                $res = '';
             break;
         case 'superblock':
             $res = '?>~~{~~superblock~~}~~<?php ';