. * * @file * @ingroup Skins */ use Skins\Chameleon\ComponentFactory; /** * SkinTemplate class for the Chameleon skin * * @author Stephan Gambke * @since 1.0 * @ingroup Skins */ class SkinChameleon extends SkinTemplate { public $skinname = 'chameleon'; public $stylename = 'chameleon'; public $template = '\Skins\Chameleon\ChameleonTemplate'; public $useHeadElement = true; private $componentFactory; /** * @param $out OutputPage object */ public function setupSkinUserCss( OutputPage $out ) { // load Bootstrap styles $out->addModuleStyles( array( 'ext.bootstrap.styles' ) ); } /** * @param \OutputPage $out */ public function initPage( OutputPage $out ) { parent::initPage( $out ); // Enable responsive behaviour on mobile browsers $out->addMeta( 'viewport', 'width=device-width, initial-scale=1.0' ); } /** * @return QuickTemplate */ protected function setupTemplateForOutput() { $tpl = parent::setupTemplateForOutput(); $this->getComponentFactory()->setSkinTemplate( $tpl ); $tpl->set( 'skin', $this ); $this->addSkinModulesToOutput(); return $tpl; } /** * @return ComponentFactory */ public function getComponentFactory() { if ( ! isset( $this->componentFactory ) ) { $this->componentFactory = new \Skins\Chameleon\ComponentFactory( $this->getLayoutFilePath() ); } return $this->componentFactory; } public function addSkinModulesToOutput() { // load Bootstrap scripts $out = $this->getOutput(); $out->addModules( array( 'ext.bootstrap.scripts' ) ); $out->addModules( $this->getComponentFactory()->getRootComponent()->getResourceLoaderModules() ); } /** * @param Title $title * @return string */ public function getPageClasses( $title ) { $layoutFilePath = $this->getLayoutFilePath(); $layoutName = Sanitizer::escapeClass( 'layout-' . basename( $layoutFilePath, '.xml' ) ); return implode( ' ', array( parent::getPageClasses( $title ), $layoutName ) ); } /** * Template method that can be overridden by subclasses * @return string Path to layout file */ protected function getLayoutFilePath() { return $GLOBALS['egChameleonLayoutFile']; } }