Exemple #1
0
	public static function showMenu($e, $view){
		preg_match_all("/<div[^>]*>\[menu=(.*?)\/\]<\/div>/si", $view->html, $matches);
		$menus = array();
		$replaceStrings = array();
		if(count($matches) > 1){
			$replaceStrings = $matches[0];
			$menus = $matches[1];
		}
		for ($i = 0; $i < count($menus); $i++){
			$data = json_decode($menus[$i], true);
			$track = new Navigation_Class_Track();
			$track->setRow($data);
			$options = getParam('options', Navigation_Class_Manager::$defaultMenuConfig, $data);
			$replaceString = $replaceStrings[$i];
			$menuId = $options['name'];
			if(!strlen($menuId)){
				$menuId = 'menu-' . md5(microtime());
			}
			
			//Replace the content
			$html = $track->getHtml($menuId, $options['navClass']);
			ob_start();
			?>
			<script type="text/javascript">
				Ext.EventManager.on(window, 'load',function(){
					var options = Ext.decode('<?php echo json_encode($options); ?>');
					new Ext.ux.PapercutMenu('<?php echo $menuId; ?>', options);
				});
			</script>
			<?php
			$html .= ob_get_clean();
			$view->html = str_replace($replaceString, $html, $view->html);
		}	
	}