.
*
* @file
* @ingroup Skins
*/
namespace Skins\Chameleon\Components;
use Linker;
use Skins\Chameleon\IdRegistry;
/**
* The Logo class.
*
* The logo image as a link to the wiki main page wrapped in a div:
*
* @author Stephan Gambke
* @since 1.0
* @ingroup Skins
*/
class Logo extends Component {
/**
* Builds the HTML code for this component
*
* @return String the HTML code
*/
public function getHtml() {
$attribs = NULL;
if ( $this->addLink() ) {
$attribs = array_merge(
array( 'href' => $this->getSkinTemplate()->data[ 'nav_urls' ][ 'mainpage' ][ 'href' ] ),
Linker::tooltipAndAccesskeyAttribs( 'p-logo' )
);
}
$contents = \Html::element( 'img',
array(
'src' => $this->getSkinTemplate()->data[ 'logopath' ],
'alt' => $this->getSkinTemplate()->data[ 'sitename' ],
)
);
return
$this->indent() . '' .
$this->indent() . \Html::openElement( 'div',
array(
'id' => IdRegistry::getRegistry()->getId( 'p-logo' ),
'class' => 'p-logo ' . $this->getClassString(),
'role' => 'banner'
)
) .
$this->indent( 1 ) . \Html::rawElement( 'a', $attribs, $contents ) .
$this->indent( -1 ) . '
' . "\n";
}
/**
* Return true if addLink attribute is unset or set to 'yes' in the Logo
* component description. Clicking on the logo should redirect to Main Page
* in that case. Else the logo should just display an inactive image.
*
* @return bool
*/
private function addLink() {
if ( $this->getDomElement() === null ) {
return true;
}
$addLink = $this->getDomElement()->getAttribute( 'addLink' );
if ( $addLink === '' ) {
return true;
}
return filter_var( $addLink, FILTER_VALIDATE_BOOLEAN );
}
}