<?php
if ( ! defined( 'MEDIAWIKI' ) )
- die( -1 );
+ die( 1 );
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# http://www.gnu.org/copyleft/gpl.html
/**
* @subpackage Skins
*/
-require_once 'GlobalFunctions.php';
-
/**
* Wrapper object for MediaWiki's localization functions,
* to be passed to the template engine.
*
- * @access private
+ * @private
* @package MediaWiki
*/
class MediaWiki_I18N {
*/
class SkinTemplate extends Skin {
/**#@+
- * @access private
+ * @private
*/
/**
* @param string $repository subdirectory where we keep template files
* @param string $cache_dir
* @return object
- * @access private
+ * @private
*/
function setupTemplate( $classname, $repository=false, $cache_dir=false ) {
return new $classname();
* initialize various variables and generate the template
*
* @param OutputPage $out
- * @access public
+ * @public
*/
function outputPage( &$out ) {
global $wgTitle, $wgArticle, $wgUser, $wgLang, $wgContLang, $wgOut;
global $wgPageShowWatchingUsers;
global $wgUseTrackbacks;
global $wgDBname;
+ global $wgArticlePath, $wgScriptPath, $wgServer, $wgLang, $wgCanonicalNamespaceNames;
$fname = 'SkinTemplate::outputPage';
wfProfileIn( $fname );
+ // Hook that allows last minute changes to the output page, e.g.
+ // adding of CSS or Javascript by extensions.
+ wfRunHooks( 'BeforePageDisplay', array( &$out ) );
+
extract( $wgRequest->getValues( 'oldid', 'diff' ) );
wfProfileIn( "$fname-init" );
wfProfileIn( "$fname-stuff2" );
$tpl->set( 'title', $wgOut->getPageTitle() );
$tpl->set( 'pagetitle', $wgOut->getHTMLTitle() );
+ $tpl->set( 'displaytitle', $wgOut->mPageLinkTitle );
+ $nsname = @$wgCanonicalNamespaceNames[ $this->mTitle->getNamespace() ];
+ if ( $nsname === NULL ) $nsname = $this->mTitle->getNsText();
+
+ $tpl->set( 'nscanonical', $nsname );
+ $tpl->set( 'titleprefixeddbkey', $this->mTitle->getPrefixedDBKey() );
+ $tpl->set( 'titletext', $this->mTitle->getText() );
+ $tpl->set( 'articleid', $this->mTitle->getArticleId() );
+
$tpl->setRef( "thispage", $this->thispage );
$subpagestr = $this->subPageSubtitle();
$tpl->set(
$tpl->set('headscripts', $out->getScript() );
$tpl->setRef( 'wgScript', $wgScript );
$tpl->setRef( 'skinname', $this->skinname );
+ $tpl->set( 'skinclass', get_class( $this ) );
$tpl->setRef( 'stylename', $this->stylename );
$tpl->set( 'printable', $wgRequest->getBool( 'printable' ) );
$tpl->setRef( 'loggedin', $this->loggedin );
$tpl->set( 'searchaction', $this->escapeSearchLink() );
$tpl->set( 'search', trim( $wgRequest->getVal( 'search' ) ) );
$tpl->setRef( 'stylepath', $wgStylePath );
+ $tpl->setRef( 'articlepath', $wgArticlePath );
+ $tpl->setRef( 'scriptpath', $wgScriptPath );
+ $tpl->setRef( 'serverurl', $wgServer );
$tpl->setRef( 'logopath', $wgLogo );
$tpl->setRef( "lang", $wgContLanguageCode );
$tpl->set( 'dir', $wgContLang->isRTL() ? "rtl" : "ltr" );
$tpl->set( 'rtl', $wgContLang->isRTL() );
$tpl->set( 'langname', $wgContLang->getLanguageName( $wgContLanguageCode ) );
$tpl->set( 'showjumplinks', $wgUser->getOption( 'showjumplinks' ) );
- $tpl->setRef( 'username', $this->username );
+ $tpl->set( 'username', $wgUser->isAnon() ? NULL : $this->username );
$tpl->setRef( 'userpage', $this->userpage);
$tpl->setRef( 'userpageurl', $this->userpageUrlDetails['href']);
+ $tpl->set( 'userlang', $wgLang->getCode() );
$tpl->set( 'pagecss', $this->setupPageCss() );
$tpl->setRef( 'usercss', $this->usercss);
$tpl->setRef( 'userjs', $this->userjs);
$sep = str_replace("_", " ", wfMsgHtml("newtalkseperator"));
$msgs = array();
foreach ($newtalks as $newtalk) {
- $msgs[] = wfElement("a",
+ $msgs[] = wfElement("a",
array('href' => $newtalk["link"]), $newtalk["wiki"]);
}
$parts = implode($sep, $msgs);
$tpl->setRef( 'newtalk', $ntl );
$tpl->setRef( 'skin', $this);
$tpl->set( 'logo', $this->logoText() );
- if ( $wgOut->isArticle() and (!isset( $oldid ) or isset( $diff )) and 0 != $wgArticle->getID() ) {
+ if ( $wgOut->isArticle() and (!isset( $oldid ) or isset( $diff )) and
+ $wgArticle and 0 != $wgArticle->getID() )
+ {
if ( !$wgDisableCounters ) {
$viewcount = $wgLang->formatNum( $wgArticle->getCount() );
if ( $viewcount ) {
- $tpl->set('viewcount', wfMsg( "viewcount", $viewcount ));
+ $tpl->set('viewcount', wfMsgExt( 'viewcount', array( 'parseinline' ), $viewcount ) );
} else {
$tpl->set('viewcount', false);
}
$tpl->setRef( 'debug', $out->mDebugtext );
$tpl->set( 'reporttime', $out->reportTime() );
$tpl->set( 'sitenotice', wfGetSiteNotice() );
+ $tpl->set( 'bottomscripts', $this->bottomScripts() );
$printfooter = "<div class=\"printfooter\">\n" . $this->printSource() . "</div>\n";
$out->mBodytext .= $printfooter ;
* For the base class, assume strings all around.
*
* @param mixed $str
- * @access private
+ * @private
*/
function printOrError( &$str ) {
echo $str;
/**
* build array of urls for personal toolbar
* @return array
- * @access private
+ * @private
*/
function buildPersonalUrls() {
global $wgTitle, $wgShowIPinHeader;
);
}
}
+
+ wfRunHooks( 'PersonalUrls', array( &$personal_urls, &$wgTitle ) );
wfProfileOut( $fname );
return $personal_urls;
}
$text = wfMsg( $message );
if ( $text == "<$message>" ) {
- $text = html_entity_decode($text);
+ global $wgContLang;
+ $text = $wgContLang->getNsText( Namespace::getSubject( $title->getNamespace() ) );
}
return array(
/**
* an array of edit links by default used for the tabs
* @return array
- * @access private
+ * @private
*/
function buildContentActionUrls () {
- global $wgContLang;
+ global $wgContLang, $wgOut;
$fname = 'SkinTemplate::buildContentActionUrls';
wfProfileIn( $fname );
$subjpage = $this->mTitle->getSubjectPage();
$talkpage = $this->mTitle->getTalkPage();
- $nskey = $this->getNameSpaceKey();
+ $nskey = $this->mTitle->getNamespaceKey();
$content_actions[$nskey] = $this->tabAction(
$subjpage,
$nskey,
true);
wfProfileIn( "$fname-edit" );
- if ( $this->mTitle->userCanEdit() ) {
+ if ( $this->mTitle->userCanEdit() && ( $this->mTitle->exists() || $this->mTitle->userCanCreate() ) ) {
$istalk = $this->mTitle->isTalkPage();
$istalkclass = $istalk?' istalk':'';
$content_actions['edit'] = array(
'href' => $this->mTitle->getLocalUrl( $this->editUrlOptions() )
);
- if ( $istalk ) {
+ if ( $istalk || $wgOut->showNewSectionLink() ) {
$content_actions['addsection'] = array(
'class' => $section == 'new'?'selected':false,
'text' => wfMsg('addsection'),
);
}
if ( $this->mTitle->userCanMove()) {
+ $moveTitle = Title::makeTitle( NS_SPECIAL, 'Movepage' );
$content_actions['move'] = array(
'class' => ($this->mTitle->getDbKey() == 'Movepage' and $this->mTitle->getNamespace == NS_SPECIAL) ? 'selected' : false,
'text' => wfMsg('move'),
- 'href' => $this->makeSpecialUrl("Movepage/$this->thispage" )
+ 'href' => $moveTitle->getLocalUrl( 'target=' . urlencode( $this->thispage ) )
);
}
} else {
//article doesn't exist or is deleted
- if($wgUser->isAllowed('delete')){
+ if( $wgUser->isAllowed( 'delete' ) ) {
if( $n = $this->mTitle->isDeleted() ) {
+ $undelTitle = Title::makeTitle( NS_SPECIAL, 'Undelete' );
$content_actions['undelete'] = array(
'class' => false,
- 'text' => ($n == 1) ? wfMsg( 'undelete_short1' ) : wfMsg('undelete_short', $n ),
- 'href' => $this->makeSpecialUrl("Undelete/$this->thispage")
+ 'text' => wfMsgExt( 'undelete_short', array( 'parsemag' ), $n ),
+ 'href' => $undelTitle->getLocalUrl( 'target=' . urlencode( $this->thispage ) )
+ #'href' => $this->makeSpecialUrl("Undelete/$this->thispage")
);
}
}
$content_actions['varlang-' . $vcount] = array(
'class' => $selected,
'text' => $varname,
- 'href' => $this->mTitle->getLocalUrl( $actstr . 'variant=' . $code )
+ 'href' => $this->mTitle->getLocalUrl( $actstr . 'variant=' . urlencode( $code ) )
);
$vcount ++;
}
/**
* build array of common navigation links
* @return array
- * @access private
+ * @private
*/
function buildNavUrls () {
global $wgUseTrackbacks, $wgTitle, $wgArticle;
// A print stylesheet is attached to all pages, but nobody ever
// figures that out. :) Add a link...
if( $this->iscontent && ($action == '' || $action == 'view' || $action == 'purge' ) ) {
- $revid = $wgArticle->getRevIdFetched();
+ $revid = $wgArticle ? $wgArticle->getLatest() : 0;
if ( !( $revid == 0 ) )
$nav_urls['print'] = array(
'text' => wfMsg( 'printableversion' ),
wfRunHooks( 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink', array( &$this, &$nav_urls, &$oldid, &$revid ) );
}
- if( $this->mTitle->getNamespace() != NS_SPECIAL) {
+ if( $this->mTitle->getNamespace() != NS_SPECIAL ) {
+ $wlhTitle = Title::makeTitle( NS_SPECIAL, 'Whatlinkshere' );
$nav_urls['whatlinkshere'] = array(
- 'href' => $this->makeSpecialUrl("Whatlinkshere/$this->thispage")
+ 'href' => $wlhTitle->getLocalUrl( 'target=' . urlencode( $this->thispage ) )
);
if( $this->mTitle->getArticleId() ) {
+ $rclTitle = Title::makeTitle( NS_SPECIAL, 'Recentchangeslinked' );
$nav_urls['recentchangeslinked'] = array(
- 'href' => $this->makeSpecialUrl("Recentchangeslinked/$this->thispage")
+ 'href' => $rclTitle->getLocalUrl( 'target=' . urlencode( $this->thispage ) )
);
}
if ($wgUseTrackbacks)
/**
* Generate strings used for xml 'id' names
* @return string
- * @access private
+ * @private
*/
function getNameSpaceKey () {
- switch ($this->mTitle->getNamespace()) {
- case NS_MAIN:
- case NS_TALK:
- return 'nstab-main';
- case NS_USER:
- case NS_USER_TALK:
- return 'nstab-user';
- case NS_MEDIA:
- return 'nstab-media';
- case NS_SPECIAL:
- return 'nstab-special';
- case NS_PROJECT:
- case NS_PROJECT_TALK:
- return 'nstab-wp';
- case NS_IMAGE:
- case NS_IMAGE_TALK:
- return 'nstab-image';
- case NS_MEDIAWIKI:
- case NS_MEDIAWIKI_TALK:
- return 'nstab-mediawiki';
- case NS_TEMPLATE:
- case NS_TEMPLATE_TALK:
- return 'nstab-template';
- case NS_HELP:
- case NS_HELP_TALK:
- return 'nstab-help';
- case NS_CATEGORY:
- case NS_CATEGORY_TALK:
- return 'nstab-category';
- default:
- return 'nstab-' . strtolower( $this->mTitle->getSubjectNsText() );
- }
+ return $this->mTitle->getNamespaceKey();
}
/**
- * @access private
+ * @private
*/
function setupUserCss() {
$fname = 'SkinTemplate::setupUserCss';
}
/**
- * @access private
+ * @private
*/
function setupUserJs() {
$fname = 'SkinTemplate::setupUserJs';
* Code for extensions to hook into to provide per-page CSS, see
* extensions/PageCSS/PageCSS.php for an implementation of this.
*
- * @access private
+ * @private
*/
function setupPageCss() {
$fname = 'SkinTemplate::setupPageCss';
/**
* returns css with user-specific options
- * @access public
+ * @public
*/
function getUserStylesheet() {
}
/**
- * @access public
+ * @public
*/
function getUserJs() {
$fname = 'SkinTemplate::getUserJs';
*/
class QuickTemplate {
/**
- * @access public
+ * @public
*/
function QuickTemplate() {
$this->data = array();
}
/**
- * @access public
+ * @public
*/
function set( $name, $value ) {
$this->data[$name] = $value;
}
/**
- * @access public
+ * @public
*/
function setRef($name, &$value) {
$this->data[$name] =& $value;
}
/**
- * @access public
+ * @public
*/
function setTranslator( &$t ) {
$this->translator = &$t;
}
/**
- * @access public
+ * @public
*/
function execute() {
echo "Override this function.";
/**
- * @access private
+ * @private
*/
function text( $str ) {
echo htmlspecialchars( $this->data[$str] );
}
/**
- * @access private
+ * @private
+ */
+ function jstext( $str ) {
+ echo Xml::escapeJsString( $this->data[$str] );
+ }
+
+ /**
+ * @private
*/
function html( $str ) {
echo $this->data[$str];
}
/**
- * @access private
+ * @private
*/
function msg( $str ) {
echo htmlspecialchars( $this->translator->translate( $str ) );
}
/**
- * @access private
+ * @private
*/
function msgHtml( $str ) {
echo $this->translator->translate( $str );
/**
* An ugly, ugly hack.
- * @access private
+ * @private
*/
function msgWiki( $str ) {
global $wgParser, $wgTitle, $wgOut;
$text = $this->translator->translate( $str );
$parserOutput = $wgParser->parse( $text, $wgTitle,
- $wgOut->mParserOptions, true );
+ $wgOut->parserOptions(), true );
echo $parserOutput->getText();
}
/**
- * @access private
+ * @private
*/
function haveData( $str ) {
return $this->data[$str];
}
/**
- * @access private
+ * @private
*/
function haveMsg( $str ) {
$msg = $this->translator->translate( $str );