|
|
@@ -1076,6 +1076,10 @@ class HtmlHelper extends Helper {
|
|
|
/**
|
|
|
* Build a nested list (UL/OL) out of an associative array.
|
|
|
*
|
|
|
+ * Options for $options:
|
|
|
+ *
|
|
|
+ * - `tag` - Type of list tag to use (ol/ul)
|
|
|
+ *
|
|
|
* Options for $itemOptions:
|
|
|
*
|
|
|
* - `even` - Class to use for even rows.
|
|
|
@@ -1084,14 +1088,14 @@ class HtmlHelper extends Helper {
|
|
|
* @param array $list Set of elements to list
|
|
|
* @param string|array $options Additional HTML attributes of the list (ol/ul) tag or if ul/ol use that as tag
|
|
|
* @param array $itemOptions Additional HTML attributes of the list item (LI) tag
|
|
|
- * @param string $tag Type of list tag to use (ol/ul)
|
|
|
* @return string The nested list
|
|
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#HtmlHelper::nestedList
|
|
|
*/
|
|
|
- public function nestedList(array $list, array $options = [], array $itemOptions = [], $tag = 'ul') {
|
|
|
- $items = $this->_nestedListItem($list, $options, $itemOptions, $tag);
|
|
|
+ public function nestedList(array $list, array $options = [], array $itemOptions = []) {
|
|
|
+ $options += array('tag' => 'ul');
|
|
|
+ $items = $this->_nestedListItem($list, $options, $itemOptions);
|
|
|
return $this->formatTemplate($tag, [
|
|
|
- 'attrs' => $this->templater()->formatAttributes($options),
|
|
|
+ 'attrs' => $this->templater()->formatAttributes($options, ['tag']),
|
|
|
'content' => $items
|
|
|
]);
|
|
|
}
|
|
|
@@ -1100,19 +1104,18 @@ class HtmlHelper extends Helper {
|
|
|
* Internal function to build a nested list (UL/OL) out of an associative array.
|
|
|
*
|
|
|
* @param array $items Set of elements to list
|
|
|
- * @param array $options Additional HTML attributes of the list (ol/ul) tag
|
|
|
+ * @param array $options Options and additional HTML attributes of the list (ol/ul) tag
|
|
|
* @param array $itemOptions Additional HTML attributes of the list item (LI) tag
|
|
|
- * @param string $tag Type of list tag to use (ol/ul)
|
|
|
* @return string The nested list element
|
|
|
* @see HtmlHelper::nestedList()
|
|
|
*/
|
|
|
- protected function _nestedListItem($items, $options, $itemOptions, $tag) {
|
|
|
+ protected function _nestedListItem($items, $options, $itemOptions) {
|
|
|
$out = '';
|
|
|
|
|
|
$index = 1;
|
|
|
foreach ($items as $key => $item) {
|
|
|
if (is_array($item)) {
|
|
|
- $item = $key . $this->nestedList($item, $options, $itemOptions, $tag);
|
|
|
+ $item = $key . $this->nestedList($item, $options, $itemOptions);
|
|
|
}
|
|
|
if (isset($itemOptions['even']) && $index % 2 === 0) {
|
|
|
$itemOptions['class'] = $itemOptions['even'];
|