2004-02-18 02:15:00 +00:00
|
|
|
<?php
|
2012-05-10 15:51:44 +00:00
|
|
|
/**
|
|
|
|
|
* Base class for all skins.
|
|
|
|
|
*
|
|
|
|
|
* 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.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
*/
|
|
|
|
|
|
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
|
|
|
/**
|
|
|
|
|
* @defgroup Skins Skins
|
|
|
|
|
*/
|
|
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2013-05-25 11:10:34 +00:00
|
|
|
* The main skin class which provides methods and properties for all other skins.
|
2007-04-24 06:53:31 +00:00
|
|
|
*
|
|
|
|
|
* See docs/skin.txt for more information.
|
|
|
|
|
*
|
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-09-02 23:28:24 +00:00
|
|
|
*/
|
2011-07-18 20:52:22 +00:00
|
|
|
abstract class Skin extends ContextSource {
|
2014-05-26 10:27:02 +00:00
|
|
|
protected $skinname = null;
|
2011-01-01 01:03:02 +00:00
|
|
|
protected $mRelevantTitle = null;
|
|
|
|
|
protected $mRelevantUser = null;
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2014-05-31 12:49:24 +00:00
|
|
|
/**
|
|
|
|
|
* @var string Stylesheets set to use. Subdirectory in skins/ where various stylesheets are
|
|
|
|
|
* located. Only needs to be set if you intend to use the getSkinStylePath() method.
|
|
|
|
|
*/
|
|
|
|
|
public $stylename = null;
|
|
|
|
|
|
2005-12-19 23:36:43 +00:00
|
|
|
/**
|
|
|
|
|
* Fetch the set of available skins.
|
2014-04-23 09:46:22 +00:00
|
|
|
* @return array Associative array of strings
|
2005-12-19 23:36:43 +00:00
|
|
|
*/
|
2007-01-22 23:50:42 +00:00
|
|
|
static function getSkinNames() {
|
2006-06-08 15:12:26 +00:00
|
|
|
global $wgValidSkinNames;
|
2006-07-02 15:57:59 +00:00
|
|
|
static $skinsInitialised = false;
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2010-12-26 22:24:55 +00:00
|
|
|
if ( !$skinsInitialised || !count( $wgValidSkinNames ) ) {
|
2006-07-02 15:57:59 +00:00
|
|
|
# Get a list of available skins
|
|
|
|
|
# Build using the regular expression '^(.*).php$'
|
|
|
|
|
# Array keys are all lower case, array value keep the case used by filename
|
|
|
|
|
#
|
|
|
|
|
wfProfileIn( __METHOD__ . '-init' );
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2006-07-02 15:57:59 +00:00
|
|
|
global $wgStyleDirectory;
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2006-07-02 15:57:59 +00:00
|
|
|
$skinDir = dir( $wgStyleDirectory );
|
|
|
|
|
|
2013-03-27 07:14:01 +00:00
|
|
|
if ( $skinDir !== false && $skinDir !== null ) {
|
|
|
|
|
# while code from www.php.net
|
|
|
|
|
while ( false !== ( $file = $skinDir->read() ) ) {
|
|
|
|
|
// Skip non-PHP files, hidden files, and '.dep' includes
|
|
|
|
|
$matches = array();
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2013-03-27 07:14:01 +00:00
|
|
|
if ( preg_match( '/^([^.]*)\.php$/', $file, $matches ) ) {
|
|
|
|
|
$aSkin = $matches[1];
|
2014-05-25 21:58:05 +00:00
|
|
|
|
|
|
|
|
// Explicitly disallow loading core skins via the autodiscovery mechanism.
|
|
|
|
|
//
|
|
|
|
|
// They should be loaded already (in a non-autodicovery way), but old files might still
|
|
|
|
|
// exist on the server because our MW version upgrade process is widely documented as
|
|
|
|
|
// requiring just copying over all files, without removing old ones.
|
|
|
|
|
//
|
|
|
|
|
// This is one of the reasons we should have never used autodiscovery in the first
|
|
|
|
|
// place. This hack can be safely removed when autodiscovery is gone.
|
|
|
|
|
if ( in_array( $aSkin, array( 'CologneBlue', 'Modern', 'MonoBook', 'Vector' ) ) ) {
|
2014-06-10 20:38:47 +00:00
|
|
|
wfLogWarning(
|
|
|
|
|
"An old copy of the $aSkin skin was found in your skins/ directory. " .
|
|
|
|
|
"You should remove it to avoid problems in the future." .
|
|
|
|
|
"See https://www.mediawiki.org/wiki/Manual:Skin_autodiscovery for details."
|
|
|
|
|
);
|
2014-05-25 21:58:05 +00:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-10 20:38:47 +00:00
|
|
|
wfLogWarning(
|
|
|
|
|
"A skin using autodiscovery mechanism, $aSkin, was found in your skins/ directory. " .
|
|
|
|
|
"The mechanism will be removed in MediaWiki 1.25 and the skin will no longer be recognized. " .
|
|
|
|
|
"See https://www.mediawiki.org/wiki/Manual:Skin_autodiscovery for information how to fix this."
|
|
|
|
|
);
|
2013-03-27 07:14:01 +00:00
|
|
|
$wgValidSkinNames[strtolower( $aSkin )] = $aSkin;
|
|
|
|
|
}
|
2006-07-02 15:57:59 +00:00
|
|
|
}
|
2013-03-27 07:14:01 +00:00
|
|
|
$skinDir->close();
|
2006-07-02 15:57:59 +00:00
|
|
|
}
|
|
|
|
|
$skinsInitialised = true;
|
|
|
|
|
wfProfileOut( __METHOD__ . '-init' );
|
|
|
|
|
}
|
2006-06-08 15:12:26 +00:00
|
|
|
return $wgValidSkinNames;
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2012-06-18 06:43:47 +00:00
|
|
|
|
2012-10-26 15:42:13 +00:00
|
|
|
/**
|
2012-01-03 18:33:26 +00:00
|
|
|
* Fetch the skinname messages for available skins.
|
2014-04-23 09:46:22 +00:00
|
|
|
* @return string[]
|
2012-01-03 18:33:26 +00:00
|
|
|
*/
|
|
|
|
|
static function getSkinNameMessages() {
|
|
|
|
|
$messages = array();
|
2013-04-20 22:49:30 +00:00
|
|
|
foreach ( self::getSkinNames() as $skinKey => $skinName ) {
|
2012-01-03 18:33:26 +00:00
|
|
|
$messages[] = "skinname-$skinKey";
|
|
|
|
|
}
|
|
|
|
|
return $messages;
|
|
|
|
|
}
|
here it is ... the upload-api, script-server, js2 (javascript phase2) branch merge 1st attempt.
Here is a short overview of changes and associated default configuration variables (most everything is off by default) also see ~soon to be updated~: http://www.mediawiki.org/wiki/Media_Projects_Overview
= Upload Improvements =
==Upload API ==
* Based on the early work of Bryan Tong and others it adds the upload option to the api.
* We rewrite Special:Upload page to include use the new refactoring
* Added in token checks in both the SpecialUpload.php page so avoids DOS / xss copy-by-url JavaScript based cross site POST file submissions
== Copy by URL==
$wgAllowCopyUploads = false;
* http class rewrite includes a new http background download see: includes/HttpFunctions.php
* spins off a php process that calls: maintenance/http_session_download.php
* pushes updates to the session and gives the user a progress bar on http copy uploads from other server progress (using js2 upload interface) (if not using the js2 upload interface it does the request in-place but the download is limited to the php ini timeout time)
== Firefogg ==
* Firefogg enables resumable upload by chunks
* progress indicators and conditional invokation (js2 system)
* and of-course client side transcoding.
= Script Server =
$wgEnableScriptLoader = false;
* off by default if $wgEnableScriptLoader is turned on script files are grouped, gziped, cached etc.
for more info see: http://www.mediawiki.org/wiki/Extension:ScriptLoader
* Includes some early skin js include fixes (skin/script system still lots of love)
* Includes a "javascript class autoloader" this is packaged into mwEmbed so that the mwEmbed library can work in stand alone mode (while retaining localization and script serving) (one such application is the make page for firefogg.org : http://www.firefogg.org/make/index.html )
* The file that contains the autojavascript loading classes is: js2/php/jsAutoloadLocalClasses.php
* One can use this auto class loading dependency system with extensions and add-ons but I need to better document that.
= js2 system / mwEmbed=
$wgEnableJS2system = false
* includes initial rewrite towards more jquery based javascript code
* especially for the Special:Upload page.
* Also the edit page include support for the "add-media-wizard"
* includes dependency loader for javascript that optionally takes advantage of the script-loader
* remote embedding of javascript interfaces (like embedding video, or commons media searching)
* $wgDebugJavaScript = false; .. .this variable lets you always get "always fresh javascript". When used with the script-loader it does not minify the script-loader output.
= mwEmbed =
* Will commit a separate patch to oggHandler that conditionally outputs <video tag> to use the new javascript video player.
** mv_embed player includes: play-head, volume control, remote embedding, oggz-chop support across plugins.
* add-media-wizard adds easy inserts of media to pages (with import)
== jQuery==
* we include a base install of jQuery, jQuery ui and some plugins.
* all the javascript classes are in the scriptloader so its easy to load any set of jquery ui components that you may need using the script-server. You get a callback so you can then execute js with dependencies loaded.
== other stuff ==
there is a bit more code in js2 that pertains to sequence editing, timed text display and basic image editing. We include a base import of pixastic-lib & pixastic-editor... will work with the pixastic developer to try and ensure upstream compatibility on our usage of the library for in-browser photo and sequence manipulation.
2009-07-14 23:52:14 +00:00
|
|
|
|
2008-08-06 17:41:17 +00:00
|
|
|
/**
|
2013-05-25 11:10:34 +00:00
|
|
|
* Fetch the list of user-selectable skins in regards to $wgSkipSkins.
|
2008-08-06 17:41:17 +00:00
|
|
|
* Useful for Special:Preferences and other places where you
|
|
|
|
|
* only want to show skins users _can_ use.
|
2013-05-25 13:05:55 +00:00
|
|
|
* @return string[]
|
2014-04-15 18:22:41 +00:00
|
|
|
* @since 1.23
|
2008-08-06 17:41:17 +00:00
|
|
|
*/
|
2013-05-25 13:05:55 +00:00
|
|
|
public static function getAllowedSkins() {
|
2008-08-06 17:41:17 +00:00
|
|
|
global $wgSkipSkins;
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2013-05-25 11:10:34 +00:00
|
|
|
$allowedSkins = self::getSkinNames();
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2008-08-06 17:41:17 +00:00
|
|
|
foreach ( $wgSkipSkins as $skip ) {
|
2013-05-25 11:10:34 +00:00
|
|
|
unset( $allowedSkins[$skip] );
|
2008-08-06 17:41:17 +00:00
|
|
|
}
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2013-05-25 11:10:34 +00:00
|
|
|
return $allowedSkins;
|
2008-08-06 17:41:17 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2013-05-25 13:05:55 +00:00
|
|
|
/**
|
2014-04-13 01:48:42 +00:00
|
|
|
* @deprecated since 1.23, use getAllowedSkins
|
2013-05-25 13:05:55 +00:00
|
|
|
* @return string[]
|
|
|
|
|
*/
|
|
|
|
|
public static function getUsableSkins() {
|
2014-04-13 01:48:42 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.23' );
|
2013-05-25 13:05:55 +00:00
|
|
|
return self::getAllowedSkins();
|
|
|
|
|
}
|
|
|
|
|
|
2005-12-19 23:36:43 +00:00
|
|
|
/**
|
|
|
|
|
* Normalize a skin preference value to a form that can be loaded.
|
|
|
|
|
* If a skin can't be found, it will fall back to the configured
|
2014-05-26 10:27:02 +00:00
|
|
|
* default, or the hardcoded default if that's broken.
|
|
|
|
|
* @param string $key 'monobook', 'vector', etc.
|
2005-12-19 23:36:43 +00:00
|
|
|
* @return string
|
|
|
|
|
*/
|
2006-07-10 15:41:30 +00:00
|
|
|
static function normalizeKey( $key ) {
|
2005-12-19 23:36:43 +00:00
|
|
|
global $wgDefaultSkin;
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2006-11-08 07:12:03 +00:00
|
|
|
$skinNames = Skin::getSkinNames();
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2012-02-15 19:44:54 +00:00
|
|
|
if ( $key == '' || $key == 'default' ) {
|
2005-12-19 23:36:43 +00:00
|
|
|
// Don't return the default immediately;
|
|
|
|
|
// in a misconfiguration we need to fall back.
|
|
|
|
|
$key = $wgDefaultSkin;
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-04 13:48:16 +00:00
|
|
|
if ( isset( $skinNames[$key] ) ) {
|
2005-12-19 23:36:43 +00:00
|
|
|
return $key;
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-12-19 23:36:43 +00:00
|
|
|
// Older versions of the software used a numeric setting
|
|
|
|
|
// in the user preferences.
|
|
|
|
|
$fallback = array(
|
|
|
|
|
0 => $wgDefaultSkin,
|
2010-02-01 13:52:55 +00:00
|
|
|
2 => 'cologneblue'
|
|
|
|
|
);
|
2005-12-19 23:36:43 +00:00
|
|
|
|
2010-09-04 13:48:16 +00:00
|
|
|
if ( isset( $fallback[$key] ) ) {
|
2005-12-19 23:36:43 +00:00
|
|
|
$key = $fallback[$key];
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2010-09-04 13:48:16 +00:00
|
|
|
if ( isset( $skinNames[$key] ) ) {
|
2005-12-19 23:36:43 +00:00
|
|
|
return $key;
|
2011-06-17 16:05:05 +00:00
|
|
|
} elseif ( isset( $skinNames[$wgDefaultSkin] ) ) {
|
2010-07-16 13:57:03 +00:00
|
|
|
return $wgDefaultSkin;
|
2005-12-19 23:36:43 +00:00
|
|
|
} else {
|
2010-07-16 13:57:03 +00:00
|
|
|
return 'vector';
|
2005-12-19 23:36:43 +00:00
|
|
|
}
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-12-19 23:36:43 +00:00
|
|
|
/**
|
|
|
|
|
* Factory method for loading a skin of a given type
|
2014-05-26 10:27:02 +00:00
|
|
|
* @param string $key 'monobook', 'vector', etc.
|
2005-12-19 23:36:43 +00:00
|
|
|
* @return Skin
|
|
|
|
|
*/
|
2006-07-10 15:41:30 +00:00
|
|
|
static function &newFromKey( $key ) {
|
2008-12-10 23:39:02 +00:00
|
|
|
global $wgStyleDirectory;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2006-11-08 07:12:03 +00:00
|
|
|
$key = Skin::normalizeKey( $key );
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2006-11-08 07:12:03 +00:00
|
|
|
$skinNames = Skin::getSkinNames();
|
2005-12-19 23:36:43 +00:00
|
|
|
$skinName = $skinNames[$key];
|
2010-12-26 14:15:27 +00:00
|
|
|
$className = "Skin{$skinName}";
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2006-02-18 04:34:10 +00:00
|
|
|
# Grab the skin class and initialise it.
|
2013-05-08 06:48:56 +00:00
|
|
|
if ( !class_exists( $className ) ) {
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2013-05-07 23:00:15 +00:00
|
|
|
require_once "{$wgStyleDirectory}/{$skinName}.php";
|
2007-12-14 06:53:15 +00:00
|
|
|
|
2013-03-13 07:42:41 +00:00
|
|
|
# Check if we got if not fallback to default skin
|
2013-05-08 06:48:56 +00:00
|
|
|
if ( !class_exists( $className ) ) {
|
2007-12-14 06:53:15 +00:00
|
|
|
# DO NOT die if the class isn't found. This breaks maintenance
|
|
|
|
|
# scripts and can cause a user account to be unrecoverable
|
|
|
|
|
# except by SQL manipulation if a previously valid skin name
|
|
|
|
|
# is no longer valid.
|
|
|
|
|
wfDebug( "Skin class does not exist: $className\n" );
|
2010-07-16 14:04:54 +00:00
|
|
|
$className = 'SkinVector';
|
2007-12-14 06:53:15 +00:00
|
|
|
}
|
2005-12-19 23:36:43 +00:00
|
|
|
}
|
2011-09-05 15:30:01 +00:00
|
|
|
$skin = new $className( $key );
|
2005-12-19 23:36:43 +00:00
|
|
|
return $skin;
|
|
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2014-03-15 20:13:54 +00:00
|
|
|
/**
|
2014-04-23 09:46:22 +00:00
|
|
|
* @return string Skin name
|
2014-03-15 20:13:54 +00:00
|
|
|
*/
|
2007-04-16 13:23:16 +00:00
|
|
|
public function getSkinName() {
|
|
|
|
|
return $this->skinname;
|
2004-06-09 13:04:52 +00:00
|
|
|
}
|
2004-07-24 13:18:14 +00:00
|
|
|
|
2011-11-29 21:04:20 +00:00
|
|
|
/**
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param OutputPage $out
|
2011-11-29 21:04:20 +00:00
|
|
|
*/
|
2008-08-21 14:09:57 +00:00
|
|
|
function initPage( OutputPage $out ) {
|
2007-10-13 11:24:50 +00:00
|
|
|
wfProfileIn( __METHOD__ );
|
2004-07-16 20:50:16 +00:00
|
|
|
|
2006-03-16 02:47:49 +00:00
|
|
|
$this->preloadExistence();
|
2004-07-16 20:50:16 +00:00
|
|
|
|
2007-10-13 11:24:50 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2004-07-16 20:50:16 +00:00
|
|
|
|
2013-05-13 22:09:33 +00:00
|
|
|
/**
|
|
|
|
|
* Defines the ResourceLoader modules that should be added to the skin
|
|
|
|
|
* It is recommended that skins wishing to override call parent::getDefaultModules()
|
|
|
|
|
* and substitute out any modules they wish to change by using a key to look them up
|
2014-04-23 09:46:22 +00:00
|
|
|
* @return array Array of modules with helper keys for easy overriding
|
2013-05-13 22:09:33 +00:00
|
|
|
*/
|
|
|
|
|
public function getDefaultModules() {
|
|
|
|
|
global $wgIncludeLegacyJavaScript, $wgPreloadJavaScriptMwUtil, $wgUseAjax,
|
2013-05-28 12:00:52 +00:00
|
|
|
$wgAjaxWatch, $wgEnableAPI, $wgEnableWriteAPI;
|
2013-05-13 22:09:33 +00:00
|
|
|
|
|
|
|
|
$out = $this->getOutput();
|
|
|
|
|
$user = $out->getUser();
|
|
|
|
|
$modules = array(
|
|
|
|
|
// modules that enhance the page content in some way
|
|
|
|
|
'content' => array(
|
|
|
|
|
'mediawiki.page.ready',
|
|
|
|
|
),
|
|
|
|
|
// modules that exist for legacy reasons
|
|
|
|
|
'legacy' => array(),
|
|
|
|
|
// modules relating to search functionality
|
|
|
|
|
'search' => array(),
|
|
|
|
|
// modules relating to functionality relating to watching an article
|
|
|
|
|
'watch' => array(),
|
|
|
|
|
// modules which relate to the current users preferences
|
|
|
|
|
'user' => array(),
|
|
|
|
|
);
|
|
|
|
|
if ( $wgIncludeLegacyJavaScript ) {
|
|
|
|
|
$modules['legacy'][] = 'mediawiki.legacy.wikibits';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $wgPreloadJavaScriptMwUtil ) {
|
|
|
|
|
$modules['legacy'][] = 'mediawiki.util';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add various resources if required
|
|
|
|
|
if ( $wgUseAjax ) {
|
|
|
|
|
$modules['legacy'][] = 'mediawiki.legacy.ajax';
|
|
|
|
|
|
2013-05-28 12:00:52 +00:00
|
|
|
if ( $wgEnableAPI ) {
|
|
|
|
|
if ( $wgEnableWriteAPI && $wgAjaxWatch && $user->isLoggedIn()
|
|
|
|
|
&& $user->isAllowed( 'writeapi' )
|
|
|
|
|
) {
|
|
|
|
|
$modules['watch'][] = 'mediawiki.page.watch.ajax';
|
|
|
|
|
}
|
2013-05-13 22:09:33 +00:00
|
|
|
|
2013-12-04 17:23:54 +00:00
|
|
|
$modules['search'][] = 'mediawiki.searchSuggest';
|
2013-05-13 22:09:33 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $user->getBoolOption( 'editsectiononrightclick' ) ) {
|
|
|
|
|
$modules['user'][] = 'mediawiki.action.view.rightClickEdit';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Crazy edit-on-double-click stuff
|
|
|
|
|
if ( $out->isArticle() && $user->getOption( 'editondblclick' ) ) {
|
|
|
|
|
$modules['user'][] = 'mediawiki.action.view.dblClickEdit';
|
|
|
|
|
}
|
|
|
|
|
return $modules;
|
|
|
|
|
}
|
|
|
|
|
|
2006-03-16 02:47:49 +00:00
|
|
|
/**
|
|
|
|
|
* Preload the existence of three commonly-requested pages in a single query
|
|
|
|
|
*/
|
|
|
|
|
function preloadExistence() {
|
2011-07-18 20:52:22 +00:00
|
|
|
$user = $this->getUser();
|
2011-06-17 16:05:05 +00:00
|
|
|
|
2007-01-22 19:19:15 +00:00
|
|
|
// User/talk link
|
Revert r86872: Breaks LiquidThreads page moves with the below failure. Threads are lost and nowhere to be found any more.
[25-Apr-2011 18:12:45] /wiki/Special:MoveThread/Thread:User_talk:Siebrand/test/One_new_message: Exception: MWNamespace::getTalk does not make any sense for given namespace -1
#0 /www/w/includes/Namespace.php(81): MWNamespace::isMethodValidFor(-1, 'MWNamespace::ge...')
#1 /www/w/includes/WatchedItem.php(73): MWNamespace::getTalk(-1)
#2 /www/w/includes/User.php(2304): WatchedItem->addWatch()
#3 /www/w/includes/actions/WatchAction.php(53): User->addWatch(Object(Title))
#4 /www/w/includes/Action.php(376): WatchAction->onView()
#5 /www/w/extensions/LiquidThreads/classes/Thread.php(115): FormlessAction->execute()
#6 /www/w/extensions/LiquidThreads/classes/Thread.php(435): Thread::create(Object(Article), Object(Article), NULL, 1, 'One new message')
#7 /www/w/extensions/LiquidThreads/classes/Thread.php(414): Thread->leaveTrace('move test', Object(Title), Object(Title))
#8 /www/w/extensions/LiquidThreads/pages/SpecialMoveThread.php(107): Thread->moveToPage(Object(Title), 'move test', true)
#9 [internal function]: SpecialMoveThread->trySubmit(Array)
#10 /www/w/includes/HTMLForm.php(279): call_user_func(Array, Array)
#11 /www/w/includes/HTMLForm.php(228): HTMLForm->trySubmit()
#12 /www/w/includes/HTMLForm.php(242): HTMLForm->tryAuthorizedSubmit()
#13 /www/w/extensions/LiquidThreads/pages/ThreadActionPage.php(37): HTMLForm->show()
#14 /www/w/includes/SpecialPageFactory.php(459): ThreadActionPage->execute('Thread:User_tal...')
#15 /www/w/includes/Wiki.php(252): SpecialPageFactory::executePath(Object(Title), Object(RequestContext))
#16 /www/w/includes/Wiki.php(98): MediaWiki->handleSpecialCases()
#17 /www/w/index.php(145): MediaWiki->performRequestForTitle(NULL)
#18 {main}
2011-04-25 18:20:53 +00:00
|
|
|
$titles = array( $user->getUserPage(), $user->getTalkPage() );
|
2007-01-22 19:19:15 +00:00
|
|
|
|
|
|
|
|
// Other tab link
|
2011-11-02 20:55:08 +00:00
|
|
|
if ( $this->getTitle()->isSpecialPage() ) {
|
2007-01-22 19:19:15 +00:00
|
|
|
// nothing
|
2011-04-03 12:46:36 +00:00
|
|
|
} elseif ( $this->getTitle()->isTalkPage() ) {
|
|
|
|
|
$titles[] = $this->getTitle()->getSubjectPage();
|
2006-03-16 02:47:49 +00:00
|
|
|
} else {
|
2011-04-03 12:46:36 +00:00
|
|
|
$titles[] = $this->getTitle()->getTalkPage();
|
2006-03-16 02:47:49 +00:00
|
|
|
}
|
2007-01-22 19:19:15 +00:00
|
|
|
|
|
|
|
|
$lb = new LinkBatch( $titles );
|
2010-09-14 07:26:48 +00:00
|
|
|
$lb->setCaller( __METHOD__ );
|
2006-03-16 02:47:49 +00:00
|
|
|
$lb->execute();
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2011-05-02 15:26:19 +00:00
|
|
|
/**
|
|
|
|
|
* Get the current revision ID
|
|
|
|
|
*
|
2014-04-23 09:46:22 +00:00
|
|
|
* @return int
|
2011-05-02 15:26:19 +00:00
|
|
|
*/
|
|
|
|
|
public function getRevisionId() {
|
2011-07-18 20:52:22 +00:00
|
|
|
return $this->getOutput()->getRevisionId();
|
2011-05-02 15:26:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Whether the revision displayed is the latest revision of the page
|
|
|
|
|
*
|
2014-04-23 09:46:22 +00:00
|
|
|
* @return bool
|
2011-05-02 15:26:19 +00:00
|
|
|
*/
|
|
|
|
|
public function isRevisionCurrent() {
|
|
|
|
|
$revID = $this->getRevisionId();
|
|
|
|
|
return $revID == 0 || $revID == $this->getTitle()->getLatestRevID();
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-01 01:03:02 +00:00
|
|
|
/**
|
|
|
|
|
* Set the "relevant" title
|
|
|
|
|
* @see self::getRelevantTitle()
|
2014-04-23 11:39:49 +00:00
|
|
|
* @param Title $t
|
2011-01-01 01:03:02 +00:00
|
|
|
*/
|
|
|
|
|
public function setRelevantTitle( $t ) {
|
|
|
|
|
$this->mRelevantTitle = $t;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return the "relevant" title.
|
|
|
|
|
* A "relevant" title is not necessarily the actual title of the page.
|
|
|
|
|
* Special pages like Special:MovePage use set the page they are acting on
|
|
|
|
|
* as their "relevant" title, this allows the skin system to display things
|
|
|
|
|
* such as content tabs which belong to to that page instead of displaying
|
|
|
|
|
* a basic special page tab which has almost no meaning.
|
2011-06-26 23:40:43 +00:00
|
|
|
*
|
|
|
|
|
* @return Title
|
2011-01-01 01:03:02 +00:00
|
|
|
*/
|
|
|
|
|
public function getRelevantTitle() {
|
2013-02-03 20:05:24 +00:00
|
|
|
if ( isset( $this->mRelevantTitle ) ) {
|
2011-01-01 01:03:02 +00:00
|
|
|
return $this->mRelevantTitle;
|
|
|
|
|
}
|
2011-04-03 12:46:36 +00:00
|
|
|
return $this->getTitle();
|
2011-01-01 01:03:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the "relevant" user
|
|
|
|
|
* @see self::getRelevantUser()
|
2014-04-23 11:39:49 +00:00
|
|
|
* @param User $u
|
2011-01-01 01:03:02 +00:00
|
|
|
*/
|
|
|
|
|
public function setRelevantUser( $u ) {
|
|
|
|
|
$this->mRelevantUser = $u;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return the "relevant" user.
|
|
|
|
|
* A "relevant" user is similar to a relevant title. Special pages like
|
|
|
|
|
* Special:Contributions mark the user which they are relevant to so that
|
|
|
|
|
* things like the toolbox can display the information they usually are only
|
|
|
|
|
* able to display on a user's userpage and talkpage.
|
2011-04-17 11:31:11 +00:00
|
|
|
* @return User
|
2011-01-01 01:03:02 +00:00
|
|
|
*/
|
|
|
|
|
public function getRelevantUser() {
|
2013-02-03 20:05:24 +00:00
|
|
|
if ( isset( $this->mRelevantUser ) ) {
|
2011-01-01 01:03:02 +00:00
|
|
|
return $this->mRelevantUser;
|
|
|
|
|
}
|
|
|
|
|
$title = $this->getRelevantTitle();
|
2013-04-20 22:49:30 +00:00
|
|
|
if ( $title->hasSubjectNamespace( NS_USER ) ) {
|
2012-08-30 20:05:58 +00:00
|
|
|
$rootUser = $title->getRootText();
|
2011-01-01 01:03:02 +00:00
|
|
|
if ( User::isIP( $rootUser ) ) {
|
|
|
|
|
$this->mRelevantUser = User::newFromName( $rootUser, false );
|
|
|
|
|
} else {
|
2011-10-03 13:41:50 +00:00
|
|
|
$user = User::newFromName( $rootUser, false );
|
2011-11-20 10:55:58 +00:00
|
|
|
if ( $user && $user->isLoggedIn() ) {
|
2011-01-01 01:03:02 +00:00
|
|
|
$this->mRelevantUser = $user;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $this->mRelevantUser;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-01 13:52:55 +00:00
|
|
|
/**
|
|
|
|
|
* Outputs the HTML generated by other functions.
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param OutputPage $out
|
2010-02-01 13:52:55 +00:00
|
|
|
*/
|
2011-09-01 14:33:57 +00:00
|
|
|
abstract function outputPage( OutputPage $out = null );
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2011-11-29 21:04:20 +00:00
|
|
|
/**
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param array $data
|
2011-11-29 21:04:20 +00:00
|
|
|
* @return string
|
|
|
|
|
*/
|
2006-12-08 06:09:15 +00:00
|
|
|
static function makeVariablesScript( $data ) {
|
2010-09-04 13:48:16 +00:00
|
|
|
if ( $data ) {
|
2010-09-24 22:10:25 +00:00
|
|
|
return Html::inlineScript(
|
|
|
|
|
ResourceLoader::makeLoaderConditionalScript( ResourceLoader::makeConfigSetScript( $data ) )
|
|
|
|
|
);
|
2009-08-22 19:55:28 +00:00
|
|
|
} else {
|
|
|
|
|
return '';
|
2011-06-17 16:05:05 +00:00
|
|
|
}
|
2006-07-28 22:52:46 +00:00
|
|
|
}
|
|
|
|
|
|
2011-12-29 20:39:29 +00:00
|
|
|
/**
|
2012-07-10 12:48:06 +00:00
|
|
|
* Make a "<script>" tag containing global variables
|
2011-12-29 20:39:29 +00:00
|
|
|
*
|
2014-04-15 20:18:19 +00:00
|
|
|
* @deprecated since 1.19
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param mixed $unused
|
2011-12-29 20:39:29 +00:00
|
|
|
* @return string HTML fragment
|
|
|
|
|
*/
|
|
|
|
|
public static function makeGlobalVariablesScript( $unused ) {
|
|
|
|
|
global $wgOut;
|
|
|
|
|
|
|
|
|
|
wfDeprecated( __METHOD__, '1.19' );
|
|
|
|
|
|
|
|
|
|
return self::makeVariablesScript( $wgOut->getJSVars() );
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-02 19:54:46 +00:00
|
|
|
/**
|
|
|
|
|
* Get the query to generate a dynamic stylesheet
|
2010-09-04 01:06:34 +00:00
|
|
|
*
|
2010-07-02 19:54:46 +00:00
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public static function getDynamicStylesheetQuery() {
|
|
|
|
|
global $wgSquidMaxage;
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2010-07-02 19:54:46 +00:00
|
|
|
return array(
|
|
|
|
|
'action' => 'raw',
|
|
|
|
|
'maxage' => $wgSquidMaxage,
|
|
|
|
|
'usemsgcache' => 'yes',
|
|
|
|
|
'ctype' => 'text/css',
|
|
|
|
|
'smaxage' => $wgSquidMaxage,
|
|
|
|
|
);
|
|
|
|
|
}
|
2008-08-21 14:09:57 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add skin specific stylesheets
|
2011-05-04 10:43:40 +00:00
|
|
|
* Calling this method with an $out of anything but the same OutputPage
|
2011-07-18 20:52:22 +00:00
|
|
|
* inside ->getOutput() is deprecated. The $out arg is kept
|
2011-05-04 10:43:40 +00:00
|
|
|
* for compatibility purposes with skins.
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param OutputPage $out
|
2012-07-10 15:16:46 +00:00
|
|
|
* @todo delete
|
2008-08-21 14:09:57 +00:00
|
|
|
*/
|
2011-02-04 04:18:05 +00:00
|
|
|
abstract function setupSkinUserCss( OutputPage $out );
|
2008-08-21 14:09:57 +00:00
|
|
|
|
2011-04-16 20:01:39 +00:00
|
|
|
/**
|
|
|
|
|
* TODO: document
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param Title $title
|
|
|
|
|
* @return string
|
2011-04-16 20:01:39 +00:00
|
|
|
*/
|
2008-08-10 20:10:37 +00:00
|
|
|
function getPageClasses( $title ) {
|
2010-02-01 13:52:55 +00:00
|
|
|
$numeric = 'ns-' . $title->getNamespace();
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2011-11-02 20:55:08 +00:00
|
|
|
if ( $title->isSpecialPage() ) {
|
2009-03-29 12:46:11 +00:00
|
|
|
$type = 'ns-special';
|
2011-02-06 21:08:48 +00:00
|
|
|
// bug 23315: provide a class based on the canonical special page name without subpages
|
2011-04-17 11:31:11 +00:00
|
|
|
list( $canonicalName ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
|
2011-02-06 21:08:48 +00:00
|
|
|
if ( $canonicalName ) {
|
2011-02-09 17:06:41 +00:00
|
|
|
$type .= ' ' . Sanitizer::escapeClass( "mw-special-$canonicalName" );
|
2011-02-06 21:08:48 +00:00
|
|
|
} else {
|
|
|
|
|
$type .= ' mw-invalidspecialpage';
|
|
|
|
|
}
|
2010-09-04 13:48:16 +00:00
|
|
|
} elseif ( $title->isTalkPage() ) {
|
2009-03-29 12:46:11 +00:00
|
|
|
$type = 'ns-talk';
|
2008-08-10 19:48:30 +00:00
|
|
|
} else {
|
2009-03-29 12:46:11 +00:00
|
|
|
$type = 'ns-subject';
|
2008-08-10 19:48:30 +00:00
|
|
|
}
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2010-02-01 13:52:55 +00:00
|
|
|
$name = Sanitizer::escapeClass( 'page-' . $title->getPrefixedText() );
|
2011-08-09 18:36:20 +00:00
|
|
|
|
|
|
|
|
return "$numeric $type $name";
|
2008-08-10 19:48:30 +00:00
|
|
|
}
|
2010-10-04 05:38:48 +00:00
|
|
|
|
2013-12-18 18:34:57 +00:00
|
|
|
/*
|
|
|
|
|
* Return values for <html> element
|
|
|
|
|
* @return array of associative name-to-value elements for <html> element
|
|
|
|
|
*/
|
|
|
|
|
public function getHtmlElementAttributes() {
|
|
|
|
|
$lang = $this->getLanguage();
|
|
|
|
|
return array(
|
|
|
|
|
'lang' => $lang->getHtmlCode(),
|
|
|
|
|
'dir' => $lang->getDir(),
|
|
|
|
|
'class' => 'client-nojs',
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-03 14:12:41 +00:00
|
|
|
/**
|
|
|
|
|
* This will be called by OutputPage::headElement when it is creating the
|
2012-07-10 12:48:06 +00:00
|
|
|
* "<body>" tag, skins can override it if they have a need to add in any
|
2010-10-03 14:12:41 +00:00
|
|
|
* body attributes or classes of their own.
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param OutputPage $out
|
|
|
|
|
* @param array $bodyAttrs
|
2010-10-03 14:12:41 +00:00
|
|
|
*/
|
2010-10-04 05:38:48 +00:00
|
|
|
function addToBodyAttributes( $out, &$bodyAttrs ) {
|
2010-10-03 14:12:41 +00:00
|
|
|
// does nothing by default
|
|
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* URL to the logo
|
2014-04-23 09:46:22 +00:00
|
|
|
* @return string
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2004-09-02 00:25:56 +00:00
|
|
|
function getLogo() {
|
2003-04-14 23:10:40 +00:00
|
|
|
global $wgLogo;
|
|
|
|
|
return $wgLogo;
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-29 21:04:20 +00:00
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2011-05-04 10:43:40 +00:00
|
|
|
function getCategoryLinks() {
|
2011-07-13 13:33:37 +00:00
|
|
|
global $wgUseCategoryBrowser;
|
2011-03-03 10:22:46 +00:00
|
|
|
|
2011-07-18 20:52:22 +00:00
|
|
|
$out = $this->getOutput();
|
2011-07-24 17:05:42 +00:00
|
|
|
$allCats = $out->getCategoryLinks();
|
2011-04-16 20:22:18 +00:00
|
|
|
|
2011-07-24 17:05:42 +00:00
|
|
|
if ( !count( $allCats ) ) {
|
2010-02-01 13:52:55 +00:00
|
|
|
return '';
|
|
|
|
|
}
|
2004-07-16 20:50:16 +00:00
|
|
|
|
2011-07-13 13:33:37 +00:00
|
|
|
$embed = "<li>";
|
2011-07-13 10:41:21 +00:00
|
|
|
$pop = "</li>";
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2008-02-25 16:38:25 +00:00
|
|
|
$s = '';
|
2011-10-21 20:09:27 +00:00
|
|
|
$colon = $this->msg( 'colon-separator' )->escaped();
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2008-02-25 16:38:25 +00:00
|
|
|
if ( !empty( $allCats['normal'] ) ) {
|
2013-02-03 20:05:24 +00:00
|
|
|
$t = $embed . implode( "{$pop}{$embed}", $allCats['normal'] ) . $pop;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2012-08-27 23:38:19 +00:00
|
|
|
$msg = $this->msg( 'pagecategories' )->numParams( count( $allCats['normal'] ) )->escaped();
|
2011-10-21 20:09:27 +00:00
|
|
|
$linkPage = wfMessage( 'pagecategorieslink' )->inContentLanguage()->text();
|
2011-09-09 15:37:20 +00:00
|
|
|
$s .= '<div id="mw-normal-catlinks" class="mw-normal-catlinks">' .
|
2011-10-21 20:09:27 +00:00
|
|
|
Linker::link( Title::newFromText( $linkPage ), $msg )
|
2011-07-13 10:41:21 +00:00
|
|
|
. $colon . '<ul>' . $t . '</ul>' . '</div>';
|
2008-02-25 16:38:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Hidden categories
|
|
|
|
|
if ( isset( $allCats['hidden'] ) ) {
|
2011-07-18 20:52:22 +00:00
|
|
|
if ( $this->getUser()->getBoolOption( 'showhiddencats' ) ) {
|
2011-09-09 15:37:20 +00:00
|
|
|
$class = ' mw-hidden-cats-user-shown';
|
2011-04-03 12:46:36 +00:00
|
|
|
} elseif ( $this->getTitle()->getNamespace() == NS_CATEGORY ) {
|
2011-09-09 15:37:20 +00:00
|
|
|
$class = ' mw-hidden-cats-ns-shown';
|
2008-02-25 16:38:25 +00:00
|
|
|
} else {
|
2011-09-09 15:37:20 +00:00
|
|
|
$class = ' mw-hidden-cats-hidden';
|
2008-02-25 16:38:25 +00:00
|
|
|
}
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2011-09-09 15:37:20 +00:00
|
|
|
$s .= "<div id=\"mw-hidden-catlinks\" class=\"mw-hidden-catlinks$class\">" .
|
2012-08-27 23:38:19 +00:00
|
|
|
$this->msg( 'hidden-categories' )->numParams( count( $allCats['hidden'] ) )->escaped() .
|
2013-02-03 20:05:24 +00:00
|
|
|
$colon . '<ul>' . $embed . implode( "{$pop}{$embed}", $allCats['hidden'] ) . $pop . '</ul>' .
|
2010-02-01 13:52:55 +00:00
|
|
|
'</div>';
|
2008-02-25 16:38:25 +00:00
|
|
|
}
|
2004-07-16 20:50:16 +00:00
|
|
|
|
2004-08-23 00:49:02 +00:00
|
|
|
# optional 'dmoz-like' category browser. Will be shown under the list
|
|
|
|
|
# of categories an article belong to
|
2010-09-04 13:48:16 +00:00
|
|
|
if ( $wgUseCategoryBrowser ) {
|
2005-02-11 06:37:22 +00:00
|
|
|
$s .= '<br /><hr />';
|
2004-09-03 21:22:20 +00:00
|
|
|
|
2004-08-23 00:49:02 +00:00
|
|
|
# get a big array of the parents tree
|
2011-04-03 12:46:36 +00:00
|
|
|
$parenttree = $this->getTitle()->getParentCategoryTree();
|
2005-02-23 22:25:00 +00:00
|
|
|
# Skin object passed by reference cause it can not be
|
2005-08-25 00:39:07 +00:00
|
|
|
# accessed under the method subfunction drawCategoryBrowser
|
2011-06-26 23:40:43 +00:00
|
|
|
$tempout = explode( "\n", $this->drawCategoryBrowser( $parenttree ) );
|
2005-08-25 00:39:07 +00:00
|
|
|
# Clean out bogus first entry and sort them
|
2009-03-29 12:46:11 +00:00
|
|
|
unset( $tempout[0] );
|
|
|
|
|
asort( $tempout );
|
2005-08-25 00:39:07 +00:00
|
|
|
# Output one per line
|
2009-03-29 12:46:11 +00:00
|
|
|
$s .= implode( "<br />\n", $tempout );
|
2004-06-06 02:06:46 +00:00
|
|
|
}
|
2004-07-16 20:50:16 +00:00
|
|
|
|
2004-05-31 09:04:50 +00:00
|
|
|
return $s;
|
|
|
|
|
}
|
2004-07-16 20:50:16 +00:00
|
|
|
|
2009-03-29 12:46:11 +00:00
|
|
|
/**
|
2013-03-13 07:42:41 +00:00
|
|
|
* Render the array as a series of links.
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param array $tree Categories tree returned by Title::getParentCategoryTree
|
|
|
|
|
* @return string Separated by >, terminate with "\n"
|
2005-08-25 00:39:07 +00:00
|
|
|
*/
|
2011-04-16 20:01:39 +00:00
|
|
|
function drawCategoryBrowser( $tree ) {
|
2005-07-02 22:39:22 +00:00
|
|
|
$return = '';
|
2010-09-04 13:48:16 +00:00
|
|
|
|
|
|
|
|
foreach ( $tree as $element => $parent ) {
|
|
|
|
|
if ( empty( $parent ) ) {
|
2005-07-02 22:39:22 +00:00
|
|
|
# element start a new list
|
2005-08-25 00:39:07 +00:00
|
|
|
$return .= "\n";
|
2005-07-02 22:39:22 +00:00
|
|
|
} else {
|
|
|
|
|
# grab the others elements
|
2011-04-16 20:01:39 +00:00
|
|
|
$return .= $this->drawCategoryBrowser( $parent ) . ' > ';
|
2005-07-02 22:39:22 +00:00
|
|
|
}
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2005-07-02 22:39:22 +00:00
|
|
|
# add our current element to the list
|
2009-03-29 12:46:11 +00:00
|
|
|
$eltitle = Title::newFromText( $element );
|
2013-02-03 20:05:24 +00:00
|
|
|
$return .= Linker::link( $eltitle, htmlspecialchars( $eltitle->getText() ) );
|
2005-07-02 22:39:22 +00:00
|
|
|
}
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2005-07-02 22:39:22 +00:00
|
|
|
return $return;
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-29 21:04:20 +00:00
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2011-05-04 10:43:40 +00:00
|
|
|
function getCategories() {
|
2011-07-18 20:52:22 +00:00
|
|
|
$out = $this->getOutput();
|
2011-05-04 01:53:05 +00:00
|
|
|
|
2011-05-04 10:43:40 +00:00
|
|
|
$catlinks = $this->getCategoryLinks();
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-09 11:45:12 +00:00
|
|
|
$classes = 'catlinks';
|
2009-10-17 10:35:46 +00:00
|
|
|
|
2010-09-04 13:48:16 +00:00
|
|
|
// Check what we're showing
|
2011-03-03 10:22:46 +00:00
|
|
|
$allCats = $out->getCategoryLinks();
|
2011-07-18 20:52:22 +00:00
|
|
|
$showHidden = $this->getUser()->getBoolOption( 'showhiddencats' ) ||
|
2011-04-03 12:46:36 +00:00
|
|
|
$this->getTitle()->getNamespace() == NS_CATEGORY;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2010-09-04 13:48:16 +00:00
|
|
|
if ( empty( $allCats['normal'] ) && !( !empty( $allCats['hidden'] ) && $showHidden ) ) {
|
2008-03-09 11:45:12 +00:00
|
|
|
$classes .= ' catlinks-allhidden';
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2009-08-25 15:09:40 +00:00
|
|
|
return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
|
2004-04-28 06:03:45 +00:00
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2008-08-08 15:53:49 +00:00
|
|
|
/**
|
|
|
|
|
* This runs a hook to allow extensions placing their stuff after content
|
|
|
|
|
* and article metadata (e.g. categories).
|
|
|
|
|
* Note: This function has nothing to do with afterContent().
|
|
|
|
|
*
|
|
|
|
|
* This hook is placed here in order to allow using the same hook for all
|
|
|
|
|
* skins, both the SkinTemplate based ones and the older ones, which directly
|
|
|
|
|
* use this class to get their data.
|
|
|
|
|
*
|
|
|
|
|
* The output of this function gets processed in SkinTemplate::outputPage() for
|
|
|
|
|
* the SkinTemplate based skins, all other skins should directly echo it.
|
|
|
|
|
*
|
2014-04-23 09:46:22 +00:00
|
|
|
* @return string Empty by default, if not changed by any hook function.
|
2008-08-08 15:53:49 +00:00
|
|
|
*/
|
2008-08-21 14:09:57 +00:00
|
|
|
protected function afterContentHook() {
|
2009-03-29 12:46:11 +00:00
|
|
|
$data = '';
|
2008-08-08 15:53:49 +00:00
|
|
|
|
2010-09-04 13:48:16 +00:00
|
|
|
if ( wfRunHooks( 'SkinAfterContent', array( &$data, $this ) ) ) {
|
2008-08-08 15:53:49 +00:00
|
|
|
// adding just some spaces shouldn't toggle the output
|
|
|
|
|
// of the whole <div/>, so we use trim() here
|
2010-09-04 13:48:16 +00:00
|
|
|
if ( trim( $data ) != '' ) {
|
2008-08-08 15:53:49 +00:00
|
|
|
// Doing this here instead of in the skins to
|
|
|
|
|
// ensure that the div has the same ID in all
|
|
|
|
|
// skins
|
2008-08-09 01:46:25 +00:00
|
|
|
$data = "<div id='mw-data-after-content'>\n" .
|
2008-08-08 15:53:49 +00:00
|
|
|
"\t$data\n" .
|
2008-08-09 01:46:25 +00:00
|
|
|
"</div>\n";
|
2008-08-08 15:53:49 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
2008-08-21 14:09:57 +00:00
|
|
|
wfDebug( "Hook SkinAfterContent changed output processing.\n" );
|
2008-08-08 15:53:49 +00:00
|
|
|
}
|
|
|
|
|
|
2008-08-08 16:12:05 +00:00
|
|
|
return $data;
|
2008-08-08 15:53:49 +00:00
|
|
|
}
|
|
|
|
|
|
2009-02-08 23:39:17 +00:00
|
|
|
/**
|
|
|
|
|
* Generate debug data HTML for displaying at the bottom of the main content
|
|
|
|
|
* area.
|
2014-04-23 09:46:22 +00:00
|
|
|
* @return string HTML containing debug data, if enabled (otherwise empty).
|
2009-02-08 23:39:17 +00:00
|
|
|
*/
|
2011-05-04 10:43:40 +00:00
|
|
|
protected function generateDebugHTML() {
|
2012-08-27 20:57:15 +00:00
|
|
|
return MWDebug::getHTMLDebugLog();
|
2009-09-17 18:55:29 +00:00
|
|
|
}
|
|
|
|
|
|
2006-07-29 22:34:22 +00:00
|
|
|
/**
|
2012-07-10 12:48:06 +00:00
|
|
|
* This gets called shortly before the "</body>" tag.
|
2011-07-24 17:05:42 +00:00
|
|
|
*
|
2014-04-23 09:46:22 +00:00
|
|
|
* @return string HTML-wrapped JS code to be put before "</body>"
|
2006-07-29 22:34:22 +00:00
|
|
|
*/
|
2011-07-24 17:05:42 +00:00
|
|
|
function bottomScripts() {
|
2011-04-07 12:07:25 +00:00
|
|
|
// TODO and the suckage continues. This function is really just a wrapper around
|
|
|
|
|
// OutputPage::getBottomScripts() which takes a Skin param. This should be cleaned
|
|
|
|
|
// up at some point
|
2011-07-24 17:05:42 +00:00
|
|
|
$bottomScriptText = $this->getOutput()->getBottomScripts();
|
2007-08-23 22:34:12 +00:00
|
|
|
wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2007-08-23 22:34:12 +00:00
|
|
|
return $bottomScriptText;
|
2006-07-29 22:34:22 +00:00
|
|
|
}
|
|
|
|
|
|
2011-08-29 10:47:44 +00:00
|
|
|
/**
|
|
|
|
|
* Text with the permalink to the source page,
|
|
|
|
|
* usually shown on the footer of a printed page
|
|
|
|
|
*
|
|
|
|
|
* @return string HTML text with an URL
|
|
|
|
|
*/
|
2004-08-09 00:22:43 +00:00
|
|
|
function printSource() {
|
2011-08-29 10:47:44 +00:00
|
|
|
$oldid = $this->getRevisionId();
|
2011-09-07 12:56:06 +00:00
|
|
|
if ( $oldid ) {
|
2014-05-11 15:33:33 +00:00
|
|
|
$canonicalUrl = $this->getTitle()->getCanonicalURL( 'oldid=' . $oldid );
|
|
|
|
|
$url = htmlspecialchars( wfExpandIRI( $canonicalUrl ) );
|
2011-09-07 12:56:06 +00:00
|
|
|
} else {
|
|
|
|
|
// oldid not available for non existing pages
|
2012-03-29 05:55:27 +00:00
|
|
|
$url = htmlspecialchars( wfExpandIRI( $this->getTitle()->getCanonicalURL() ) );
|
2011-09-07 12:56:06 +00:00
|
|
|
}
|
2014-05-11 15:33:33 +00:00
|
|
|
|
|
|
|
|
return $this->msg( 'retrievedfrom', '<a dir="ltr" href="' . $url
|
|
|
|
|
. '">' . $url . '</a>' )->text();
|
2004-08-09 00:22:43 +00:00
|
|
|
}
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2011-11-29 21:04:20 +00:00
|
|
|
/**
|
2014-04-23 09:46:22 +00:00
|
|
|
* @return string
|
2011-11-29 21:04:20 +00:00
|
|
|
*/
|
2004-06-01 03:41:00 +00:00
|
|
|
function getUndeleteLink() {
|
2011-07-18 20:52:22 +00:00
|
|
|
$action = $this->getRequest()->getVal( 'action', 'view' );
|
2009-04-23 20:07:18 +00:00
|
|
|
|
2011-10-07 13:58:16 +00:00
|
|
|
if ( $this->getUser()->isAllowed( 'deletedhistory' ) &&
|
2012-03-11 22:05:54 +00:00
|
|
|
( $this->getTitle()->getArticleID() == 0 || $action == 'history' ) ) {
|
2011-09-16 16:55:39 +00:00
|
|
|
$n = $this->getTitle()->isDeleted();
|
2011-07-06 16:47:29 +00:00
|
|
|
|
2009-05-28 17:15:58 +00:00
|
|
|
if ( $n ) {
|
2011-07-18 20:52:22 +00:00
|
|
|
if ( $this->getUser()->isAllowed( 'undelete' ) ) {
|
2009-05-28 17:15:58 +00:00
|
|
|
$msg = 'thisisdeleted';
|
|
|
|
|
} else {
|
|
|
|
|
$msg = 'viewdeleted';
|
|
|
|
|
}
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2011-10-21 20:09:27 +00:00
|
|
|
return $this->msg( $msg )->rawParams(
|
2011-07-24 17:05:42 +00:00
|
|
|
Linker::linkKnown(
|
2011-04-03 12:46:36 +00:00
|
|
|
SpecialPage::getTitleFor( 'Undelete', $this->getTitle()->getPrefixedDBkey() ),
|
2011-10-21 20:09:27 +00:00
|
|
|
$this->msg( 'restorelink' )->numParams( $n )->escaped() )
|
|
|
|
|
)->text();
|
2005-08-07 14:10:17 +00:00
|
|
|
}
|
2004-06-01 03:41:00 +00:00
|
|
|
}
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2004-06-09 01:18:04 +00:00
|
|
|
return '';
|
2004-06-01 03:41:00 +00:00
|
|
|
}
|
2004-07-16 20:50:16 +00:00
|
|
|
|
2011-11-29 21:04:20 +00:00
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2011-05-04 10:43:40 +00:00
|
|
|
function subPageSubtitle() {
|
2011-07-18 20:52:22 +00:00
|
|
|
$out = $this->getOutput();
|
2004-04-28 15:07:28 +00:00
|
|
|
$subpages = '';
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2011-03-03 10:22:46 +00:00
|
|
|
if ( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages, $this, $out ) ) ) {
|
2008-05-21 20:07:10 +00:00
|
|
|
return $subpages;
|
2010-02-01 13:52:55 +00:00
|
|
|
}
|
2008-01-29 15:05:48 +00:00
|
|
|
|
2011-03-03 10:22:46 +00:00
|
|
|
if ( $out->isArticle() && MWNamespace::hasSubpages( $out->getTitle()->getNamespace() ) ) {
|
2011-04-03 12:46:36 +00:00
|
|
|
$ptext = $this->getTitle()->getPrefixedText();
|
2010-09-04 13:48:16 +00:00
|
|
|
if ( preg_match( '/\//', $ptext ) ) {
|
2009-03-29 12:46:11 +00:00
|
|
|
$links = explode( '/', $ptext );
|
2008-04-20 18:53:46 +00:00
|
|
|
array_pop( $links );
|
2004-06-09 01:18:04 +00:00
|
|
|
$c = 0;
|
|
|
|
|
$growinglink = '';
|
2008-04-20 18:53:46 +00:00
|
|
|
$display = '';
|
2014-05-26 19:09:25 +00:00
|
|
|
$lang = $this->getLanguage();
|
2010-09-04 13:48:16 +00:00
|
|
|
|
|
|
|
|
foreach ( $links as $link ) {
|
2008-04-20 18:53:46 +00:00
|
|
|
$growinglink .= $link;
|
|
|
|
|
$display .= $link;
|
|
|
|
|
$linkObj = Title::newFromText( $growinglink );
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2012-05-30 21:06:26 +00:00
|
|
|
if ( is_object( $linkObj ) && $linkObj->isKnown() ) {
|
2011-07-24 17:05:42 +00:00
|
|
|
$getlink = Linker::linkKnown(
|
2009-06-07 15:02:12 +00:00
|
|
|
$linkObj,
|
2011-07-24 17:05:42 +00:00
|
|
|
htmlspecialchars( $display )
|
2009-06-07 15:02:12 +00:00
|
|
|
);
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2008-04-20 18:53:46 +00:00
|
|
|
$c++;
|
2010-09-04 13:48:16 +00:00
|
|
|
|
|
|
|
|
if ( $c > 1 ) {
|
2014-05-26 19:09:25 +00:00
|
|
|
$subpages .= $lang->getDirMarkEntity() . $this->msg( 'pipe-separator' )->escaped();
|
2013-04-20 22:49:30 +00:00
|
|
|
} else {
|
2004-06-09 01:18:04 +00:00
|
|
|
$subpages .= '< ';
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2004-04-28 15:07:28 +00:00
|
|
|
$subpages .= $getlink;
|
2008-04-20 18:53:46 +00:00
|
|
|
$display = '';
|
|
|
|
|
} else {
|
|
|
|
|
$display .= '/';
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2008-04-20 18:53:46 +00:00
|
|
|
$growinglink .= '/';
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2004-04-28 15:07:28 +00:00
|
|
|
return $subpages;
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2007-02-05 21:42:48 +00:00
|
|
|
/**
|
|
|
|
|
* Returns true if the IP should be shown in the header
|
2014-04-23 09:46:22 +00:00
|
|
|
* @return bool
|
2007-02-05 21:42:48 +00:00
|
|
|
*/
|
|
|
|
|
function showIPinHeader() {
|
|
|
|
|
global $wgShowIPinHeader;
|
|
|
|
|
return $wgShowIPinHeader && session_id() != '';
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-29 21:04:20 +00:00
|
|
|
/**
|
2014-04-23 09:46:22 +00:00
|
|
|
* @return string
|
2011-11-29 21:04:20 +00:00
|
|
|
*/
|
2004-04-24 06:25:19 +00:00
|
|
|
function getSearchLink() {
|
2006-11-29 05:45:03 +00:00
|
|
|
$searchPage = SpecialPage::getTitleFor( 'Search' );
|
2004-04-24 06:25:19 +00:00
|
|
|
return $searchPage->getLocalURL();
|
|
|
|
|
}
|
2004-07-16 20:50:16 +00:00
|
|
|
|
2011-11-29 21:04:20 +00:00
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2004-04-24 06:25:19 +00:00
|
|
|
function escapeSearchLink() {
|
|
|
|
|
return htmlspecialchars( $this->getSearchLink() );
|
|
|
|
|
}
|
2004-07-16 20:50:16 +00:00
|
|
|
|
2011-11-29 21:04:20 +00:00
|
|
|
/**
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param string $type
|
2011-11-29 21:04:20 +00:00
|
|
|
* @return string
|
|
|
|
|
*/
|
2006-03-16 02:47:49 +00:00
|
|
|
function getCopyright( $type = 'detect' ) {
|
2011-09-21 09:03:53 +00:00
|
|
|
global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgContLang;
|
2004-07-16 20:50:16 +00:00
|
|
|
|
2006-03-16 02:47:49 +00:00
|
|
|
if ( $type == 'detect' ) {
|
2014-05-11 15:33:33 +00:00
|
|
|
if ( !$this->isRevisionCurrent()
|
|
|
|
|
&& !$this->msg( 'history_copyright' )->inContentLanguage()->isDisabled()
|
|
|
|
|
) {
|
2006-03-16 02:47:49 +00:00
|
|
|
$type = 'history';
|
|
|
|
|
} else {
|
|
|
|
|
$type = 'normal';
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-07-16 20:50:16 +00:00
|
|
|
|
2006-03-16 02:47:49 +00:00
|
|
|
if ( $type == 'history' ) {
|
2004-06-21 07:55:16 +00:00
|
|
|
$msg = 'history_copyright';
|
|
|
|
|
} else {
|
|
|
|
|
$msg = 'copyright';
|
|
|
|
|
}
|
2004-07-16 20:50:16 +00:00
|
|
|
|
2010-09-04 13:48:16 +00:00
|
|
|
if ( $wgRightsPage ) {
|
2009-06-13 12:24:43 +00:00
|
|
|
$title = Title::newFromText( $wgRightsPage );
|
2011-04-16 20:01:39 +00:00
|
|
|
$link = Linker::linkKnown( $title, $wgRightsText );
|
2010-09-04 13:48:16 +00:00
|
|
|
} elseif ( $wgRightsUrl ) {
|
2011-04-16 20:01:39 +00:00
|
|
|
$link = Linker::makeExternalLink( $wgRightsUrl, $wgRightsText );
|
2010-09-04 13:48:16 +00:00
|
|
|
} elseif ( $wgRightsText ) {
|
2008-09-10 02:43:46 +00:00
|
|
|
$link = $wgRightsText;
|
2004-04-11 01:25:00 +00:00
|
|
|
} else {
|
|
|
|
|
# Give up now
|
2011-07-28 20:42:56 +00:00
|
|
|
return '';
|
2004-04-11 01:25:00 +00:00
|
|
|
}
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2009-06-24 16:49:28 +00:00
|
|
|
// Allow for site and per-namespace customization of copyright notice.
|
2014-03-24 22:57:59 +00:00
|
|
|
// @todo Remove deprecated $forContent param from hook handlers and then remove here.
|
2010-07-21 16:01:10 +00:00
|
|
|
$forContent = true;
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2014-05-11 15:33:33 +00:00
|
|
|
wfRunHooks(
|
|
|
|
|
'SkinCopyrightFooter',
|
|
|
|
|
array( $this->getTitle(), $type, &$msg, &$link, &$forContent )
|
|
|
|
|
);
|
here it is ... the upload-api, script-server, js2 (javascript phase2) branch merge 1st attempt.
Here is a short overview of changes and associated default configuration variables (most everything is off by default) also see ~soon to be updated~: http://www.mediawiki.org/wiki/Media_Projects_Overview
= Upload Improvements =
==Upload API ==
* Based on the early work of Bryan Tong and others it adds the upload option to the api.
* We rewrite Special:Upload page to include use the new refactoring
* Added in token checks in both the SpecialUpload.php page so avoids DOS / xss copy-by-url JavaScript based cross site POST file submissions
== Copy by URL==
$wgAllowCopyUploads = false;
* http class rewrite includes a new http background download see: includes/HttpFunctions.php
* spins off a php process that calls: maintenance/http_session_download.php
* pushes updates to the session and gives the user a progress bar on http copy uploads from other server progress (using js2 upload interface) (if not using the js2 upload interface it does the request in-place but the download is limited to the php ini timeout time)
== Firefogg ==
* Firefogg enables resumable upload by chunks
* progress indicators and conditional invokation (js2 system)
* and of-course client side transcoding.
= Script Server =
$wgEnableScriptLoader = false;
* off by default if $wgEnableScriptLoader is turned on script files are grouped, gziped, cached etc.
for more info see: http://www.mediawiki.org/wiki/Extension:ScriptLoader
* Includes some early skin js include fixes (skin/script system still lots of love)
* Includes a "javascript class autoloader" this is packaged into mwEmbed so that the mwEmbed library can work in stand alone mode (while retaining localization and script serving) (one such application is the make page for firefogg.org : http://www.firefogg.org/make/index.html )
* The file that contains the autojavascript loading classes is: js2/php/jsAutoloadLocalClasses.php
* One can use this auto class loading dependency system with extensions and add-ons but I need to better document that.
= js2 system / mwEmbed=
$wgEnableJS2system = false
* includes initial rewrite towards more jquery based javascript code
* especially for the Special:Upload page.
* Also the edit page include support for the "add-media-wizard"
* includes dependency loader for javascript that optionally takes advantage of the script-loader
* remote embedding of javascript interfaces (like embedding video, or commons media searching)
* $wgDebugJavaScript = false; .. .this variable lets you always get "always fresh javascript". When used with the script-loader it does not minify the script-loader output.
= mwEmbed =
* Will commit a separate patch to oggHandler that conditionally outputs <video tag> to use the new javascript video player.
** mv_embed player includes: play-head, volume control, remote embedding, oggz-chop support across plugins.
* add-media-wizard adds easy inserts of media to pages (with import)
== jQuery==
* we include a base install of jQuery, jQuery ui and some plugins.
* all the javascript classes are in the scriptloader so its easy to load any set of jquery ui components that you may need using the script-server. You get a callback so you can then execute js with dependencies loaded.
== other stuff ==
there is a bit more code in js2 that pertains to sequence editing, timed text display and basic image editing. We include a base import of pixastic-lib & pixastic-editor... will work with the pixastic developer to try and ensure upstream compatibility on our usage of the library for in-browser photo and sequence manipulation.
2009-07-14 23:52:14 +00:00
|
|
|
|
2014-03-24 22:57:59 +00:00
|
|
|
return $this->msg( $msg )->rawParams( $link )->text();
|
2004-04-11 01:25:00 +00:00
|
|
|
}
|
2004-07-16 20:50:16 +00:00
|
|
|
|
2011-11-29 21:04:20 +00:00
|
|
|
/**
|
|
|
|
|
* @return null|string
|
|
|
|
|
*/
|
2004-04-11 01:25:00 +00:00
|
|
|
function getCopyrightIcon() {
|
2006-03-07 01:10:39 +00:00
|
|
|
global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2004-06-09 01:18:04 +00:00
|
|
|
$out = '';
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2004-12-28 22:02:19 +00:00
|
|
|
if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
|
|
|
|
|
$out = $wgCopyrightIcon;
|
2010-02-01 13:52:55 +00:00
|
|
|
} elseif ( $wgRightsIcon ) {
|
2004-04-11 01:25:00 +00:00
|
|
|
$icon = htmlspecialchars( $wgRightsIcon );
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2004-12-28 22:02:19 +00:00
|
|
|
if ( $wgRightsUrl ) {
|
2004-04-11 01:25:00 +00:00
|
|
|
$url = htmlspecialchars( $wgRightsUrl );
|
2010-09-04 13:48:16 +00:00
|
|
|
$out .= '<a href="' . $url . '">';
|
2004-04-11 01:25:00 +00:00
|
|
|
}
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2004-04-11 01:25:00 +00:00
|
|
|
$text = htmlspecialchars( $wgRightsText );
|
2009-08-13 01:03:48 +00:00
|
|
|
$out .= "<img src=\"$icon\" alt=\"$text\" width=\"88\" height=\"31\" />";
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2004-12-28 22:02:19 +00:00
|
|
|
if ( $wgRightsUrl ) {
|
2004-06-09 01:18:04 +00:00
|
|
|
$out .= '</a>';
|
2004-04-11 01:25:00 +00:00
|
|
|
}
|
|
|
|
|
}
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2004-04-11 01:25:00 +00:00
|
|
|
return $out;
|
|
|
|
|
}
|
2004-07-16 20:50:16 +00:00
|
|
|
|
2010-02-01 13:52:55 +00:00
|
|
|
/**
|
|
|
|
|
* Gets the powered by MediaWiki icon.
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2004-04-11 01:25:00 +00:00
|
|
|
function getPoweredBy() {
|
2010-11-14 19:45:55 +00:00
|
|
|
global $wgStylePath;
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2004-09-05 03:25:58 +00:00
|
|
|
$url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
|
2014-05-11 15:33:33 +00:00
|
|
|
$text = '<a href="//www.mediawiki.org/"><img src="' . $url
|
|
|
|
|
. '" height="31" width="88" alt="Powered by MediaWiki" /></a>';
|
2011-06-17 16:05:05 +00:00
|
|
|
wfRunHooks( 'SkinGetPoweredBy', array( &$text, $this ) );
|
2010-11-10 08:18:21 +00:00
|
|
|
return $text;
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2011-01-26 17:06:18 +00:00
|
|
|
/**
|
|
|
|
|
* Get the timestamp of the latest revision, formatted in user language
|
|
|
|
|
*
|
2014-04-23 09:46:22 +00:00
|
|
|
* @return string
|
2011-01-26 17:06:18 +00:00
|
|
|
*/
|
2011-12-10 16:30:40 +00:00
|
|
|
protected function lastModified() {
|
|
|
|
|
$timestamp = $this->getOutput()->getRevisionTimestamp();
|
|
|
|
|
|
|
|
|
|
# No cached timestamp, load it from the database
|
|
|
|
|
if ( $timestamp === null ) {
|
2011-05-02 15:26:19 +00:00
|
|
|
$timestamp = Revision::getTimestampFromId( $this->getTitle(), $this->getRevisionId() );
|
2008-07-06 11:01:32 +00:00
|
|
|
}
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2004-04-01 12:46:31 +00:00
|
|
|
if ( $timestamp ) {
|
2011-11-21 16:13:21 +00:00
|
|
|
$d = $this->getLanguage()->userDate( $timestamp, $this->getUser() );
|
|
|
|
|
$t = $this->getLanguage()->userTime( $timestamp, $this->getUser() );
|
2011-10-21 20:09:27 +00:00
|
|
|
$s = ' ' . $this->msg( 'lastmodifiedat', $d, $t )->text();
|
2004-04-01 12:46:31 +00:00
|
|
|
} else {
|
2004-06-09 01:18:04 +00:00
|
|
|
$s = '';
|
2004-04-01 12:46:31 +00:00
|
|
|
}
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2008-03-30 09:48:15 +00:00
|
|
|
if ( wfGetLB()->getLaggedSlaveMode() ) {
|
2011-10-21 20:09:27 +00:00
|
|
|
$s .= ' <strong>' . $this->msg( 'laggedslavemode' )->text() . '</strong>';
|
2005-01-15 10:40:46 +00:00
|
|
|
}
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2003-04-14 23:10:40 +00:00
|
|
|
return $s;
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-29 21:04:20 +00:00
|
|
|
/**
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param string $align
|
2011-11-29 21:04:20 +00:00
|
|
|
* @return string
|
|
|
|
|
*/
|
2004-09-02 00:25:56 +00:00
|
|
|
function logoText( $align = '' ) {
|
2010-01-06 19:59:42 +00:00
|
|
|
if ( $align != '' ) {
|
2012-08-27 19:41:00 +00:00
|
|
|
$a = " style='float: {$align};'";
|
2009-03-29 12:46:11 +00:00
|
|
|
} else {
|
|
|
|
|
$a = '';
|
|
|
|
|
}
|
2004-07-16 20:50:16 +00:00
|
|
|
|
2011-10-21 20:09:27 +00:00
|
|
|
$mp = $this->msg( 'mainpage' )->escaped();
|
2006-12-03 00:22:14 +00:00
|
|
|
$mptitle = Title::newMainPage();
|
2011-12-13 04:04:52 +00:00
|
|
|
$url = ( is_object( $mptitle ) ? htmlspecialchars( $mptitle->getLocalURL() ) : '' );
|
2004-08-21 11:40:18 +00:00
|
|
|
|
2004-08-22 08:51:28 +00:00
|
|
|
$logourl = $this->getLogo();
|
|
|
|
|
$s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2003-04-14 23:10:40 +00:00
|
|
|
return $s;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-05 04:44:28 +00:00
|
|
|
/**
|
2013-03-13 07:42:41 +00:00
|
|
|
* Renders a $wgFooterIcons icon according to the method's arguments
|
2014-05-11 15:33:33 +00:00
|
|
|
* @param array $icon The icon to build the html for, see $wgFooterIcons
|
|
|
|
|
* for the format of this array.
|
|
|
|
|
* @param bool|string $withImage Whether to use the icon's image or output
|
|
|
|
|
* a text-only footericon.
|
2014-04-23 09:46:22 +00:00
|
|
|
* @return string HTML
|
2010-12-05 04:44:28 +00:00
|
|
|
*/
|
2010-12-05 10:41:58 +00:00
|
|
|
function makeFooterIcon( $icon, $withImage = 'withImage' ) {
|
|
|
|
|
if ( is_string( $icon ) ) {
|
2010-12-05 04:44:28 +00:00
|
|
|
$html = $icon;
|
2010-12-05 10:41:58 +00:00
|
|
|
} else { // Assuming array
|
2013-02-03 20:05:24 +00:00
|
|
|
$url = isset( $icon["url"] ) ? $icon["url"] : null;
|
2010-12-05 10:41:58 +00:00
|
|
|
unset( $icon["url"] );
|
|
|
|
|
if ( isset( $icon["src"] ) && $withImage === 'withImage' ) {
|
2014-05-11 15:33:33 +00:00
|
|
|
// do this the lazy way, just pass icon data as an attribute array
|
|
|
|
|
$html = Html::element( 'img', $icon );
|
2010-12-05 04:44:28 +00:00
|
|
|
} else {
|
2010-12-05 10:41:58 +00:00
|
|
|
$html = htmlspecialchars( $icon["alt"] );
|
2010-12-05 04:44:28 +00:00
|
|
|
}
|
|
|
|
|
if ( $url ) {
|
|
|
|
|
$html = Html::rawElement( 'a', array( "href" => $url ), $html );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $html;
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-01 13:52:55 +00:00
|
|
|
/**
|
|
|
|
|
* Gets the link to the wiki's main page.
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2004-09-02 00:25:56 +00:00
|
|
|
function mainPageLink() {
|
2011-07-24 17:37:00 +00:00
|
|
|
$s = Linker::linkKnown(
|
2009-06-07 15:02:12 +00:00
|
|
|
Title::newMainPage(),
|
2011-10-21 20:09:27 +00:00
|
|
|
$this->msg( 'mainpage' )->escaped()
|
2009-06-07 15:02:12 +00:00
|
|
|
);
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2003-04-14 23:10:40 +00:00
|
|
|
return $s;
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-29 21:04:20 +00:00
|
|
|
/**
|
2014-03-24 19:58:53 +00:00
|
|
|
* Returns an HTML link for use in the footer
|
|
|
|
|
* @param string $desc i18n message key for the link text
|
|
|
|
|
* @param string $page i18n message key for the page to link to
|
|
|
|
|
* @return string HTML anchor
|
2011-11-29 21:04:20 +00:00
|
|
|
*/
|
2010-12-05 11:01:34 +00:00
|
|
|
public function footerLink( $desc, $page ) {
|
2007-02-16 03:43:40 +00:00
|
|
|
// if the link description has been set to "-" in the default language,
|
2011-10-21 20:09:27 +00:00
|
|
|
if ( $this->msg( $desc )->inContentLanguage()->isDisabled() ) {
|
2007-02-16 03:43:40 +00:00
|
|
|
// then it is disabled, for all languages.
|
2005-11-29 20:25:20 +00:00
|
|
|
return '';
|
|
|
|
|
} else {
|
2007-02-16 03:43:40 +00:00
|
|
|
// Otherwise, we display the link for the user, described in their
|
|
|
|
|
// language (which may or may not be the same as the default language),
|
|
|
|
|
// but we make the link target be the one site-wide page.
|
2011-10-21 20:09:27 +00:00
|
|
|
$title = Title::newFromText( $this->msg( $page )->inContentLanguage()->text() );
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2011-04-16 20:01:39 +00:00
|
|
|
return Linker::linkKnown(
|
2009-06-13 12:24:43 +00:00
|
|
|
$title,
|
2011-10-21 20:09:27 +00:00
|
|
|
$this->msg( $desc )->escaped()
|
2009-06-13 12:24:43 +00:00
|
|
|
);
|
2005-11-29 20:25:20 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-01 13:52:55 +00:00
|
|
|
/**
|
|
|
|
|
* Gets the link to the wiki's privacy policy page.
|
2014-04-23 09:46:22 +00:00
|
|
|
* @return string HTML
|
2010-02-01 13:52:55 +00:00
|
|
|
*/
|
2007-02-16 03:43:40 +00:00
|
|
|
function privacyLink() {
|
|
|
|
|
return $this->footerLink( 'privacy', 'privacypage' );
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-01 13:52:55 +00:00
|
|
|
/**
|
|
|
|
|
* Gets the link to the wiki's about page.
|
2014-04-23 09:46:22 +00:00
|
|
|
* @return string HTML
|
2010-02-01 13:52:55 +00:00
|
|
|
*/
|
2004-09-02 00:25:56 +00:00
|
|
|
function aboutLink() {
|
2007-02-16 03:43:40 +00:00
|
|
|
return $this->footerLink( 'aboutsite', 'aboutpage' );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2010-02-01 13:52:55 +00:00
|
|
|
/**
|
|
|
|
|
* Gets the link to the wiki's general disclaimers page.
|
2014-04-23 09:46:22 +00:00
|
|
|
* @return string HTML
|
2010-02-01 13:52:55 +00:00
|
|
|
*/
|
2004-09-02 00:25:56 +00:00
|
|
|
function disclaimerLink() {
|
2007-02-16 03:43:40 +00:00
|
|
|
return $this->footerLink( 'disclaimers', 'disclaimerpage' );
|
2004-01-06 06:00:01 +00:00
|
|
|
}
|
|
|
|
|
|
2005-12-01 09:47:44 +00:00
|
|
|
/**
|
|
|
|
|
* Return URL options for the 'edit page' link.
|
|
|
|
|
* This may include an 'oldid' specifier, if the current page view is such.
|
|
|
|
|
*
|
2009-06-07 15:02:12 +00:00
|
|
|
* @return array
|
2006-04-19 15:46:24 +00:00
|
|
|
* @private
|
2005-12-01 09:47:44 +00:00
|
|
|
*/
|
|
|
|
|
function editUrlOptions() {
|
here it is ... the upload-api, script-server, js2 (javascript phase2) branch merge 1st attempt.
Here is a short overview of changes and associated default configuration variables (most everything is off by default) also see ~soon to be updated~: http://www.mediawiki.org/wiki/Media_Projects_Overview
= Upload Improvements =
==Upload API ==
* Based on the early work of Bryan Tong and others it adds the upload option to the api.
* We rewrite Special:Upload page to include use the new refactoring
* Added in token checks in both the SpecialUpload.php page so avoids DOS / xss copy-by-url JavaScript based cross site POST file submissions
== Copy by URL==
$wgAllowCopyUploads = false;
* http class rewrite includes a new http background download see: includes/HttpFunctions.php
* spins off a php process that calls: maintenance/http_session_download.php
* pushes updates to the session and gives the user a progress bar on http copy uploads from other server progress (using js2 upload interface) (if not using the js2 upload interface it does the request in-place but the download is limited to the php ini timeout time)
== Firefogg ==
* Firefogg enables resumable upload by chunks
* progress indicators and conditional invokation (js2 system)
* and of-course client side transcoding.
= Script Server =
$wgEnableScriptLoader = false;
* off by default if $wgEnableScriptLoader is turned on script files are grouped, gziped, cached etc.
for more info see: http://www.mediawiki.org/wiki/Extension:ScriptLoader
* Includes some early skin js include fixes (skin/script system still lots of love)
* Includes a "javascript class autoloader" this is packaged into mwEmbed so that the mwEmbed library can work in stand alone mode (while retaining localization and script serving) (one such application is the make page for firefogg.org : http://www.firefogg.org/make/index.html )
* The file that contains the autojavascript loading classes is: js2/php/jsAutoloadLocalClasses.php
* One can use this auto class loading dependency system with extensions and add-ons but I need to better document that.
= js2 system / mwEmbed=
$wgEnableJS2system = false
* includes initial rewrite towards more jquery based javascript code
* especially for the Special:Upload page.
* Also the edit page include support for the "add-media-wizard"
* includes dependency loader for javascript that optionally takes advantage of the script-loader
* remote embedding of javascript interfaces (like embedding video, or commons media searching)
* $wgDebugJavaScript = false; .. .this variable lets you always get "always fresh javascript". When used with the script-loader it does not minify the script-loader output.
= mwEmbed =
* Will commit a separate patch to oggHandler that conditionally outputs <video tag> to use the new javascript video player.
** mv_embed player includes: play-head, volume control, remote embedding, oggz-chop support across plugins.
* add-media-wizard adds easy inserts of media to pages (with import)
== jQuery==
* we include a base install of jQuery, jQuery ui and some plugins.
* all the javascript classes are in the scriptloader so its easy to load any set of jquery ui components that you may need using the script-server. You get a callback so you can then execute js with dependencies loaded.
== other stuff ==
there is a bit more code in js2 that pertains to sequence editing, timed text display and basic image editing. We include a base import of pixastic-lib & pixastic-editor... will work with the pixastic developer to try and ensure upstream compatibility on our usage of the library for in-browser photo and sequence manipulation.
2009-07-14 23:52:14 +00:00
|
|
|
$options = array( 'action' => 'edit' );
|
2009-06-07 15:02:12 +00:00
|
|
|
|
2011-01-11 13:04:55 +00:00
|
|
|
if ( !$this->isRevisionCurrent() ) {
|
2011-05-02 15:26:19 +00:00
|
|
|
$options['oldid'] = intval( $this->getRevisionId() );
|
2005-12-01 09:47:44 +00:00
|
|
|
}
|
2009-06-07 15:02:12 +00:00
|
|
|
|
|
|
|
|
return $options;
|
2005-12-01 09:47:44 +00:00
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2011-11-29 21:04:20 +00:00
|
|
|
/**
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param User|int $id
|
2011-11-29 21:04:20 +00:00
|
|
|
* @return bool
|
|
|
|
|
*/
|
2004-11-25 06:20:01 +00:00
|
|
|
function showEmailUser( $id ) {
|
2011-11-01 16:09:27 +00:00
|
|
|
if ( $id instanceof User ) {
|
|
|
|
|
$targetUser = $id;
|
|
|
|
|
} else {
|
|
|
|
|
$targetUser = User::newFromId( $id );
|
|
|
|
|
}
|
2014-05-11 15:33:33 +00:00
|
|
|
|
|
|
|
|
# The sending user must have a confirmed email address and the target
|
|
|
|
|
# user must have a confirmed email address and allow emails from users.
|
|
|
|
|
return $this->getUser()->canSendEmail() &&
|
|
|
|
|
$targetUser->canReceiveEmail();
|
2004-11-25 06:20:01 +00:00
|
|
|
}
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2010-12-05 04:22:29 +00:00
|
|
|
/**
|
|
|
|
|
* Return a fully resolved style path url to images or styles stored in the common folder.
|
|
|
|
|
* This method returns a url resolved using the configured skin style path
|
|
|
|
|
* and includes the style version inside of the url.
|
2013-03-11 17:15:01 +00:00
|
|
|
* @param string $name The name or path of a skin resource file
|
2014-04-23 09:46:22 +00:00
|
|
|
* @return string The fully resolved style path url including styleversion
|
2010-12-05 04:22:29 +00:00
|
|
|
*/
|
2010-12-04 17:10:48 +00:00
|
|
|
function getCommonStylePath( $name ) {
|
2010-12-04 14:45:14 +00:00
|
|
|
global $wgStylePath, $wgStyleVersion;
|
2010-12-16 18:30:15 +00:00
|
|
|
return "$wgStylePath/common/$name?$wgStyleVersion";
|
2010-12-04 14:45:14 +00:00
|
|
|
}
|
|
|
|
|
|
2010-12-05 04:22:29 +00:00
|
|
|
/**
|
2013-03-13 07:42:41 +00:00
|
|
|
* Return a fully resolved style path url to images or styles stored in the current skins's folder.
|
2010-12-05 04:22:29 +00:00
|
|
|
* This method returns a url resolved using the configured skin style path
|
|
|
|
|
* and includes the style version inside of the url.
|
2014-05-31 12:49:24 +00:00
|
|
|
*
|
|
|
|
|
* Requires $stylename to be set, otherwise throws MWException.
|
|
|
|
|
*
|
2013-03-11 17:15:01 +00:00
|
|
|
* @param string $name The name or path of a skin resource file
|
2014-04-23 09:46:22 +00:00
|
|
|
* @return string The fully resolved style path url including styleversion
|
2010-12-05 04:22:29 +00:00
|
|
|
*/
|
2010-12-04 17:00:34 +00:00
|
|
|
function getSkinStylePath( $name ) {
|
2010-12-04 14:45:14 +00:00
|
|
|
global $wgStylePath, $wgStyleVersion;
|
2014-05-31 12:49:24 +00:00
|
|
|
|
|
|
|
|
if ( $this->stylename === null ) {
|
|
|
|
|
$class = get_class( $this );
|
|
|
|
|
throw new MWException( "$class::\$stylename must be set to use getSkinStylePath()" );
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-16 18:30:15 +00:00
|
|
|
return "$wgStylePath/{$this->stylename}/$name?$wgStyleVersion";
|
2010-12-04 14:45:14 +00:00
|
|
|
}
|
|
|
|
|
|
2006-02-18 04:34:10 +00:00
|
|
|
/* these are used extensively in SkinTemplate, but also some other places */
|
2011-11-29 21:04:20 +00:00
|
|
|
|
|
|
|
|
/**
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param string $urlaction
|
|
|
|
|
* @return string
|
2011-11-29 21:04:20 +00:00
|
|
|
*/
|
2006-12-03 00:22:14 +00:00
|
|
|
static function makeMainPageUrl( $urlaction = '' ) {
|
|
|
|
|
$title = Title::newMainPage();
|
2007-01-12 10:03:51 +00:00
|
|
|
self::checkTitle( $title, '' );
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2006-12-03 00:22:14 +00:00
|
|
|
return $title->getLocalURL( $urlaction );
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-29 21:04:20 +00:00
|
|
|
/**
|
2012-08-10 18:59:08 +00:00
|
|
|
* Make a URL for a Special Page using the given query and protocol.
|
|
|
|
|
*
|
|
|
|
|
* If $proto is set to null, make a local URL. Otherwise, make a full
|
|
|
|
|
* URL with the protocol specified.
|
|
|
|
|
*
|
2013-03-11 17:15:01 +00:00
|
|
|
* @param string $name Name of the Special page
|
|
|
|
|
* @param string $urlaction Query to append
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param string|null $proto Protocol to use or null for a local URL
|
|
|
|
|
* @return string
|
2011-11-29 21:04:20 +00:00
|
|
|
*/
|
2012-08-10 18:59:08 +00:00
|
|
|
static function makeSpecialUrl( $name, $urlaction = '', $proto = null ) {
|
2011-04-17 11:31:11 +00:00
|
|
|
$title = SpecialPage::getSafeTitleFor( $name );
|
2013-04-20 22:49:30 +00:00
|
|
|
if ( is_null( $proto ) ) {
|
2012-08-10 18:59:08 +00:00
|
|
|
return $title->getLocalURL( $urlaction );
|
|
|
|
|
} else {
|
|
|
|
|
return $title->getFullURL( $urlaction, false, $proto );
|
|
|
|
|
}
|
2004-05-05 12:01:54 +00:00
|
|
|
}
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2011-11-29 21:04:20 +00:00
|
|
|
/**
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param string $name
|
|
|
|
|
* @param string $subpage
|
|
|
|
|
* @param string $urlaction
|
|
|
|
|
* @return string
|
2011-11-29 21:04:20 +00:00
|
|
|
*/
|
2006-12-18 00:20:21 +00:00
|
|
|
static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
|
2006-12-18 00:46:36 +00:00
|
|
|
$title = SpecialPage::getSafeTitleFor( $name, $subpage );
|
2006-12-18 00:20:21 +00:00
|
|
|
return $title->getLocalURL( $urlaction );
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-29 21:04:20 +00:00
|
|
|
/**
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param string $name
|
|
|
|
|
* @param string $urlaction
|
|
|
|
|
* @return string
|
2011-11-29 21:04:20 +00:00
|
|
|
*/
|
2006-09-22 13:07:06 +00:00
|
|
|
static function makeI18nUrl( $name, $urlaction = '' ) {
|
2012-08-21 17:23:53 +00:00
|
|
|
$title = Title::newFromText( wfMessage( $name )->inContentLanguage()->text() );
|
2006-09-22 13:07:06 +00:00
|
|
|
self::checkTitle( $title, $name );
|
2004-05-05 12:01:54 +00:00
|
|
|
return $title->getLocalURL( $urlaction );
|
|
|
|
|
}
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2011-11-29 21:04:20 +00:00
|
|
|
/**
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param string $name
|
|
|
|
|
* @param string $urlaction
|
|
|
|
|
* @return string
|
2011-11-29 21:04:20 +00:00
|
|
|
*/
|
2006-09-22 13:07:06 +00:00
|
|
|
static function makeUrl( $name, $urlaction = '' ) {
|
2004-05-05 12:01:54 +00:00
|
|
|
$title = Title::newFromText( $name );
|
2006-09-22 13:07:06 +00:00
|
|
|
self::checkTitle( $title, $name );
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2004-07-16 20:50:16 +00:00
|
|
|
return $title->getLocalURL( $urlaction );
|
2004-05-05 12:01:54 +00:00
|
|
|
}
|
2004-09-26 09:45:35 +00:00
|
|
|
|
2010-02-01 13:52:55 +00:00
|
|
|
/**
|
|
|
|
|
* If url string starts with http, consider as external URL, else
|
|
|
|
|
* internal
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param string $name
|
|
|
|
|
* @return string URL
|
2010-02-01 13:52:55 +00:00
|
|
|
*/
|
2006-09-22 13:07:06 +00:00
|
|
|
static function makeInternalOrExternalUrl( $name ) {
|
2012-07-10 18:49:02 +00:00
|
|
|
if ( preg_match( '/^(?i:' . wfUrlProtocols() . ')/', $name ) ) {
|
2004-09-26 09:45:35 +00:00
|
|
|
return $name;
|
|
|
|
|
} else {
|
2006-09-22 13:07:06 +00:00
|
|
|
return self::makeUrl( $name );
|
2004-09-26 09:45:35 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-29 21:04:20 +00:00
|
|
|
/**
|
|
|
|
|
* this can be passed the NS number as defined in Language.php
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param string $name
|
|
|
|
|
* @param string $urlaction
|
|
|
|
|
* @param int $namespace
|
|
|
|
|
* @return string
|
2011-11-29 21:04:20 +00:00
|
|
|
*/
|
2006-09-22 13:07:06 +00:00
|
|
|
static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN ) {
|
2004-08-22 23:55:36 +00:00
|
|
|
$title = Title::makeTitleSafe( $namespace, $name );
|
2006-09-22 13:07:06 +00:00
|
|
|
self::checkTitle( $title, $name );
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2004-06-03 01:29:02 +00:00
|
|
|
return $title->getLocalURL( $urlaction );
|
|
|
|
|
}
|
2004-07-16 20:50:16 +00:00
|
|
|
|
2011-11-29 21:04:20 +00:00
|
|
|
/**
|
|
|
|
|
* these return an array with the 'href' and boolean 'exists'
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param string $name
|
|
|
|
|
* @param string $urlaction
|
2011-11-29 21:04:20 +00:00
|
|
|
* @return array
|
|
|
|
|
*/
|
2006-09-22 13:07:06 +00:00
|
|
|
static function makeUrlDetails( $name, $urlaction = '' ) {
|
2004-05-13 19:44:13 +00:00
|
|
|
$title = Title::newFromText( $name );
|
2006-09-22 13:07:06 +00:00
|
|
|
self::checkTitle( $title, $name );
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2004-07-16 20:50:16 +00:00
|
|
|
return array(
|
2004-05-13 19:44:13 +00:00
|
|
|
'href' => $title->getLocalURL( $urlaction ),
|
2010-09-27 15:59:58 +00:00
|
|
|
'exists' => $title->getArticleID() != 0,
|
2004-07-16 20:50:16 +00:00
|
|
|
);
|
2004-05-13 19:44:13 +00:00
|
|
|
}
|
2004-05-05 12:01:54 +00:00
|
|
|
|
2005-10-22 20:52:30 +00:00
|
|
|
/**
|
|
|
|
|
* Make URL details where the article exists (or at least it's convenient to think so)
|
2013-03-11 17:15:01 +00:00
|
|
|
* @param string $name Article name
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param string $urlaction
|
|
|
|
|
* @return array
|
2005-10-22 20:52:30 +00:00
|
|
|
*/
|
2006-09-22 13:07:06 +00:00
|
|
|
static function makeKnownUrlDetails( $name, $urlaction = '' ) {
|
2005-10-22 20:52:30 +00:00
|
|
|
$title = Title::newFromText( $name );
|
2006-09-22 13:07:06 +00:00
|
|
|
self::checkTitle( $title, $name );
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2005-10-22 20:52:30 +00:00
|
|
|
return array(
|
|
|
|
|
'href' => $title->getLocalURL( $urlaction ),
|
|
|
|
|
'exists' => true
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-29 21:04:20 +00:00
|
|
|
/**
|
|
|
|
|
* make sure we have some title to operate on
|
|
|
|
|
*
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param Title $title
|
|
|
|
|
* @param string $name
|
2011-11-29 21:04:20 +00:00
|
|
|
*/
|
2007-01-12 10:03:51 +00:00
|
|
|
static function checkTitle( &$title, $name ) {
|
2010-09-04 13:48:16 +00:00
|
|
|
if ( !is_object( $title ) ) {
|
2004-05-05 12:01:54 +00:00
|
|
|
$title = Title::newFromText( $name );
|
2010-09-04 13:48:16 +00:00
|
|
|
if ( !is_object( $title ) ) {
|
2004-06-24 21:33:43 +00:00
|
|
|
$title = Title::newFromText( '--error: link target missing--' );
|
2004-05-05 12:01:54 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-06-28 14:18:08 +00:00
|
|
|
/**
|
2012-10-22 18:59:44 +00:00
|
|
|
* Build an array that represents the sidebar(s), the navigation bar among them.
|
|
|
|
|
*
|
|
|
|
|
* BaseTemplate::getSidebar can be used to simplify the format and id generation in new skins.
|
|
|
|
|
*
|
|
|
|
|
* The format of the returned array is array( heading => content, ... ), where:
|
|
|
|
|
* - heading is the heading of a navigation portlet. It is either:
|
|
|
|
|
* - magic string to be handled by the skins ('SEARCH' / 'LANGUAGES' / 'TOOLBOX' / ...)
|
|
|
|
|
* - a message name (e.g. 'navigation'), the message should be HTML-escaped by the skin
|
|
|
|
|
* - plain text, which should be HTML-escaped by the skin
|
|
|
|
|
* - content is the contents of the portlet. It is either:
|
|
|
|
|
* - HTML text (<ul><li>...</li>...</ul>)
|
|
|
|
|
* - array of link data in a format accepted by BaseTemplate::makeListItem()
|
|
|
|
|
* - (for a magic string as a key, any value)
|
|
|
|
|
*
|
|
|
|
|
* Note that extensions can control the sidebar contents using the SkinBuildSidebar hook
|
|
|
|
|
* and can technically insert anything in here; skin creators are expected to handle
|
|
|
|
|
* values described above.
|
2005-06-28 14:18:08 +00:00
|
|
|
*
|
|
|
|
|
* @return array
|
2005-07-03 04:00:33 +00:00
|
|
|
*/
|
2005-06-28 14:18:08 +00:00
|
|
|
function buildSidebar() {
|
2012-02-07 16:49:34 +00:00
|
|
|
global $wgMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
|
2008-06-03 20:24:00 +00:00
|
|
|
wfProfileIn( __METHOD__ );
|
2005-07-03 04:00:33 +00:00
|
|
|
|
2011-11-21 16:13:21 +00:00
|
|
|
$key = wfMemcKey( 'sidebar', $this->getLanguage()->getCode() );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-06-03 20:24:00 +00:00
|
|
|
if ( $wgEnableSidebarCache ) {
|
2012-02-07 16:49:34 +00:00
|
|
|
$cachedsidebar = $wgMemc->get( $key );
|
2008-06-03 20:24:00 +00:00
|
|
|
if ( $cachedsidebar ) {
|
2014-05-09 11:57:16 +00:00
|
|
|
wfRunHooks( 'SidebarBeforeOutput', array( $this, &$cachedsidebar ) );
|
|
|
|
|
|
2008-06-03 20:24:00 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2006-01-14 22:13:43 +00:00
|
|
|
return $cachedsidebar;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-06-28 14:18:08 +00:00
|
|
|
$bar = array();
|
2010-06-29 06:39:32 +00:00
|
|
|
$this->addToSidebar( $bar, 'sidebar' );
|
2009-11-18 21:06:54 +00:00
|
|
|
|
|
|
|
|
wfRunHooks( 'SkinBuildSidebar', array( $this, &$bar ) );
|
2010-02-01 13:52:55 +00:00
|
|
|
if ( $wgEnableSidebarCache ) {
|
2012-02-07 16:49:34 +00:00
|
|
|
$wgMemc->set( $key, $bar, $wgSidebarCacheExpiry );
|
2010-02-01 13:52:55 +00:00
|
|
|
}
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2014-05-09 11:57:16 +00:00
|
|
|
wfRunHooks( 'SidebarBeforeOutput', array( $this, &$bar ) );
|
|
|
|
|
|
2009-11-18 21:06:54 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
|
|
|
|
return $bar;
|
|
|
|
|
}
|
2014-03-15 19:57:00 +00:00
|
|
|
|
2010-06-29 06:39:32 +00:00
|
|
|
/**
|
|
|
|
|
* Add content from a sidebar system message
|
|
|
|
|
* Currently only used for MediaWiki:Sidebar (but may be used by Extensions)
|
|
|
|
|
*
|
|
|
|
|
* This is just a wrapper around addToSidebarPlain() for backwards compatibility
|
2010-09-04 01:06:34 +00:00
|
|
|
*
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param array $bar
|
|
|
|
|
* @param string $message
|
2010-06-29 06:39:32 +00:00
|
|
|
*/
|
|
|
|
|
function addToSidebar( &$bar, $message ) {
|
2012-08-21 17:23:53 +00:00
|
|
|
$this->addToSidebarPlain( $bar, wfMessage( $message )->inContentLanguage()->plain() );
|
2010-06-29 06:39:32 +00:00
|
|
|
}
|
2010-09-04 01:06:34 +00:00
|
|
|
|
2010-02-25 15:58:29 +00:00
|
|
|
/**
|
2010-06-29 06:39:32 +00:00
|
|
|
* Add content from plain text
|
|
|
|
|
* @since 1.17
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param array $bar
|
|
|
|
|
* @param string $text
|
|
|
|
|
* @return array
|
2010-02-25 15:58:29 +00:00
|
|
|
*/
|
2010-06-29 06:39:32 +00:00
|
|
|
function addToSidebarPlain( &$bar, $text ) {
|
2010-02-25 15:58:29 +00:00
|
|
|
$lines = explode( "\n", $text );
|
2010-05-27 16:56:34 +00:00
|
|
|
|
2008-01-24 20:14:35 +00:00
|
|
|
$heading = '';
|
2010-09-04 13:48:16 +00:00
|
|
|
|
|
|
|
|
foreach ( $lines as $line ) {
|
|
|
|
|
if ( strpos( $line, '*' ) !== 0 ) {
|
2005-06-28 14:18:08 +00:00
|
|
|
continue;
|
2010-02-01 13:52:55 +00:00
|
|
|
}
|
2011-08-07 08:08:36 +00:00
|
|
|
$line = rtrim( $line, "\r" ); // for Windows compat
|
2010-09-04 13:48:16 +00:00
|
|
|
|
|
|
|
|
if ( strpos( $line, '**' ) !== 0 ) {
|
2009-04-09 05:27:25 +00:00
|
|
|
$heading = trim( $line, '* ' );
|
2010-09-04 13:48:16 +00:00
|
|
|
if ( !array_key_exists( $heading, $bar ) ) {
|
2010-02-01 13:52:55 +00:00
|
|
|
$bar[$heading] = array();
|
|
|
|
|
}
|
2005-06-28 14:18:08 +00:00
|
|
|
} else {
|
2010-05-27 16:56:34 +00:00
|
|
|
$line = trim( $line, '* ' );
|
2010-09-04 13:48:16 +00:00
|
|
|
|
|
|
|
|
if ( strpos( $line, '|' ) !== false ) { // sanity check
|
2011-04-03 12:46:36 +00:00
|
|
|
$line = MessageCache::singleton()->transform( $line, false, null, $this->getTitle() );
|
2010-05-27 19:38:27 +00:00
|
|
|
$line = array_map( 'trim', explode( '|', $line, 2 ) );
|
2012-01-05 15:34:26 +00:00
|
|
|
if ( count( $line ) !== 2 ) {
|
|
|
|
|
// Second sanity check, could be hit by people doing
|
2012-01-07 15:43:21 +00:00
|
|
|
// funky stuff with parserfuncs... (bug 33321)
|
2012-01-05 15:34:26 +00:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-26 19:52:11 +00:00
|
|
|
$extraAttribs = array();
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2011-10-21 20:09:27 +00:00
|
|
|
$msgLink = $this->msg( $line[0] )->inContentLanguage();
|
2011-05-23 16:32:52 +00:00
|
|
|
if ( $msgLink->exists() ) {
|
|
|
|
|
$link = $msgLink->text();
|
|
|
|
|
if ( $link == '-' ) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$link = $line[0];
|
2010-02-01 13:52:55 +00:00
|
|
|
}
|
2011-10-21 20:09:27 +00:00
|
|
|
$msgText = $this->msg( $line[1] );
|
2011-05-23 16:32:52 +00:00
|
|
|
if ( $msgText->exists() ) {
|
|
|
|
|
$text = $msgText->text();
|
|
|
|
|
} else {
|
2005-08-08 13:26:42 +00:00
|
|
|
$text = $line[1];
|
2010-02-01 13:52:55 +00:00
|
|
|
}
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2012-07-10 18:49:02 +00:00
|
|
|
if ( preg_match( '/^(?i:' . wfUrlProtocols() . ')/', $link ) ) {
|
2006-10-30 06:25:31 +00:00
|
|
|
$href = $link;
|
2011-11-29 21:04:20 +00:00
|
|
|
|
2011-08-20 10:18:09 +00:00
|
|
|
// Parser::getExternalLinkAttribs won't work here because of the Namespace things
|
|
|
|
|
global $wgNoFollowLinks, $wgNoFollowDomainExceptions;
|
2011-08-20 10:25:38 +00:00
|
|
|
if ( $wgNoFollowLinks && !wfMatchesDomainList( $href, $wgNoFollowDomainExceptions ) ) {
|
2011-06-26 19:52:11 +00:00
|
|
|
$extraAttribs['rel'] = 'nofollow';
|
|
|
|
|
}
|
2011-11-29 21:04:20 +00:00
|
|
|
|
2011-06-26 19:52:11 +00:00
|
|
|
global $wgExternalLinkTarget;
|
2013-03-24 10:01:51 +00:00
|
|
|
if ( $wgExternalLinkTarget ) {
|
2011-06-26 19:52:11 +00:00
|
|
|
$extraAttribs['target'] = $wgExternalLinkTarget;
|
|
|
|
|
}
|
2006-10-30 06:25:31 +00:00
|
|
|
} else {
|
|
|
|
|
$title = Title::newFromText( $link );
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2006-11-01 11:21:46 +00:00
|
|
|
if ( $title ) {
|
|
|
|
|
$title = $title->fixSpecialName();
|
2011-08-25 07:03:25 +00:00
|
|
|
$href = $title->getLinkURL();
|
2006-11-01 11:21:46 +00:00
|
|
|
} else {
|
|
|
|
|
$href = 'INVALID-TITLE';
|
|
|
|
|
}
|
2006-10-30 06:25:31 +00:00
|
|
|
}
|
|
|
|
|
|
2011-06-26 19:52:11 +00:00
|
|
|
$bar[$heading][] = array_merge( array(
|
2005-08-08 13:26:42 +00:00
|
|
|
'text' => $text,
|
2005-10-11 23:46:00 +00:00
|
|
|
'href' => $href,
|
2011-07-12 00:25:20 +00:00
|
|
|
'id' => 'n-' . Sanitizer::escapeId( strtr( $line[1], ' ', '-' ), 'noninitial' ),
|
2006-01-14 22:13:43 +00:00
|
|
|
'active' => false
|
2011-06-26 19:52:11 +00:00
|
|
|
), $extraAttribs );
|
2010-02-01 13:52:55 +00:00
|
|
|
} else {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2005-06-28 14:18:08 +00:00
|
|
|
}
|
|
|
|
|
}
|
2010-09-04 01:06:34 +00:00
|
|
|
|
2010-05-27 16:56:34 +00:00
|
|
|
return $bar;
|
2005-06-28 14:18:08 +00:00
|
|
|
}
|
2009-07-07 21:49:45 +00:00
|
|
|
|
|
|
|
|
/**
|
2013-08-24 13:21:33 +00:00
|
|
|
* This function previously controlled whether the 'mediawiki.legacy.wikiprintable' module
|
|
|
|
|
* should be loaded by OutputPage. That module no longer exists and the return value of this
|
|
|
|
|
* method is ignored.
|
2009-07-07 21:49:45 +00:00
|
|
|
*
|
2013-08-24 13:21:33 +00:00
|
|
|
* If your skin doesn't provide its own print styles, the 'mediawiki.legacy.commonPrint' module
|
|
|
|
|
* can be used instead (SkinTemplate-based skins do it automatically).
|
|
|
|
|
*
|
|
|
|
|
* @deprecated since 1.22
|
2009-07-07 21:49:45 +00:00
|
|
|
* @return bool
|
|
|
|
|
*/
|
|
|
|
|
public function commonPrintStylesheet() {
|
2013-08-24 13:21:33 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.22' );
|
|
|
|
|
return false;
|
2009-07-07 21:49:45 +00:00
|
|
|
}
|
2010-03-23 16:11:37 +00:00
|
|
|
|
|
|
|
|
/**
|
2013-05-05 01:08:58 +00:00
|
|
|
* Gets new talk page messages for the current user and returns an
|
|
|
|
|
* appropriate alert message (or an empty string if there are no messages)
|
2014-04-23 09:46:22 +00:00
|
|
|
* @return string
|
2010-03-23 16:11:37 +00:00
|
|
|
*/
|
2011-04-03 12:46:36 +00:00
|
|
|
function getNewtalks() {
|
2013-05-05 01:08:58 +00:00
|
|
|
|
|
|
|
|
$newMessagesAlert = '';
|
|
|
|
|
$user = $this->getUser();
|
|
|
|
|
$newtalks = $user->getNewMessageLinks();
|
2011-07-18 20:52:22 +00:00
|
|
|
$out = $this->getOutput();
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2013-05-05 01:08:58 +00:00
|
|
|
// Allow extensions to disable or modify the new messages alert
|
|
|
|
|
if ( !wfRunHooks( 'GetNewMessagesAlert', array( &$newMessagesAlert, $newtalks, $user, $out ) ) ) {
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
if ( $newMessagesAlert ) {
|
|
|
|
|
return $newMessagesAlert;
|
|
|
|
|
}
|
2010-03-23 16:11:37 +00:00
|
|
|
|
2010-09-04 13:48:16 +00:00
|
|
|
if ( count( $newtalks ) == 1 && $newtalks[0]['wiki'] === wfWikiID() ) {
|
2013-05-05 01:08:58 +00:00
|
|
|
$uTalkTitle = $user->getTalkPage();
|
Correctly update wl_notificationtimestamp when viewing old revisions
== Prelude ==
wl_notificationtimestamp controls sending the user e-mail
notifications about changes to pages, as well as showing the "updated
since last visit" markers on history pages, recent changes and
watchlist.
== The bug ==
Previously, on every view of a page, the notification timestamp was
cleared, regardless of whether the user as actually viewing the latest
revision. When viewing a diff, however, the timestamp was cleared only
if one of the revisions being compared was the latest one of its page.
The same behavior applied to talk page message indicators (which are
actually stored sepately to cater to anonymous users).
This was inconsistent and surprising when one was attempting to, say,
go through the 50 new posts to a discussion page in a peacemeal
fashion.
== The fix ==
If the revision being viewed is the latest (or can't be determined),
the timestamp is cleared as previously, as this is necessary to
reenable e-mail notifications for given user and page.
If the revision isn't the latest, the timestamp is updated to
revision's timestamp plus one second. This uses up to two simple
(selectField) indexed queries per page view, only fired when we
do not already know we're looking at the latest version.
Talk page indicator is updated to point at the next revision after the
one being viewed, or cleared if viewing the latest revision. The
UserClearNewTalkNotification hook gained $oldid as the second argument
(a backwards-compatible change). In Skin, we no longer ignore the
indicator being present if we're viewing the talk page, as it might
still be valid.
== The bonus ==
Comments and formatting was updated in a few places, including
tables.sql and Wiki.php.
The following functions gained a second, optional $oldid parameter
(holy indirection, Batman!):
* WikiPage#doViewUpdates()
* User#clearNotification()
* WatchedItem#resetNotificationTimestamp()
DifferenceEngine gained a public method mapDiffPrevNext() used
to parse the ids from URL parameters like oldid=12345&diff=prev,
factored out of loadRevisionIds(). A bug where the NewDifferenceEngine
hook would not be called in some cases, dating back to its
introduction in r45518, was fixed in the process.
Bug: 41759
Change-Id: I4144ba1987b8d7a7e8b24f4f067eedac2ae44459
2013-09-16 10:31:40 +00:00
|
|
|
$lastSeenRev = isset( $newtalks[0]['rev'] ) ? $newtalks[0]['rev'] : null;
|
|
|
|
|
$nofAuthors = 0;
|
|
|
|
|
if ( $lastSeenRev !== null ) {
|
|
|
|
|
$plural = true; // Default if we have a last seen revision: if unknown, use plural
|
|
|
|
|
$latestRev = Revision::newFromTitle( $uTalkTitle, false, Revision::READ_NORMAL );
|
|
|
|
|
if ( $latestRev !== null ) {
|
|
|
|
|
// Singular if only 1 unseen revision, plural if several unseen revisions.
|
|
|
|
|
$plural = $latestRev->getParentId() !== $lastSeenRev->getId();
|
|
|
|
|
$nofAuthors = $uTalkTitle->countAuthorsBetween(
|
|
|
|
|
$lastSeenRev, $latestRev, 10, 'include_new' );
|
2012-06-18 06:43:47 +00:00
|
|
|
}
|
Correctly update wl_notificationtimestamp when viewing old revisions
== Prelude ==
wl_notificationtimestamp controls sending the user e-mail
notifications about changes to pages, as well as showing the "updated
since last visit" markers on history pages, recent changes and
watchlist.
== The bug ==
Previously, on every view of a page, the notification timestamp was
cleared, regardless of whether the user as actually viewing the latest
revision. When viewing a diff, however, the timestamp was cleared only
if one of the revisions being compared was the latest one of its page.
The same behavior applied to talk page message indicators (which are
actually stored sepately to cater to anonymous users).
This was inconsistent and surprising when one was attempting to, say,
go through the 50 new posts to a discussion page in a peacemeal
fashion.
== The fix ==
If the revision being viewed is the latest (or can't be determined),
the timestamp is cleared as previously, as this is necessary to
reenable e-mail notifications for given user and page.
If the revision isn't the latest, the timestamp is updated to
revision's timestamp plus one second. This uses up to two simple
(selectField) indexed queries per page view, only fired when we
do not already know we're looking at the latest version.
Talk page indicator is updated to point at the next revision after the
one being viewed, or cleared if viewing the latest revision. The
UserClearNewTalkNotification hook gained $oldid as the second argument
(a backwards-compatible change). In Skin, we no longer ignore the
indicator being present if we're viewing the talk page, as it might
still be valid.
== The bonus ==
Comments and formatting was updated in a few places, including
tables.sql and Wiki.php.
The following functions gained a second, optional $oldid parameter
(holy indirection, Batman!):
* WikiPage#doViewUpdates()
* User#clearNotification()
* WatchedItem#resetNotificationTimestamp()
DifferenceEngine gained a public method mapDiffPrevNext() used
to parse the ids from URL parameters like oldid=12345&diff=prev,
factored out of loadRevisionIds(). A bug where the NewDifferenceEngine
hook would not be called in some cases, dating back to its
introduction in r45518, was fixed in the process.
Bug: 41759
Change-Id: I4144ba1987b8d7a7e8b24f4f067eedac2ae44459
2013-09-16 10:31:40 +00:00
|
|
|
} else {
|
|
|
|
|
// Singular if no revision -> diff link will show latest change only in any case
|
|
|
|
|
$plural = false;
|
|
|
|
|
}
|
2013-11-20 20:58:45 +00:00
|
|
|
$plural = $plural ? 999 : 1;
|
|
|
|
|
// 999 signifies "more than one revision". We don't know how many, and even if we did,
|
Correctly update wl_notificationtimestamp when viewing old revisions
== Prelude ==
wl_notificationtimestamp controls sending the user e-mail
notifications about changes to pages, as well as showing the "updated
since last visit" markers on history pages, recent changes and
watchlist.
== The bug ==
Previously, on every view of a page, the notification timestamp was
cleared, regardless of whether the user as actually viewing the latest
revision. When viewing a diff, however, the timestamp was cleared only
if one of the revisions being compared was the latest one of its page.
The same behavior applied to talk page message indicators (which are
actually stored sepately to cater to anonymous users).
This was inconsistent and surprising when one was attempting to, say,
go through the 50 new posts to a discussion page in a peacemeal
fashion.
== The fix ==
If the revision being viewed is the latest (or can't be determined),
the timestamp is cleared as previously, as this is necessary to
reenable e-mail notifications for given user and page.
If the revision isn't the latest, the timestamp is updated to
revision's timestamp plus one second. This uses up to two simple
(selectField) indexed queries per page view, only fired when we
do not already know we're looking at the latest version.
Talk page indicator is updated to point at the next revision after the
one being viewed, or cleared if viewing the latest revision. The
UserClearNewTalkNotification hook gained $oldid as the second argument
(a backwards-compatible change). In Skin, we no longer ignore the
indicator being present if we're viewing the talk page, as it might
still be valid.
== The bonus ==
Comments and formatting was updated in a few places, including
tables.sql and Wiki.php.
The following functions gained a second, optional $oldid parameter
(holy indirection, Batman!):
* WikiPage#doViewUpdates()
* User#clearNotification()
* WatchedItem#resetNotificationTimestamp()
DifferenceEngine gained a public method mapDiffPrevNext() used
to parse the ids from URL parameters like oldid=12345&diff=prev,
factored out of loadRevisionIds(). A bug where the NewDifferenceEngine
hook would not be called in some cases, dating back to its
introduction in r45518, was fixed in the process.
Bug: 41759
Change-Id: I4144ba1987b8d7a7e8b24f4f067eedac2ae44459
2013-09-16 10:31:40 +00:00
|
|
|
// the number of revisions or authors is not necessarily the same as the number of
|
|
|
|
|
// "messages".
|
|
|
|
|
$newMessagesLink = Linker::linkKnown(
|
|
|
|
|
$uTalkTitle,
|
|
|
|
|
$this->msg( 'newmessageslinkplural' )->params( $plural )->escaped(),
|
|
|
|
|
array(),
|
|
|
|
|
array( 'redirect' => 'no' )
|
|
|
|
|
);
|
2010-03-23 16:11:37 +00:00
|
|
|
|
Correctly update wl_notificationtimestamp when viewing old revisions
== Prelude ==
wl_notificationtimestamp controls sending the user e-mail
notifications about changes to pages, as well as showing the "updated
since last visit" markers on history pages, recent changes and
watchlist.
== The bug ==
Previously, on every view of a page, the notification timestamp was
cleared, regardless of whether the user as actually viewing the latest
revision. When viewing a diff, however, the timestamp was cleared only
if one of the revisions being compared was the latest one of its page.
The same behavior applied to talk page message indicators (which are
actually stored sepately to cater to anonymous users).
This was inconsistent and surprising when one was attempting to, say,
go through the 50 new posts to a discussion page in a peacemeal
fashion.
== The fix ==
If the revision being viewed is the latest (or can't be determined),
the timestamp is cleared as previously, as this is necessary to
reenable e-mail notifications for given user and page.
If the revision isn't the latest, the timestamp is updated to
revision's timestamp plus one second. This uses up to two simple
(selectField) indexed queries per page view, only fired when we
do not already know we're looking at the latest version.
Talk page indicator is updated to point at the next revision after the
one being viewed, or cleared if viewing the latest revision. The
UserClearNewTalkNotification hook gained $oldid as the second argument
(a backwards-compatible change). In Skin, we no longer ignore the
indicator being present if we're viewing the talk page, as it might
still be valid.
== The bonus ==
Comments and formatting was updated in a few places, including
tables.sql and Wiki.php.
The following functions gained a second, optional $oldid parameter
(holy indirection, Batman!):
* WikiPage#doViewUpdates()
* User#clearNotification()
* WatchedItem#resetNotificationTimestamp()
DifferenceEngine gained a public method mapDiffPrevNext() used
to parse the ids from URL parameters like oldid=12345&diff=prev,
factored out of loadRevisionIds(). A bug where the NewDifferenceEngine
hook would not be called in some cases, dating back to its
introduction in r45518, was fixed in the process.
Bug: 41759
Change-Id: I4144ba1987b8d7a7e8b24f4f067eedac2ae44459
2013-09-16 10:31:40 +00:00
|
|
|
$newMessagesDiffLink = Linker::linkKnown(
|
|
|
|
|
$uTalkTitle,
|
|
|
|
|
$this->msg( 'newmessagesdifflinkplural' )->params( $plural )->escaped(),
|
|
|
|
|
array(),
|
|
|
|
|
$lastSeenRev !== null
|
|
|
|
|
? array( 'oldid' => $lastSeenRev->getId(), 'diff' => 'cur' )
|
|
|
|
|
: array( 'diff' => 'cur' )
|
|
|
|
|
);
|
2010-03-23 16:11:37 +00:00
|
|
|
|
Correctly update wl_notificationtimestamp when viewing old revisions
== Prelude ==
wl_notificationtimestamp controls sending the user e-mail
notifications about changes to pages, as well as showing the "updated
since last visit" markers on history pages, recent changes and
watchlist.
== The bug ==
Previously, on every view of a page, the notification timestamp was
cleared, regardless of whether the user as actually viewing the latest
revision. When viewing a diff, however, the timestamp was cleared only
if one of the revisions being compared was the latest one of its page.
The same behavior applied to talk page message indicators (which are
actually stored sepately to cater to anonymous users).
This was inconsistent and surprising when one was attempting to, say,
go through the 50 new posts to a discussion page in a peacemeal
fashion.
== The fix ==
If the revision being viewed is the latest (or can't be determined),
the timestamp is cleared as previously, as this is necessary to
reenable e-mail notifications for given user and page.
If the revision isn't the latest, the timestamp is updated to
revision's timestamp plus one second. This uses up to two simple
(selectField) indexed queries per page view, only fired when we
do not already know we're looking at the latest version.
Talk page indicator is updated to point at the next revision after the
one being viewed, or cleared if viewing the latest revision. The
UserClearNewTalkNotification hook gained $oldid as the second argument
(a backwards-compatible change). In Skin, we no longer ignore the
indicator being present if we're viewing the talk page, as it might
still be valid.
== The bonus ==
Comments and formatting was updated in a few places, including
tables.sql and Wiki.php.
The following functions gained a second, optional $oldid parameter
(holy indirection, Batman!):
* WikiPage#doViewUpdates()
* User#clearNotification()
* WatchedItem#resetNotificationTimestamp()
DifferenceEngine gained a public method mapDiffPrevNext() used
to parse the ids from URL parameters like oldid=12345&diff=prev,
factored out of loadRevisionIds(). A bug where the NewDifferenceEngine
hook would not be called in some cases, dating back to its
introduction in r45518, was fixed in the process.
Bug: 41759
Change-Id: I4144ba1987b8d7a7e8b24f4f067eedac2ae44459
2013-09-16 10:31:40 +00:00
|
|
|
if ( $nofAuthors >= 1 && $nofAuthors <= 10 ) {
|
|
|
|
|
$newMessagesAlert = $this->msg(
|
|
|
|
|
'youhavenewmessagesfromusers',
|
|
|
|
|
$newMessagesLink,
|
|
|
|
|
$newMessagesDiffLink
|
2013-12-03 23:47:54 +00:00
|
|
|
)->numParams( $nofAuthors, $plural );
|
Correctly update wl_notificationtimestamp when viewing old revisions
== Prelude ==
wl_notificationtimestamp controls sending the user e-mail
notifications about changes to pages, as well as showing the "updated
since last visit" markers on history pages, recent changes and
watchlist.
== The bug ==
Previously, on every view of a page, the notification timestamp was
cleared, regardless of whether the user as actually viewing the latest
revision. When viewing a diff, however, the timestamp was cleared only
if one of the revisions being compared was the latest one of its page.
The same behavior applied to talk page message indicators (which are
actually stored sepately to cater to anonymous users).
This was inconsistent and surprising when one was attempting to, say,
go through the 50 new posts to a discussion page in a peacemeal
fashion.
== The fix ==
If the revision being viewed is the latest (or can't be determined),
the timestamp is cleared as previously, as this is necessary to
reenable e-mail notifications for given user and page.
If the revision isn't the latest, the timestamp is updated to
revision's timestamp plus one second. This uses up to two simple
(selectField) indexed queries per page view, only fired when we
do not already know we're looking at the latest version.
Talk page indicator is updated to point at the next revision after the
one being viewed, or cleared if viewing the latest revision. The
UserClearNewTalkNotification hook gained $oldid as the second argument
(a backwards-compatible change). In Skin, we no longer ignore the
indicator being present if we're viewing the talk page, as it might
still be valid.
== The bonus ==
Comments and formatting was updated in a few places, including
tables.sql and Wiki.php.
The following functions gained a second, optional $oldid parameter
(holy indirection, Batman!):
* WikiPage#doViewUpdates()
* User#clearNotification()
* WatchedItem#resetNotificationTimestamp()
DifferenceEngine gained a public method mapDiffPrevNext() used
to parse the ids from URL parameters like oldid=12345&diff=prev,
factored out of loadRevisionIds(). A bug where the NewDifferenceEngine
hook would not be called in some cases, dating back to its
introduction in r45518, was fixed in the process.
Bug: 41759
Change-Id: I4144ba1987b8d7a7e8b24f4f067eedac2ae44459
2013-09-16 10:31:40 +00:00
|
|
|
} else {
|
|
|
|
|
// $nofAuthors === 11 signifies "11 or more" ("more than 10")
|
|
|
|
|
$newMessagesAlert = $this->msg(
|
|
|
|
|
$nofAuthors > 10 ? 'youhavenewmessagesmanyusers' : 'youhavenewmessages',
|
|
|
|
|
$newMessagesLink,
|
|
|
|
|
$newMessagesDiffLink
|
2013-12-03 23:47:54 +00:00
|
|
|
)->numParams( $plural );
|
2010-03-23 16:11:37 +00:00
|
|
|
}
|
Correctly update wl_notificationtimestamp when viewing old revisions
== Prelude ==
wl_notificationtimestamp controls sending the user e-mail
notifications about changes to pages, as well as showing the "updated
since last visit" markers on history pages, recent changes and
watchlist.
== The bug ==
Previously, on every view of a page, the notification timestamp was
cleared, regardless of whether the user as actually viewing the latest
revision. When viewing a diff, however, the timestamp was cleared only
if one of the revisions being compared was the latest one of its page.
The same behavior applied to talk page message indicators (which are
actually stored sepately to cater to anonymous users).
This was inconsistent and surprising when one was attempting to, say,
go through the 50 new posts to a discussion page in a peacemeal
fashion.
== The fix ==
If the revision being viewed is the latest (or can't be determined),
the timestamp is cleared as previously, as this is necessary to
reenable e-mail notifications for given user and page.
If the revision isn't the latest, the timestamp is updated to
revision's timestamp plus one second. This uses up to two simple
(selectField) indexed queries per page view, only fired when we
do not already know we're looking at the latest version.
Talk page indicator is updated to point at the next revision after the
one being viewed, or cleared if viewing the latest revision. The
UserClearNewTalkNotification hook gained $oldid as the second argument
(a backwards-compatible change). In Skin, we no longer ignore the
indicator being present if we're viewing the talk page, as it might
still be valid.
== The bonus ==
Comments and formatting was updated in a few places, including
tables.sql and Wiki.php.
The following functions gained a second, optional $oldid parameter
(holy indirection, Batman!):
* WikiPage#doViewUpdates()
* User#clearNotification()
* WatchedItem#resetNotificationTimestamp()
DifferenceEngine gained a public method mapDiffPrevNext() used
to parse the ids from URL parameters like oldid=12345&diff=prev,
factored out of loadRevisionIds(). A bug where the NewDifferenceEngine
hook would not be called in some cases, dating back to its
introduction in r45518, was fixed in the process.
Bug: 41759
Change-Id: I4144ba1987b8d7a7e8b24f4f067eedac2ae44459
2013-09-16 10:31:40 +00:00
|
|
|
$newMessagesAlert = $newMessagesAlert->text();
|
|
|
|
|
# Disable Squid cache
|
|
|
|
|
$out->setSquidMaxage( 0 );
|
2010-09-04 13:48:16 +00:00
|
|
|
} elseif ( count( $newtalks ) ) {
|
2013-05-05 01:08:58 +00:00
|
|
|
$sep = $this->msg( 'newtalkseparator' )->escaped();
|
2010-03-23 16:11:37 +00:00
|
|
|
$msgs = array();
|
2010-09-04 13:48:16 +00:00
|
|
|
|
|
|
|
|
foreach ( $newtalks as $newtalk ) {
|
2010-03-23 16:11:37 +00:00
|
|
|
$msgs[] = Xml::element(
|
|
|
|
|
'a',
|
|
|
|
|
array( 'href' => $newtalk['link'] ), $newtalk['wiki']
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
$parts = implode( $sep, $msgs );
|
2013-05-05 01:08:58 +00:00
|
|
|
$newMessagesAlert = $this->msg( 'youhavenewmessagesmulti' )->rawParams( $parts )->escaped();
|
2011-03-03 10:22:46 +00:00
|
|
|
$out->setSquidMaxage( 0 );
|
2010-03-23 16:11:37 +00:00
|
|
|
}
|
2010-09-04 13:48:16 +00:00
|
|
|
|
2013-05-05 01:08:58 +00:00
|
|
|
return $newMessagesAlert;
|
2010-03-23 16:11:37 +00:00
|
|
|
}
|
2011-02-12 21:24:05 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get a cached notice
|
|
|
|
|
*
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param string $name Message name, or 'default' for $wgSiteNotice
|
|
|
|
|
* @return string HTML fragment
|
2011-02-12 21:24:05 +00:00
|
|
|
*/
|
|
|
|
|
private function getCachedNotice( $name ) {
|
2011-07-01 21:28:11 +00:00
|
|
|
global $wgRenderHashAppend, $parserMemc, $wgContLang;
|
2011-02-12 21:24:05 +00:00
|
|
|
|
|
|
|
|
wfProfileIn( __METHOD__ );
|
|
|
|
|
|
|
|
|
|
$needParse = false;
|
|
|
|
|
|
2013-04-20 22:49:30 +00:00
|
|
|
if ( $name === 'default' ) {
|
2011-02-12 21:24:05 +00:00
|
|
|
// special case
|
|
|
|
|
global $wgSiteNotice;
|
|
|
|
|
$notice = $wgSiteNotice;
|
2013-04-20 22:49:30 +00:00
|
|
|
if ( empty( $notice ) ) {
|
2011-02-12 21:24:05 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2011-10-21 20:09:27 +00:00
|
|
|
$msg = $this->msg( $name )->inContentLanguage();
|
2013-04-20 22:49:30 +00:00
|
|
|
if ( $msg->isDisabled() ) {
|
2011-02-12 21:24:05 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
$notice = $msg->plain();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Use the extra hash appender to let eg SSL variants separately cache.
|
|
|
|
|
$key = wfMemcKey( $name . $wgRenderHashAppend );
|
|
|
|
|
$cachedNotice = $parserMemc->get( $key );
|
2013-04-20 22:49:30 +00:00
|
|
|
if ( is_array( $cachedNotice ) ) {
|
|
|
|
|
if ( md5( $notice ) == $cachedNotice['hash'] ) {
|
2011-02-12 21:24:05 +00:00
|
|
|
$notice = $cachedNotice['html'];
|
|
|
|
|
} else {
|
|
|
|
|
$needParse = true;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$needParse = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $needParse ) {
|
2011-07-18 20:52:22 +00:00
|
|
|
$parsed = $this->getOutput()->parse( $notice );
|
2011-04-03 12:46:36 +00:00
|
|
|
$parserMemc->set( $key, array( 'html' => $parsed, 'hash' => md5( $notice ) ), 600 );
|
|
|
|
|
$notice = $parsed;
|
2011-02-12 21:24:05 +00:00
|
|
|
}
|
|
|
|
|
|
2011-07-01 21:28:11 +00:00
|
|
|
$notice = Html::rawElement( 'div', array( 'id' => 'localNotice',
|
2011-12-11 18:46:18 +00:00
|
|
|
'lang' => $wgContLang->getHtmlCode(), 'dir' => $wgContLang->getDir() ), $notice );
|
2011-02-12 21:24:05 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
|
|
|
|
return $notice;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get a notice based on page's namespace
|
|
|
|
|
*
|
2014-04-23 09:46:22 +00:00
|
|
|
* @return string HTML fragment
|
2011-02-12 21:24:05 +00:00
|
|
|
*/
|
|
|
|
|
function getNamespaceNotice() {
|
|
|
|
|
wfProfileIn( __METHOD__ );
|
|
|
|
|
|
2011-04-03 12:46:36 +00:00
|
|
|
$key = 'namespacenotice-' . $this->getTitle()->getNsText();
|
2011-03-01 08:52:38 +00:00
|
|
|
$namespaceNotice = $this->getCachedNotice( $key );
|
2011-02-12 21:24:05 +00:00
|
|
|
if ( $namespaceNotice && substr( $namespaceNotice, 0, 7 ) != '<p><' ) {
|
|
|
|
|
$namespaceNotice = '<div id="namespacebanner">' . $namespaceNotice . '</div>';
|
|
|
|
|
} else {
|
|
|
|
|
$namespaceNotice = '';
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-18 01:06:04 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2011-02-12 21:24:05 +00:00
|
|
|
return $namespaceNotice;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the site notice
|
|
|
|
|
*
|
2014-04-23 09:46:22 +00:00
|
|
|
* @return string HTML fragment
|
2011-02-12 21:24:05 +00:00
|
|
|
*/
|
|
|
|
|
function getSiteNotice() {
|
|
|
|
|
wfProfileIn( __METHOD__ );
|
|
|
|
|
$siteNotice = '';
|
|
|
|
|
|
|
|
|
|
if ( wfRunHooks( 'SiteNoticeBefore', array( &$siteNotice, $this ) ) ) {
|
2011-07-18 20:52:22 +00:00
|
|
|
if ( is_object( $this->getUser() ) && $this->getUser()->isLoggedIn() ) {
|
2011-02-12 21:24:05 +00:00
|
|
|
$siteNotice = $this->getCachedNotice( 'sitenotice' );
|
|
|
|
|
} else {
|
|
|
|
|
$anonNotice = $this->getCachedNotice( 'anonnotice' );
|
|
|
|
|
if ( !$anonNotice ) {
|
|
|
|
|
$siteNotice = $this->getCachedNotice( 'sitenotice' );
|
|
|
|
|
} else {
|
|
|
|
|
$siteNotice = $anonNotice;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ( !$siteNotice ) {
|
|
|
|
|
$siteNotice = $this->getCachedNotice( 'default' );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wfRunHooks( 'SiteNoticeAfter', array( &$siteNotice, $this ) );
|
|
|
|
|
wfProfileOut( __METHOD__ );
|
|
|
|
|
return $siteNotice;
|
2011-04-03 11:44:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a section edit link. This supersedes editSectionLink() and
|
|
|
|
|
* editSectionLinkForOther().
|
|
|
|
|
*
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param Title $nt The title being linked to (may not be the same as
|
2013-11-16 00:06:48 +00:00
|
|
|
* the current page, if the section is included from a template)
|
2013-03-11 17:15:01 +00:00
|
|
|
* @param string $section The designation of the section being pointed to,
|
2011-04-03 11:44:11 +00:00
|
|
|
* to be included in the link, like "§ion=$section"
|
2013-03-11 17:15:01 +00:00
|
|
|
* @param string $tooltip The tooltip to use for the link: will be escaped
|
2011-04-03 11:44:11 +00:00
|
|
|
* and wrapped in the 'editsectionhint' message
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param string $lang Language code
|
2014-04-05 19:54:24 +00:00
|
|
|
* @return string HTML to use for edit link
|
2011-04-03 11:44:11 +00:00
|
|
|
*/
|
|
|
|
|
public function doEditSectionLink( Title $nt, $section, $tooltip = null, $lang = false ) {
|
|
|
|
|
// HTML generated here should probably have userlangattributes
|
|
|
|
|
// added to it for LTR text on RTL pages
|
2012-08-21 17:23:53 +00:00
|
|
|
|
|
|
|
|
$lang = wfGetLangObj( $lang );
|
|
|
|
|
|
2011-04-03 11:44:11 +00:00
|
|
|
$attribs = array();
|
|
|
|
|
if ( !is_null( $tooltip ) ) {
|
|
|
|
|
# Bug 25462: undo double-escaping.
|
|
|
|
|
$tooltip = Sanitizer::decodeCharReferences( $tooltip );
|
2012-08-21 17:23:53 +00:00
|
|
|
$attribs['title'] = wfMessage( 'editsectionhint' )->rawParams( $tooltip )
|
|
|
|
|
->inLanguage( $lang )->text();
|
2011-04-03 11:44:11 +00:00
|
|
|
}
|
2012-08-21 17:23:53 +00:00
|
|
|
$link = Linker::link( $nt, wfMessage( 'editsection' )->inLanguage( $lang )->text(),
|
2011-04-03 11:44:11 +00:00
|
|
|
$attribs,
|
|
|
|
|
array( 'action' => 'edit', 'section' => $section ),
|
|
|
|
|
array( 'noclasses', 'known' )
|
|
|
|
|
);
|
|
|
|
|
|
2013-05-17 18:19:40 +00:00
|
|
|
# Add the brackets and the span and run the hook.
|
2013-05-17 18:34:08 +00:00
|
|
|
$result = '<span class="mw-editsection">'
|
|
|
|
|
. '<span class="mw-editsection-bracket">[</span>'
|
|
|
|
|
. $link
|
|
|
|
|
. '<span class="mw-editsection-bracket">]</span>'
|
|
|
|
|
. '</span>';
|
2011-04-03 11:44:11 +00:00
|
|
|
|
|
|
|
|
wfRunHooks( 'DoEditSectionLink', array( $this, $nt, $section, $tooltip, &$result, $lang ) );
|
|
|
|
|
return $result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Use PHP's magic __call handler to intercept legacy calls to the linker
|
|
|
|
|
* for backwards compatibility.
|
|
|
|
|
*
|
2013-03-11 17:15:01 +00:00
|
|
|
* @param string $fname Name of called method
|
|
|
|
|
* @param array $args Arguments to the method
|
2012-10-07 23:35:26 +00:00
|
|
|
* @throws MWException
|
2012-02-09 21:36:14 +00:00
|
|
|
* @return mixed
|
2011-04-03 11:44:11 +00:00
|
|
|
*/
|
|
|
|
|
function __call( $fname, $args ) {
|
2011-04-04 03:42:34 +00:00
|
|
|
$realFunction = array( 'Linker', $fname );
|
|
|
|
|
if ( is_callable( $realFunction ) ) {
|
2013-03-28 16:41:12 +00:00
|
|
|
wfDeprecated( get_class( $this ) . '::' . $fname, '1.21' );
|
2011-04-04 03:42:34 +00:00
|
|
|
return call_user_func_array( $realFunction, $args );
|
2011-04-03 11:44:11 +00:00
|
|
|
} else {
|
|
|
|
|
$className = get_class( $this );
|
2011-04-03 12:37:07 +00:00
|
|
|
throw new MWException( "Call to undefined method $className::$fname" );
|
2011-04-03 11:44:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-01 16:44:44 +00:00
|
|
|
}
|