function feedTitle() { global $wgLanguageCode, $wgSitename; $page = SpecialPage::getPage($this->getName()); $desc = $page->getDescription(); return "{$wgSitename} - {$desc} [{$wgLanguageCode}]"; }
/** * Perform one of the "standard" actions * * @param $output OutputPage * @param $article Article * @param $title Title * @param $user User * @param $request WebRequest */ function performAction(&$output, &$article, &$title, &$user, &$request) { wfProfileIn(__METHOD__); if (!wfRunHooks('MediaWikiPerformAction', array($output, $article, $title, $user, $request, $this))) { wfProfileOut(__METHOD__); return; } $action = $this->getVal('Action'); if (in_array($action, $this->getVal('DisabledActions', array()))) { /* No such action; this will switch to the default case */ $action = 'nosuchaction'; } // Workaround for bug #20966: inability of IE to provide an action dependent // on which submit button is clicked. if ($action === 'historysubmit') { if ($request->getBool('revisiondelete')) { $action = 'revisiondelete'; } else { $action = 'view'; } } switch ($action) { case 'view': $output->setSquidMaxage($this->getVal('SquidMaxage')); $article->view(); break; case 'raw': // includes JS/CSS wfProfileIn(__METHOD__ . '-raw'); $raw = new RawPage($article); $raw->view(); wfProfileOut(__METHOD__ . '-raw'); break; case 'watch': case 'unwatch': case 'delete': case 'revert': case 'rollback': case 'protect': case 'unprotect': case 'info': case 'markpatrolled': case 'render': case 'deletetrackback': case 'purge': $article->{$action}(); break; case 'print': $article->view(); break; case 'dublincore': if (!$this->getVal('EnableDublinCoreRdf')) { wfHttpError(403, 'Forbidden', wfMsg('nodublincore')); } else { $rdf = new DublinCoreRdf($article); $rdf->show(); } break; case 'creativecommons': if (!$this->getVal('EnableCreativeCommonsRdf')) { wfHttpError(403, 'Forbidden', wfMsg('nocreativecommons')); } else { $rdf = new CreativeCommonsRdf($article); $rdf->show(); } break; case 'credits': Credits::showPage($article); break; case 'submit': if (session_id() == '') { /* Send a cookie so anons get talk message notifications */ wfSetupSession(); } /* Continue... */ /* Continue... */ case 'edit': case 'editredlink': if (wfRunHooks('CustomEditor', array($article, $user))) { $internal = $request->getVal('internaledit'); $external = $request->getVal('externaledit'); $section = $request->getVal('section'); $oldid = $request->getVal('oldid'); if (!$this->getVal('UseExternalEditor') || $action == 'submit' || $internal || $section || $oldid || !$user->getOption('externaleditor') && !$external) { $editor = new EditPage($article); $editor->submit(); } elseif ($this->getVal('UseExternalEditor') && ($external || $user->getOption('externaleditor'))) { $mode = $request->getVal('mode'); $extedit = new ExternalEdit($article, $mode); $extedit->edit(); } } break; case 'history': if ($request->getFullRequestURL() == $title->getInternalURL('action=history')) { $output->setSquidMaxage($this->getVal('SquidMaxage')); } $history = new HistoryPage($article); $history->history(); break; case 'revisiondelete': // For show/hide submission from history page $special = SpecialPage::getPage('Revisiondelete'); $special->execute(''); break; default: if (wfRunHooks('UnknownAction', array($action, $article))) { $output->showErrorPage('nosuchaction', 'nosuchactiontext'); } } wfProfileOut(__METHOD__); }
/** * 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); }
wfDie(); } $wgOut->disable(); $dbw = wfGetDB(DB_MASTER); foreach ($wgQueryPages as $page) { @(list($class, $special, $limit) = $page); # --list : just show the name of pages if (@$options['list']) { print "{$special}\n"; continue; } if (!isset($options['override']) && $wgDisableQueryPageUpdate && in_array($special, $wgDisableQueryPageUpdate)) { printf("%-30s disabled\n", $special); continue; } $specialObj = SpecialPage::getPage($special); if (!$specialObj) { print "No such special page: {$special}\n"; exit; } if (!class_exists($class)) { $file = $specialObj->getFile(); require_once $file; } $queryPage = new $class(); if (!isset($options['only']) or $options['only'] == $queryPage->getName()) { printf('%-30s ', $special); if ($queryPage->isExpensive()) { $t1 = explode(' ', microtime()); # Do the query $num = $queryPage->recache($limit === null ? $wgQueryCacheLimit : $limit);
/** * This actually refreshes the special pages * Will need to be modified further */ function refreshSpecial() { global $wgRequest, $wgQueryPages, $wgOut; $dbw = wfGetDB(DB_MASTER); $to_refresh = $wgRequest->getArray('wpSpecial'); $total = array('pages' => 0, 'rows' => 0, 'elapsed' => 0, 'total_elapsed' => 0); foreach ($wgQueryPages as $page) { @(list($class, $special, $limit) = $page); if (!in_array($special, $to_refresh)) { continue; } $specialObj = SpecialPage::getPage($special); if (!$specialObj) { $wgOut->addWikiText(wfMsg('refreshspecial-no-page') . ": {$special}\n"); exit; } $file = $specialObj->getFile(); if ($file) { require_once $file; } $queryPage = new $class(); $message = ''; if (!isset($options['only']) or $options['only'] == $queryPage->getName()) { $wgOut->addHTML("<b>{$special}</b>: "); if ($queryPage->isExpensive()) { $t1 = explode(' ', microtime()); # Do the query $num = $queryPage->recache($limit === null ? REFRESHSPECIAL_ROW_LIMIT : $limit); $t2 = explode(' ', microtime()); if ($num === false) { $wgOut->addHTML(wfMsg('refreshspecial-db-error') . '<br />'); } else { $message = wfMsgExt('refreshspecial-page-result', array('escape', 'parsemag'), $num) . ' '; $elapsed = $t2[0] - $t1[0] + ($t2[1] - $t1[1]); $total['elapsed'] += $elapsed; $total['rows'] += $num; $total['pages']++; $ftime = $this->computeTime($elapsed); $this->formatTimeMessage($ftime, $message); $wgOut->addHTML("{$message}<br />"); } $t1 = explode(' ', microtime()); # Reopen any connections that have closed if (!wfGetLB()->pingAll()) { $wgOut->addHTML('<br />'); do { $wgOut->addHTML(wfMsg('refreshspecial-reconnecting') . '<br />'); sleep(REFRESHSPECIAL_RECONNECTION_SLEEP); } while (!wfGetLB()->pingAll()); $wgOut->addHTML(wfMsg('refreshspecial-reconnected') . '<br /><br />'); } else { # Commit the results $dbw->commit(); } # Wait for the slave to catch up $slaveDB = wfGetDB(DB_SLAVE, array('QueryPage::recache', 'vslow')); while (wfGetLB()->safeGetLag($slaveDB) > REFRESHSPECIAL_SLAVE_LAG_LIMIT) { $wgOut->addHTML(wfMsg('refreshspecial-slave-lagged') . '<br />'); sleep(REFRESHSPECIAL_SLAVE_LAG_SLEEP); } $t2 = explode(' ', microtime()); $elapsed_total = $t2[0] - $t1[0] + ($t2[1] - $t1[1]); $total['total_elapsed'] += $elapsed + $elapsed_total; } else { $wgOut->addHTML(wfMsg('refreshspecial-skipped') . '<br />'); } } } /* display all stats */ $elapsed_message = ''; $total_elapsed_message = ''; $this->formatTimeMessage($this->computeTime($total['elapsed']), $elapsed_message); $this->formatTimeMessage($this->computeTime($total['total_elapsed']), $total_elapsed_message); $wgOut->addHTML('<br />' . wfMsgExt('refreshspecial-total-display', array('escape', 'parsemag'), $total['pages'], $total['rows'], $elapsed_message, $total_elapsed_message)); $wgOut->addHTML('</ul></form>'); }
protected function feedTitle() { global $wgContLanguageCode, $wgSitename; $page = SpecialPage::getPage('Contributions'); $desc = $page->getDescription(); return "{$wgSitename} - {$desc} [{$wgContLanguageCode}]"; }
/** * 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 a title object * @param $including output is being captured for use in {{special:whatever}} */ static function executePath(&$title, $including = false) { global $wgOut, $wgTitle; $fname = 'SpecialPage::executePath'; wfProfileIn($fname); $bits = split("/", $title->getDBkey(), 2); $name = $bits[0]; if (!isset($bits[1])) { // bug 2087 $par = NULL; } else { $par = $bits[1]; } $page = SpecialPage::getPage($name); if (is_null($page)) { if ($including) { wfProfileOut($fname); return false; } else { $redir = SpecialPage::getRedirect($name); if (isset($redir)) { if ($par) { $redir = Title::makeTitle($redir->getNamespace(), $redir->getText() . '/' . $par); } $params = SpecialPage::getRedirectParams($name); if ($params) { $url = $redir->getFullUrl($params); } else { $url = $redir->getFullUrl(); } $wgOut->redirect($url); $retVal = $redir; $wgOut->redirect($url); $retVal = $redir; } else { $wgOut->setArticleRelated(false); $wgOut->setRobotpolicy('noindex,nofollow'); $wgOut->setStatusCode(404); $wgOut->showErrorPage('nosuchspecialpage', 'nospecialpagetext'); $retVal = false; } } } else { if ($including && !$page->includable()) { wfProfileOut($fname); return false; } elseif (!$including) { if ($par !== NULL) { $wgTitle = Title::makeTitle(NS_SPECIAL, $name); } else { $wgTitle = $title; } } $page->including($including); $profName = 'Special:' . $page->getName(); wfProfileIn($profName); $page->execute($par); wfProfileOut($profName); $retVal = true; } wfProfileOut($fname); return $retVal; }
/** * 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 a title object * @param $including output is being captured for use in {{special:whatever}} */ function executePath(&$title, $including = false) { global $wgSpecialPages, $wgOut, $wgTitle; $bits = split("/", $title->getDBkey(), 2); $name = $bits[0]; if (!isset($bits[1])) { // bug 2087 $par = NULL; } else { $par = $bits[1]; } $page =& SpecialPage::getPage($name); if (is_null($page)) { if ($including) { return false; } else { $redir =& SpecialPage::getRedirect($name); if (isset($redir)) { if (isset($par)) { $wgOut->redirect($redir->getFullURL() . '/' . $par); } else { $wgOut->redirect($redir->getFullURL()); } $retVal = $redir; } else { $wgOut->setArticleRelated(false); $wgOut->setRobotpolicy("noindex,follow"); $wgOut->errorpage("nosuchspecialpage", "nospecialpagetext"); $retVal = false; } } } else { if ($including && !$page->includable()) { return false; } if ($par !== NULL) { $wgTitle = Title::makeTitle(NS_SPECIAL, $name); } else { $wgTitle = $title; } $page->including($including); $page->execute($par); $retVal = true; } return $retVal; }
public function execute() { global $IP, $wgOut, $wgSpecialPageCacheUpdates, $wgQueryPages, $wgQueryCacheLimit, $wgDisableQueryPageUpdate; $wgOut->disable(); $dbw = wfGetDB(DB_MASTER); foreach ($wgSpecialPageCacheUpdates as $special => $call) { if (!is_callable($call)) { $this->error("Uncallable function {$call}!"); continue; } $t1 = explode(' ', microtime()); call_user_func($call, $dbw); $t2 = explode(' ', microtime()); $this->output(sprintf('%-30s ', $special)); $elapsed = $t2[0] - $t1[0] + ($t2[1] - $t1[1]); $hours = intval($elapsed / 3600); $minutes = intval($elapsed % 3600 / 60); $seconds = $elapsed - $hours * 3600 - $minutes * 60; if ($hours) { $this->output($hours . 'h '); } if ($minutes) { $this->output($minutes . 'm '); } $this->output(sprintf("completed in %.2fs\n", $seconds)); # Wait for the slave to catch up wfWaitForSlaves(5); } // This is needed to initialise $wgQueryPages require_once "{$IP}/includes/QueryPage.php"; foreach ($wgQueryPages as $page) { @(list($class, $special, $limit) = $page); # --list : just show the name of pages if ($this->hasOption('list')) { $this->output("{$special}\n"); continue; } if (!$this->hasOption('override') && $wgDisableQueryPageUpdate && in_array($special, $wgDisableQueryPageUpdate)) { $this->output(sprintf("%-30s disabled\n", $special)); continue; } $specialObj = SpecialPage::getPage($special); if (!$specialObj) { $this->output("No such special page: {$special}\n"); exit; } if (!class_exists($class)) { $file = $specialObj->getFile(); require_once $file; } $queryPage = new $class(); if (!$this->hasOption('only') || $this->getOption('only') == $queryPage->getName()) { $this->output(sprintf('%-30s ', $special)); if ($queryPage->isExpensive()) { $t1 = explode(' ', microtime()); # Do the query $num = $queryPage->recache($limit === null ? $wgQueryCacheLimit : $limit); $t2 = explode(' ', microtime()); if ($num === false) { $this->output("FAILED: database error\n"); } else { $this->output("got {$num} rows in "); $elapsed = $t2[0] - $t1[0] + ($t2[1] - $t1[1]); $hours = intval($elapsed / 3600); $minutes = intval($elapsed % 3600 / 60); $seconds = $elapsed - $hours * 3600 - $minutes * 60; if ($hours) { $this->output($hours . 'h '); } if ($minutes) { $this->output($minutes . 'm '); } $this->output(sprintf("%.2fs\n", $seconds)); } # Reopen any connections that have closed if (!wfGetLB()->pingAll()) { $this->output("\n"); do { $this->error("Connection failed, reconnecting in 10 seconds..."); sleep(10); } while (!wfGetLB()->pingAll()); $this->output("Reconnected\n\n"); } else { # Commit the results $dbw->commit(); } # Wait for the slave to catch up wfWaitForSlaves(5); } else { $this->output("cheap, skipped\n"); } } } }
/** * What we should do if the permission action is clicked. * @param OutputPage $output * @param Article $article * @param Title $title * @param User $user * @param WebRequest $request * @Param MediaWiki $wiki */ static function displayACLForm($output, $article, $title, $user, $request, $wiki) { global $wgParser; if ($request->getVal('action') != self::$ACTION) { return true; } $text = ""; $owner = MWUtil::pageOwner($title, true); $text .= "Page owner is '''" . $owner->getName() . "'''."; ACL::loadUserGroups(); $ownergroups = ACL::getUserGroups($owner); $ogroups = " Owner belongs to these user groups:"; if ($ownergroups) { foreach ($ownergroups as $g) { $ogroups .= $g['name'] . ","; } } else { $ogroups = " Owner does not belong to any user group"; } $text .= $ogroups . "\n\n"; $permissionpage = ACL_ACL . ":" . $article->getID(); $permissiontitle = Title::newFromText($permissionpage); $ns = $title->getNSText(); if (!$ns) { $ns = "Main"; } $sp = SpecialPage::getPage("FormEdit"); $sp_url = $sp->getTitle()->getLocalURL(); $sp_url .= "?form=" . self::$FORM . "&target={$permissionpage}&ACL Page Permission[PageId]={$article->getID()}&ACL Page Permission[PageName]={$title->getDBkey()}&ACL Page Permission[Namespace]={$ns}"; if ($permissiontitle->exists()) { $text .= "[[{$permissionpage}|View Page Permission]]\n\n----\n"; $output->addWikiText($text); $output->addHTML("<a href='{$sp_url}'>Edit permission for this page</a>"); } else { $text .= "No page specific Permission is set."; $output->addWikiText($text); $output->addHTML("<a href='{$sp_url}'>Set permission for this page</a>"); } return false; }
static function newFromSpecialPage($page_name) { $item = new ALItem(); $item->label = $page_name; $page = SpecialPage::getPage($page_name); global $wgUser; $item->text = $wgUser->getSkin()->linkKnown($page->getTitle(), $page->getDescription()); return $item; }