<?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;
  }
}

?>
