/** * Get the Title object or URL to use for a redirect. We use Title * objects for same-wiki, non-special redirects and URLs for everything * else. * @param $rt Title Redirect target * @return mixed false, Title object of local target, or string with URL */ public function getRedirectURL($rt) { if ($rt) { if ($rt->getInterwiki() != '') { if ($rt->isLocal()) { // Offsite wikis need an HTTP redirect. // // This can be hard to reverse and may produce loops, // so they may be disabled in the site configuration. $source = $this->mTitle->getFullURL('redirect=no'); return $rt->getFullURL('rdfrom=' . urlencode($source)); } } else { if ($rt->getNamespace() == NS_SPECIAL) { // Gotta handle redirects to special pages differently: // Fill the HTTP response "Location" header and ignore // the rest of the page we're on. // // This can be hard to reverse, so they may be disabled. if ($rt->isSpecial('Userlogout')) { // rolleyes } else { return $rt->getFullURL(); } } return $rt; } } // No or invalid redirect return false; }
/** * Create a redirect that is also valid JavaScript * * @param Title $destination * @param string $text ignored * @return JavaScriptContent */ public function makeRedirectContent(Title $destination, $text = '') { // The parameters are passed as a string so the / is not url-encoded by wfArrayToCgi $url = $destination->getFullURL('action=raw&ctype=text/javascript', false, PROTO_RELATIVE); $class = $this->getContentClass(); return new $class('/* #REDIRECT */' . Xml::encodeJsCall('mw.loader.load', [$url])); }
/** * Look for the requested qrcode file. If we don't have the code on file, * first generate then publish it. */ public function showCode($label = false) { // Check for a provided label and use the page URL as default (but force protocol if requested) if ($label) { $this->_label = $label; // should we sanitize this? $this->_uploadComment = $label; } else { $url = parse_url($this->_title->getFullURL()); $url['scheme'] = $this->_scheme ? $this->_scheme : $url['scheme']; //$this->_label = http_build_url($url); // http_build_url is part of pecl_http >= 0.21.0 :( $this->_label = $url['scheme'] . '://' . $url['host'] . (isset($url['port']) ? $url['port'] : '') . (isset($url['path']) ? $url['path'] : '') . (isset($url['query']) ? '?' . $url['query'] : '') . (isset($url['fragment']) ? '#' . $url['fragment'] : ''); $this->_uploadComment = 'Encoded URL for ' . $this->_title->getFullText(); } // Use this page's title as part of the filename (Also regenerates qrcodes when the label changes). $this->_dstFileName = 'QR-' . md5($this->_label) . '.png'; $file = wfFindFile($this->_dstFileName); // Shortcut for RepoGroup::singleton()->findFile() if ($file && $file->isVisible()) { wfDebug("QrCode::showCode: Requested file " . $this->_dstFileName . " already exists. Displaying image.\n"); return $this->_displayImage($file); } else { wfDebug("QrCode::showCode: Requested file " . $this->_dstFileName . " is new and needs to be generated.\n"); $this->_generate(); return; } }
/** * Get the Title object or URL to use for a redirect. We use Title * objects for same-wiki, non-special redirects and URLs for everything * else. * @param $rt Title Redirect target * @return mixed false, Title object of local target, or string with URL */ public function getRedirectURL( $rt ) { if ( !$rt ) { return false; } if ( $rt->isExternal() ) { if ( $rt->isLocal() ) { // Offsite wikis need an HTTP redirect. // // This can be hard to reverse and may produce loops, // so they may be disabled in the site configuration. $source = $this->mTitle->getFullURL( 'redirect=no' ); return $rt->getFullURL( array( 'rdfrom' => $source ) ); } else { // External pages pages without "local" bit set are not valid // redirect targets return false; } } if ( $rt->isSpecialPage() ) { // Gotta handle redirects to special pages differently: // Fill the HTTP response "Location" header and ignore // the rest of the page we're on. // // Some pages are not valid targets if ( $rt->isValidRedirectTarget() ) { return $rt->getFullURL(); } else { return false; } } return $rt; }
/** * Create a redirect that is also valid CSS * * @param Title $destination * @param string $text ignored * @return CssContent */ public function makeRedirectContent(Title $destination, $text = '') { // The parameters are passed as a string so the / is not url-encoded by wfArrayToCgi $url = $destination->getFullURL('action=raw&ctype=text/css', false, PROTO_RELATIVE); $class = $this->getContentClass(); return new $class('/* #REDIRECT */@import ' . CSSMin::buildUrlValue($url) . ';'); }
/** * @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); }
/** * Appends a mobile view link to the desktop footer * @param Skin $sk * @param QuickTemplate $tpl * @param MobileContext $ctx * @param Title $title * @param WebRequest $req */ public static function desktopFooter($sk, $tpl, $ctx, $title, $req) { $footerlinks = $tpl->data['footerlinks']; $args = $req->getQueryValues(); // avoid title being set twice unset($args['title'], $args['useformat']); $args['mobileaction'] = 'toggle_view_mobile'; $mobileViewUrl = $title->getFullURL($args); $mobileViewUrl = $ctx->getMobileUrl($mobileViewUrl); $link = Html::element('a', array('href' => $mobileViewUrl, 'class' => 'noprint stopMobileRedirectToggle'), wfMessage('mobile-frontend-view')->text()); $tpl->set('mobileview', $link); $footerlinks['places'][] = 'mobileview'; $tpl->set('footerlinks', $footerlinks); }
/** * Attempt submission * @return bool false if output is done, true if the rest of the form should be displayed */ function attemptSave() { global $wgUser, $wgOut; $resultDetails = false; # Allow bots to exempt some edits from bot flagging $bot = $wgUser->isAllowed('bot') && $this->bot; $status = $this->internalAttemptSave($resultDetails, $bot); // FIXME: once the interface for internalAttemptSave() is made nicer, this should use the message in $status if ($status->value == self::AS_SUCCESS_UPDATE || $status->value == self::AS_SUCCESS_NEW_ARTICLE) { $this->didSave = true; } switch ($status->value) { case self::AS_HOOK_ERROR_EXPECTED: case self::AS_CONTENT_TOO_BIG: case self::AS_ARTICLE_WAS_DELETED: case self::AS_CONFLICT_DETECTED: case self::AS_SUMMARY_NEEDED: case self::AS_TEXTBOX_EMPTY: case self::AS_MAX_ARTICLE_SIZE_EXCEEDED: case self::AS_END: return true; case self::AS_HOOK_ERROR: case self::AS_FILTERING: return false; case self::AS_SUCCESS_NEW_ARTICLE: $query = $resultDetails['redirect'] ? 'redirect=no' : ''; $anchor = isset($resultDetails['sectionanchor']) ? $resultDetails['sectionanchor'] : ''; $wgOut->redirect($this->mTitle->getFullURL($query) . $anchor); return false; case self::AS_SUCCESS_UPDATE: $extraQuery = ''; $sectionanchor = $resultDetails['sectionanchor']; // Give extensions a chance to modify URL query on update wfRunHooks('ArticleUpdateBeforeRedirect', array($this->mArticle, &$sectionanchor, &$extraQuery)); if ($resultDetails['redirect']) { if ($extraQuery == '') { $extraQuery = 'redirect=no'; } else { $extraQuery = 'redirect=no&' . $extraQuery; } } $wgOut->redirect($this->mTitle->getFullURL($extraQuery) . $sectionanchor); return false; case self::AS_BLANK_ARTICLE: $wgOut->redirect($this->getContextTitle()->getFullURL()); return false; case self::AS_SPAM_ERROR: $this->spamPageWithContent($resultDetails['spam']); return false; case self::AS_BLOCKED_PAGE_FOR_USER: throw new UserBlockedError($wgUser->mBlock); case self::AS_IMAGE_REDIRECT_ANON: case self::AS_IMAGE_REDIRECT_LOGGED: throw new PermissionsError('upload'); case self::AS_READ_ONLY_PAGE_ANON: case self::AS_READ_ONLY_PAGE_LOGGED: throw new PermissionsError('edit'); case self::AS_READ_ONLY_PAGE: throw new ReadOnlyError(); case self::AS_RATE_LIMITED: throw new ThrottledError(); case self::AS_NO_CREATE_PERMISSION: $permission = $this->mTitle->isTalkPage() ? 'createtalk' : 'createpage'; throw new PermissionsError($permission); } return false; }
protected function getFooterAllChangesLink() { $articleTitle = $this->pageTitle->getText(); $url = $this->pageTitle->getFullURL(['action' => 'history']); return $this->getMessage('emailext-founder-footer-all-changes', $url, $articleTitle)->parse(); }
static function linkBegin($skin, Title $target, &$text, array &$attribs, &$query, &$options, &$ret) { if ($target->isExternal()) { $args = ''; $u = $target->getFullURL(); $link = $target->getPrefixedURL(); if ('' == $text) { $text = $target->getPrefixedText(); } $style = Linker::getInterwikiLinkAttributes($link, $text, 'extiw'); if ($text == 'RTENOTITLE') { // 2223 $text = $u = $link; $args .= '_fcknotitle="true" '; } $t = "<a {$args}href=\"{$u}\"{$style}>{$text}</a>"; wfProfileOut(__METHOD__); $ret = $t; return false; } return true; }
/** * Prepare a data to create a link element * * @param Title $title A target article's Title object * @param $params * @return array */ public static function getTitleLink(Title $title, $params) { $prefixedTitle = $title->getPrefixedText(); $data = ['text' => $prefixedTitle, 'url' => $title->getFullURL($params), 'title' => $prefixedTitle, 'classes' => '']; if (!$title->exists()) { $data['classes'] = 'new'; $data['title'] = wfMessage('red-link-title', $prefixedTitle)->escaped(); } return $data; }
/** * Handle status, such as after attempt save * * @param Status $status * @param array|bool $resultDetails * * @throws ErrorPageError * @return bool False, if output is done, true if rest of the form should be displayed */ private function handleStatus(Status $status, $resultDetails) { global $wgUser, $wgOut; /** * @todo FIXME: once the interface for internalAttemptSave() is made * nicer, this should use the message in $status */ if ($status->value == self::AS_SUCCESS_UPDATE || $status->value == self::AS_SUCCESS_NEW_ARTICLE) { $this->didSave = true; if (!$resultDetails['nullEdit']) { $this->setPostEditCookie($status->value); } } switch ($status->value) { case self::AS_HOOK_ERROR_EXPECTED: case self::AS_CONTENT_TOO_BIG: case self::AS_ARTICLE_WAS_DELETED: case self::AS_CONFLICT_DETECTED: case self::AS_SUMMARY_NEEDED: case self::AS_TEXTBOX_EMPTY: case self::AS_MAX_ARTICLE_SIZE_EXCEEDED: case self::AS_END: case self::AS_BLANK_ARTICLE: return true; case self::AS_HOOK_ERROR: return false; case self::AS_PARSE_ERROR: $wgOut->addWikiText('<div class="error">' . $status->getWikiText() . '</div>'); return true; case self::AS_SUCCESS_NEW_ARTICLE: $query = $resultDetails['redirect'] ? 'redirect=no' : ''; $anchor = isset($resultDetails['sectionanchor']) ? $resultDetails['sectionanchor'] : ''; $wgOut->redirect($this->mTitle->getFullURL($query) . $anchor); return false; case self::AS_SUCCESS_UPDATE: $extraQuery = ''; $sectionanchor = $resultDetails['sectionanchor']; // Give extensions a chance to modify URL query on update wfRunHooks('ArticleUpdateBeforeRedirect', array($this->mArticle, &$sectionanchor, &$extraQuery)); if ($resultDetails['redirect']) { if ($extraQuery == '') { $extraQuery = 'redirect=no'; } else { $extraQuery = 'redirect=no&' . $extraQuery; } } $wgOut->redirect($this->mTitle->getFullURL($extraQuery) . $sectionanchor); return false; case self::AS_SPAM_ERROR: $this->spamPageWithContent($resultDetails['spam']); return false; case self::AS_BLOCKED_PAGE_FOR_USER: throw new UserBlockedError($wgUser->getBlock()); case self::AS_IMAGE_REDIRECT_ANON: case self::AS_IMAGE_REDIRECT_LOGGED: throw new PermissionsError('upload'); case self::AS_READ_ONLY_PAGE_ANON: case self::AS_READ_ONLY_PAGE_LOGGED: throw new PermissionsError('edit'); case self::AS_READ_ONLY_PAGE: throw new ReadOnlyError(); case self::AS_RATE_LIMITED: throw new ThrottledError(); case self::AS_NO_CREATE_PERMISSION: $permission = $this->mTitle->isTalkPage() ? 'createtalk' : 'createpage'; throw new PermissionsError($permission); case self::AS_NO_CHANGE_CONTENT_MODEL: throw new PermissionsError('editcontentmodel'); default: // We don't recognize $status->value. The only way that can happen // is if an extension hook aborted from inside ArticleSave. // Render the status object into $this->hookError // FIXME this sucks, we should just use the Status object throughout $this->hookError = '<div class="error">' . $status->getWikitext() . '</div>'; return true; } }
/** * Get the rendered text for previewing. * @return string */ function getPreviewText() { wfProfileIn(__METHOD__); // Wikia change begin global $wgEnableSlowPagesBlacklistExt; if (!empty($wgEnableSlowPagesBlacklistExt)) { global $wgSlowPagesBlacklist; if (in_array($this->mTitle->getFullURL(), $wgSlowPagesBlacklist)) { wfProfileOut(__METHOD__); return sprintf('<div class="previewnote">%s</div>', wfMessage('slowpagesblacklist-preview-unavailable')->plain()); } } // Wikia change end global $wgOut, $wgUser, $wgParser, $wgRawHtml; // wikia change begin // TODO: remove? // @see https://trac.wikia-inc.com/changeset/6028 global $wgRequest; if ($wgUser->getGlobalPreference('showtoolbar') && !$wgUser->getGlobalPreference('riched_disable') && !$this->previewOnOpen()) { $oldTextBox1 = $this->textbox1; $this->importFormData($wgRequest); } // wikia change end if ($wgRawHtml && !$this->mTokenOk) { // Could be an offsite preview attempt. This is very unsafe if // HTML is enabled, as it could be an attack. $parsedNote = ''; if ($this->textbox1 !== '') { // Do not put big scary notice, if previewing the empty // string, which happens when you initially edit // a category page, due to automatic preview-on-open. $parsedNote = $wgOut->parse("<div class='previewnote'>" . wfMsg('session_fail_preview_html') . "</div>", true, true); } wfProfileOut(__METHOD__); return $parsedNote; } if ($this->mTriedSave && !$this->mTokenOk) { if ($this->mTokenOkExceptSuffix) { $note = wfMsg('token_suffix_mismatch'); } else { $note = wfMsg('session_fail_preview'); } } elseif ($this->incompleteForm) { $note = wfMsg('edit_form_incomplete'); } else { $note = wfMsg('previewnote'); } $parserOptions = ParserOptions::newFromUser($wgUser); $parserOptions->setEditSection(false); $parserOptions->setTidy(true); $parserOptions->setIsPreview(true); $parserOptions->setIsSectionPreview(!is_null($this->section) && $this->section !== ''); # don't parse non-wikitext pages, show message about preview # XXX: stupid php bug won't let us use $this->getContextTitle()->isCssJsSubpage() here -- This note has been there since r3530. Sure the bug was fixed time ago? if ($this->isCssJsSubpage || !$this->mTitle->isWikitextPage()) { if ($this->mTitle->isCssJsSubpage()) { $level = 'user'; } elseif ($this->mTitle->isCssOrJsPage()) { $level = 'site'; } else { $level = false; } # Used messages to make sure grep find them: # Messages: usercsspreview, userjspreview, sitecsspreview, sitejspreview if ($level) { if (preg_match("/\\.css\$/", $this->mTitle->getText())) { $previewtext = "<div id='mw-{$level}csspreview'>\n" . wfMsg("{$level}csspreview") . "\n</div>"; $class = "mw-code mw-css"; } elseif (preg_match("/\\.js\$/", $this->mTitle->getText())) { $previewtext = "<div id='mw-{$level}jspreview'>\n" . wfMsg("{$level}jspreview") . "\n</div>"; $class = "mw-code mw-js"; } else { throw new MWException('A CSS/JS (sub)page but which is not css nor js!'); } } $parserOutput = $wgParser->parse($previewtext, $this->mTitle, $parserOptions); $previewHTML = $parserOutput->mText; $previewHTML .= "<pre class=\"{$class}\" dir=\"ltr\">\n" . htmlspecialchars($this->textbox1) . "\n</pre>\n"; } else { $rt = Title::newFromRedirectArray($this->textbox1); if ($rt) { $previewHTML = $this->mArticle->viewRedirect($rt, false); } else { $toparse = $this->textbox1; # If we're adding a comment, we need to show the # summary as the headline if ($this->section == "new" && $this->summary != "") { $toparse = wfMsgForContent('newsectionheaderdefaultlevel', $this->summary) . "\n\n" . $toparse; } wfRunHooks('EditPageGetPreviewText', array($this, &$toparse)); $parserOptions->enableLimitReport(); $toparse = $wgParser->preSaveTransform($toparse, $this->mTitle, $wgUser, $parserOptions); $parserOutput = $wgParser->parse($toparse, $this->mTitle, $parserOptions); $previewHTML = $parserOutput->getText(); $this->mParserOutput = $parserOutput; $wgOut->addParserOutputNoText($parserOutput); if (count($parserOutput->getWarnings())) { $note .= "\n\n" . implode("\n\n", $parserOutput->getWarnings()); } } } if ($this->isConflict) { $conflict = '<h2 id="mw-previewconflict">' . htmlspecialchars(wfMsg('previewconflict')) . "</h2>\n"; } else { $conflict = '<hr />'; } // wikia change begin // BugId:5451 wfRunHooks('EditPageGetPreviewNote', array($this, &$note)); // wikia change end $previewhead = "<div class='previewnote'>\n" . '<h2 id="mw-previewheader">' . htmlspecialchars(wfMsg('preview')) . "</h2>" . $wgOut->parse($note, true, true) . $conflict . "</div>\n"; $pageLang = $this->mTitle->getPageLanguage(); $attribs = array('lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir(), 'class' => 'mw-content-' . $pageLang->getDir()); $previewHTML = Html::rawElement('div', $attribs, $previewHTML); wfProfileOut(__METHOD__); return $previewhead . $previewHTML . $this->previewTextAfterContent; }
protected function getFooterMessages() { $unwatchUrl = $this->title->getFullURL(['action' => 'unwatch']); $footerMessages = [$this->getMessage('emailext-unfollow-text', $unwatchUrl, $this->title->getPrefixedText())->parse()]; return array_merge($footerMessages, parent::getFooterMessages()); }
protected function getFooterMessages() { $footerMessages = [$this->getMessage('emailext-unfollow-text', $this->categoryPage->getFullURL('action=unwatch'), $this->categoryPage->getPrefixedText())->parse()]; return array_merge($footerMessages, parent::getFooterMessages()); }
/** * generateTimeMapText * * Generates Time Map text as per examples in Memento TimeMap RFC * @see http://www.mementoweb.org/guide/rfc/ID/ * * @param array $data array with entries containing the keys rev_id and rev_timestamp * @param string $timeMapURI used to construct self TimeMap URI relation * @param Title $titleObj the Title Object for this TimeMap * @param array $pagedTimeMapEntries array of arrays, each entry containing * the keys 'uri', 'from', and 'until' referring to the URI of * the TimeMap and its from and until dates * * @returns string formatted timemap */ public function generateTimeMapText($data, $timeMapURI, Title $titleObj, $pagedTimeMapEntries = array()) { $outputArray = array(); $latesturi = $titleObj->getFullURL(); $title = $this->getFullNamespacePageTitle($this->article->getTitle()); $timegateuri = $this->getTimeGateURI($title); $latestEntry = $this->constructLinkRelationHeader($latesturi, 'original latest-version'); $timegateEntry = $this->constructLinkRelationHeader($timegateuri, 'timegate'); $from = $data[count($data) - 1]['rev_timestamp']; $until = $data[0]['rev_timestamp']; // we can't really use $this->constructTimeMapLinkHeaderWithBounds // because that method creates an entry for a "full", or "starter" // TimeMap and generateTimeMapText might be called by a function // that is working with a pivot TimeMap $timemapEntry = '<' . $timeMapURI . '>; rel="self"; type="application/link-format"; ' . 'from="' . $from . '"; until="' . $until . '"'; $outputArray[] = $timemapEntry; foreach ($pagedTimeMapEntries as &$pagedTimeMap) { // TODO: make this a function $pagedTimemapEntry = '<' . $pagedTimeMap['uri'] . '>; rel="timemap"; type="application/link-format";' . 'from="' . $pagedTimeMap['from'] . '"; ' . 'until="' . $pagedTimeMap['until'] . '"'; $outputArray[] = $pagedTimemapEntry; } $outputArray[] = $timegateEntry; $outputArray[] = $latestEntry; for ($i = count($data) - 1; $i >= 0; $i--) { $output = ""; $datum = $data[$i]; $uri = $titleObj->getFullURL(array("oldid" => $datum['rev_id'])); $output = $this->constructMementoLinkHeaderRelationEntry($uri, $datum['rev_timestamp'], "memento"); $outputArray[] = $output; } // the original implementation of TimeMap for Mediawiki used ,<SP><LF> // to separate the entries and added a \n at the end $timemap = implode(",\n", $outputArray); return $timemap; }
/** * Generates a diff link. Used when the full diff is not wanted for example * when $wgFeedDiffCutoff is 0. * * @param Title $title Title object: used to generate the diff URL * @param int $newid Newid for this diff * @param int|null $oldid Oldid for the diff. Null means it is a new article * @return string */ protected static function getDiffLink(Title $title, $newid, $oldid = null) { $queryParameters = array('diff' => $newid); if ($oldid != null) { $queryParameters['oldid'] = $oldid; } $diffUrl = $title->getFullURL($queryParameters); $diffLink = Html::element('a', array('href' => $diffUrl), wfMessage('showdiff')->inContentLanguage()->text()); return $diffLink; }
/** * Get link to current revision of new title because it's first revision of this title * * @return String */ protected function getArticleLinkText() { return $this->getMessage('emailext-watchedpage-article-link-text', $this->newTitle->getFullURL(['diff' => 0, 'oldid' => $this->currentRevId]), $this->newTitle->getPrefixedText())->parse(); }
/** * Prepare the content for the 'last edited' message, e.g. 'Last edited on 30 August * 2013, at 23:31'. This message is different for the main page since main page * content is typically transcuded rather than edited directly. * @param Title $title The Title object of the page being viewed * @return array */ protected function getHistoryLink(Title $title) { $user = $this->getUser(); $isMainPage = $title->isMainPage(); $mp = new MobilePage($this->getTitle(), false); $timestamp = $mp->getLatestTimestamp(); // Main pages tend to include transclusions (see bug 51924) if ($isMainPage) { $lastModified = $this->msg('mobile-frontend-history')->plain(); } else { $lastModified = $this->msg('mobile-frontend-last-modified-date', $this->getLanguage()->userDate($timestamp, $user), $this->getLanguage()->userTime($timestamp, $user))->parse(); } $historyUrl = $this->mobileContext->getMobileUrl($title->getFullURL('action=history')); $edit = $mp->getLatestEdit(); $link = array('data-timestamp' => $isMainPage ? '' : $edit['timestamp'], 'href' => $historyUrl, 'text' => $lastModified, 'data-user-name' => $edit['name'], 'data-user-gender' => $edit['gender']); $link['href'] = SpecialPage::getTitleFor('History', $title)->getLocalURL(); return $link; }
/** * Gets error HTML for attempted NS_TOPIC deletion using core interface * * @param Title $title Topic title they are attempting to delete * @return string Error html */ protected static function getTopicDeletionError(Title $title) { $error = wfMessage('flow-error-core-topic-deletion', $title->getFullURL())->parse(); $wrappedError = Html::rawElement('span', array('class' => 'plainlinks'), $error); return $wrappedError; }
private function titleEntry(Title $title, $date, $priority, $includeVideo = false) { return "\t<url>\n" . "\t\t<loc>{$title->getFullURL()}</loc>\n" . "\t\t<lastmod>{$date}</lastmod>\n" . "\t\t<priority>{$priority}</priority>\n" . ($includeVideo ? $this->videoEntry($title) : "") . "\t</url>\n"; }
/** * Constructor for a single item in the vcard. Requires the URI of the item. */ public function __construct(Title $t, $prefix, $firstname, $lastname, $additionalname, $suffix, $fullname, $tels, $addresses, $emails, $birthday, $jobtitle, $role, $organization, $department, $category, $url, $note) { $this->uri = $t->getFullURL(); $this->url = $url; // read fullname or guess it in a simple way from other names that are given if ($fullname != '') { $this->label = $fullname; } elseif ($firstname . $lastname != '') { $this->label = $firstname . ($firstname != '' && $lastname != '' ? ' ' : '') . $lastname; } else { $this->label = $t->getText(); } $this->label = SRFVCardEntry::vCardEscape($this->label); // read firstname and lastname, or guess it from other names that are given if ($firstname . $lastname == '') { // guessing needed $nameparts = explode(' ', $this->label); // Accepted forms for guessing: // "Lastname" // "Firstname Lastname" // "Firstname <Additionalnames> Lastname" $this->lastname = SRFvCardEntry::vCardEscape(array_pop($nameparts)); if (count($nameparts) > 0) { $this->firstname = SRFvCardEntry::vCardEscape(array_shift($nameparts)); } foreach ($nameparts as $name) { $this->additionalname .= ($this->additionalname != '' ? ',' : '') . SRFvCardEntry::vCardEscape($name); } } else { $this->firstname = SRFvCardEntry::vCardEscape($firstname); $this->lastname = SRFvCardEntry::vCardEscape($lastname); } if ($additionalname != '') { $this->additionalname = $additionalname; } // no escape, can be a value list // ^ overwrite above guessing in that case $this->prefix = SRFvCardEntry::vCardEscape($prefix); $this->suffix = SRFvCardEntry::vCardEscape($suffix); $this->tels = $tels; $this->addresses = $addresses; $this->emails = $emails; $this->birthday = $birthday; $this->title = SRFvCardEntry::vCardEscape($jobtitle); $this->role = SRFvCardEntry::vCardEscape($role); $this->organization = SRFvCardEntry::vCardEscape($organization); $this->department = SRFvCardEntry::vCardEscape($department); $this->category = $category; // allow non-escaped "," in here for making a list of categories $this->note = SRFvCardEntry::vCardEscape($note); $article = new Article($t); $this->dtstamp = $article->getTimestamp(); }
/** * Constructor for a single item in the feed. Requires the URI of the item. */ public function __construct(Title $t, $c, $d) { $this->title = $t; $this->uri = $t->getFullURL(); $this->label = $t->getText(); $article = null; if (count($c) == 0) { $article = new Article($t); $this->creator = array(); $this->creator[] = $article->getUserText(); } else { $this->creator = $c; } $this->date = array(); if (count($d) == 0) { if (is_null($article)) { $article = new Article($t); } $this->date[] = date("c", strtotime($article->getTimestamp())); } else { foreach ($d as $date) { $this->date[] = $date; } } // get content if ($t->getNamespace() == NS_MAIN) { $this->articlename = ':' . $t->getDBkey(); } else { $this->articlename = $t->getPrefixedDBKey(); } }
protected function getPostListingLink() { $url = $this->pageTitle->getFullURL(); $name = $this->pageTitle->getText(); return $this->getMessage('emailext-blogpost-view-all', $url, $name)->parse(); }
protected function getCommentSectionLink() { $url = $this->pageTitle->getFullURL('#WikiaArticleComments'); return $this->getMessage('emailext-comment-view-all', $url)->parse(); }
/** * Transclude an interwiki link. * * @param Title $title * @param string $action * * @return string */ public function interwikiTransclude($title, $action) { global $wgEnableScaryTranscluding; if (!$wgEnableScaryTranscluding) { return wfMessage('scarytranscludedisabled')->inContentLanguage()->text(); } $url = $title->getFullURL(array('action' => $action)); if (strlen($url) > 255) { return wfMessage('scarytranscludetoolong')->inContentLanguage()->text(); } return $this->fetchScaryTemplateMaybeFromCache($url); }
/** * Set the suggested title * @param Title|null $title */ public function setSuggestedTitle(Title $title = null) { $this->suggestedTitle = $title; if ($title !== null) { $this->url = wfExpandUrl($title->getFullURL(), PROTO_CURRENT); } }
/** * Prepare the content for the 'last edited' message, e.g. 'Last edited on 30 August * 2013, at 23:31'. This message is different for the main page since main page * content is typically transcuded rather than edited directly. * @param Title $title The Title object of the page being viewed * @return array */ protected function getHistoryLink(Title $title) { $user = $this->getUser(); $isMainPage = $title->isMainPage(); // add last modified timestamp $revId = $this->getRevisionId(); $timestamp = Revision::getTimestampFromId($this->getTitle(), $revId); // Main pages tend to include transclusions (see bug 51924) if ($isMainPage) { $lastModified = $this->msg('mobile-frontend-history')->plain(); } else { $lastModified = $this->msg('mobile-frontend-last-modified-date', $this->getLanguage()->userDate($timestamp, $user), $this->getLanguage()->userTime($timestamp, $user))->parse(); } $unixTimestamp = wfTimestamp(TS_UNIX, $timestamp); $historyUrl = $this->mobileContext->getMobileUrl($title->getFullURL('action=history')); $link = array('data-timestamp' => $isMainPage ? '' : $unixTimestamp, 'href' => $historyUrl, 'text' => $lastModified, 'data-user-name' => '', 'data-user-gender' => 'unknown'); $rev = Revision::newFromId($this->getRevisionId()); if ($rev) { $userId = $rev->getUser(); if ($userId) { $revUser = User::newFromId($userId); $revUser->load(User::READ_NORMAL); $link = array_merge($link, array('data-user-name' => $revUser->getName(), 'data-user-gender' => $revUser->getOption('gender'))); } } $link['href'] = SpecialPage::getTitleFor('History', $title)->getLocalURL(); return $link; }
/** * Used when generating internal and interwiki links in Linker::link(), * just before the function returns a value. * @see https://www.mediawiki.org/wiki/Manual:Hooks/LinkEnd * * @since 0.1 * * @param $skin * @param Title $target * @param array $options * @param string $text * @param array $attribs * @param $ret * * @return true */ public static function onLinkEnd($skin, Title $target, array $options, &$text, array &$attribs, &$ret) { if ($GLOBALS['wgContestEmailParse']) { $attribs['href'] = $target->getFullURL(); } return true; }