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
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup 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) {
|
2008-05-06 14:14:37 +00:00
|
|
|
wfProfileIn( __METHOD__ );
|
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);
|
|
|
|
|
}
|
2008-05-06 14:14:37 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
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.
|
|
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup 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;
|
2008-08-04 18:07:36 +00:00
|
|
|
|
2004-11-19 04:14:59 +00:00
|
|
|
/**#@-*/
|
|
|
|
|
|
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.
|
|
|
|
|
*
|
2008-08-21 14:09:57 +00:00
|
|
|
* @param $out OutputPage
|
2004-11-19 12:44:51 +00:00
|
|
|
*/
|
2008-08-21 14:09:57 +00:00
|
|
|
function initPage( OutputPage $out ) {
|
2004-11-19 04:14:59 +00:00
|
|
|
parent::initPage( $out );
|
|
|
|
|
$this->skinname = 'monobook';
|
|
|
|
|
$this->stylename = 'monobook';
|
2004-11-25 05:31:49 +00:00
|
|
|
$this->template = 'QuickTemplate';
|
2008-08-21 14:09:57 +00:00
|
|
|
}
|
2008-08-04 18:07:36 +00:00
|
|
|
|
2008-08-21 14:09:57 +00:00
|
|
|
/**
|
|
|
|
|
* Add specific styles for this skin
|
|
|
|
|
*
|
|
|
|
|
* @param $out OutputPage
|
|
|
|
|
*/
|
|
|
|
|
function setupSkinUserCss( OutputPage $out ){
|
|
|
|
|
$out->addStyle( 'common/shared.css', 'screen' );
|
|
|
|
|
$out->addStyle( 'common/commonPrint.css', 'print' );
|
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.
|
|
|
|
|
*
|
2008-08-21 14:09:57 +00:00
|
|
|
* @param $callback string (or file)
|
|
|
|
|
* @param $repository string: subdirectory where we keep template files
|
|
|
|
|
* @param $cache_dir string
|
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
|
|
|
*
|
2008-08-21 14:09:57 +00:00
|
|
|
* @param $out OutputPage
|
2004-11-19 04:14:59 +00:00
|
|
|
*/
|
2008-08-21 14:09:57 +00:00
|
|
|
function outputPage( OutputPage $out ) {
|
|
|
|
|
global $wgTitle, $wgArticle, $wgUser, $wgLang, $wgContLang;
|
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;
|
2008-11-19 12:05:33 +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;
|
2008-07-28 16:54:06 +00:00
|
|
|
global $wgUseTrackbacks, $wgUseSiteJs;
|
2006-07-28 19:05:27 +00:00
|
|
|
global $wgArticlePath, $wgScriptPath, $wgServer, $wgLang, $wgCanonicalNamespaceNames;
|
2004-11-19 04:14:59 +00:00
|
|
|
|
2008-05-06 14:14:37 +00:00
|
|
|
wfProfileIn( __METHOD__ );
|
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
|
|
|
|
2008-05-06 14:14:37 +00:00
|
|
|
wfProfileIn( __METHOD__."-init" );
|
2004-11-19 04:14:59 +00:00
|
|
|
$this->initPage( $out );
|
2005-02-21 11:28:07 +00:00
|
|
|
|
2008-08-21 14:09:57 +00:00
|
|
|
$this->setMembers();
|
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());
|
|
|
|
|
#}
|
2008-05-06 14:14:37 +00:00
|
|
|
wfProfileOut( __METHOD__."-init" );
|
2004-11-19 04:14:59 +00:00
|
|
|
|
2008-05-06 14:14:37 +00:00
|
|
|
wfProfileIn( __METHOD__."-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-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
|
|
|
|
2008-08-21 14:09:57 +00:00
|
|
|
$this->userjs = $this->userjsprev = false;
|
|
|
|
|
$this->setupUserCss( $out );
|
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();
|
2008-05-06 14:14:37 +00:00
|
|
|
wfProfileOut( __METHOD__."-stuff" );
|
2004-11-19 04:14:59 +00:00
|
|
|
|
2008-05-06 14:14:37 +00:00
|
|
|
wfProfileIn( __METHOD__."-stuff2" );
|
2008-12-31 17:02:23 +00:00
|
|
|
$tpl->set( 'title', $out->getPageTitle() );
|
2008-08-21 14:09:57 +00:00
|
|
|
$tpl->set( 'pagetitle', $out->getHTMLTitle() );
|
|
|
|
|
$tpl->set( 'displaytitle', $out->mPageLinkTitle );
|
2008-08-10 20:10:37 +00:00
|
|
|
$tpl->set( 'pageclass', $this->getPageClasses( $this->mTitle ) );
|
2008-08-10 09:22:27 +00:00
|
|
|
$tpl->set( 'skinnameclass', ( "skin-" . Sanitizer::escapeClass( $this->getSkinName ( ) ) ) );
|
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
|
|
|
|
2008-08-21 14:09:57 +00:00
|
|
|
$tpl->set( 'isarticle', $out->isArticle() );
|
2006-12-03 11:44:23 +00:00
|
|
|
|
2004-11-19 04:14:59 +00:00
|
|
|
$tpl->setRef( "thispage", $this->thispage );
|
2008-10-27 18:03:47 +00:00
|
|
|
$subpagestr = $this->subPageSubtitle();
|
|
|
|
|
$tpl->set(
|
|
|
|
|
'subtitle', !empty($subpagestr)?
|
|
|
|
|
'<span class="subpages">'.$subpagestr.'</span>'.$out->getSubtitle():
|
|
|
|
|
$out->getSubtitle()
|
|
|
|
|
);
|
2004-11-19 04:14:59 +00:00
|
|
|
$undelete = $this->getUndeleteLink();
|
|
|
|
|
$tpl->set(
|
|
|
|
|
"undelete", !empty($undelete)?
|
|
|
|
|
'<span class="subpages">'.$undelete.'</span>':
|
|
|
|
|
''
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$tpl->set( 'catlinks', $this->getCategories());
|
2008-08-21 14:09:57 +00:00
|
|
|
if( $out->isSyndicated() ) {
|
2004-11-19 04:14:59 +00:00
|
|
|
$feeds = array();
|
2008-08-21 14:09:57 +00:00
|
|
|
foreach( $out->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() );
|
2008-08-21 14:09:57 +00:00
|
|
|
$tpl->set( 'headscripts', $out->getScript() );
|
|
|
|
|
$tpl->set( 'csslinks', $out->buildCssLinks() );
|
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' ) );
|
Start on some cleanup of how CSS stylesheets are loaded. Initially addressing only the SkinTemplate-based skins; would like to rip out some near-dupe code in the other skin types, with a little more refactoring...
* A skin can make calls to $this->addScript to much more cleanly list which style sheets it wants to load, for which media variants and which IE conditional versions. This replaces the 'cssfiles' array hack and giant pile of ugly conditionals in MonoBook's template.
* 'printable=yes' and 'handheld=yes' URL options are handled transparently -- 'screen' stylesheets are hidden, while those with no media specifier are left.
MediaWiki:Common.css is now listed without media -- so infoboxes are still formatted -- while the skin-specific eg MediaWiki:Monobook.css are listed for screen, as they're specific to the on-screen skin.
Note it should be a matter of one line of code to add a MediaWiki:Print.css and have it correctly handled now.
* All sheets are now loaded via <link rel="stylesheet"> instead of a mix of those and @import decls.
IIRC we had used @import originally to hide styles from Netscape 4, which tends to utterly break on MonoBook, but these days that's pretty much a non-issue.
@import also breaks some browsers' ability to save stylesheets with a file to disk, which sucks.
Confirmed that Firefox 3 can now save pages with their styles.
* 'screen, projection' media specifier has been changed to just 'screen' -- projection is something totally different.
* Added experimental options for specifying handheld stylesheets:
/**
* Optionally, we can specify a stylesheet to use for media="handheld".
* This is recognized by some, but not all, handheld/mobile/PDA browsers.
* If left empty, compliant handheld browsers won't pick up the skin
* stylesheet, which is specified for 'screen' media.
*
* Can be a complete URL, base-relative path, or $wgStylePath-relative path.
* Try 'chick/main.css' to apply the Chick styles to the MonoBook HTML.
*
* Will also be switched in when 'handheld=yes' is added to the URL, like
* the 'printable=yes' mode for print media.
*/
$wgHandheldStyle = false;
/**
* If set, 'screen' and 'handheld' media specifiers for stylesheets are
* transformed such that they apply to the iPhone/iPod Touch Mobile Safari,
* which doesn't recognize 'handheld' but does support media queries on its
* screen size.
*
* Consider only using this if you have a *really good* handheld stylesheet,
* as iPhone users won't have any way to disable it and use the "grown-up"
* styles instead.
*/
$wgHandheldForIPhone = false;
2008-07-28 05:09:08 +00:00
|
|
|
$tpl->set( 'handheld', $wgRequest->getBool( 'handheld' ) );
|
2004-11-19 04:14:59 +00:00
|
|
|
$tpl->setRef( 'loggedin', $this->loggedin );
|
2005-02-21 11:28:07 +00:00
|
|
|
$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);
|
2008-07-28 16:54:06 +00:00
|
|
|
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
|
2008-08-21 14:09:57 +00:00
|
|
|
$out->setSquidMaxage(0);
|
2004-11-19 04:14:59 +00:00
|
|
|
}
|
2006-02-14 21:10:31 +00:00
|
|
|
} else if (count($newtalks)) {
|
2008-09-15 20:38:27 +00:00
|
|
|
$sep = str_replace("_", " ", wfMsgHtml("newtalkseparator"));
|
2006-02-14 21:10:31 +00:00
|
|
|
$msgs = array();
|
|
|
|
|
foreach ($newtalks as $newtalk) {
|
2008-12-14 19:14:21 +00:00
|
|
|
$msgs[] = Xml::element("a",
|
2006-02-14 21:10:31 +00:00
|
|
|
array('href' => $newtalk["link"]), $newtalk["wiki"]);
|
|
|
|
|
}
|
|
|
|
|
$parts = implode($sep, $msgs);
|
|
|
|
|
$ntl = wfMsgHtml('youhavenewmessagesmulti', $parts);
|
2008-08-21 14:09:57 +00:00
|
|
|
$out->setSquidMaxage(0);
|
2004-11-19 04:14:59 +00:00
|
|
|
} else {
|
|
|
|
|
$ntl = '';
|
|
|
|
|
}
|
2008-05-06 14:14:37 +00:00
|
|
|
wfProfileOut( __METHOD__."-stuff2" );
|
2004-11-19 04:14:59 +00:00
|
|
|
|
2008-05-06 14:14:37 +00:00
|
|
|
wfProfileIn( __METHOD__."-stuff3" );
|
2004-11-19 04:14:59 +00:00
|
|
|
$tpl->setRef( 'newtalk', $ntl );
|
2008-07-28 16:54:06 +00:00
|
|
|
$tpl->setRef( 'skin', $this );
|
2004-11-19 04:14:59 +00:00
|
|
|
$tpl->set( 'logo', $this->logoText() );
|
2008-08-21 14:09:57 +00:00
|
|
|
if ( $out->isArticle() and (!isset( $oldid ) or isset( $diff )) and
|
2007-01-15 06:11:58 +00:00
|
|
|
$wgArticle and 0 != $wgArticle->getID() )
|
2006-08-19 03:11:49 +00:00
|
|
|
{
|
2008-11-19 12:05:33 +00:00
|
|
|
if ( !$wgDisableCounters ) {
|
|
|
|
|
$viewcount = $wgLang->formatNum( $wgArticle->getCount() );
|
2004-11-19 04:14:59 +00:00
|
|
|
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;
|
|
|
|
|
|
2008-08-18 19:21:55 +00:00
|
|
|
if( $wgMaxCredits != 0 ){
|
|
|
|
|
$this->credits = Credits::getCredits( $wgArticle, $wgMaxCredits, $wgShowCreditsIfMax );
|
2005-05-28 06:56:30 +00:00
|
|
|
} else {
|
2008-08-18 19:21:55 +00:00
|
|
|
$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
|
|
|
}
|
2008-05-06 14:14:37 +00:00
|
|
|
wfProfileOut( __METHOD__."-stuff3" );
|
2004-11-19 04:14:59 +00:00
|
|
|
|
2008-05-06 14:14:37 +00:00
|
|
|
wfProfileIn( __METHOD__."-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 ) {
|
2008-08-21 14:09:57 +00:00
|
|
|
foreach( $out->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 );
|
2008-09-04 06:37:51 +00:00
|
|
|
if ( $nt ) {
|
|
|
|
|
$language_urls[] = array(
|
|
|
|
|
'href' => $nt->getFullURL(),
|
2009-01-07 19:19:25 +00:00
|
|
|
'text' => ( $wgContLang->getLanguageName( $nt->getInterwiki() ) != ''
|
|
|
|
|
? $wgContLang->getLanguageName( $nt->getInterwiki() )
|
|
|
|
|
: $l ),
|
|
|
|
|
'class' => $class,
|
|
|
|
|
'title' => ( $wgLang->getLanguageNameLocalized( $nt->getInterwiki() ) != ''
|
|
|
|
|
? $wgLang->getLanguageNameLocalized( $nt->getInterwiki() )
|
|
|
|
|
: $l )
|
2008-09-04 06:37:51 +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);
|
|
|
|
|
}
|
2008-05-06 14:14:37 +00:00
|
|
|
wfProfileOut( __METHOD__."-stuff4" );
|
2004-11-19 04:14:59 +00:00
|
|
|
|
2008-08-20 08:40:37 +00:00
|
|
|
wfProfileIn( __METHOD__."-stuff5" );
|
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") )
|
|
|
|
|
{
|
2008-12-14 19:14:21 +00:00
|
|
|
$encEditUrl = Xml::escapeJsString( $this->mTitle->getLocalUrl( $this->editUrlOptions() ) );
|
2007-06-04 19:20:49 +00:00
|
|
|
$tpl->set('body_ondblclick', 'document.location = "' . $encEditUrl . '";');
|
2004-11-19 04:14:59 +00:00
|
|
|
} else {
|
|
|
|
|
$tpl->set('body_ondblclick', false);
|
|
|
|
|
}
|
2008-05-12 23:37:51 +00:00
|
|
|
$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 ) ) ) {
|
2009-01-13 20:28:54 +00:00
|
|
|
wfDebug( __METHOD__ . ": Hook SkinTemplateOutputPageBeforeExec broke outputPage execution!\n" );
|
2007-01-10 15:23:32 +00:00
|
|
|
}
|
|
|
|
|
|
2008-08-08 15:53:49 +00:00
|
|
|
// allow extensions adding stuff after the page content.
|
|
|
|
|
// See Skin::afterContentHook() for further documentation.
|
|
|
|
|
$tpl->set ('dataAfterContent', $this->afterContentHook());
|
2008-08-20 08:40:37 +00:00
|
|
|
wfProfileOut( __METHOD__."-stuff5" );
|
2008-08-08 15:53:49 +00:00
|
|
|
|
2004-11-19 04:14:59 +00:00
|
|
|
// execute template
|
2008-05-06 14:14:37 +00:00
|
|
|
wfProfileIn( __METHOD__."-execute" );
|
2004-11-19 04:14:59 +00:00
|
|
|
$res = $tpl->execute();
|
2008-05-06 14:14:37 +00:00
|
|
|
wfProfileOut( __METHOD__."-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 );
|
2008-05-06 14:14:37 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
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
|
|
|
|
|
|
|
|
$pageurl = $wgTitle->getLocalURL();
|
2008-05-06 14:14:37 +00:00
|
|
|
wfProfileIn( __METHOD__ );
|
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
|
|
|
);
|
2008-04-14 07:45:50 +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' ) );
|
2008-04-14 07:45:50 +00:00
|
|
|
if( $title instanceof Title && $title->getNamespace() == NS_SPECIAL ) {
|
2007-04-02 06:27:55 +00:00
|
|
|
list( $spName, $spPar ) =
|
|
|
|
|
SpecialPage::resolveAliasWithSubpage( $title->getText() );
|
|
|
|
|
$active = $spName == 'Contributions'
|
|
|
|
|
&& ( ( $spPar && $spPar == $this->username )
|
|
|
|
|
|| $wgRequest->getText( 'target' ) == $this->username );
|
|
|
|
|
} else {
|
|
|
|
|
$active = false;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
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 {
|
2008-04-18 15:46:54 +00:00
|
|
|
global $wgUser;
|
|
|
|
|
$loginlink = $wgUser->isAllowed( 'createaccount' )
|
|
|
|
|
? 'nav-login-createaccount'
|
|
|
|
|
: 'login';
|
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(
|
2008-04-18 15:46:54 +00:00
|
|
|
'text' => wfMsg( $loginlink ),
|
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(
|
2008-04-18 15:46:54 +00:00
|
|
|
'text' => wfMsg( $loginlink ),
|
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 ) );
|
2008-05-06 14:14:37 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
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';
|
|
|
|
|
}
|
2008-12-13 04:14:40 +00:00
|
|
|
if( $checkEdit && !$title->isKnown() ) {
|
2005-02-21 11:28:07 +00:00
|
|
|
$classes[] = 'new';
|
2009-01-06 15:38:26 +00:00
|
|
|
$query = 'action=edit&redlink=1';
|
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
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2007-10-17 03:53:58 +00:00
|
|
|
$result = array();
|
|
|
|
|
if( !wfRunHooks('SkinTemplateTabAction', array(&$this,
|
2008-10-26 01:47:07 +00:00
|
|
|
$title, $message, $selected, $checkEdit,
|
2007-10-17 03:53:58 +00:00
|
|
|
&$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
|
|
|
*/
|
2008-08-21 14:09:57 +00:00
|
|
|
function buildContentActionUrls() {
|
2007-12-09 23:49:03 +00:00
|
|
|
global $wgContLang, $wgLang, $wgOut;
|
2008-05-06 14:14:37 +00:00
|
|
|
wfProfileIn( __METHOD__ );
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2005-02-21 11:28:07 +00:00
|
|
|
global $wgUser, $wgRequest;
|
2008-10-27 18:03:47 +00:00
|
|
|
$action = $wgRequest->getText( 'action' );
|
2004-11-19 04:14:59 +00:00
|
|
|
$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
|
|
|
|
2008-05-06 14:14:37 +00:00
|
|
|
wfProfileIn( __METHOD__."-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,
|
2008-08-16 09:09:45 +00:00
|
|
|
'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
|
|
|
);
|
|
|
|
|
}
|
2008-12-13 04:14:40 +00:00
|
|
|
} elseif ( $this->mTitle->isKnown() ) {
|
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
|
|
|
}
|
2008-05-06 14:14:37 +00:00
|
|
|
wfProfileOut( __METHOD__."-edit" );
|
2004-11-19 04:14:59 +00:00
|
|
|
|
2008-05-06 14:14:37 +00:00
|
|
|
wfProfileIn( __METHOD__."-live" );
|
2008-08-20 08:24:10 +00:00
|
|
|
if ( $this->mTitle->exists() ) {
|
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
|
|
|
|
2008-08-20 08:40:37 +00:00
|
|
|
if( $wgUser->isAllowed('delete') ) {
|
2007-12-11 09:51:56 +00:00
|
|
|
$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' ) ) {
|
2008-08-20 08:24:10 +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
|
|
|
|
2008-05-06 14:14:37 +00:00
|
|
|
wfProfileOut( __METHOD__."-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
|
|
|
}
|
2008-04-14 07:45:50 +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
|
|
|
|
2008-05-06 14:14:37 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
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
|
|
|
*/
|
2008-08-21 14:09:57 +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
|
|
|
|
2008-05-06 14:14:37 +00:00
|
|
|
wfProfileIn( __METHOD__ );
|
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() );
|
2008-09-18 20:28:52 +00:00
|
|
|
if( $wgEnableUploads && $wgUser->isAllowed( 'upload' ) ) {
|
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 ) {
|
2009-01-02 20:50:24 +00:00
|
|
|
global $wgScript;
|
2005-08-23 17:25:22 +00:00
|
|
|
$nav_urls['permalink'] = array(
|
|
|
|
|
'text' => wfMsg( 'permalink' ),
|
2009-01-02 20:50:24 +00:00
|
|
|
'href' => "{$wgScript}?oldid={$this->mRevisionId}"
|
2005-09-28 13:52:22 +00:00
|
|
|
);
|
2005-08-23 17:25:22 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +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
|
|
|
);
|
2008-04-14 07:45:50 +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
|
|
|
}
|
2008-05-06 14:14:37 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
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
|
|
|
*/
|
2008-08-21 14:09:57 +00:00
|
|
|
function getNameSpaceKey() {
|
2006-03-20 08:25:34 +00:00
|
|
|
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
|
|
|
*/
|
2007-05-08 20:48:02 +00:00
|
|
|
function setupUserJs( $allowUserJs ) {
|
2008-05-06 14:14:37 +00:00
|
|
|
wfProfileIn( __METHOD__ );
|
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 {
|
2008-05-20 19:30:06 +00:00
|
|
|
$this->userjs = self::makeUrl($this->userpage.'/'.$this->skinname.'.js', 'action=raw&ctype='.$wgJsMimeType);
|
2004-11-19 04:14:59 +00:00
|
|
|
}
|
|
|
|
|
}
|
2008-05-06 14:14:37 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
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() {
|
2008-05-06 14:14:37 +00:00
|
|
|
wfProfileIn( __METHOD__ );
|
2005-09-27 19:40:14 +00:00
|
|
|
$out = false;
|
2006-01-14 21:16:28 +00:00
|
|
|
wfRunHooks( 'SkinTemplateSetupPageCss', array( &$out ) );
|
2008-05-06 14:14:37 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2005-09-27 19:40:14 +00:00
|
|
|
return $out;
|
|
|
|
|
}
|
2004-11-19 04:14:59 +00:00
|
|
|
}
|
|
|
|
|
|
2004-11-19 12:44:51 +00:00
|
|
|
/**
|
|
|
|
|
* Generic wrapper for template functions, with interface
|
|
|
|
|
* compatible with what we use of PHPTAL 0.7.
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup 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
|
|
|
}
|
|
|
|
|
}
|