Esempio n. 1
0
 /**
  * @override htmlify from the parent/base/super class
  */
 public function htmlify(AbstractPage $page, $escapeLabel = true, $addClassToListItem = false)
 {
     // !!! This method will be executed in the namespace of the class
     // !!! But the methods of the super/base class will be executed in its own namespace
     // get label and title for translating
     $label = $page->getLabel();
     $title = $page->getTitle();
     // translate label and title?
     if (null !== ($translator = $this->getTranslator())) {
         $textDomain = $this->getTranslatorTextDomain();
         if (is_string($label) && !empty($label)) {
             $label = $translator->translate($label, $textDomain);
         }
         if (is_string($title) && !empty($title)) {
             $title = $translator->translate($title, $textDomain);
         }
     }
     // get attribs for element
     $attribs = array('id' => $page->getId(), 'title' => $title);
     $attribs['class'] = '';
     if ($addClassToListItem === false) {
         $attribs['class'] = $page->getClass();
     }
     // Stoyan
     $attribs['class'] .= $attribs['class'] ? ' ' : '';
     $attribs['class'] .= $page->getAnchorClass();
     //		echo 'Menu<pre>';
     //		echo 'Class: ' . $page->getClass();
     //		echo 'Anchor Class: ' . $page->getAnchorClass();
     //		print_r($attribs);
     //		echo '</pre>';
     // does page have a href?
     $href = $page->getHref();
     if ($href) {
         $element = 'a';
         $attribs['href'] = $href;
         $attribs['target'] = $page->getTarget();
     } else {
         $element = 'span';
     }
     $html = '<' . $element . $this->htmlAttribs($attribs) . '>';
     if ($escapeLabel === true) {
         $escaper = $this->view->plugin('escapeHtml');
         $html .= $escaper($label);
     } else {
         $html .= $label;
     }
     $html .= '</' . $element . '>';
     return $html;
 }