function wfElggWatchlistDisplayForm($action, &$wgArticle)
{
    global $wgOut;
    if ($action == 'myact') {
        $title = $wgArticle->getTitle();
        //$page = $title->getIndexTitle();
        $page = wfUrlencode($title->getPrefixedDBkey());
        $ts = time();
        $elgg_url = ELGG_URL;
        $html = <<<END
\t\t\t<script type="text/javascript">

\t\t\t\$(document).ready(function()
\t\t\t\t{
\t\t\t\t\t\$('#elggwiki_watch_form').load("{$elgg_url}mod/mediawiki/get_watch_form_groups.php?page={$page}&ts={$ts}");
\t\t\t\t}
\t\t\t);

\t\t\t</script>

\t\t\t<div id="elggwiki_watch_form"></div>
END;
        //$wgOut->addHTML( 'The page name is ' . $title->getText() . ' and you are ' . $wgArticle->getUserText() );
        $wgOut->addHTML($html);
    }
    return false;
}
Example #2
0
function wfSpecialCiteNav(&$skintemplate, &$nav_urls, &$oldid, &$revid)
{
    if ($skintemplate->mTitle->isContentPage() && $revid !== 0) {
        $nav_urls['cite'] = array('text' => wfMsg('cite_article_link'), 'href' => $skintemplate->makeSpecialUrl('Cite', "page=" . wfUrlencode("{$skintemplate->thispage}") . "&id={$revid}"));
    }
    return true;
}
Example #3
0
function efTSPollRender( $input, $args, $parser ) {

	// Control if the "id" is set. If not, it output a error
  if ( isset( $args['id'] ) && $args['id'] != "" ) {
		$id = wfUrlencode( $args['id'] );
	} else {
		
		return wfMsg( 'tspoll-id-error' );
	}
  
  // Control if "dev" is set. If not, it use the normal skript, else, it use the dev skript
  if ( isset( $args['dev'] ) && $args['dev'] == "1" ) { // If the arrgument dev is given, use the TSPoll-Dev-Version
      $get_server = Http::get( 'http://toolserver.org/~jan/poll/dev/main.php?page=wiki_output&id='.$id );
  } else { // sonst die normale Version verwenden
      $get_server = Http::get( 'http://toolserver.org/~jan/poll/main.php?page=wiki_output&id='.$id );
  }
 
  // If $get_server is empty it output a error
	if ( $get_server != '' ) {
		return $get_server;
	}
	else {
		
		return wfMsg( 'tspoll-fetch-error' );
	}
}
Example #4
0
/**
 * @param $skintemplate SkinTemplate
 * @param $nav_urls
 * @param $oldid
 * @param $revid
 * @return bool
 */
function wfSpecialCiteNav(&$skintemplate, &$nav_urls, &$oldid, &$revid)
{
    // check whether we’re in the right namespace, the $revid has the correct type and is not empty
    // (what would mean that the current page doesn’t exist)
    if ($skintemplate->getTitle()->isContentPage() && $revid !== 0 && !empty($revid)) {
        $nav_urls['cite'] = array('args' => "page=" . wfUrlencode("{$skintemplate->thispage}") . "&id={$revid}");
    }
    return true;
}
 private function _redirectToCreateSP($listName = null)
 {
     global $wgOut;
     $specialPageTitle = Title::newFromText('CreateTopList', NS_SPECIAL);
     $url = $specialPageTitle->getFullUrl();
     if (!empty($listName)) {
         $url .= '/' . wfUrlencode($listName);
     }
     $wgOut->redirect($url);
 }
Example #6
0
 function buildContentActionUrls()
 {
     global $wgKiwixStaticDump;
     $content_actions = array();
     $nskey = $this->getNameSpaceKey();
     if (isset($wgKiwixStaticDump)) {
         $content_actions['current'] = array('text' => wfMsg('currentrev'), 'href' => str_replace('$1', wfUrlencode($this->mTitle->getPrefixedDBkey()), $wgKiwixStaticDump->oldArticlePath), 'class' => false);
     }
     return $content_actions;
 }
function efNamepacePathsGetURL($title, &$url)
{
    global $wgNamespacePaths;
    // Ensure that the context of this url is one we'd do article path replacements in
    $ns = $title->getNamespace();
    if (array_key_exists($ns, $wgNamespacePaths)) {
        $url = str_replace('$1', wfUrlencode($title->getDBkey()), $wgNamespacePaths[$ns]);
    }
    return true;
}
 /**
  * Add the language action to the list of content actions
  */
 public static function addLanguageAction(&$content_actions)
 {
     global $wgTitle;
     if ($wgTitle->getArticleId()) {
         $specialTitle = Title::newFromText("Special:MultiLanguageManager");
         if (get_class($specialTitle) != "Title") {
             return;
         }
         $content_actions['language'] = array('class' => false, 'text' => wfMsg('multilanguagemanager_language'), 'href' => $specialTitle->getLocalUrl("cible=" . wfUrlencode($wgTitle->getPrefixedDBkey())));
     }
 }
Example #9
0
/**
 * 	Constructor for Special:Emailuser.
 */
function wfSpecialEmailuser($par)
{
    global $wgRequest, $wgUser, $wgOut;
    if (!EmailUserForm::userEmailEnabled()) {
        $wgOut->showErrorPage('nosuchspecialpage', 'nospecialpagetext');
        return;
    }
    $action = $wgRequest->getVal('action');
    $target = isset($par) ? $par : $wgRequest->getVal('target');
    $targetUser = EmailUserForm::validateEmailTarget($target);
    if (!$targetUser instanceof User) {
        $wgOut->showErrorPage($targetUser . 'title', $targetUser . 'text');
        return;
    }
    $form = new EmailUserForm($targetUser, $wgRequest->getText('wpText'), $wgRequest->getText('wpSubject'), $wgRequest->getBool('wpCCMe'));
    if ($action == 'success') {
        $form->showSuccess();
        return;
    }
    $error = EmailUserForm::getPermissionsError($wgUser, $wgRequest->getVal('wpEditToken'));
    if ($error) {
        switch ($error) {
            case 'blockedemailuser':
                $wgOut->blockedPage();
                return;
            case 'actionthrottledtext':
                $wgOut->rateLimited();
                return;
            case 'sessionfailure':
                $form->showForm();
                return;
            case 'mailnologin':
                $wgOut->showErrorPage('mailnologin', 'mailnologintext');
                return;
            default:
                // It's a hook error
                list($title, $msg, $params) = $error;
                $wgOut->showErrorPage($title, $msg, $params);
                return;
        }
    }
    if ("submit" == $action && $wgRequest->wasPosted()) {
        $result = $form->doSubmit();
        if (!is_null($result)) {
            $wgOut->addHTML(wfMsg("usermailererror") . ' ' . htmlspecialchars($result->getMessage()));
        } else {
            $titleObj = SpecialPage::getTitleFor("Emailuser");
            $encTarget = wfUrlencode($form->getTarget()->getName());
            $wgOut->redirect($titleObj->getFullURL("target={$encTarget}&action=success"));
        }
    } else {
        $form->showForm();
    }
}
Example #10
0
 function buildContentActionUrls()
 {
     global $wgHTMLDump;
     $content_actions = array();
     $nskey = $this->getNameSpaceKey();
     $content_actions[$nskey] = $this->tabAction($this->mTitle->getSubjectPage(), $nskey, !$this->mTitle->isTalkPage());
     $content_actions['talk'] = $this->tabAction($this->mTitle->getTalkPage(), 'talk', $this->mTitle->isTalkPage(), '', true);
     if (isset($wgHTMLDump)) {
         $content_actions['current'] = array('text' => wfMsg('currentrev'), 'href' => str_replace('$1', wfUrlencode($this->mTitle->getPrefixedDBkey()), $wgHTMLDump->oldArticlePath), 'class' => false);
     }
     return $content_actions;
 }
