00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00020 class Tab {
00021 var $title = "Tab";
00022 var $url;
00023 var $current = false;
00024 }
00028 class TabBar {
00029 var $tabs = array();
00030
00031 function addTab($title, $url = "", $current = false) {
00032 $tab = new Tab;
00033 $tab->title = $title;
00034 if ($url != "") $tab->url = $url;
00035 $tab->current = $current;
00036 $this->tabs[$title] = $tab;
00037 }
00038
00039 function removeTab($title) {
00040 unset($this->tabs[$title]);
00041 }
00042
00043 function renameTab($oldTitle, $newTitle) {
00044 $this->tabs[$newTitle] = $this->tabs[$oldTitle];
00045 $this->tabs[$newTitle]->title = $newTitle;
00046 unset($this->tabs[$oldTitle]);
00047 }
00048 function setCurrent($title) {
00049 foreach($this->tabs as $key => $value) {
00050 $this->tabs[$key]->current = false;
00051 }
00052 $this->tabs[$title]->current = true;
00053 }
00054
00055 function renderTabBar() {
00056 $numberoftabs = count($this->tabs);
00057 $tabbar = "
00058 <div class=\"tabbar\"><span class=\"tabbar_left\"> </span>";
00059 foreach($this->tabs as $key => $value) {
00060 if(!$value->current) {
00061 $tabbar .= "<span class=\"tabbar_tab_left\"> </span><a href=\"{$value->url}\" class=\"tabbar_tab\"><span class=\"tabbar_tab\">{$value->title}</span></a><span class=\"tabbar_tab_right\"> </span>";
00062 } else {
00063 $tabbar .= "<span class=\"tabbar_tab_left_current\"> </span><span class=\"tabbar_tab_current\">{$value->title}</span><span class=\"tabbar_tab_right_current\"> </span>";
00064 }
00065 }
00066 $tabbar .= "<span class=\"tabbar_right\"> </span></div>";
00067 return $tabbar;
00068 }
00069 }
00070
00071 class CommandButton
00072 {
00073 var $title;
00074 var $command;
00075 var $url;
00076 var $icon;
00077
00078 function render()
00079 {
00080 if( $this->icon == null )
00081 $icon = "";
00082 else
00083 $icon = "<img style=\"vertical-align: middle;\" src=\"" . $this->icon . "\" alt=\"" . $this->title . "\" />";
00084 return "<a class=\"command\" title=\"" . $this->title . "\" href=\"" . $this->url . "\">[$icon" . $this->command . "]</a>";
00085 }
00086 }
00087
00088 class CommandSeparator
00089 {
00090 function render()
00091 {
00092 return " | ";
00093 }
00094 }
00095
00096 class TabWidget {
00097 var $tabbar;
00098 var $contents = "";
00099 var $commands;
00100
00101 function TabWidget () {
00102 $this->tabbar = new TabBar;
00103 }
00104 function addCommand($command, $title, $url, $icon = null) {
00105 $this->commands[$command] = new CommandButton;
00106 $this->commands[$command]->command = $command;
00107 $this->commands[$command]->title = $title;
00108 $this->commands[$command]->url = $url;
00109 $this->commands[$command]->icon = $icon;
00110 }
00111
00112 function addCommandSeparator()
00113 {
00114 $this->commands[] = new CommandSeparator;
00115 }
00116
00117 function renderTabWidget() {
00118 $tabwidget = $this->tabbar->renderTabBar() . "<div class=\"tabwidget\"><div class=\"wikirightalign\">";
00119 if (is_array($this->commands)) {
00120 foreach($this->commands as $key => $value) {
00121 $tabwidget .= $value->render();
00122 }
00123 } else {
00124 $tabwidget .= "<small style=\"font-size: 1px;\"> </small>";
00125 }
00126 $tabwidget .= "</div><div class=\"tabwidget_content\">" . $this->contents . "</div></div>";
00127 return $tabwidget;
00128 }
00129 }
00130 ?>