cvs: smarty /libs/plugins function.counter.php function.cycle.php

"Messju Mohr" <[email protected]>
Newsgroups gmane.comp.php.cvs.smarty
Message-ID <cvsmessju1071823758@cvsserver>
messju		Fri Dec 19 03:49:18 2003 EDT

  Modified files:              
    /smarty/libs/plugins	function.cycle.php function.counter.php 
  Log:
  removed extract() from parameter-parsing
  
  
Index: smarty/libs/plugins/function.cycle.php
diff -u smarty/libs/plugins/function.cycle.php:1.13 smarty/libs/plugins/function.cycle.php:1.14
--- smarty/libs/plugins/function.cycle.php:1.13	Sun Apr 20 17:18:26 2003
+++ smarty/libs/plugins/function.cycle.php	Fri Dec 19 03:49:17 2003
@@ -45,23 +45,10 @@
 {
     static $cycle_vars;
     
-    extract($params);
-
-    if (empty($name)) {
-        $name = 'default';
-    }
-
-    if (!isset($print)) {
-        $print = true;
-    }
-
-    if (!isset($advance)) {
-        $advance = true;        
-    }    
-
-    if (!isset($reset)) {
-        $reset = false;        
-    }        
+    $name = (empty($params['name'])) ? 'default' : $params['name'];
+    $print = (isset($params['print'])) ? (bool)$params['print'] : true;
+    $advance = (isset($params['advance'])) ? (bool)$params['advance'] : true;
+    $reset = (isset($params['reset'])) ? (bool)$params['reset'] : false;
             
     if (!in_array('values', array_keys($params))) {
         if(!isset($cycle_vars[$name]['values'])) {
@@ -70,31 +57,27 @@
         }
     } else {
         if(isset($cycle_vars[$name]['values'])
-            && $cycle_vars[$name]['values'] != $values ) {
+            && $cycle_vars[$name]['values'] != $params['values'] ) {
             $cycle_vars[$name]['index'] = 0;
         }
-        $cycle_vars[$name]['values'] = $values;
+        $cycle_vars[$name]['values'] = $params['values'];
     }
 
-    if (isset($delimiter)) {
-        $cycle_vars[$name]['delimiter'] = $delimiter;
-    } elseif (!isset($cycle_vars[$name]['delimiter'])) {
-        $cycle_vars[$name]['delimiter'] = ',';        
-    }
+    $cycle_vars[$name]['delimiter'] = (isset($params['delimiter'])) ? $params['delimiter'] : ',';
     
-    if(!is_array($cycle_vars[$name]['values'])) {
-        $cycle_array = explode($cycle_vars[$name]['delimiter'],$cycle_vars[$name]['values']);
-    } else {
+    if(is_array($cycle_vars[$name]['values'])) {
         $cycle_array = $cycle_vars[$name]['values'];    
+    } else {
+        $cycle_array = explode($cycle_vars[$name]['delimiter'],$cycle_vars[$name]['values']);
     }
     
     if(!isset($cycle_vars[$name]['index']) || $reset ) {
         $cycle_vars[$name]['index'] = 0;
     }
     
-    if (isset($assign)) {
+    if (isset($params['assign'])) {
         $print = false;
-        $smarty->assign($assign, $cycle_array[$cycle_vars[$name]['index']]);
+        $smarty->assign($params['assign'], $cycle_array[$cycle_vars[$name]['index']]);
     }
         
     if($print) {
Index: smarty/libs/plugins/function.counter.php
diff -u smarty/libs/plugins/function.counter.php:1.10 smarty/libs/plugins/function.counter.php:1.11
--- smarty/libs/plugins/function.counter.php:1.10	Tue Jun  3 09:22:41 2003
+++ smarty/libs/plugins/function.counter.php	Fri Dec 19 03:49:17 2003
@@ -22,16 +22,7 @@
 {
     static $counters = array();
 
-    extract($params);
-
-    if (!isset($name)) {
-		if(isset($id)) {
-			$name = $id;
-		} else {		
-        	$name = "default";
-		}
-	}
-
+    $name = (isset($params['name'])) ? $params['name'] : 'default';
     if (!isset($counters[$name])) {
         $counters[$name] = array(
             'start'=>1,
@@ -42,20 +33,20 @@
     }
     $counter =& $counters[$name];
 
-    if (isset($start)) {
-        $counter['start'] = $counter['count'] = $start;
+    if (isset($params['start'])) {
+        $counter['start'] = $counter['count'] = (int)$params['start'];
     }
 
-    if (!empty($assign)) {
-        $counter['assign'] = $assign;
+    if (!empty($params['assign'])) {
+        $counter['assign'] = $params['assign'];
     }
 
     if (isset($counter['assign'])) {
         $smarty->assign($counter['assign'], $counter['count']);
     }
     
-    if (isset($print)) {
-        $print = (bool)$print;
+    if (isset($params['print'])) {
+        $print = (bool)$params['print'];
     } else {
         $print = empty($counter['assign']);
     }
@@ -66,12 +57,12 @@
 		$retval = null;
 	}
 
-    if (isset($skip)) {
-        $counter['skip'] = $skip;
+    if (isset($params['skip'])) {
+        $counter['skip'] = $params['skip'];
     }
     
-    if (isset($direction)) {
-        $counter['direction'] = $direction;
+    if (isset($params['direction'])) {
+        $counter['direction'] = $params['direction'];
     }
 
     if ($counter['direction'] == "down")

-- 
Smarty CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.