Example #11
0
	/**
	 * Creates the name of the page that appears in the URL;
	 * this method is necessary because Title::getPartialURL(), for
	 * some reason, doesn't include the namespace
	 */
	public static function titleURLString( $title ) {
		$namespace = wfUrlencode( $title->getNsText() );
		if ( $namespace !== '' ) {
			$namespace .= ':';
		}
		if ( MWNamespace::isCapitalized( $title->getNamespace() ) ) {
			global $wgContLang;
			return $namespace . $wgContLang->ucfirst( $title->getPartialURL() );
		} else {
			return $namespace . $title->getPartialURL();
		}
	}
 /**
  * @since 2.2
  *
  * @param DIWikiPage $diWikiPage
  *
  * @return string
  */
 public static function encodePage(DIWikiPage $diWikiPage)
 {
     $localName = '';
     if ($diWikiPage->getInterwiki() !== '') {
         $localName = $diWikiPage->getInterwiki() . ':';
     }
     if ($diWikiPage->getNamespace() !== 0) {
         $localName .= str_replace(' ', '_', $GLOBALS['wgContLang']->getNSText($diWikiPage->getNamespace())) . ':' . $diWikiPage->getDBkey();
     } else {
         $localName .= $diWikiPage->getDBkey();
     }
     return self::encodeUri(wfUrlencode($localName));
 }
Example #13
0
 /**
  * Internal helper that actually run the test.
  * Called by the public methods testEncodingUrlWith...()
  *
  */
 private function verifyEncodingFor($server, $input, $expectations)
 {
     $expected = $this->extractExpect($server, $expectations);
     // save up global
     $old = isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : null;
     $_SERVER['SERVER_SOFTWARE'] = $server;
     wfUrlencode(null);
     // do the requested test
     $this->assertEquals($expected, wfUrlencode($input), "Encoding '{$input}' for server '{$server}' should be '{$expected}'");
     // restore global
     if ($old === null) {
         unset($_SERVER['SERVER_SOFTWARE']);
     } else {
         $_SERVER['SERVER_SOFTWARE'] = $old;
     }
     wfUrlencode(null);
 }
Example #14
0
/**
 * wfElggNotifyCurlUpdate 
 * 
 * @param object $article 
 * @param object $user 
 * @param bool $isMinor 
 * @param bool $isWatch 
 * @return bool
 */
function wfElggNotifyCurlUpdate($article, $user, $text, $summary, $isMinor, $isWatch, $section, $flags, $revision)
{
    if ($isMinor) {
        $editStatus = 'minor';
    } else {
        $editStatus = 'major';
    }
    $title = $article->getTitle();
    $page = wfUrlencode($title->getPrefixedDBkey());
    $username = $user->mName;
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, ELGG_URL . "mod/mediawiki/edit_notify.php");
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, "page={$page}&mediawiki_username={$username}&edit_status={$editStatus}");
    curl_exec($ch);
    curl_close($ch);
    return true;
}
 /**
  * Returns the (partial) URL for the given page (including any section identifier).
  *
  * @param TitleValue $page The link's target
  * @param array $params any additional URL parameters.
  *
  * @return string
  */
 public function getPageUrl(TitleValue $page, $params = array())
 {
     //TODO: move the code from Linker::linkUrl here!
     //The below is just a rough estimation!
     $name = $this->formatter->getPrefixedText($page);
     $name = str_replace(' ', '_', $name);
     $name = wfUrlencode($name);
     $url = $this->baseUrl . $name;
     if ($params) {
         $separator = strpos($url, '?') ? '&' : '?';
         $url .= $separator . wfArrayToCgi($params);
     }
     $fragment = $page->getFragment();
     if ($fragment !== '') {
         $url = $url . '#' . wfUrlencode($fragment);
     }
     return $url;
 }
 /**
  * Displays form to create wiki
  */
 protected function _executeCreate($wgFarmer, $wiki)
 {
     global $wgOut, $wgUser, $wgRequest;
     if (!$wgFarmer->getActiveWiki()->isDefaultWiki()) {
         $wgOut->wrapWikiMsg('== $1 ==', 'farmer-notavailable');
         $wgOut->addWikiMsg('farmer-notavailable-text');
         return;
     }
     if (!MediaWikiFarmer::userCanCreateWiki($wgUser, $wiki)) {
         $wgOut->addWikiMsg('farmercantcreatewikis');
         return;
     }
     $name = MediaWikiFarmer_Wiki::sanitizeName($wgRequest->getVal('wpName', $wiki));
     $title = MediaWikiFarmer_Wiki::sanitizeTitle($wgRequest->getVal('wpTitle'));
     $description = $wgRequest->getVal('wpDescription', '');
     $reason = $wgRequest->getVal('wpReason');
     $action = $this->getTitle('create')->escapeLocalURL();
     // if something was POST'd
     if ($wgRequest->wasPosted()) {
         // we create the wiki if the user pressed 'Confirm'
         if ($wgRequest->getCheck('wpConfirm')) {
             $wikiObj = MediaWikiFarmer_Wiki::newFromParams($name, $title, $description, $wgUser->getName());
             $wikiObj->create();
             $log = new LogPage('farmer');
             $log->addEntry('create', $this->getTitle(), $reason, array($name));
             $wgOut->wrapWikiMsg('== $1 ==', 'farmer-wikicreated');
             $wgOut->addWikiMsg('farmer-wikicreated-text', $wikiObj->getUrl(wfUrlencode(wfMessage('mainpage')->inContentLanguage()->useDatabase(false)->plain())));
             $wgOut->addWikiMsg('farmer-default', '[[' . $title . ':Special:Farmer|Special:Farmer]]');
             return;
         }
         if ($name && $title && $description) {
             $wiki = new MediaWikiFarmer_Wiki($name);
             if ($wiki->exists() || $wiki->databaseExists()) {
                 $wgOut->wrapWikiMsg("== \$1 ==\n\n\$2", 'farmer-wikiexists', array('farmer-wikiexists-text', $name));
                 return;
             }
             $url = $wiki->getUrl('');
             $wgOut->wrapWikiMsg('== $1 ==', 'farmer-confirmsetting');
             $wgOut->addHtml(Xml::openElement('table', array('class' => 'wikitable')) . "\n" . Xml::tags('tr', array(), Xml::tags('th', array(), wfMsgExt('farmer-confirmsetting-name', 'parseinline')) . Xml::element('td', array(), $name)) . "\n" . Xml::tags('tr', array(), Xml::tags('th', array(), wfMsgExt('farmer-confirmsetting-title', 'parseinline')) . Xml::element('td', array(), $title)) . "\n" . Xml::tags('tr', array(), Xml::tags('th', array(), wfMsgExt('farmer-confirmsetting-description', 'parseinline')) . Xml::element('td', array(), $description)) . "\n" . Xml::tags('tr', array(), Xml::tags('th', array(), wfMsgExt('farmer-confirmsetting-reason', 'parseinline')) . Xml::element('td', array(), $reason)) . "\n" . Xml::closeElement('table'));
             $wgOut->addWikiMsg('farmer-confirmsetting-text', $name, $title, $url);
             $nameaccount = htmlspecialchars($name);
             $nametitle = htmlspecialchars($title);
             $namedescript = htmlspecialchars($description);
             $confirmaccount = wfMsgHtml('farmer-button-confirm');
             $wgOut->addHTML("\n\n<form id=\"farmercreate2\" method=\"post\" action=\"{$action}\">\n<input type=\"hidden\" name=\"wpName\" value=\"{$nameaccount}\" />\n<input type=\"hidden\" name=\"wpTitle\" value=\"{$nametitle}\" />\n<input type=\"hidden\" name=\"wpDescription\" value=\"{$namedescript}\" />\n<input type=\"hidden\" name=\"wpReason\" value=\"{$reason}\" />\n<input type=\"submit\" name=\"wpConfirm\" value=\"{$confirmaccount}\" />\n</form>");
             return;
         }
     }
     if ($wiki && !$name) {
         $name = $wiki;
     }
     $wgOut->wrapWikiMsg("== \$1 ==\n\$2\n== \$3 ==\n\$4\n\$5\n\$6", 'farmer-createwiki-form-title', 'farmer-createwiki-form-text1', 'farmer-createwiki-form-help', 'farmer-createwiki-form-text2', 'farmer-createwiki-form-text3', 'farmer-createwiki-form-text4');
     $formURL = wfMsgHTML('farmercreateurl');
     $formSitename = wfMsgHTML('farmercreatesitename');
     $formNextStep = wfMsgHTML('farmercreatenextstep');
     $token = htmlspecialchars($wgUser->editToken());
     $wgOut->addHTML(Xml::openElement('form', array('method' => 'post', 'action' => $action)) . "\n" . Xml::buildForm(array('farmer-createwiki-user' => Xml::element('b', array(), $wgUser->getName()), 'farmer-createwiki-name' => Xml::input('wpName', 20, $name), 'farmer-createwiki-title' => Xml::input('wpTitle', 20, $title), 'farmer-createwiki-description' => Xml::textarea('wpDescription', $description), 'farmer-createwiki-reason' => Xml::input('wpReason', 20, $reason)), 'farmer-button-submit') . "\n" . Html::Hidden('token', $token) . "\n" . Xml::closeElement('form'));
 }
 public static function speciale($parser, $text)
 {
     return wfUrlencode(str_replace(' ', '_', self::special($parser, $text)));
 }
