00001 <?php 00027 require_once 'Zend/View/Helper/FormElement.php'; 00028 00039 class Zend_View_Helper_HtmlList extends Zend_View_Helper_FormElement 00040 { 00041 00050 public function htmlList(array $items, $ordered = false, $attribs = false, $escape = true) 00051 { 00052 if (!is_array($items)) { 00053 require_once 'Zend/View/Exception.php'; 00054 throw new Zend_View_Exception('First param must be an array', $this); 00055 } 00056 00057 $list = ''; 00058 00059 foreach ($items as $item) { 00060 if (!is_array($item)) { 00061 if ($escape) { 00062 $item = $this->view->escape($item); 00063 } 00064 $list .= '<li>' . $item . '</li>' . self::EOL; 00065 } else { 00066 if (6 < strlen($list)) { 00067 $list = substr($list, 0, strlen($list) - 6) 00068 . $this->htmlList($item, $ordered, $attribs, $escape) . '</li>' . self::EOL; 00069 } else { 00070 $list .= '<li>' . $this->htmlList($item, $ordered, $attribs, $escape) . '</li>' . self::EOL; 00071 } 00072 } 00073 } 00074 00075 if ($attribs) { 00076 $attribs = $this->_htmlAttribs($attribs); 00077 } else { 00078 $attribs = ''; 00079 } 00080 00081 $tag = 'ul'; 00082 if ($ordered) { 00083 $tag = 'ol'; 00084 } 00085 00086 return '<' . $tag . $attribs . '>' . self::EOL . $list . '</' . $tag . '>' . self::EOL; 00087 } 00088 }