当前位置: 首页>>代码示例>>PHP>>正文


PHP IContextSource::canUseWikiPage方法代码示例

本文整理汇总了PHP中IContextSource::canUseWikiPage方法的典型用法代码示例。如果您正苦于以下问题:PHP IContextSource::canUseWikiPage方法的具体用法?PHP IContextSource::canUseWikiPage怎么用?PHP IContextSource::canUseWikiPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IContextSource的用法示例。


在下文中一共展示了IContextSource::canUseWikiPage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: initializeArticle

 /**
  * Initialize the main Article object for "standard" actions (view, etc)
  * Create an Article object for the page, following redirects if needed.
  *
  * @return mixed An Article, or a string to redirect to another URL
  */
 private function initializeArticle()
 {
     $title = $this->context->getTitle();
     if ($this->context->canUseWikiPage()) {
         // Try to use request context wiki page, as there
         // is already data from db saved in per process
         // cache there from this->getAction() call.
         $page = $this->context->getWikiPage();
         $article = Article::newFromWikiPage($page, $this->context);
     } else {
         // This case should not happen, but just in case.
         $article = Article::newFromTitle($title, $this->context);
         $this->context->setWikiPage($article->getPage());
     }
     // NS_MEDIAWIKI has no redirects.
     // It is also used for CSS/JS, so performance matters here...
     if ($title->getNamespace() == NS_MEDIAWIKI) {
         return $article;
     }
     $request = $this->context->getRequest();
     // Namespace might change when using redirects
     // Check for redirects ...
     $action = $request->getVal('action', 'view');
     $file = $title->getNamespace() == NS_FILE ? $article->getFile() : null;
     if (($action == 'view' || $action == 'render') && !$request->getVal('oldid') && !$request->getVal('diff') && $request->getVal('redirect') != 'no' && !(is_object($file) && $file->exists() && !$file->getRedirected())) {
         // Give extensions a change to ignore/handle redirects as needed
         $ignoreRedirect = $target = false;
         Hooks::run('InitializeArticleMaybeRedirect', array(&$title, &$request, &$ignoreRedirect, &$target, &$article));
         // Follow redirects only for... redirects.
         // If $target is set, then a hook wanted to redirect.
         if (!$ignoreRedirect && ($target || $article->isRedirect())) {
             // Is the target already set by an extension?
             $target = $target ? $target : $article->followRedirect();
             if (is_string($target)) {
                 if (!$this->config->get('DisableHardRedirects')) {
                     // we'll need to redirect
                     return $target;
                 }
             }
             if (is_object($target)) {
                 // Rewrite environment to redirected article
                 $rarticle = Article::newFromTitle($target, $this->context);
                 $rarticle->loadPageData();
                 if ($rarticle->exists() || is_object($file) && !$file->isLocal()) {
                     $rarticle->setRedirectedFrom($title);
                     $article = $rarticle;
                     $this->context->setTitle($target);
                     $this->context->setWikiPage($article->getPage());
                 }
             }
         } else {
             $this->context->setTitle($article->getTitle());
             $this->context->setWikiPage($article->getPage());
         }
     }
     return $article;
 }
开发者ID:GoProjectOwner,项目名称:mediawiki,代码行数:63,代码来源:MediaWiki.php

