这么写的人是个什么心态。。。 !$this->IsURLCurrentPage($url)和active=true,看得好纠结。。。
public function DisplayMenu($buttons)
{
echo "<table width=\"100%\" bgcolor=\"white\"
cellpadding=\"4\" cellspacing=\"4\">\n";
echo "<tr>\n";
//calculate button size
$width = 100/count($buttons);
while (list($name, $url) = each($buttons)) {
$this -> DisplayButton($width, $name, $url,
!$this->IsURLCurrentPage($url));
}
echo "</tr>\n";
echo "</table>\n";
}
public function IsURLCurrentPage($url)
{
if(strpos($_SERVER['PHP_SELF'], $url )==false)
{
return false;
}
else
{
return true;
}
}
public function
DisplayButton($width,$name,$url,$active = true)
{
if ($active) {
echo "<td width = \"".$width."%\">
<a href=\"".$url."\">
<img src=\"s-logo.gif\" alt=\"".$name."\" border=\"0\" /></a>
<a href=\"".$url."\"><span class=\"menu\">".$name."</span></a>
</td>";
} else {
echo "<td width=\"".$width."%\">
<img src=\"side-logo.gif\">
<span class=\"menu\">".$name."</span>
</td>";
}
}
public function DisplayMenu($buttons)
{
echo "<table width=\"100%\" bgcolor=\"white\"
cellpadding=\"4\" cellspacing=\"4\">\n";
echo "<tr>\n";
//calculate button size
$width = 100/count($buttons);
while (list($name, $url) = each($buttons)) {
$this -> DisplayButton($width, $name, $url,
!$this->IsURLCurrentPage($url));
}
echo "</tr>\n";
echo "</table>\n";
}
public function IsURLCurrentPage($url)
{
if(strpos($_SERVER['PHP_SELF'], $url )==false)
{
return false;
}
else
{
return true;
}
}
public function
DisplayButton($width,$name,$url,$active = true)
{
if ($active) {
echo "<td width = \"".$width."%\">
<a href=\"".$url."\">
<img src=\"s-logo.gif\" alt=\"".$name."\" border=\"0\" /></a>
<a href=\"".$url."\"><span class=\"menu\">".$name."</span></a>
</td>";
} else {
echo "<td width=\"".$width."%\">
<img src=\"side-logo.gif\">
<span class=\"menu\">".$name."</span>
</td>";
}
}