00001 <?
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 define("BUTTON_WIDTH", 100);
00021
00022 class ToolBarJames
00023 {
00024
00025
00026 var $width;
00027 var $align;
00028
00029
00030 var $numButtons;
00031
00032
00033 var $buttons;
00034
00035
00036 var $cssToolbar;
00037 var $cssButton;
00038
00039
00040 var $target;
00041
00042
00043 var $buttonWidth;
00044
00045
00046
00047 function ToolBarJames()
00048 {
00049 $this->numButtons = 0;
00050 $this->width = 100;
00051 $this->align = "center";
00052 $this->cssToolbar = "ToolBarJames";
00053 $this->cssButton = "TBButton";
00054 $this->target = "";
00055 $this->buttonWidth = BUTTON_WIDTH;
00056
00057 switch (func_num_args())
00058 {
00059 case 2:
00060 $this->width = func_get_arg(1);
00061 case 1:
00062 $this->align = func_get_arg(0);
00063 }
00064 }
00065
00066
00067 function setCssClasses($toolbar, $button)
00068 {
00069 $this->cssToolbar = $toolbar;
00070 $this->cssButton = $button;
00071 }
00072
00073
00074 function setTarget($target)
00075 {
00076 $this->target = $target;
00077 }
00078
00079
00080 function setButtonWidth($buttonWidth)
00081 {
00082 $this->buttonWidth = $buttonWidth;
00083 }
00084
00085
00086
00087 function AddButton($name, $link)
00088 {
00089 if (func_num_args() == 3)
00090 $image = func_get_arg(2);
00091 else
00092 $image = "";
00093
00094 $this->buttons[$this->numButtons] = new TBButton($name, $link, $image);
00095
00096 $this->numButtons++;
00097 }
00098
00099
00100
00101 function AddButtonSelected($name, $link)
00102 {
00103 if (func_num_args() == 3)
00104 $image = func_get_arg(2);
00105 else
00106 $image = "";
00107
00108 $this->buttons[$this->numButtons] = new TBButton($name, $link, $image);
00109
00110 $this->buttons[$this->numButtons]->setSelected(true);
00111
00112 $this->numButtons++;
00113 }
00114
00115
00116
00117 function PrintAll()
00118 {
00119
00120
00121 if (func_num_args() == 1)
00122 {
00123 $autoAdjust = func_get_arg(0);
00124 $this->PrintCommon(true, $autoAdjust);
00125 }
00126 else
00127 $this->PrintCommon(true, true);
00128 }
00129
00130
00131
00132 function PrintOnlyText()
00133 {
00134
00135
00136 if (func_num_args() == 1)
00137 {
00138 $autoAdjust = func_get_arg(0);
00139 $this->PrintCommon(false, $autoAdjust);
00140 }
00141 else
00142 $this->PrintCommon(false, true);
00143 }
00144
00145
00146
00147 function PrintCommon($all, $autoAdjust)
00148 {
00149
00150 if ($autoAdjust)
00151 $html_width = floor(100/$this->numButtons)."%";
00152 else
00153 $html_width = $this->buttonWidth;;
00154
00155 print "<table width='".$this->width."%' class='".$this->cssToolbar."' align='".$this->align."'>\n";
00156 print "<tr>\n";
00157
00158
00159
00160 if ((! $autoAdjust) and (($this->align=="center") || ($this->align=="right")))
00161 echo "\t<td> </td>\n";
00162
00163
00164
00165 for ($i = 0; $i < $this->numButtons; $i++)
00166 {
00167 echo "\t<td class='".$this->cssButton."' width='".$html_width."' align='center'>\n";
00168
00169 if ($all)
00170 $this->buttons[$i]->PrintAll($this->cssButton, $this->target);
00171 else
00172 $this->buttons[$i]->PrintOnlyText($this->cssButton, $this->target);
00173 echo "\t</td>\n";
00174 }
00175
00176
00177
00178
00179 if ((! $autoAdjust) and (($this->align=="center") || ($this->align=="left")))
00180 echo "\t<td> </td>\n";
00181
00182
00183 print "</tr>\n";
00184 print "</table>\n";
00185 }
00186
00187
00188 }
00189
00190
00191
00192
00193 class TBButton
00194 {
00195
00196 var $name;
00197 var $image;
00198 var $link;
00199
00200 var $selected;
00201
00202 function TBButton($namep, $linkp, $imagep)
00203 {
00204 $this->name = $namep;
00205 $this->image = $imagep;
00206 $this->link = $linkp;
00207 $this->selected = false;
00208 }
00209
00210 function setSelected($sel)
00211 {
00212 $this->selected = $sel;
00213 }
00214
00215
00216
00217 function PrintAll($cssClass)
00218 {
00219
00220 if (func_num_args() == 2)
00221 $target = func_get_arg(1);
00222
00223
00224 if ($this->selected)
00225 $css = $cssClass."Selected";
00226 else
00227 $css = $cssClass;
00228
00229
00230 if ($this->image == "")
00231 $this->PrintOnlyText();
00232 else
00233 {
00234 echo "\t\t<div class='".$css."'>\n";
00235
00236 $aTag = "class='".$css."' href='".$this->link."' ";
00237 if ($target)
00238 $aTag .= "target='".$target."' ";
00239 echo "\t\t<a ".$aTag." >\n";
00240
00241 echo "\t\t<img src='".$this->image."' alt='".$this->name."' border=0>\n";
00242 echo "\t\t<br> ".$this->name." </a></div>\n";
00243 }
00244 }
00245
00246
00247
00248 function PrintOnlyText($cssClass)
00249 {
00250
00251 if (func_num_args() == 2)
00252 $target = func_get_arg(1);
00253
00254
00255 if ($this->selected)
00256 $css = $cssClass."Selected";
00257 else
00258 $css = $cssClass;
00259
00260 echo "\t\t<div class='".$css."'>\n";
00261
00262 $aTag = "class='".$css."' href='".$this->link."' ";
00263 if ($target)
00264 $aTag .= "target='".$target."' ";
00265 echo "\t\t<a ".$aTag." >\n";
00266
00267 echo "\t\t".$this->name."</a></div>\n";
00268 }
00269
00270 }