public function execute($par) { $request = $this->getRequest(); $par = (string) $par; // Yes, the use of getVal() and getText() is wanted, see bug T22365 $this->text = $request->getVal('wpTitle', $par); $this->title = Title::newFromText($this->text); $this->reason = $request->getText('reason'); // Checkboxes that default being checked are tricky $this->doSubpages = $request->getBool('subpages', !$request->wasPosted()); $user = $this->getUser(); if ($this->doBasicChecks() !== true) { return; } $out = $this->getOutput(); // Real stuff starts here if (TranslatablePage::isSourcePage($this->title)) { $title = $this->msg('pt-deletepage-full-title', $this->title->getPrefixedText()); $out->setPagetitle($title); $this->code = ''; $this->page = TranslatablePage::newFromTitle($this->title); } else { $page = TranslatablePage::isTranslationPage($this->title); if ($page) { $title = $this->msg('pt-deletepage-lang-title', $this->title->getPrefixedText()); $out->setPagetitle($title); list(, $this->code) = TranslateUtils::figureMessage($this->title->getText()); $this->page = $page; } else { throw new ErrorPageError('pt-deletepage-invalid-title', 'pt-deletepage-invalid-text'); } } if (!$user->isAllowed('pagetranslation')) { throw new PermissionsError('pagetranslation'); } // Is there really no better way to do this? $subactionText = $request->getText('subaction'); switch ($subactionText) { case $this->msg('pt-deletepage-action-check')->text(): $subaction = 'check'; break; case $this->msg('pt-deletepage-action-perform')->text(): $subaction = 'perform'; break; case $this->msg('pt-deletepage-action-other')->text(): $subaction = ''; break; default: $subaction = ''; } if ($subaction === 'check' && $this->checkToken() && $request->wasPosted()) { $this->showConfirmation(); } elseif ($subaction === 'perform' && $this->checkToken() && $request->wasPosted()) { $this->performAction(); } else { $this->showForm(); } }
protected function makePageLink(Title $title = null, $parameters = array(), $html = null) { global $wgContLang, $wgUserrightsInterwikiDelimiter; if (!$this->plaintext) { $text = $wgContLang->ucfirst($title->getText()); $parts = explode($wgUserrightsInterwikiDelimiter, $text, 2); if (count($parts) === 2) { $titleLink = WikiMap::foreignUserLink($parts[1], $parts[0], htmlspecialchars($title->getText())); if ($titleLink !== false) { return $titleLink; } } } return parent::makePageLink($title, $parameters, $title ? $title->getText() : null); }
/** * Get name of the user this page referrs to */ public static function getUserName(Title $title, $namespaces, $fallbackToGlobal = true) { wfProfileIn(__METHOD__); global $wgUser, $wgRequest; $userName = null; if (in_array($title->getNamespace(), $namespaces)) { // get "owner" of this user / user talk / blog page $parts = explode('/', $title->getText()); } else { if ($title->getNamespace() == NS_SPECIAL) { if ($title->isSpecial('Following') || $title->isSpecial('Contributions')) { $target = $wgRequest->getText('target'); if ($target != '') { // /wiki/Special:Contributions?target=FooBar (RT #68323) $parts = array($target); } else { // get user this special page referrs to $parts = explode('/', $wgRequest->getText('title', false)); // remove special page name array_shift($parts); } } } } if (isset($parts[0]) && $parts[0] != '') { //this line was usign urldecode($parts[0]) before, see RT #107278, user profile pages with '+' symbols get 'non-existing' message $userName = str_replace('_', ' ', $parts[0]); } elseif ($fallbackToGlobal) { // fallback value $userName = $wgUser->getName(); } wfProfileOut(__METHOD__); return $userName; }
/** * Set headers, titles and other bits */ private function setHeaders() { global $wgOut; $wgOut->setPageTitle(wfMessage('filedelete', $this->title->getText())); $wgOut->setRobotPolicy('noindex,nofollow'); $wgOut->addBacklinkSubtitle($this->title); }
public function getExhibitionItems(Title $title) { wfProfileIn(__METHOD__); if (class_exists('CategoryDataService')) { $cacheKey = $this->getExhibitionItemsCacheKey($title->getText()); $items = $this->wg->memc->get($cacheKey); if (!is_array($items)) { $exh = CategoryDataService::getMostVisited($title->getDBkey(), null, self::EXHIBITION_ITEMS_LIMIT); $ids = array_keys($exh); $length = count($ids); $items = array(); for ($i = 0; $i < $length; $i++) { $pageId = $ids[$i]; $imgRespnse = $this->app->sendRequest('ImageServing', 'index', array('ids' => array($pageId), 'height' => 150, 'width' => 150, 'count' => 1)); $img = $imgRespnse->getVal('result'); if (!empty($img[$pageId])) { $img = $img[$pageId][0]['url']; } else { $img = false; } $oTitle = Title::newFromID($pageId); $items[] = ['img' => $img, 'title' => $oTitle->getText(), 'url' => $oTitle->getFullURL()]; } $this->wg->memc->set($cacheKey, $items, self::CACHE_TTL_EXHIBITION); } wfProfileOut(__METHOD__); return $items; } wfProfileOut(__METHOD__); return false; }
public function onSubmit(array $data) { $cat = false; $categoryStr = $data['category']; if ($categoryStr) { $cat = Title::newFromText($categoryStr, NS_CATEGORY); } if ($cat && $cat->getNamespace() !== NS_CATEGORY) { // Someone searching for something like "Wikipedia:Foo" $cat = Title::makeTitleSafe(NS_CATEGORY, $categoryStr); } if ($cat) { $this->setCategory($cat); } if (!$this->category && $categoryStr) { $msg = $this->msg('randomincategory-invalidcategory', wfEscapeWikiText($categoryStr)); return Status::newFatal($msg); } elseif (!$this->category) { return false; // no data sent } $title = $this->getRandomTitle(); if (is_null($title)) { $msg = $this->msg('randomincategory-nopages', $this->category->getText()); return Status::newFatal($msg); } $this->getOutput()->redirect($title->getFullURL()); }
protected function placesForCategory(Title $oTitle) { $placesModel = F::build('PlacesModel'); $categoryName = $oTitle->getText(); $this->wg->Out->setPageTitle(wfMsg('places-in-category', $categoryName)); return $placesModel->getFromCategories($categoryName); }
/** * @brief remove User:: from back link * * @author Tomek Odrobny * * @param Title $title * @param String $ptext * * @return Boolean */ public static function onSkinSubPageSubtitleAfterTitle($title, &$ptext) { if (!empty($title) && $title->getNamespace() == NS_USER) { $ptext = $title->getText(); } return true; }
function fnForumIndexProtector(Title &$title, User &$user, $action, &$result) { if ($user->isLoggedIn()) { #this doesnt apply to logged in users, bail, but keep going return true; } if ($action != 'edit' && $action != 'create') { #only kill editing actions (what else can anons even do?), bail, but keep going return true; } #this only applies to Forum:Index and Forum_talk:Index #check pagename if ($title->getText() != 'Index') { #wrong pagename, bail, but keep going return true; } $ns = $title->getNamespace(); #check namespace(s) if ($ns == NS_FORUM || $ns == NS_FORUM_TALK) { #bingo bango, its a match! $result = array('protectedpagetext'); Wikia::log(__METHOD__, __LINE__, "anon trying to edit forum:index, killing request"); #bail, and stop the request return false; } return true; }
private function setTitlesDefault() { $ns = $this->title->getNamespace(); $titles = array(); if (!MWNamespace::hasSubpages($ns)) { $titles[] = $this->title; } else { $explosion = explode('/', $this->title->getText()); $text = ''; foreach ($explosion as $atom) { $text .= $atom; $titles[] = Title::newFromText($text, $ns); $text .= '/'; } } $this->titles = $titles; }
/** * Convert the content model of messages that are actually JSON to JSON. * This only affects validation and UI when saving and editing, not * loading the content. * * @param Title $title * @param string $model * @return bool */ public static function onContentHandlerDefaultModelFor(Title $title, &$model) { $messages = array('Visualeditor-cite-tool-definition.json', 'Visualeditor-quick-access-characters.json'); if ($title->inNamespace(NS_MEDIAWIKI) && in_array($title->getText(), $messages)) { $model = CONTENT_MODEL_JSON; } return true; }
/** * Add a link to Special:LookupUser from Special:Contributions/USERNAME * if the user has 'lookupuser' permission * * @param integer $id * @param Title $nt * * @return bool true */ function efLoadLookupUserLink($id, $nt, &$links) { global $wgUser; if ($wgUser->isAllowed('lookupuser') && $id !== 0) { $links[] = Linker::linkKnown(SpecialPage::getTitleFor('LookupUser'), wfMsgHtml('lookupuser'), array(), array('target' => $nt->getText())); } return true; }
function wfCOArticleCommentCheck(Title $title) { global $wgCommentsOnlyNamespaces; if (in_array($title->getNamespace(), $wgCommentsOnlyNamespaces) && ($title->getText() == 'Index' || $title->equals(Title::newMainPage()))) { return false; } return true; }
/** * If the page ends in '/<language code>' then set the page's language to that code. * @param Title $title page title object * @param string|Language $pageLang the page content language (either an object or a language code) * @param Language $wgLang the user language */ public static function setLanguage($title, &$pageLang, $wgLang) { $matches = array(); if (preg_match('/\\/..$/', $title->getText(), $matches)) { $pageLang = substr($matches[0], 1); } return true; }
/** * @static * @param $id * @param Title $nt * @param $links * @return bool */ public static function ContributionsToolLinks($id, $nt, &$links) { global $wgUser; if ($id != 0 && $wgUser->isAllowed('lookupcontribs')) { $attribs = array('href' => 'http://community.wikia.com/wiki/Special:LookupContribs?target=' . urlencode($nt->getText()), 'title' => wfMsg('right-lookupcontribs')); $links[] = Xml::openElement('a', $attribs) . wfMsg('lookupcontribs') . Xml::closeElement('a'); } return true; }
/** * Change an existing article or create a new article. Updates RC and all necessary caches, * optionally via the deferred update array. * * @param Content $content New content * @param string $summary Edit summary * @param int $flags Bitfield: * EDIT_NEW * Article is known or assumed to be non-existent, create a new one * EDIT_UPDATE * Article is known or assumed to be pre-existing, update it * EDIT_MINOR * Mark this edit minor, if the user is allowed to do so * EDIT_SUPPRESS_RC * Do not log the change in recentchanges * EDIT_FORCE_BOT * Mark the edit a "bot" edit regardless of user rights * EDIT_AUTOSUMMARY * Fill in blank summaries with generated text where possible * * If neither EDIT_NEW nor EDIT_UPDATE is specified, the status of the * article will be detected. If EDIT_UPDATE is specified and the article * doesn't exist, the function will return an edit-gone-missing error. If * EDIT_NEW is specified and the article does exist, an edit-already-exists * error will be returned. These two conditions are also possible with * auto-detection due to MediaWiki's performance-optimised locking strategy. * * @param bool|int $baseRevId The revision ID this edit was based off, if any. * This is not the parent revision ID, rather the revision ID for older * content used as the source for a rollback, for example. * @param User $user The user doing the edit * @param string $serialFormat Format for storing the content in the * database. * * @throws MWException * @return Status Possible errors: * edit-hook-aborted: The ArticleSave hook aborted the edit but didn't * set the fatal flag of $status. * edit-gone-missing: In update mode, but the article didn't exist. * edit-conflict: In update mode, the article changed unexpectedly. * edit-no-change: Warning that the text was the same as before. * edit-already-exists: In creation mode, but the article already exists. * * Extensions may define additional errors. * * $return->value will contain an associative array with members as follows: * new: Boolean indicating if the function attempted to create a new article. * revision: The revision object for the inserted revision, or null. * * @since 1.21 * @throws MWException */ public function doEditContent(Content $content, $summary, $flags = 0, $baseRevId = false, User $user = null, $serialFormat = null) { global $wgUser, $wgUseAutomaticEditSummaries; // Low-level sanity check if ($this->mTitle->getText() === '') { throw new MWException('Something is trying to edit an article with an empty title'); } // Make sure the given content type is allowed for this page if (!$content->getContentHandler()->canBeUsedOn($this->mTitle)) { return Status::newFatal('content-not-allowed-here', ContentHandler::getLocalizedName($content->getModel()), $this->mTitle->getPrefixedText()); } // Load the data from the master database if needed. // The caller may already loaded it from the master or even loaded it using // SELECT FOR UPDATE, so do not override that using clear(). $this->loadPageData('fromdbmaster'); $user = $user ?: $wgUser; $flags = $this->checkFlags($flags); // Trigger pre-save hook (using provided edit summary) $hookStatus = Status::newGood(array()); $hook_args = array(&$this, &$user, &$content, &$summary, $flags & EDIT_MINOR, null, null, &$flags, &$hookStatus); // Check if the hook rejected the attempted save if (!Hooks::run('PageContentSave', $hook_args) || !ContentHandler::runLegacyHooks('ArticleSave', $hook_args)) { if ($hookStatus->isOK()) { // Hook returned false but didn't call fatal(); use generic message $hookStatus->fatal('edit-hook-aborted'); } return $hookStatus; } $old_revision = $this->getRevision(); // current revision $old_content = $this->getContent(Revision::RAW); // current revision's content // Provide autosummaries if one is not provided and autosummaries are enabled if ($wgUseAutomaticEditSummaries && $flags & EDIT_AUTOSUMMARY && $summary == '') { $handler = $content->getContentHandler(); $summary = $handler->getAutosummary($old_content, $content, $flags); } // Get the pre-save transform content and final parser output $editInfo = $this->prepareContentForEdit($content, null, $user, $serialFormat); $pstContent = $editInfo->pstContent; // Content object $meta = array('bot' => $flags & EDIT_FORCE_BOT, 'minor' => $flags & EDIT_MINOR && $user->isAllowed('minoredit'), 'serialized' => $editInfo->pst, 'serialFormat' => $serialFormat, 'baseRevId' => $baseRevId, 'oldRevision' => $old_revision, 'oldContent' => $old_content, 'oldId' => $this->getLatest(), 'oldIsRedirect' => $this->isRedirect(), 'oldCountable' => $this->isCountable()); // Actually create the revision and create/update the page if ($flags & EDIT_UPDATE) { $status = $this->doModify($pstContent, $flags, $user, $summary, $meta); } else { $status = $this->doCreate($pstContent, $flags, $user, $summary, $meta); } // Promote user to any groups they meet the criteria for DeferredUpdates::addCallableUpdate(function () use($user) { $user->addAutopromoteOnceGroups('onEdit'); $user->addAutopromoteOnceGroups('onView'); // b/c }); return $status; }
/** * @covers LogFormatter::newFromEntry * @covers LogFormatter::getActionText */ public function testLogParamsTypeTitleLink() { $params = array('4:title-link:titleLink' => $this->title->getText()); $expected = Linker::link($this->title, null, array(), array()); $entry = $this->newLogEntry('param', $params); $formatter = LogFormatter::newFromEntry($entry); $formatter->setContext($this->context); $logParam = $formatter->getActionText(); $this->assertEquals($expected, $logParam); }
/** * Generate an IRC line corresponding to user unification/creation * @param Title $userpage * @param string $wikiID * @return string */ public function getLine($userpage, $wikiID) { $title = IRCColourfulRCFeedFormatter::cleanupForIRC($userpage->getPrefixedText()); $wikiID = IRCColourfulRCFeedFormatter::cleanupForIRC($wikiID); $url = $userpage->getCanonicalURL(); $user = IRCColourfulRCFeedFormatter::cleanupForIRC($userpage->getText()); # see http://www.irssi.org/documentation/formats for some colour codes. prefix is \003, # no colour (\003) switches back to the term default return "14[[07{$title}14]]4@{$wikiID}10 " . "02{$url} 5* 03{$user} 5*\n"; }
public function __construct(Title $title = null) { $this->app = F::App(); if ($title) { $this->query = $this->prepareCode($title->getText()); } $this->censusDataArr = $this->getCacheCensusDataArr($this->app->wg->LanguageCode, true); if ($this->app->wg->LanguageCode != 'en') { $this->censusDataArrDefault = $this->getCacheCensusDataArr('en', true); } }
/** * create whole list using makeListItem * @param $titles Array all page titles * @param $token string the token symbol: * - * for ul, * - # for ol * - ยท for horizontal lists * @return string the whole list * @see SubPageList::makeListItem */ function makeList( $titles ) { $c = 0; # add parent item if ($this->showparent) { $pn = '[[' . $this->ptitle->getPrefixedText() .'|'. $this->ptitle->getText() .']]'; if( $this->mode != 'bar' ) { $pn = $this->token . $pn; } $ss = trim($pn); $list[] = $ss; $c++; // flag for bar token to be added on next item } # add descendents $parlv = substr_count($this->ptitle->getPrefixedText(), '/'); $list = array(); foreach( $titles as $title ) { $lv = substr_count($title, '/') - $parlv; if ( $this->kidsonly!=1 || $lv < 2 ) { if ($this->showparent) { $lv++; } $ss = ""; if( $this->mode == 'bar' ) { if( $c>0) { $ss .= $this->token; } } else { for ( $i = 0; $i < $lv; $i++ ) { $ss .= $this->token; } } $ss .= $this->makeListItem( $title ); $ss = trim( $ss ); // make sure we don't get any <pre></pre> tags $list[] = $ss; } $c++; if ( $c > 200 ) { break; } } $retval = ''; if( count( $list ) > 0 ) { $retval = implode( "\n", $list ); if ( $this->mode == 'bar' ) { $retval = implode( "", $list ); } } return $retval; }
/** * (non-PHPdoc) * @see LogFormatter::makePageLink() * * @since 0.1 * * This is overridden to change the link text to only include the name of the object, * rather then the full name of it's page. */ protected function makePageLink(Title $title = null, $parameters = array()) { if (!$title instanceof Title) { throw new MWException("Expected title, got null"); } $text = explode('/', $title->getText(), 2); $text = $text[count($text) - 1]; if (!$this->plaintext) { $link = Linker::link($title, htmlspecialchars($text), array(), $parameters); } else { $link = '[[' . $title->getPrefixedText() . '|' . $text . ']]'; } return $link; }
/** * Send a watched page edit email using the new Email extension. * @param User $user */ private function sendUsingEmailExtension(\User $user) { $controller = $this->getEmailExtensionController(); if (!empty($controller)) { $childArticleID = ''; if (!empty($this->otherParam['childTitle'])) { /** @var Title $childTitleObj */ $childTitleObj = $this->otherParam['childTitle']; $childArticleID = $childTitleObj->getArticleID(); } $params = ['targetUser' => $user->getName(), 'pageTitle' => $this->title->getText(), 'namespace' => $this->title->getNamespace(), 'summary' => $this->summary, 'currentRevId' => $this->currentRevId, 'previousRevId' => $this->previousRevId, 'replyToAddress' => $this->replyto, 'fromAddress' => $this->from->address, 'fromName' => $this->from->name, 'childArticleID' => $childArticleID]; F::app()->sendRequest($controller, 'handle', $params); } }
/** * Fills the textbox of a new page with content. */ function lw_templatePreload(&$textbox, Title &$title) { $lwVars = getLyricWikiVariables(); $titleStr = $title->getText(); // only use templates in the main namespace $ns = $title->getNamespace(); if ($ns != NS_MAIN && $ns != NS_TALK) { return true; } $tempType = ""; $pageType = ""; if (isset($_GET['template'])) { $pageType = strtolower($_GET['template']); } if ($pageType == "") { $pageType = $lwVars["pagetype"]; } # pull template from database and replace placeholds if ($pageType == "none") { $textbox = ""; } else { $extra = trim(wfMsgForContentNoTrans("lwtemp-extra-templates")); if ($extra != "") { $extras = explode("\n", $extra); foreach ($extras as $item) { if (strpos($item, "|")) { $parts = explode("|", $item); if (0 < preg_match("/{$parts[0]}/", $titleStr, $m)) { $pageType = $parts[1]; } } } } $template = wfMsgForContentNoTrans("lwtemp-{$pageType}-template"); // only display a template if the template actually exists if ($template != "<{$pageType}Template>" and $template != "<{$pageType}Template>") { $textbox = $template; $lwVars = getLyricWikiVariables(); $replace = array(); $with = array(); foreach ($lwVars as $key => $value) { $replace[] = "{{" . strtoupper($key) . "}}"; $with[] = $value; } $textbox = str_replace($replace, $with, $textbox); } } return true; }
/** * Reject edit action if user attempts to edit another users page or subpage * Usage: $wgHooks['userCan'][] = 'keepYourHandsToYourself'; * @param Title $title Title of the article. (passed by reference) * @param User $user User attempting action on article - presumably $wgUser. (passed by reference) * @param String $action Action being taken on article. (passed by value) * @param Mixed $result The result of processing. (passed by reference) * @return true Always true so other extensions have a chance to process 'userCan' */ function keepYourHandsToYourself($title, $user, $action, $result) { # Check for Namespace, edit action, and sysopship if ($title->getNamespace() != NS_USER || $action != 'edit' || in_array('sysop', $user->getGroups() || in_array('jrsysop', $user->getGroups()))) { return true; } # Check if the page name matches or starts with the username $name = $user->getName(); $text = $title->getText(); if ($name == $text || preg_match('/^' . preg_quote($name) . '\\//', $text)) { return true; } # If we got this far, then it's a user trying to edit another user's page $result = false; return true; }
/** * Extract inexpensive information from a Title object for return to Lua * * @param $title Title Title to return * @return array Lua data */ private function getInexpensiveTitleData(Title $title) { $ns = $title->getNamespace(); $ret = array('isLocal' => (bool) $title->isLocal(), 'interwiki' => $title->getInterwiki(), 'namespace' => $ns, 'nsText' => $title->getNsText(), 'text' => $title->getText(), 'fragment' => $title->getFragment(), 'thePartialUrl' => $title->getPartialURL()); if ($ns === NS_SPECIAL) { // Core doesn't currently record special page links, but it may in the future. if ($this->getParser() && !$title->equals($this->getTitle())) { $this->getParser()->getOutput()->addLink($title); } $ret['exists'] = (bool) SpecialPageFactory::exists($title->getDBkey()); } if ($ns !== NS_FILE && $ns !== NS_MEDIA) { $ret['file'] = false; } return $ret; }
/** * Sanity checks for when a file is being moved * * @return Status */ protected function isValidFileMove() { $status = new Status(); $file = wfLocalFile($this->oldTitle); $file->load(File::READ_LATEST); if ($file->exists()) { if ($this->newTitle->getText() != wfStripIllegalFilenameChars($this->newTitle->getText())) { $status->fatal('imageinvalidfilename'); } if (!File::checkExtensionCompatibility($file, $this->newTitle->getDBkey())) { $status->fatal('imagetypemismatch'); } } if (!$this->newTitle->inNamespace(NS_FILE)) { $status->fatal('imagenocrossnamespace'); } return $status; }
/** * Hook into Article::view() to provide syntax highlighting for * custom CSS and JavaScript pages * * @param string $text * @param Title $title * @param OutputPage $output * @return bool */ public static function viewHook($text, $title, $output) { // Determine the language preg_match('!\\.(css|js)$!u', $title->getText(), $matches); $lang = $matches[1] == 'css' ? 'css' : 'javascript'; // Attempt to format $geshi = self::prepare($text, $lang); if ($geshi instanceof GeSHi) { $out = $geshi->parse_code(); if (!$geshi->error()) { // Done $output->addHeadItem("source-{$lang}", self::buildHeadItem($geshi)); $output->addHtml("<div dir=\"ltr\">{$out}</div>"); return false; } } // Bottle out return true; }
/** * @return string */ function getImageSection() { $r = ''; $rescnt = $this->showGallery ? $this->gallery->count() : count($this->imgsNoGallery); if ($rescnt > 0) { $dbcnt = $this->cat->getFileCount(); $countmsg = $this->getCountMessage($rescnt, $dbcnt, 'file'); $r .= "<div id=\"mw-category-media\">\n"; $r .= '<h2>' . $this->msg('category-media-header', wfEscapeWikiText($this->title->getText()))->text() . "</h2>\n"; $r .= $countmsg; $r .= $this->getSectionPagingLinks('file'); if ($this->showGallery) { $r .= $this->gallery->toHTML(); } else { $r .= $this->formatList($this->imgsNoGallery, $this->imgsNoGallery_start_char); } $r .= $this->getSectionPagingLinks('file'); $r .= "\n</div>"; } return $r; }
/** * Return an array of versions for the supplied article. * These are saved as category tags so we need to find the page_id from the article and anything in the categorylinks table. * Return a list with each element being a PonyDocsVersion object. * * @param boolean $reload If true, force reload from database; else used cache copy (if found). * @return array */ public function getProductVersions($reload = FALSE) { if (sizeof($this->versions) && !$reload) { return $this->versions; } $dbr = wfGetDB(DB_SLAVE); $revision = $this->pArticle->mRevision; $res = $dbr->select('categorylinks', 'cl_to', array('cl_to LIKE "V:%:%"', 'cl_type = "page"', "cl_sortkey = '" . $dbr->strencode(strtoupper($this->pTitle->getText())) . "'"), __METHOD__); $this->versions = array(); while ($row = $dbr->fetchObject($res)) { if (preg_match('/^v:(.*):(.*)/i', $row->cl_to, $match)) { $v = PonyDocsProductVersion::GetVersionByName($match[1], $match[2]); if ($v) { $this->versions[] = $v; } } } // Sort by the order on the versions admin page usort($this->versions, "PonyDocs_ProductVersionCmp"); return $this->versions; }
/** * @param Title $title Title object that this entry is for. * @param String $pubDate Publish date formattable by wfTimestamp. * @param Array $keywords list of (String) keywords * @param Mixed Boolean or Integer. Namespace containing comments page for entry. * True for the corresponding talk page of $title * False for none * An integer for the page name of $title in the specific namespace denoted by that integer. */ public function __construct($title, $pubDate, $keywords = '', $comment = true) { if (!$title || !$title instanceof Title) { // Paranoia throw new MWException('Invalid title object passed to FeedSMItem'); } $commentsURL = ''; if ($comment === true) { // The comment ns is this article's talk namespace. $commentsURL = $title->getTalkPage()->getFullUrl(); } elseif (is_int($comment)) { // There's a specific comments namespace. $commentsTitle = Title::makeTitle($comment, $title->getDBkey()); if ($commentsTitle) { $commentsURL = $commentsTitle->getFullUrl(); } } $this->keywords = $keywords; $this->titleObj = $title; parent::__construct($title->getText(), '', $title->getFullURL(), $pubDate, '', $commentsURL); }