Example #18
0
 /**
  * Return value of a magic variable (like PAGENAME)
  *
  * @private
  *
  * @param $index integer
  * @param bool|\PPFrame $frame
  *
  * @throws MWException
  * @return string
  */
 function getVariableValue($index, $frame = false)
 {
     global $wgContLang, $wgSitename, $wgServer;
     global $wgArticlePath, $wgScriptPath, $wgStylePath;
     if (is_null($this->mTitle)) {
         // If no title set, bad things are going to happen
         // later. Title should always be set since this
         // should only be called in the middle of a parse
         // operation (but the unit-tests do funky stuff)
         throw new MWException(__METHOD__ . ' Should only be ' . ' called while parsing (no title set)');
     }
     /**
      * Some of these require message or data lookups and can be
      * expensive to check many times.
      */
     if (wfRunHooks('ParserGetVariableValueVarCache', array(&$this, &$this->mVarCache))) {
         if (isset($this->mVarCache[$index])) {
             return $this->mVarCache[$index];
         }
     }
     $ts = wfTimestamp(TS_UNIX, $this->mOptions->getTimestamp());
     wfRunHooks('ParserGetVariableValueTs', array(&$this, &$ts));
     $pageLang = $this->getFunctionLang();
     switch ($index) {
         case 'currentmonth':
             $value = $pageLang->formatNum(MWTimestamp::getInstance($ts)->format('m'));
             break;
         case 'currentmonth1':
             $value = $pageLang->formatNum(MWTimestamp::getInstance($ts)->format('n'));
             break;
         case 'currentmonthname':
             $value = $pageLang->getMonthName(MWTimestamp::getInstance($ts)->format('n'));
             break;
         case 'currentmonthnamegen':
             $value = $pageLang->getMonthNameGen(MWTimestamp::getInstance($ts)->format('n'));
             break;
         case 'currentmonthabbrev':
             $value = $pageLang->getMonthAbbreviation(MWTimestamp::getInstance($ts)->format('n'));
             break;
         case 'currentday':
             $value = $pageLang->formatNum(MWTimestamp::getInstance($ts)->format('j'));
             break;
         case 'currentday2':
             $value = $pageLang->formatNum(MWTimestamp::getInstance($ts)->format('d'));
             break;
         case 'localmonth':
             $value = $pageLang->formatNum(MWTimestamp::getLocalInstance($ts)->format('m'));
             break;
         case 'localmonth1':
             $value = $pageLang->formatNum(MWTimestamp::getLocalInstance($ts)->format('n'));
             break;
         case 'localmonthname':
             $value = $pageLang->getMonthName(MWTimestamp::getLocalInstance($ts)->format('n'));
             break;
         case 'localmonthnamegen':
             $value = $pageLang->getMonthNameGen(MWTimestamp::getLocalInstance($ts)->format('n'));
             break;
         case 'localmonthabbrev':
             $value = $pageLang->getMonthAbbreviation(MWTimestamp::getLocalInstance($ts)->format('n'));
             break;
         case 'localday':
             $value = $pageLang->formatNum(MWTimestamp::getLocalInstance($ts)->format('j'));
             break;
         case 'localday2':
             $value = $pageLang->formatNum(MWTimestamp::getLocalInstance($ts)->format('d'));
             break;
         case 'pagename':
             $value = wfEscapeWikiText($this->mTitle->getText());
             break;
         case 'pagenamee':
             $value = wfEscapeWikiText($this->mTitle->getPartialURL());
             break;
         case 'fullpagename':
             $value = wfEscapeWikiText($this->mTitle->getPrefixedText());
             break;
         case 'fullpagenamee':
             $value = wfEscapeWikiText($this->mTitle->getPrefixedURL());
             break;
         case 'subpagename':
             $value = wfEscapeWikiText($this->mTitle->getSubpageText());
             break;
         case 'subpagenamee':
             $value = wfEscapeWikiText($this->mTitle->getSubpageUrlForm());
             break;
         case 'rootpagename':
             $value = wfEscapeWikiText($this->mTitle->getRootText());
             break;
         case 'rootpagenamee':
             $value = wfEscapeWikiText(wfUrlEncode(str_replace(' ', '_', $this->mTitle->getRootText())));
             break;
         case 'basepagename':
             $value = wfEscapeWikiText($this->mTitle->getBaseText());
             break;
         case 'basepagenamee':
             $value = wfEscapeWikiText(wfUrlEncode(str_replace(' ', '_', $this->mTitle->getBaseText())));
             break;
         case 'talkpagename':
             if ($this->mTitle->canTalk()) {
                 $talkPage = $this->mTitle->getTalkPage();
                 $value = wfEscapeWikiText($talkPage->getPrefixedText());
             } else {
                 $value = '';
             }
             break;
         case 'talkpagenamee':
             if ($this->mTitle->canTalk()) {
                 $talkPage = $this->mTitle->getTalkPage();
                 $value = wfEscapeWikiText($talkPage->getPrefixedURL());
             } else {
                 $value = '';
             }
             break;
         case 'subjectpagename':
             $subjPage = $this->mTitle->getSubjectPage();
             $value = wfEscapeWikiText($subjPage->getPrefixedText());
             break;
         case 'subjectpagenamee':
             $subjPage = $this->mTitle->getSubjectPage();
             $value = wfEscapeWikiText($subjPage->getPrefixedURL());
             break;
         case 'pageid':
             // requested in bug 23427
             $pageid = $this->getTitle()->getArticleID();
             if ($pageid == 0) {
                 # 0 means the page doesn't exist in the database,
                 # which means the user is previewing a new page.
                 # The vary-revision flag must be set, because the magic word
                 # will have a different value once the page is saved.
                 $this->mOutput->setFlag('vary-revision');
                 wfDebug(__METHOD__ . ": {{PAGEID}} used in a new page, setting vary-revision...\n");
             }
             $value = $pageid ? $pageid : null;
             break;
         case 'revisionid':
             # Let the edit saving system know we should parse the page
             # *after* a revision ID has been assigned.
             $this->mOutput->setFlag('vary-revision');
             wfDebug(__METHOD__ . ": {{REVISIONID}} used, setting vary-revision...\n");
             $value = $this->mRevisionId;
             break;
         case 'revisionday':
             # Let the edit saving system know we should parse the page
             # *after* a revision ID has been assigned. This is for null edits.
             $this->mOutput->setFlag('vary-revision');
             wfDebug(__METHOD__ . ": {{REVISIONDAY}} used, setting vary-revision...\n");
             $value = intval(substr($this->getRevisionTimestamp(), 6, 2));
             break;
         case 'revisionday2':
             # Let the edit saving system know we should parse the page
             # *after* a revision ID has been assigned. This is for null edits.
             $this->mOutput->setFlag('vary-revision');
             wfDebug(__METHOD__ . ": {{REVISIONDAY2}} used, setting vary-revision...\n");
             $value = substr($this->getRevisionTimestamp(), 6, 2);
             break;
         case 'revisionmonth':
             # Let the edit saving system know we should parse the page
             # *after* a revision ID has been assigned. This is for null edits.
             $this->mOutput->setFlag('vary-revision');
             wfDebug(__METHOD__ . ": {{REVISIONMONTH}} used, setting vary-revision...\n");
             $value = substr($this->getRevisionTimestamp(), 4, 2);
             break;
         case 'revisionmonth1':
             # Let the edit saving system know we should parse the page
             # *after* a revision ID has been assigned. This is for null edits.
             $this->mOutput->setFlag('vary-revision');
             wfDebug(__METHOD__ . ": {{REVISIONMONTH1}} used, setting vary-revision...\n");
             $value = intval(substr($this->getRevisionTimestamp(), 4, 2));
             break;
         case 'revisionyear':
             # Let the edit saving system know we should parse the page
             # *after* a revision ID has been assigned. This is for null edits.
             $this->mOutput->setFlag('vary-revision');
             wfDebug(__METHOD__ . ": {{REVISIONYEAR}} used, setting vary-revision...\n");
             $value = substr($this->getRevisionTimestamp(), 0, 4);
             break;
         case 'revisiontimestamp':
             # Let the edit saving system know we should parse the page
             # *after* a revision ID has been assigned. This is for null edits.
             $this->mOutput->setFlag('vary-revision');
             wfDebug(__METHOD__ . ": {{REVISIONTIMESTAMP}} used, setting vary-revision...\n");
             $value = $this->getRevisionTimestamp();
             break;
         case 'revisionuser':
             # Let the edit saving system know we should parse the page
             # *after* a revision ID has been assigned. This is for null edits.
             $this->mOutput->setFlag('vary-revision');
             wfDebug(__METHOD__ . ": {{REVISIONUSER}} used, setting vary-revision...\n");
             $value = $this->getRevisionUser();
             break;
         case 'revisionsize':
             # Let the edit saving system know we should parse the page
             # *after* a revision ID has been assigned. This is for null edits.
             $this->mOutput->setFlag('vary-revision');
             wfDebug(__METHOD__ . ": {{REVISIONSIZE}} used, setting vary-revision...\n");
             $value = $this->getRevisionSize();
             break;
         case 'namespace':
             $value = str_replace('_', ' ', $wgContLang->getNsText($this->mTitle->getNamespace()));
             break;
         case 'namespacee':
             $value = wfUrlencode($wgContLang->getNsText($this->mTitle->getNamespace()));
             break;
         case 'namespacenumber':
             $value = $this->mTitle->getNamespace();
             break;
         case 'talkspace':
             $value = $this->mTitle->canTalk() ? str_replace('_', ' ', $this->mTitle->getTalkNsText()) : '';
             break;
         case 'talkspacee':
             $value = $this->mTitle->canTalk() ? wfUrlencode($this->mTitle->getTalkNsText()) : '';
             break;
         case 'subjectspace':
             $value = str_replace('_', ' ', $this->mTitle->getSubjectNsText());
             break;
         case 'subjectspacee':
             $value = wfUrlencode($this->mTitle->getSubjectNsText());
             break;
         case 'currentdayname':
             $value = $pageLang->getWeekdayName((int) MWTimestamp::getInstance($ts)->format('w') + 1);
             break;
         case 'currentyear':
             $value = $pageLang->formatNum(MWTimestamp::getInstance($ts)->format('Y'), true);
             break;
         case 'currenttime':
             $value = $pageLang->time(wfTimestamp(TS_MW, $ts), false, false);
             break;
         case 'currenthour':
             $value = $pageLang->formatNum(MWTimestamp::getInstance($ts)->format('H'), true);
             break;
         case 'currentweek':
             # @bug 4594 PHP5 has it zero padded, PHP4 does not, cast to
             # int to remove the padding
             $value = $pageLang->formatNum((int) MWTimestamp::getInstance($ts)->format('W'));
             break;
         case 'currentdow':
             $value = $pageLang->formatNum(MWTimestamp::getInstance($ts)->format('w'));
             break;
         case 'localdayname':
             $value = $pageLang->getWeekdayName((int) MWTimestamp::getLocalInstance($ts)->format('w') + 1);
             break;
         case 'localyear':
             $value = $pageLang->formatNum(MWTimestamp::getLocalInstance($ts)->format('Y'), true);
             break;
         case 'localtime':
             $value = $pageLang->time(MWTimestamp::getLocalInstance($ts)->format('YmdHis'), false, false);
             break;
         case 'localhour':
             $value = $pageLang->formatNum(MWTimestamp::getLocalInstance($ts)->format('H'), true);
             break;
         case 'localweek':
             # @bug 4594 PHP5 has it zero padded, PHP4 does not, cast to
             # int to remove the padding
             $value = $pageLang->formatNum((int) MWTimestamp::getLocalInstance($ts)->format('W'));
             break;
         case 'localdow':
             $value = $pageLang->formatNum(MWTimestamp::getLocalInstance($ts)->format('w'));
             break;
         case 'numberofarticles':
             $value = $pageLang->formatNum(SiteStats::articles());
             break;
         case 'numberoffiles':
             $value = $pageLang->formatNum(SiteStats::images());
             break;
         case 'numberofusers':
             $value = $pageLang->formatNum(SiteStats::users());
             break;
         case 'numberofactiveusers':
             $value = $pageLang->formatNum(SiteStats::activeUsers());
             break;
         case 'numberofpages':
             $value = $pageLang->formatNum(SiteStats::pages());
             break;
         case 'numberofadmins':
             $value = $pageLang->formatNum(SiteStats::numberingroup('sysop'));
             break;
         case 'numberofedits':
             $value = $pageLang->formatNum(SiteStats::edits());
             break;
         case 'numberofviews':
             global $wgDisableCounters;
             $value = !$wgDisableCounters ? $pageLang->formatNum(SiteStats::views()) : '';
             break;
         case 'currenttimestamp':
             $value = wfTimestamp(TS_MW, $ts);
             break;
         case 'localtimestamp':
             $value = MWTimestamp::getLocalInstance($ts)->format('YmdHis');
             break;
         case 'currentversion':
             $value = SpecialVersion::getVersion();
             break;
         case 'articlepath':
             return $wgArticlePath;
         case 'sitename':
             return $wgSitename;
         case 'server':
             return $wgServer;
         case 'servername':
             $serverParts = wfParseUrl($wgServer);
             return $serverParts && isset($serverParts['host']) ? $serverParts['host'] : $wgServer;
         case 'scriptpath':
             return $wgScriptPath;
         case 'stylepath':
             return $wgStylePath;
         case 'directionmark':
             return $pageLang->getDirMark();
         case 'contentlanguage':
             global $wgLanguageCode;
             return $wgLanguageCode;
         case 'cascadingsources':
             $value = CoreParserFunctions::cascadingsources($this);
             break;
         default:
             $ret = null;
             wfRunHooks('ParserGetVariableValueSwitch', array(&$this, &$this->mVarCache, &$index, &$ret, &$frame));
             return $ret;
     }
     if ($index) {
         $this->mVarCache[$index] = $value;
     }
     return $value;
 }
