english/modules/mod_djmenu/helper.php
/**
     
     * Utility function for writing a menu link
     
     */
Utility function for writing a menu link
Utility function for writing a menu link
function mosGetMenuLink($item, $level = 0, &$params, $havechild = null) {
        $app 	= JFactory::getApplication();
        $menu 	= $app->getMenu();
		$item->flink = $item->link;
		if(!isset($item->level_diff)) {
	        switch ($item->type) {
						case 'separator':
							$item->browserNav = 3;
							break;
						case 'url':
							if ((strpos($item->link, 'index.php?') === 0) && (strpos($item->link, 'Itemid=') === false)) {
								$item->flink = $item->link.'&Itemid='.$item->id;
							}
							break;
						case 'alias':
							$item->flink = 'index.php?Itemid='.$item->params->get('aliasoptions');
							break;
						default:
							$router = JSite::getRouter();
							if ($router->getMode() == JROUTER_MODE_SEF) {
								$item->flink = 'index.php?Itemid='.$item->id;
							}
							else {
								$item->flink .= '&Itemid='.$item->id;
							}
							break;
			}
	        if (strcasecmp(substr($item->flink, 0, 4), 'http') && (strpos($item->flink, 'index.php?') !== false)) {
				$item->flink = JRoute::_($item->flink, true, $item->params->get('secure'));
			} else {
				$item->flink = JRoute::_($item->flink);
			}
			$item->title = htmlspecialchars($item->title);
			$item->anchor_css = htmlspecialchars($item->params->get('menu-anchor_css', ''));
			$item->anchor_title = htmlspecialchars($item->params->get('menu-anchor_title', ''));
			$item->menu_image = $item->params->get('menu_image', '') ? htmlspecialchars($item->params->get('menu_image', '')) : '';
		}
		$anchor_title = $item->anchor_title ? 'title="'.$item->anchor_title.'" ' : '';
		if ($item->menu_image) {
				$item->params->get('menu_text', 1 ) ? 
				$linktype = '<img src="'.$item->menu_image.'" alt="'.$item->title.'" /><span class="image-title">'.$item->title.'</span> ' :
				$linktype = '&nbsp;<img src="'.$item->menu_image.'" alt="'.$item->title.'" />&nbsp;';
		} 
		else { 
			$linktype = $item->title;
		}
        $classplus = '';        
        if (in_array($item->id, $this->tabakt)) {        
            $classplus = 'active ';
        }
		$classplus .= $item->anchor_css;
		$class = 'class="'.$classplus.'"';;
        if ($level == 0) $class = 'class="dj-up_a '.trim($classplus).'"';            
        if ($havechild && $level != 0) {        
            if ( empty($classplus))
                $class = 'class="dj-more"';                
            else
                $class = 'class="dj-more-'.$classplus.'"';                
        }
		$spanclass = '';
        if ($havechild && $level == 0) {        
            $spanclass = 'class="dj-drop" ';            
        }
        if ($level == 0) {
            $linktype = '<span '.$spanclass.'>'.$linktype.'</span>';
        }
        $link = '';
        switch ($item->browserNav) {
            default:
            case 0:            
				$link = '<a href="'.$item->flink.'" '.$class.' '.$anchor_title.'>'.$linktype.'</a>';
                break;
			case 1:
				$link = '<a href="'.$item->flink.'" '.$class.' '.$anchor_title.' target="_blank">'.$linktype.'</a>';
				break;
            case 2:
                $attribs = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550';
				$link = '<a href="'.$item->flink.'" onclick="window.open(this.href,\'targetWindow\',\''.$attribs.'\');return false;" '.$class.' '.$anchor_title.'>'.$linktype.'</a>';
                break;
            case 3:
                $link = '<a '.$class.' '.$anchor_title.'>'.$linktype.'</a>';
                break;
        }
        return $link;
    }
