<?php
/*
* @package LabCMS
* @copyright (c) 2006 Alexander Levin aka Loki (loki_angel@mail.ru)
* @support http://labcms.ru
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/
	$mod_template="menu.tpl";
	//значение по умолчанию
	if (!isset(LabConfig::$mcfg['menu_level'])) LabConfig::$mcfg['menu_level']=1;

  	$parent=array_key_exists((LabConfig::$mcfg['menu_level']-1), LabCMS::i()->parents)?LabCMS::i()->parents[(LabConfig::$mcfg['menu_level']-1)]:$parent=LabCMS::i()->id;
	
	if (LabCMS::i()->is_cached($mod_template, -1, LabCMS::i()->id)) return;
	
	$menu = Db::i()->select("-- CACHE: 24h
	SELECT tree_name,t.tree_id, path, external FROM ?_tree t WHERE parent_id=? AND menu=1 ORDER BY pos", $parent);
	
    foreach($menu as $key=>$m) {
    	if($m["tree_id"] == LabCMS::i()->parents[LabConfig::$mcfg['menu_level']])
    	$menu[$key]["active"]=1;
    }

    Tpl::i()->assign('menu', $menu);
