/** * Whether CategorySelect should be used for the current request. * @return Boolean */ public static function isEnabled() { wfProfileIn(__METHOD__); if (!isset(self::$isEnabled)) { $app = F::app(); $request = $app->wg->Request; $title = $app->wg->Title; $user = $app->wg->User; $action = $request->getVal('action', 'view'); $undo = $request->getVal('undo'); $undoafter = $request->getVal('undoafter'); $viewModeActions = array('view', 'purge'); $editModeActions = array('edit', 'submit'); $supportedActions = array_merge($viewModeActions, $editModeActions); $supportedSkins = array('SkinAnswers', 'SkinOasis', 'SkinVenus'); $isViewMode = in_array($action, $viewModeActions); $isEditMode = in_array($action, $editModeActions); $extraNamespacesOnView = array(NS_FILE, NS_CATEGORY); $extraNamespacesOnEdit = array(NS_FILE, NS_CATEGORY, NS_USER, NS_SPECIAL); $isEnabled = true; if ($request->getVal('usecatsel', '') == 'no' || $user->getGlobalPreference('disablecategoryselect') || !in_array(get_class(RequestContext::getMain()->getSkin()), $supportedSkins) || !in_array($action, $supportedActions) || $title->isCssJsSubpage() || $action == 'view' && !$title->exists() || $action == 'purge' && $user->isAnon() && !$request->wasPosted() || $undo > 0 && $undoafter > 0 || $title->mNamespace == NS_TEMPLATE || $isViewMode && !in_array($title->mNamespace, array_merge($app->wg->ContentNamespaces, $extraNamespacesOnView)) || $isEditMode && !in_array($title->mNamespace, array_merge($app->wg->ContentNamespaces, $extraNamespacesOnEdit))) { $isEnabled = false; } self::$isEnabled = $isEnabled; } wfProfileOut(__METHOD__); return self::$isEnabled; }
/** * Add hooks for view and edit pages */ public static function onMediaWikiPerformAction($output, $article, $title, $user, $request, $mediawiki, $force = false) { global $wgHooks; wfProfileIn(__METHOD__); if ($force || CategorySelectHelper::isEnabled()) { $app = F::app(); $action = $app->wg->Request->getVal('action', 'view'); JSMessages::enqueuePackage('CategorySelect', JSMessages::INLINE); $wgHooks['MakeGlobalVariablesScript'][] = 'CategorySelectHooksHelper::onMakeGlobalVariablesScript'; // Add hooks for edit pages if ($action == 'edit' || $action == 'submit' || $force) { $wgHooks['EditForm::MultiEdit:Form'][] = 'CategorySelectHooksHelper::onEditFormMultiEditForm'; $wgHooks['EditPage::CategoryBox'][] = 'CategorySelectHooksHelper::onEditPageCategoryBox'; $wgHooks['EditPage::getContent::end'][] = 'CategorySelectHooksHelper::onEditPageGetContentEnd'; $wgHooks['EditPage::importFormData'][] = 'CategorySelectHooksHelper::onEditPageImportFormData'; $wgHooks['EditPage::showEditForm:fields'][] = 'CategorySelectHooksHelper::onEditPageShowEditFormFields'; } } wfProfileOut(__METHOD__); return true; }
if ($wg->EnableInfoBoxTest) { echo $app->renderView('ArticleInfoBox', 'Index'); } ?> <?php echo $bodytext; ?> </div> <?php if (empty($wg->SuppressArticleCategories)) { ?> <?php if (!empty($wg->EnableCategorySelectExt) && CategorySelectHelper::isEnabled()) { ?> <?php echo $app->renderView('CategorySelect', 'articlePage'); ?> <?php } else { ?> <?php echo $app->renderView('ArticleCategories', 'Index'); ?> <?php } ?> <?php }