public static function onBeforePageDisplay(OutputPage &$output, Skin &$skin) { $title = $output->getTitle(); // Disallow commenting on pages without article id if ($title->getArticleID() == 0) { return true; } if ($title->isSpecialPage()) { return true; } // These could be explicitly allowed in later version if (!$title->canTalk()) { return true; } if ($title->isTalkPage()) { return true; } // No commenting on main page if ($title->isMainPage()) { return true; } // Do not display when printing if ($output->isPrintable()) { return true; } // Disable if not viewing if ($skin->getRequest()->getVal('action', 'view') != 'view') { return true; } // Blacklist several namespace if (in_array($title->getNamespace(), self::getFilteredNamespace())) { return true; } if ($output->getUser()->isAllowed('commentadmin-restricted')) { $output->addJsConfigVars(array('commentadmin' => '')); } global $wgFlowThreadConfig; $config = array('Avatar' => $wgFlowThreadConfig['Avatar'], 'AnonymousAvatar' => $wgFlowThreadConfig['AnonymousAvatar']); if (\FlowThread\Post::canPost($output->getUser())) { $output->addJsConfigVars(array('canpost' => '')); } else { $config['CantPostNotice'] = wfMessage('flowthread-ui-cantpost')->toString(); } global $wgFlowThreadConfig; $output->addJsConfigVars(array('wgFlowThreadConfig' => $config)); $output->addModules('ext.flowthread'); return true; }
/** * * @param OutputPage $oOutputPage * @param Skin $oSkin * @return boolean - always true */ public function onBeforePageDisplay(&$oOutputPage, &$oSkin) { if (!in_array($oOutputPage->getRequest()->getVal('action', 'view'), array('edit', 'submit'))) { return true; } $oOutputPage->addModules('bluespice.insertLink.interWikiLinks'); //TODO implement ow $oOutputPage->addJsConfigVars('BSInterWikiPrefixes', $this->getInterWikiLinkPrefixes()); return true; }
/** * Adds resources to ResourceLoader * @param OutputPage $out * @param Skin $skin * @return boolean Always true to keep hook running */ public function onBeforePageDisplay(&$out, &$skin) { $out->addModules('ext.bluespice.contextmenu'); //We check if the current user can send Mails trough the wiki //TODO: Maybe move to BSF? $mEMailPermissioErrors = SpecialEmailUser::getPermissionsError($this->getUser(), $this->getUser()->getEditToken()); $bUserCanSendMail = false; if ($mEMailPermissioErrors === null) { $bUserCanSendMail = true; } $out->addJsConfigVars('bsUserCanSendMail', $bUserCanSendMail); return true; }
/** * Adds VisualEditor JS to the output. * * This is attached to the MediaWiki 'BeforePageDisplay' hook. * * @param OutputPage $output * @param Skin $skin * @return boolean */ public static function onBeforePageDisplay(OutputPage &$output, Skin &$skin) { $output->addModules(array('ext.visualEditor.desktopArticleTarget.init', 'ext.visualEditor.targetLoader')); $output->addModuleStyles(array('ext.visualEditor.desktopArticleTarget.noscript')); // add scroll offset js variable to output $veConfig = ConfigFactory::getDefaultInstance()->makeConfig('visualeditor'); $skinsToolbarScrollOffset = $veConfig->get('VisualEditorSkinToolbarScrollOffset'); $toolbarScrollOffset = 0; $skinName = $skin->getSkinName(); if (isset($skinsToolbarScrollOffset[$skinName])) { $toolbarScrollOffset = $skinsToolbarScrollOffset[$skinName]; } $output->addJsConfigVars('wgVisualEditorToolbarScrollOffset', $toolbarScrollOffset); return true; }
public static function injectCss(OutputPage $out, $text) { global $wgTranslatePageTranslationULS; $title = $out->getTitle(); $isSource = TranslatablePage::isSourcePage($title); $isTranslation = TranslatablePage::isTranslationPage($title); if ($isSource || $isTranslation) { $out->addModuleStyles('ext.translate'); if ($wgTranslatePageTranslationULS) { $out->addModules('ext.translate.pagetranslation.uls'); } // Per bug T63331 $type = $isSource ? 'source' : 'translation'; $out->addJsConfigVars('wgTranslatePageTranslation', $type); } return true; }
/** * Adds resources to ResourceLoader * @param OutputPage $out * @param Skin $skin * @return boolean Always true to keep hook running */ public function onBeforePageDisplay(&$out, &$skin) { //Having a dedicated module for styles and loading it through //'addModuleStyles' prevents CSS flickering. It shoult obly be done //when styling elements that are available in the source HTML. If you //want to style markup that gets generated by JavaScript embed your //styling in the same module and use 'addModules'. $out->addModuleStyles('ext.bluespice.boilerPlate.styles'); //Adding JavaScript and clientside I18N $out->addModules('ext.bluespice.boilerPlate.scripts'); //Additional context sensitive data for the clientside $bVar = date('w') == 3; //Is it Wednesday? $out->addJsConfigVars('bsBoilerPlateSomeCalculatedVar', $bVar); return true; }
/** * Adds the 'ext.bluespice.responsibleeditors' module to the OutputPage * @param OutputPage $out * @param Skin $skin * @return boolean */ public function onBeforePageDisplay($out, $skin) { if ($out->getRequest()->getVal('action', 'view') == 'view' && !$out->getTitle()->isSpecialPage()) { $out->addModules('ext.bluespice.responsibleEditors'); $out->addModuleStyles('ext.bluespice.responsibleEditors.styles'); //Make information about current pages RespEds available on client side $iArticleId = $out->getTitle()->getArticleID(); $aResponsibleEditorIds = $this->getResponsibleEditorIdsByArticleId($iArticleId); $oData = new stdClass(); $oData->articleId = $iArticleId; $oData->editorIds = $aResponsibleEditorIds; $out->addJsConfigVars('bsResponsibleEditors', $oData); } if (BsExtensionManager::getExtension('Bookshelf') !== null) { //Attach Bookshelfs plugin if in context if (SpecialPage::getTitleFor('BookshelfBookManager')->equals($out->getTitle())) { $out->addModules('ext.bluespice.responsibleEditors.bookshelfPlugin'); } } if (BsExtensionManager::getExtension('SuperList') !== null) { //Attach SuperList plugin if in context if (SpecialPage::getTitleFor('SuperList')->equals($out->getTitle())) { $out->addModules('ext.bluespice.responsibleEditors.superList'); } } return true; }
/** * Adds CSS to Page * @param OutputPage $out * @param Skin $skin * @return boolean */ public function onBeforePageDisplay(&$out, &$skin) { $out->addModuleStyles('ext.bluespice.review.styles'); if ($out->getTitle()->isContentPage() == false) { return true; } if ($out->getTitle()->exists() == false) { return true; } //if( $out->getTitle()->userCan('workflowread') == false ) return true; $out->addModules('ext.bluespice.review'); //PW TODO: find better way //this always was loaded too late, no matter what dependency or position $out->addScript('<script>' . "\$(document).on( 'BsStateBarRegisterToggleClickElements', function(event, aRegisteredToggleClickElements) {" . "aRegisteredToggleClickElements.push(\$('#sb-Review'));" . "});" . '</script>'); $bUserCanEdit = $out->getTitle()->userCan('workflowedit'); $out->addJsConfigVars('bsReviewUserCanEdit', $bUserCanEdit); $oRev = BsReviewProcess::newFromPid($out->getTitle()->getArticleID()); $out->addJsConfigVars('bsReview', $this->makeJSDataObject($oRev)); return true; }
/** * * @param OutputPage $out * @param Skin $skin * @return boolean */ public static function onBeforePageDisplay(&$out, &$skin) { $out->addModuleStyles('ext.bluespice.insertcategory.styles'); $out->addModules('ext.bluespice.insertcategory'); $out->addJsConfigVars('BSInsertCategoryWithParents', BsConfig::get('MW::InsertCategory::WithParents')); return true; }