本文整理汇总了PHP中Action::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP Action::factory方法的具体用法?PHP Action::factory怎么用?PHP Action::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Action
的用法示例。
在下文中一共展示了Action::factory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: performAction
/**
* Perform one of the "standard" actions
*
* @param Page $page
* @param Title $requestTitle The original title, before any redirects were applied
*/
private function performAction(Page $page, Title $requestTitle)
{
$request = $this->context->getRequest();
$output = $this->context->getOutput();
$title = $this->context->getTitle();
$user = $this->context->getUser();
if (!Hooks::run('MediaWikiPerformAction', array($output, $page, $title, $user, $request, $this))) {
return;
}
$act = $this->getAction();
$action = Action::factory($act, $page, $this->context);
if ($action instanceof Action) {
# Let CDN cache things if we can purge them.
if ($this->config->get('UseSquid') && in_array(wfExpandUrl($request->getRequestURL(), PROTO_INTERNAL), $requestTitle->getCdnUrls())) {
$output->setCdnMaxage($this->config->get('SquidMaxage'));
}
$action->show();
return;
}
if (Hooks::run('UnknownAction', array($request->getVal('action', 'view'), $page))) {
$output->setStatusCode(404);
$output->showErrorPage('nosuchaction', 'nosuchactiontext');
}
}
示例2: performAction
/**
* Perform one of the "standard" actions
*
* @param Page $page
* @param Title $requestTitle The original title, before any redirects were applied
*/
private function performAction(Page $page, Title $requestTitle)
{
$request = $this->context->getRequest();
$output = $this->context->getOutput();
$title = $this->context->getTitle();
$user = $this->context->getUser();
if (!Hooks::run('MediaWikiPerformAction', [$output, $page, $title, $user, $request, $this])) {
return;
}
$act = $this->getAction();
$action = Action::factory($act, $page, $this->context);
if ($action instanceof Action) {
// Narrow DB query expectations for this HTTP request
$trxLimits = $this->config->get('TrxProfilerLimits');
$trxProfiler = Profiler::instance()->getTransactionProfiler();
if ($request->wasPosted() && !$action->doesWrites()) {
$trxProfiler->setExpectations($trxLimits['POST-nonwrite'], __METHOD__);
$request->markAsSafeRequest();
}
# Let CDN cache things if we can purge them.
if ($this->config->get('UseSquid') && in_array(wfExpandUrl($request->getRequestURL(), PROTO_INTERNAL), $requestTitle->getCdnUrls())) {
$output->setCdnMaxage($this->config->get('SquidMaxage'));
}
$action->show();
return;
}
if (Hooks::run('UnknownAction', [$request->getVal('action', 'view'), $page])) {
$output->setStatusCode(404);
$output->showErrorPage('nosuchaction', 'nosuchactiontext');
}
}
示例3: testDisabledAction_factoryReturnsFalse
public function testDisabledAction_factoryReturnsFalse()
{
$page = $this->getPage();
$action = Action::factory('disabled', $page);
$this->assertFalse($action);
}
示例4: outputPage
//.........这里部分代码省略.........
if ($userlang !== $wgContLang->getHtmlCode() || $userdir !== $wgContLang->getDir()) {
$escUserlang = htmlspecialchars($userlang);
$escUserdir = htmlspecialchars($userdir);
// Attributes must be in double quotes because htmlspecialchars() doesn't
// escape single quotes
$attrs = " lang=\"{$escUserlang}\" dir=\"{$escUserdir}\"";
$tpl->set('userlangattributes', $attrs);
}
wfProfileOut(__METHOD__ . '-stuff2');
wfProfileIn(__METHOD__ . '-stuff3');
$tpl->set('newtalk', $this->getNewtalks());
$tpl->set('logo', $this->logoText());
$tpl->set('copyright', false);
$tpl->set('viewcount', false);
$tpl->set('lastmod', false);
$tpl->set('credits', false);
$tpl->set('numberofwatchingusers', false);
if ($out->isArticle() && $title->exists()) {
if ($this->isRevisionCurrent()) {
if (!$wgDisableCounters) {
$viewcount = $this->getWikiPage()->getCount();
if ($viewcount) {
$tpl->set('viewcount', $this->msg('viewcount')->numParams($viewcount)->parse());
}
}
if ($wgPageShowWatchingUsers) {
$dbr = wfGetDB(DB_SLAVE);
$num = $dbr->selectField('watchlist', 'COUNT(*)', array('wl_title' => $title->getDBkey(), 'wl_namespace' => $title->getNamespace()), __METHOD__);
if ($num > 0) {
$tpl->set('numberofwatchingusers', $this->msg('number_of_watching_users_pageview')->numParams($num)->parse());
}
}
if ($wgMaxCredits != 0) {
$tpl->set('credits', Action::factory('credits', $this->getWikiPage(), $this->getContext())->getCredits($wgMaxCredits, $wgShowCreditsIfMax));
} else {
$tpl->set('lastmod', $this->lastModified());
}
}
$tpl->set('copyright', $this->getCopyright());
}
wfProfileOut(__METHOD__ . '-stuff3');
wfProfileIn(__METHOD__ . '-stuff4');
$tpl->set('copyrightico', $this->getCopyrightIcon());
$tpl->set('poweredbyico', $this->getPoweredBy());
$tpl->set('disclaimer', $this->disclaimerLink());
$tpl->set('privacy', $this->privacyLink());
$tpl->set('about', $this->aboutLink());
$tpl->set('footerlinks', array('info' => array('lastmod', 'viewcount', 'numberofwatchingusers', 'credits', 'copyright'), 'places' => array('privacy', 'about', 'disclaimer')));
global $wgFooterIcons;
$tpl->set('footericons', $wgFooterIcons);
foreach ($tpl->data['footericons'] as $footerIconsKey => &$footerIconsBlock) {
if (count($footerIconsBlock) > 0) {
foreach ($footerIconsBlock as &$footerIcon) {
if (isset($footerIcon['src'])) {
if (!isset($footerIcon['width'])) {
$footerIcon['width'] = 88;
}
if (!isset($footerIcon['height'])) {
$footerIcon['height'] = 31;
}
}
}
} else {
unset($tpl->data['footericons'][$footerIconsKey]);
}
}
示例5: run
/**
* Run a replaceText job
* @return boolean success
*/
function run()
{
wfProfileIn(__METHOD__);
if (is_null($this->title)) {
$this->error = "replaceText: Invalid title";
wfProfileOut(__METHOD__);
return false;
}
if (array_key_exists('move_page', $this->params)) {
global $wgUser;
$actual_user = $wgUser;
$wgUser = User::newFromId($this->params['user_id']);
$cur_page_name = $this->title->getText();
if ($this->params['use_regex']) {
$new_page_name = preg_replace("/" . $this->params['target_str'] . "/U", $this->params['replacement_str'], $cur_page_name);
} else {
$new_page_name = str_replace($this->params['target_str'], $this->params['replacement_str'], $cur_page_name);
}
$new_title = Title::newFromText($new_page_name, $this->title->getNamespace());
$reason = $this->params['edit_summary'];
$create_redirect = $this->params['create_redirect'];
$this->title->moveTo($new_title, true, $reason, $create_redirect);
if ($this->params['watch_page']) {
if (class_exists('WatchAction')) {
// Class was added in MW 1.19
WatchAction::doWatch($new_title, $wgUser);
} else {
Action::factory('watch', new WikiPage($new_title))->execute();
}
}
$wgUser = $actual_user;
} else {
// WikiPage::getContent() replaced
// Article::fetchContent() starting in MW 1.21.
if (method_exists('WikiPage', 'getContent')) {
if ($this->title->getContentModel() !== CONTENT_MODEL_WIKITEXT) {
$this->error = 'replaceText: Wiki page "' . $this->title->getPrefixedDBkey() . '" does not hold regular wikitext.';
wfProfileOut(__METHOD__);
return false;
}
$wikiPage = new WikiPage($this->title);
// Is this check necessary?
if (!$wikiPage) {
$this->error = 'replaceText: Wiki page not found for "' . $this->title->getPrefixedDBkey() . '."';
wfProfileOut(__METHOD__);
return false;
}
$article_text = $wikiPage->getContent()->getNativeData();
} else {
$article = new Article($this->title, 0);
if (!$article) {
$this->error = 'replaceText: Article not found for "' . $this->title->getPrefixedDBkey() . '"';
wfProfileOut(__METHOD__);
return false;
}
$article_text = $article->fetchContent();
}
wfProfileIn(__METHOD__ . '-replace');
$target_str = $this->params['target_str'];
$replacement_str = $this->params['replacement_str'];
// @todo FIXME eh?
$num_matches;
if ($this->params['use_regex']) {
$new_text = preg_replace('/' . $target_str . '/U', $replacement_str, $article_text, -1, $num_matches);
} else {
$new_text = str_replace($target_str, $replacement_str, $article_text, $num_matches);
}
// If there's at least one replacement, modify the page,
// using the passed-in edit summary.
if ($num_matches > 0) {
// Change global $wgUser variable to the one
// specified by the job only for the extent of
// this replacement.
global $wgUser;
$actual_user = $wgUser;
$wgUser = User::newFromId($this->params['user_id']);
$edit_summary = $this->params['edit_summary'];
$flags = EDIT_MINOR;
if ($wgUser->isAllowed('bot')) {
$flags |= EDIT_FORCE_BOT;
}
if (method_exists('WikiPage', 'getContent')) {
$new_content = new WikitextContent($new_text);
$wikiPage->doEditContent($new_content, $edit_summary, $flags);
} else {
$article->doEdit($new_text, $edit_summary, $flags);
}
$wgUser = $actual_user;
}
wfProfileOut(__METHOD__ . '-replace');
}
wfProfileOut(__METHOD__);
return true;
}
示例6: rollback
/**
* Handle action=rollback
* @deprecated since 1.19
*/
public function rollback()
{
wfDeprecated(__METHOD__, '1.19');
Action::factory('rollback', $this)->show();
}
示例7: performAction
/**
* Perform one of the "standard" actions
*
* @param $page Page
*/
private function performAction(Page $page)
{
wfProfileIn(__METHOD__);
$request = $this->context->getRequest();
$output = $this->context->getOutput();
$title = $this->context->getTitle();
$user = $this->context->getUser();
if (!wfRunHooks('MediaWikiPerformAction', array($output, $page, $title, $user, $request, $this))) {
wfProfileOut(__METHOD__);
return;
}
$act = $this->getAction();
$action = Action::factory($act, $page);
if ($action instanceof Action) {
$action->show();
wfProfileOut(__METHOD__);
return;
}
if (wfRunHooks('UnknownAction', array($request->getVal('action', 'view'), $page))) {
$output->showErrorPage('nosuchaction', 'nosuchactiontext');
}
wfProfileOut(__METHOD__);
}
示例8: prepareQuickTemplate
//.........这里部分代码省略.........
// showjumplinks preference has been removed
$tpl->set('username', $this->loggedin ? $this->username : null);
$tpl->setRef('userpage', $this->userpage);
$tpl->setRef('userpageurl', $this->userpageUrlDetails['href']);
$tpl->set('userlang', $userLangCode);
// Users can have their language set differently than the
// content of the wiki. For these users, tell the web browser
// that interface elements are in a different language.
$tpl->set('userlangattributes', '');
$tpl->set('specialpageattributes', '');
# obsolete
// Used by VectorBeta to insert HTML before content but after the
// heading for the page title. Defaults to empty string.
$tpl->set('prebodyhtml', '');
if ($userLangCode !== $wgContLang->getHtmlCode() || $userLangDir !== $wgContLang->getDir()) {
$escUserlang = htmlspecialchars($userLangCode);
$escUserdir = htmlspecialchars($userLangDir);
// Attributes must be in double quotes because htmlspecialchars() doesn't
// escape single quotes
$attrs = " lang=\"{$escUserlang}\" dir=\"{$escUserdir}\"";
$tpl->set('userlangattributes', $attrs);
}
$tpl->set('newtalk', $this->getNewtalks());
$tpl->set('logo', $this->logoText());
$tpl->set('copyright', false);
// No longer used
$tpl->set('viewcount', false);
$tpl->set('lastmod', false);
$tpl->set('credits', false);
$tpl->set('numberofwatchingusers', false);
if ($out->isArticle() && $title->exists()) {
if ($this->isRevisionCurrent()) {
if ($wgMaxCredits != 0) {
$tpl->set('credits', Action::factory('credits', $this->getWikiPage(), $this->getContext())->getCredits($wgMaxCredits, $wgShowCreditsIfMax));
} else {
$tpl->set('lastmod', $this->lastModified());
}
}
$tpl->set('copyright', $this->getCopyright());
}
$tpl->set('copyrightico', $this->getCopyrightIcon());
$tpl->set('poweredbyico', $this->getPoweredBy());
$tpl->set('disclaimer', $this->disclaimerLink());
$tpl->set('privacy', $this->privacyLink());
$tpl->set('about', $this->aboutLink());
$tpl->set('footerlinks', array('info' => array('lastmod', 'numberofwatchingusers', 'credits', 'copyright'), 'places' => array('privacy', 'about', 'disclaimer')));
global $wgFooterIcons;
$tpl->set('footericons', $wgFooterIcons);
foreach ($tpl->data['footericons'] as $footerIconsKey => &$footerIconsBlock) {
if (count($footerIconsBlock) > 0) {
foreach ($footerIconsBlock as &$footerIcon) {
if (isset($footerIcon['src'])) {
if (!isset($footerIcon['width'])) {
$footerIcon['width'] = 88;
}
if (!isset($footerIcon['height'])) {
$footerIcon['height'] = 31;
}
}
}
} else {
unset($tpl->data['footericons'][$footerIconsKey]);
}
}
$tpl->set('indicators', $out->getIndicators());
$tpl->set('sitenotice', $this->getSiteNotice());
示例9: performAction
/**
* Perform one of the "standard" actions
*
* @param $article Article
*/
private function performAction(Page $article)
{
global $wgSquidMaxage, $wgUseExternalEditor;
wfProfileIn(__METHOD__);
$request = $this->context->getRequest();
$output = $this->context->getOutput();
$title = $this->context->getTitle();
$user = $this->context->getUser();
if (!wfRunHooks('MediaWikiPerformAction', array($output, $article, $title, $user, $request, $this))) {
wfProfileOut(__METHOD__);
return;
}
$act = $this->getAction();
$action = Action::factory($act, $article);
if ($action instanceof Action) {
$action->show();
wfProfileOut(__METHOD__);
return;
}
switch ($act) {
case 'view':
$output->setSquidMaxage($wgSquidMaxage);
$article->view();
break;
case 'raw':
// includes JS/CSS
wfProfileIn(__METHOD__ . '-raw');
$raw = new RawPage($article);
$raw->view();
wfProfileOut(__METHOD__ . '-raw');
break;
case 'delete':
case 'protect':
case 'unprotect':
case 'render':
$article->{$act}();
break;
case 'submit':
if (session_id() == '') {
// Send a cookie so anons get talk message notifications
wfSetupSession();
}
// Continue...
// Continue...
case 'edit':
if (wfRunHooks('CustomEditor', array($article, $user))) {
$internal = $request->getVal('internaledit');
$external = $request->getVal('externaledit');
$section = $request->getVal('section');
$oldid = $request->getVal('oldid');
if (!$wgUseExternalEditor || $act == 'submit' || $internal || $section || $oldid || !$user->getOption('externaleditor') && !$external) {
$editor = new EditPage($article);
$editor->submit();
} elseif ($wgUseExternalEditor && ($external || $user->getOption('externaleditor'))) {
$mode = $request->getVal('mode');
$extedit = new ExternalEdit($article->getTitle(), $mode);
$extedit->edit();
}
}
break;
case 'history':
if ($request->getFullRequestURL() == $title->getInternalURL('action=history')) {
$output->setSquidMaxage($wgSquidMaxage);
}
$history = new HistoryPage($article);
$history->history();
break;
default:
if (wfRunHooks('UnknownAction', array($act, $article))) {
$output->showErrorPage('nosuchaction', 'nosuchactiontext');
}
}
wfProfileOut(__METHOD__);
}
示例10: execute
function execute($par)
{
global $wgUser, $wgOut, $wgRequest, $wgTitle;
if ($wgUser->isBlocked()) {
$wgOut->blockedPage();
return;
}
if (!($wgUser->isSysop() || in_array('newarticlepatrol', $wgUser->getRights()))) {
$wgOut->setRobotpolicy('noindex,nofollow');
$wgOut->showErrorPage('nosuchspecialpage', 'nospecialpagetext');
return;
}
wfLoadExtensionMessages("NFDGuardian");
if ($wgRequest->getVal('fetchInnards')) {
//get next article to vote on
$wgOut->disable();
$result = self::getNextInnards($wgRequest->getVal('nfd_type'));
print_r(json_encode($result));
return;
} else {
if ($wgRequest->getVal('getVoteBlock')) {
//get all the votes for the right rail module
$wgOut->setArticleBodyOnly(true);
$wgOut->addHTML(self::getVoteBlock($wgRequest->getVal('nfd_id')));
return;
} else {
if ($wgRequest->getVal('edit')) {
//get the html that goes into the page when a user clicks the edit tab
$wgOut->setArticleBodyOnly(true);
$t = Title::newFromID($wgRequest->getVal('articleId'));
if ($t) {
$a = new Article($t);
$editor = new EditPage($a);
$editor->edit();
//Old code for when we wanted to remove
//the nfd template from the edit window
/*$content = $wgOut->getHTML();
$wgOut->clearHTML();
//grab the edit form
$data = array();
$data['form'] = $content;
//then take out the template
$c = new NFDProcessor();
$template = $c->getFullTemplate($wgRequest->getVal('nfd_id'));
$articleContent = $a->getContent();
$articleContent = str_replace($template, "", $articleContent);
$data['newContent'] = $articleContent;
print_r(json_encode($data));*/
}
return;
} else {
if ($wgRequest->getVal('discussion')) {
//get the html that goes into the page when a user clicks the discussion tab
$wgOut->setArticleBodyOnly(true);
$t = Title::newFromID($wgRequest->getVal('articleId'));
if ($t) {
$tDiscussion = $t->getTalkPage();
if ($tDiscussion) {
$a = new Article($tDiscussion);
$content = $a->getContent();
$wgOldTitle = $wgTitle;
$wgTitle = $tDiscussion;
$wgOut->addHTML($wgOut->parse($content));
$wgOut->addHTML(PostComment::getForm(true, $tDiscussion, true));
$wgTitle = $wgOldTitle;
}
}
return;
} else {
if ($wgRequest->getVal('confirmation')) {
//get confirmation dialog after user has edited the article
$wgOut->setArticleBodyOnly(true);
echo $this->confirmationModal($wgRequest->getVal('articleId'));
return;
} else {
if ($wgRequest->getVal('history')) {
//get the html that goes into the page when a user clicks the history tab
$wgOut->setArticleBodyOnly(true);
$t = Title::newFromID($wgRequest->getVal('articleId'));
if ($t) {
$historyContext = clone $this->getContext();
$historyContext->setTitle($t);
$historyContext->setWikiPage(WikiPage::factory($t));
$pageHistory = Action::factory("history", WikiPage::factory($t), $historyContext);
$pageHistory->onView();
return;
}
} else {
if ($wgRequest->getVal('diff')) {
//get the html that goes into the page when a user asks for a diffs
$wgOut->setArticleBodyOnly(true);
$t = Title::newFromID($wgRequest->getVal('articleId'));
if ($t) {
$a = new Article($t);
$wgOut->addHtml('<div class="article_inner">');
$a->view();
$wgOut->addHtml('</div>');
}
//.........这里部分代码省略.........
示例11: pageStats
function pageStats()
{
global $wgOut, $wgLang, $wgRequest, $wgUser;
global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgPageShowWatchingUsers;
if (!is_null($wgRequest->getVal('oldid')) || !is_null($wgRequest->getVal('diff'))) {
return '';
}
if (!$wgOut->isArticle() || !$this->getSkin()->getTitle()->exists()) {
return '';
}
$article = new Article($this->getSkin()->getTitle(), 0);
$s = '';
if (!$wgDisableCounters) {
$count = $wgLang->formatNum($article->getCount());
if ($count) {
$s = wfMsgExt('viewcount', array('parseinline'), $count);
}
}
if ($wgMaxCredits != 0) {
$s .= ' ' . Action::factory('credits', $article)->getCredits($wgMaxCredits, $wgShowCreditsIfMax);
} else {
$s .= $this->data['lastmod'];
}
if ($wgPageShowWatchingUsers && $wgUser->getOption('shownumberswatching')) {
$dbr = wfGetDB(DB_SLAVE);
$res = $dbr->select('watchlist', array('COUNT(*) AS n'), array('wl_title' => $dbr->strencode($this->getSkin()->getTitle()->getDBkey()), 'wl_namespace' => $this->getSkin()->getTitle()->getNamespace()), __METHOD__);
$x = $dbr->fetchObject($res);
$s .= ' ' . wfMsgExt('number_of_watching_users_pageview', array('parseinline'), $wgLang->formatNum($x->n));
}
return $s . ' ' . $this->getSkin()->getCopyright();
}
示例12: execute
public function execute()
{
global $wgRequestTime;
if (!$this->enabled) {
$this->error("Nothing to do -- \$wgUseFileCache is disabled.", true);
}
$start = $this->getOption('start', "0");
if (!ctype_digit($start)) {
$this->error("Invalid value for start parameter.", true);
}
$start = intval($start);
$end = $this->getOption('end', "0");
if (!ctype_digit($end)) {
$this->error("Invalid value for end parameter.", true);
}
$end = intval($end);
$this->output("Building content page file cache from page {$start}!\n");
$dbr = $this->getDB(DB_REPLICA);
$overwrite = $this->getOption('overwrite', false);
$start = $start > 0 ? $start : $dbr->selectField('page', 'MIN(page_id)', false, __METHOD__);
$end = $end > 0 ? $end : $dbr->selectField('page', 'MAX(page_id)', false, __METHOD__);
if (!$start) {
$this->error("Nothing to do.", true);
}
$_SERVER['HTTP_ACCEPT_ENCODING'] = 'bgzip';
// hack, no real client
# Do remaining chunk
$end += $this->mBatchSize - 1;
$blockStart = $start;
$blockEnd = $start + $this->mBatchSize - 1;
$dbw = $this->getDB(DB_MASTER);
// Go through each page and save the output
while ($blockEnd <= $end) {
// Get the pages
$res = $dbr->select('page', ['page_namespace', 'page_title', 'page_id'], ['page_namespace' => MWNamespace::getContentNamespaces(), "page_id BETWEEN {$blockStart} AND {$blockEnd}"], __METHOD__, ['ORDER BY' => 'page_id ASC', 'USE INDEX' => 'PRIMARY']);
$this->beginTransaction($dbw, __METHOD__);
// for any changes
foreach ($res as $row) {
$rebuilt = false;
$title = Title::makeTitleSafe($row->page_namespace, $row->page_title);
if (null == $title) {
$this->output("Page {$row->page_id} has bad title\n");
continue;
// broken title?
}
$context = new RequestContext();
$context->setTitle($title);
$article = Article::newFromTitle($title, $context);
$context->setWikiPage($article->getPage());
// If the article is cacheable, then load it
if ($article->isFileCacheable(HTMLFileCache::MODE_REBUILD)) {
$viewCache = new HTMLFileCache($title, 'view');
$historyCache = new HTMLFileCache($title, 'history');
if ($viewCache->isCacheGood() && $historyCache->isCacheGood()) {
if ($overwrite) {
$rebuilt = true;
} else {
$this->output("Page '{$title}' (id {$row->page_id}) already cached\n");
continue;
// done already!
}
}
MediaWiki\suppressWarnings();
// header notices
// Cache ?action=view
$wgRequestTime = microtime(true);
# bug 22852
ob_start();
$article->view();
$context->getOutput()->output();
$context->getOutput()->clearHTML();
$viewHtml = ob_get_clean();
$viewCache->saveToFileCache($viewHtml);
// Cache ?action=history
$wgRequestTime = microtime(true);
# bug 22852
ob_start();
Action::factory('history', $article, $context)->show();
$context->getOutput()->output();
$context->getOutput()->clearHTML();
$historyHtml = ob_get_clean();
$historyCache->saveToFileCache($historyHtml);
MediaWiki\restoreWarnings();
if ($rebuilt) {
$this->output("Re-cached page '{$title}' (id {$row->page_id})...");
} else {
$this->output("Cached page '{$title}' (id {$row->page_id})...");
}
$this->output("[view: " . strlen($viewHtml) . " bytes; " . "history: " . strlen($historyHtml) . " bytes]\n");
} else {
$this->output("Page '{$title}' (id {$row->page_id}) not cacheable\n");
}
}
$this->commitTransaction($dbw, __METHOD__);
// commit any changes (just for sanity)
$blockStart += $this->mBatchSize;
$blockEnd += $this->mBatchSize;
}
$this->output("Done!\n");
}
示例13: setAttributes
public function setAttributes($attributes)
{
foreach ($this->methodActions as $method => &$actions) {
foreach ($actions as &$action) {
$action = Action::factory($action, $attributes);
}
}
return $this;
}
示例14: 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';
}
示例15: run
/**
* Run a replaceText job
* @return boolean success
*/
function run() {
wfProfileIn( __METHOD__ );
if ( is_null( $this->title ) ) {
$this->error = "replaceText: Invalid title";
wfProfileOut( __METHOD__ );
return false;
}
if ( array_key_exists( 'move_page', $this->params ) ) {
global $wgUser;
$actual_user = $wgUser;
$wgUser = User::newFromId( $this->params['user_id'] );
$cur_page_name = $this->title->getText();
if ( $this->params['use_regex'] ) {
$new_page_name = preg_replace( "/".$this->params['target_str']."/U", $this->params['replacement_str'], $cur_page_name );
} else {
$new_page_name = str_replace( $this->params['target_str'], $this->params['replacement_str'], $cur_page_name );
}
$new_title = Title::newFromText( $new_page_name, $this->title->getNamespace() );
$reason = $this->params['edit_summary'];
$create_redirect = $this->params['create_redirect'];
$this->title->moveTo( $new_title, true, $reason, $create_redirect );
if ( $this->params['watch_page'] ) {
if ( class_exists( 'WatchAction' ) ) {
// Class was added in MW 1.19
WatchAction::doWatch( $new_title, $wgUser );
} elseif ( class_exists( 'Action' ) ) {
// Class was added in MW 1.18
Action::factory( 'watch', new Article( $new_title, 0 ) )->execute();
} else {
$article = new Article( $new_title, 0 );
$article->doWatch();
}
}
$wgUser = $actual_user;
} else {
$article = new Article( $this->title, 0 );
if ( !$article ) {
$this->error = 'replaceText: Article not found "' . $this->title->getPrefixedDBkey() . '"';
wfProfileOut( __METHOD__ );
return false;
}
wfProfileIn( __METHOD__ . '-replace' );
$article_text = $article->fetchContent();
$target_str = $this->params['target_str'];
$replacement_str = $this->params['replacement_str'];
$num_matches;
if ( $this->params['use_regex'] ) {
$new_text = preg_replace( '/'.$target_str.'/U', $replacement_str, $article_text, -1, $num_matches );
} else {
$new_text = str_replace( $target_str, $replacement_str, $article_text, $num_matches );
}
// if there's at least one replacement, modify the page,
// using the passed-in edit summary
if ( $num_matches > 0 ) {
// change global $wgUser variable to the one
// specified by the job only for the extent of
// this replacement
global $wgUser;
$actual_user = $wgUser;
$wgUser = User::newFromId( $this->params['user_id'] );
$edit_summary = $this->params['edit_summary'];
$flags = EDIT_MINOR;
if ( $wgUser->isAllowed( 'bot' ) )
$flags |= EDIT_FORCE_BOT;
$article->doEdit( $new_text, $edit_summary, $flags );
$wgUser = $actual_user;
}
wfProfileOut( __METHOD__ . '-replace' );
}
wfProfileOut( __METHOD__ );
return true;
}