Example #19
0
 /**
  * Get the URL of the content-only fragment of the description page. For
  * MediaWiki this means action=render. This should only be called by the
  * repository's file class, since it may return invalid results. User code
  * should use File::getDescriptionText().
  *
  * @param $name String: name of image to fetch
  * @param $lang String: language to fetch it in, if any.
  * @return string
  */
 public function getDescriptionRenderUrl($name, $lang = null)
 {
     $query = 'action=render';
     if (!is_null($lang)) {
         $query .= '&uselang=' . $lang;
     }
     if (isset($this->scriptDirUrl)) {
         return $this->makeUrl('title=' . wfUrlencode('Image:' . $name) . "&{$query}");
     } else {
         $descUrl = $this->getDescriptionUrl($name);
         if ($descUrl) {
             return wfAppendQuery($descUrl, $query);
         } else {
             return false;
         }
     }
 }
Example #20
0
 /**
  * Write logging information for API features to a debug log, for usage
  * analysis.
  * @param string $feature Feature being used.
  */
 protected function logFeatureUsage($feature)
 {
     $request = $this->getRequest();
     $s = '"' . addslashes($feature) . '"' . ' "' . wfUrlencode(str_replace(' ', '_', $this->getUser()->getName())) . '"' . ' "' . $request->getIP() . '"' . ' "' . addslashes($request->getHeader('Referer')) . '"' . ' "' . addslashes($this->getMain()->getUserAgent()) . '"';
     wfDebugLog('api-feature-usage', $s, 'private');
 }
