2019-07-17 20:08:50 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Zend Framework
|
|
|
|
*
|
|
|
|
* LICENSE
|
|
|
|
*
|
|
|
|
* This source file is subject to the new BSD license that is bundled
|
|
|
|
* with this package in the file LICENSE.txt.
|
|
|
|
* It is also available through the world-wide-web at this URL:
|
|
|
|
* http://framework.zend.com/license/new-bsd
|
|
|
|
* If you did not receive a copy of the license and are unable to
|
|
|
|
* obtain it through the world-wide-web, please send an email
|
|
|
|
* to license@zend.com so we can send you a copy immediately.
|
|
|
|
*
|
|
|
|
* @category Zend
|
|
|
|
* @package Zend_View
|
|
|
|
* @subpackage Helper
|
2019-07-17 20:19:00 +00:00
|
|
|
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
2019-07-17 20:08:50 +00:00
|
|
|
* @license http://framework.zend.com/license/new-bsd New BSD License
|
2019-07-17 20:19:00 +00:00
|
|
|
* @version $Id: HtmlList.php 16541 2009-07-07 06:59:03Z bkarwin $
|
2019-07-17 20:08:50 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Zend_View_Helper_FormELement
|
|
|
|
*/
|
|
|
|
require_once 'Zend/View/Helper/FormElement.php';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper for ordered and unordered lists
|
|
|
|
*
|
|
|
|
* @uses Zend_View_Helper_FormElement
|
|
|
|
* @category Zend
|
|
|
|
* @package Zend_View
|
|
|
|
* @subpackage Helper
|
2019-07-17 20:19:00 +00:00
|
|
|
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
2019-07-17 20:08:50 +00:00
|
|
|
* @license http://framework.zend.com/license/new-bsd New BSD License
|
|
|
|
*/
|
|
|
|
class Zend_View_Helper_HtmlList extends Zend_View_Helper_FormElement
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generates a 'List' element.
|
|
|
|
*
|
|
|
|
* @param array $items Array with the elements of the list
|
|
|
|
* @param boolean $ordered Specifies ordered/unordered list; default unordered
|
|
|
|
* @param array $attribs Attributes for the ol/ul tag.
|
|
|
|
* @return string The list XHTML.
|
|
|
|
*/
|
|
|
|
public function htmlList(array $items, $ordered = false, $attribs = false, $escape = true)
|
|
|
|
{
|
|
|
|
if (!is_array($items)) {
|
|
|
|
require_once 'Zend/View/Exception.php';
|
|
|
|
throw new Zend_View_Exception('First param must be an array', $this);
|
|
|
|
}
|
|
|
|
|
|
|
|
$list = '';
|
|
|
|
|
|
|
|
foreach ($items as $item) {
|
|
|
|
if (!is_array($item)) {
|
|
|
|
if ($escape) {
|
2019-07-17 20:16:19 +00:00
|
|
|
$item = $this->view->escape($item);
|
2019-07-17 20:08:50 +00:00
|
|
|
}
|
2019-07-17 20:16:19 +00:00
|
|
|
$list .= '<li>' . $item . '</li>' . self::EOL;
|
2019-07-17 20:08:50 +00:00
|
|
|
} else {
|
2019-07-17 20:16:19 +00:00
|
|
|
if (6 < strlen($list)) {
|
|
|
|
$list = substr($list, 0, strlen($list) - 6)
|
|
|
|
. $this->htmlList($item, $ordered, $attribs, $escape) . '</li>' . self::EOL;
|
2019-07-17 20:08:50 +00:00
|
|
|
} else {
|
2019-07-17 20:16:19 +00:00
|
|
|
$list .= '<li>' . $this->htmlList($item, $ordered, $attribs, $escape) . '</li>' . self::EOL;
|
2019-07-17 20:08:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($attribs) {
|
|
|
|
$attribs = $this->_htmlAttribs($attribs);
|
|
|
|
} else {
|
|
|
|
$attribs = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
$tag = 'ul';
|
|
|
|
if ($ordered) {
|
|
|
|
$tag = 'ol';
|
|
|
|
}
|
|
|
|
|
2019-07-17 20:16:19 +00:00
|
|
|
return '<' . $tag . $attribs . '>' . self::EOL . $list . '</' . $tag . '>' . self::EOL;
|
2019-07-17 20:08:50 +00:00
|
|
|
}
|
|
|
|
}
|