Ejemplo n.º 1
0
 /**
  * This is called by MediaWiki to render the skin.
  */
 final function execute()
 {
     //parse content first, to allow for any ADDTEMPLATE items
     $content = $this->parseContent($this->data['bodycontent']);
     if (!$this->getLayoutClass()) {
         throw new \Exception('No layout class defined.');
     }
     $layoutClass = $this->getLayoutClass();
     $layout = new $layoutClass($this->getSkin(), $this);
     //set up standard content zones
     //head element (including opening body tag)
     $layout->addHTMLTo('head', $this->html('headelement'));
     //the logo image defined in LocalSettings
     $layout->addHTMLTo('logo', $this->data['logopath']);
     $layout->addHTMLTo('prepend:body', $this->html('prebodyhtml'));
     //the article title
     if ($this->showTitle) {
         $layout->addHTMLTo('content-container.class', 'has-title');
         $layout->addHTMLTo('title-html', $this->data['title']);
     }
     //article content
     $layout->addHTMLTo('content-html', $content);
     //the site notice
     if (!empty($this->data['sitenotice'])) {
         $layout->addHTMLTo('site-notice', $this->data['sitenotice']);
     }
     //the site tagline, if there is one
     if ($this->showTagline) {
         $layout->addHTMLTo('content-container.class', 'has-tagline');
         $layout->addHTMLTo('tagline', $this->getMsg('tagline'));
     }
     $breadcrumbTrees = $this->breadcrumbs();
     $layout->addTemplateTo('breadcrumbs', 'breadcrumbs', array('trees' => $breadcrumbTrees));
     if (\Skinny::hasContent('toc')) {
         // $layout->addHTMLTo('toc', \Skinny::getContent('toc')[0]['html']);
     }
     // if ( $this->data['dataAfterContent'] ) {
     // 	$layout->addHTMLTo('append:content', $this->data['dataAfterContent']);
     // }
     //the contents of Mediawiki:Sidebar
     // $layout->addTemplate('classic-sidebar', 'classic-sidebar', array(
     // 	'sections'=>$this->data['sidebar']
     // ));
     // //list of language variants
     // $layout->addTemplate('language-variants', 'language-variants', array(
     // 	'variants'=>$this->data['language_urls']
     // ));
     //page footer
     $layout->addHookTo('footer-links', array($this, 'getFooterLinks'));
     $layout->addHookTo('footer-icons', array($this, 'getFooterIcons'));
     //mediawiki needs this to inject script tags after the footer
     $layout->addHookTo('append:body', array($this, 'afterFooter'));
     $this->data['pageLanguage'] = $this->getSkin()->getTitle()->getPageViewLanguage()->getCode();
     //allow skins to set up before render
     $this->initialize();
     echo $layout->render();
     // $this->printTrail();
 }
Ejemplo n.º 2
0
 protected function superhero()
 {
     $content = '';
     //Skinny can be used to content from the article into the
     if (class_exists('Skinny') && Skinny::hasContent('superhero')) {
         $content = Skinny::getContent('superhero');
         return $this->renderTemplate('superhero', array('content' => $content));
     }
 }
Ejemplo n.º 3
0
 /**
  * Render zone content, optionally passing arguments to provide to
  * object methods
  */
 protected function renderZone($zone, $args = array())
 {
     $sep = isset($args['seperator']) ? $args['seperator'] : ' ';
     if ($this->debug === true) {
         echo "\n\n" . '<!-- Template Zone: ' . $zone . ' -->';
     }
     $content = '';
     if (isset($this->content[$zone])) {
         foreach ($this->content[$zone] as $item) {
             switch ($item['type']) {
                 case 'hook':
                     //method will be called with two arrays as arguments
                     //the first is the args passed to this method (ie. in a template call to $this->insert() )
                     //the second are the args passed when the hook was bound
                     $content .= call_user_func_array($item['hook'], array($args, $item['arguments']));
                     break;
                 case 'html':
                     $content .= $sep . (string) $item['html'];
                     break;
                 case 'template':
                     $content .= $this->renderTemplate($item['template'], $item['params']);
                     break;
                 case 'zone':
                     $content .= $this->renderZone($item['zone'], $item['params']);
                     break;
             }
         }
     }
     //content from #movetoskin and #skintemplate
     if (\Skinny::hasContent($zone)) {
         foreach (\Skinny::getContent($zone) as $item) {
             //pre-rendered html from #movetoskin
             if (isset($item['html'])) {
                 if ($this->debug === true) {
                     $content .= '<!--Skinny:MoveToSkin: ' . $template . '-->';
                 }
                 $content .= $sep . $item['html'];
             } else {
                 //a template name to render
                 if (isset($item['template'])) {
                     if ($this->debug === true) {
                         $content .= '<!--Skinny:Template (via #skintemplate): ' . $item['template'] . '-->';
                     }
                     $content .= $this->renderTemplate($item['template'], $item['params']);
                 }
             }
         }
     }
     return $content;
 }