/**
* Set the title
- * @param Title $t The title to use
+ * @param $t Title object to use
*/
public function setTitle( $t ) {
$this->mTitle = $t;
* Make a <script> tag containing global variables
* @param $skinName string Name of the skin
* The odd calling convention is for backwards compatibility
- * @TODO @FIXME Make this not depend on $wgTitle!
+ * @todo FIXME: Make this not depend on $wgTitle!
*/
static function makeGlobalVariablesScript( $skinName ) {
if ( is_array( $skinName ) ) {
implode( "\t", $digitTransTable ),
);
- $mainPage = Title::newFromText( wfMsgForContent( 'mainpage' ) );
+ $mainPage = Title::newMainPage();
$vars = array(
'skin' => $skinName,
'stylepath' => $wgStylePath,
'wgArticleId' => $wgTitle->getArticleId(),
'wgIsArticle' => $wgOut->isArticle(),
'wgUserName' => $wgUser->isAnon() ? null : $wgUser->getName(),
- 'wgUserGroups' => $wgUser->isAnon() ? null : $wgUser->getEffectiveGroups(),
+ 'wgUserGroups' => $wgUser->getEffectiveGroups(),
'wgUserLanguage' => $wgLang->getCode(),
'wgContentLanguage' => $wgContLang->getCode(),
'wgBreakFrames' => $wgBreakFrames,
// if on upload page output the extension list & js_upload
if( SpecialPage::resolveAlias( $wgTitle->getDBkey() ) == 'Upload' ) {
- global $wgFileExtensions, $wgAjaxUploadInterface;
+ global $wgFileExtensions;
$vars['wgFileExtensions'] = $wgFileExtensions;
}
/**
* Split for easier subclassing in SkinSimple, SkinStandard and SkinCologneBlue
+ * Anything in here won't be generated if $wgAllowUserCssPrefs is false.
*/
protected function reallyGenerateUserStylesheet() {
global $wgUser;
// Per-site custom styles
if( $wgUseSiteCss ) {
global $wgHandheldStyle;
- $query = wfArrayToCGI( array(
- 'usemsgcache' => 'yes',
- 'ctype' => 'text/css',
- 'smaxage' => $wgSquidMaxage
- ) + $siteargs );
+ $query = wfArrayToCGI( self::getDynamicStylesheetQuery() );
# Site settings must override extension css! (bug 15025)
$out->addStyle( self::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI ) );
$out->addStyle( self::makeNSUrl( 'Print.css', $query, NS_MEDIAWIKI ), 'print' );
$out->addStyle( self::makeNSUrl( $this->getSkinName() . '.css', $query, NS_MEDIAWIKI ) );
}
- if( $wgUser->isLoggedIn() ) {
- // Ensure that logged-in users' generated CSS isn't clobbered
- // by anons' publicly cacheable generated CSS.
- $siteargs['smaxage'] = '0';
- $siteargs['ts'] = $wgUser->mTouched;
- }
- // Per-user styles based on preferences
- $siteargs['gen'] = 'css';
- if( ( $us = $wgRequest->getVal( 'useskin', '' ) ) !== '' ) {
- $siteargs['useskin'] = $us;
+ global $wgAllowUserCssPrefs;
+ if( $wgAllowUserCssPrefs ){
+ if( $wgUser->isLoggedIn() ) {
+ // Ensure that logged-in users' generated CSS isn't clobbered
+ // by anons' publicly cacheable generated CSS.
+ $siteargs['smaxage'] = '0';
+ $siteargs['ts'] = $wgUser->mTouched;
+ }
+ // Per-user styles based on preferences
+ $siteargs['gen'] = 'css';
+ if( ( $us = $wgRequest->getVal( 'useskin', '' ) ) !== '' ) {
+ $siteargs['useskin'] = $us;
+ }
+ $out->addStyle( self::makeUrl( '-', wfArrayToCGI( $siteargs ) ) );
}
- $out->addStyle( self::makeUrl( '-', wfArrayToCGI( $siteargs ) ) );
// Per-user custom style pages
if( $wgAllowUserCss && $wgUser->isLoggedIn() ) {
// @FIXME: properly escape the cdata!
$out->addInlineStyle( $wgRequest->getText( 'wpTextbox1' ) );
} else {
- $out->addStyle( self::makeUrl(
- $this->userpage . '/' . $this->getSkinName() . '.css',
- 'action=raw&ctype=text/css' )
- );
+ $names = array( 'common', $this->getSkinName() );
+ foreach( $names as $name ) {
+ $out->addStyle( self::makeUrl(
+ $this->userpage . '/' . $name . '.css',
+ 'action=raw&ctype=text/css' )
+ );
+ }
}
}
wfProfileOut( __METHOD__ );
}
+
+ /**
+ * Get the query to generate a dynamic stylesheet
+ *
+ * @return array
+ */
+ public static function getDynamicStylesheetQuery() {
+ global $wgSquidMaxage;
+ return array(
+ 'action' => 'raw',
+ 'maxage' => $wgSquidMaxage,
+ 'usemsgcache' => 'yes',
+ 'ctype' => 'text/css',
+ 'smaxage' => $wgSquidMaxage,
+ );
+ }
/**
* Add skin specific stylesheets
}
function getQuickbarCompensator( $rows = 1 ) {
- return "<td width='152' rowspan='{$rows}'> </td>";
+ return "<td width='152' rowspan='{$rows}'> </td>";
}
/**
. '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />';
if( $wgUseTwoButtonsSearchForm ) {
- $s .= ' <input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
+ $s .= ' <input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
} else {
$s .= ' <a href="' . $this->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n";
}
$nt = Title::newFromText( $l );
$url = $nt->escapeFullURL();
$text = $wgContLang->getLanguageName( $nt->getInterwiki() );
+ $title = htmlspecialchars( $nt->getText() );
if ( $text == '' ) {
$text = $l;
}
$style = $this->getExternalLinkAttributes();
- $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
+ $s .= "<a href=\"{$url}\" title=\"{$title}\"{$style}>{$text}</a>";
}
if( $wgContLang->isRTL() ) {
$s .= '</span>';
);
}
+ function getUploadLink() {
+ global $wgUploadNavigationUrl;
+
+ if( $wgUploadNavigationUrl ) {
+ # Using an empty class attribute to avoid automatic setting of "external" class
+ return $this->makeExternalLink( $wgUploadNavigationUrl, wfMsgHtml( 'upload' ), false, null, array( 'class' => '') );
+ } else {
+ return $this->link(
+ SpecialPage::getTitleFor('Upload'),
+ wfMsgHtml( 'upload' ),
+ array(),
+ array(),
+ array( 'known', 'noclasses' )
+ );
+ }
+ }
+
/* these are used extensively in SkinTemplate, but also some other places */
static function makeMainPageUrl( $urlaction = '' ) {
$title = Title::newMainPage();
/**
* Add content from plain text
+ * @since 1.17
* @param &$bar array
* @param $text string
*/
function addToSidebarPlain( &$bar, $text ) {
$lines = explode( "\n", $text );
+ $wikiBar = array(); # We need to handle the wikitext on a different variable, to avoid trying to do an array operation on text, which would be a fatal error.
+
$heading = '';
foreach( $lines as $line ) {
if( strpos( $line, '*' ) !== 0 ) {
$bar[$heading] = array();
}
} else {
+ $line = trim( $line, '* ' );
if( strpos( $line, '|' ) !== false ) { // sanity check
- $line = array_map( 'trim', explode( '|', trim( $line, '* ' ), 2 ) );
+ $line = array_map( 'trim', explode( '|', $line, 2 ) );
$link = wfMsgForContent( $line[0] );
if( $link == '-' ) {
continue;
'id' => 'n-' . strtr( $line[1], ' ', '-' ),
'active' => false
);
+ } else if ( (substr($line, 0, 2) == '{{') && (substr($line, -2) == '}}') ) {
+ global $wgParser, $wgTitle;
+
+ $line = substr($line, 2, strlen($line) - 4 );
+
+ if (is_null($wgParser->mOptions))
+ $wgParser->mOptions = new ParserOptions();
+
+ $wgParser->mOptions->setEditSection(false);
+ $wikiBar[$heading] = $wgParser->parse( wfMsgForContentNoTrans( $line ) , $wgTitle, $wgParser->mOptions )->getText();
} else {
continue;
}
}
}
+
+ if ( count($wikiBar) > 0 )
+ $bar = array_merge($bar, $wikiBar);
+
+ return $bar;
}
/**
public function commonPrintStylesheet() {
return true;
}
+
+ /**
+ * Gets new talk page messages for the current user.
+ * @return MediaWiki message or if no new talk page messages, nothing
+ */
+ function getNewtalks() {
+ global $wgUser, $wgOut;
+ $newtalks = $wgUser->getNewMessageLinks();
+ $ntl = '';
+
+ if( count( $newtalks ) == 1 && $newtalks[0]['wiki'] === wfWikiID() ) {
+ $userTitle = $this->mUser->getUserPage();
+ $userTalkTitle = $userTitle->getTalkPage();
+
+ if( !$userTalkTitle->equals( $this->mTitle ) ) {
+ $newMessagesLink = $this->link(
+ $userTalkTitle,
+ wfMsgHtml( 'newmessageslink' ),
+ array(),
+ array( 'redirect' => 'no' ),
+ array( 'known', 'noclasses' )
+ );
+
+ $newMessagesDiffLink = $this->link(
+ $userTalkTitle,
+ wfMsgHtml( 'newmessagesdifflink' ),
+ array(),
+ array( 'diff' => 'cur' ),
+ array( 'known', 'noclasses' )
+ );
+
+ $ntl = wfMsg(
+ 'youhavenewmessages',
+ $newMessagesLink,
+ $newMessagesDiffLink
+ );
+ # Disable Squid cache
+ $wgOut->setSquidMaxage( 0 );
+ }
+ } elseif( count( $newtalks ) ) {
+ // _>" " for BC <= 1.16
+ $sep = str_replace( '_', ' ', wfMsgHtml( 'newtalkseparator' ) );
+ $msgs = array();
+ foreach( $newtalks as $newtalk ) {
+ $msgs[] = Xml::element(
+ 'a',
+ array( 'href' => $newtalk['link'] ), $newtalk['wiki']
+ );
+ }
+ $parts = implode( $sep, $msgs );
+ $ntl = wfMsgHtml( 'youhavenewmessagesmulti', $parts );
+ $wgOut->setSquidMaxage( 0 );
+ }
+ return $ntl;
+ }
+
}