Exemplo n.º 1
0
function handleChildren($arEls, $path)
{
    foreach ($arEls as $elName => $arEl) {
        if (strpos($path, ",") !== false) {
            if (isset($arEl['*'])) {
                $thirdLevelName = '__bx_thirdLevel_' . $GLOBALS["thirdLevelId"];
                $GLOBALS["thirdLevelId"]++;
                foreach ($arEl['*'] as $cN => $arC) {
                    pushElement($path, $cN, $arC['TITLE'], false, $arC['ICON'], $arC['COMPLEX'], '{DESCRIPTION : \'' . CUtil::JSEscape($arC['DESCRIPTION']) . '\'}', $thirdLevelName, $arC['SCREENSHOT']);
                }
            }
            continue;
        }
        $realPath = $path == '' ? $elName : $path . ',' . $elName;
        pushElement($path, $elName, $arEl['@']['NAME'], true, '', 'N');
        if (isset($arEl['#'])) {
            handleChildren($arEl['#'], $realPath);
        }
        if (is_array($arEl['*']) && !empty($arEl['*'])) {
            foreach ($arEl['*'] as $compName => $arC) {
                pushElement($realPath, $compName, $arC['TITLE'], false, $arC['ICON'], $arC['COMPLEX'], '{DESCRIPTION : \'' . CUtil::JSEscape($arC['DESCRIPTION']) . '\'}', false, $arC['SCREENSHOT']);
            }
        }
    }
}
Exemplo n.º 2
0
		function handleChildren($value){
			global $ch_level;
			global $menu;
			if(!empty($value['children'])){ //if the top level item has children items, make an empty copy of the first value
				if($ch_level>0){
					$menu_class="dropdown-submenu";
					$toggles = 'class="sub-a" class="dropdown-toggle" data-toggle="dropdown"';
				} else {
					$menu_class="dropdown t".$ch_level;
					$toggles = 'class="dropdown-toggle" data-toggle="dropdown"';
					
				}
				$menu .= '<li class="'.$menu_class.'"><a href="#" '.$toggles.'>'.$value['name'].'<b class="caret"></b></a>';
				$menu .= '<ul class="dropdown-menu men-level-'.$ch_level.'">';
				if($value['href']!='#'){
					//$menu .= '<li class="dropdown">'.$value['name'].'</li>'; //this copies the top level item into the first child
					$menu .= '<li><a href="'.$value['href'].'" target="'.$value['target'].'">'.$value['name'].'</a></li>'; //this copies the top level item into the first child
				}
				++$ch_level;
				foreach($value['children'] as $c_value){ //loop through the child elements
					if(substr($c_value['name'], 0, 4)=='CRM_'){
						$c_value['name'] = substr($c_value['name'],4);
					}
					$menu .=handleChildren($c_value);
					//$menu .= '<li><a href="'.$c_value['href'].'" target="'.$c_value['target'].'">'.$c_value['name'].'</a></li>';
				}
				--$ch_level;
				$menu .= '</ul></li>';
			}else{ //if there are no child elements, just echo out the menu item
				$menu .= '<li><a href="'.$value['href'].'" target="'.$value['target'].'">'.$value['name'].'</a></li>';
			}
		}
Exemplo n.º 3
0
function quick_menu($before='', $after='', $additionalMenu = '', $custom_caret = ''){ //pulls domain from config file
	global $menu;
	$menu = '';
	$menu .= '<ul class="nav navbar-nav men-level-'.$ch_level.'">'.$before;
	$file = menu_file_path($additionalMenu);
	$json_menu = json_decode(file_get_contents($file), true);
	if(is_array($json_menu)){
		foreach($json_menu as $value){
			$menu.=handleChildren($value);
		}
	}
	$menu_id = 'nav_menu';
	if($additionalMenu != ''){
		$menu_id .= '_' . $additionalMenu;
	}
	$menu .= $after.'</ul>';
	echo '<div id="' . $menu_id . '" class="NP collapse navbar-collapse navbar-ex1-collapse">'.$menu.'</div>';
	$da_neccessary_javascript = "<script type=\"text/javascript\">
		$('ul.dropdown-menu [data-toggle=dropdown]').on('click', function(event) {
			event.preventDefault(); 
			event.stopPropagation(); 
			$(this).parent().toggleClass('open');
			var menu = $(this).parent().find(\"ul\");
			var menupos = menu.offset();
		  
			if ((menupos.left + menu.width()) + 30 > $(window).width()) {
				var newpos = - menu.width();      
			} else {
				var newpos = $(this).parent().width();
			}
			menu.css({ left:newpos });
		});
		function checkForChanges(){
			if (!$('.navbar-collapse').hasClass('in')){
				$('.nav-row').css('max-height','40px');
			} else {
				$('.nav-row').css('max-height','none');
				setTimeout(checkForChanges, 500);
			}
		}
		$(function(){
			checkForChanges();
		});
	</script>";
	echo $da_neccessary_javascript;
}