english/libraries/joomla/html/html/menu.php
/**
	 * Build the multiple select list for Menu Links/Pages
	 */
Build the multiple select list for Menu Links/Pages
Build the multiple select list for Menu Links / Pages
public static function linkoptions($all=false, $unassigned=false)
	{
		$db = JFactory::getDbo();
		$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, m.ordering'
		;
		$db->setQuery($query);
		$mitems = $db->loadObjectList();
		if ($db->getErrorNum()) {
			JError::raiseNotice(500, $db->getErrorMsg());
		}
		if (!$mitems) {
			$mitems = array();
		}
		$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::_('JOPTION_MENUS'));
			if ($all) {
				$mitems[] = JHtml::_('select.option',  0, JText::_('JALL'));
			}
			if ($unassigned) {
				$mitems[] = JHtml::_('select.option',  -1, JText::_('JOPTION_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->menutype);
				$lastMenuType = $list_a->menutype;
				$tmpMenuType  = $list_a->menutype;
			}
			$mitems[] = JHtml::_('select.option',  $list_a->id, $list_a->title);
		}
		if ($lastMenuType !== null) {
			$mitems[] = JHtml::_('select.option',  '</OPTGROUP>');
		}
		return $mitems;
	}
public static function linkoptions ( $ all = false , $ unassigned = false ) { $ db = JFactory :: getDbo ( ) ; $ 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, m.ordering' ; $ db -> setQuery ( $ query ) ; $ mitems = $ db -> loadObjectList ( ) ; if ( $ db -> getErrorNum ( ) ) { JError :: raiseNotice ( 500 , $ db -> getErrorMsg ( ) ) ; } if ( ! $ mitems ) { $ mitems = array ( ) ; } $ 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 :: _ ( 'JOPTION_MENUS' ) ) ; if ( $ all ) { $ mitems [ ] = JHtml :: _ ( 'select.option' , 0 , JText :: _ ( 'JALL' ) ) ; } if ( $ unassigned ) { $ mitems [ ] = JHtml :: _ ( 'select.option' , - 1 , JText :: _ ( 'JOPTION_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 -> menutype ) ; $ lastMenuType = $ list_a -> menutype ; $ tmpMenuType = $ list_a -> menutype ; } $ mitems [ ] = JHtml :: _ ( 'select.option' , $ list_a -> id , $ list_a -> title ) ; } if ( $ lastMenuType !== null ) { $ mitems [ ] = JHtml :: _ ( 'select.option' , '</OPTGROUP>' ) ; } return $ mitems ; }
Build the multiple select list for Menu Links/Pages
Build the multiple select list for Menu Links / Pages
// get a list of the menu items // Check for a database error. // Establish the hierarchy of the menu // First pass - collect children // Second pass - get an indent list of the items // Code that adds menu name to Display of Page(s)