示例2: getActionName

	/**
	 * Get the action that will be executed, not necessarily the one passed
	 * passed through the "action" request parameter. Actions disabled in
	 * $wgActions will be replaced by "nosuchaction".
	 *
	 * @since 1.19
	 * @param $context IContextSource
	 * @return string: action name
	 */
	final public static function getActionName( IContextSource $context ) {
		global $wgActions;

		$request = $context->getRequest();
		$actionName = $request->getVal( 'action', 'view' );

		// Check for disabled actions
		if ( isset( $wgActions[$actionName] ) && $wgActions[$actionName] === false ) {
			$actionName = 'nosuchaction';
		}

		// Workaround for bug #20966: inability of IE to provide an action dependent
		// on which submit button is clicked.
		if ( $actionName === 'historysubmit' ) {
			if ( $request->getBool( 'revisiondelete' ) ) {
				$actionName = 'revisiondelete';
			} else {
				$actionName = 'view';
			}
		} elseif ( $actionName == 'editredlink' ) {
			$actionName = 'edit';
		}

		// Trying to get a WikiPage for NS_SPECIAL etc. will result
		// in WikiPage::factory throwing "Invalid or virtual namespace -1 given."
		// For SpecialPages et al, default to action=view.
		if ( !$context->canUseWikiPage() ) {
			return 'view';
		}

		$action = Action::factory( $actionName, $context->getWikiPage(), $context );
		if ( $action instanceof Action ) {
			return $action->getName();
		}

		return 'nosuchaction';
	}
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:46,代码来源:Action.php

示例3: initializeArticle

 /**
  * Initialize the main Article object for "standard" actions (view, etc)
  * Create an Article object for the page, following redirects if needed.
  *
  * @return Article|string An Article, or a string to redirect to another URL
  */
 private function initializeArticle()
 {
     $title = $this->context->getTitle();
     if ($this->context->canUseWikiPage()) {
         // Try to use request context wiki page, as there
         // is already data from db saved in per process
         // cache there from this->getAction() call.
         $page = $this->context->getWikiPage();
     } else {
         // This case should not happen, but just in case.
         // @TODO: remove this or use an exception
         $page = WikiPage::factory($title);
         $this->context->setWikiPage($page);
         wfWarn("RequestContext::canUseWikiPage() returned false");
     }
     // Make GUI wrapper for the WikiPage
     $article = Article::newFromWikiPage($page, $this->context);
     // Skip some unnecessary code if the content model doesn't support redirects
     if (!ContentHandler::getForTitle($title)->supportsRedirects()) {
         return $article;
     }
     $request = $this->context->getRequest();
     // Namespace might change when using redirects
     // Check for redirects ...
     $action = $request->getVal('action', 'view');
     $file = $page instanceof WikiFilePage ? $page->getFile() : null;
     if (($action == 'view' || $action == 'render') && !$request->getVal('oldid') && !$request->getVal('diff') && $request->getVal('redirect') != 'no' && !(is_object($file) && $file->exists() && !$file->getRedirected())) {
         // Give extensions a change to ignore/handle redirects as needed
         $ignoreRedirect = $target = false;
         Hooks::run('InitializeArticleMaybeRedirect', [&$title, &$request, &$ignoreRedirect, &$target, &$article]);
         $page = $article->getPage();
         // reflect any hook changes
         // Follow redirects only for... redirects.
         // If $target is set, then a hook wanted to redirect.
         if (!$ignoreRedirect && ($target || $page->isRedirect())) {
             // Is the target already set by an extension?
             $target = $target ? $target : $page->followRedirect();
             if (is_string($target)) {
                 if (!$this->config->get('DisableHardRedirects')) {
                     // we'll need to redirect
                     return $target;
                 }
             }
             if (is_object($target)) {
                 // Rewrite environment to redirected article
                 $rpage = WikiPage::factory($target);
                 $rpage->loadPageData();
                 if ($rpage->exists() || is_object($file) && !$file->isLocal()) {
                     $rarticle = Article::newFromWikiPage($rpage, $this->context);
                     $rarticle->setRedirectedFrom($title);
                     $article = $rarticle;
                     $this->context->setTitle($target);
                     $this->context->setWikiPage($article->getPage());
                 }
             }
         } else {
             // Article may have been changed by hook
             $this->context->setTitle($article->getTitle());
             $this->context->setWikiPage($article->getPage());
         }
     }
     return $article;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:69,代码来源:MediaWiki.php


注:本文中的IContextSource::canUseWikiPage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。