Código PHP:
/**
* Returns an HTML string containing an 'a' element for the given page if
* the page's href is not empty, and a 'span' element if it is empty
*
* Overrides {@link AbstractHelper::htmlify()}.
*
* @param AbstractPage $page page to generate HTML for
* @param bool $escapeLabel Whether or not to escape the label
* @return string HTML string for the given page
*/
public function htmlify(AbstractPage $page, $escapeLabel = true)
{
// 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,
'class' => $page->getClass()
);
// does page have a href?
$href = $page->getHref();
if( $href )
{
$element = 'a';
$attribs['href'] = $href;
$attribs['target'] = $page->getTarget();
}
else
{
$element = 'span';
}
// ***************** THESE ARE NEW LINES *************** //
if( $element === 'span' )
{
return $this->view->escapeHtml($label);
}
$customProperties = $page->getCustomProperties();
if( $page->getClass() == 'dropdown-toggle' )
{
//inserta un icono mediante el tag <iclass>icon-name</iclass>
if( isset($customProperties['iclass']) )
{
return '<' . $element . ' data-toggle="dropdown" ' . $this->htmlAttribs($attribs) . '>'
. '<i class="' . $customProperties['iclass'] . '"></i> '
. $this->view->escapeHtml($label)
. '<b class="caret"></b>'
. '</' . $element . '>';
}
return '<' . $element . ' data-toggle="dropdown" ' . $this->htmlAttribs($attribs) . '>'
. $this->view->escapeHtml($label)
. ' <b class="caret"></b>'
. '</' . $element . '>';
}
elseif( isset($customProperties['iclass']) )
{
return '<' . $element . $this->htmlAttribs($attribs) . '>'
. '<i class="' . $customProperties['iclass'] . '"></i> '
. $this->view->escapeHtml($label)
. '</' . $element . '>';
}
// ***************** END OF NEW STUFF *************** //
$html = '<' . $element . $this->htmlAttribs($attribs) . '>';
if( $escapeLabel === true )
{
$escaper = $this->view->plugin('escapeHtml');
$html .= $escaper($label);
}
else
{
$html .= $label;
}
$html .= '</' . $element . '>';
return $html;
}