Example #21
0
 /**
  * Get a real URL referring to this title
  *
  * @param string $query an optional query string
  * @param string|bool $variant language variant of url (for sr, zh..)
  *
  * @return string the URL
  */
 public function getFullURL($query = '', $variant = false)
 {
     $this->loadAll();
     $namespace = wfUrlencode($this->getNsText());
     if ($this->mNamespace != NS_MAIN) {
         $namespace .= ":";
     }
     /**
      * replace $1 with article title with namespace
      */
     if (is_array($query)) {
         $query = wfArrayToCGI($query);
     }
     $url = str_replace('$1', $namespace . $this->mUrlform, $this->mArticlePath);
     $url = wfAppendQuery($this->mServer . $url, $query);
     return $url;
 }
 /**
  * Returns a string that can be appended to the URL (without encoding) to preserve the
  * return target. Does not include leading '?'/'&'.
  */
 protected function getReturnToQueryStringFragment()
 {
     $returnto = '';
     if ($this->mReturnTo !== '') {
         $returnto = 'returnto=' . wfUrlencode($this->mReturnTo);
         if ($this->mReturnToQuery !== '') {
             $returnto .= '&returntoquery=' . wfUrlencode($this->mReturnToQuery);
         }
     }
     return $returnto;
 }
Example #23
0
 /**
  * Get a URL with no fragment or server name.  If this page is generated
  * with action=render, $wgServer is prepended.
  * @param string $query an optional query string; if not specified,
  * 	$wgArticlePath will be used.
  * @param string $variant language variant of url (for sr, zh..)
  * @return string the URL
  */
 public function getLocalURL($query = '', $variant = false)
 {
     global $wgArticlePath, $wgScript, $wgServer, $wgRequest;
     global $wgVariantArticlePath, $wgContLang, $wgUser;
     // internal links should point to same variant as current page (only anonymous users)
     if ($variant == false && $wgContLang->hasVariants() && !$wgUser->isLoggedIn()) {
         $pref = $wgContLang->getPreferredVariant(false);
         if ($pref != $wgContLang->getCode()) {
             $variant = $pref;
         }
     }
     if ($this->isExternal()) {
         $url = $this->getFullURL();
         if ($query) {
             // This is currently only used for edit section links in the
             // context of interwiki transclusion. In theory we should
             // append the query to the end of any existing query string,
             // but interwiki transclusion is already broken in that case.
             $url .= "?{$query}";
         }
     } else {
         $dbkey = wfUrlencode($this->getPrefixedDBkey());
         if ($query == '') {
             if ($variant != false && $wgContLang->hasVariants()) {
                 if ($wgVariantArticlePath == false) {
                     $variantArticlePath = "{$wgScript}?title=\$1&variant=\$2";
                     // default
                 } else {
                     $variantArticlePath = $wgVariantArticlePath;
                 }
                 $url = str_replace('$2', urlencode($variant), $variantArticlePath);
                 $url = str_replace('$1', $dbkey, $url);
             } else {
                 $url = str_replace('$1', $dbkey, $wgArticlePath);
             }
         } else {
             global $wgActionPaths;
             $url = false;
             $matches = array();
             if (!empty($wgActionPaths) && preg_match('/^(.*&|)action=([^&]*)(&(.*)|)$/', $query, $matches)) {
                 $action = urldecode($matches[2]);
                 if (isset($wgActionPaths[$action])) {
                     $query = $matches[1];
                     if (isset($matches[4])) {
                         $query .= $matches[4];
                     }
                     $url = str_replace('$1', $dbkey, $wgActionPaths[$action]);
                     if ($query != '') {
                         $url .= '?' . $query;
                     }
                 }
             }
             if ($url === false) {
                 if ($query == '-') {
                     $query = '';
                 }
                 $url = "{$wgScript}?title={$dbkey}&{$query}";
             }
         }
         // FIXME: this causes breakage in various places when we
         // actually expected a local URL and end up with dupe prefixes.
         if ($wgRequest->getVal('action') == 'render') {
             $url = $wgServer . $url;
         }
     }
     wfRunHooks('GetLocalURL', array(&$this, &$url, $query));
     return $url;
 }
 function newFromInterwiki($interwiki, $page)
 {
     $base = Title::getInterwikiLink($interwiki);
     if (empty($base)) {
         return new WikiError('Bad interwiki link');
     } else {
         $import = wfUrlencode("Special:Export/{$page}");
         $url = str_replace("\$1", $import, $base);
         return ImportStreamSource::newFromURL($url);
     }
 }
