/** * This is the default action of the index.php entry point: just view the * page of the given title. */ public function view() { global $wgUseFileCache, $wgUseETag, $wgDebugToolbar, $wgMaxRedirects; # Get variables from query string # As side effect this will load the revision and update the title # in a revision ID is passed in the request, so this should remain # the first call of this method even if $oldid is used way below. $oldid = $this->getOldID(); $user = $this->getContext()->getUser(); # Another whitelist check in case getOldID() is altering the title $permErrors = $this->getTitle()->getUserPermissionsErrors('read', $user); if (count($permErrors)) { wfDebug(__METHOD__ . ": denied on secondary read check\n"); throw new PermissionsError('read', $permErrors); } $outputPage = $this->getContext()->getOutput(); # getOldID() may as well want us to redirect somewhere else if ($this->mRedirectUrl) { $outputPage->redirect($this->mRedirectUrl); wfDebug(__METHOD__ . ": redirecting due to oldid\n"); return; } # If we got diff in the query, we want to see a diff page instead of the article. if ($this->getContext()->getRequest()->getCheck('diff')) { wfDebug(__METHOD__ . ": showing diff page\n"); $this->showDiffPage(); return; } # Set page title (may be overridden by DISPLAYTITLE) $outputPage->setPageTitle($this->getTitle()->getPrefixedText()); $outputPage->setArticleFlag(true); # Allow frames by default $outputPage->allowClickjacking(); $parserCache = ParserCache::singleton(); $parserOptions = $this->getParserOptions(); # Render printable version, use printable version cache if ($outputPage->isPrintable()) { $parserOptions->setIsPrintable(true); $parserOptions->setEditSection(false); } elseif (!$this->isCurrent() || !$this->getTitle()->quickUserCan('edit', $user)) { $parserOptions->setEditSection(false); } # Try client and file cache if (!$wgDebugToolbar && $oldid === 0 && $this->mPage->checkTouched()) { if ($wgUseETag) { $outputPage->setETag($parserCache->getETag($this, $parserOptions)); } # Use the greatest of the page's timestamp or the timestamp of any # redirect in the chain (bug 67849) $timestamp = $this->mPage->getTouched(); if (isset($this->mRedirectedFrom)) { $timestamp = max($timestamp, $this->mRedirectedFrom->getTouched()); # If there can be more than one redirect in the chain, we have # to go through the whole chain too in case an intermediate # redirect was changed. if ($wgMaxRedirects > 1) { $titles = Revision::newFromTitle($this->mRedirectedFrom)->getContent(Revision::FOR_THIS_USER, $user)->getRedirectChain(); $thisTitle = $this->getTitle(); foreach ($titles as $title) { if (Title::compare($title, $thisTitle) === 0) { break; } $timestamp = max($timestamp, $title->getTouched()); } } } # Is it client cached? if ($outputPage->checkLastModified($timestamp)) { wfDebug(__METHOD__ . ": done 304\n"); return; # Try file cache } elseif ($wgUseFileCache && $this->tryFileCache()) { wfDebug(__METHOD__ . ": done file cache\n"); # tell wgOut that output is taken care of $outputPage->disable(); $this->mPage->doViewUpdates($user, $oldid); return; } } # Should the parser cache be used? $useParserCache = $this->mPage->shouldCheckParserCache($parserOptions, $oldid); wfDebug('Article::view using parser cache: ' . ($useParserCache ? 'yes' : 'no') . "\n"); if ($user->getStubThreshold()) { $this->getContext()->getStats()->increment('pcache_miss_stub'); } $this->showRedirectedFromHeader(); $this->showNamespaceHeader(); # Iterate through the possible ways of constructing the output text. # Keep going until $outputDone is set, or we run out of things to do. $pass = 0; $outputDone = false; $this->mParserOutput = false; while (!$outputDone && ++$pass) { switch ($pass) { case 1: Hooks::run('ArticleViewHeader', array(&$this, &$outputDone, &$useParserCache)); break; case 2: # Early abort if the page doesn't exist if (!$this->mPage->exists()) { wfDebug(__METHOD__ . ": showing missing article\n"); $this->showMissingArticle(); $this->mPage->doViewUpdates($user); return; } # Try the parser cache if ($useParserCache) { $this->mParserOutput = $parserCache->get($this, $parserOptions); if ($this->mParserOutput !== false) { if ($oldid) { wfDebug(__METHOD__ . ": showing parser cache contents for current rev permalink\n"); $this->setOldSubtitle($oldid); } else { wfDebug(__METHOD__ . ": showing parser cache contents\n"); } $outputPage->addParserOutput($this->mParserOutput); # Ensure that UI elements requiring revision ID have # the correct version information. $outputPage->setRevisionId($this->mPage->getLatest()); # Preload timestamp to avoid a DB hit $cachedTimestamp = $this->mParserOutput->getTimestamp(); if ($cachedTimestamp !== null) { $outputPage->setRevisionTimestamp($cachedTimestamp); $this->mPage->setTimestamp($cachedTimestamp); } $outputDone = true; } } break; case 3: # This will set $this->mRevision if needed $this->fetchContentObject(); # Are we looking at an old revision if ($oldid && $this->mRevision) { $this->setOldSubtitle($oldid); if (!$this->showDeletedRevisionHeader()) { wfDebug(__METHOD__ . ": cannot view deleted revision\n"); return; } } # Ensure that UI elements requiring revision ID have # the correct version information. $outputPage->setRevisionId($this->getRevIdFetched()); # Preload timestamp to avoid a DB hit $outputPage->setRevisionTimestamp($this->getTimestamp()); # Pages containing custom CSS or JavaScript get special treatment if ($this->getTitle()->isCssOrJsPage() || $this->getTitle()->isCssJsSubpage()) { wfDebug(__METHOD__ . ": showing CSS/JS source\n"); $this->showCssOrJsPage(); $outputDone = true; } elseif (!Hooks::run('ArticleContentViewCustom', array($this->fetchContentObject(), $this->getTitle(), $outputPage))) { # Allow extensions do their own custom view for certain pages $outputDone = true; } elseif (!ContentHandler::runLegacyHooks('ArticleViewCustom', array($this->fetchContentObject(), $this->getTitle(), $outputPage))) { # Allow extensions do their own custom view for certain pages $outputDone = true; } break; case 4: # Run the parse, protected by a pool counter wfDebug(__METHOD__ . ": doing uncached parse\n"); $content = $this->getContentObject(); $poolArticleView = new PoolWorkArticleView($this->getPage(), $parserOptions, $this->getRevIdFetched(), $useParserCache, $content); if (!$poolArticleView->execute()) { $error = $poolArticleView->getError(); if ($error) { $outputPage->clearHTML(); // for release() errors $outputPage->enableClientCache(false); $outputPage->setRobotPolicy('noindex,nofollow'); $errortext = $error->getWikiText(false, 'view-pool-error'); $outputPage->addWikiText('<div class="errorbox">' . $errortext . '</div>'); } # Connection or timeout error return; } $this->mParserOutput = $poolArticleView->getParserOutput(); $outputPage->addParserOutput($this->mParserOutput); if ($content->getRedirectTarget()) { $outputPage->addSubtitle("<span id=\"redirectsub\">" . $this->getContext()->msg('redirectpagesub')->parse() . "</span>"); } # Don't cache a dirty ParserOutput object if ($poolArticleView->getIsDirty()) { $outputPage->setSquidMaxage(0); $outputPage->addHTML("<!-- parser cache is expired, " . "sending anyway due to pool overload-->\n"); } $outputDone = true; break; # Should be unreachable, but just in case... # Should be unreachable, but just in case... default: break 2; } } # Get the ParserOutput actually *displayed* here. # Note that $this->mParserOutput is the *current*/oldid version output. $pOutput = $outputDone instanceof ParserOutput ? $outputDone : $this->mParserOutput; # Adjust title for main page & pages with displaytitle if ($pOutput) { $this->adjustDisplayTitle($pOutput); } # For the main page, overwrite the <title> element with the con- # tents of 'pagetitle-view-mainpage' instead of the default (if # that's not empty). # This message always exists because it is in the i18n files if ($this->getTitle()->isMainPage()) { $msg = wfMessage('pagetitle-view-mainpage')->inContentLanguage(); if (!$msg->isDisabled()) { $outputPage->setHTMLTitle($msg->title($this->getTitle())->text()); } } # Check for any __NOINDEX__ tags on the page using $pOutput $policy = $this->getRobotPolicy('view', $pOutput); $outputPage->setIndexPolicy($policy['index']); $outputPage->setFollowPolicy($policy['follow']); $this->showViewFooter(); $this->mPage->doViewUpdates($user, $oldid); $outputPage->addModules('mediawiki.action.view.postEdit'); }
public function execute() { $this->params = $this->extractRequestParams(); if (!is_null($this->params['prop'])) { $prop = array_flip($this->params['prop']); $this->fld_protection = isset($prop['protection']); $this->fld_watched = isset($prop['watched']); $this->fld_talkid = isset($prop['talkid']); $this->fld_subjectid = isset($prop['subjectid']); $this->fld_url = isset($prop['url']); $this->fld_readable = isset($prop['readable']); $this->fld_preload = isset($prop['preload']); } $pageSet = $this->getPageSet(); $this->titles = $pageSet->getGoodTitles(); $this->missing = $pageSet->getMissingTitles(); $this->everything = $this->titles + $this->missing; $result = $this->getResult(); uasort($this->everything, array('Title', 'compare')); if (!is_null($this->params['continue'])) { // Throw away any titles we're gonna skip so they don't // clutter queries $cont = explode('|', $this->params['continue']); if (count($cont) != 2) { $this->dieUsage("Invalid continue param. You should pass the original " . "value returned by the previous query", "_badcontinue"); } $conttitle = Title::makeTitleSafe($cont[0], $cont[1]); foreach ($this->everything as $pageid => $title) { if (Title::compare($title, $conttitle) >= 0) { break; } unset($this->titles[$pageid]); unset($this->missing[$pageid]); unset($this->everything[$pageid]); } } $this->pageRestrictions = $pageSet->getCustomField('page_restrictions'); $this->pageIsRedir = $pageSet->getCustomField('page_is_redirect'); $this->pageIsNew = $pageSet->getCustomField('page_is_new'); $this->pageCounter = $pageSet->getCustomField('page_counter'); $this->pageTouched = $pageSet->getCustomField('page_touched'); $this->pageLatest = $pageSet->getCustomField('page_latest'); $this->pageLength = $pageSet->getCustomField('page_len'); $db = $this->getDB(); // Get protection info if requested if ($this->fld_protection) { $this->getProtectionInfo(); } if ($this->fld_watched) { $this->getWatchedInfo(); } // Run the talkid/subjectid query if requested if ($this->fld_talkid || $this->fld_subjectid) { $this->getTSIDs(); } foreach ($this->everything as $pageid => $title) { $pageInfo = $this->extractPageInfo($pageid, $title); $fit = $result->addValue(array('query', 'pages'), $pageid, $pageInfo); if (!$fit) { $this->setContinueEnumParameter('continue', $title->getNamespace() . '|' . $title->getText()); break; } } }
/** * @desc Compares passed title with Wikia.css title * * @param $title * @return bool */ public function isWikiaCssTitle($title) { return Title::compare($title, $this->getCssFileTitle()) === 0; }
public function execute() { $this->params = $this->extractRequestParams(); if (!is_null($this->params['prop'])) { $prop = array_flip($this->params['prop']); $this->fld_protection = isset($prop['protection']); $this->fld_watched = isset($prop['watched']); $this->fld_watchers = isset($prop['watchers']); $this->fld_notificationtimestamp = isset($prop['notificationtimestamp']); $this->fld_talkid = isset($prop['talkid']); $this->fld_subjectid = isset($prop['subjectid']); $this->fld_url = isset($prop['url']); $this->fld_readable = isset($prop['readable']); $this->fld_preload = isset($prop['preload']); $this->fld_displaytitle = isset($prop['displaytitle']); } $pageSet = $this->getPageSet(); $this->titles = $pageSet->getGoodTitles(); $this->missing = $pageSet->getMissingTitles(); $this->everything = $this->titles + $this->missing; $result = $this->getResult(); uasort($this->everything, array('Title', 'compare')); if (!is_null($this->params['continue'])) { // Throw away any titles we're gonna skip so they don't // clutter queries $cont = explode('|', $this->params['continue']); $this->dieContinueUsageIf(count($cont) != 2); $conttitle = Title::makeTitleSafe($cont[0], $cont[1]); foreach ($this->everything as $pageid => $title) { if (Title::compare($title, $conttitle) >= 0) { break; } unset($this->titles[$pageid]); unset($this->missing[$pageid]); unset($this->everything[$pageid]); } } $this->pageRestrictions = $pageSet->getCustomField('page_restrictions'); // when resolving redirects, no page will have this field $this->pageIsRedir = !$pageSet->isResolvingRedirects() ? $pageSet->getCustomField('page_is_redirect') : array(); $this->pageIsNew = $pageSet->getCustomField('page_is_new'); $this->pageTouched = $pageSet->getCustomField('page_touched'); $this->pageLatest = $pageSet->getCustomField('page_latest'); $this->pageLength = $pageSet->getCustomField('page_len'); // Get protection info if requested if ($this->fld_protection) { $this->getProtectionInfo(); } if ($this->fld_watched || $this->fld_notificationtimestamp) { $this->getWatchedInfo(); } if ($this->fld_watchers) { $this->getWatcherInfo(); } // Run the talkid/subjectid query if requested if ($this->fld_talkid || $this->fld_subjectid) { $this->getTSIDs(); } if ($this->fld_displaytitle) { $this->getDisplayTitle(); } /** @var $title Title */ foreach ($this->everything as $pageid => $title) { $pageInfo = $this->extractPageInfo($pageid, $title); $fit = $pageInfo !== null && $result->addValue(array('query', 'pages'), $pageid, $pageInfo); if (!$fit) { $this->setContinueEnumParameter('continue', $title->getNamespace() . '|' . $title->getText()); break; } } }
/** * Insert the captcha prompt into the edit form. */ function getForm() { global $wgOut, $wgExtensionAssetsPath, $wgEnableAPI, $wgTitle, $wgRequest; // Uses addModuleStyles so it is loaded when JS is disabled. $wgOut->addModuleStyles('ext.confirmEdit.fancyCaptcha.styles'); $title = SpecialPage::getTitleFor('Captcha', 'image'); $index = $this->getCaptchaIndex(); // WIKIHOW - changed by Gershon Bialer to get rid of refresh button //if ( $wgEnableAPI ) { if (false && $wgEnableAPI) { // Loaded only if JS is enabled $wgOut->addModules('ext.confirmEdit.fancyCaptcha'); $captchaReload = Html::element('small', array('class' => 'confirmedit-captcha-reload fancycaptcha-reload'), wfMessage('fancycaptcha-reload-text')->text()); } else { //WIKIHOW - added instructions back in place of the refresh button [sc - 01/07/2014] $captchaReload = wfMessage('fancy-instructions')->text(); } //XXCHANGEDXX - custom label logic for our different pages [sc] if ($wgTitle->getText() == 'LoginReminder') { //no label $sec_label = ''; } else { $sec_label = Html::element('label', array('for' => 'wpCaptchaWord', 'class' => 'captcha_label'), wfMessage('captcha_login_label')->plain()); } //XXCHANGEDXX - Different tabindex position on different pages $ult = SpecialPage::getTitleFor("UserLogin"); if (Title::compare($wgTitle, $ult) == 0 && $wgRequest->getVal('type', '') == 'signup') { $tabindex = 7; } else { $tabindex = 4; } return "<div class='fancycaptcha-wrapper'><div class='fancycaptcha-image-container'>" . Html::element('img', array('class' => 'fancycaptcha-image', 'src' => $title->getLocalUrl('wpCaptchaId=' . urlencode($index)), 'alt' => '')) . $captchaReload . "</div>\n" . '<p>' . $sec_label . Html::element('input', array('name' => 'wpCaptchaWord', 'id' => 'wpCaptchaWord', 'type' => 'text', 'size' => '12', 'autocomplete' => 'off', 'autocorrect' => 'off', 'autocapitalize' => 'off', 'required' => 'required', 'tabindex' => $tabindex, 'class' => 'input_med')) . Html::element('input', array('type' => 'hidden', 'name' => 'wpCaptchaId', 'id' => 'wpCaptchaId', 'value' => $index)) . "</p>\n" . "</div>\n"; }