2017-02-23 15:21:34 +08:00
|
|
|
|
<?php
|
2016-08-21 23:06:17 +04:00
|
|
|
|
|
2017-03-10 10:50:11 +08:00
|
|
|
|
require_once "tools.php";
|
|
|
|
|
require_once "tools_session.php";
|
|
|
|
|
require_once "tools_json.php";
|
2016-08-21 23:06:17 +04:00
|
|
|
|
|
2017-03-10 10:50:11 +08:00
|
|
|
|
class UISideBar
|
|
|
|
|
{
|
|
|
|
|
private $active_page=null;
|
|
|
|
|
private $bar_list=null;
|
2016-08-23 18:08:07 +04:00
|
|
|
|
|
|
|
|
|
private $sidebar_width; //bootstarp中屏幕被分为12列宽,我们在PC桌面宽度环境,导航栏宽度设为1。手机/平板纵屏中,导航栏宽度设为2
|
2016-08-21 23:06:17 +04:00
|
|
|
|
|
2017-03-10 10:50:11 +08:00
|
|
|
|
public function __construct($ap,$sw)
|
|
|
|
|
{
|
|
|
|
|
$this->active_page=$ap;
|
2016-08-28 20:04:16 +04:00
|
|
|
|
$this->sidebar_width=$sw;
|
2017-03-10 10:50:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-10 11:09:03 +08:00
|
|
|
|
public function add($code,$text,$link)
|
2017-03-10 10:50:11 +08:00
|
|
|
|
{
|
|
|
|
|
$this->bar_list[$code]=array("link"=>$link,"text"=>$text);
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-10 11:09:03 +08:00
|
|
|
|
public function set_active($code)
|
|
|
|
|
{
|
|
|
|
|
$this->active_page=$code;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-10 10:50:11 +08:00
|
|
|
|
public function to_json()
|
|
|
|
|
{
|
|
|
|
|
return json_encode($bar_list,JSON_UNESCAPED_UNICODE);
|
|
|
|
|
}
|
2016-08-21 23:06:17 +04:00
|
|
|
|
|
2017-03-10 10:50:11 +08:00
|
|
|
|
private function echo_item($code,$text,$link)
|
|
|
|
|
{
|
2016-08-21 23:06:17 +04:00
|
|
|
|
echo '<a class="list-group-item';
|
|
|
|
|
|
2017-03-10 10:50:11 +08:00
|
|
|
|
if($code==$this->active_page)
|
2016-08-21 23:06:17 +04:00
|
|
|
|
echo ' active';
|
|
|
|
|
|
2017-03-10 15:25:51 +08:00
|
|
|
|
echo '" href="'.$link.'">'.$text.'</a>';
|
2017-03-10 10:50:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function start()
|
|
|
|
|
{
|
|
|
|
|
if($this->bar_list==null)return;
|
2016-08-21 23:06:17 +04:00
|
|
|
|
|
2016-08-28 20:04:16 +04:00
|
|
|
|
echo '<div class="row" style="margin-left: 0px; margin-right: 0px;">';
|
2016-08-23 18:08:07 +04:00
|
|
|
|
echo '<div class="col-xs-'.$this->sidebar_width.' bs-docs-sidebar" style="padding-top: 15px;">
|
2016-08-21 23:06:17 +04:00
|
|
|
|
<div class="list-group bs-docs-sidenav affix-top">';
|
|
|
|
|
|
2017-03-10 10:50:11 +08:00
|
|
|
|
foreach($this->bar_list as $code=>$obj)
|
|
|
|
|
{
|
|
|
|
|
$link=$obj["link"];
|
|
|
|
|
$text=$obj["text"];
|
|
|
|
|
|
2017-03-10 11:09:03 +08:00
|
|
|
|
$this->echo_item($code,$text,$link);
|
2017-03-10 10:50:11 +08:00
|
|
|
|
}
|
2016-08-21 23:06:17 +04:00
|
|
|
|
|
|
|
|
|
echo '</div>
|
|
|
|
|
</div>
|
2016-08-28 13:31:43 +04:00
|
|
|
|
<div div class="col-xs-'.(12-$this->sidebar_width).'" style="padding-left: 0px;">';
|
2017-03-10 10:50:11 +08:00
|
|
|
|
}
|
2016-08-21 23:06:17 +04:00
|
|
|
|
|
2017-03-10 10:50:11 +08:00
|
|
|
|
public function end()
|
|
|
|
|
{
|
2016-08-28 20:04:16 +04:00
|
|
|
|
echo '</div>
|
|
|
|
|
</div>';
|
2017-03-10 10:50:11 +08:00
|
|
|
|
}
|
|
|
|
|
};//class UISideBar
|