Example #25
0
 public function __wakeup()
 {
     $this->mArticleID = $this->mNamespace >= 0 ? -1 : 0;
     $this->mUrlform = wfUrlencode($this->mDbkeyform);
     $this->mTextform = strtr($this->mDbkeyform, '_', ' ');
 }
Example #26
0
 /**
  * Secure and split - main initialisation function for this object
  *
  * Assumes that mDbkeyform has been set, and is urldecoded
  * and uses underscores, but not otherwise munged.  This function
  * removes illegal characters, splits off the interwiki and
  * namespace prefixes, sets the other forms, and canonicalizes
  * everything.
  *
  * @throws MalformedTitleException On invalid titles
  * @return bool True on success
  */
 private function secureAndSplit()
 {
     # Initialisation
     $this->mInterwiki = '';
     $this->mFragment = '';
     $this->mNamespace = $this->mDefaultNamespace;
     # Usually NS_MAIN
     $dbkey = $this->mDbkeyform;
     // @note: splitTitleString() is a temporary hack to allow MediaWikiTitleCodec to share
     //        the parsing code with Title, while avoiding massive refactoring.
     // @todo: get rid of secureAndSplit, refactor parsing code.
     $titleParser = self::getTitleParser();
     // MalformedTitleException can be thrown here
     $parts = $titleParser->splitTitleString($dbkey, $this->getDefaultNamespace());
     # Fill fields
     $this->setFragment('#' . $parts['fragment']);
     $this->mInterwiki = $parts['interwiki'];
     $this->mLocalInterwiki = $parts['local_interwiki'];
     $this->mNamespace = $parts['namespace'];
     $this->mUserCaseDBKey = $parts['user_case_dbkey'];
     $this->mDbkeyform = $parts['dbkey'];
     $this->mUrlform = wfUrlencode($this->mDbkeyform);
     $this->mTextform = str_replace('_', ' ', $this->mDbkeyform);
     # We already know that some pages won't be in the database!
     if ($this->isExternal() || $this->mNamespace == NS_SPECIAL) {
         $this->mArticleID = 0;
     }
     return true;
 }
Example #27
0
 /**
  * Log the preceding request
  * @param int $time Time in seconds
  */
 protected function logRequest($time)
 {
     $request = $this->getRequest();
     $milliseconds = $time === null ? '?' : round($time * 1000);
     $s = 'API' . ' ' . $request->getMethod() . ' ' . wfUrlencode(str_replace(' ', '_', $this->getUser()->getName())) . ' ' . $request->getIP() . ' T=' . $milliseconds . 'ms';
     foreach ($this->getParamsUsed() as $name) {
         $value = $request->getVal($name);
         if ($value === null) {
             continue;
         }
         $s .= ' ' . $name . '=';
         if (strlen($value) > 256) {
             $encValue = $this->encodeRequestLogValue(substr($value, 0, 256));
             $s .= $encValue . '[...]';
         } else {
             $s .= $this->encodeRequestLogValue($value);
         }
     }
     $s .= "\n";
     wfDebugLog('api', $s, 'private');
 }
