* */ class ems_displayer_menu_single extends ems_displayer_base { /** * Constructor object for the class and it also sets the default customizations for the displayer * * @param ems_framework_registry $param, boolean $displayText = true * @access public * @return void */ public function __construct(ems_framework_registry $param,$displayText = true) { parent::__construct($param,$displayText); $this->customize("block_header",""); $this->customize("block_footer",""); $this->customize("item_header",""); $this->customize("item_footer",""); $this->customize("item_seperator",""); $this->customize("text_header",""); $this->customize("text_footer",""); $this->customize("apply_text",true); $this->customize("link_class",""); $this->customize("first_item_header",""); $this->customize("last_item_header",""); $this->customize("prefix",""); } /** * Actually performs the generation work by the displayer * * @param ems_framework_registry $param * @access public * @return string or writes the text to the buffer directly */ public function display(ems_framework_registry $param) { $menu = $this->do; $it = $menu->createIterator(); $firstItem = true; while ($it->hasNext()) { $link = $it->next(); if ($this->custom['link_class']) { $classText = "class = '{$this->custom['link_class']}'"; } else { $classText = ""; } // set the link text header and footer if ($this->custom['apply_text'] === true) { if ($this->custom['text_header'] && $this->custom['text_footer']) { $textHeader = $this->custom['text_header']; $textFooter = $this->custom['text_footer']; } else { $textHeader = ""; $textFooter = ""; } } else { $textHeader = ""; $textFooter = ""; } // if an item is first or last, it could have a different header tag than the rest. // this checks that and assigns the appropriate value to itemHeader if ($firstItem === true && $this->custom['first_item_header']) { $itemHeader = $this->custom['first_item_header']; } else if (!$it->hasNext() && $this->custom['last_item_header']) { $itemHeader = $this->custom['last_item_header']; } else { $itemHeader = $this->custom['item_header']; } if ($link->getTarget()) { $targetText = "target='{$link->getTarget()}'"; } else { $targetText = ""; } // put the menu string togeter $linkText = "{$itemHeader}getURL()}' {$classText} {$targetText}>{$textHeader}{$link->getName()}{$textFooter}{$this->custom['item_footer']}"; $list[] = $linkText; $firstItem = false; } if (is_array($list)) { $text = implode($this->custom['item_seperator'],$list); } else { $text = ""; } $text = "{$this->custom['block_header']}{$text}{$this->custom['block_footer']}"; return $this->returnType($text); } } ?>