Used to render menu items as a ul li fake table
in the backend.

@param array $menuItems The menu items to render as tree.
@param null|int $level The current level.
@return string
359073
public function renderTree($menuItems, $level = null)
    {
        $output = '';

        $depth = ($level !== null) ? $level : 1;

        foreach ($menuItems as $key => $menuItem) {
            $classes = ['menu-item'];
            $menuItemRow = $this->_View->element('../Menus/__menu-item-row', [
                'menuItem' => $menuItem,
                'level' => $level
            ]);

            if (!empty($menuItem['children'])) {
                $menuItemRow .= '<ul>' . $this->renderTree($menuItem['children'], $depth + 1) . '</ul>';
            } else {
                $classes[] = 'no-children';
            }
            $output .= '<li class="' . join(' ', $classes) . '" data-menu-item-id="' . $menuItem['id'] . '">' . $menuItemRow . '</li>';
        }

        return $output;
    }
919799
private function filterParent($parent, MenuItemCollection $items)
    {
        $filteredItems = new MenuItemCollection();

        foreach ($items->getItems() as $name => $item) {
            if ($parent === $item->getParent()) {
                $subItems = $this->filterParent($name, $items);
                if (count($subItems)) {
                    $item->setItems($subItems);
                }
                $filteredItems->set($name, $item);
                $items->remove($name);
            }
        }

        return $filteredItems;
    }
354355
protected function renderMenu($items)
	{
		if(count($items))
		{
			echo CHtml::openTag('ul',$this->htmlOptions)."\n";
			$this->renderMenuRecursive($items);
			echo CHtml::closeTag('ul');
		}
	}
618819
protected function buildListItem(string $item, string $marker, int $nestingLevel): string
	{
		return str_repeat($this->padding, $nestingLevel) . $marker . ' ' . $item . PHP_EOL;
	}
819245
protected function _prepareItems($items)
    {
        if (is_integer($items)) {
            $id = $items;
            $cacheKey = "render({$id})";
            $items = static::cache($cacheKey);

            if ($items === null) {
                $items = TableRegistry::get('Menu.MenuLinks')
                    ->find('threaded')
                    ->where(['menu_id' => $id])
                    ->all();
                static::cache($cacheKey, $items);
            }
        } elseif (is_string($items)) {
            $slug = $items;
            $cacheKey = "render({$slug})";
            $items = static::cache($cacheKey);

            if ($items === null) {
                $items = [];
                $menu = TableRegistry::get('Menu.Menus')
                    ->find()
                    ->select(['id'])
                    ->where(['slug' => $slug])
                    ->first();

                if ($menu instanceof EntityInterface) {
                    $items = TableRegistry::get('Menu.MenuLinks')
                        ->find('threaded')
                        ->where(['menu_id' => $menu->id])
                        ->all();
                }
                static::cache($cacheKey, $items);
            }
        }

        return $items;
    }
1170150
public function remove_child(custom_menu_item $menuitem) {
        $removed = false;
        if (($key = array_search($menuitem, $this->children)) !== false) {
            unset($this->children[$key]);
            $this->children = array_values($this->children);
            $removed = true;
        } else {
            foreach ($this->children as $child) {
                if ($removed = $child->remove_child($menuitem)) {
                    break;
                }
            }
        }
        return $removed;
    }
390773
public function getHtml($nodeId, $level, $storeId = null)
    {
        $classes = $level == 0 ? 'level-top' : '';
        $node = $this->nodes[$nodeId];
        $url = $this->getCategoryUrl($nodeId, $storeId);
        $title = $node->getTitle();

        return <<<HTML
<a href="$url" class="$classes" role="menuitem"><span>$title</span></a>
HTML;
    }
495197
private function buildMenuItems(array $items)
    {
        $html = '';

        foreach ($items as $item) {

            if ($this->multilevel && $item->hasChilds()) {
                $html .= '
				<li class="navbar-parent">
					<a href="' . $item->getUrl() . '">' . $item->getText() . '</a>
					<ul>';

                $html .= $this->buildMenuItems($item->getChilds());

                $html .= '
					</ul>
				</li>';
            } else {

                $url = $item->getUrl();

                if ($url) {
                    $html .= '<li><a href="' . $url . '">' . $item->getText() . '</a></li>';
                } else {
                    $html .= '<li><a href="#" onClick="return false">' . $item->getText() . '</a></li>';
                }
            }
        }

        return $html;
    }
