Example #1
0
 static function generate_main_menu($level = 0)
 {
     global $db;
     $content = array();
     $level_str = "";
     if ($level > 0) {
         $level_str = "param_level BETWEEN 0 AND {$level} AND";
     }
     $res = $db->get_all("SELECT * FROM fw_tree WHERE {$level_str} status='1' ORDER BY param_left");
     $content = Common::generate_menu($res, $res[0]['param_left'], $res[0]['param_right']);
     $modules = array('shop', 'cabinet', 'site_map');
     foreach ($content as $value) {
         if ($value['param_level'] == 1) {
             if (!in_array($value['module'], $modules)) {
                 $modules[$value['url']] = $value['module'];
             }
         }
     }
     if (in_array("shop", $modules)) {
         $shop_menu = $db->get_all("SELECT id,name,url,param_left,param_right,(param_level+1) as param_level,'shop' as module,'1' as status FROM fw_catalogue WHERE status='1' ORDER BY param_left");
         $shop_menu = Common::generate_menu($shop_menu, $shop_menu[0]['param_left'], $shop_menu[0]['param_right']);
         //print_r($shop_menu);
         $content = MyArray::insert_array_into_array($content, $shop_menu, "shop");
     }
     if (in_array("forum", $modules)) {
         $forum_menu = $db->get_all("SELECT id,name,url,param_left,param_right,(param_level+1) as param_level,'forum' as module,status FROM fw_forums WHERE status='1' ORDER BY param_left");
         $forum_menu = Common::generate_menu($forum_menu, $forum_menu[0]['param_left'], $forum_menu[0]['param_right']);
         $content = MyArray::insert_array_into_array($content, $forum_menu, "forum");
     }
     if (in_array("news", $modules)) {
         $news_menu = $db->get_all("SELECT id,title as name,CONCAT('archive','/',id) as url,'1' as param_left,'2' as param_right,'2' as param_level,'news' as module,'1' as status FROM fw_news ORDER BY publish_date DESC");
         $content = MyArray::insert_array_into_array($content, $news_menu, "news");
     }
     /*if (in_array("cabinet", $modules)) {
     			
     			$cabinet_menu=array(
     				array(
     					"id" => "1",
     					"name" => "Вход в систему",
     					"url" => "login",
     					"param_left" => "1",
     					"param_right" => "2",
     					"param_level" => "2",
     					"module" => "cabinet",
     					"status" => "1"
     				),
     
     					array(
     					"id" => "3",
     					"name" => "Выполненные заказы",
     					"url" => "orders",
     					"param_left" => "5",
     					"param_right" => "6",
     					"param_level" => "2",
     					"module" => "cabinet",
     					"status" => "1"
     				),
     
     				array(
     					"id" => "4",
     					"name" => "Регистрация",
     					"url" => "register",
     					"param_left" => "7",
     					"param_right" => "8",
     					"param_level" => "2",
     					"module" => "cabinet",
     					"status" => "1"
     				),
     				array(
     					"id" => "5",
     					"name" => "Выйти из системы",
     					"url" => "logout",
     					"param_left" => "9",
     					"param_right" => "10",
     					"param_level" => "2",
     					"module" => "cabinet",
     					"status" => "1"
     				)
     			);
     			$content=MyArray::insert_array_into_array($content,	$cabinet_menu, "cabinet");
     		}*/
     $full_url = "/";
     $_tmp_full_url = $full_url;
     $content = Common::generate_main_menu_full_url($content, $full_url);
     return $content;
 }