本文整理汇总了PHP中IContextSource::setWikiPage方法的典型用法代码示例。如果您正苦于以下问题:PHP IContextSource::setWikiPage方法的具体用法?PHP IContextSource::setWikiPage怎么用?PHP IContextSource::setWikiPage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IContextSource
的用法示例。
在下文中一共展示了IContextSource::setWikiPage方法的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;
}
示例2: 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()
{
global $wgDisableHardRedirects, $wgTitle;
wfProfileIn(__METHOD__);
$title = $this->context->getTitle();
$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) {
wfProfileOut(__METHOD__);
return $article;
}
$request = $this->context->getRequest();
// Namespace might change when using redirects
// Check for redirects ...
$action = $request->getVal('action', 'view');
// commented by wikia; $file = ( $title->getNamespace() == NS_FILE ) ? $article->getFile() : null;
// ... and check that we still have ImagePage instance here (might be replaced by 'ArticleFromTitle' hook above) - bugId:9286 (ADi)
$file = $title->getNamespace() == NS_FILE && $article instanceof ImagePage ? $article->getFile() : null;
if (($action == 'view' || $action == 'render') && !$request->getVal('oldid') && !$request->getVal('diff') && $request->getVal('redirect') != 'no' && true) {
// Give extensions a change to ignore/handle redirects as needed
$ignoreRedirect = $target = false;
wfRunHooks('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 (!$wgDisableHardRedirects) {
// we'll need to redirect
wfProfileOut(__METHOD__);
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());
// in MW 1.16 $wgTitle = $target, so we added it here too
$wgTitle = $target;
}
}
} else {
$this->context->setTitle($article->getTitle());
$this->context->setWikiPage($article->getPage());
}
}
wfProfileOut(__METHOD__);
return $article;
}
示例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;
}