コード例 #1
0
 /**
  * The template used for article pages and edit previews.
  */
 public function articlePage()
 {
     wfProfileIn(__METHOD__);
     // Template rendering cancelled by hook
     if (!wfRunHooks('CategorySelectArticlePage')) {
         wfProfileOut(__METHOD__);
         return false;
     }
     $categories = $this->wg->out->getCategories();
     $showHidden = (bool) $this->wg->User->getGlobalPreference('showhiddencats');
     $userCanEdit = $this->request->getVal('userCanEdit', CategorySelectHelper::isEditable());
     // There are no categories present and user can't edit, skip rendering
     if (!$userCanEdit && !count($categories)) {
         wfProfileOut(__METHOD__);
         return false;
     }
     // Categories link
     $categoriesLinkAttributes = array('class' => 'categoriesLink');
     $categoriesLinkPage = wfMessage('pagecategorieslink')->inContentLanguage()->text();
     $categoriesLinkText = wfMessage('pagecategories')->escaped();
     if (!empty($this->wg->WikiaUseNoFollow)) {
         $categoriesLinkAttributes['rel'] = 'nofollow';
     }
     $categoriesLink = Linker::link(Title::newFromText($categoriesLinkPage), $categoriesLinkText, $categoriesLinkAttributes);
     Wikia::addAssetsToOutput('category_select_css');
     Wikia::addAssetsToOutput('category_select_js');
     $this->response->setVal('categories', $categories);
     $this->response->setVal('categoriesLink', $categoriesLink);
     $this->response->setVal('showHidden', $showHidden);
     $this->response->setVal('userCanEdit', $userCanEdit);
     if ($this->app->checkSkin('venus')) {
         $this->overrideTemplate('articlePageVenus');
     }
     wfProfileOut(__METHOD__);
 }
コード例 #2
0
 /**
  * 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;
 }
コード例 #3
0
 /**
  * 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;
 }
コード例 #4
0
ファイル: Body_Index.php プロジェクト: Tjorriemorrie/app
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 
}