本文整理汇总了PHP中JHTMLMenu::TreeRecurse方法的典型用法代码示例。如果您正苦于以下问题:PHP JHTMLMenu::TreeRecurse方法的具体用法?PHP JHTMLMenu::TreeRecurse怎么用?PHP JHTMLMenu::TreeRecurse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JHTMLMenu
的用法示例。
在下文中一共展示了JHTMLMenu::TreeRecurse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInput
function getInput()
{
$db =& JFactory::getDBO();
$version = new JVersion();
$odering = ", m.ordering";
if ($version->RELEASE >= '3.0') {
$odering = "";
}
$query = 'SELECT m.id, m.parent_id, m.title, m.menutype' . ' FROM #__menu AS m' . ' WHERE m.published = 1' . ' ORDER BY m.menutype, m.parent_id ' . $odering;
$db->setQuery($query);
$mitems = $db->loadObjectList();
$mitems_temp = $mitems;
$children = array();
foreach ($mitems as $v) {
$id = $v->id;
$pt = $v->parent_id;
$list = @$children[$pt] ? $children[$pt] : array();
array_push($list, $v);
$children[$pt] = $list;
}
$list = JHTMLMenu::TreeRecurse(intval($mitems[0]->parent_id), '', array(), $children, 9999, 0, 0);
$mitems_spacer = $mitems_temp[0]->menutype;
$mitems = array();
if (@$all | @$unassigned) {
$mitems[] = JHTML::_('select.option', '<OPTGROUP>', JText::_('Menus'));
if ($all) {
$mitems[] = JHTML::_('select.option', 0, JText::_('All'));
}
if ($unassigned) {
$mitems[] = JHTML::_('select.option', -1, JText::_('Unassigned'));
}
$mitems[] = JHTML::_('select.option', '</OPTGROUP>');
}
$lastMenuType = null;
$tmpMenuType = null;
foreach ($list as $list_a) {
if ($list_a->menutype != $lastMenuType) {
if ($tmpMenuType) {
$mitems[] = JHTML::_('select.option', '</OPTGROUP>');
}
$mitems[] = JHTML::_('select.option', '<OPTGROUP>', $list_a->title);
$lastMenuType = $list_a->menutype;
$tmpMenuType = $list_a->menutype;
}
$mitems[] = JHTML::_('select.option', $list_a->id, $list_a->treename);
}
if ($lastMenuType !== null) {
$mitems[] = JHTML::_('select.option', '</OPTGROUP>');
}
$result = JHTML::_('select.genericlist', $mitems, $this->name . '[]', 'class="inputbox" size="15" multiple="multiple"', 'value', 'text', $this->value);
return $result;
}
示例2: treerecurse
function treerecurse($id, $indent, $list, &$children, $maxlevel = 9999, $level = 0, $type = 1)
{
if (@$children[$id] && $level <= $maxlevel) {
foreach ($children[$id] as $v) {
$id = $v->id;
if ($type) {
$pre = '<sup>|_</sup> ';
$spacer = '. ';
} else {
$pre = '- ';
$spacer = ' ';
}
if ($v->parent == 0) {
$txt = $v->name;
} else {
$txt = $pre . $v->name;
}
$pt = $v->parent;
$list[$id] = $v;
$list[$id]->treename = "{$indent}{$txt}";
$list[$id]->children = count(@$children[$id]);
$list = JHTMLMenu::TreeRecurse($id, $indent . $spacer, $list, $children, $maxlevel, $level + 1, $type);
}
}
return $list;
}