956999
protected function renderItems($_items = NULL) {
		$_items = is_null($_items) ? $this->items : $_items;
		$items = '';
        $dataid = 0;
		foreach ($_items as $item) {
			$options = ArrayHelper::getValue($item, 'options', ['class' => 'dd-item dd3-item']);
            $options = ArrayHelper::merge($this->itemOptions, $options);
            $dataId  = ArrayHelper::getValue($item, 'id', $dataid++);
            $options = ArrayHelper::merge($options, ['data-id' => $dataId]);

            $contentOptions = ArrayHelper::getValue($item, 'contentOptions', ['class' => 'dd3-content']);
			$content = $this->handleLabel;
			$content .= Html::tag('div', ArrayHelper::getValue($item, 'content', ''), $contentOptions);

			$children = ArrayHelper::getValue($item, 'children', []);
			if (!empty($children)) {
					// recursive rendering children items
				$content .= Html::beginTag('ol', ['class' => 'dd-list']);
				$content .= $this->renderItems($children);
				$content .= Html::endTag('ol');
			}

			$items .= Html::tag('li', $content, $options) . PHP_EOL;
		}
		return $items;
	}
144559
public function getMenu($level = 1)
    {
        if (class_exists(ContentController::class)) {
            $controller = Injector::inst()->get(ContentController::class);
            return $controller->getMenu($level);
        }
    }
315162
public function getItemUuiD($menuItem)
    {
        $itemID = '';
        if (is_a($menuItem, MenuItem::class)) {
            $itemID = 'MenuItem'.$menuItem->getURL();
        }

        if (is_a($menuItem, MenuBuilder::class)) {
            $itemID = 'MenuBuilder'.$menuItem->getName();
        }

        return Str::limit(md5(Str::slug($itemID)), 12, null);
    }
1183131
protected function _getLevelElement(array $options, $level)
    {
        $levelElement = 'menu_child_' . $level;
        $element      = $options['childMenuAttr']['element'];

        list($plugin, $path) = $this->_View->pluginSplit($element);
        $path    = FS::clean($path, '/');
        $details = explode('/', $path);
        array_pop($details);

        $path = implode('/', $details);

        return $plugin . '.' . $path . '/' . $levelElement;
    }
1205915
public function getMediaFolderByLevels($levels)
    {
        $qb = $this->createQueryBuilder('mf')
                   ->andWhere('mf._level IN (:levels)')
                   ->setParameter('levels', $levels)
                   ->orderBy('mf._leftnode', 'asc');

        return $qb->getQuery()->getResult();
    }
438159
public function getTabs(array $items, array $attrs = []): string
    {
        $attrs = HtmlAttrs::build(array_replace_recursive([
            'role' => 'tablist',
            'class' => 'nav nav-tabs',
        ], $attrs));

        return vsprintf('<ul %s>%s</ul>', [
            $attrs,
            implode('', array_map([$this, 'getTab'], $items)),
        ]);
    }
786970
public function render($key, array $items = [], array $options = [], $level = 1)
    {
        $i = 0;
        $output    = [];
        $options   = Hash::merge($this->_default, $options);
        $sorted    = Hash::sort($items, '{s}.weight', 'ASC');
        $itemCount = count($sorted);

        foreach ($sorted as $item) {
            $i++;
            $item = $this->_setFirstLast($i, $itemCount, $item);

            $children = false;
            if (count($item['children']) > 0) {
                $children = $this->render($key, $item['children'], $options, $level + 1);
            }

            $itemParams = [
                'options'  => $options,
                'item'     => $item,
                'count'    => $i,
                'children' => $children,
                'level'    => $level,
            ];

            $this->_setItemParams($itemParams);

            if (isset($item['callable']) && is_callable($item['callable'])) {
                $output[] = call_user_func_array($item['callable'], array_merge(['view' => $this->_View], $itemParams));
            } else {
                $output[] = $this->_View->element($options['itemElement'], $itemParams);
            }
        }

        $element = $this->_getCurrentMenuElement($options, $level);

        return $this->_View->element($element, [
            'content' => $output,
            'options' => $options,
        ]);
    }
247098
protected function transformLink(MenuItem $item = null)
    {
        $link = $item->getLink();

        if ($link === null) {
            return '#';
        }

        if ($link->isFramed()) {
            return $this->route(
                'index.php?option=com_symfony&view=frame&title=' . urlencode($item->getName()) . '&url=' . urlencode($link->getLink())
            );
        }

        return $link->getLink();
    }
295632
protected function renderItem($item, $depth=0)
	{
		//visibility
		if (isset($item['visible']) && $item['visible'] === false) return '';

		//prepare options
		$options = isset($item['options']) ? $item['options'] : [];
		Html::addCssClass($options, 'depth-' . $depth);
		if (isset($item['active']) && $item['active']) Html::addCssClass($options, 'active');
		if (isset($item['items']) && count($item['items']) > 0) Html::addCssClass($options, 'is-parent');

		//prepare returned code
		$ret = Html::beginTag('li', $options);
		$ret .= $this->createEntry($item, $depth);

		//render children recursively
		if (isset($item['items']) && ($this->maxDepth === null || ($this->maxDepth !== null && $depth + 1 <= $this->maxDepth))) {
			$ret .= Html::beginTag('ul');
			foreach ($item['items'] as $subItem) {
				$ret .= $this->renderItem($subItem, $depth + 1);
			}
			$ret .= Html::endTag('ul');
		}

		//finish and return
		$ret .= Html::endTag('li');
		return $ret;
	}