<?php

if(!defined('VI_BASE')) {
	exit('Access Denied');
}

///////////////////////////////////
?>

<div id="wrapper">

    <!--header start-->
    <div id="header">
    
		<?php
        //加载用户偏好
        require VI_ROOT.'dialog/classic.loader.php';
        ?>
        
        <div id="header-logo">
            <?php echo '<strong><a href="'. $_G['setting']['global']['url'] .'" title="'. $_G['setting']['global']['site'] .'" target="_blank">'. $_G['setting']['global']['site'] .'</a></strong>';?>
        </div>
        
        <!--info start-->
        <div id="header-info">
            <?php
                //gravatar
                if( $_G['setting']['global']['avatar'] == 'gravatar' && $_SESSION['Manager']["email"] ){
                    $avatar = "http://www.gravatar.com/avatar.php?gravatar_id=".md5( strtolower($_SESSION['Manager']["email"]) )."&default=&size=40";
                }else{
                    $avatar = 'image/'.($_SESSION['Manager']["avatar"]?'avatar/'.$_SESSION['Manager']["avatar"]:'avatar.jpg');
                }
            ?>
            <a rel="javascript:void(0);"  id="bind_avatar"><img src="<?php echo $avatar;?>" alt="修改头像" /></a>
        
            <div>
                <?php
                if( $_SESSION['Manager']['account'] ){
                    echo '<strong>'.$_SESSION['Manager']['account'].'</strong> <span>['.$_CACHE['system']['group'][$_SESSION['Manager']['gid']]['name'].']</span>';               
                }else{
					echo '欢迎您，请登录';
                }
                ?>
            </div>
            
                <div>
                <a id="bind_start">开始</a>
                - <a id="bind_system">系统设置</a>
                - <a  id="bind_module">模块管理</a>
                <?php
                if( $_SESSION['Manager']['account'] ){
                    echo ' - <a id="bind_account">修改资料</a> - <a id="bind_logout">退出</a> ';               
                }
                ?>
                <?php
                    //AdobeAIR
                    if( strpos($_SERVER["HTTP_USER_AGENT"],"AdobeAIR") !== false ){
                        echo '- <a onclick="javascript:location.reload(true);">刷新</a>';
                    }
                ?>
                </div>
            </div>
            <!--info end-->
        
            <!--tool start-->
            <div id="header-tool">
        
            <div id="header-links">    
                <?php
                foreach( $_G['project']['menu'] as $key => $val ){
                echo '<a href="'.$key.'" target="_blank">'.$val.'</a>';	
                }
                ?>
            </div>
            
            <div id="header-search">
                <form action="#" onsubmit="">
                <input type="text" class="text" maxlength="12" name="q" id="q" value="输入关键字并回车.." />
                </form>
            </div>
            
            </div>
        <!--tool end-->
    </div>
    <!--header end-->
    
    <!--control start-->
    <div id="control" title="显示/隐藏侧边栏"></div>
    <!--control end-->
    
    <!--sidebar start-->
    <div id="sidebar">
        <?php
        
        //菜单控制
        if( $_SESSION['Manager']['account'] ){						
            echo '
                <div id="sidebar-search">
                    <ul>
                        <li>'.loader_image("icon/user.png").' <a id="bind_admin">用户</a></li>
                        <li>'.loader_image("icon/folder.png").' <a id="bind_attach">附件</a></li>					
                        <li>'.loader_image("icon/info.png").' <a id="bind_licence">验证</a></li>
                    </ul>
                </div>
                ';
        }
        ?>
    
        <div id="sidebar-menu">
        
        <?php
        //菜单控制
        if( $_SESSION['Manager']['account'] == '' ){
        echo '
        <div id="menu-powered">
            <p></p>
            <p align="center"><a href="http://www.veryide.com/buy.php" target="_blank"><img src="image/model/'.$_G['licence']["type"].'.gif" alt="'.$_G['version'][$_G['licence']["type"]]["name"].'" /></a></p>
            <p align="center" class="text-key">VeryIDE '.$_G['version'][$_G['licence']["type"]]["name"].'用户</p>
            <p align="center">- 登录后菜单可见 -</p>
            <p align="center">'.$_G['project']['powered'].'</p>
        </div>
        ';
                
        }else{
            
                echo '
                <div id="menu-title">
                    <span id="bind_splay" title="展开菜单"></span>
                    <span class="custom" id="bind_custom" title="偏好设置"></span>
                    <strong>VeryIDE</strong>
                </div>';
    
                //菜单缓存
                echo '<div id="menu-link">';
                
                //当前用户组权限设置
                $permit = $_CACHE['system']['group'][$_SESSION['Manager']["gid"]]["config"];
                
                //模块菜单
                foreach( $_CACHE['system']['module'] as $key ){
                    
                    //判断模块状态、是否有菜单、是否设置偏好、当前用户是否有权限
                    if( isset($key["config"]) && $key["config"] && $key["state"] ){
    
                        //config
                        require_once VI_ROOT.$key["config"];
                        
                        if( is_array($_G['module'][$key["appid"]]["menu"]) ){
                            
                            $icon = '<img src="module/'.$key["appid"].'/icon.png" />';
                        
                            echo '<div data-appid=\''.$key["appid"].'\'><span>'.$icon.$key["name"].'</span></div>';
                            echo '<ul id="mod_'.$key["appid"].'">';
                            
                                foreach( $_G['module'][$key["appid"]]["menu"] as $name => $link ){                                        
                                        echo '<li><a href="'.VI_BASE.'module/'.$key["appid"]."/".$link.'">'.$name.'</a></li>';
                                }
                            
                            echo '</ul>';
                        }
                        
                    }
                
                }
                
                echo '</div>';
    
            }
            ?>
    
        </div>
    </div>
    <!--sidebar end-->
    
    <!--container start-->
    <div id="container">
        <div>
            <iframe frameborder="0" id="column" allowtransparency="true" name="column" src="dialog/blank.html"></iframe>
        </div>
    </div>
    <!--container end-->

</div>