2004-11-19 04:14:59 +00:00
|
|
|
<?php
|
2006-01-07 12:31:39 +00:00
|
|
|
if ( ! defined( 'MEDIAWIKI' ) )
|
2006-06-07 04:15:58 +00:00
|
|
|
die( 1 );
|
2006-01-07 12:31:39 +00:00
|
|
|
|
2004-11-19 04:14:59 +00:00
|
|
|
# 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
|
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
#
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
#
|
|
|
|
|
# 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.,
|
2006-04-05 07:43:17 +00:00
|
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2004-11-19 04:14:59 +00:00
|
|
|
# http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
|
|
|
|
|
/**
|
2004-11-19 12:44:51 +00:00
|
|
|
* Wrapper object for MediaWiki's localization functions,
|
|
|
|
|
* to be passed to the template engine.
|
|
|
|
|
*
|
2006-04-20 20:43:38 +00:00
|
|
|
* @private
|
2007-04-24 06:53:31 +00:00
|
|
|
* @addtogroup Skins
|
2004-11-19 04:14:59 +00:00
|
|
|
*/
|
|
|
|
|
class MediaWiki_I18N {
|
|
|
|
|
var $_context = array();
|
|
|
|
|
|
|
|
|
|
function set($varName, $value) {
|
|
|
|
|
$this->_context[$varName] = $value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function translate($value) {
|
2004-11-22 06:50:37 +00:00
|
|
|
$fname = 'SkinTemplate-translate';
|
|
|
|
|
wfProfileIn( $fname );
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2004-11-19 04:14:59 +00:00
|
|
|
// Hack for i18n:attributes in PHPTAL 1.0.0 dev version as of 2004-10-23
|
|
|
|
|
$value = preg_replace( '/^string:/', '', $value );
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2004-11-19 04:14:59 +00:00
|
|
|
$value = wfMsg( $value );
|
|
|
|
|
// interpolate variables
|
Changing lines like this: "extract( $dbw->tableNames( 'page', 'archive' ) );" to be like this: "list ($page, $archive) = $dbw->tableNamesN( 'page', 'archive' );".
Three reasons for this:
1) It's better for analysis tools [which want explicit variable declaration]
2) It's easier for a human to read, as it's completely explicit where the variables came from [which is something you don't get with extract() ]
3) It makes it easier to find everywhere where a variable is used with search/grep [which you can't currently do with $tbl_page variables from things like: "extract($db->tableNames( 'page', 'revision'), EXTR_PREFIX_ALL, 'tbl');"].
Otherwise, from a functionality/efficiency perspective the two forms should be identical.
By doing this have been able run static analysis over the usages of these variables, thus eliminating 5 unneeded table names from calls, plus removing 3 unused calls entirely, and it just feels subjectively slightly nicer to me.
2006-11-27 08:36:57 +00:00
|
|
|
$m = array();
|
2004-11-19 04:14:59 +00:00
|
|
|
while (preg_match('/\$([0-9]*?)/sm', $value, $m)) {
|
|
|
|
|
list($src, $var) = $m;
|
|
|
|
|
wfSuppressWarnings();
|
|
|
|
|
$varValue = $this->_context[$var];
|
|
|
|
|
wfRestoreWarnings();
|
|
|
|
|
$value = str_replace($src, $varValue, $value);
|
|
|
|
|
}
|
2004-11-22 06:50:37 +00:00
|
|
|
wfProfileOut( $fname );
|
2004-11-19 04:14:59 +00:00
|
|
|
return $value;
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-11-19 12:44:51 +00:00
|
|
|
|
2004-11-19 04:14:59 +00:00
|
|
|
/**
|
2007-04-24 06:53:31 +00:00
|
|
|
* Template-filler skin base class
|
|
|
|
|
* Formerly generic PHPTal (http://phptal.sourceforge.net/) skin
|
|
|
|
|
* Based on Brion's smarty skin
|
|
|
|
|
* @copyright Copyright © Gabriel Wicke -- http://www.aulinx.de/
|
|
|
|
|
*
|
|
|
|
|
* @todo Needs some serious refactoring into functions that correspond
|
|
|
|
|
* to the computations individual esi snippets need. Most importantly no body
|
|
|
|
|
* parsing for most of those of course.
|
|
|
|
|
*
|
|
|
|
|
* @addtogroup Skins
|
2004-11-19 04:14:59 +00:00
|
|
|
*/
|
|
|
|
|
class SkinTemplate extends Skin {
|
|
|
|
|
/**#@+
|
2006-04-20 20:43:38 +00:00
|
|
|
* @private
|
2004-11-19 04:14:59 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Name of our skin, set in initPage()
|
|
|
|
|
* It probably need to be all lower case.
|
|
|
|
|
*/
|
|
|
|
|
var $skinname;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Stylesheets set to use
|
|
|
|
|
* Sub directory in ./skins/ where various stylesheets are located
|
|
|
|
|
*/
|
|
|
|
|
var $stylename;
|
|
|
|
|
|
|
|
|
|
/**
|
2004-11-25 05:31:49 +00:00
|
|
|
* For QuickTemplate, the name of the subclass which
|
2004-11-19 12:44:51 +00:00
|
|
|
* will actually fill the template.
|
2004-11-19 04:14:59 +00:00
|
|
|
*/
|
|
|
|
|
var $template;
|
|
|
|
|
|
|
|
|
|
/**#@-*/
|
|
|
|
|
|
2004-11-19 12:44:51 +00:00
|
|
|
/**
|
|
|
|
|
* Setup the base parameters...
|
|
|
|
|
* Child classes should override this to set the name,
|
|
|
|
|
* style subdirectory, and template filler callback.
|
|
|
|
|
*
|
|
|
|
|
* @param OutputPage $out
|
|
|
|
|
*/
|
2004-11-19 04:14:59 +00:00
|
|
|
function initPage( &$out ) {
|
|
|
|
|
parent::initPage( $out );
|
|
|
|
|
$this->skinname = 'monobook';
|
|
|
|
|
$this->stylename = 'monobook';
|
2004-11-25 05:31:49 +00:00
|
|
|
$this->template = 'QuickTemplate';
|
2004-11-19 04:14:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2004-11-19 12:44:51 +00:00
|
|
|
* Create the template engine object; we feed it a bunch of data
|
|
|
|
|
* and eventually it spits out some HTML. Should have interface
|
|
|
|
|
* roughly equivalent to PHPTAL 0.7.
|
|
|
|
|
*
|
|
|
|
|
* @param string $callback (or file)
|
|
|
|
|
* @param string $repository subdirectory where we keep template files
|
|
|
|
|
* @param string $cache_dir
|
2004-11-19 04:14:59 +00:00
|
|
|
* @return object
|
2006-04-20 20:43:38 +00:00
|
|
|
* @private
|
2004-11-19 04:14:59 +00:00
|
|
|
*/
|
2005-07-22 11:29:15 +00:00
|
|
|
function setupTemplate( $classname, $repository=false, $cache_dir=false ) {
|
2004-11-25 05:31:49 +00:00
|
|
|
return new $classname();
|
2004-11-19 04:14:59 +00:00
|
|
|
}
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2004-11-19 04:14:59 +00:00
|
|
|
/**
|
|
|
|
|
* initialize various variables and generate the template
|
2004-11-19 12:44:51 +00:00
|
|
|
*
|
|
|
|
|
* @param OutputPage $out
|
2006-04-20 20:43:38 +00:00
|
|
|
* @public
|
2004-11-19 04:14:59 +00:00
|
|
|
*/
|
|
|
|
|
function outputPage( &$out ) {
|
|
|
|
|
global $wgTitle, $wgArticle, $wgUser, $wgLang, $wgContLang, $wgOut;
|
2006-05-31 20:39:14 +00:00
|
|
|
global $wgScript, $wgStylePath, $wgContLanguageCode;
|
2005-12-04 18:27:59 +00:00
|
|
|
global $wgMimeType, $wgJsMimeType, $wgOutputEncoding, $wgRequest;
|
2007-01-07 22:31:07 +00:00
|
|
|
global $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces;
|
2005-05-28 06:56:30 +00:00
|
|
|
global $wgDisableCounters, $wgLogo, $action, $wgFeedClasses, $wgHideInterlanguageLinks;
|
2004-11-19 04:14:59 +00:00
|
|
|
global $wgMaxCredits, $wgShowCreditsIfMax;
|
2004-12-18 03:47:11 +00:00
|
|
|
global $wgPageShowWatchingUsers;
|
2005-07-23 05:47:25 +00:00
|
|
|
global $wgUseTrackbacks;
|
2006-07-28 19:05:27 +00:00
|
|
|
global $wgArticlePath, $wgScriptPath, $wgServer, $wgLang, $wgCanonicalNamespaceNames;
|
2004-11-19 04:14:59 +00:00
|
|
|
|
2004-11-22 06:50:37 +00:00
|
|
|
$fname = 'SkinTemplate::outputPage';
|
|
|
|
|
wfProfileIn( $fname );
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2006-11-29 11:43:58 +00:00
|
|
|
$oldid = $wgRequest->getVal( 'oldid' );
|
|
|
|
|
$diff = $wgRequest->getVal( 'diff' );
|
2004-11-19 04:14:59 +00:00
|
|
|
|
2004-11-22 06:50:37 +00:00
|
|
|
wfProfileIn( "$fname-init" );
|
2004-11-19 04:14:59 +00:00
|
|
|
$this->initPage( $out );
|
2005-02-21 11:28:07 +00:00
|
|
|
|
2005-05-14 17:55:04 +00:00
|
|
|
$this->mTitle =& $wgTitle;
|
2005-02-21 11:28:07 +00:00
|
|
|
$this->mUser =& $wgUser;
|
|
|
|
|
|
2005-07-22 11:29:15 +00:00
|
|
|
$tpl = $this->setupTemplate( $this->template, 'skins' );
|
2004-11-19 04:14:59 +00:00
|
|
|
|
|
|
|
|
#if ( $wgUseDatabaseMessages ) { // uncomment this to fall back to GetText
|
|
|
|
|
$tpl->setTranslator(new MediaWiki_I18N());
|
|
|
|
|
#}
|
2004-11-22 06:50:37 +00:00
|
|
|
wfProfileOut( "$fname-init" );
|
2004-11-19 04:14:59 +00:00
|
|
|
|
2004-11-22 06:50:37 +00:00
|
|
|
wfProfileIn( "$fname-stuff" );
|
2005-02-21 11:28:07 +00:00
|
|
|
$this->thispage = $this->mTitle->getPrefixedDbKey();
|
|
|
|
|
$this->thisurl = $this->mTitle->getPrefixedURL();
|
2005-02-21 12:23:52 +00:00
|
|
|
$this->loggedin = $wgUser->isLoggedIn();
|
|
|
|
|
$this->iscontent = ($this->mTitle->getNamespace() != NS_SPECIAL );
|
2004-11-19 04:14:59 +00:00
|
|
|
$this->iseditable = ($this->iscontent and !($action == 'edit' or $action == 'submit'));
|
|
|
|
|
$this->username = $wgUser->getName();
|
2005-02-21 12:23:52 +00:00
|
|
|
$userPage = $wgUser->getUserPage();
|
|
|
|
|
$this->userpage = $userPage->getPrefixedText();
|
2005-10-22 20:52:30 +00:00
|
|
|
|
|
|
|
|
if ( $wgUser->isLoggedIn() || $this->showIPinHeader() ) {
|
2006-09-22 13:07:06 +00:00
|
|
|
$this->userpageUrlDetails = self::makeUrlDetails( $this->userpage );
|
2005-10-22 20:52:30 +00:00
|
|
|
} else {
|
|
|
|
|
# This won't be used in the standard skins, but we define it to preserve the interface
|
|
|
|
|
# To save time, we check for existence
|
2006-09-22 13:07:06 +00:00
|
|
|
$this->userpageUrlDetails = self::makeKnownUrlDetails( $this->userpage );
|
2005-10-22 20:52:30 +00:00
|
|
|
}
|
2004-11-19 04:14:59 +00:00
|
|
|
|
|
|
|
|
$this->usercss = $this->userjs = $this->userjsprev = false;
|
|
|
|
|
$this->setupUserCss();
|
2007-05-08 20:48:02 +00:00
|
|
|
$this->setupUserJs( $out->isUserJsAllowed() );
|
2005-02-21 11:28:07 +00:00
|
|
|
$this->titletxt = $this->mTitle->getPrefixedText();
|
2004-11-22 06:50:37 +00:00
|
|
|
wfProfileOut( "$fname-stuff" );
|
2004-11-19 04:14:59 +00:00
|
|
|
|
2004-11-22 06:50:37 +00:00
|
|
|
wfProfileIn( "$fname-stuff2" );
|
2004-11-19 04:14:59 +00:00
|
|
|
$tpl->set( 'title', $wgOut->getPageTitle() );
|
|
|
|
|
$tpl->set( 'pagetitle', $wgOut->getHTMLTitle() );
|
2006-04-11 10:16:27 +00:00
|
|
|
$tpl->set( 'displaytitle', $wgOut->mPageLinkTitle );
|
2007-01-15 16:29:41 +00:00
|
|
|
$tpl->set( 'pageclass', Sanitizer::escapeClass( 'page-'.$this->mTitle->getPrefixedText() ) );
|
2004-11-19 04:14:59 +00:00
|
|
|
|
2007-01-15 06:11:58 +00:00
|
|
|
$nsname = isset( $wgCanonicalNamespaceNames[ $this->mTitle->getNamespace() ] ) ?
|
2006-11-29 05:45:03 +00:00
|
|
|
$wgCanonicalNamespaceNames[ $this->mTitle->getNamespace() ] :
|
|
|
|
|
$this->mTitle->getNsText();
|
2006-10-20 02:57:59 +00:00
|
|
|
|
2006-07-28 19:05:27 +00:00
|
|
|
$tpl->set( 'nscanonical', $nsname );
|
2006-08-23 13:57:16 +00:00
|
|
|
$tpl->set( 'nsnumber', $this->mTitle->getNamespace() );
|
2006-07-28 19:05:27 +00:00
|
|
|
$tpl->set( 'titleprefixeddbkey', $this->mTitle->getPrefixedDBKey() );
|
|
|
|
|
$tpl->set( 'titletext', $this->mTitle->getText() );
|
|
|
|
|
$tpl->set( 'articleid', $this->mTitle->getArticleId() );
|
2006-12-03 14:13:59 +00:00
|
|
|
$tpl->set( 'currevisionid', isset( $wgArticle ) ? $wgArticle->getLatest() : 0 );
|
2006-12-03 12:35:50 +00:00
|
|
|
|
2006-08-23 13:57:16 +00:00
|
|
|
$tpl->set( 'isarticle', $wgOut->isArticle() );
|
2006-12-03 11:44:23 +00:00
|
|
|
|
2004-11-19 04:14:59 +00:00
|
|
|
$tpl->setRef( "thispage", $this->thispage );
|
|
|
|
|
$subpagestr = $this->subPageSubtitle();
|
|
|
|
|
$tpl->set(
|
|
|
|
|
'subtitle', !empty($subpagestr)?
|
|
|
|
|
'<span class="subpages">'.$subpagestr.'</span>'.$out->getSubtitle():
|
|
|
|
|
$out->getSubtitle()
|
|
|
|
|
);
|
|
|
|
|
$undelete = $this->getUndeleteLink();
|
|
|
|
|
$tpl->set(
|
|
|
|
|
"undelete", !empty($undelete)?
|
|
|
|
|
'<span class="subpages">'.$undelete.'</span>':
|
|
|
|
|
''
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$tpl->set( 'catlinks', $this->getCategories());
|
|
|
|
|
if( $wgOut->isSyndicated() ) {
|
|
|
|
|
$feeds = array();
|
2008-01-12 00:13:53 +00:00
|
|
|
foreach( $wgOut->getSyndicationLinks() as $format => $link ) {
|
2004-11-19 04:14:59 +00:00
|
|
|
$feeds[$format] = array(
|
2008-01-12 00:13:53 +00:00
|
|
|
'text' => wfMsg( "feed-$format" ),
|
|
|
|
|
'href' => $link );
|
2004-11-19 04:14:59 +00:00
|
|
|
}
|
|
|
|
|
$tpl->setRef( 'feeds', $feeds );
|
|
|
|
|
} else {
|
|
|
|
|
$tpl->set( 'feeds', false );
|
|
|
|
|
}
|
2006-11-29 05:45:03 +00:00
|
|
|
if ($wgUseTrackbacks && $out->isArticleRelated()) {
|
|
|
|
|
$tpl->set( 'trackbackhtml', $wgTitle->trackbackRDF() );
|
|
|
|
|
} else {
|
|
|
|
|
$tpl->set( 'trackbackhtml', null );
|
|
|
|
|
}
|
2005-07-23 05:47:25 +00:00
|
|
|
|
2007-01-07 22:31:07 +00:00
|
|
|
$tpl->setRef( 'xhtmldefaultnamespace', $wgXhtmlDefaultNamespace );
|
|
|
|
|
$tpl->set( 'xhtmlnamespaces', $wgXhtmlNamespaces );
|
2004-11-19 04:14:59 +00:00
|
|
|
$tpl->setRef( 'mimetype', $wgMimeType );
|
2005-05-05 21:00:49 +00:00
|
|
|
$tpl->setRef( 'jsmimetype', $wgJsMimeType );
|
2004-11-19 04:14:59 +00:00
|
|
|
$tpl->setRef( 'charset', $wgOutputEncoding );
|
|
|
|
|
$tpl->set( 'headlinks', $out->getHeadLinks() );
|
2005-08-28 21:58:14 +00:00
|
|
|
$tpl->set('headscripts', $out->getScript() );
|
2004-11-19 04:14:59 +00:00
|
|
|
$tpl->setRef( 'wgScript', $wgScript );
|
|
|
|
|
$tpl->setRef( 'skinname', $this->skinname );
|
2006-07-28 19:05:27 +00:00
|
|
|
$tpl->set( 'skinclass', get_class( $this ) );
|
2004-11-19 04:14:59 +00:00
|
|
|
$tpl->setRef( 'stylename', $this->stylename );
|
2005-06-22 22:59:39 +00:00
|
|
|
$tpl->set( 'printable', $wgRequest->getBool( 'printable' ) );
|
2004-11-19 04:14:59 +00:00
|
|
|
$tpl->setRef( 'loggedin', $this->loggedin );
|
2005-02-21 11:28:07 +00:00
|
|
|
$tpl->set('nsclass', 'ns-'.$this->mTitle->getNamespace());
|
|
|
|
|
$tpl->set('notspecialpage', $this->mTitle->getNamespace() != NS_SPECIAL);
|
2004-11-19 04:14:59 +00:00
|
|
|
/* XXX currently unused, might get useful later
|
2005-02-21 11:28:07 +00:00
|
|
|
$tpl->set( "editable", ($this->mTitle->getNamespace() != NS_SPECIAL ) );
|
|
|
|
|
$tpl->set( "exists", $this->mTitle->getArticleID() != 0 );
|
|
|
|
|
$tpl->set( "watch", $this->mTitle->userIsWatching() ? "unwatch" : "watch" );
|
|
|
|
|
$tpl->set( "protect", count($this->mTitle->isProtected()) ? "unprotect" : "protect" );
|
2004-11-19 04:14:59 +00:00
|
|
|
$tpl->set( "helppage", wfMsg('helppage'));
|
|
|
|
|
*/
|
|
|
|
|
$tpl->set( 'searchaction', $this->escapeSearchLink() );
|
2005-01-07 03:25:49 +00:00
|
|
|
$tpl->set( 'search', trim( $wgRequest->getVal( 'search' ) ) );
|
2004-11-19 04:14:59 +00:00
|
|
|
$tpl->setRef( 'stylepath', $wgStylePath );
|
2006-07-28 19:05:27 +00:00
|
|
|
$tpl->setRef( 'articlepath', $wgArticlePath );
|
|
|
|
|
$tpl->setRef( 'scriptpath', $wgScriptPath );
|
|
|
|
|
$tpl->setRef( 'serverurl', $wgServer );
|
2004-11-19 04:14:59 +00:00
|
|
|
$tpl->setRef( 'logopath', $wgLogo );
|
|
|
|
|
$tpl->setRef( "lang", $wgContLanguageCode );
|
2006-05-31 20:39:14 +00:00
|
|
|
$tpl->set( 'dir', $wgContLang->isRTL() ? "rtl" : "ltr" );
|
|
|
|
|
$tpl->set( 'rtl', $wgContLang->isRTL() );
|
2004-11-19 04:14:59 +00:00
|
|
|
$tpl->set( 'langname', $wgContLang->getLanguageName( $wgContLanguageCode ) );
|
2005-10-27 00:11:41 +00:00
|
|
|
$tpl->set( 'showjumplinks', $wgUser->getOption( 'showjumplinks' ) );
|
2006-07-28 19:05:27 +00:00
|
|
|
$tpl->set( 'username', $wgUser->isAnon() ? NULL : $this->username );
|
2004-11-19 04:14:59 +00:00
|
|
|
$tpl->setRef( 'userpage', $this->userpage);
|
|
|
|
|
$tpl->setRef( 'userpageurl', $this->userpageUrlDetails['href']);
|
2006-07-28 19:05:27 +00:00
|
|
|
$tpl->set( 'userlang', $wgLang->getCode() );
|
2005-09-29 07:55:46 +00:00
|
|
|
$tpl->set( 'pagecss', $this->setupPageCss() );
|
2004-11-19 04:14:59 +00:00
|
|
|
$tpl->setRef( 'usercss', $this->usercss);
|
|
|
|
|
$tpl->setRef( 'userjs', $this->userjs);
|
|
|
|
|
$tpl->setRef( 'userjsprev', $this->userjsprev);
|
|
|
|
|
global $wgUseSiteJs;
|
|
|
|
|
if ($wgUseSiteJs) {
|
2007-07-09 21:39:42 +00:00
|
|
|
$jsCache = $this->loggedin ? '&smaxage=0' : '';
|
|
|
|
|
$tpl->set( 'jsvarurl',
|
|
|
|
|
self::makeUrl('-',
|
|
|
|
|
"action=raw$jsCache&gen=js&useskin=" .
|
|
|
|
|
urlencode( $this->getSkinName() ) ) );
|
2004-11-19 04:14:59 +00:00
|
|
|
} else {
|
|
|
|
|
$tpl->set('jsvarurl', false);
|
|
|
|
|
}
|
2006-02-14 21:20:38 +00:00
|
|
|
$newtalks = $wgUser->getNewMessageLinks();
|
2006-02-14 21:10:31 +00:00
|
|
|
|
2006-10-04 09:06:18 +00:00
|
|
|
if (count($newtalks) == 1 && $newtalks[0]["wiki"] === wfWikiID() ) {
|
2005-02-21 11:28:07 +00:00
|
|
|
$usertitle = $this->mUser->getUserPage();
|
2004-11-19 04:14:59 +00:00
|
|
|
$usertalktitle = $usertitle->getTalkPage();
|
2005-02-21 11:28:07 +00:00
|
|
|
if( !$usertalktitle->equals( $this->mTitle ) ) {
|
2005-12-21 04:24:08 +00:00
|
|
|
$ntl = wfMsg( 'youhavenewmessages',
|
2006-11-08 07:12:03 +00:00
|
|
|
$this->makeKnownLinkObj(
|
2005-02-21 11:28:07 +00:00
|
|
|
$usertalktitle,
|
2006-02-22 22:17:25 +00:00
|
|
|
wfMsgHtml( 'newmessageslink' ),
|
|
|
|
|
'redirect=no'
|
2005-12-21 02:47:35 +00:00
|
|
|
),
|
2006-11-08 07:12:03 +00:00
|
|
|
$this->makeKnownLinkObj(
|
2005-12-21 02:47:35 +00:00
|
|
|
$usertalktitle,
|
|
|
|
|
wfMsgHtml( 'newmessagesdifflink' ),
|
|
|
|
|
'diff=cur'
|
2005-02-21 11:28:07 +00:00
|
|
|
)
|
2004-11-19 04:14:59 +00:00
|
|
|
);
|
|
|
|
|
# Disable Cache
|
|
|
|
|
$wgOut->setSquidMaxage(0);
|
|
|
|
|
}
|
2006-02-14 21:10:31 +00:00
|
|
|
} else if (count($newtalks)) {
|
2006-02-14 22:36:25 +00:00
|
|
|
$sep = str_replace("_", " ", wfMsgHtml("newtalkseperator"));
|
2006-02-14 21:10:31 +00:00
|
|
|
$msgs = array();
|
|
|
|
|
foreach ($newtalks as $newtalk) {
|
2006-03-11 17:13:49 +00:00
|
|
|
$msgs[] = wfElement("a",
|
2006-02-14 21:10:31 +00:00
|
|
|
array('href' => $newtalk["link"]), $newtalk["wiki"]);
|
|
|
|
|
}
|
|
|
|
|
$parts = implode($sep, $msgs);
|
|
|
|
|
$ntl = wfMsgHtml('youhavenewmessagesmulti', $parts);
|
|
|
|
|
$wgOut->setSquidMaxage(0);
|
2004-11-19 04:14:59 +00:00
|
|
|
} else {
|
|
|
|
|
$ntl = '';
|
|
|
|
|
}
|
2004-11-22 06:50:37 +00:00
|
|
|
wfProfileOut( "$fname-stuff2" );
|
2004-11-19 04:14:59 +00:00
|
|
|
|
2004-11-22 06:50:37 +00:00
|
|
|
wfProfileIn( "$fname-stuff3" );
|
2004-11-19 04:14:59 +00:00
|
|
|
$tpl->setRef( 'newtalk', $ntl );
|
|
|
|
|
$tpl->setRef( 'skin', $this);
|
|
|
|
|
$tpl->set( 'logo', $this->logoText() );
|
2007-01-15 06:11:58 +00:00
|
|
|
if ( $wgOut->isArticle() and (!isset( $oldid ) or isset( $diff )) and
|
|
|
|
|
$wgArticle and 0 != $wgArticle->getID() )
|
2006-08-19 03:11:49 +00:00
|
|
|
{
|
2004-11-19 04:14:59 +00:00
|
|
|
if ( !$wgDisableCounters ) {
|
|
|
|
|
$viewcount = $wgLang->formatNum( $wgArticle->getCount() );
|
|
|
|
|
if ( $viewcount ) {
|
2006-04-29 13:15:19 +00:00
|
|
|
$tpl->set('viewcount', wfMsgExt( 'viewcount', array( 'parseinline' ), $viewcount ) );
|
2004-11-19 04:14:59 +00:00
|
|
|
} else {
|
|
|
|
|
$tpl->set('viewcount', false);
|
|
|
|
|
}
|
2005-03-18 07:56:28 +00:00
|
|
|
} else {
|
|
|
|
|
$tpl->set('viewcount', false);
|
2004-11-19 04:14:59 +00:00
|
|
|
}
|
2004-12-18 03:47:11 +00:00
|
|
|
|
|
|
|
|
if ($wgPageShowWatchingUsers) {
|
2007-01-22 23:50:42 +00:00
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
Changing lines like this: "extract( $dbw->tableNames( 'page', 'archive' ) );" to be like this: "list ($page, $archive) = $dbw->tableNamesN( 'page', 'archive' );".
Three reasons for this:
1) It's better for analysis tools [which want explicit variable declaration]
2) It's easier for a human to read, as it's completely explicit where the variables came from [which is something you don't get with extract() ]
3) It makes it easier to find everywhere where a variable is used with search/grep [which you can't currently do with $tbl_page variables from things like: "extract($db->tableNames( 'page', 'revision'), EXTR_PREFIX_ALL, 'tbl');"].
Otherwise, from a functionality/efficiency perspective the two forms should be identical.
By doing this have been able run static analysis over the usages of these variables, thus eliminating 5 unneeded table names from calls, plus removing 3 unused calls entirely, and it just feels subjectively slightly nicer to me.
2006-11-27 08:36:57 +00:00
|
|
|
$watchlist = $dbr->tableName( 'watchlist' );
|
2004-12-18 03:47:11 +00:00
|
|
|
$sql = "SELECT COUNT(*) AS n FROM $watchlist
|
2008-01-14 09:13:04 +00:00
|
|
|
WHERE wl_title='" . $dbr->strencode($this->mTitle->getDBkey()) .
|
2005-02-21 11:28:07 +00:00
|
|
|
"' AND wl_namespace=" . $this->mTitle->getNamespace() ;
|
2006-02-18 04:34:10 +00:00
|
|
|
$res = $dbr->query( $sql, 'SkinTemplate::outputPage');
|
2004-12-18 03:47:11 +00:00
|
|
|
$x = $dbr->fetchObject( $res );
|
|
|
|
|
$numberofwatchingusers = $x->n;
|
|
|
|
|
if ($numberofwatchingusers > 0) {
|
2007-11-10 14:52:56 +00:00
|
|
|
$tpl->set('numberofwatchingusers',
|
|
|
|
|
wfMsgExt('number_of_watching_users_pageview', array('parseinline'),
|
|
|
|
|
$wgLang->formatNum($numberofwatchingusers))
|
|
|
|
|
);
|
2004-12-18 03:47:11 +00:00
|
|
|
} else {
|
|
|
|
|
$tpl->set('numberofwatchingusers', false);
|
2004-12-18 03:50:47 +00:00
|
|
|
}
|
2004-12-18 03:47:11 +00:00
|
|
|
} else {
|
|
|
|
|
$tpl->set('numberofwatchingusers', false);
|
|
|
|
|
}
|
|
|
|
|
|
2004-11-19 04:14:59 +00:00
|
|
|
$tpl->set('copyright',$this->getCopyright());
|
|
|
|
|
|
|
|
|
|
$this->credits = false;
|
|
|
|
|
|
|
|
|
|
if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
|
2006-06-01 08:19:02 +00:00
|
|
|
require_once("Credits.php");
|
|
|
|
|
$this->credits = getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
|
2005-05-28 06:56:30 +00:00
|
|
|
} else {
|
|
|
|
|
$tpl->set('lastmod', $this->lastModified());
|
2004-11-19 04:14:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$tpl->setRef( 'credits', $this->credits );
|
|
|
|
|
|
|
|
|
|
} elseif ( isset( $oldid ) && !isset( $diff ) ) {
|
|
|
|
|
$tpl->set('copyright', $this->getCopyright());
|
|
|
|
|
$tpl->set('viewcount', false);
|
|
|
|
|
$tpl->set('lastmod', false);
|
|
|
|
|
$tpl->set('credits', false);
|
2004-12-18 03:50:47 +00:00
|
|
|
$tpl->set('numberofwatchingusers', false);
|
2004-11-19 04:14:59 +00:00
|
|
|
} else {
|
|
|
|
|
$tpl->set('copyright', false);
|
|
|
|
|
$tpl->set('viewcount', false);
|
|
|
|
|
$tpl->set('lastmod', false);
|
|
|
|
|
$tpl->set('credits', false);
|
2004-12-18 03:50:47 +00:00
|
|
|
$tpl->set('numberofwatchingusers', false);
|
2004-11-19 04:14:59 +00:00
|
|
|
}
|
2004-11-22 06:50:37 +00:00
|
|
|
wfProfileOut( "$fname-stuff3" );
|
2004-11-19 04:14:59 +00:00
|
|
|
|
2004-11-22 06:50:37 +00:00
|
|
|
wfProfileIn( "$fname-stuff4" );
|
2004-11-19 04:14:59 +00:00
|
|
|
$tpl->set( 'copyrightico', $this->getCopyrightIcon() );
|
|
|
|
|
$tpl->set( 'poweredbyico', $this->getPoweredBy() );
|
|
|
|
|
$tpl->set( 'disclaimer', $this->disclaimerLink() );
|
2005-11-29 20:25:20 +00:00
|
|
|
$tpl->set( 'privacy', $this->privacyLink() );
|
2004-11-19 04:14:59 +00:00
|
|
|
$tpl->set( 'about', $this->aboutLink() );
|
|
|
|
|
|
|
|
|
|
$tpl->setRef( 'debug', $out->mDebugtext );
|
2008-03-24 15:04:55 +00:00
|
|
|
$tpl->set( 'reporttime', wfReportTime() );
|
2005-03-27 16:56:11 +00:00
|
|
|
$tpl->set( 'sitenotice', wfGetSiteNotice() );
|
2006-07-29 22:34:22 +00:00
|
|
|
$tpl->set( 'bottomscripts', $this->bottomScripts() );
|
2004-11-19 04:14:59 +00:00
|
|
|
|
|
|
|
|
$printfooter = "<div class=\"printfooter\">\n" . $this->printSource() . "</div>\n";
|
|
|
|
|
$out->mBodytext .= $printfooter ;
|
|
|
|
|
$tpl->setRef( 'bodytext', $out->mBodytext );
|
|
|
|
|
|
|
|
|
|
# Language links
|
|
|
|
|
$language_urls = array();
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2005-05-28 06:56:30 +00:00
|
|
|
if ( !$wgHideInterlanguageLinks ) {
|
2005-07-24 08:06:56 +00:00
|
|
|
foreach( $wgOut->getLanguageLinks() as $l ) {
|
2005-08-09 12:25:07 +00:00
|
|
|
$tmp = explode( ':', $l, 2 );
|
|
|
|
|
$class = 'interwiki-' . $tmp[0];
|
|
|
|
|
unset($tmp);
|
2005-05-28 06:56:30 +00:00
|
|
|
$nt = Title::newFromText( $l );
|
2005-08-09 12:25:07 +00:00
|
|
|
$language_urls[] = array(
|
|
|
|
|
'href' => $nt->getFullURL(),
|
2006-05-31 20:39:14 +00:00
|
|
|
'text' => ($wgContLang->getLanguageName( $nt->getInterwiki()) != ''?$wgContLang->getLanguageName( $nt->getInterwiki()) : $l),
|
2007-09-11 15:22:53 +00:00
|
|
|
'class' => $class
|
2005-08-09 12:25:07 +00:00
|
|
|
);
|
2005-05-28 06:56:30 +00:00
|
|
|
}
|
2004-11-19 04:14:59 +00:00
|
|
|
}
|
|
|
|
|
if(count($language_urls)) {
|
|
|
|
|
$tpl->setRef( 'language_urls', $language_urls);
|
|
|
|
|
} else {
|
|
|
|
|
$tpl->set('language_urls', false);
|
|
|
|
|
}
|
2004-11-22 06:50:37 +00:00
|
|
|
wfProfileOut( "$fname-stuff4" );
|
2004-11-19 04:14:59 +00:00
|
|
|
|
|
|
|
|
# Personal toolbar
|
|
|
|
|
$tpl->set('personal_urls', $this->buildPersonalUrls());
|
|
|
|
|
$content_actions = $this->buildContentActionUrls();
|
|
|
|
|
$tpl->setRef('content_actions', $content_actions);
|
2004-11-22 06:50:37 +00:00
|
|
|
|
2004-11-19 04:14:59 +00:00
|
|
|
// XXX: attach this from javascript, same with section editing
|
|
|
|
|
if($this->iseditable && $wgUser->getOption("editondblclick") )
|
|
|
|
|
{
|
2007-06-04 19:20:49 +00:00
|
|
|
$encEditUrl = wfEscapeJsString( $this->mTitle->getLocalUrl( $this->editUrlOptions() ) );
|
|
|
|
|
$tpl->set('body_ondblclick', 'document.location = "' . $encEditUrl . '";');
|
2004-11-19 04:14:59 +00:00
|
|
|
} else {
|
|
|
|
|
$tpl->set('body_ondblclick', false);
|
|
|
|
|
}
|
2005-03-25 12:37:19 +00:00
|
|
|
if( $this->iseditable && $wgUser->getOption( 'editsectiononrightclick' ) ) {
|
|
|
|
|
$tpl->set( 'body_onload', 'setupRightClickEdit()' );
|
|
|
|
|
} else {
|
|
|
|
|
$tpl->set( 'body_onload', false );
|
|
|
|
|
}
|
2005-05-24 20:06:52 +00:00
|
|
|
$tpl->set( 'sidebar', $this->buildSidebar() );
|
2004-11-19 04:14:59 +00:00
|
|
|
$tpl->set( 'nav_urls', $this->buildNavUrls() );
|
|
|
|
|
|
2007-01-10 15:23:32 +00:00
|
|
|
// original version by hansm
|
|
|
|
|
if( !wfRunHooks( 'SkinTemplateOutputPageBeforeExec', array( &$this, &$tpl ) ) ) {
|
|
|
|
|
wfDebug( __METHOD__ . ': Hook SkinTemplateOutputPageBeforeExec broke outputPage execution!' );
|
|
|
|
|
}
|
|
|
|
|
|
2004-11-19 04:14:59 +00:00
|
|
|
// execute template
|
2004-11-22 06:50:37 +00:00
|
|
|
wfProfileIn( "$fname-execute" );
|
2004-11-19 04:14:59 +00:00
|
|
|
$res = $tpl->execute();
|
2004-11-22 06:50:37 +00:00
|
|
|
wfProfileOut( "$fname-execute" );
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2004-11-19 04:14:59 +00:00
|
|
|
// result may be an error
|
2004-11-19 07:37:46 +00:00
|
|
|
$this->printOrError( $res );
|
2004-11-22 06:50:37 +00:00
|
|
|
wfProfileOut( $fname );
|
2004-11-19 04:14:59 +00:00
|
|
|
}
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2004-11-19 07:37:46 +00:00
|
|
|
/**
|
|
|
|
|
* Output the string, or print error message if it's
|
|
|
|
|
* an error object of the appropriate type.
|
2004-11-19 12:44:51 +00:00
|
|
|
* For the base class, assume strings all around.
|
2004-11-19 07:37:46 +00:00
|
|
|
*
|
|
|
|
|
* @param mixed $str
|
2006-04-20 20:43:38 +00:00
|
|
|
* @private
|
2004-11-19 07:37:46 +00:00
|
|
|
*/
|
2007-01-12 10:03:51 +00:00
|
|
|
function printOrError( $str ) {
|
2004-11-19 07:37:46 +00:00
|
|
|
echo $str;
|
|
|
|
|
}
|
2004-11-19 04:14:59 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* build array of urls for personal toolbar
|
2004-11-19 12:44:51 +00:00
|
|
|
* @return array
|
2006-04-20 20:43:38 +00:00
|
|
|
* @private
|
2004-11-19 04:14:59 +00:00
|
|
|
*/
|
|
|
|
|
function buildPersonalUrls() {
|
2007-04-02 06:27:55 +00:00
|
|
|
global $wgTitle, $wgRequest;
|
2005-10-12 01:13:46 +00:00
|
|
|
|
2004-11-22 06:50:37 +00:00
|
|
|
$fname = 'SkinTemplate::buildPersonalUrls';
|
2005-10-12 01:13:46 +00:00
|
|
|
$pageurl = $wgTitle->getLocalURL();
|
2004-11-22 06:50:37 +00:00
|
|
|
wfProfileIn( $fname );
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2004-11-19 04:14:59 +00:00
|
|
|
/* set up the default links for the personal toolbar */
|
|
|
|
|
$personal_urls = array();
|
|
|
|
|
if ($this->loggedin) {
|
|
|
|
|
$personal_urls['userpage'] = array(
|
2005-04-30 11:14:11 +00:00
|
|
|
'text' => $this->username,
|
|
|
|
|
'href' => &$this->userpageUrlDetails['href'],
|
2005-10-12 01:13:46 +00:00
|
|
|
'class' => $this->userpageUrlDetails['exists']?false:'new',
|
|
|
|
|
'active' => ( $this->userpageUrlDetails['href'] == $pageurl )
|
2004-11-19 04:14:59 +00:00
|
|
|
);
|
2005-04-30 11:14:11 +00:00
|
|
|
$usertalkUrlDetails = $this->makeTalkUrlDetails($this->userpage);
|
2004-11-19 04:14:59 +00:00
|
|
|
$personal_urls['mytalk'] = array(
|
|
|
|
|
'text' => wfMsg('mytalk'),
|
2005-04-30 11:14:11 +00:00
|
|
|
'href' => &$usertalkUrlDetails['href'],
|
2005-10-12 01:13:46 +00:00
|
|
|
'class' => $usertalkUrlDetails['exists']?false:'new',
|
|
|
|
|
'active' => ( $usertalkUrlDetails['href'] == $pageurl )
|
2004-11-19 04:14:59 +00:00
|
|
|
);
|
2006-09-22 13:07:06 +00:00
|
|
|
$href = self::makeSpecialUrl( 'Preferences' );
|
2004-11-19 04:14:59 +00:00
|
|
|
$personal_urls['preferences'] = array(
|
2006-09-22 13:07:06 +00:00
|
|
|
'text' => wfMsg( 'mypreferences' ),
|
2007-04-10 10:30:05 +00:00
|
|
|
'href' => $href,
|
2005-10-12 01:13:46 +00:00
|
|
|
'active' => ( $href == $pageurl )
|
2004-11-19 04:14:59 +00:00
|
|
|
);
|
2006-09-22 13:07:06 +00:00
|
|
|
$href = self::makeSpecialUrl( 'Watchlist' );
|
2004-11-19 04:14:59 +00:00
|
|
|
$personal_urls['watchlist'] = array(
|
2007-04-20 15:04:50 +00:00
|
|
|
'text' => wfMsg( 'mywatchlist' ),
|
2005-10-12 01:13:46 +00:00
|
|
|
'href' => $href,
|
|
|
|
|
'active' => ( $href == $pageurl )
|
2004-11-19 04:14:59 +00:00
|
|
|
);
|
2007-04-02 06:27:55 +00:00
|
|
|
|
|
|
|
|
# We need to do an explicit check for Special:Contributions, as we
|
|
|
|
|
# have to match both the title, and the target (which could come
|
|
|
|
|
# from request values or be specified in "sub page" form. The plot
|
|
|
|
|
# thickens, because $wgTitle is altered for special pages, so doesn't
|
|
|
|
|
# contain the original alias-with-subpage.
|
|
|
|
|
$title = Title::newFromText( $wgRequest->getText( 'title' ) );
|
|
|
|
|
if( $title instanceof Title && $title->getNamespace() == NS_SPECIAL ) {
|
|
|
|
|
list( $spName, $spPar ) =
|
|
|
|
|
SpecialPage::resolveAliasWithSubpage( $title->getText() );
|
|
|
|
|
$active = $spName == 'Contributions'
|
|
|
|
|
&& ( ( $spPar && $spPar == $this->username )
|
|
|
|
|
|| $wgRequest->getText( 'target' ) == $this->username );
|
|
|
|
|
} else {
|
|
|
|
|
$active = false;
|
|
|
|
|
}
|
|
|
|
|
|
2006-12-18 00:20:21 +00:00
|
|
|
$href = self::makeSpecialUrlSubpage( 'Contributions', $this->username );
|
2004-11-19 04:14:59 +00:00
|
|
|
$personal_urls['mycontris'] = array(
|
2006-09-22 13:07:06 +00:00
|
|
|
'text' => wfMsg( 'mycontris' ),
|
2006-11-29 05:45:03 +00:00
|
|
|
'href' => $href,
|
2007-04-02 06:27:55 +00:00
|
|
|
'active' => $active
|
2004-11-19 04:14:59 +00:00
|
|
|
);
|
|
|
|
|
$personal_urls['logout'] = array(
|
2006-09-22 13:07:06 +00:00
|
|
|
'text' => wfMsg( 'userlogout' ),
|
|
|
|
|
'href' => self::makeSpecialUrl( 'Userlogout',
|
2006-10-30 06:25:31 +00:00
|
|
|
$wgTitle->isSpecial( 'Preferences' ) ? '' : "returnto={$this->thisurl}"
|
2006-11-29 05:45:03 +00:00
|
|
|
),
|
|
|
|
|
'active' => false
|
2004-11-19 04:14:59 +00:00
|
|
|
);
|
|
|
|
|
} else {
|
2007-02-05 21:42:48 +00:00
|
|
|
if( $this->showIPinHeader() ) {
|
2005-10-12 01:13:46 +00:00
|
|
|
$href = &$this->userpageUrlDetails['href'];
|
2004-11-19 04:14:59 +00:00
|
|
|
$personal_urls['anonuserpage'] = array(
|
2005-04-30 11:14:11 +00:00
|
|
|
'text' => $this->username,
|
2005-10-12 01:13:46 +00:00
|
|
|
'href' => $href,
|
|
|
|
|
'class' => $this->userpageUrlDetails['exists']?false:'new',
|
|
|
|
|
'active' => ( $pageurl == $href )
|
2004-11-19 04:14:59 +00:00
|
|
|
);
|
2005-04-30 11:14:11 +00:00
|
|
|
$usertalkUrlDetails = $this->makeTalkUrlDetails($this->userpage);
|
2005-10-12 01:13:46 +00:00
|
|
|
$href = &$usertalkUrlDetails['href'];
|
2005-04-30 11:14:11 +00:00
|
|
|
$personal_urls['anontalk'] = array(
|
|
|
|
|
'text' => wfMsg('anontalk'),
|
2005-10-12 01:13:46 +00:00
|
|
|
'href' => $href,
|
|
|
|
|
'class' => $usertalkUrlDetails['exists']?false:'new',
|
|
|
|
|
'active' => ( $pageurl == $href )
|
2004-11-19 04:14:59 +00:00
|
|
|
);
|
|
|
|
|
$personal_urls['anonlogin'] = array(
|
|
|
|
|
'text' => wfMsg('userlogin'),
|
2006-09-22 13:07:06 +00:00
|
|
|
'href' => self::makeSpecialUrl( 'Userlogin', 'returnto=' . $this->thisurl ),
|
2007-01-15 06:11:58 +00:00
|
|
|
'active' => $wgTitle->isSpecial( 'Userlogin' )
|
2004-11-19 04:14:59 +00:00
|
|
|
);
|
|
|
|
|
} else {
|
2005-04-30 11:14:11 +00:00
|
|
|
|
2004-11-19 04:14:59 +00:00
|
|
|
$personal_urls['login'] = array(
|
|
|
|
|
'text' => wfMsg('userlogin'),
|
2006-09-22 13:07:06 +00:00
|
|
|
'href' => self::makeSpecialUrl( 'Userlogin', 'returnto=' . $this->thisurl ),
|
2006-10-30 06:25:31 +00:00
|
|
|
'active' => $wgTitle->isSpecial( 'Userlogin' )
|
2004-11-19 04:14:59 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
2006-05-17 07:02:06 +00:00
|
|
|
|
2007-01-15 06:11:58 +00:00
|
|
|
wfRunHooks( 'PersonalUrls', array( &$personal_urls, &$wgTitle ) );
|
2004-11-22 06:50:37 +00:00
|
|
|
wfProfileOut( $fname );
|
2004-11-19 04:14:59 +00:00
|
|
|
return $personal_urls;
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-22 11:29:15 +00:00
|
|
|
function tabAction( $title, $message, $selected, $query='', $checkEdit=false ) {
|
2005-02-21 11:28:07 +00:00
|
|
|
$classes = array();
|
|
|
|
|
if( $selected ) {
|
|
|
|
|
$classes[] = 'selected';
|
|
|
|
|
}
|
2007-05-09 18:41:05 +00:00
|
|
|
if( $checkEdit && !$title->isAlwaysKnown() && $title->getArticleId() == 0 ) {
|
2005-02-21 11:28:07 +00:00
|
|
|
$classes[] = 'new';
|
2005-06-27 04:18:09 +00:00
|
|
|
$query = 'action=edit';
|
2005-02-21 11:28:07 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-08-27 03:47:47 +00:00
|
|
|
$text = wfMsg( $message );
|
2006-09-11 12:22:35 +00:00
|
|
|
if ( wfEmptyMsg( $message, $text ) ) {
|
2006-04-02 22:59:26 +00:00
|
|
|
global $wgContLang;
|
2008-03-21 23:13:34 +00:00
|
|
|
$text = $wgContLang->getFormattedNsText( MWNamespace::getSubject( $title->getNamespace() ) );
|
2005-08-27 03:47:47 +00:00
|
|
|
}
|
2007-10-17 03:53:58 +00:00
|
|
|
|
|
|
|
|
$result = array();
|
|
|
|
|
if( !wfRunHooks('SkinTemplateTabAction', array(&$this,
|
|
|
|
|
$title, $message, $selected, $checkEdit,
|
|
|
|
|
&$classes, &$query, &$text, &$result)) ) {
|
|
|
|
|
return $result;
|
|
|
|
|
}
|
2007-10-16 20:29:11 +00:00
|
|
|
|
2005-02-21 11:28:07 +00:00
|
|
|
return array(
|
|
|
|
|
'class' => implode( ' ', $classes ),
|
2005-08-27 03:47:47 +00:00
|
|
|
'text' => $text,
|
2005-02-21 11:28:07 +00:00
|
|
|
'href' => $title->getLocalUrl( $query ) );
|
|
|
|
|
}
|
2005-04-30 11:14:11 +00:00
|
|
|
|
2006-09-22 13:18:51 +00:00
|
|
|
function makeTalkUrlDetails( $name, $urlaction = '' ) {
|
2005-04-30 11:14:11 +00:00
|
|
|
$title = Title::newFromText( $name );
|
2007-02-23 04:45:23 +00:00
|
|
|
if( !is_object($title) ) {
|
|
|
|
|
throw new MWException( __METHOD__." given invalid pagename $name" );
|
|
|
|
|
}
|
2005-04-30 11:14:11 +00:00
|
|
|
$title = $title->getTalkPage();
|
2006-09-22 13:18:51 +00:00
|
|
|
self::checkTitle( $title, $name );
|
2005-04-30 11:14:11 +00:00
|
|
|
return array(
|
|
|
|
|
'href' => $title->getLocalURL( $urlaction ),
|
2006-09-22 13:18:51 +00:00
|
|
|
'exists' => $title->getArticleID() != 0 ? true : false
|
2005-04-30 11:14:11 +00:00
|
|
|
);
|
|
|
|
|
}
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2006-09-22 13:18:51 +00:00
|
|
|
function makeArticleUrlDetails( $name, $urlaction = '' ) {
|
2005-04-30 11:14:11 +00:00
|
|
|
$title = Title::newFromText( $name );
|
|
|
|
|
$title= $title->getSubjectPage();
|
2006-09-22 13:07:06 +00:00
|
|
|
self::checkTitle( $title, $name );
|
2005-04-30 11:14:11 +00:00
|
|
|
return array(
|
|
|
|
|
'href' => $title->getLocalURL( $urlaction ),
|
2006-09-22 13:18:51 +00:00
|
|
|
'exists' => $title->getArticleID() != 0 ? true : false
|
2005-04-30 11:14:11 +00:00
|
|
|
);
|
|
|
|
|
}
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2004-11-19 04:14:59 +00:00
|
|
|
/**
|
|
|
|
|
* an array of edit links by default used for the tabs
|
2004-11-19 12:44:51 +00:00
|
|
|
* @return array
|
2006-04-20 20:43:38 +00:00
|
|
|
* @private
|
2004-11-19 04:14:59 +00:00
|
|
|
*/
|
|
|
|
|
function buildContentActionUrls () {
|
2007-12-09 23:49:03 +00:00
|
|
|
global $wgContLang, $wgLang, $wgOut;
|
2004-11-22 06:50:37 +00:00
|
|
|
$fname = 'SkinTemplate::buildContentActionUrls';
|
|
|
|
|
wfProfileIn( $fname );
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2005-02-21 11:28:07 +00:00
|
|
|
global $wgUser, $wgRequest;
|
2004-11-19 04:14:59 +00:00
|
|
|
$action = $wgRequest->getText( 'action' );
|
|
|
|
|
$section = $wgRequest->getText( 'section' );
|
|
|
|
|
$content_actions = array();
|
|
|
|
|
|
2005-12-11 13:06:10 +00:00
|
|
|
$prevent_active_tabs = false ;
|
|
|
|
|
wfRunHooks( 'SkinTemplatePreventOtherActiveTabs', array( &$this , &$prevent_active_tabs ) ) ;
|
|
|
|
|
|
2004-12-04 05:03:19 +00:00
|
|
|
if( $this->iscontent ) {
|
2005-08-02 13:35:19 +00:00
|
|
|
$subjpage = $this->mTitle->getSubjectPage();
|
|
|
|
|
$talkpage = $this->mTitle->getTalkPage();
|
2004-11-19 04:14:59 +00:00
|
|
|
|
2006-03-16 02:51:11 +00:00
|
|
|
$nskey = $this->mTitle->getNamespaceKey();
|
2005-02-21 11:28:07 +00:00
|
|
|
$content_actions[$nskey] = $this->tabAction(
|
2005-08-02 13:35:19 +00:00
|
|
|
$subjpage,
|
2005-02-21 11:28:07 +00:00
|
|
|
$nskey,
|
2005-12-11 13:06:10 +00:00
|
|
|
!$this->mTitle->isTalkPage() && !$prevent_active_tabs,
|
2005-07-01 11:15:48 +00:00
|
|
|
'', true);
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2005-02-21 11:28:07 +00:00
|
|
|
$content_actions['talk'] = $this->tabAction(
|
2005-08-02 13:35:19 +00:00
|
|
|
$talkpage,
|
2005-02-21 11:28:07 +00:00
|
|
|
'talk',
|
2005-12-11 13:06:10 +00:00
|
|
|
$this->mTitle->isTalkPage() && !$prevent_active_tabs,
|
2005-02-21 11:28:07 +00:00
|
|
|
'',
|
|
|
|
|
true);
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2004-11-22 06:50:37 +00:00
|
|
|
wfProfileIn( "$fname-edit" );
|
2007-01-20 17:58:38 +00:00
|
|
|
if ( $this->mTitle->quickUserCan( 'edit' ) && ( $this->mTitle->exists() || $this->mTitle->quickUserCan( 'create' ) ) ) {
|
2005-02-21 11:28:07 +00:00
|
|
|
$istalk = $this->mTitle->isTalkPage();
|
2004-11-19 04:14:59 +00:00
|
|
|
$istalkclass = $istalk?' istalk':'';
|
|
|
|
|
$content_actions['edit'] = array(
|
|
|
|
|
'class' => ((($action == 'edit' or $action == 'submit') and $section != 'new') ? 'selected' : '').$istalkclass,
|
2008-03-14 13:23:48 +00:00
|
|
|
'text' => $this->mTitle->exists()
|
|
|
|
|
? wfMsg( 'edit' )
|
|
|
|
|
: wfMsg( 'create' ),
|
2005-12-01 09:47:44 +00:00
|
|
|
'href' => $this->mTitle->getLocalUrl( $this->editUrlOptions() )
|
2004-11-19 04:14:59 +00:00
|
|
|
);
|
2005-02-21 11:28:07 +00:00
|
|
|
|
2006-05-01 20:35:08 +00:00
|
|
|
if ( $istalk || $wgOut->showNewSectionLink() ) {
|
2004-11-19 04:14:59 +00:00
|
|
|
$content_actions['addsection'] = array(
|
|
|
|
|
'class' => $section == 'new'?'selected':false,
|
|
|
|
|
'text' => wfMsg('addsection'),
|
2005-02-21 11:28:07 +00:00
|
|
|
'href' => $this->mTitle->getLocalUrl( 'action=edit§ion=new' )
|
2004-11-19 04:14:59 +00:00
|
|
|
);
|
|
|
|
|
}
|
2007-09-27 20:52:16 +00:00
|
|
|
} elseif ( $this->mTitle->exists() || $this->mTitle->isAlwaysKnown() ) {
|
2004-11-22 06:50:37 +00:00
|
|
|
$content_actions['viewsource'] = array(
|
|
|
|
|
'class' => ($action == 'edit') ? 'selected' : false,
|
|
|
|
|
'text' => wfMsg('viewsource'),
|
2005-12-01 09:47:44 +00:00
|
|
|
'href' => $this->mTitle->getLocalUrl( $this->editUrlOptions() )
|
2004-11-22 06:50:37 +00:00
|
|
|
);
|
2004-11-19 04:14:59 +00:00
|
|
|
}
|
2004-11-22 06:50:37 +00:00
|
|
|
wfProfileOut( "$fname-edit" );
|
2004-11-19 04:14:59 +00:00
|
|
|
|
2004-11-22 06:50:37 +00:00
|
|
|
wfProfileIn( "$fname-live" );
|
2005-02-21 11:28:07 +00:00
|
|
|
if ( $this->mTitle->getArticleId() ) {
|
2004-11-19 04:14:59 +00:00
|
|
|
|
2004-11-22 06:50:37 +00:00
|
|
|
$content_actions['history'] = array(
|
|
|
|
|
'class' => ($action == 'history') ? 'selected' : false,
|
|
|
|
|
'text' => wfMsg('history_short'),
|
2005-02-21 11:28:07 +00:00
|
|
|
'href' => $this->mTitle->getLocalUrl( 'action=history')
|
2004-11-22 06:50:37 +00:00
|
|
|
);
|
2004-11-19 04:14:59 +00:00
|
|
|
|
2007-12-11 09:51:56 +00:00
|
|
|
if($wgUser->isAllowed('delete')){
|
|
|
|
|
$content_actions['delete'] = array(
|
|
|
|
|
'class' => ($action == 'delete') ? 'selected' : false,
|
|
|
|
|
'text' => wfMsg('delete'),
|
|
|
|
|
'href' => $this->mTitle->getLocalUrl( 'action=delete' )
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
if ( $this->mTitle->quickUserCan( 'move' ) ) {
|
|
|
|
|
$moveTitle = SpecialPage::getTitleFor( 'Movepage', $this->thispage );
|
|
|
|
|
$content_actions['move'] = array(
|
|
|
|
|
'class' => $this->mTitle->isSpecial( 'Movepage' ) ? 'selected' : false,
|
|
|
|
|
'text' => wfMsg('move'),
|
|
|
|
|
'href' => $moveTitle->getLocalUrl()
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2005-12-08 17:44:35 +00:00
|
|
|
if ( $this->mTitle->getNamespace() !== NS_MEDIAWIKI && $wgUser->isAllowed( 'protect' ) ) {
|
2005-02-21 11:28:07 +00:00
|
|
|
if(!$this->mTitle->isProtected()){
|
2004-11-19 04:14:59 +00:00
|
|
|
$content_actions['protect'] = array(
|
|
|
|
|
'class' => ($action == 'protect') ? 'selected' : false,
|
|
|
|
|
'text' => wfMsg('protect'),
|
2005-02-21 11:28:07 +00:00
|
|
|
'href' => $this->mTitle->getLocalUrl( 'action=protect' )
|
2004-11-19 04:14:59 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
$content_actions['unprotect'] = array(
|
|
|
|
|
'class' => ($action == 'unprotect') ? 'selected' : false,
|
|
|
|
|
'text' => wfMsg('unprotect'),
|
2005-02-21 11:28:07 +00:00
|
|
|
'href' => $this->mTitle->getLocalUrl( 'action=unprotect' )
|
2004-11-19 04:14:59 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
//article doesn't exist or is deleted
|
2007-12-31 21:09:43 +00:00
|
|
|
if( $wgUser->isAllowed( 'deletedhistory' ) && $wgUser->isAllowed( 'undelete' ) ) {
|
2005-02-21 11:28:07 +00:00
|
|
|
if( $n = $this->mTitle->isDeleted() ) {
|
2006-10-30 06:25:31 +00:00
|
|
|
$undelTitle = SpecialPage::getTitleFor( 'Undelete' );
|
2004-11-19 04:14:59 +00:00
|
|
|
$content_actions['undelete'] = array(
|
|
|
|
|
'class' => false,
|
2007-12-09 23:49:03 +00:00
|
|
|
'text' => wfMsgExt( 'undelete_short', array( 'parsemag' ), $wgLang->formatNum($n) ),
|
2006-04-17 17:18:26 +00:00
|
|
|
'href' => $undelTitle->getLocalUrl( 'target=' . urlencode( $this->thispage ) )
|
2006-09-22 13:07:06 +00:00
|
|
|
#'href' => self::makeSpecialUrl( "Undelete/$this->thispage" )
|
2004-11-19 04:14:59 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-12-11 09:51:56 +00:00
|
|
|
|
|
|
|
|
if ( $this->mTitle->getNamespace() !== NS_MEDIAWIKI && $wgUser->isAllowed( 'protect' ) ) {
|
2008-01-11 04:55:48 +00:00
|
|
|
if( !$this->mTitle->getRestrictions( 'create' ) ) {
|
2007-12-11 09:51:56 +00:00
|
|
|
$content_actions['protect'] = array(
|
|
|
|
|
'class' => ($action == 'protect') ? 'selected' : false,
|
|
|
|
|
'text' => wfMsg('protect'),
|
|
|
|
|
'href' => $this->mTitle->getLocalUrl( 'action=protect' )
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
$content_actions['unprotect'] = array(
|
|
|
|
|
'class' => ($action == 'unprotect') ? 'selected' : false,
|
|
|
|
|
'text' => wfMsg('unprotect'),
|
|
|
|
|
'href' => $this->mTitle->getLocalUrl( 'action=unprotect' )
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-11-19 04:14:59 +00:00
|
|
|
}
|
2007-12-11 09:51:56 +00:00
|
|
|
|
2004-11-22 06:50:37 +00:00
|
|
|
wfProfileOut( "$fname-live" );
|
2004-12-24 02:47:38 +00:00
|
|
|
|
2008-01-15 16:04:50 +00:00
|
|
|
if( $this->loggedin ) {
|
2005-02-21 11:28:07 +00:00
|
|
|
if( !$this->mTitle->userIsWatching()) {
|
2004-11-22 06:50:37 +00:00
|
|
|
$content_actions['watch'] = array(
|
|
|
|
|
'class' => ($action == 'watch' or $action == 'unwatch') ? 'selected' : false,
|
|
|
|
|
'text' => wfMsg('watch'),
|
2005-02-21 11:28:07 +00:00
|
|
|
'href' => $this->mTitle->getLocalUrl( 'action=watch' )
|
2004-11-22 06:50:37 +00:00
|
|
|
);
|
2004-11-19 04:14:59 +00:00
|
|
|
} else {
|
2004-11-22 06:50:37 +00:00
|
|
|
$content_actions['unwatch'] = array(
|
|
|
|
|
'class' => ($action == 'unwatch' or $action == 'watch') ? 'selected' : false,
|
|
|
|
|
'text' => wfMsg('unwatch'),
|
2005-02-21 11:28:07 +00:00
|
|
|
'href' => $this->mTitle->getLocalUrl( 'action=unwatch' )
|
2004-11-22 06:50:37 +00:00
|
|
|
);
|
2004-11-19 04:14:59 +00:00
|
|
|
}
|
2005-05-23 21:01:02 +00:00
|
|
|
}
|
2007-03-14 18:20:21 +00:00
|
|
|
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-12-09 10:17:52 +00:00
|
|
|
wfRunHooks( 'SkinTemplateTabs', array( &$this , &$content_actions ) ) ;
|
2004-11-19 04:14:59 +00:00
|
|
|
} else {
|
|
|
|
|
/* show special page tab */
|
|
|
|
|
|
2006-10-16 00:37:18 +00:00
|
|
|
$content_actions[$this->mTitle->getNamespaceKey()] = array(
|
2004-11-22 06:50:37 +00:00
|
|
|
'class' => 'selected',
|
2007-01-15 06:11:58 +00:00
|
|
|
'text' => wfMsg('nstab-special'),
|
2005-06-25 00:50:34 +00:00
|
|
|
'href' => $wgRequest->getRequestURL(), // @bug 2457, 2510
|
2004-11-22 06:50:37 +00:00
|
|
|
);
|
2005-12-15 21:05:58 +00:00
|
|
|
|
|
|
|
|
wfRunHooks( 'SkinTemplateBuildContentActionUrlsAfterSpecialPage', array( &$this, &$content_actions ) );
|
2004-11-19 04:14:59 +00:00
|
|
|
}
|
|
|
|
|
|
2004-12-24 02:47:38 +00:00
|
|
|
/* show links to different language variants */
|
|
|
|
|
global $wgDisableLangConversion;
|
|
|
|
|
$variants = $wgContLang->getVariants();
|
|
|
|
|
if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
|
|
|
|
|
$preferred = $wgContLang->getPreferredVariant();
|
|
|
|
|
$vcount=0;
|
|
|
|
|
foreach( $variants as $code ) {
|
|
|
|
|
$varname = $wgContLang->getVariantname( $code );
|
|
|
|
|
if( $varname == 'disable' )
|
|
|
|
|
continue;
|
|
|
|
|
$selected = ( $code == $preferred )? 'selected' : false;
|
|
|
|
|
$content_actions['varlang-' . $vcount] = array(
|
|
|
|
|
'class' => $selected,
|
|
|
|
|
'text' => $varname,
|
2006-10-12 10:34:49 +00:00
|
|
|
'href' => $this->mTitle->getLocalURL('',$code)
|
2004-12-24 02:47:38 +00:00
|
|
|
);
|
|
|
|
|
$vcount ++;
|
|
|
|
|
}
|
2005-06-22 22:59:39 +00:00
|
|
|
}
|
2004-12-24 02:47:38 +00:00
|
|
|
|
2005-08-26 14:16:16 +00:00
|
|
|
wfRunHooks( 'SkinTemplateContentActions', array( &$content_actions ) );
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2004-11-22 06:50:37 +00:00
|
|
|
wfProfileOut( $fname );
|
2004-11-19 04:14:59 +00:00
|
|
|
return $content_actions;
|
|
|
|
|
}
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2005-06-28 14:18:08 +00:00
|
|
|
|
2004-11-19 04:14:59 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* build array of common navigation links
|
2004-11-19 12:44:51 +00:00
|
|
|
* @return array
|
2006-04-20 20:43:38 +00:00
|
|
|
* @private
|
2004-11-19 04:14:59 +00:00
|
|
|
*/
|
|
|
|
|
function buildNavUrls () {
|
2008-03-24 15:04:55 +00:00
|
|
|
global $wgUseTrackbacks, $wgTitle, $wgUser, $wgRequest;
|
|
|
|
|
global $wgEnableUploads, $wgUploadNavigationUrl;
|
2005-07-23 05:47:25 +00:00
|
|
|
|
2004-11-22 06:50:37 +00:00
|
|
|
$fname = 'SkinTemplate::buildNavUrls';
|
|
|
|
|
wfProfileIn( $fname );
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2004-11-19 04:14:59 +00:00
|
|
|
$action = $wgRequest->getText( 'action' );
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2004-11-19 04:14:59 +00:00
|
|
|
$nav_urls = array();
|
2006-12-03 00:22:14 +00:00
|
|
|
$nav_urls['mainpage'] = array( 'href' => self::makeMainPageUrl() );
|
2005-04-24 00:53:12 +00:00
|
|
|
if( $wgEnableUploads ) {
|
2005-04-24 01:31:31 +00:00
|
|
|
if ($wgUploadNavigationUrl) {
|
2006-09-22 13:07:06 +00:00
|
|
|
$nav_urls['upload'] = array( 'href' => $wgUploadNavigationUrl );
|
2005-07-03 04:00:33 +00:00
|
|
|
} else {
|
2006-09-22 13:07:06 +00:00
|
|
|
$nav_urls['upload'] = array( 'href' => self::makeSpecialUrl( 'Upload' ) );
|
2005-04-24 00:53:12 +00:00
|
|
|
}
|
2004-11-19 04:14:59 +00:00
|
|
|
} else {
|
2005-11-10 08:55:17 +00:00
|
|
|
if ($wgUploadNavigationUrl)
|
2006-09-22 13:07:06 +00:00
|
|
|
$nav_urls['upload'] = array( 'href' => $wgUploadNavigationUrl );
|
2005-11-10 08:55:17 +00:00
|
|
|
else
|
|
|
|
|
$nav_urls['upload'] = false;
|
2004-11-19 04:14:59 +00:00
|
|
|
}
|
2006-09-22 13:07:06 +00:00
|
|
|
$nav_urls['specialpages'] = array( 'href' => self::makeSpecialUrl( 'Specialpages' ) );
|
2004-11-19 04:14:59 +00:00
|
|
|
|
2006-11-29 05:45:03 +00:00
|
|
|
// default permalink to being off, will override it as required below.
|
|
|
|
|
$nav_urls['permalink'] = false;
|
2007-01-15 06:11:58 +00:00
|
|
|
|
2005-06-28 18:04:09 +00:00
|
|
|
// 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' ) ) {
|
2007-02-05 17:44:19 +00:00
|
|
|
$nav_urls['print'] = array(
|
|
|
|
|
'text' => wfMsg( 'printableversion' ),
|
|
|
|
|
'href' => $wgRequest->appendQuery( 'printable=yes' )
|
|
|
|
|
);
|
2005-08-23 17:25:22 +00:00
|
|
|
|
|
|
|
|
// Also add a "permalink" while we're at it
|
2007-05-03 06:08:12 +00:00
|
|
|
if ( $this->mRevisionId ) {
|
2005-08-23 17:25:22 +00:00
|
|
|
$nav_urls['permalink'] = array(
|
|
|
|
|
'text' => wfMsg( 'permalink' ),
|
2007-05-03 06:08:12 +00:00
|
|
|
'href' => $wgTitle->getLocalURL( "oldid=$this->mRevisionId" )
|
2005-09-28 13:52:22 +00:00
|
|
|
);
|
2005-08-23 17:25:22 +00:00
|
|
|
}
|
2007-05-03 06:08:12 +00:00
|
|
|
|
|
|
|
|
// Copy in case this undocumented, shady hook tries to mess with internals
|
|
|
|
|
$revid = $this->mRevisionId;
|
|
|
|
|
wfRunHooks( 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink', array( &$this, &$nav_urls, &$revid, &$revid ) );
|
2005-06-28 18:04:09 +00:00
|
|
|
}
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2006-04-16 19:17:02 +00:00
|
|
|
if( $this->mTitle->getNamespace() != NS_SPECIAL ) {
|
2006-10-30 06:25:31 +00:00
|
|
|
$wlhTitle = SpecialPage::getTitleFor( 'Whatlinkshere', $this->thispage );
|
2005-05-07 07:23:46 +00:00
|
|
|
$nav_urls['whatlinkshere'] = array(
|
2006-10-30 06:25:31 +00:00
|
|
|
'href' => $wlhTitle->getLocalUrl()
|
2005-05-07 07:23:46 +00:00
|
|
|
);
|
2005-12-11 19:10:53 +00:00
|
|
|
if( $this->mTitle->getArticleId() ) {
|
2006-10-30 06:25:31 +00:00
|
|
|
$rclTitle = SpecialPage::getTitleFor( 'Recentchangeslinked', $this->thispage );
|
2005-12-11 19:10:53 +00:00
|
|
|
$nav_urls['recentchangeslinked'] = array(
|
2006-10-30 06:25:31 +00:00
|
|
|
'href' => $rclTitle->getLocalUrl()
|
2005-12-11 19:10:53 +00:00
|
|
|
);
|
2006-11-29 05:45:03 +00:00
|
|
|
} else {
|
|
|
|
|
$nav_urls['recentchangeslinked'] = false;
|
2005-12-11 19:10:53 +00:00
|
|
|
}
|
2005-07-23 05:47:25 +00:00
|
|
|
if ($wgUseTrackbacks)
|
|
|
|
|
$nav_urls['trackbacklink'] = array(
|
|
|
|
|
'href' => $wgTitle->trackbackURL()
|
|
|
|
|
);
|
2004-11-19 04:14:59 +00:00
|
|
|
}
|
|
|
|
|
|
2005-02-21 11:28:07 +00:00
|
|
|
if( $this->mTitle->getNamespace() == NS_USER || $this->mTitle->getNamespace() == NS_USER_TALK ) {
|
|
|
|
|
$id = User::idFromName($this->mTitle->getText());
|
|
|
|
|
$ip = User::isIP($this->mTitle->getText());
|
2004-11-19 04:14:59 +00:00
|
|
|
} else {
|
|
|
|
|
$id = 0;
|
|
|
|
|
$ip = false;
|
|
|
|
|
}
|
|
|
|
|
|
2007-07-11 01:26:27 +00:00
|
|
|
if($id || $ip) { # both anons and non-anons have contribs list
|
2004-11-19 04:14:59 +00:00
|
|
|
$nav_urls['contributions'] = array(
|
2006-12-18 00:20:21 +00:00
|
|
|
'href' => self::makeSpecialUrlSubpage( 'Contributions', $this->mTitle->getText() )
|
2004-11-19 04:14:59 +00:00
|
|
|
);
|
2007-07-11 07:29:53 +00:00
|
|
|
|
2007-07-11 01:26:27 +00:00
|
|
|
if( $id ) {
|
|
|
|
|
$logPage = SpecialPage::getTitleFor( 'Log' );
|
2007-07-11 07:29:53 +00:00
|
|
|
$nav_urls['log'] = array( 'href' => $logPage->getLocalUrl( 'user='
|
|
|
|
|
. $this->mTitle->getPartialUrl() ) );
|
2007-07-11 01:26:27 +00:00
|
|
|
} else {
|
|
|
|
|
$nav_urls['log'] = false;
|
|
|
|
|
}
|
2007-07-11 07:29:53 +00:00
|
|
|
|
2006-11-29 05:45:03 +00:00
|
|
|
if ( $wgUser->isAllowed( 'block' ) ) {
|
2005-10-24 00:31:02 +00:00
|
|
|
$nav_urls['blockip'] = array(
|
2006-12-18 00:20:21 +00:00
|
|
|
'href' => self::makeSpecialUrlSubpage( 'Blockip', $this->mTitle->getText() )
|
2007-01-15 06:11:58 +00:00
|
|
|
);
|
2006-11-29 05:45:03 +00:00
|
|
|
} else {
|
|
|
|
|
$nav_urls['blockip'] = false;
|
|
|
|
|
}
|
2004-11-19 04:14:59 +00:00
|
|
|
} else {
|
|
|
|
|
$nav_urls['contributions'] = false;
|
2007-07-11 01:26:27 +00:00
|
|
|
$nav_urls['log'] = false;
|
2006-11-29 05:45:03 +00:00
|
|
|
$nav_urls['blockip'] = false;
|
2004-11-19 04:14:59 +00:00
|
|
|
}
|
|
|
|
|
$nav_urls['emailuser'] = false;
|
2004-11-25 05:31:49 +00:00
|
|
|
if( $this->showEmailUser( $id ) ) {
|
|
|
|
|
$nav_urls['emailuser'] = array(
|
2006-12-18 00:20:21 +00:00
|
|
|
'href' => self::makeSpecialUrlSubpage( 'Emailuser', $this->mTitle->getText() )
|
2004-11-25 05:31:49 +00:00
|
|
|
);
|
2004-11-19 04:14:59 +00:00
|
|
|
}
|
2004-11-22 06:50:37 +00:00
|
|
|
wfProfileOut( $fname );
|
2004-11-19 04:14:59 +00:00
|
|
|
return $nav_urls;
|
|
|
|
|
}
|
|
|
|
|
|
2006-03-20 08:25:34 +00:00
|
|
|
/**
|
|
|
|
|
* Generate strings used for xml 'id' names
|
|
|
|
|
* @return string
|
2006-04-20 20:43:38 +00:00
|
|
|
* @private
|
2006-03-20 08:25:34 +00:00
|
|
|
*/
|
|
|
|
|
function getNameSpaceKey () {
|
|
|
|
|
return $this->mTitle->getNamespaceKey();
|
|
|
|
|
}
|
|
|
|
|
|
2004-11-19 04:14:59 +00:00
|
|
|
/**
|
2006-04-20 20:43:38 +00:00
|
|
|
* @private
|
2004-11-19 04:14:59 +00:00
|
|
|
*/
|
2004-11-19 12:44:51 +00:00
|
|
|
function setupUserCss() {
|
2004-11-22 06:50:37 +00:00
|
|
|
$fname = 'SkinTemplate::setupUserCss';
|
|
|
|
|
wfProfileIn( $fname );
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2006-05-31 20:39:14 +00:00
|
|
|
global $wgRequest, $wgAllowUserCss, $wgUseSiteCss, $wgContLang, $wgSquidMaxage, $wgStylePath, $wgUser;
|
2004-11-19 04:14:59 +00:00
|
|
|
|
2005-01-16 13:21:51 +00:00
|
|
|
$sitecss = '';
|
|
|
|
|
$usercss = '';
|
2005-01-17 21:21:30 +00:00
|
|
|
$siteargs = '&maxage=' . $wgSquidMaxage;
|
2006-09-26 05:30:12 +00:00
|
|
|
if( $this->loggedin ) {
|
|
|
|
|
// Ensure that logged-in users' generated CSS isn't clobbered
|
|
|
|
|
// by anons' publicly cacheable generated CSS.
|
|
|
|
|
$siteargs .= '&smaxage=0';
|
|
|
|
|
}
|
2004-11-19 04:14:59 +00:00
|
|
|
|
|
|
|
|
# Add user-specific code if this is a user and we allow that kind of thing
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2004-11-19 04:14:59 +00:00
|
|
|
if ( $wgAllowUserCss && $this->loggedin ) {
|
|
|
|
|
$action = $wgRequest->getText('action');
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2004-11-19 04:14:59 +00:00
|
|
|
# if we're previewing the CSS page, use it
|
2005-02-21 11:28:07 +00:00
|
|
|
if( $this->mTitle->isCssSubpage() and $this->userCanPreview( $action ) ) {
|
2005-01-17 21:21:30 +00:00
|
|
|
$siteargs = "&smaxage=0&maxage=0";
|
2004-11-19 04:14:59 +00:00
|
|
|
$usercss = $wgRequest->getText('wpTextbox1');
|
|
|
|
|
} else {
|
|
|
|
|
$usercss = '@import "' .
|
2006-09-22 13:07:06 +00:00
|
|
|
self::makeUrl($this->userpage . '/'.$this->skinname.'.css',
|
2004-11-19 04:14:59 +00:00
|
|
|
'action=raw&ctype=text/css') . '";' ."\n";
|
|
|
|
|
}
|
2005-01-17 21:21:30 +00:00
|
|
|
|
|
|
|
|
$siteargs .= '&ts=' . $wgUser->mTouched;
|
2004-11-19 04:14:59 +00:00
|
|
|
}
|
|
|
|
|
|
2006-10-13 21:48:19 +00:00
|
|
|
if( $wgContLang->isRTL() ) {
|
|
|
|
|
global $wgStyleVersion;
|
|
|
|
|
$sitecss .= "@import \"$wgStylePath/$this->stylename/rtl.css?$wgStyleVersion\";\n";
|
|
|
|
|
}
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2005-01-16 13:45:23 +00:00
|
|
|
# If we use the site's dynamic CSS, throw that in, too
|
2004-11-19 04:14:59 +00:00
|
|
|
if ( $wgUseSiteCss ) {
|
2006-08-29 07:36:02 +00:00
|
|
|
$query = "usemsgcache=yes&action=raw&ctype=text/css&smaxage=$wgSquidMaxage";
|
2007-05-09 12:54:54 +00:00
|
|
|
$skinquery = '';
|
2007-05-09 12:57:26 +00:00
|
|
|
if (($us = $wgRequest->getVal('useskin', '')) !== '')
|
2007-05-09 12:54:54 +00:00
|
|
|
$skinquery = "&useskin=$us";
|
2006-09-22 13:07:06 +00:00
|
|
|
$sitecss .= '@import "' . self::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI) . '";' . "\n";
|
|
|
|
|
$sitecss .= '@import "' . self::makeNSUrl( ucfirst( $this->skinname ) . '.css', $query, NS_MEDIAWIKI ) . '";' . "\n";
|
2007-05-09 12:54:54 +00:00
|
|
|
$sitecss .= '@import "' . self::makeUrl( '-', "action=raw&gen=css$siteargs$skinquery" ) . '";' . "\n";
|
2004-11-19 04:14:59 +00:00
|
|
|
}
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2004-11-19 04:14:59 +00:00
|
|
|
# If we use any dynamic CSS, make a little CDATA block out of it.
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2004-11-19 04:14:59 +00:00
|
|
|
if ( !empty($sitecss) || !empty($usercss) ) {
|
2005-01-16 13:04:11 +00:00
|
|
|
$this->usercss = "/*<![CDATA[*/\n" . $sitecss . $usercss . '/*]]>*/';
|
2004-11-19 04:14:59 +00:00
|
|
|
}
|
2004-11-22 06:50:37 +00:00
|
|
|
wfProfileOut( $fname );
|
2004-11-19 04:14:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2006-04-20 20:43:38 +00:00
|
|
|
* @private
|
2004-11-19 04:14:59 +00:00
|
|
|
*/
|
2007-05-08 20:48:02 +00:00
|
|
|
function setupUserJs( $allowUserJs ) {
|
2004-11-22 06:50:37 +00:00
|
|
|
$fname = 'SkinTemplate::setupUserJs';
|
|
|
|
|
wfProfileIn( $fname );
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2007-05-08 20:48:02 +00:00
|
|
|
global $wgRequest, $wgJsMimeType;
|
2004-11-19 04:14:59 +00:00
|
|
|
$action = $wgRequest->getText('action');
|
|
|
|
|
|
2007-05-08 20:48:02 +00:00
|
|
|
if( $allowUserJs && $this->loggedin ) {
|
2005-02-21 11:28:07 +00:00
|
|
|
if( $this->mTitle->isJsSubpage() and $this->userCanPreview( $action ) ) {
|
2004-11-19 04:14:59 +00:00
|
|
|
# XXX: additional security check/prompt?
|
|
|
|
|
$this->userjsprev = '/*<![CDATA[*/ ' . $wgRequest->getText('wpTextbox1') . ' /*]]>*/';
|
|
|
|
|
} else {
|
2006-09-22 13:07:06 +00:00
|
|
|
$this->userjs = self::makeUrl($this->userpage.'/'.$this->skinname.'.js', 'action=raw&ctype='.$wgJsMimeType.'&dontcountme=s');
|
2004-11-19 04:14:59 +00:00
|
|
|
}
|
|
|
|
|
}
|
2004-11-22 06:50:37 +00:00
|
|
|
wfProfileOut( $fname );
|
2004-11-19 04:14:59 +00:00
|
|
|
}
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2005-09-27 19:40:14 +00:00
|
|
|
/**
|
|
|
|
|
* Code for extensions to hook into to provide per-page CSS, see
|
2005-11-15 11:13:14 +00:00
|
|
|
* extensions/PageCSS/PageCSS.php for an implementation of this.
|
2005-09-27 19:40:14 +00:00
|
|
|
*
|
2006-04-20 20:43:38 +00:00
|
|
|
* @private
|
2005-09-27 19:40:14 +00:00
|
|
|
*/
|
|
|
|
|
function setupPageCss() {
|
|
|
|
|
$fname = 'SkinTemplate::setupPageCss';
|
|
|
|
|
wfProfileIn( $fname );
|
|
|
|
|
$out = false;
|
2006-01-14 21:16:28 +00:00
|
|
|
wfRunHooks( 'SkinTemplateSetupPageCss', array( &$out ) );
|
2007-01-15 06:11:58 +00:00
|
|
|
|
2005-09-27 19:40:14 +00:00
|
|
|
wfProfileOut( $fname );
|
|
|
|
|
return $out;
|
|
|
|
|
}
|
|
|
|
|
|
2004-11-19 04:14:59 +00:00
|
|
|
/**
|
|
|
|
|
* returns css with user-specific options
|
2006-04-20 20:43:38 +00:00
|
|
|
* @public
|
2004-11-19 04:14:59 +00:00
|
|
|
*/
|
2005-03-25 07:25:49 +00:00
|
|
|
|
2004-11-19 04:14:59 +00:00
|
|
|
function getUserStylesheet() {
|
2004-11-22 06:50:37 +00:00
|
|
|
$fname = 'SkinTemplate::getUserStylesheet';
|
|
|
|
|
wfProfileIn( $fname );
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2004-11-19 04:14:59 +00:00
|
|
|
$s = "/* generated user stylesheet */\n";
|
2005-03-25 07:25:49 +00:00
|
|
|
$s .= $this->reallyDoGetUserStyles();
|
2004-11-22 06:50:37 +00:00
|
|
|
wfProfileOut( $fname );
|
2004-11-19 04:14:59 +00:00
|
|
|
return $s;
|
|
|
|
|
}
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2004-11-19 04:14:59 +00:00
|
|
|
/**
|
2006-11-17 02:05:34 +00:00
|
|
|
* This returns MediaWiki:Common.js and MediaWiki:[Skinname].js concate-
|
|
|
|
|
* nated together. For some bizarre reason, it does *not* return any
|
|
|
|
|
* custom user JS from subpages. Huh?
|
|
|
|
|
*
|
|
|
|
|
* There's absolutely no reason to have separate Monobook/Common JSes.
|
|
|
|
|
* Any JS that cares can just check the skin variable generated at the
|
|
|
|
|
* top. For now Monobook.js will be maintained, but it should be consi-
|
|
|
|
|
* dered deprecated.
|
|
|
|
|
*
|
|
|
|
|
* @return string
|
2004-11-19 04:14:59 +00:00
|
|
|
*/
|
2006-11-17 02:05:34 +00:00
|
|
|
public function getUserJs() {
|
2004-11-22 06:50:37 +00:00
|
|
|
$fname = 'SkinTemplate::getUserJs';
|
|
|
|
|
wfProfileIn( $fname );
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2006-11-17 02:05:34 +00:00
|
|
|
$s = parent::getUserJs();
|
|
|
|
|
$s .= "\n\n/* MediaWiki:".ucfirst($this->skinname).".js (deprecated; migrate to Common.js!) */\n";
|
2005-05-01 02:39:54 +00:00
|
|
|
|
|
|
|
|
// avoid inclusion of non defined user JavaScript (with custom skins only)
|
|
|
|
|
// by checking for default message content
|
|
|
|
|
$msgKey = ucfirst($this->skinname).'.js';
|
2006-09-05 09:44:52 +00:00
|
|
|
$userJS = wfMsgForContent($msgKey);
|
2006-09-11 12:22:35 +00:00
|
|
|
if ( !wfEmptyMsg( $msgKey, $userJS ) ) {
|
2005-05-01 02:39:54 +00:00
|
|
|
$s .= $userJS;
|
|
|
|
|
}
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2004-11-22 06:50:37 +00:00
|
|
|
wfProfileOut( $fname );
|
2004-11-19 04:14:59 +00:00
|
|
|
return $s;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-11-19 12:44:51 +00:00
|
|
|
/**
|
|
|
|
|
* Generic wrapper for template functions, with interface
|
|
|
|
|
* compatible with what we use of PHPTAL 0.7.
|
2007-01-20 15:09:52 +00:00
|
|
|
* @addtogroup Skins
|
2004-11-19 12:44:51 +00:00
|
|
|
*/
|
2004-11-19 04:14:59 +00:00
|
|
|
class QuickTemplate {
|
2004-11-25 05:31:49 +00:00
|
|
|
/**
|
2006-04-20 20:43:38 +00:00
|
|
|
* @public
|
2004-11-25 05:31:49 +00:00
|
|
|
*/
|
|
|
|
|
function QuickTemplate() {
|
2004-11-19 04:14:59 +00:00
|
|
|
$this->data = array();
|
2004-11-25 06:04:16 +00:00
|
|
|
$this->translator = new MediaWiki_I18N();
|
2004-11-19 04:14:59 +00:00
|
|
|
}
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2004-11-25 05:31:49 +00:00
|
|
|
/**
|
2006-04-20 20:43:38 +00:00
|
|
|
* @public
|
2004-11-25 05:31:49 +00:00
|
|
|
*/
|
2004-11-19 04:14:59 +00:00
|
|
|
function set( $name, $value ) {
|
|
|
|
|
$this->data[$name] = $value;
|
|
|
|
|
}
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2004-11-25 05:31:49 +00:00
|
|
|
/**
|
2006-04-20 20:43:38 +00:00
|
|
|
* @public
|
2004-11-25 05:31:49 +00:00
|
|
|
*/
|
2004-11-19 04:14:59 +00:00
|
|
|
function setRef($name, &$value) {
|
|
|
|
|
$this->data[$name] =& $value;
|
|
|
|
|
}
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2004-11-25 05:31:49 +00:00
|
|
|
/**
|
2006-04-20 20:43:38 +00:00
|
|
|
* @public
|
2004-11-25 05:31:49 +00:00
|
|
|
*/
|
2004-11-19 04:14:59 +00:00
|
|
|
function setTranslator( &$t ) {
|
|
|
|
|
$this->translator = &$t;
|
|
|
|
|
}
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2004-11-25 05:31:49 +00:00
|
|
|
/**
|
2006-04-20 20:43:38 +00:00
|
|
|
* @public
|
2004-11-25 05:31:49 +00:00
|
|
|
*/
|
2004-11-19 04:14:59 +00:00
|
|
|
function execute() {
|
2004-11-25 05:31:49 +00:00
|
|
|
echo "Override this function.";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2006-04-20 20:43:38 +00:00
|
|
|
* @private
|
2004-11-25 05:31:49 +00:00
|
|
|
*/
|
|
|
|
|
function text( $str ) {
|
|
|
|
|
echo htmlspecialchars( $this->data[$str] );
|
|
|
|
|
}
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2006-07-28 19:05:27 +00:00
|
|
|
/**
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
|
|
|
|
function jstext( $str ) {
|
|
|
|
|
echo Xml::escapeJsString( $this->data[$str] );
|
|
|
|
|
}
|
|
|
|
|
|
2004-11-25 05:31:49 +00:00
|
|
|
/**
|
2006-04-20 20:43:38 +00:00
|
|
|
* @private
|
2004-11-25 05:31:49 +00:00
|
|
|
*/
|
|
|
|
|
function html( $str ) {
|
|
|
|
|
echo $this->data[$str];
|
|
|
|
|
}
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2004-11-25 05:31:49 +00:00
|
|
|
/**
|
2006-04-20 20:43:38 +00:00
|
|
|
* @private
|
2004-11-25 05:31:49 +00:00
|
|
|
*/
|
|
|
|
|
function msg( $str ) {
|
|
|
|
|
echo htmlspecialchars( $this->translator->translate( $str ) );
|
|
|
|
|
}
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2004-11-25 05:31:49 +00:00
|
|
|
/**
|
2006-04-20 20:43:38 +00:00
|
|
|
* @private
|
2004-11-25 05:31:49 +00:00
|
|
|
*/
|
|
|
|
|
function msgHtml( $str ) {
|
|
|
|
|
echo $this->translator->translate( $str );
|
|
|
|
|
}
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2004-12-23 11:43:24 +00:00
|
|
|
/**
|
|
|
|
|
* An ugly, ugly hack.
|
2006-04-20 20:43:38 +00:00
|
|
|
* @private
|
2004-12-23 11:43:24 +00:00
|
|
|
*/
|
|
|
|
|
function msgWiki( $str ) {
|
2005-12-04 18:27:59 +00:00
|
|
|
global $wgParser, $wgTitle, $wgOut;
|
2004-12-23 11:43:24 +00:00
|
|
|
|
|
|
|
|
$text = $this->translator->translate( $str );
|
|
|
|
|
$parserOutput = $wgParser->parse( $text, $wgTitle,
|
2006-07-26 07:15:39 +00:00
|
|
|
$wgOut->parserOptions(), true );
|
2004-12-23 11:43:24 +00:00
|
|
|
echo $parserOutput->getText();
|
|
|
|
|
}
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2004-11-25 05:31:49 +00:00
|
|
|
/**
|
2006-04-20 20:43:38 +00:00
|
|
|
* @private
|
2004-11-25 05:31:49 +00:00
|
|
|
*/
|
|
|
|
|
function haveData( $str ) {
|
2006-11-29 05:45:03 +00:00
|
|
|
return isset( $this->data[$str] );
|
2004-11-25 05:31:49 +00:00
|
|
|
}
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2004-11-25 05:31:49 +00:00
|
|
|
/**
|
2006-04-20 20:43:38 +00:00
|
|
|
* @private
|
2004-11-25 05:31:49 +00:00
|
|
|
*/
|
|
|
|
|
function haveMsg( $str ) {
|
|
|
|
|
$msg = $this->translator->translate( $str );
|
|
|
|
|
return ($msg != '-') && ($msg != ''); # ????
|
2004-11-19 04:14:59 +00:00
|
|
|
}
|
|
|
|
|
}
|
2007-06-29 01:19:14 +00:00
|
|
|
|
2007-11-11 14:17:59 +00:00
|
|
|
|
2007-11-12 16:03:34 +00:00
|
|
|
|
2007-12-09 23:49:03 +00:00
|
|
|
|