2004-02-18 02:15:00 +00:00
< ? php
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
*/
2010-02-01 13:52:55 +00:00
if ( ! defined ( 'MEDIAWIKI' ) ) {
2006-06-07 06:40:24 +00:00
die ( 1 );
2010-02-01 13:52:55 +00:00
}
2004-08-12 06:54:58 +00:00
2004-09-02 23:28:24 +00:00
/**
2006-02-18 04:34:10 +00:00
* The main skin class that provide methods and properties for all other skins .
2004-09-02 23:28:24 +00:00
* This base class is also the " Standard " skin .
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 {
2009-03-29 12:46:11 +00:00
protected $skinname = 'standard' ;
2011-01-01 01:03:02 +00:00
protected $mRelevantTitle = null ;
protected $mRelevantUser = null ;
2003-04-14 23:10:40 +00:00
2005-12-19 23:36:43 +00:00
/**
* Fetch the set of available skins .
* @ return array of strings
*/
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 );
# while code from www.php.net
2010-09-04 13:48:16 +00:00
while ( false !== ( $file = $skinDir -> read () ) ) {
2006-07-02 15:57:59 +00:00
// Skip non-PHP files, hidden files, and '.dep' includes
2006-11-29 11:43:58 +00:00
$matches = array ();
2010-09-04 13:48:16 +00:00
if ( preg_match ( '/^([^.]*)\.php$/' , $file , $matches ) ) {
2006-07-02 15:57:59 +00:00
$aSkin = $matches [ 1 ];
2010-02-01 13:52:55 +00:00
$wgValidSkinNames [ strtolower ( $aSkin )] = $aSkin ;
2006-07-02 15:57:59 +00:00
}
}
$skinDir -> close ();
$skinsInitialised = true ;
wfProfileOut ( __METHOD__ . '-init' );
}
2006-06-08 15:12:26 +00:00
return $wgValidSkinNames ;
2003-04-14 23:10:40 +00:00
}
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
/**
* Fetch the list of usable skins in regards to $wgSkipSkins .
* Useful for Special : Preferences and other places where you
* only want to show skins users _can_ use .
* @ return array of strings
*/
public static function getUsableSkins () {
global $wgSkipSkins ;
2010-09-04 13:48:16 +00:00
2008-08-06 17:41:17 +00:00
$usableSkins = self :: getSkinNames ();
2010-09-04 13:48:16 +00:00
2008-08-06 17:41:17 +00:00
foreach ( $wgSkipSkins as $skip ) {
unset ( $usableSkins [ $skip ] );
}
2010-09-04 13:48:16 +00:00
2008-08-06 17:41:17 +00:00
return $usableSkins ;
}
2006-01-07 13:31:29 +00:00
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
* default ( or the old 'Classic' skin if that ' s broken ) .
2010-02-01 13:52:55 +00:00
* @ param $key String : 'monobook' , 'standard' , 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
2010-09-04 13:48:16 +00:00
if ( $key == '' ) {
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 ,
1 => 'nostalgia' ,
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
2010-02-01 13:52:55 +00:00
* @ param $key String : 'monobook' , 'standard' , 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.
The beginnings of HipHop compiled mode support. It works now for parser cache hits.
* Work around HipHop issue 314 (volatile broken) and issue 308 (no compilation detection) by adding some large and ugly compilation detection code to WebStart.php and doMaintenance.php.
* Provide an MW_COMPILED constant which can be used to detect compiled mode throughout the codebase.
* Introduced wfIsHipHop(), which detects either compiled or interpreted mode. Used this to work around unusual eval() return value in eval.php.
* Work around lack of ini_get() in Maintenance.php, by duplicating wfIsHipHop().
* In Maintenance::shouldExecute(), accept "include" as an inclusion function name, since all kinds of inclusion give this string in HipHop.
* Introduced new class MWInit, which provides some static functions in the pre-autoloader environment.
* Introduced MWInit::compiledPath(), which provides a relative path for invoking a compiled file, and MWInit::interpretedPath(), which provides an absolute path for interpreting a PHP file. Used these new functions in the appropriate places.
* When we are running compiled code, don't include files which would generate duplicate class, function or constant definitions. Documented the new requirements on the contents of Defines.php and UtfNormalDefines.php.
* In HipHop compiled mode, it's not possible to have executable code in the same file as a class definition.
** Moved MimeMagic initialisation to the constructor.
** Moved Namespace.php global variable initialisation to Setup.php.
** Moved MemcachedSessions.php initialisation to the caller in GlobalFunctions.php.
** Moved Sanitizer.php constants and global variables to static class members. Introduced an accessor function for the attribs regex, as a new place to put code formerly at file level.
** Moved Language.php initialisation of $wgLanguageNames to Language::getLanguageNames(). Removed the global variable, marked "private" since forever.
* In two places: don't use error_log() with type=3 to append to a file, HipHop doesn't support it. Use file_put_contents() with FILE_APPEND instead.
* Work around the terrible breakage of class_exists() by using MWInit::classExists() instead in various places. In WebInstaller::getPageByName(), the class_exists() was marked with a fixme comment already, so I replaced it with an autoloader solution.
2011-04-04 12:59:55 +00:00
if ( ! MWInit :: classExists ( $className ) ) {
2010-09-04 13:48:16 +00:00
The beginnings of HipHop compiled mode support. It works now for parser cache hits.
* Work around HipHop issue 314 (volatile broken) and issue 308 (no compilation detection) by adding some large and ugly compilation detection code to WebStart.php and doMaintenance.php.
* Provide an MW_COMPILED constant which can be used to detect compiled mode throughout the codebase.
* Introduced wfIsHipHop(), which detects either compiled or interpreted mode. Used this to work around unusual eval() return value in eval.php.
* Work around lack of ini_get() in Maintenance.php, by duplicating wfIsHipHop().
* In Maintenance::shouldExecute(), accept "include" as an inclusion function name, since all kinds of inclusion give this string in HipHop.
* Introduced new class MWInit, which provides some static functions in the pre-autoloader environment.
* Introduced MWInit::compiledPath(), which provides a relative path for invoking a compiled file, and MWInit::interpretedPath(), which provides an absolute path for interpreting a PHP file. Used these new functions in the appropriate places.
* When we are running compiled code, don't include files which would generate duplicate class, function or constant definitions. Documented the new requirements on the contents of Defines.php and UtfNormalDefines.php.
* In HipHop compiled mode, it's not possible to have executable code in the same file as a class definition.
** Moved MimeMagic initialisation to the constructor.
** Moved Namespace.php global variable initialisation to Setup.php.
** Moved MemcachedSessions.php initialisation to the caller in GlobalFunctions.php.
** Moved Sanitizer.php constants and global variables to static class members. Introduced an accessor function for the attribs regex, as a new place to put code formerly at file level.
** Moved Language.php initialisation of $wgLanguageNames to Language::getLanguageNames(). Removed the global variable, marked "private" since forever.
* In two places: don't use error_log() with type=3 to append to a file, HipHop doesn't support it. Use file_put_contents() with FILE_APPEND instead.
* Work around the terrible breakage of class_exists() by using MWInit::classExists() instead in various places. In WebInstaller::getPageByName(), the class_exists() was marked with a fixme comment already, so I replaced it with an autoloader solution.
2011-04-04 12:59:55 +00:00
if ( ! defined ( 'MW_COMPILED' ) ) {
// Preload base classes to work around APC/PHP5 bug
$deps = " { $wgStyleDirectory } / { $skinName } .deps.php " ;
if ( file_exists ( $deps ) ) {
include_once ( $deps );
}
require_once ( " { $wgStyleDirectory } / { $skinName } .php " );
2010-02-01 13:52:55 +00:00
}
2007-12-14 06:53:15 +00:00
# Check if we got if not failback to default skin
The beginnings of HipHop compiled mode support. It works now for parser cache hits.
* Work around HipHop issue 314 (volatile broken) and issue 308 (no compilation detection) by adding some large and ugly compilation detection code to WebStart.php and doMaintenance.php.
* Provide an MW_COMPILED constant which can be used to detect compiled mode throughout the codebase.
* Introduced wfIsHipHop(), which detects either compiled or interpreted mode. Used this to work around unusual eval() return value in eval.php.
* Work around lack of ini_get() in Maintenance.php, by duplicating wfIsHipHop().
* In Maintenance::shouldExecute(), accept "include" as an inclusion function name, since all kinds of inclusion give this string in HipHop.
* Introduced new class MWInit, which provides some static functions in the pre-autoloader environment.
* Introduced MWInit::compiledPath(), which provides a relative path for invoking a compiled file, and MWInit::interpretedPath(), which provides an absolute path for interpreting a PHP file. Used these new functions in the appropriate places.
* When we are running compiled code, don't include files which would generate duplicate class, function or constant definitions. Documented the new requirements on the contents of Defines.php and UtfNormalDefines.php.
* In HipHop compiled mode, it's not possible to have executable code in the same file as a class definition.
** Moved MimeMagic initialisation to the constructor.
** Moved Namespace.php global variable initialisation to Setup.php.
** Moved MemcachedSessions.php initialisation to the caller in GlobalFunctions.php.
** Moved Sanitizer.php constants and global variables to static class members. Introduced an accessor function for the attribs regex, as a new place to put code formerly at file level.
** Moved Language.php initialisation of $wgLanguageNames to Language::getLanguageNames(). Removed the global variable, marked "private" since forever.
* In two places: don't use error_log() with type=3 to append to a file, HipHop doesn't support it. Use file_put_contents() with FILE_APPEND instead.
* Work around the terrible breakage of class_exists() by using MWInit::classExists() instead in various places. In WebInstaller::getPageByName(), the class_exists() was marked with a fixme comment already, so I replaced it with an autoloader solution.
2011-04-04 12:59:55 +00:00
if ( ! MWInit :: classExists ( $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' ;
The beginnings of HipHop compiled mode support. It works now for parser cache hits.
* Work around HipHop issue 314 (volatile broken) and issue 308 (no compilation detection) by adding some large and ugly compilation detection code to WebStart.php and doMaintenance.php.
* Provide an MW_COMPILED constant which can be used to detect compiled mode throughout the codebase.
* Introduced wfIsHipHop(), which detects either compiled or interpreted mode. Used this to work around unusual eval() return value in eval.php.
* Work around lack of ini_get() in Maintenance.php, by duplicating wfIsHipHop().
* In Maintenance::shouldExecute(), accept "include" as an inclusion function name, since all kinds of inclusion give this string in HipHop.
* Introduced new class MWInit, which provides some static functions in the pre-autoloader environment.
* Introduced MWInit::compiledPath(), which provides a relative path for invoking a compiled file, and MWInit::interpretedPath(), which provides an absolute path for interpreting a PHP file. Used these new functions in the appropriate places.
* When we are running compiled code, don't include files which would generate duplicate class, function or constant definitions. Documented the new requirements on the contents of Defines.php and UtfNormalDefines.php.
* In HipHop compiled mode, it's not possible to have executable code in the same file as a class definition.
** Moved MimeMagic initialisation to the constructor.
** Moved Namespace.php global variable initialisation to Setup.php.
** Moved MemcachedSessions.php initialisation to the caller in GlobalFunctions.php.
** Moved Sanitizer.php constants and global variables to static class members. Introduced an accessor function for the attribs regex, as a new place to put code formerly at file level.
** Moved Language.php initialisation of $wgLanguageNames to Language::getLanguageNames(). Removed the global variable, marked "private" since forever.
* In two places: don't use error_log() with type=3 to append to a file, HipHop doesn't support it. Use file_put_contents() with FILE_APPEND instead.
* Work around the terrible breakage of class_exists() by using MWInit::classExists() instead in various places. In WebInstaller::getPageByName(), the class_exists() was marked with a fixme comment already, so I replaced it with an autoloader solution.
2011-04-04 12:59:55 +00:00
if ( ! defined ( 'MW_COMPILED' ) ) {
require_once ( " { $wgStyleDirectory } /Vector.php " );
}
2007-12-14 06:53:15 +00:00
}
2005-12-19 23:36:43 +00:00
}
2006-07-11 14:11:23 +00:00
$skin = new $className ;
2005-12-19 23:36:43 +00:00
return $skin ;
}
2003-04-14 23:10:40 +00:00
2005-03-03 17:17:03 +00:00
/** @return string skin name */
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
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
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-04-03 12:46:36 +00:00
if ( $this -> getTitle () -> getNamespace () == NS_SPECIAL ) {
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
*
* @ return Integer
*/
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
*
* @ return Boolean
*/
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 ()
* @ param $t Title object to use
*/
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 () {
if ( isset ( $this -> mRelevantTitle ) ) {
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 ()
* @ param $u User object to use
*/
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 () {
if ( isset ( $this -> mRelevantUser ) ) {
return $this -> mRelevantUser ;
}
$title = $this -> getRelevantTitle ();
if ( $title -> getNamespace () == NS_USER || $title -> getNamespace () == NS_USER_TALK ) {
$rootUser = strtok ( $title -> getText (), '/' );
if ( User :: isIP ( $rootUser ) ) {
$this -> mRelevantUser = User :: newFromName ( $rootUser , false );
} else {
$user = User :: newFromName ( $rootUser );
if ( $user -> isLoggedIn () ) {
$this -> mRelevantUser = $user ;
}
}
return $this -> mRelevantUser ;
}
return null ;
}
2010-02-01 13:52:55 +00:00
/**
* Outputs the HTML generated by other functions .
2011-06-26 23:40:43 +00:00
* @ param $out OutputPage
2010-02-01 13:52:55 +00:00
*/
2011-04-04 00:42:52 +00:00
abstract function outputPage ( OutputPage $out );
2010-09-04 13:48:16 +00:00
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
}
2008-08-10 07:14:08 +00:00
/**
2010-02-01 13:52:55 +00:00
* Generated JavaScript action = raw & gen = js
2011-05-02 17:30:17 +00:00
* This used to load MediaWiki : Common . js and the skin - specific style
2011-05-02 17:39:29 +00:00
* before the ResourceLoader .
2006-11-17 02:05:34 +00:00
*
2011-05-06 21:50:18 +00:00
* @ deprecated since 1.18 Use the ResourceLoader instead . This may be removed at some
2011-05-02 17:30:17 +00:00
* point .
2010-02-01 13:52:55 +00:00
* @ param $skinName String : If set , overrides the skin name
2011-05-02 17:30:17 +00:00
* @ return String
2004-09-02 23:28:24 +00:00
*/
2009-09-10 06:43:01 +00:00
public function generateUserJs ( $skinName = null ) {
2010-09-11 03:26:15 +00:00
return '' ;
2007-04-21 14:44:56 +00:00
}
2004-07-16 20:50:16 +00:00
2008-08-10 07:14:08 +00:00
/**
2009-03-29 12:46:11 +00:00
* Generate user stylesheet for action = raw & gen = css
2011-05-02 17:30:17 +00:00
*
2011-05-06 21:50:18 +00:00
* @ deprecated since 1.18 Use the ResourceLoader instead . This may be removed at some
2011-05-02 17:30:17 +00:00
* point .
* @ return String
2008-08-10 07:14:08 +00:00
*/
2008-08-21 14:09:57 +00:00
public function generateUserStylesheet () {
2010-09-11 03:26:15 +00:00
return '' ;
2003-04-14 23:10:40 +00:00
}
2008-06-19 18:18:57 +00:00
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 .
2008-08-21 14:09:57 +00:00
* @ param $out OutputPage
2011-02-04 04:18:05 +00:00
* @ 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
* @ param $title Title
* @ return String
*/
2008-08-10 20:10:37 +00:00
function getPageClasses ( $title ) {
2011-07-11 10:57:01 +00:00
global $wgRequest ;
2010-02-01 13:52:55 +00:00
$numeric = 'ns-' . $title -> getNamespace ();
2010-09-04 13:48:16 +00:00
if ( $title -> getNamespace () == NS_SPECIAL ) {
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-07-11 10:57:01 +00:00
if ( $wgRequest -> getVal ( 'action' ) ) {
$action = 'action-' . $wgRequest -> getVal ( 'action' );
} else {
$action = 'action-view' ;
}
return " $numeric $type $name $action " ;
2008-08-10 19:48:30 +00:00
}
2010-10-04 05:38:48 +00:00
2010-10-03 14:12:41 +00:00
/**
* This will be called by OutputPage :: headElement when it is creating the
* < body > tag , skins can override it if they have a need to add in any
* body attributes or classes of their own .
2011-06-26 23:40:43 +00:00
* @ param $out OutputPage
* @ param $bodyAttrs Array
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
2011-06-26 23:40:43 +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-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 = '' ;
2008-03-06 18:54:22 +00:00
$colon = wfMsgExt ( 'colon-separator' , 'escapenoentities' );
2010-09-04 13:48:16 +00:00
2008-02-25 16:38:25 +00:00
if ( ! empty ( $allCats [ 'normal' ] ) ) {
2011-07-14 11:42:14 +00:00
$t = $embed . implode ( " { $pop } { $embed } " , $allCats [ 'normal' ] ) . $pop ;
2008-04-14 07:45:50 +00:00
2008-03-06 18:54:22 +00:00
$msg = wfMsgExt ( 'pagecategories' , array ( 'parsemag' , 'escapenoentities' ), count ( $allCats [ 'normal' ] ) );
2008-02-25 16:38:25 +00:00
$s .= '<div id="mw-normal-catlinks">' .
2011-04-16 20:01:39 +00:00
Linker :: link ( Title :: newFromText ( wfMsgForContent ( 'pagecategorieslink' ) ), $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' ) ) {
2010-09-04 13:48:16 +00:00
$class = 'mw-hidden-cats-user-shown' ;
2011-04-03 12:46:36 +00:00
} elseif ( $this -> getTitle () -> getNamespace () == NS_CATEGORY ) {
2008-02-25 16:38:25 +00:00
$class = 'mw-hidden-cats-ns-shown' ;
} else {
$class = 'mw-hidden-cats-hidden' ;
}
2010-09-04 13:48:16 +00:00
2008-04-14 07:45:50 +00:00
$s .= " <div id= \" mw-hidden-catlinks \" class= \" $class\ " > " .
wfMsgExt ( 'hidden-categories' , array ( 'parsemag' , 'escapenoentities' ), count ( $allCats [ 'hidden' ] ) ) .
2011-07-14 11:42:14 +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
/**
* Render the array as a serie of links .
2006-11-08 07:12:03 +00:00
* @ param $tree Array : categories tree returned by Title :: getParentCategoryTree
2006-04-19 15:46:24 +00:00
* @ return String separated by & gt ;, 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 );
2011-07-24 17:05:42 +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-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 .
*
2011-06-26 23:40:43 +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 .
* @ return String HTML containing debug data , if enabled ( otherwise empty ) .
*/
2011-05-04 10:43:40 +00:00
protected function generateDebugHTML () {
2011-03-03 10:22:46 +00:00
global $wgShowDebug ;
2010-09-04 13:48:16 +00:00
2009-02-08 23:39:17 +00:00
if ( $wgShowDebug ) {
2011-07-18 20:52:22 +00:00
$listInternals = $this -> formatDebugHTML ( $this -> getOutput () -> mDebugtext );
2011-03-26 13:27:50 +00:00
return " \n <hr /> \n <strong>Debug data:</strong><ul id= \" mw-debug-html \" > " .
2009-09-17 18:55:29 +00:00
$listInternals . " </ul> \n " ;
2009-02-08 23:39:17 +00:00
}
2010-09-04 13:48:16 +00:00
2009-02-08 23:39:17 +00:00
return '' ;
}
2009-09-17 18:55:29 +00:00
private function formatDebugHTML ( $debugText ) {
2011-03-07 18:21:58 +00:00
global $wgDebugTimestamps ;
2009-09-17 18:55:29 +00:00
$lines = explode ( " \n " , $debugText );
$curIdent = 0 ;
$ret = '<li>' ;
2010-09-04 13:48:16 +00:00
foreach ( $lines as $line ) {
2011-03-07 18:21:58 +00:00
$pre = '' ;
if ( $wgDebugTimestamps ) {
$matches = array ();
if ( preg_match ( '/^(\d+\.\d+\s{2})/' , $line , $matches ) ) {
$pre = $matches [ 1 ];
$line = substr ( $line , strlen ( $pre ) );
}
}
2009-09-17 18:55:29 +00:00
$display = ltrim ( $line );
$ident = strlen ( $line ) - strlen ( $display );
$diff = $ident - $curIdent ;
2011-03-07 18:21:58 +00:00
$display = $pre . $display ;
2010-02-01 13:52:55 +00:00
if ( $display == '' ) {
2009-09-17 18:55:29 +00:00
$display = " \xc2 \xa0 " ;
2010-02-01 13:52:55 +00:00
}
2009-09-17 18:55:29 +00:00
if ( ! $ident && $diff < 0 && substr ( $display , 0 , 9 ) != 'Entering ' && substr ( $display , 0 , 8 ) != 'Exiting ' ) {
$ident = $curIdent ;
$diff = 0 ;
$display = '<span style="background:yellow;">' . htmlspecialchars ( $display ) . '</span>' ;
} else {
$display = htmlspecialchars ( $display );
}
2010-02-01 13:52:55 +00:00
if ( $diff < 0 ) {
2009-09-21 20:31:33 +00:00
$ret .= str_repeat ( " </li></ul> \n " , - $diff ) . " </li><li> \n " ;
2010-02-01 13:52:55 +00:00
} elseif ( $diff == 0 ) {
2009-09-17 18:55:29 +00:00
$ret .= " </li><li> \n " ;
2010-02-01 13:52:55 +00:00
} else {
2009-09-17 18:55:29 +00:00
$ret .= str_repeat ( " <ul><li> \n " , $diff );
2010-02-01 13:52:55 +00:00
}
2011-03-26 13:27:50 +00:00
$ret .= " <tt> $display </tt> \n " ;
2009-10-17 10:35:46 +00:00
2009-09-17 18:55:29 +00:00
$curIdent = $ident ;
}
2010-09-04 13:48:16 +00:00
2009-09-17 18:55:29 +00:00
$ret .= str_repeat ( '</li></ul>' , $curIdent ) . '</li>' ;
2010-09-04 13:48:16 +00:00
2009-09-17 18:55:29 +00:00
return $ret ;
}
2006-07-29 22:34:22 +00:00
/**
2008-08-21 14:09:57 +00:00
* This gets called shortly before the </ body > tag .
2011-07-24 17:05:42 +00:00
*
2008-08-21 14:09:57 +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
}
2005-03-03 17:17:03 +00:00
/** @return string Retrievied from HTML text */
2004-08-09 00:22:43 +00:00
function printSource () {
2011-04-03 12:46:36 +00:00
$url = htmlspecialchars ( $this -> getTitle () -> getFullURL () );
2010-02-01 13:52:55 +00:00
return wfMsg ( 'retrievedfrom' , '<a href="' . $url . '">' . $url . '</a>' );
2004-08-09 00:22:43 +00:00
}
2004-08-09 05:38:11 +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-07-18 20:52:22 +00:00
if ( $this -> getUser () -> isAllowed ( 'deletedhistory' ) &&
2011-04-03 12:46:36 +00:00
( $this -> getTitle () -> getArticleId () == 0 || $action == 'history' ) ) {
2011-07-06 16:47:29 +00:00
2011-07-18 20:52:22 +00:00
$includeSuppressed = $this -> getUser () -> isAllowed ( 'suppressrevision' );
2011-07-06 16:47:29 +00:00
$n = $this -> getTitle () -> isDeleted ( $includeSuppressed );
2010-09-04 13:48:16 +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
2009-06-07 15:02:12 +00:00
return wfMsg (
$msg ,
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-07-24 17:05:42 +00:00
wfMsgExt ( 'restorelink' , array ( 'parsemag' , 'escape' ), $this -> getLang () -> formatNum ( $n ) )
2009-06-07 15:02:12 +00:00
)
);
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-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 = '' ;
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
if ( is_object ( $linkObj ) && $linkObj -> exists () ) {
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 ) {
2009-03-29 12:46:11 +00:00
$subpages .= wfMsgExt ( 'pipe-separator' , 'escapenoentities' );
2003-04-14 23:10:40 +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
2011-06-26 23:40:43 +00:00
* @ return Bool
2007-02-05 21:42:48 +00:00
*/
function showIPinHeader () {
global $wgShowIPinHeader ;
return $wgShowIPinHeader && session_id () != '' ;
}
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
2004-04-24 06:25:19 +00:00
function escapeSearchLink () {
return htmlspecialchars ( $this -> getSearchLink () );
}
2004-07-16 20:50:16 +00:00
2006-03-16 02:47:49 +00:00
function getCopyright ( $type = 'detect' ) {
2011-04-03 12:46:36 +00:00
global $wgRightsPage , $wgRightsUrl , $wgRightsText ;
2004-07-16 20:50:16 +00:00
2006-03-16 02:47:49 +00:00
if ( $type == 'detect' ) {
2011-07-18 20:52:22 +00:00
$diff = $this -> getRequest () -> getVal ( 'diff' );
2010-09-04 13:48:16 +00:00
2011-01-11 13:04:55 +00:00
if ( is_null ( $diff ) && ! $this -> isRevisionCurrent () && wfMsgForContent ( 'history_copyright' ) !== '-' ) {
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
2004-06-09 01:18:04 +00:00
$out = '' ;
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
return $out ;
}
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.
2010-07-21 16:01:10 +00:00
$forContent = true ;
2010-09-04 13:48:16 +00:00
2011-04-03 12:46:36 +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
2010-07-21 16:01:10 +00:00
if ( $forContent ) {
$out .= wfMsgForContent ( $msg , $link );
} else {
$out .= wfMsg ( $msg , $link );
}
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
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 " );
2010-11-10 08:18:21 +00:00
$text = '<a href="http://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
*
* @ param $article Article object . Used if we ' re working with the current revision
* @ return String
*/
protected function lastModified ( $article ) {
2011-01-11 13:04:55 +00:00
if ( ! $this -> isRevisionCurrent () ) {
2011-05-02 15:26:19 +00:00
$timestamp = Revision :: getTimestampFromId ( $this -> getTitle (), $this -> getRevisionId () );
2008-07-06 11:01:32 +00:00
} else {
2011-01-26 17:06:18 +00:00
$timestamp = $article -> getTimestamp ();
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-07-18 20:52:22 +00:00
$d = $this -> getLang () -> date ( $timestamp , true );
$t = $this -> getLang () -> time ( $timestamp , true );
2006-09-21 18:29:54 +00:00
$s = ' ' . wfMsg ( 'lastmodifiedat' , $d , $t );
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 () ) {
2005-01-15 10:40:46 +00:00
$s .= ' <strong>' . wfMsg ( 'laggedslavemode' ) . '</strong>' ;
}
2010-09-04 13:48:16 +00:00
2003-04-14 23:10:40 +00:00
return $s ;
}
2004-09-02 00:25:56 +00:00
function logoText ( $align = '' ) {
2010-01-06 19:59:42 +00:00
if ( $align != '' ) {
2009-03-29 12:46:11 +00:00
$a = " align=' { $align } ' " ;
} else {
$a = '' ;
}
2004-07-16 20:50:16 +00:00
2011-07-24 17:05:42 +00:00
$mp = wfMsgHtml ( 'mainpage' );
2006-12-03 00:22:14 +00:00
$mptitle = Title :: newMainPage ();
2009-03-29 12:46:11 +00:00
$url = ( is_object ( $mptitle ) ? $mptitle -> escapeLocalURL () : '' );
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
/**
* Renders a $wgFooterIcons icon acording to the method ' s arguments
2010-12-05 10:58:13 +00:00
* @ param $icon Array : The icon to build the html for , see $wgFooterIcons for the format of this array
2011-06-26 23:40:43 +00:00
* @ param $withImage Bool | String : Whether to use the icon ' s image or output a text - only footericon
* @ 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
2011-02-03 00:00:58 +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' ) {
2010-12-05 04:44:28 +00:00
$html = Html :: element ( 'img' , $icon ); // do this the lazy way, just pass icon data as an attribute array
} 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:05:42 +00:00
$s = Linker :: linkKown (
2009-06-07 15:02:12 +00:00
Title :: newMainPage (),
2011-07-24 17:05:42 +00:00
wfMsgHtml ( 'mainpage' )
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 ;
}
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,
2010-09-04 13:48:16 +00:00
if ( wfMsgForContent ( $desc ) == '-' ) {
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.
2009-06-15 11:27:48 +00:00
$title = Title :: newFromText ( wfMsgForContent ( $page ) );
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 ,
wfMsgExt ( $desc , array ( 'parsemag' , 'escapenoentities' ) )
);
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 .
2011-06-26 23:40:43 +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 .
2011-06-26 23:40:43 +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 .
2011-06-26 23:40:43 +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
2004-11-25 06:20:01 +00:00
function showEmailUser ( $id ) {
2008-10-17 22:20:07 +00:00
$targetUser = User :: newFromId ( $id );
2011-07-18 20:52:22 +00:00
return $this -> getUser () -> canSendEmail () && # the sending user must have a confirmed email address
2008-10-17 22:20:07 +00:00
$targetUser -> canReceiveEmail (); # the target user must have a confirmed email address and allow emails from users
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 .
2010-12-16 18:30:15 +00:00
* @ param $name String : The name or path of a skin resource file
2010-12-05 04:22:29 +00:00
* @ return String The fully resolved style path url including styleversion
*/
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
/**
* Return a fully resolved style path url to images or styles stored in the curent skins ' s folder .
* This method returns a url resolved using the configured skin style path
* and includes the style version inside of the url .
2010-12-16 18:30:15 +00:00
* @ param $name String : The name or path of a skin resource file
2010-12-05 04:22:29 +00:00
* @ return String The fully resolved style path url including styleversion
*/
2010-12-04 17:00:34 +00:00
function getSkinStylePath ( $name ) {
2010-12-04 14:45:14 +00:00
global $wgStylePath , $wgStyleVersion ;
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 */
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 );
}
2006-09-22 13:07:06 +00:00
static function makeSpecialUrl ( $name , $urlaction = '' ) {
2011-04-17 11:31:11 +00:00
$title = SpecialPage :: getSafeTitleFor ( $name );
2004-05-05 12:01:54 +00:00
return $title -> getLocalURL ( $urlaction );
}
2005-07-03 04:00:33 +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 );
}
2006-09-22 13:07:06 +00:00
static function makeI18nUrl ( $name , $urlaction = '' ) {
$title = Title :: newFromText ( wfMsgForContent ( $name ) );
self :: checkTitle ( $title , $name );
2004-05-05 12:01:54 +00:00
return $title -> getLocalURL ( $urlaction );
}
2005-07-03 04:00:33 +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
2011-06-26 23:40:43 +00:00
* @ param $name String
* @ return String URL
2010-02-01 13:52:55 +00:00
*/
2006-09-22 13:07:06 +00:00
static function makeInternalOrExternalUrl ( $name ) {
2005-10-30 11:24:43 +00:00
if ( preg_match ( '/^(?:' . 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
}
}
2004-06-03 01:29:02 +00:00
# this can be passed the NS number as defined in Language.php
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
2004-05-13 19:44:13 +00:00
/* these return an array with the 'href' and boolean 'exists' */
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 )
2011-06-26 23:40:43 +00:00
* @ param $name String Article name
* @ param $urlaction String
* @ 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
);
}
2004-05-15 03:38:35 +00:00
# make sure we have some title to operate on
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
/**
* Build an array that represents the sidebar ( s ), the navigation bar among them
*
* @ return array
2005-07-03 04:00:33 +00:00
*/
2005-06-28 14:18:08 +00:00
function buildSidebar () {
2008-02-09 09:11:45 +00:00
global $parserMemc , $wgEnableSidebarCache , $wgSidebarCacheExpiry ;
2008-06-03 20:24:00 +00:00
wfProfileIn ( __METHOD__ );
2005-07-03 04:00:33 +00:00
2011-07-18 20:52:22 +00:00
$key = wfMemcKey ( 'sidebar' , $this -> getLang () -> getCode () );
2008-04-14 07:45:50 +00:00
2008-06-03 20:24:00 +00:00
if ( $wgEnableSidebarCache ) {
2006-04-14 08:26:35 +00:00
$cachedsidebar = $parserMemc -> get ( $key );
2008-06-03 20:24:00 +00:00
if ( $cachedsidebar ) {
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 ) {
$parserMemc -> set ( $key , $bar , $wgSidebarCacheExpiry );
}
2010-09-04 13:48:16 +00:00
2009-11-18 21:06:54 +00:00
wfProfileOut ( __METHOD__ );
return $bar ;
}
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
*
2010-06-29 06:39:32 +00:00
* @ param & $bar array
* @ param $message String
*/
function addToSidebar ( & $bar , $message ) {
2011-02-19 13:39:09 +00:00
$this -> addToSidebarPlain ( $bar , wfMsgForContentNoTrans ( $message ) );
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
2010-02-25 15:58:29 +00:00
* @ param & $bar array
* @ param $text string
2011-06-26 23:40:43 +00:00
* @ 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
$wikiBar = array (); # We need to handle the wikitext on a different variable, to avoid trying to do an array operation on text, which would be a fatal error.
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
}
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 ) );
2011-06-26 19:52:11 +00:00
$extraAttribs = array ();
2010-09-04 13:48:16 +00:00
2011-05-23 16:32:52 +00:00
$msgLink = wfMessage ( $line [ 0 ] ) -> inContentLanguage ();
if ( $msgLink -> exists () ) {
$link = $msgLink -> text ();
if ( $link == '-' ) {
continue ;
}
} else {
$link = $line [ 0 ];
2010-02-01 13:52:55 +00:00
}
2008-12-19 08:54:51 +00:00
2011-05-23 16:32:52 +00:00
$msgText = wfMessage ( $line [ 1 ] );
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
2006-10-30 06:25:31 +00:00
if ( preg_match ( '/^(?:' . wfUrlProtocols () . ')/' , $link ) ) {
$href = $link ;
2011-06-26 19:52:11 +00:00
//Parser::getExternalLinkAttribs won't work here because of the Namespace things
global $wgNoFollowLinks ;
if ( $wgNoFollowLinks ) {
$extraAttribs [ 'rel' ] = 'nofollow' ;
global $wgNoFollowDomainExceptions ;
if ( $wgNoFollowDomainExceptions ) {
$bits = wfParseUrl ( $url );
if ( is_array ( $bits ) && isset ( $bits [ 'host' ] ) ) {
foreach ( $wgNoFollowDomainExceptions as $domain ) {
if ( substr ( $bits [ 'host' ], - strlen ( $domain ) ) == $domain ) {
unset ( $extraAttribs [ 'rel' ] );
break ;
}
}
}
}
}
global $wgExternalLinkTarget ;
if ( $wgExternalLinkTarget ) {
$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 ();
$href = $title -> getLocalURL ();
} 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 );
2011-06-17 16:05:05 +00:00
} elseif ( ( substr ( $line , 0 , 2 ) == '{{' ) && ( substr ( $line , - 2 ) == '}}' ) ) {
2011-02-19 13:39:09 +00:00
global $wgParser ;
2010-09-04 01:06:34 +00:00
2010-09-04 13:48:16 +00:00
$line = substr ( $line , 2 , strlen ( $line ) - 4 );
2010-09-04 01:06:34 +00:00
2010-10-15 23:16:11 +00:00
$options = new ParserOptions ();
$options -> setEditSection ( false );
$options -> setInterfaceMessage ( true );
2011-04-03 12:46:36 +00:00
$wikiBar [ $heading ] = $wgParser -> parse ( wfMsgForContentNoTrans ( $line ) , $this -> getTitle (), $options ) -> getText ();
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-09-04 13:48:16 +00:00
if ( count ( $wikiBar ) > 0 ) {
$bar = array_merge ( $bar , $wikiBar );
}
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
/**
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
* Should we include common / wikiprintable . css ? Skins that have their own
* print stylesheet should override this and return false . ( This is an
* ugly hack to get Monobook to play nicely with
2009-07-07 21:49:45 +00:00
* OutputPage :: headElement () . )
*
* @ return bool
*/
public function commonPrintStylesheet () {
return true ;
}
2010-03-23 16:11:37 +00:00
/**
* Gets new talk page messages for the current user .
* @ return MediaWiki message or if no new talk page messages , nothing
*/
2011-04-03 12:46:36 +00:00
function getNewtalks () {
2011-07-18 20:52:22 +00:00
$out = $this -> getOutput ();
2010-09-04 13:48:16 +00:00
2011-07-18 20:52:22 +00:00
$newtalks = $this -> getUser () -> getNewMessageLinks ();
2010-04-20 08:14:47 +00:00
$ntl = '' ;
2010-03-23 16:11:37 +00:00
2010-09-04 13:48:16 +00:00
if ( count ( $newtalks ) == 1 && $newtalks [ 0 ][ 'wiki' ] === wfWikiID () ) {
2011-04-03 23:38:44 +00:00
$userTitle = $this -> getUser () -> getUserPage ();
2010-03-23 16:11:37 +00:00
$userTalkTitle = $userTitle -> getTalkPage ();
2011-03-03 10:22:46 +00:00
if ( ! $userTalkTitle -> equals ( $out -> getTitle () ) ) {
2011-07-24 17:05:42 +00:00
$newMessagesLink = Linker :: linkKown (
2010-03-23 16:11:37 +00:00
$userTalkTitle ,
wfMsgHtml ( 'newmessageslink' ),
array (),
2011-07-24 17:05:42 +00:00
array ( 'redirect' => 'no' )
2010-03-23 16:11:37 +00:00
);
2011-07-24 17:05:42 +00:00
$newMessagesDiffLink = Linker :: linkKown (
2010-03-23 16:11:37 +00:00
$userTalkTitle ,
wfMsgHtml ( 'newmessagesdifflink' ),
array (),
2011-07-24 17:05:42 +00:00
array ( 'diff' => 'cur' )
2010-03-23 16:11:37 +00:00
);
$ntl = wfMsg (
'youhavenewmessages' ,
$newMessagesLink ,
$newMessagesDiffLink
);
# Disable Squid cache
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
} elseif ( count ( $newtalks ) ) {
2010-03-23 16:11:37 +00:00
// _>" " for BC <= 1.16
$sep = str_replace ( '_' , ' ' , wfMsgHtml ( 'newtalkseparator' ) );
$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 );
$ntl = wfMsgHtml ( 'youhavenewmessagesmulti' , $parts );
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
2010-03-23 16:11:37 +00:00
return $ntl ;
}
2011-02-12 21:24:05 +00:00
/**
* Get a cached notice
*
* @ param $name String : message name , or 'default' for $wgSiteNotice
* @ return String : HTML fragment
*/
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 ;
if ( $name === 'default' ) {
// special case
global $wgSiteNotice ;
$notice = $wgSiteNotice ;
if ( empty ( $notice ) ) {
wfProfileOut ( __METHOD__ );
return false ;
}
} else {
$msg = wfMessage ( $name ) -> inContentLanguage ();
if ( $msg -> isDisabled () ) {
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 );
if ( is_array ( $cachedNotice ) ) {
if ( md5 ( $notice ) == $cachedNotice [ 'hash' ] ) {
$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' ,
'lang' => $wgContLang -> getCode (), 'dir' => $wgContLang -> getDir () ), $notice );
2011-02-12 21:24:05 +00:00
wfProfileOut ( __METHOD__ );
return $notice ;
}
/**
* Get a notice based on page ' s namespace
*
* @ return String : HTML fragment
*/
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
*
* @ return String : HTML fragment
*/
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 () .
*
* @ param $nt Title The title being linked to ( may not be the same as
* $wgTitle , if the section is included from a template )
* @ param $section string The designation of the section being pointed to ,
* to be included in the link , like " §ion= $section "
* @ param $tooltip string The tooltip to use for the link : will be escaped
* and wrapped in the 'editsectionhint' message
* @ param $lang string Language code
* @ return string HTML to use for edit link
*/
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
$attribs = array ();
if ( ! is_null ( $tooltip ) ) {
# Bug 25462: undo double-escaping.
$tooltip = Sanitizer :: decodeCharReferences ( $tooltip );
2011-04-22 21:05:47 +00:00
$attribs [ 'title' ] = wfMsgExt ( 'editsectionhint' , array ( 'language' => $lang , 'parsemag' ), $tooltip );
2011-04-03 11:44:11 +00:00
}
$link = Linker :: link ( $nt , wfMsgExt ( 'editsection' , array ( 'language' => $lang ) ),
$attribs ,
array ( 'action' => 'edit' , 'section' => $section ),
array ( 'noclasses' , 'known' )
);
# Run the old hook. This takes up half of the function . . . hopefully
# we can rid of it someday.
$attribs = '' ;
if ( $tooltip ) {
2011-04-22 21:05:47 +00:00
$attribs = wfMsgExt ( 'editsectionhint' , array ( 'language' => $lang , 'parsemag' , 'escape' ), $tooltip );
2011-04-03 11:44:11 +00:00
$attribs = " title= \" $attribs\ " " ;
}
$result = null ;
wfRunHooks ( 'EditSectionLink' , array ( & $this , $nt , $section , $attribs , $link , & $result , $lang ) );
if ( ! is_null ( $result ) ) {
# For reverse compatibility, add the brackets *after* the hook is
# run, and even add them to hook-provided text. (This is the main
# reason that the EditSectionLink hook is deprecated in favor of
# DoEditSectionLink: it can't change the brackets or the span.)
$result = wfMsgExt ( 'editsection-brackets' , array ( 'escape' , 'replaceafter' , 'language' => $lang ), $result );
return " <span class= \" editsection \" > $result </span> " ;
}
# Add the brackets and the span, and *then* run the nice new hook, with
# clean and non-redundant arguments.
$result = wfMsgExt ( 'editsection-brackets' , array ( 'escape' , 'replaceafter' , 'language' => $lang ), $link );
$result = " <span class= \" editsection \" > $result </span> " ;
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 .
*
* @ param $fname String Name of called method
* @ param $args Array Arguments to the method
*/
function __call ( $fname , $args ) {
2011-04-04 03:42:34 +00:00
$realFunction = array ( 'Linker' , $fname );
if ( is_callable ( $realFunction ) ) {
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
}