/** * @throws \Email\Check */ private function assertValidCommentTitle() { if (!$this->commentTitle instanceof \Title) { throw new Check("Could not find comment for revision ID given by currentRevId"); } if (!$this->commentTitle->exists()) { throw new Check("Comment doesn't exist."); } }
/** * @throws \Email\Check */ private function assertValidTitle() { if (!$this->pageTitle instanceof \Title) { throw new Check("Invalid value passed for title"); } if (!$this->pageTitle->exists()) { throw new Check("Title doesn't exist."); } }
/** * @throws \Email\Check */ private function assertValidPostTitle() { if (!$this->postTitle instanceof \Title) { $articleID = $this->getVal('childArticleID', false); throw new Check("Could not find post for article ID '{$articleID}' given by childArticleID"); } if (!$this->postTitle->exists()) { throw new Check("Post doesn't exist."); } }
/** * Returns infobox data * * @return array in format [ 'data' => [], 'sources' => [] ] or [] will be returned */ public function getData() { if ($this->title && $this->title->exists()) { $parserOutput = Article::newFromTitle($this->title, RequestContext::getMain())->getParserOutput(); $data = $parserOutput ? $parserOutput->getProperty(self::INFOBOXES_PROPERTY_NAME) : false; //return empty [] to prevent false on non existing infobox data return $data ? $data : []; } return []; }
protected function assertUserRolesSet() { if (empty($this->authorUserName)) { throw new Check("Could not determine message author"); } if (empty($this->wallUserName)) { throw new Check("Could not determine message owner"); } if (!$this->wallTitle->exists()) { throw new Check("Given Message Wall doesn't exist"); } }
/** * @throws \Email\Check */ protected function assertValidPageAddedToCategory() { if (!$this->pageAddedToCategory instanceof \Title) { throw new Check("Invalid value passed for pageAddedToCategory (param: pageTitle)"); } if (!$this->pageAddedToCategory->exists()) { // Check master DB just in case the page was just created and it // hasn't been replicated to the slave yet if ($this->pageAddedToCategory->getArticleID(\Title::GAID_FOR_UPDATE) == 0) { throw new Check("pageAddedToCategory doesn't exist."); } } }
public function execute($par) { $this->useTransactionalTimeLimit(); $this->checkReadOnly(); $this->setHeaders(); $this->outputHeader(); $request = $this->getRequest(); $target = !is_null($par) ? $par : $request->getVal('target'); // Yes, the use of getVal() and getText() is wanted, see bug 20365 $oldTitleText = $request->getVal('wpOldTitle', $target); if (is_string($oldTitleText)) { $this->oldTitle = Title::newFromText($oldTitleText); } if ($this->oldTitle === null) { // Either oldTitle wasn't passed, or newFromText returned null throw new ErrorPageError('notargettitle', 'notargettext'); } if (!$this->oldTitle->exists()) { throw new ErrorPageError('nopagetitle', 'nopagetext'); } $newTitleTextMain = $request->getText('wpNewTitleMain'); $newTitleTextNs = $request->getInt('wpNewTitleNs', $this->oldTitle->getNamespace()); // Backwards compatibility for forms submitting here from other sources // which is more common than it should be.. $newTitleText_bc = $request->getText('wpNewTitle'); $this->newTitle = strlen($newTitleText_bc) > 0 ? Title::newFromText($newTitleText_bc) : Title::makeTitleSafe($newTitleTextNs, $newTitleTextMain); $user = $this->getUser(); # Check rights $permErrors = $this->oldTitle->getUserPermissionsErrors('move', $user); if (count($permErrors)) { // Auto-block user's IP if the account was "hard" blocked DeferredUpdates::addCallableUpdate(function () use($user) { $user->spreadAnyEditBlock(); }); throw new PermissionsError('move', $permErrors); } $def = !$request->wasPosted(); $this->reason = $request->getText('wpReason'); $this->moveTalk = $request->getBool('wpMovetalk', $def); $this->fixRedirects = $request->getBool('wpFixRedirects', $def); $this->leaveRedirect = $request->getBool('wpLeaveRedirect', $def); $this->moveSubpages = $request->getBool('wpMovesubpages', false); $this->deleteAndMove = $request->getBool('wpDeleteAndMove') && $request->getBool('wpConfirm'); $this->moveOverShared = $request->getBool('wpMoveOverSharedFile', false); $this->watch = $request->getCheck('wpWatch') && $user->isLoggedIn(); if ('submit' == $request->getVal('action') && $request->wasPosted() && $user->matchEditToken($request->getVal('wpEditToken'))) { $this->doSubmit(); } else { $this->showForm(array()); } }
/** * Set up all member variables using a database query. * @throws MWException * @return bool True on success, false on failure. */ protected function initialize() { if ($this->mName === null && $this->mID === null) { throw new MWException(__METHOD__ . ' has both names and IDs null'); } elseif ($this->mID === null) { $where = ['cat_title' => $this->mName]; } elseif ($this->mName === null) { $where = ['cat_id' => $this->mID]; } else { # Already initialized return true; } $dbr = wfGetDB(DB_REPLICA); $row = $dbr->selectRow('category', ['cat_id', 'cat_title', 'cat_pages', 'cat_subcats', 'cat_files'], $where, __METHOD__); if (!$row) { # Okay, there were no contents. Nothing to initialize. if ($this->mTitle) { # If there is a title object but no record in the category table, # treat this as an empty category. $this->mID = false; $this->mName = $this->mTitle->getDBkey(); $this->mPages = 0; $this->mSubcats = 0; $this->mFiles = 0; # If the title exists, call refreshCounts to add a row for it. if ($this->mTitle->exists()) { DeferredUpdates::addCallableUpdate([$this, 'refreshCounts']); } return true; } else { return false; # Fail } } $this->mID = $row->cat_id; $this->mName = $row->cat_title; $this->mPages = $row->cat_pages; $this->mSubcats = $row->cat_subcats; $this->mFiles = $row->cat_files; # (bug 13683) If the count is negative, then 1) it's obviously wrong # and should not be kept, and 2) we *probably* don't have to scan many # rows to obtain the correct figure, so let's risk a one-time recount. if ($this->mPages < 0 || $this->mSubcats < 0 || $this->mFiles < 0) { $this->mPages = max($this->mPages, 0); $this->mSubcats = max($this->mSubcats, 0); $this->mFiles = max($this->mFiles, 0); DeferredUpdates::addCallableUpdate([$this, 'refreshCounts']); } return true; }
/** * set appropriate status code for deleted pages * * @author ADi * @param Title $title * @param Article $article * @return bool */ public function onArticleFromTitle(&$title, &$article) { if (!$title->exists() && $title->isDeleted()) { F::app()->wg->Out->setStatusCode(SEOTweaksHooksHelper::DELETED_PAGES_STATUS_CODE); } return true; }
/** * Do the basic checks whether moving is possible and whether * the input looks anywhere near sane. * @return bool */ protected function doBasicChecks() { global $wgOut; # Check for database lock if ( wfReadOnly() ) { $wgOut->readOnlyPage(); return false; } if ( $this->title === null ) { $wgOut->showErrorPage( 'notargettitle', 'notargettext' ); return false; } if ( !$this->title->exists() ) { $wgOut->showErrorPage( 'nopagetitle', 'nopagetext' ); return false; } # Check rights $permErrors = $this->title->getUserPermissionsErrors( 'delete', $this->user ); if ( !empty( $permErrors ) ) { $wgOut->showPermissionsErrorPage( $permErrors ); return false; } // Let the caller know it's safe to continue return true; }
/** * Render the special page * @param string $par parameter as subpage of specialpage */ public function executeWhenAvailable($par = '') { $out = $this->getOutput(); $out->setPageTitle($this->msg('history')); $out->addModuleStyles(array('mobile.pagelist.styles', 'mobile.pagesummary.styles')); $this->offset = $this->getRequest()->getVal('offset', false); if ($par) { // enter article history view $this->title = Title::newFromText($par); if ($this->title && $this->title->exists()) { // make sure, the content of the page supports the default history page if (!self::shouldUseSpecialHistory($this->title)) { // and if not, redirect to the default history action $out->redirect($this->title->getLocalUrl(array('action' => 'history'))); return; } $this->addModules(); $this->getOutput()->addHtml(Html::openElement('div', array('class' => 'history content-unstyled'))); $this->renderHeaderBar($this->title); $res = $this->doQuery(); $this->showHistory($res); $this->getOutput()->addHtml(Html::closeElement('div')); return; } } $this->showPageNotFound(); }
/** * set appropriate status code for deleted pages * * @author ADi * @author Władysław Bodzek <*****@*****.**> * @param Title $title * @param Article $article * @return bool */ public static function onAfterInitialize(&$title, &$article, &$output) { if (!$title->exists() && $title->isDeleted()) { $setDeletedStatusCode = true; // handle special cases switch ($title->getNamespace()) { case NS_CATEGORY: // skip non-empty categories if (Category::newFromTitle($title)->getPageCount() > 0) { $setDeletedStatusCode = false; } break; case NS_FILE: // skip existing file with deleted description $file = wfFindFile($title); if ($file && $file->exists()) { $setDeletedStatusCode = false; } break; } if ($setDeletedStatusCode) { $output->setStatusCode(SEOTweaksHooksHelper::DELETED_PAGES_STATUS_CODE); } } return true; }
/** * return the page titles of the subpages in an array * @return array all titles * @private */ function getTitles() { wfProfileIn( __METHOD__ ); $dbr = wfGetDB( DB_SLAVE ); $conditions = array(); $options = array(); $order = strtoupper( $this->order ); if( $this->ordermethod == 'title' ) { $options['ORDER BY'] = 'page_title ' . $order; } elseif( $this->ordermethod == 'lastedit' ) { $options['ORDER BY'] = 'page_touched ' . $order; } if( $this->parent !== -1) { $this->ptitle = Title::newFromText( $this->parent ); # note that non-existent pages may nevertheless have valid subpages # on the other hand, not checking that the page exists can let input through which causes database errors if ( $this->ptitle instanceof Title && $this->ptitle->exists() && $this->ptitle->userCanRead() ) { $parent = $this->ptitle->getDBkey(); $this->parent = $parent; $this->namespace = $this->ptitle->getNsText(); $nsi = $this->ptitle->getNamespace(); } else { $this->error( wfMsg('spl3_debug','parent') ); return null; } } else { $this->ptitle = $this->title; $parent = $this->title->getDBkey(); $this->parent = $parent; $this->namespace = $this->title->getNsText(); $nsi = $this->title->getNamespace(); } // don't let list cross namespaces if ( strlen( $nsi ) > 0 ) { $conditions['page_namespace'] = $nsi; } $conditions['page_is_redirect'] = 0; $conditions[] = 'page_title ' . $dbr->buildLike( $parent . '/', $dbr->anyString() ); $fields = array(); $fields[] = 'page_title'; $fields[] = 'page_namespace'; $res = $dbr->select( 'page', $fields, $conditions, __METHOD__, $options ); $titles = array(); foreach ( $res as $row ) { $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title ); if( $title ) { $titles[] = $title; } } wfProfileOut( __METHOD__ ); return $titles; }
function wfAutoPageCreateTextForImagePlaceholder(Title $title, &$text) { // this was for RT#45568 - Bartek // basic idea is to load the template for ImagePlaceholder to work when the article does not yet exist // but on view, not on article edit (on preview the placeholder is blocked by default) global $wgRequest; if (!$title->exists() && 'edit' != $wgRequest->getVal('action')) { $text = wfMsgForContent('newpagelayout'); } return true; }
public static function create(Title $title) { wfProfileIn(__METHOD__); if (empty($title) || $title->exists()) { return; } $article = F::build('Article', array($title)); $status = $article->doEdit('', 'Article created', EDIT_NEW, false, F::app()->wg->user); wfProfileOut(__METHOD__); return self::newFromTitle($article->getTitle()); }
/** * Render the page with a list of languages the page is available in * @param string $pagename The name of the page */ public function executeWhenAvailable($pagename) { if (!is_string($pagename) || $pagename === '') { wfHttpError(404, $this->msg('mobile-frontend-languages-404-title')->text(), $this->msg('mobile-frontend-languages-404-desc')->text()); return; } $this->title = Title::newFromText($pagename); $output = $this->getOutput(); $html = ''; if ($this->title && $this->title->exists()) { $titlename = $this->title->getPrefixedText(); $pageTitle = $this->msg('mobile-frontend-languages-header-page', $titlename)->text(); $languages = $this->getLanguages(); $variants = $this->getLanguageVariants(); $languagesCount = count($languages); $variantsCount = count($variants); $html .= Html::element('p', array(), $this->msg('mobile-frontend-languages-text')->params($titlename)->numParams($languagesCount)->text()); $html .= Html::openElement('p'); $html .= Html::element('a', array('href' => $this->title->getLocalUrl()), $this->msg('returnto', $titlename)->text()); $html .= Html::closeElement('p'); if ($languagesCount > 0 || $variantsCount > 1) { // Language variants first if ($variantsCount > 1) { $variantHeader = $variantsCount > 1 ? $this->msg('mobile-frontend-languages-variant-header')->text() : ''; $html .= Html::element('h2', array('id' => 'mw-mf-language-variant-header'), $variantHeader); $html .= Html::openElement('ul', array('id' => 'mw-mf-language-variant-selection')); foreach ($variants as $val) { $html .= $this->makeLangListItem($val); } $html .= Html::closeElement('ul'); } // Then other languages if ($languagesCount > 0) { $languageHeader = $this->msg('mobile-frontend-languages-header')->text(); $html .= Html::element('h2', array('id' => 'mw-mf-language-header'), $languageHeader) . Html::openElement('ul', array('id' => 'mw-mf-language-selection')); foreach ($languages as $val) { $html .= $this->makeLangListItem($val); } $html .= Html::closeElement('ul'); } } } else { $pageTitle = $this->msg('mobile-frontend-languages-header')->text(); $html .= Html::element('p', array(), $this->msg('mobile-frontend-languages-nonexistent-title')->params($pagename)->text()); } $html = MobileUI::contentElement($html); $output->setPageTitle($pageTitle); $output->addHTML($html); }
/** * @return Title */ private function getRbTitle() { if ($this->mTitleObj !== null) { return $this->mTitleObj; } $params = $this->extractRequestParams(); $this->mTitleObj = Title::newFromText($params['title']); if (!$this->mTitleObj || $this->mTitleObj->isExternal()) { $this->dieUsageMsg(array('invalidtitle', $params['title'])); } if (!$this->mTitleObj->exists()) { $this->dieUsageMsg('notanarticle'); } return $this->mTitleObj; }
/** * Retrieves * @param Title $title * @return bool|User */ public static function getPageAuthor(Title $title) { if (!$title->exists()) { return false; } $firstRev = $title->getFirstRevision(); if (!$firstRev) { return false; } $user = User::newFromId($firstRev->getUser()); if (!$user) { return false; } return $user; }
/** * Render the special page * @param string $par parameter as subpage of specialpage */ public function executeWhenAvailable($par = '') { $out = $this->getOutput(); $out->setPageTitle($this->msg('history')); $this->offset = $this->getRequest()->getVal('offset', false); if ($par) { // enter article history view $this->title = Title::newFromText($par); if ($this->title && $this->title->exists()) { $this->addModules(); $this->renderHeaderBar($this->title); $res = $this->doQuery(); $this->showHistory($res); return; } } $this->showPageNotFound(); }
/** * @param Title $title * @param WikiPage $article * @return bool */ public function onArticleFromTitle(Title &$title, &$article) { if ($title->exists() && $title->getNamespace() != NS_FILE && $title->getNamespace() != NS_CATEGORY) { $key = $this->generateCacheKey($title->getArticleId()); $this->switches = $this->app->wg->memc->get($key); if (empty($this->switches)) { $article = F::build('Article', array($title)); $this->switches = array(); foreach ($this->magicWords as $wordID) { $magicWord = MagicWord::get($wordID); $this->switches[$wordID] = 0 < $magicWord->match($article->getRawText()); } $this->app->wg->memc->set($key, $this->switches, self::CACHE_DURATION); } $this->process(); } return true; }
/** * Helper function -- remove files and associated articles by Title * * @param Title $title Title to be removed * * @return bool */ public function deleteFileByTitle($title) { if ($title->exists()) { $file = wfFindFile($title, array('ignoreRedirect' => true)); $noOldArchive = ""; // yes this really needs to be set this way $comment = "removing for test"; $restrictDeletedVersions = false; $status = FileDeleteForm::doDelete($title, $file, $noOldArchive, $comment, $restrictDeletedVersions); if (!$status->isGood()) { return false; } $page = WikiPage::factory($title); $page->doDeleteArticle("removing for test"); // see if it now doesn't exist; reload $title = Title::newFromText($title->getText(), NS_FILE); } return !($title && $title instanceof Title && $title->exists()); }
/** * Call the stock "user is blocked" page */ function blockedPage() { global $wgOut; $wgOut->blockedPage(false); # Standard block notice on the top, don't 'return' # If the user made changes, preserve them when showing the markup # (This happens when a user is blocked during edit, for instance) $first = $this->firsttime || !$this->save && $this->textbox1 == ''; if ($first) { $source = $this->mTitle->exists() ? $this->getContent() : false; } else { $source = $this->textbox1; } # Spit out the source or the user's modified version if ($source !== false) { $wgOut->addHTML('<hr />'); $wgOut->addWikiMsg($first ? 'blockedoriginalsource' : 'blockededitsource', $this->mTitle->getPrefixedText()); $this->showTextbox1(array('readonly'), $source); } }
/** * Render the special page * @param string $par parameter as subpage of specialpage */ public function executeWhenAvailable($par = '') { $out = $this->getOutput(); $out->setPageTitle($this->msg('history')); $out->addModuleStyles(array('mobile.pagelist.styles', 'mobile.pagesummary.styles')); $this->offset = $this->getRequest()->getVal('offset', false); if ($par) { // enter article history view $this->title = Title::newFromText($par); if ($this->title && $this->title->exists()) { $this->addModules(); $this->getOutput()->addHtml(Html::openElement('div', array('class' => 'history content-unstyled'))); $this->renderHeaderBar($this->title); $res = $this->doQuery(); $this->showHistory($res); $this->getOutput()->addHtml(Html::closeElement('div')); return; } } $this->showPageNotFound(); }
/** * @param Title $title * @param WikiPage $article * @return bool */ public static function onArticleFromTitle(Title &$title, &$article) { global $wgLandingPagesAsContentMagicWords; $app = F::app(); if ($title->exists() && $title->getNamespace() != NS_FILE && $title->getNamespace() != NS_CATEGORY) { $key = self::generateCacheKey($title->getArticleId()); self::$switches = $app->wg->memc->get($key); if (empty(self::$switches)) { $article = new Article($title); self::$switches = array(); $magicWords = array_keys($wgLandingPagesAsContentMagicWords); foreach ($magicWords as $wordID) { $magicWord = MagicWord::get($wordID); self::$switches[$wordID] = 0 < $magicWord->match($article->getRawText()); } $app->wg->memc->set($key, self::$switches, self::CACHE_DURATION); } self::process(); } return true; }
/** * Return HTML to be used when embedding polls from inside parser * TODO: replace all this with a hook inside parser * * @param WikiaPoll $poll * @param Title $finalTitle */ public static function generate($poll, $finalTitle) { wfProfileIn(__METHOD__); if ($finalTitle instanceof Title && $finalTitle->exists() && $finalTitle->getNamespace() == NS_WIKIA_POLL) { $app = F::app(); $ret = $poll->renderEmbedded(); if (self::$alreadyAddedCSSJS == false) { // make sure we don't include twice if there are multiple polls on one page self::$alreadyAddedCSSJS = true; // add CSS & JS and Poll HTML together if ($app->checkSkin('wikiamobile')) { $cssLinks = AssetsManager::getInstance()->getURL('wikiapoll_wikiamobile_scss'); $jsLinks = AssetsManager::getInstance()->getURL('wikiapoll_wikiamobile_js'); $css = ''; $js = ''; if (is_array($cssLinks)) { foreach ($cssLinks as $s) { $css .= "<link rel=stylesheet href={$s} />"; } } if (is_array($jsLinks)) { foreach ($jsLinks as $s) { $js .= "<script src={$s}></script>"; } } $js .= JSMessages::printPackages(array('WikiaMobilePolls')); $ret = str_replace("\n", ' ', "{$css}{$ret}{$js}"); } else { $sassUrl = AssetsManager::getInstance()->getSassCommonURL('/extensions/wikia/WikiaPoll/css/WikiaPoll.scss'); $css = '<link rel="stylesheet" type="text/css" href="' . htmlspecialchars($sassUrl) . ' " />'; $jsFile = JSSnippets::addToStack(array('/extensions/wikia/WikiaPoll/js/WikiaPoll.js'), array(), 'WikiaPoll.init'); $ret = str_replace("\n", ' ', "{$css} {$ret} {$jsFile}"); } } wfProfileOut(__METHOD__); return $ret; } wfProfileOut(__METHOD__); return ''; }
/** * @param array $params * * @return Title */ private function getRbTitle(array $params) { if ($this->mTitleObj !== null) { return $this->mTitleObj; } $this->requireOnlyOneParameter($params, 'title', 'pageid'); if (isset($params['title'])) { $this->mTitleObj = Title::newFromText($params['title']); if (!$this->mTitleObj || $this->mTitleObj->isExternal()) { $this->dieUsageMsg(array('invalidtitle', $params['title'])); } } elseif (isset($params['pageid'])) { $this->mTitleObj = Title::newFromID($params['pageid']); if (!$this->mTitleObj) { $this->dieUsageMsg(array('nosuchpageid', $params['pageid'])); } } if (!$this->mTitleObj->exists()) { $this->dieUsageMsg('notanarticle'); } return $this->mTitleObj; }
/** * Do the basic checks whether moving is possible and whether * the input looks anywhere near sane. * @throws PermissionsError|ErrorPageError|ReadOnlyError * @return bool */ protected function doBasicChecks() { # Check rights if (!$this->userCanExecute($this->getUser())) { $this->displayRestrictionError(); } if ($this->title === null) { throw new ErrorPageError('notargettitle', 'notargettext'); } if (!$this->title->exists()) { throw new ErrorPageError('nopagetitle', 'nopagetext'); } $permissionErrors = $this->title->getUserPermissionsErrors('delete', $this->getUser()); if (count($permissionErrors)) { throw new PermissionsError('delete', $permissionErrors); } # Check for database lock if (wfReadOnly()) { throw new ReadOnlyError(); } // Let the caller know it's safe to continue return true; }
public function execute($par) { $this->useTransactionalTimeLimit(); $this->checkPermissions(); $this->checkReadOnly(); $this->loadRequestParams(); $this->setHeaders(); $this->outputHeader(); if ($this->mTargetID && $this->mDestID && $this->mAction == 'submit' && $this->mMerge) { $this->merge(); return; } if (!$this->mSubmitted) { $this->showMergeForm(); return; } $errors = []; if (!$this->mTargetObj instanceof Title) { $errors[] = $this->msg('mergehistory-invalid-source')->parseAsBlock(); } elseif (!$this->mTargetObj->exists()) { $errors[] = $this->msg('mergehistory-no-source', wfEscapeWikiText($this->mTargetObj->getPrefixedText()))->parseAsBlock(); } if (!$this->mDestObj instanceof Title) { $errors[] = $this->msg('mergehistory-invalid-destination')->parseAsBlock(); } elseif (!$this->mDestObj->exists()) { $errors[] = $this->msg('mergehistory-no-destination', wfEscapeWikiText($this->mDestObj->getPrefixedText()))->parseAsBlock(); } if ($this->mTargetObj && $this->mDestObj && $this->mTargetObj->equals($this->mDestObj)) { $errors[] = $this->msg('mergehistory-same-destination')->parseAsBlock(); } if (count($errors)) { $this->showMergeForm(); $this->getOutput()->addHTML(implode("\n", $errors)); } else { $this->showHistory(); } }
/** * @param object $row * @param Title $title */ protected function moveInconsistentPage($row, $title) { if ($title->exists() || $title->getInterwiki() || !$title->canExist()) { if ($title->getInterwiki() || !$title->canExist()) { $prior = $title->getPrefixedDBkey(); } else { $prior = $title->getDBkey(); } # Old cleanupTitles could move articles there. See bug 23147. $ns = $row->page_namespace; if ($ns < 0) { $ns = 0; } # Namespace which no longer exists. Put the page in the main namespace # since we don't have any idea of the old namespace name. See bug 68501. if (!MWNamespace::exists($ns)) { $ns = 0; } $clean = 'Broken/' . $prior; $verified = Title::makeTitleSafe($ns, $clean); if (!$verified || $verified->exists()) { $blah = "Broken/id:" . $row->page_id; $this->output("Couldn't legalize; form '{$clean}' exists; using '{$blah}'\n"); $verified = Title::makeTitleSafe($ns, $blah); } $title = $verified; } if (is_null($title)) { $this->error("Something awry; empty title.", true); } $ns = $title->getNamespace(); $dest = $title->getDBkey(); if ($this->dryrun) { $this->output("DRY RUN: would rename {$row->page_id} ({$row->page_namespace}," . "'{$row->page_title}') to ({$ns},'{$dest}')\n"); } else { $this->output("renaming {$row->page_id} ({$row->page_namespace}," . "'{$row->page_title}') to ({$ns},'{$dest}')\n"); $dbw = wfGetDB(DB_MASTER); $dbw->update('page', array('page_namespace' => $ns, 'page_title' => $dest), array('page_id' => $row->page_id), __METHOD__); LinkCache::singleton()->clear(); } }
/** * Return the CSS colour of a known link * * @param Title $t * @param int $threshold User defined threshold * @return string CSS class */ public static function getLinkColour($t, $threshold) { $colour = ''; if ($t->isRedirect()) { # Page is a redirect $colour = 'mw-redirect'; } elseif ($threshold > 0 && $t->isContentPage() && $t->exists() && $t->getLength() < $threshold) { # Page is a stub $colour = 'stub'; } return $colour; }