<?php
/**
 * Copyright (C) 2009  Honghao Geng (genghonghao@gmail.com)
 * $Id: index.php 309 2009-11-09 05:25:02Z genghonghao $
 */

define('IN_ADMIN', TRUE);

require_once dirname(__FILE__) . '/includes/init.php';
require_once GEN_ROOT . '/admin/includes/menu.inc.php';

// 验证用户是否登录
if (false === verify_user()) {;
    header("Location: ../login.php");
}

$tpl->assign('admin', $_SESSION['user']['username']);

// 导航
$navigation = get_navigation();
$cur_nav = isset($_REQUEST['module']) ? (array_key_exists(trim($_REQUEST['module']), $navigation) ? trim($_REQUEST['module']) : '1_home_page') : '1_home_page';
$navigation[$cur_nav]['current'] = true;
$tpl->assign('nav', $navigation);

// 设置自动加载页
switch($cur_nav) {
    case '1_home_page':
        $loading_page = 'main.php';
        break;
    case '2_content_manage':
        $loading_page = 'content.php';
        break;
    case '3_system_setup':
        $loading_page = 'system.php';
        $view_size['height'] = "1000px;";
        $tpl->assign('view_size', $view_size);
        break;
    case '5_data_setup':
        $loading_page = 'data.php';
        break;
    case '6_image_manage':
        $loading_page = 'image.php';
        break;
    case '7_user_manage':
        $loading_page = 'user.php';
        break;
    case '8_other_manage':
        $loading_page = 'other.php';
        break;
    default:
       $loading_page = 'main.php';
        break;
}
$tpl->assign('loading_page', $loading_page);

// 导航下的分类
$tpl->assign('category', get_cur_nav_category($cur_nav));

$tpl->display('index.html');
?>