Example #28
0
 /**
  * Return value of a magic variable (like PAGENAME)
  *
  * @private
  */
 function getVariableValue($index)
 {
     global $wgContLang, $wgSitename, $wgServer, $wgServerName, $wgScriptPath;
     /**
      * Some of these require message or data lookups and can be
      * expensive to check many times.
      */
     if (wfRunHooks('ParserGetVariableValueVarCache', array(&$this, &$this->mVarCache))) {
         if (isset($this->mVarCache[$index])) {
             return $this->mVarCache[$index];
         }
     }
     $ts = wfTimestamp(TS_UNIX, $this->mOptions->getTimestamp());
     wfRunHooks('ParserGetVariableValueTs', array(&$this, &$ts));
     # Use the time zone
     global $wgLocaltimezone;
     if (isset($wgLocaltimezone)) {
         $oldtz = getenv('TZ');
         putenv('TZ=' . $wgLocaltimezone);
     }
     wfSuppressWarnings();
     // E_STRICT system time bitching
     $localTimestamp = date('YmdHis', $ts);
     $localMonth = date('m', $ts);
     $localMonthName = date('n', $ts);
     $localDay = date('j', $ts);
     $localDay2 = date('d', $ts);
     $localDayOfWeek = date('w', $ts);
     $localWeek = date('W', $ts);
     $localYear = date('Y', $ts);
     $localHour = date('H', $ts);
     if (isset($wgLocaltimezone)) {
         putenv('TZ=' . $oldtz);
     }
     wfRestoreWarnings();
     switch ($index) {
         case 'currentmonth':
             return $this->mVarCache[$index] = $wgContLang->formatNum(gmdate('m', $ts));
         case 'currentmonthname':
             return $this->mVarCache[$index] = $wgContLang->getMonthName(gmdate('n', $ts));
         case 'currentmonthnamegen':
             return $this->mVarCache[$index] = $wgContLang->getMonthNameGen(gmdate('n', $ts));
         case 'currentmonthabbrev':
             return $this->mVarCache[$index] = $wgContLang->getMonthAbbreviation(gmdate('n', $ts));
         case 'currentday':
             return $this->mVarCache[$index] = $wgContLang->formatNum(gmdate('j', $ts));
         case 'currentday2':
             return $this->mVarCache[$index] = $wgContLang->formatNum(gmdate('d', $ts));
         case 'localmonth':
             return $this->mVarCache[$index] = $wgContLang->formatNum($localMonth);
         case 'localmonthname':
             return $this->mVarCache[$index] = $wgContLang->getMonthName($localMonthName);
         case 'localmonthnamegen':
             return $this->mVarCache[$index] = $wgContLang->getMonthNameGen($localMonthName);
         case 'localmonthabbrev':
             return $this->mVarCache[$index] = $wgContLang->getMonthAbbreviation($localMonthName);
         case 'localday':
             return $this->mVarCache[$index] = $wgContLang->formatNum($localDay);
         case 'localday2':
             return $this->mVarCache[$index] = $wgContLang->formatNum($localDay2);
         case 'pagename':
             return wfEscapeWikiText($this->mTitle->getText());
         case 'pagenamee':
             return $this->mTitle->getPartialURL();
         case 'fullpagename':
             return wfEscapeWikiText($this->mTitle->getPrefixedText());
         case 'fullpagenamee':
             return $this->mTitle->getPrefixedURL();
         case 'subpagename':
             return wfEscapeWikiText($this->mTitle->getSubpageText());
         case 'subpagenamee':
             return $this->mTitle->getSubpageUrlForm();
         case 'basepagename':
             return wfEscapeWikiText($this->mTitle->getBaseText());
         case 'basepagenamee':
             return wfUrlEncode(str_replace(' ', '_', $this->mTitle->getBaseText()));
         case 'talkpagename':
             if ($this->mTitle->canTalk()) {
                 $talkPage = $this->mTitle->getTalkPage();
                 return wfEscapeWikiText($talkPage->getPrefixedText());
             } else {
                 return '';
             }
         case 'talkpagenamee':
             if ($this->mTitle->canTalk()) {
                 $talkPage = $this->mTitle->getTalkPage();
                 return $talkPage->getPrefixedUrl();
             } else {
                 return '';
             }
         case 'subjectpagename':
             $subjPage = $this->mTitle->getSubjectPage();
             return wfEscapeWikiText($subjPage->getPrefixedText());
         case 'subjectpagenamee':
             $subjPage = $this->mTitle->getSubjectPage();
             return $subjPage->getPrefixedUrl();
         case 'revisionid':
             // Let the edit saving system know we should parse the page
             // *after* a revision ID has been assigned.
             $this->mOutput->setFlag('vary-revision');
             wfDebug(__METHOD__ . ": {{REVISIONID}} used, setting vary-revision...\n");
             return $this->mRevisionId;
         case 'revisionday':
             // Let the edit saving system know we should parse the page
             // *after* a revision ID has been assigned. This is for null edits.
             $this->mOutput->setFlag('vary-revision');
             wfDebug(__METHOD__ . ": {{REVISIONDAY}} used, setting vary-revision...\n");
             return intval(substr($this->getRevisionTimestamp(), 6, 2));
         case 'revisionday2':
             // Let the edit saving system know we should parse the page
             // *after* a revision ID has been assigned. This is for null edits.
             $this->mOutput->setFlag('vary-revision');
             wfDebug(__METHOD__ . ": {{REVISIONDAY2}} used, setting vary-revision...\n");
             return substr($this->getRevisionTimestamp(), 6, 2);
         case 'revisionmonth':
             // Let the edit saving system know we should parse the page
             // *after* a revision ID has been assigned. This is for null edits.
             $this->mOutput->setFlag('vary-revision');
             wfDebug(__METHOD__ . ": {{REVISIONMONTH}} used, setting vary-revision...\n");
             return intval(substr($this->getRevisionTimestamp(), 4, 2));
         case 'revisionyear':
             // Let the edit saving system know we should parse the page
             // *after* a revision ID has been assigned. This is for null edits.
             $this->mOutput->setFlag('vary-revision');
             wfDebug(__METHOD__ . ": {{REVISIONYEAR}} used, setting vary-revision...\n");
             return substr($this->getRevisionTimestamp(), 0, 4);
         case 'revisiontimestamp':
             // Let the edit saving system know we should parse the page
             // *after* a revision ID has been assigned. This is for null edits.
             $this->mOutput->setFlag('vary-revision');
             wfDebug(__METHOD__ . ": {{REVISIONTIMESTAMP}} used, setting vary-revision...\n");
             return $this->getRevisionTimestamp();
         case 'revisionuser':
             // Let the edit saving system know we should parse the page
             // *after* a revision ID has been assigned. This is for null edits.
             $this->mOutput->setFlag('vary-revision');
             wfDebug(__METHOD__ . ": {{REVISIONUSER}} used, setting vary-revision...\n");
             return $this->getRevisionUser();
         case 'namespace':
             return str_replace('_', ' ', $wgContLang->getNsText($this->mTitle->getNamespace()));
         case 'namespacee':
             return wfUrlencode($wgContLang->getNsText($this->mTitle->getNamespace()));
         case 'talkspace':
             return $this->mTitle->canTalk() ? str_replace('_', ' ', $this->mTitle->getTalkNsText()) : '';
         case 'talkspacee':
             return $this->mTitle->canTalk() ? wfUrlencode($this->mTitle->getTalkNsText()) : '';
         case 'subjectspace':
             return $this->mTitle->getSubjectNsText();
         case 'subjectspacee':
             return wfUrlencode($this->mTitle->getSubjectNsText());
         case 'currentdayname':
             return $this->mVarCache[$index] = $wgContLang->getWeekdayName(gmdate('w', $ts) + 1);
         case 'currentyear':
             return $this->mVarCache[$index] = $wgContLang->formatNum(gmdate('Y', $ts), true);
         case 'currenttime':
             return $this->mVarCache[$index] = $wgContLang->time(wfTimestamp(TS_MW, $ts), false, false);
         case 'currenthour':
             return $this->mVarCache[$index] = $wgContLang->formatNum(gmdate('H', $ts), true);
         case 'currentweek':
             // @bug 4594 PHP5 has it zero padded, PHP4 does not, cast to
             // int to remove the padding
             return $this->mVarCache[$index] = $wgContLang->formatNum((int) gmdate('W', $ts));
         case 'currentdow':
             return $this->mVarCache[$index] = $wgContLang->formatNum(gmdate('w', $ts));
         case 'localdayname':
             return $this->mVarCache[$index] = $wgContLang->getWeekdayName($localDayOfWeek + 1);
         case 'localyear':
             return $this->mVarCache[$index] = $wgContLang->formatNum($localYear, true);
         case 'localtime':
             return $this->mVarCache[$index] = $wgContLang->time($localTimestamp, false, false);
         case 'localhour':
             return $this->mVarCache[$index] = $wgContLang->formatNum($localHour, true);
         case 'localweek':
             // @bug 4594 PHP5 has it zero padded, PHP4 does not, cast to
             // int to remove the padding
             return $this->mVarCache[$index] = $wgContLang->formatNum((int) $localWeek);
         case 'localdow':
             return $this->mVarCache[$index] = $wgContLang->formatNum($localDayOfWeek);
         case 'numberofarticles':
             return $this->mVarCache[$index] = $wgContLang->formatNum(SiteStats::articles());
         case 'numberoffiles':
             return $this->mVarCache[$index] = $wgContLang->formatNum(SiteStats::images());
         case 'numberofusers':
             return $this->mVarCache[$index] = $wgContLang->formatNum(SiteStats::users());
         case 'numberofactiveusers':
             return $this->mVarCache[$index] = $wgContLang->formatNum(SiteStats::activeUsers());
         case 'numberofpages':
             return $this->mVarCache[$index] = $wgContLang->formatNum(SiteStats::pages());
         case 'numberofadmins':
             return $this->mVarCache[$index] = $wgContLang->formatNum(SiteStats::numberingroup('sysop'));
         case 'numberofedits':
             return $this->mVarCache[$index] = $wgContLang->formatNum(SiteStats::edits());
         case 'numberofviews':
             return $this->mVarCache[$index] = $wgContLang->formatNum(SiteStats::views());
         case 'currenttimestamp':
             return $this->mVarCache[$index] = wfTimestamp(TS_MW, $ts);
         case 'localtimestamp':
             return $this->mVarCache[$index] = $localTimestamp;
         case 'currentversion':
             return $this->mVarCache[$index] = SpecialVersion::getVersion();
         case 'sitename':
             return $wgSitename;
         case 'server':
             return $wgServer;
         case 'servername':
             return $wgServerName;
         case 'scriptpath':
             return $wgScriptPath;
         case 'directionmark':
             return $wgContLang->getDirMark();
         case 'contentlanguage':
             global $wgContLanguageCode;
             return $wgContLanguageCode;
         default:
             $ret = null;
             if (wfRunHooks('ParserGetVariableValueSwitch', array(&$this, &$this->mVarCache, &$index, &$ret))) {
                 return $ret;
             } else {
                 return null;
             }
     }
 }
