", "/about/fine_art.php", array ( new MenuItem("Reviews", "/about/reviews.php", null, ""), new MenuItem("Film", "/about/film.php", null, ""), new MenuItem("CV", "/about/cv.php", null, ""), new MenuItem("Shop", "/about/shop.php", null, "") ), ""), new MenuItem("Commercial", "/about/commercial.php", null, ""), new MenuItem("News", "/about/news.php", null, "") ), "about"), new MenuItem("Fine Art//", "/fine_art/", array ( new MenuItem("58 North", "/fine_art/58north.php", null, ""), new MenuItem("Darkeden", "/fine_art/darkeden.php", null, ""), new MenuItem("Land/Sea/Sky >", "/fine_art/land.php", array ( new MenuItem("Land", "/fine_art/land.php", null, ""), new MenuItem("Sea", "/fine_art/sea.php", null, ""), new MenuItem("Sky", "/fine_art/sky.php", null, "") ), "lss"), new MenuItem("Land's End/Cape Wrath >", "/fine_art/lands_end.php", array ( new MenuItem("Land's End", "/fine_art/lands_end.php", null, ""), new MenuItem("Cape Wrath", "/fine_art/cape_wrath.php", null, "") ), "le"), new MenuItem("Lost Souls", "/fine_art/lost_souls.php", null, ""), new MenuItem("Portraits", "/fine_art/portraits.php", null, ""), new MenuItem("Self Portraits", "/fine_art/self_portraits.php", null, ""), new MenuItem("Stones", "/fine_art/stones.php", null, ""), new MenuItem("Tender", "/fine_art/tender.php", null, ""), new MenuItem("Within", "/fine_art/within.php", null, ""), new MenuItem("archive", "/fine_art/archive.php", null, "") ), "art"), new MenuItem("Commercial//", "/commercial/", array ( new MenuItem("Location", "/commercial/location_gallery.php", null, ""), new MenuItem("People", "/commercial/people_gallery.php", null, ""), new MenuItem("Studio", "/commercial/studio_gallery.php", null, "") ), "commercial"), new MenuItem("Contact//", "/contact/", null, "contact") ); class MenuItem { var $label; var $href; var $childMenu; var $style; function MenuItem($label, $href, $childMenu = null, $style = "") { $this->label = $label; $this->href = $href; $this->childMenu = $childMenu; $this->style = $style; } function getLabel() { return $this->label; } function getHref() { return $this->href; } function getChildMenu() { return $this->childMenu; } function getStyle() { return $this->style; } } function treeMenu($array) { $menuItemFormat = '
  • %s%s
  • '; $menuItemSelFormat = '
  • %s%s
  • '; return treeMenuMaker($array, $menuItemFormat, $menuItemSelFormat); } function treeMenuMaker($array, $menuItemFormat, $menuItemSelFormat) { $treeMenu = ""; $uri = $_SERVER['REQUEST_URI']; foreach ($array as $index => $menuItem) { $label = $menuItem->getLabel(); $href = $menuItem->getHref(); $style = $menuItem->getStyle(); $hasChildren = (is_array($menuItem->getChildMenu())); $index == 0; //is a check for homepage (assumes that is first) - this is a special case that we must always do a full compare $isDirectoryHref = (strrpos($href, "/") === (strlen($href) - 1)); $fullCompare = (!$isDirectoryHref); if ($fullCompare) $comp = $index."full"; else $comp = $index."part"; $selected = ($fullCompare ? $uri == $href : strpos($uri, $href) === 0); if ($selected) { $menuTpl = $menuItemSelFormat; } else { $menuTpl = $menuItemFormat; } $childMenu = ""; if ($hasChildren) { $childMenu = sprintf ("\n", treeMenuMaker($menuItem->getChildMenu(), $menuItemFormat, $menuItemSelFormat)); } $treeMenu .= sprintf($menuTpl, $style, $href, $label, $childMenu)."\n"; } return $treeMenu; } ?>