public static function onOutputPageBeforeHTML(OutputPage &$out, &$text)
 {
     if (WikiaPageType::isMainPage() && !F::app()->checkSkin('wikiamobile')) {
         $text = '';
         $out->clearHTML();
         $out->addHTML(F::app()->sendRequest('WikiaHomePageController', 'index')->toString());
     }
     return $out;
 }
 /**
  * Handles new pages to show error message and print message, that page does not exist.
  * @param OutputPage $out
  */
 protected function handleNewPages(OutputPage $out)
 {
     # Show error message
     $title = $this->getTitle();
     if (!$title->exists() && !$title->isSpecialPage() && $title->userCan('create', $this->getUser()) && $title->getNamespace() !== NS_FILE) {
         $out->clearHTML();
         $out->addHTML(Html::openElement('div', array('id' => 'mw-mf-newpage')) . wfMessage('mobile-frontend-editor-newpage-prompt')->parse() . Html::closeElement('div'));
     }
 }
Example #3
0
 /**
  * Function
  * 
  * onBeforePageDisplay
  *
  * @param OutputPage $out
  * @param Skin $skin
  * @return boolean
  */
 public static function onBeforePageDisplay(OutputPage &$out, Skin &$skin)
 {
     # Modify OutputPage HTML base on WebRequest's action
     switch ($GLOBALS['wgRequest']->getVal('action')) {
         # If purge page, do nothing
         case 'purge':
             break;
             # If OntoKiWi edit ontology with form, change displayed title and load form resources
         # If OntoKiWi edit ontology with form, change displayed title and load form resources
         case 'formedit':
             $title = $out->getPageTitle();
             $title = str_replace(' ', '_', $title);
             $out->mPagetitle = $title;
             $out->addModules(array('ext.okw.form.js', 'ext.okw.form.css'));
             break;
             # If delete page, check if page has ontology data, and:
             #     1) change displayed title
             #     2) add "Delete Ontology Data" checkbox
         # If delete page, check if page has ontology data, and:
         #     1) change displayed title
         #     2) add "Delete Ontology Data" checkbox
         case 'delete':
             global $wgRequest;
             if (OntologyValidator::isExistTitleText($wgRequest->getVal('title'))) {
                 $title = $out->getPageTitle();
                 $title = str_replace(' ', '_', $title);
                 $html = preg_replace('/(<input[^>]*name=[\'"]wpWatch[\'"].+?(?=<div>))/', '${1}&#160;<input name="okwDelete" type="checkbox" value="1" id="wpWatch" checked/>&#160;' . '<label for="okwDelete">Delete Ontology Data</label>', $out->getHTML());
                 $out->clearHTML();
                 $out->addHTML($html);
             }
             break;
             # Default display to check if page has ontology data, and:
             #     1) Change displayed title
             #     2) Call PageDisplayPrinter::display
             #     3) Load page resources
             #     4) Redirect if only ID is provided and is valid
         # Default display to check if page has ontology data, and:
         #     1) Change displayed title
         #     2) Call PageDisplayPrinter::display
         #     3) Load page resources
         #     4) Redirect if only ID is provided and is valid
         default:
             $title = $out->getPageTitle();
             $titleName = str_replace(' ', '_', $title);
             if (OntologyValidator::isExistOutputPage($out)) {
                 $out->mPagetitle = $titleName;
                 $html = $out->getHTML();
                 $out->clearHTML();
                 $html = PageDisplayPrinter::display($titleName) . $html;
                 $out->addHTML($html);
                 $out->addModules(array('ext.okw.page.js', 'ext.okw.page.css'));
             } else {
                 if (preg_match_all('/([a-zA-Z]+)[:_]([a-zA-Z]*)[:_]?(\\d+)/', $titleName, $matches, PREG_SET_ORDER)) {
                     if ($matches[0][2] == '') {
                         $title = Title::newFromText($matches[0][1] . ':' . $matches[0][1] . '_' . $matches[0][3]);
                         if (OntologyValidator::isExistTitle($title)) {
                             $out->redirect($title->getFullURL());
                             $out->output();
                         }
                     }
                 }
             }
             break;
     }
     return true;
 }