<?php
//後台的選單
if(!function_exists('admin_toolbar')){
  //xoops_version.php記得加上 $modversion['system_menu'] = 1; （for 2.5）
  function admin_toolbar($n="0"){
    $version=floatval(substr(XOOPS_VERSION,6,3));
    if($version < 2.5){
      include_once XOOPS_ROOT_PATH."/Frameworks/art/functions.php";
      include_once XOOPS_ROOT_PATH."/Frameworks/art/functions.admin.php";
      loadModuleAdminMenu($n);
    }
  }
}

//$moduleName用於當該工具列是整合到佈景，而非模組的時候使用。
//首頁的連結工具
if(!function_exists('toolbar')){
  //$interface_menu[工具列名稱]="網址";
  //$interface_logo[工具列名稱]="圖檔名稱";（圖檔一律放到模組的images下）
  function toolbar($interface_menu=array(),$interface_logo=array(),$id="id='menu'",$li="",$moduleName=""){
    if(empty($interface_menu))return;
    $td="";

    if(is_array($interface_menu)){
      foreach($interface_menu as $title => $url){
        $urlPath=(empty($moduleName) or substr($url,0,7)=="http://")?$url:XOOPS_URL."/modules/{$moduleName}/{$url}";
        $basename=basename($_SERVER['SCRIPT_NAME']);
        $baseurl=basename($url);

        $li_class=preg_match("/^{$basename}/",$baseurl)?$li:"";
        $selected=preg_match("/^{$basename}/",$baseurl)?"selected":"";
        $td.="<li $li_class><a href='{$urlPath}' class='$selected'>{$title}</a></li>\n";
      }
    }else{
      return;
    }

    $cssCode="";
    if(empty($moduleName)){
      $id="id='toolbar'";
      $cssCode="<style type='text/css'>
        #toolbar{
          margin:10px 0px 10px;
        }
        #toolbar ul li{
          list-style:none outside;
          float:left;
          padding:3px 0px;
          margin:2px 0px;
        }
        #toolbar a:link, #toolbar a:visited {
            font-size: 11px;
            padding: 3px 10px 2px 10px;
            color: #707070;
            background-color: #FBFBFB;
            text-decoration: none;
            border: 1px solid #E0E0E0;
            margin:0px 2px;
        }
         #toolbar a:hover, #toolbar a.selected {
            color: #000000;
            background-color: #FFFFCC;
            border: 1px solid #505050;
          }
        </style>";
    }

    $main="
    $cssCode
    <div $id>
    <ul>
    {$td}
    </ul>
    </div>
    <div style='clear:both;'></div>
    ";
    return $main;
  }
}


if(!function_exists('toolbar_bootstrap')){
  function toolbar_bootstrap($interface_menu=array()){

    if(empty($interface_menu))return;

    $main="
    <style>


    #mod .navbar-inner{
      min-height:20px;
      padding-right:20px;
      padding-left:20px;
      background-color:#fafafa;
      background-image:-moz-linear-gradient(top,#fff,#f2f2f2);
      background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#f2f2f2));
      background-image:-webkit-linear-gradient(top,#fff,#f2f2f2);
      background-image:-o-linear-gradient(top,#fff,#f2f2f2);
      background-image:linear-gradient(to bottom,#fff,#f2f2f2);
      background-repeat:repeat-x;
      border:1px solid #d4d4d4;
      -webkit-border-radius:4px;
      -moz-border-radius:4px;
      border-radius:4px;
      filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff',endColorstr='#fff2f2f2',GradientType=0);
      *zoom:1;
      -webkit-box-shadow:0 1px 4px rgba(0,0,0,.065);
      -moz-box-shadow:0 1px 4px rgba(0,0,0,.065);
      box-shadow:0 1px 4px rgba(0,0,0,.065)
    }


    #mod .brand{
      display:block;
      float:left;
      padding:5px 10px 5px 20px;
      margin-left:-20px;
      font-size:11pt;
      color:#777;
      text-shadow:0 1px 0 #fff
    }


    #mod .navbar-text{
      margin-bottom:0;
      line-height:20px;
      color:#777
    }

    #mod .navbar-link{
      color:#777
    }

    #mod .navbar-link:hover,.navbar-link:focus{
      color:#333
    }

    #mod .divider-vertical{
      height:20px;
      margin:0 9px;
      border-right:1px solid #fff;
      border-left:1px solid #f2f2f2
    }

    #mod .nav > li a {
      color:#707070;
      font-weight:normal;
      text-shadow: none;
      padding:5px 15px;
    }

    #mod .nav > li.active a {
      font-weight:normal;
      color: rgb(85, 85, 85);
      text-decoration: none;
      background-color: rgb(229, 229, 229);
      box-shadow: 0px 3px 8px rgba(0, 0, 0, 0.125) inset;
    }


    #mod .nav > li a:hover {
      background-color:#707070;
      font-weight:normal;
      color: white;
    }
    </style>

    <div class='navbar' id='mod' style='position: static;'>
      <div class='navbar-inner'>
        <div class='container'>
          <a class='btn btn-navbar' data-toggle='collapse' data-target='.navbar-inverse-collapse'>
            <span class='icon-bar'></span>
            <span class='icon-bar'></span>
            <span class='icon-bar'></span>
          </a>
          <a class='brand' href='index.php'><i class='icon-home'></i></a>
          <div style='height: auto;' class='nav-collapse navbar-inverse-collapse in collapse'>
            <ul class='nav'>";

    if(is_array($interface_menu)){
      foreach($interface_menu as $title => $url){
        $urlPath=(empty($moduleName) or substr($url,0,7)=="http://")?$url:XOOPS_URL."/modules/{$moduleName}/{$url}";
        $basename=basename($_SERVER['SCRIPT_NAME']);
        $baseurl=basename($url);
        //if($baseurl=="index.php" and !preg_match("/admin/", $url))continue;
        $active=preg_match("/^{$basename}/",$baseurl)?"class='active'":"";
        $main.="
        <li {$active}>
        <a href='{$urlPath}'>{$title}</a>
        </li>";
      }
    }else{
      return;
    }
    $main.="
          </ul>
        </div>
      </div>
    </div>
  </div>
    ";
    return $main;
  }
}



?>