Example #29
0
 /**
  * Adds help link with an icon via page indicators.
  * Link target can be overridden by a local message containing a wikilink:
  * the message key is: lowercase action or special page name + '-helppage'.
  * @param string $to Target MediaWiki.org page title or encoded URL.
  * @param bool $overrideBaseUrl Whether $url is a full URL, to avoid MW.o.
  * @since 1.25
  */
 public function addHelpLink($to, $overrideBaseUrl = false)
 {
     $this->addModuleStyles('mediawiki.helplink');
     $text = $this->msg('helppage-top-gethelp')->escaped();
     if ($overrideBaseUrl) {
         $helpUrl = $to;
     } else {
         $toUrlencoded = wfUrlencode(str_replace(' ', '_', $to));
         $helpUrl = "//www.mediawiki.org/wiki/Special:MyLanguage/{$toUrlencoded}";
     }
     $link = Html::rawElement('a', array('href' => $helpUrl, 'target' => '_blank', 'class' => 'mw-helplink'), $text);
     $this->setIndicators(array('mw-helplink' => $link));
 }
Example #30
0
 /**
  * @private
  */
 function mainLoginForm($msg, $msgtype = 'error')
 {
     global $wgUser, $wgOut, $wgAllowRealName, $wgEnableEmail;
     global $wgCookiePrefix, $wgAuth, $wgLoginLanguageSelector;
     global $wgAuth;
     if ($this->mType == 'signup') {
         if (!$wgUser->isAllowed('createaccount')) {
             $this->userNotPrivilegedMessage();
             return;
         } elseif ($wgUser->isBlockedFromCreateAccount()) {
             $this->userBlockedMessage();
             return;
         }
     }
     if ('' == $this->mName) {
         if ($wgUser->isLoggedIn()) {
             $this->mName = $wgUser->getName();
         } else {
             $this->mName = isset($_COOKIE[$wgCookiePrefix . 'UserName']) ? $_COOKIE[$wgCookiePrefix . 'UserName'] : null;
         }
     }
     $titleObj = SpecialPage::getTitleFor('Userlogin');
     if ($this->mType == 'signup') {
         $template = new UsercreateTemplate();
         $q = 'action=submitlogin&type=signup';
         $linkq = 'type=login';
         $linkmsg = 'gotaccount';
     } else {
         $template = new UserloginTemplate();
         $q = 'action=submitlogin&type=login';
         $linkq = 'type=signup';
         $linkmsg = 'nologin';
     }
     if (!empty($this->mReturnTo)) {
         $returnto = '&returnto=' . wfUrlencode($this->mReturnTo);
         $q .= $returnto;
         $linkq .= $returnto;
     }
     # Pass any language selection on to the mode switch link
     if ($wgLoginLanguageSelector && $this->mLanguage) {
         $linkq .= '&uselang=' . $this->mLanguage;
     }
     $link = '<a href="' . htmlspecialchars($titleObj->getLocalUrl($linkq)) . '">';
     $link .= wfMsgHtml($linkmsg . 'link');
     $link .= '</a>';
     # Don't show a "create account" link if the user can't
     if ($this->showCreateOrLoginLink($wgUser)) {
         $template->set('link', wfMsgHtml($linkmsg, $link));
     } else {
         $template->set('link', '');
     }
     $template->set('header', '');
     $template->set('name', $this->mName);
     $template->set('password', $this->mPassword);
     $template->set('retype', $this->mRetype);
     $template->set('email', $this->mEmail);
     $template->set('realname', $this->mRealName);
     $template->set('domain', $this->mDomain);
     $template->set('action', $titleObj->getLocalUrl($q));
     $template->set('message', $msg);
     $template->set('messagetype', $msgtype);
     $template->set('createemail', $wgEnableEmail && $wgUser->isLoggedIn());
     $template->set('userealname', $wgAllowRealName);
     $template->set('useemail', $wgEnableEmail);
     $template->set('canreset', $wgAuth->allowPasswordChange());
     $template->set('remember', $wgUser->getOption('rememberpassword') or $this->mRemember);
     # Prepare language selection links as needed
     if ($wgLoginLanguageSelector) {
         $template->set('languages', $this->makeLanguageSelector());
         if ($this->mLanguage) {
             $template->set('uselang', $this->mLanguage);
         }
     }
     // Give authentication and captcha plugins a chance to modify the form
     $wgAuth->modifyUITemplate($template);
     if ($this->mType == 'signup') {
         wfRunHooks('UserCreateForm', array(&$template));
     } else {
         wfRunHooks('UserLoginForm', array(&$template));
     }
     $wgOut->setPageTitle(wfMsg('userlogin'));
     $wgOut->setRobotpolicy('noindex,nofollow');
     $wgOut->setArticleRelated(false);
     $wgOut->addTemplate($template);
 }