• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • Examples
  • File List

E:/E/GEAMP/www/openbiz/openbiz/others/Zend/View/Helper/PartialLoop.php

00001 <?php
00024 require_once 'Zend/View/Helper/Partial.php';
00025 
00035 class Zend_View_Helper_PartialLoop extends Zend_View_Helper_Partial
00036 {
00037 
00042     protected $partialCounter = 0;
00043 
00058     public function partialLoop($name = null, $module = null, $model = null)
00059     {
00060         if (0 == func_num_args()) {
00061             return $this;
00062         }
00063 
00064         if ((null === $model) && (null !== $module)) {
00065             $model  = $module;
00066             $module = null;
00067         }
00068 
00069         if (!is_array($model)
00070             && (!$model instanceof Traversable)
00071             && (is_object($model) && !method_exists($model, 'toArray'))
00072         ) {
00073             require_once 'Zend/View/Helper/Partial/Exception.php';
00074             throw new Zend_View_Helper_Partial_Exception('PartialLoop helper requires iterable data');
00075         }
00076 
00077         if (is_object($model)
00078             && (!$model instanceof Traversable)
00079             && method_exists($model, 'toArray')
00080         ) {
00081             $model = $model->toArray();
00082         }
00083 
00084         $content = '';
00085         // reset the counter if it's call again
00086         $this->partialCounter = 0;
00087         foreach ($model as $item) {
00088             // increment the counter variable
00089             $this->partialCounter++;
00090 
00091             $content .= $this->partial($name, $module, $item);
00092         }
00093 
00094         return $content;
00095     }
00096 }

Generated on Thu Apr 19 2012 17:01:18 for openbiz by  doxygen 1.7.2