function mosGetMenuLink ( $ item , $ level = 0 , & $ params , $ havechild = null ) { $ app = JFactory :: getApplication ( ) ; $ menu = $ app -> getMenu ( ) ; $ item -> flink = $ item -> link ; if ( ! isset ( $ item -> level_diff ) ) { switch ( $ item -> type ) { case 'separator' : $ item -> browserNav = 3 ; break ; case 'url' : if ( ( strpos ( $ item -> link , 'index.php?' ) === 0 ) && ( strpos ( $ item -> link , 'Itemid=' ) === false ) ) { $ item -> flink = $ item -> link . '&Itemid=' . $ item -> id ; } break ; case 'alias' : $ item -> flink = 'index.php?Itemid=' . $ item -> params -> get ( 'aliasoptions' ) ; break ; default : $ router = JSite :: getRouter ( ) ; if ( $ router -> getMode ( ) == JROUTER_MODE_SEF ) { $ item -> flink = 'index.php?Itemid=' . $ item -> id ; } else { $ item -> flink .= '&Itemid=' . $ item -> id ; } break ; } if ( strcasecmp ( substr ( $ item -> flink , 0 , 4 ) , 'http' ) && ( strpos ( $ item -> flink , 'index.php?' ) !== false ) ) { $ item -> flink = JRoute :: _ ( $ item -> flink , true , $ item -> params -> get ( 'secure' ) ) ; } else { $ item -> flink = JRoute :: _ ( $ item -> flink ) ; } $ item -> title = htmlspecialchars ( $ item -> title ) ; $ item -> anchor_css = htmlspecialchars ( $ item -> params -> get ( 'menu-anchor_css' , '' ) ) ; $ item -> anchor_title = htmlspecialchars ( $ item -> params -> get ( 'menu-anchor_title' , '' ) ) ; $ item -> menu_image = $ item -> params -> get ( 'menu_image' , '' ) ? htmlspecialchars ( $ item -> params -> get ( 'menu_image' , '' ) ) : '' ; } $ anchor_title = $ item -> anchor_title ? 'title="' . $ item -> anchor_title . '" ' : '' ; if ( $ item -> menu_image ) { $ item -> params -> get ( 'menu_text' , 1 ) ? $ linktype = '<img src="' . $ item -> menu_image . '" alt="' . $ item -> title . '" /><span class="image-title">' . $ item -> title . '</span> ' : $ linktype = '&nbsp;<img src="' . $ item -> menu_image . '" alt="' . $ item -> title . '" />&nbsp;' ; } else { $ linktype = $ item -> title ; } $ classplus = '' ; if ( in_array ( $ item -> id , $ this -> tabakt ) ) { $ classplus = 'active ' ; } $ classplus .= $ item -> anchor_css ; $ class = 'class="' . $ classplus . '"' ; ; if ( $ level == 0 ) $ class = 'class="dj-up_a ' . trim ( $ classplus ) . '"' ; if ( $ havechild && $ level != 0 ) { if ( empty ( $ classplus ) ) $ class = 'class="dj-more"' ; else $ class = 'class="dj-more-' . $ classplus . '"' ; } $ spanclass = '' ; if ( $ havechild && $ level == 0 ) { $ spanclass = 'class="dj-drop" ' ; } if ( $ level == 0 ) { $ linktype = '<span ' . $ spanclass . '>' . $ linktype . '</span>' ; } $ link = '' ; switch ( $ item -> browserNav ) { default : case 0 : $ link = '<a href="' . $ item -> flink . '" ' . $ class . ' ' . $ anchor_title . '>' . $ linktype . '</a>' ; break ; case 1 : $ link = '<a href="' . $ item -> flink . '" ' . $ class . ' ' . $ anchor_title . ' target="_blank">' . $ linktype . '</a>' ; break ; case 2 : $ attribs = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550' ; $ link = '<a href="' . $ item -> flink . '" onclick="window.open(this.href,\'targetWindow\',\'' . $ attribs . '\');return false;" ' . $ class . ' ' . $ anchor_title . '>' . $ linktype . '</a>' ; break ; case 3 : $ link = '<a ' . $ class . ' ' . $ anchor_title . '>' . $ linktype . '</a>' ; break ; } return $ link ; }
Utility function for writing a menu link
Utility function for writing a menu link
// If this is an internal Joomla link, ensure the Itemid is set. // If this is an alias use the item id stored in the parameters to make the link. // get image if selected // Note. It is important to remove spaces between elements. // Add classes // cases are slightly different // same window // _blank // open in a popup window // don't link it