本文整理汇总了PHP中SpecialPageFactory::getPage方法的典型用法代码示例。如果您正苦于以下问题:PHP SpecialPageFactory::getPage方法的具体用法?PHP SpecialPageFactory::getPage怎么用?PHP SpecialPageFactory::getPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpecialPageFactory
的用法示例。
在下文中一共展示了SpecialPageFactory::getPage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSpecialPage
/**
* @dataProvider provideSpecialPages
*/
public function testSpecialPage($name)
{
$page = SpecialPageFactory::getPage($name);
$title = $page->getPageTitle();
$context = RequestContext::newExtraneousContext($title);
$page->setContext($context);
try {
$page->run(null);
} catch (PermissionsError $e) {
// This is okay
wfDebug('Permissions error caught; expected.');
} catch (ErrorPageError $e) {
// This is okay as well
wfDebug('Page error caught; expected.');
}
$this->assertTrue(true, "Special page {$name} was executed succesfully with anon user");
$user = new MockSuperUser();
$context->setUser($user);
$page->setContext($context);
// This should not throw permission errors
try {
$page->run(null);
} catch (ErrorPageError $e) {
// This is okay here
wfDebug('Page error caught; expected.');
}
$this->assertTrue(true, "Special page {$name} was executed succesfully with super user");
}
示例2: buildData
public function buildData()
{
global $wgUser, $wgTitle;
$page = SpecialPageFactory::getPage($this->name);
if (!is_object($page)) {
$this->buildExternalData();
return;
}
$this->available = true;
$this->enabled = $page->userCanExecute($wgUser);
$this->caption = $page->getDescription();
$this->description = $page->getDescription();
$this->href = $page->getTitle()->getLocalUrl();
switch ($this->name) {
case 'RecentChangesLinked':
$this->href .= '/' . $wgTitle->getPartialUrl();
break;
case 'Contributions':
$this->href .= '/' . $wgUser->getTitleKey();
break;
}
$specialPageName = $page->getName();
$options = array();
wfRunHooks("UserCommand::SpecialPage::{$specialPageName}", array($this, &$options));
foreach ($options as $k => $v) {
$this->{$k} = $v;
}
}
示例3: show
public function show()
{
$special = SpecialPageFactory::getPage('Revisiondelete');
$special->setContext($this->getContext());
$special->getContext()->setTitle($special->getPageTitle());
$special->run('');
}
示例4: buildData
public function buildData()
{
global $wgUser, $wgTitle;
$page = SpecialPageFactory::getPage($this->name);
if (!is_object($page)) {
$this->buildExternalData();
// BugId:22989 - we don't want the PageLayoutBuilder to be shown if disabled.
if ('LayoutBuilder' == $this->name) {
// do not show PLB if it's not available on the wiki
$this->available = $this->enabled;
}
return;
}
$this->available = true;
$this->enabled = $page->userCanExecute($wgUser);
$this->caption = $page->getDescription();
$this->description = $page->getDescription();
$this->href = $page->getTitle()->getLocalUrl();
switch ($this->name) {
case 'RecentChangesLinked':
$this->href .= '/' . $wgTitle->getPartialUrl();
break;
case 'Contributions':
$this->href .= '/' . $wgUser->getTitleKey();
break;
}
$specialPageName = $page->getName();
$options = array();
wfRunHooks("UserCommand::SpecialPage::{$specialPageName}", array($this, &$options));
foreach ($options as $k => $v) {
$this->{$k} = $v;
}
}
示例5: testGetPage
/**
* @covers SpecialPageFactory::getPage
* @dataProvider specialPageProvider
*/
public function testGetPage($spec, $shouldReuseInstance)
{
$this->mergeMwGlobalArrayValue('wgSpecialPages', array('testdummy' => $spec));
SpecialPageFactory::resetList();
$page = SpecialPageFactory::getPage('testdummy');
$this->assertInstanceOf('SpecialPage', $page);
$page2 = SpecialPageFactory::getPage('testdummy');
$this->assertEquals($shouldReuseInstance, $page2 === $page, "Should re-use instance:");
}
示例6: show
public function show()
{
$action = self::getName();
if ($action === 'nosuchaction') {
throw new ErrorPageError($this->msg('nosuchaction'), $this->msg('nosuchactiontext'));
}
// map actions to (whitelisted) special pages
$special = SpecialPageFactory::getPage(self::$actionToSpecialPageMapping[$action]);
$special->setContext($this->getContext());
$special->getContext()->setTitle($special->getPageTitle());
$special->run('');
}
示例7: printAltFormsList
function printAltFormsList($alt_forms, $target_name)
{
$text = "";
$fe = SpecialPageFactory::getPage('FormEdit');
$fe_url = $fe->getTitle()->getFullURL();
$i = 0;
foreach ($alt_forms as $alt_form) {
if ($i++ > 0) {
$text .= ', ';
}
$text .= "<a href=\"{$fe_url}/{$alt_form}/{$target_name}\">" . str_replace('_', ' ', $alt_form) . '</a>';
}
return $text;
}
示例8: printAltFormsList
function printAltFormsList($alt_forms, $target_name)
{
$text = "";
$fe = SpecialPageFactory::getPage('FormEdit');
$fe_url = $fe->getTitle()->getFullURL();
$i = 0;
foreach ($alt_forms as $alt_form) {
if ($i++ > 0) {
$text .= ', ';
}
$altFormURL = $fe_url . '/' . rawurlencode($alt_form) . '/' . rawurlencode($target_name);
$text .= Html::element('a', array('href' => $altFormURL), str_replace('_', ' ', $alt_form));
}
return $text;
}
示例9: execute
public function execute($param)
{
$this->setHeaders();
$oOutput = new SpecialNewWikisGraphOutput();
$endDate = new DateTime(date('Y-m-d'));
$endDate->sub(new DateInterval('P1D'));
$startDate = clone $endDate;
$startDate->sub(new DateInterval('P1M'));
$oOutput->set($this->getReport($startDate, $endDate, $param));
$aAllOptions = array_merge($this->aAvailableLanguages, $this->aAvailableOtherOptions);
$param = in_array($param, $aAllOptions) ? $param : '';
$oOutput->setActive($param);
$sReturnChart = $oOutput->getHTML();
$oTmpl = new EasyTemplate(dirname(__FILE__) . "/templates/");
$oTmpl->set_vars(array("tabs" => $this->aAvailableLanguages, "other" => $this->aAvailableOtherOptions, "active" => $param, "path" => SpecialPageFactory::getPage(self::NEW_WIKIS_GRAPH)->getTitle()->getFullURL()));
F::app()->wg->out->addHTML($oTmpl->render("metrics-menu"));
F::app()->wg->out->addHTML($sReturnChart);
}
示例10: getSpecialPage
/**
* Compatibility helper function.
* Since 1.18 SpecialPageFactory::getPage should be used.
* SpecialPage::getPage is deprecated in 1.18.
*
* @since 2.3.3
*
* @param string $pageName
*
* @return SpecialPage|null
*/
public static function getSpecialPage($pageName)
{
$hasFactory = class_exists('SpecialPageFactory') && method_exists('SpecialPageFactory', 'getPage');
return $hasFactory ? SpecialPageFactory::getPage($pageName) : SpecialPage::getPage($pageName);
}
示例11: createFormLink
static function createFormLink(&$parser, $params, $parserFunctionName)
{
// Set defaults.
$inFormName = $inLinkStr = $inExistingPageLinkStr = $inLinkType = $inTooltip = $inQueryStr = $inTargetName = '';
if ($parserFunctionName == 'queryformlink') {
$inLinkStr = wfMessage('runquery')->text();
}
$inCreatePage = false;
$classStr = '';
$inQueryArr = array();
$targetWindow = '_self';
// assign params
// - support unlabelled params, for backwards compatibility
// - parse and sanitize all parameter values
foreach ($params as $i => $param) {
$elements = explode('=', $param, 2);
// set param_name and value
if (count($elements) > 1) {
$param_name = trim($elements[0]);
// parse (and sanitize) parameter values
$value = trim($parser->recursiveTagParse($elements[1]));
} else {
$param_name = null;
// parse (and sanitize) parameter values
$value = trim($parser->recursiveTagParse($param));
}
if ($param_name == 'form') {
$inFormName = $value;
} elseif ($param_name == 'link text') {
$inLinkStr = $value;
} elseif ($param_name == 'existing page link text') {
$inExistingPageLinkStr = $value;
} elseif ($param_name == 'link type') {
$inLinkType = $value;
} elseif ($param_name == 'query string') {
// Change HTML-encoded ampersands directly to
// URL-encoded ampersands, so that the string
// doesn't get split up on the '&'.
$inQueryStr = str_replace('&', '%26', $value);
parse_str($inQueryStr, $arr);
$inQueryArr = self::array_merge_recursive_distinct($inQueryArr, $arr);
} elseif ($param_name == 'tooltip') {
$inTooltip = Sanitizer::decodeCharReferences($value);
} elseif ($param_name == 'target') {
$inTargetName = $value;
} elseif ($param_name == null && $value == 'popup') {
self::loadScriptsForPopupForm($parser);
$classStr = 'popupformlink';
} elseif ($param_name == null && $value == 'new window') {
$targetWindow = '_blank';
} elseif ($param_name == null && $value == 'create page') {
$inCreatePage = true;
} elseif ($param_name !== null) {
$value = urlencode($value);
parse_str("{$param_name}={$value}", $arr);
$inQueryArr = self::array_merge_recursive_distinct($inQueryArr, $arr);
}
}
// Not the most graceful way to do this, but it is the
// easiest - if this is the #formredlink function, just
// ignore whatever values were passed in for these params.
if ($parserFunctionName == 'formredlink') {
$inLinkType = $inTooltip = null;
}
// If "red link only" was specified, and a target page was
// specified, and it exists, just link to the page.
if ($inTargetName != '') {
$targetTitle = Title::newFromText($inTargetName);
$targetPageExists = $targetTitle != '' && $targetTitle->exists();
} else {
$targetPageExists = false;
}
if ($parserFunctionName == 'formredlink' && $targetPageExists) {
if ($inExistingPageLinkStr == '') {
return Linker::link($targetTitle);
} else {
return Linker::link($targetTitle, $inExistingPageLinkStr);
}
}
// The page doesn't exist, so if 'create page' was
// specified, create the page now.
if ($parserFunctionName == 'formredlink' && $inCreatePage && $inTargetName != '') {
$targetTitle = Title::newFromText($inTargetName);
SFFormLinker::createPageWithForm($targetTitle, $inFormName);
}
if ($parserFunctionName == 'queryformlink') {
$formSpecialPage = SpecialPageFactory::getPage('RunQuery');
} else {
$formSpecialPage = SpecialPageFactory::getPage('FormEdit');
}
if ($inFormName == '') {
$query = array('target' => $inTargetName);
$link_url = $formSpecialPage->getTitle()->getLocalURL($query);
} elseif (strpos($inFormName, '/') == true) {
$query = array('form' => $inFormName, 'target' => $inTargetName);
$link_url = $formSpecialPage->getTitle()->getLocalURL($query);
} else {
$link_url = $formSpecialPage->getTitle()->getLocalURL() . "/{$inFormName}";
if (!empty($inTargetName)) {
$link_url .= "/{$inTargetName}";
//.........这里部分代码省略.........
示例12: 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)) {
// Prevent information leak via Special:MyPage et al (T109724)
if ($title->isSpecialPage()) {
$specialPage = SpecialPageFactory::getPage($title->getDBKey());
if ($specialPage instanceof RedirectSpecialPage && $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() ?: array();
$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(array('wgInternalRedirectTargetUrl' => $target->getFullURL($query)));
$output->addModules('mediawiki.action.view.redirect');
//.........这里部分代码省略.........
示例13: uploadableHTML
public static function uploadableHTML($input_id, $delimiter = null, $default_filename = null, $cur_value = '', $other_args = array())
{
$upload_window_page = SpecialPageFactory::getPage('UploadWindow');
$query_string = "sfInputID={$input_id}";
if ($delimiter != null) {
$query_string .= "&sfDelimiter={$delimiter}";
}
if ($default_filename != null) {
$query_string .= "&wpDestFile={$default_filename}";
}
$upload_window_url = $upload_window_page->getTitle()->getFullURL($query_string);
$upload_label = wfMessage('upload')->text();
// We need to set the size by default.
$style = "width:650 height:500";
$cssClasses = array('sfFancyBox', 'sfUploadable');
$showPreview = array_key_exists('image preview', $other_args);
if ($showPreview) {
$cssClasses[] = 'sfImagePreview';
}
$linkAttrs = array('href' => $upload_window_url, 'class' => implode(' ', $cssClasses), 'rev' => $style, 'data-input-id' => $input_id);
$text = "\t" . Html::element('a', $linkAttrs, $upload_label) . "\n";
if ($showPreview) {
$text .= Html::rawElement('div', array('id' => $input_id . '_imagepreview', 'class' => 'sfImagePreviewWrapper'), self::getPreviewImage($cur_value));
}
return $text;
}
示例14: specialPagesList
/**
* Show a drop-down box of special pages
* @return string
*/
function specialPagesList()
{
global $wgScript;
$select = new XmlSelect('title');
$pages = SpecialPageFactory::getUsablePages();
array_unshift($pages, SpecialPageFactory::getPage('SpecialPages'));
foreach ($pages as $obj) {
$select->addOption($obj->getDescription(), $obj->getTitle()->getPrefixedDBkey());
}
return Html::rawElement('form', array('id' => 'specialpages', 'method' => 'get', 'action' => $wgScript), $select->getHTML() . Xml::submitButton(wfMessage('go')->text()));
}
示例15: GetSpecialPage
/**
* @brief This returns the HTML output of any SpecialPage::execute function
* @details
* SpecialPage::capturePath will skip SpecialPages which are not "includable"
* (which is all the interesting ones) So we need to force it.
*
* @requestParam string page the name of the Special page to invoke
* @responseParam string output the HTML output of the special page
*/
public function GetSpecialPage()
{
if (!$this->wg->User->isAllowed('admindashboard')) {
$this->displayRestrictionError();
return false;
// skip rendering
}
// Construct title object from request params
$pageName = $this->getVal("page");
$title = SpecialPage::getTitleFor($pageName);
// Save global variables and initialize context for special page
global $wgOut, $wgTitle;
$oldTitle = $wgTitle;
$oldOut = $wgOut;
$wgOut = new OutputPage();
$wgOut->setTitle($title);
$wgTitle = $title;
// Construct special page object
try {
$basePages = array("Categories", "Recentchanges", "Specialpages");
if (in_array($pageName, $basePages)) {
$sp = SpecialPageFactory::getPage($pageName);
} else {
$sp = new $pageName();
}
} catch (Exception $e) {
print_pre("Could not construct special page object");
}
if ($sp instanceof SpecialPage) {
$ret = $sp->execute(false);
} else {
print_pre("Object is not a special page.");
}
// TODO: check retval of special page call?
$this->output = $wgOut->getHTML();
// Restore global variables
$wgTitle = $oldTitle;
$wgOut = $oldOut;
}