本文整理汇总了PHP中SpecialPageFactory::executePath方法的典型用法代码示例。如果您正苦于以下问题:PHP SpecialPageFactory::executePath方法的具体用法?PHP SpecialPageFactory::executePath怎么用?PHP SpecialPageFactory::executePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpecialPageFactory
的用法示例。
在下文中一共展示了SpecialPageFactory::executePath方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSubPageRedirect
public function testSubPageRedirect()
{
$ctx = new RequestContext();
SpecialPageFactory::executePath(Title::newFromText('Special:Search/foo_bar'), $ctx);
$url = $ctx->getOutput()->getRedirect();
// some older versions of hhvm have a bug that doesn't parse relative
// urls with a port, so help it out a little bit.
// https://github.com/facebook/hhvm/issues/7136
$url = wfExpandUrl($url, PROTO_CURRENT);
$parts = parse_url($url);
$this->assertEquals('/w/index.php', $parts['path']);
parse_str($parts['query'], $query);
$this->assertEquals('Special:Search', $query['title']);
$this->assertEquals('foo bar', $query['search']);
}
示例2: performRequest
/**
* Performs the request.
* - bad titles
* - read restriction
* - local interwiki redirects
* - redirect loop
* - special pages
* - normal pages
*
* @throws MWException|PermissionsError|BadTitleError|HttpError
* @return void
*/
private function performRequest()
{
global $wgServer, $wgUsePathInfo, $wgTitle;
wfProfileIn(__METHOD__);
$request = $this->context->getRequest();
$requestTitle = $title = $this->context->getTitle();
$output = $this->context->getOutput();
$user = $this->context->getUser();
if ($request->getVal('printable') === 'yes') {
$output->setPrintable();
}
$unused = null;
// To pass it by reference
wfRunHooks('BeforeInitialize', array(&$title, &$unused, &$output, &$user, $request, $this));
// Invalid titles. Bug 21776: The interwikis must redirect even if the page name is empty.
if (is_null($title) || $title->getDBkey() == '' && $title->getInterwiki() == '' || $title->isSpecial('Badtitle')) {
$this->context->setTitle(SpecialPage::getTitleFor('Badtitle'));
wfProfileOut(__METHOD__);
throw new BadTitleError();
}
// Check user's permissions to read this page.
// We have to check here to catch special pages etc.
// We will check again in Article::view().
$permErrors = $title->getUserPermissionsErrors('read', $user);
if (count($permErrors)) {
// Bug 32276: allowing the skin to generate output with $wgTitle or
// $this->context->title set to the input title would allow anonymous users to
// determine whether a page exists, potentially leaking private data. In fact, the
// curid and oldid request parameters would allow page titles to be enumerated even
// when they are not guessable. So we reset the title to Special:Badtitle before the
// permissions error is displayed.
//
// The skin mostly uses $this->context->getTitle() these days, but some extensions
// still use $wgTitle.
$badTitle = SpecialPage::getTitleFor('Badtitle');
$this->context->setTitle($badTitle);
$wgTitle = $badTitle;
wfProfileOut(__METHOD__);
throw new PermissionsError('read', $permErrors);
}
$pageView = false;
// was an article or special page viewed?
// Interwiki redirects
if ($title->getInterwiki() != '') {
$rdfrom = $request->getVal('rdfrom');
if ($rdfrom) {
$url = $title->getFullURL(array('rdfrom' => $rdfrom));
} else {
$query = $request->getValues();
unset($query['title']);
$url = $title->getFullURL($query);
}
// Check for a redirect loop
if (!preg_match('/^' . preg_quote($wgServer, '/') . '/', $url) && $title->isLocal()) {
// 301 so google et al report the target as the actual url.
$output->redirect($url, 301);
} else {
$this->context->setTitle(SpecialPage::getTitleFor('Badtitle'));
wfProfileOut(__METHOD__);
throw new BadTitleError();
}
// Redirect loops, no title in URL, $wgUsePathInfo URLs, and URLs with a variant
} elseif ($request->getVal('action', 'view') == 'view' && !$request->wasPosted() && ($request->getVal('title') === null || $title->getPrefixedDBkey() != $request->getVal('title')) && !count($request->getValueNames(array('action', 'title'))) && wfRunHooks('TestCanonicalRedirect', array($request, $title, $output))) {
if ($title->isSpecialPage()) {
list($name, $subpage) = SpecialPageFactory::resolveAlias($title->getDBkey());
if ($name) {
$title = SpecialPage::getTitleFor($name, $subpage);
}
}
$targetUrl = wfExpandUrl($title->getFullURL(), PROTO_CURRENT);
// Redirect to canonical url, make it a 301 to allow caching
if ($targetUrl == $request->getFullRequestURL()) {
$message = "Redirect loop detected!\n\n" . "This means the wiki got confused about what page was " . "requested; this sometimes happens when moving a wiki " . "to a new server or changing the server configuration.\n\n";
if ($wgUsePathInfo) {
$message .= "The wiki is trying to interpret the page " . "title from the URL path portion (PATH_INFO), which " . "sometimes fails depending on the web server. Try " . "setting \"\$wgUsePathInfo = false;\" in your " . "LocalSettings.php, or check that \$wgArticlePath " . "is correct.";
} else {
$message .= "Your web server was detected as possibly not " . "supporting URL path components (PATH_INFO) correctly; " . "check your LocalSettings.php for a customized " . "\$wgArticlePath setting and/or toggle \$wgUsePathInfo " . "to true.";
}
throw new HttpError(500, $message);
} else {
$output->setSquidMaxage(1200);
$output->redirect($targetUrl, '301');
}
// Special pages
} elseif (NS_SPECIAL == $title->getNamespace()) {
$pageView = true;
// Actions that need to be made when we have a special pages
SpecialPageFactory::executePath($title, $this->context);
//.........这里部分代码省略.........
示例3: performRequest
//.........这里部分代码省略.........
Hooks::run('BeforeInitialize', [&$title, &$unused, &$output, &$user, $request, $this]);
// Invalid titles. Bug 21776: The interwikis must redirect even if the page name is empty.
if (is_null($title) || $title->getDBkey() == '' && !$title->isExternal() || $title->isSpecial('Badtitle')) {
$this->context->setTitle(SpecialPage::getTitleFor('Badtitle'));
try {
$this->parseTitle();
} catch (MalformedTitleException $ex) {
throw new BadTitleError($ex);
}
throw new BadTitleError();
}
// Check user's permissions to read this page.
// We have to check here to catch special pages etc.
// We will check again in Article::view().
$permErrors = $title->isSpecial('RunJobs') ? [] : $title->getUserPermissionsErrors('read', $user);
if (count($permErrors)) {
// Bug 32276: allowing the skin to generate output with $wgTitle or
// $this->context->title set to the input title would allow anonymous users to
// determine whether a page exists, potentially leaking private data. In fact, the
// curid and oldid request parameters would allow page titles to be enumerated even
// when they are not guessable. So we reset the title to Special:Badtitle before the
// permissions error is displayed.
// The skin mostly uses $this->context->getTitle() these days, but some extensions
// still use $wgTitle.
$badTitle = SpecialPage::getTitleFor('Badtitle');
$this->context->setTitle($badTitle);
$wgTitle = $badTitle;
throw new PermissionsError('read', $permErrors);
}
// Interwiki redirects
if ($title->isExternal()) {
$rdfrom = $request->getVal('rdfrom');
if ($rdfrom) {
$url = $title->getFullURL(['rdfrom' => $rdfrom]);
} else {
$query = $request->getValues();
unset($query['title']);
$url = $title->getFullURL($query);
}
// Check for a redirect loop
if (!preg_match('/^' . preg_quote($this->config->get('Server'), '/') . '/', $url) && $title->isLocal()) {
// 301 so google et al report the target as the actual url.
$output->redirect($url, 301);
} else {
$this->context->setTitle(SpecialPage::getTitleFor('Badtitle'));
try {
$this->parseTitle();
} catch (MalformedTitleException $ex) {
throw new BadTitleError($ex);
}
throw new BadTitleError();
}
// Handle any other redirects.
// Redirect loops, titleless URL, $wgUsePathInfo URLs, and URLs with a variant
} elseif (!$this->tryNormaliseRedirect($title)) {
// Prevent information leak via Special:MyPage et al (T109724)
if ($title->isSpecialPage()) {
$specialPage = SpecialPageFactory::getPage($title->getDBkey());
if ($specialPage instanceof RedirectSpecialPage) {
$specialPage->setContext($this->context);
if ($this->config->get('HideIdentifiableRedirects') && $specialPage->personallyIdentifiableTarget()) {
list(, $subpage) = SpecialPageFactory::resolveAlias($title->getDBkey());
$target = $specialPage->getRedirect($subpage);
// target can also be true. We let that case fall through to normal processing.
if ($target instanceof Title) {
$query = $specialPage->getRedirectQuery() ?: [];
$request = new DerivativeRequest($this->context->getRequest(), $query);
$request->setRequestURL($this->context->getRequest()->getRequestURL());
$this->context->setRequest($request);
// Do not varnish cache these. May vary even for anons
$this->context->getOutput()->lowerCdnMaxage(0);
$this->context->setTitle($target);
$wgTitle = $target;
// Reset action type cache. (Special pages have only view)
$this->action = null;
$title = $target;
$output->addJsConfigVars(['wgInternalRedirectTargetUrl' => $target->getFullURL($query)]);
$output->addModules('mediawiki.action.view.redirect');
}
}
}
}
// Special pages ($title may have changed since if statement above)
if (NS_SPECIAL == $title->getNamespace()) {
// Actions that need to be made when we have a special pages
SpecialPageFactory::executePath($title, $this->context);
} else {
// ...otherwise treat it as an article view. The article
// may still be a wikipage redirect to another article or URL.
$article = $this->initializeArticle();
if (is_object($article)) {
$this->performAction($article, $requestTitle);
} elseif (is_string($article)) {
$output->redirect($article);
} else {
throw new MWException("Shouldn't happen: MediaWiki::initializeArticle()" . " returned neither an object nor a URL");
}
}
}
}
示例4: performRequest
/**
* Performs the request.
* - bad titles
* - read restriction
* - local interwiki redirects
* - redirect loop
* - special pages
* - normal pages
*
* @throws MWException|PermissionsError|BadTitleError|HttpError
* @return void
*/
private function performRequest()
{
global $wgTitle;
$request = $this->context->getRequest();
$requestTitle = $title = $this->context->getTitle();
$output = $this->context->getOutput();
$user = $this->context->getUser();
if ($request->getVal('printable') === 'yes') {
$output->setPrintable();
}
$unused = null;
// To pass it by reference
Hooks::run('BeforeInitialize', array(&$title, &$unused, &$output, &$user, $request, $this));
// Invalid titles. Bug 21776: The interwikis must redirect even if the page name is empty.
if (is_null($title) || $title->getDBkey() == '' && !$title->isExternal() || $title->isSpecial('Badtitle')) {
$this->context->setTitle(SpecialPage::getTitleFor('Badtitle'));
try {
$this->parseTitle();
} catch (MalformedTitleException $ex) {
throw new BadTitleError($ex);
}
throw new BadTitleError();
}
// Check user's permissions to read this page.
// We have to check here to catch special pages etc.
// We will check again in Article::view().
$permErrors = $title->isSpecial('RunJobs') ? array() : $title->getUserPermissionsErrors('read', $user);
if (count($permErrors)) {
// Bug 32276: allowing the skin to generate output with $wgTitle or
// $this->context->title set to the input title would allow anonymous users to
// determine whether a page exists, potentially leaking private data. In fact, the
// curid and oldid request parameters would allow page titles to be enumerated even
// when they are not guessable. So we reset the title to Special:Badtitle before the
// permissions error is displayed.
//
// The skin mostly uses $this->context->getTitle() these days, but some extensions
// still use $wgTitle.
$badTitle = SpecialPage::getTitleFor('Badtitle');
$this->context->setTitle($badTitle);
$wgTitle = $badTitle;
throw new PermissionsError('read', $permErrors);
}
// Interwiki redirects
if ($title->isExternal()) {
$rdfrom = $request->getVal('rdfrom');
if ($rdfrom) {
$url = $title->getFullURL(array('rdfrom' => $rdfrom));
} else {
$query = $request->getValues();
unset($query['title']);
$url = $title->getFullURL($query);
}
// Check for a redirect loop
if (!preg_match('/^' . preg_quote($this->config->get('Server'), '/') . '/', $url) && $title->isLocal()) {
// 301 so google et al report the target as the actual url.
$output->redirect($url, 301);
} else {
$this->context->setTitle(SpecialPage::getTitleFor('Badtitle'));
try {
$this->parseTitle();
} catch (MalformedTitleException $ex) {
throw new BadTitleError($ex);
}
throw new BadTitleError();
}
// Handle any other redirects.
// Redirect loops, titleless URL, $wgUsePathInfo URLs, and URLs with a variant
} elseif (!$this->tryNormaliseRedirect($title)) {
// Special pages
if (NS_SPECIAL == $title->getNamespace()) {
// Actions that need to be made when we have a special pages
SpecialPageFactory::executePath($title, $this->context);
} else {
// ...otherwise treat it as an article view. The article
// may still be a wikipage redirect to another article or URL.
$article = $this->initializeArticle();
if (is_object($article)) {
$this->performAction($article, $requestTitle);
} elseif (is_string($article)) {
$output->redirect($article);
} else {
throw new MWException("Shouldn't happen: MediaWiki::initializeArticle()" . " returned neither an object nor a URL");
}
}
}
}
示例5: executePath
/**
* Execute a special page path.
* The path may contain parameters, e.g. Special:Name/Params
* Extracts the special page name and call the execute method, passing the parameters
*
* Returns a title object if the page is redirected, false if there was no such special
* page, and true if it was successful.
*
* @param $title Title object
* @param $context IContextSource
* @param $including Bool output is being captured for use in {{special:whatever}}
* @return Bool
* @deprecated since 1.18 call SpecialPageFactory method directly
*/
public static function executePath(&$title, IContextSource &$context, $including = false)
{
wfDeprecated(__METHOD__, '1.18');
return SpecialPageFactory::executePath($title, $context, $including);
}
示例6: executePath
/**
* Execute a special page path.
* The path may contain parameters, e.g. Special:Name/Params
* Extracts the special page name and call the execute method, passing the parameters
*
* Returns a title object if the page is redirected, false if there was no such special
* page, and true if it was successful.
*
* @param $title Title object
* @param $context IContextSource
* @param $including Bool output is being captured for use in {{special:whatever}}
* @return Bool
* @deprecated since 1.18 call SpecialPageFactory method directly
*/
public static function executePath(&$title, IContextSource &$context, $including = false)
{
return SpecialPageFactory::executePath($title, $context, $including);
}
示例7: performRequest
/**
* Performs the request.
* - bad titles
* - read restriction
* - local interwiki redirects
* - redirect loop
* - special pages
* - normal pages
*
* @return void
*/
private function performRequest()
{
global $wgServer, $wgUsePathInfo;
wfProfileIn(__METHOD__);
$request = $this->context->getRequest();
$title = $this->context->getTitle();
$output = $this->context->getOutput();
$user = $this->context->getUser();
if ($request->getVal('printable') === 'yes') {
$output->setPrintable();
}
$pageView = false;
// was an article or special page viewed?
wfRunHooks('BeforeInitialize', array(&$title, null, &$output, &$user, $request, $this));
// Invalid titles. Bug 21776: The interwikis must redirect even if the page name is empty.
if (is_null($title) || $title->getDBkey() == '' && $title->getInterwiki() == '' || $title->isSpecial('Badtitle')) {
$this->context->setTitle(SpecialPage::getTitleFor('Badtitle'));
// Die now before we mess up $wgArticle and the skin stops working
throw new ErrorPageError('badtitle', 'badtitletext');
// If the user is not logged in, the Namespace:title of the article must be in
// the Read array in order for the user to see it. (We have to check here to
// catch special pages etc. We check again in Article::view())
} elseif (!$title->userCanRead()) {
$output->loginToUse();
// Interwiki redirects
} elseif ($title->getInterwiki() != '') {
$rdfrom = $request->getVal('rdfrom');
if ($rdfrom) {
$url = $title->getFullURL('rdfrom=' . urlencode($rdfrom));
} else {
$query = $request->getValues();
unset($query['title']);
$url = $title->getFullURL($query);
}
// Check for a redirect loop
if (!preg_match('/^' . preg_quote($wgServer, '/') . '/', $url) && $title->isLocal()) {
// 301 so google et al report the target as the actual url.
$output->redirect($url, 301);
} else {
$this->context->setTitle(SpecialPage::getTitleFor('Badtitle'));
wfProfileOut(__METHOD__);
throw new ErrorPageError('badtitle', 'badtitletext');
}
// Redirect loops, no title in URL, $wgUsePathInfo URLs, and URLs with a variant
} elseif ($request->getVal('action', 'view') == 'view' && !$request->wasPosted() && ($request->getVal('title') === null || $title->getPrefixedDBKey() != $request->getVal('title')) && !count($request->getValueNames(array('action', 'title'))) && wfRunHooks('TestCanonicalRedirect', array($request, $title, $output))) {
if ($title->getNamespace() == NS_SPECIAL) {
list($name, $subpage) = SpecialPageFactory::resolveAlias($title->getDBkey());
if ($name) {
$title = SpecialPage::getTitleFor($name, $subpage);
}
}
$targetUrl = wfExpandUrl($title->getFullURL(), PROTO_CURRENT);
// Redirect to canonical url, make it a 301 to allow caching
if ($targetUrl == $request->getFullRequestURL()) {
$message = "Redirect loop detected!\n\n" . "This means the wiki got confused about what page was " . "requested; this sometimes happens when moving a wiki " . "to a new server or changing the server configuration.\n\n";
if ($wgUsePathInfo) {
$message .= "The wiki is trying to interpret the page " . "title from the URL path portion (PATH_INFO), which " . "sometimes fails depending on the web server. Try " . "setting \"\$wgUsePathInfo = false;\" in your " . "LocalSettings.php, or check that \$wgArticlePath " . "is correct.";
} else {
$message .= "Your web server was detected as possibly not " . "supporting URL path components (PATH_INFO) correctly; " . "check your LocalSettings.php for a customized " . "\$wgArticlePath setting and/or toggle \$wgUsePathInfo " . "to true.";
}
wfHttpError(500, "Internal error", $message);
} else {
$output->setSquidMaxage(1200);
$output->redirect($targetUrl, '301');
}
// Special pages
} elseif (NS_SPECIAL == $title->getNamespace()) {
$pageView = true;
// Actions that need to be made when we have a special pages
SpecialPageFactory::executePath($title, $this->context);
} else {
// ...otherwise treat it as an article view. The article
// may be a redirect to another article or URL.
$article = $this->initializeArticle();
if (is_object($article)) {
$pageView = true;
/**
* $wgArticle is deprecated, do not use it. This will possibly be removed
* entirely in 1.20 or 1.21
* @deprecated since 1.18
*/
global $wgArticle;
$wgArticle = $article;
$this->performAction($article);
} elseif (is_string($article)) {
$output->redirect($article);
} else {
wfProfileOut(__METHOD__);
throw new MWException("Shouldn't happen: MediaWiki::initializeArticle() returned neither an object nor a URL");
//.........这里部分代码省略.........
示例8: performRequest
//.........这里部分代码省略.........
}
if ($isNew) {
wfRunHooks('AddNewAccount', array($u, false));
$u->addNewUserLogEntry('create');
$injected_html = '';
wfRunHooks('UserLoginComplete', array(&$u, &$injected_html));
$welcome_creation_msg = 'welcomecreation-msg';
wfRunHooks('BeforeWelcomeCreation', array(&$welcome_creation_msg, &$injected_html));
} else {
$injected_html = '';
wfRunHooks('UserLoginComplete', array(&$u, &$injected_html));
}
# </SANDSTORM>
if ($request->getVal('printable') === 'yes') {
$output->setPrintable();
}
$unused = null;
// To pass it by reference
Hooks::run('BeforeInitialize', array(&$title, &$unused, &$output, &$user, $request, $this));
// Invalid titles. Bug 21776: The interwikis must redirect even if the page name is empty.
if (is_null($title) || $title->getDBkey() == '' && !$title->isExternal() || $title->isSpecial('Badtitle')) {
$this->context->setTitle(SpecialPage::getTitleFor('Badtitle'));
throw new BadTitleError();
}
// Check user's permissions to read this page.
// We have to check here to catch special pages etc.
// We will check again in Article::view().
$permErrors = $title->isSpecial('RunJobs') ? array() : $title->getUserPermissionsErrors('read', $user);
if (count($permErrors)) {
// Bug 32276: allowing the skin to generate output with $wgTitle or
// $this->context->title set to the input title would allow anonymous users to
// determine whether a page exists, potentially leaking private data. In fact, the
// curid and oldid request parameters would allow page titles to be enumerated even
// when they are not guessable. So we reset the title to Special:Badtitle before the
// permissions error is displayed.
//
// The skin mostly uses $this->context->getTitle() these days, but some extensions
// still use $wgTitle.
$badTitle = SpecialPage::getTitleFor('Badtitle');
$this->context->setTitle($badTitle);
$wgTitle = $badTitle;
throw new PermissionsError('read', $permErrors);
}
// Interwiki redirects
if ($title->isExternal()) {
$rdfrom = $request->getVal('rdfrom');
if ($rdfrom) {
$url = $title->getFullURL(array('rdfrom' => $rdfrom));
} else {
$query = $request->getValues();
unset($query['title']);
$url = $title->getFullURL($query);
}
// Check for a redirect loop
if (!preg_match('/^' . preg_quote($this->config->get('Server'), '/') . '/', $url) && $title->isLocal()) {
// 301 so google et al report the target as the actual url.
$output->redirect($url, 301);
} else {
$this->context->setTitle(SpecialPage::getTitleFor('Badtitle'));
throw new BadTitleError();
}
// Redirect loops, no title in URL, $wgUsePathInfo URLs, and URLs with a variant
} elseif ($request->getVal('action', 'view') == 'view' && !$request->wasPosted() && ($request->getVal('title') === null || $title->getPrefixedDBkey() != $request->getVal('title')) && !count($request->getValueNames(array('action', 'title'))) && Hooks::run('TestCanonicalRedirect', array($request, $title, $output))) {
if ($title->isSpecialPage()) {
list($name, $subpage) = SpecialPageFactory::resolveAlias($title->getDBkey());
if ($name) {
$title = SpecialPage::getTitleFor($name, $subpage);
}
}
$targetUrl = wfExpandUrl($title->getFullURL(), PROTO_CURRENT);
// Redirect to canonical url, make it a 301 to allow caching
if ($targetUrl == $request->getFullRequestURL()) {
$message = "Redirect loop detected!\n\n" . "This means the wiki got confused about what page was " . "requested; this sometimes happens when moving a wiki " . "to a new server or changing the server configuration.\n\n";
if ($this->config->get('UsePathInfo')) {
$message .= "The wiki is trying to interpret the page " . "title from the URL path portion (PATH_INFO), which " . "sometimes fails depending on the web server. Try " . "setting \"\$wgUsePathInfo = false;\" in your " . "LocalSettings.php, or check that \$wgArticlePath " . "is correct.";
} else {
$message .= "Your web server was detected as possibly not " . "supporting URL path components (PATH_INFO) correctly; " . "check your LocalSettings.php for a customized " . "\$wgArticlePath setting and/or toggle \$wgUsePathInfo " . "to true.";
}
throw new HttpError(500, $message);
} else {
$output->setSquidMaxage(1200);
$output->redirect($targetUrl, '301');
}
// Special pages
} elseif (NS_SPECIAL == $title->getNamespace()) {
// Actions that need to be made when we have a special pages
SpecialPageFactory::executePath($title, $this->context);
} else {
// ...otherwise treat it as an article view. The article
// may be a redirect to another article or URL.
$article = $this->initializeArticle();
if (is_object($article)) {
$this->performAction($article, $requestTitle);
} elseif (is_string($article)) {
$output->redirect($article);
} else {
throw new MWException("Shouldn't happen: MediaWiki::initializeArticle()" . " returned neither an object nor a URL");
}
}
}