*/
if( defined( "MEDIAWIKI" ) ) {
-# See skin.doc
+# See skin.txt
require_once( 'Linker.php' );
require_once( 'Image.php' );
require_once( 'RecentChange.php' );
-global $wgLinkHolders;
-$wgLinkHolders = array(
- 'namespaces' => array(),
- 'dbkeys' => array(),
- 'queries' => array(),
- 'texts' => array(),
- 'titles' => array()
-);
-global $wgInterwikiLinkHolders;
-$wgInterwikiLinkHolders = array();
-
/**
* @todo document
* @package MediaWiki
wfProfileIn( 'Skin::outputPage' );
$this->initPage( $out );
+
$out->out( $out->headElement() );
$out->out( "\n<body" );
$out->out( "<!-- Wiki debugging output:\n" .
$out->mDebugtext . "-->\n" );
}
+
$out->out( $this->beforeContent() );
$out->out( $out->mBodytext . "\n" );
}
function getHeadScripts() {
- global $wgStylePath, $wgUser, $wgContLang, $wgAllowUserJs;
- $r = "<script type=\"text/javascript\" src=\"{$wgStylePath}/common/wikibits.js\"></script>\n";
+ global $wgStylePath, $wgUser, $wgContLang, $wgAllowUserJs, $wgJsMimeType;
+ $r = "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js\"></script>\n";
+ $r.= "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/sorttable.js\"></script>\n";
if( $wgAllowUserJs && $wgUser->isLoggedIn() ) {
$userpage = $wgUser->getUserPage();
$userjs = htmlspecialchars( $this->makeUrl(
$userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
- 'action=raw&ctype=text/javascript'));
- $r .= '<script type="text/javascript" src="'.$userjs."\"></script>\n";
+ 'action=raw&ctype='.$wgJsMimeType));
+ $r .= '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>\n";
}
return $r;
}
*/
function userCanPreview( $action ) {
global $wgTitle, $wgRequest, $wgUser;
-
+
if( $action != 'submit' )
return false;
if( !$wgRequest->wasPosted() )
return false;
- if( !$wgTitle->userCanEditCssJsSubpage() )
+ if( !$wgTitle->userCanEditCssJsSubpage() )
return false;
return $wgUser->matchEditToken(
$wgRequest->getVal( 'wpEditToken' ) );
}
-
+
# get the user/site-specific stylesheet, SkinPHPTal called from RawPage.php (settings are cached that way)
function getUserStylesheet() {
global $wgOut, $wgStylePath, $wgContLang, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
return $s . $this->reallyDoGetUserStyles();
}
-
+
function reallyDoGetUserStyles() {
global $wgUser;
$s = '';
- $underline = $wgUser->getOption( "underline" ) ? 'underline' : 'none';
- $s .= "a { text-decoration: $underline; }\n";
+ if (($undopt = $wgUser->getOption("underline")) != 2) {
+ $underline = $undopt ? 'underline' : 'none';
+ $s .= "a { text-decoration: $underline; }\n";
+ }
if( $wgUser->getOption( 'highlightbroken' ) ) {
$s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
} else {
END;
}
if( $wgUser->getOption( 'justify' ) ) {
- $s .= "#article { text-align: justify; }\n";
+ $s .= "#article, #bodyContent { text-align: justify; }\n";
}
if( !$wgUser->getOption( 'showtoc' ) ) {
$s .= "#toc { display: none; }\n";
}
+ if( !$wgUser->getOption( 'editsection' ) ) {
+ $s .= ".editsection { display: none; }\n";
+ }
return $s;
}
}
function doBeforeContent() {
- global $wgOut, $wgTitle, $wgContLang, $wgSiteNotice;
+ global $wgOut, $wgTitle, $wgContLang;
$fname = 'Skin::doBeforeContent';
wfProfileIn( $fname );
$s .= "</tr>\n</table>\n</div>\n";
$s .= "\n<div id='article'>\n";
- if( $wgSiteNotice ) {
- $s .= "\n<div id='siteNotice'>$wgSiteNotice</div>\n";
+ $notice = wfGetSiteNotice();
+ if( $notice ) {
+ $s .= "\n<div id='siteNotice'>$notice</div>\n";
}
$s .= $this->pageTitle();
$s .= $this->pageSubtitle() ;
return $s;
}
-
+
function getCategoryLinks () {
global $wgOut, $wgTitle, $wgParser;
global $wgUseCategoryMagic, $wgUseCategoryBrowser, $wgLang;
# get a big array of the parents tree
$parenttree = $wgTitle->getParentCategoryTree();
- # Render the array as a serie of links
- # Need to give skin cause $this is undefined at this level
- function walkThrough ($tree, &$skin) {
- $return = '';
- foreach($tree as $element => $parent) {
- if(empty($parent)) {
- # element start a new list
- $return .= '<br />';
- } else {
- # grab the others elements
- $return .= walkThrough($parent, $skin);
- }
- # add our current element to the list
- $eltitle = Title::NewFromText($element);
- if(!empty($parent)) $return .= ' > ';
- $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
- }
- return $return;
- }
-
# Skin object passed by reference cause it can not be
# accessed under the method subfunction walkThrough.
- $s .= walkThrough($parenttree, $this);
+ $s .= Skin::drawCategoryBrowser($parenttree, $this);
}
return $s;
}
+ # Render the array as a serie of links
+ function drawCategoryBrowser ($tree, &$skin) {
+ $return = '';
+ foreach ($tree as $element => $parent) {
+ if (empty($parent)) {
+ # element start a new list
+ $return .= '<br />';
+ } else {
+ # grab the others elements
+ $return .= Skin::drawCategoryBrowser($parent, $skin);
+ }
+ # add our current element to the list
+ $eltitle = Title::NewFromText($element);
+ if (!empty($parent)) $return .= ' > ';
+ $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
+ }
+ return $return;
+ }
+
function getCategories() {
$catlinks=$this->getCategoryLinks();
if(!empty($catlinks)) {
function doAfterContent() { }
function pageTitleLinks() {
- global $wgOut, $wgTitle, $wgUser, $wgContLang, $wgUseApproval, $wgRequest;
+ global $wgOut, $wgTitle, $wgUser, $wgContLang, $wgRequest;
extract( $wgRequest->getValues( 'oldid', 'diff' ) );
$action = $wgRequest->getText( 'action' );
if ( $wgOut->isArticleRelated() ) {
if ( $wgTitle->getNamespace() == NS_IMAGE ) {
$name = $wgTitle->getDBkey();
- $image = new Image( $wgTitle->getDBkey() );
+ $image = new Image( $wgTitle );
if( $image->exists() ) {
$link = htmlspecialchars( $image->getURL() );
$style = $this->getInternalLinkAttributes( $link, $name );
$s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
}
}
- # This will show the "Approve" link if $wgUseApproval=true;
- if ( isset ( $wgUseApproval ) && $wgUseApproval )
- {
- $t = $wgTitle->getDBkey();
- $name = 'Approve this article' ;
- $link = "http://test.wikipedia.org/w/magnus/wiki.phtml?title={$t}&action=submit&doit=1" ;
- #htmlspecialchars( wfImageUrl( $name ) );
- $style = $this->getExternalLinkAttributes( $link, $name );
- $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>" ;
- }
}
if ( 'history' == $action || isset( $diff ) || isset( $oldid ) ) {
$s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
# do not show "You have new messages" text when we are viewing our
# own talk page
- if( $wgTitle->equals( $wgUser->getTalkPage() ) ) {
+ if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
$tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
wfMsg('newmessageslink') );
$s.= ' | <strong>'. wfMsg( 'newmessages', $tl ) . '</strong>';
}
}
}
-
+
$go = wfMsg( 'go' );
$sp = wfMsg( 'specialpages' );
$spp = $wgContLang->specialPage( 'Specialpages' );
$s .= "<select name=\"wpDropdown\">\n";
$s .= "<option value=\"{$spp}\">{$sp}</option>\n";
-
+
foreach ( $a as $name => $desc ) {
$p = $wgContLang->specialPage( $name );
$s .= "<option value=\"{$p}\">{$desc}</option>\n";
# 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
# 1 != $wgUser->getOption('disablemail'); # and not disabled
}
-
+
function emailUserLink() {
global $wgTitle;
}
function otherLanguages() {
- global $wgOut, $wgContLang, $wgTitle;
+ global $wgOut, $wgContLang, $wgTitle, $wgHideInterlanguageLinks;
+
+ if ( $wgHideInterlanguageLinks ) {
+ return '';
+ }
$a = $wgOut->getLanguageLinks();
if ( 0 == count( $a ) ) {
$title = Title::makeTitle( NS_SPECIAL, $name );
return $title->getLocalURL( $urlaction );
}
-
+
/*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
$title = Title::newFromText( wfMsgForContent($name) );
$this->checkTitle($title, $name);
return $title->getLocalURL( $urlaction );
}
-
+
/*static*/ function makeUrl ( $name, $urlaction='' ) {
$title = Title::newFromText( $name );
$this->checkTitle($title, $name);
}
}
+ /**
+ * Build an array that represents the sidebar(s), the navigation bar among them
+ *
+ * @return array
+ * @access private
+ */
+ function buildSidebar() {
+ $fname = 'SkinTemplate::buildSidebar';
+ wfProfileIn( $fname );
+
+ $bar = array();
+ $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
+ foreach ($lines as $line) {
+ if (strpos($line, '*') !== 0)
+ continue;
+ if (strpos($line, '**') !== 0) {
+ $line = trim($line, '* ');
+ $heading = $line;
+ } else {
+ if (strpos($line, '|') !== false) { // sanity check
+ $line = explode( '|' , trim($line, '* '), 2 );
+ $link = wfMsgForContent( $line[0] );
+ if ($link == '-')
+ continue;
+ $bar[$heading][] = array(
+ 'text' => wfMsg( $line[1] ),
+ 'href' => $this->makeInternalOrExternalUrl( $link ),
+ 'id' => 'n-' . strtr($line[1], ' ', '-'),
+ );
+ } else { continue; }
+ }
+ }
+
+ wfProfileOut( $fname );
+ return $bar;
+ }
}
}