2004-02-18 02:15:00 +00:00
|
|
|
<?php
|
2010-05-22 12:18:22 +00:00
|
|
|
if ( !defined( 'MEDIAWIKI' ) ) {
|
2006-06-07 06:40:24 +00:00
|
|
|
die( 1 );
|
2010-05-22 12:18:22 +00:00
|
|
|
}
|
2004-08-12 06:54:58 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* @todo document
|
|
|
|
|
*/
|
2003-04-14 23:10:40 +00:00
|
|
|
class OutputPage {
|
2008-07-25 01:27:51 +00:00
|
|
|
var $mMetatags = array(), $mKeywords = array(), $mLinktags = array();
|
2008-08-10 07:14:08 +00:00
|
|
|
var $mExtStyles = array();
|
2010-07-08 08:12:19 +00:00
|
|
|
var $mPagetitle = '', $mBodytext = '';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Holds the debug lines that will be outputted as comments in page source if
|
|
|
|
|
* $wgDebugComments is enabled. See also $wgShowDebug.
|
|
|
|
|
* TODO: make a getter method for this
|
|
|
|
|
*/
|
|
|
|
|
public $mDebugtext = '';
|
|
|
|
|
|
2010-04-10 13:38:50 +00:00
|
|
|
var $mHTMLtitle = '', $mIsarticle = true, $mPrintable = false;
|
2008-07-25 01:27:51 +00:00
|
|
|
var $mSubtitle = '', $mRedirect = '', $mStatusCode;
|
|
|
|
|
var $mLastModified = '', $mETag = false;
|
2009-11-19 00:37:00 +00:00
|
|
|
var $mCategoryLinks = array(), $mCategories = array(), $mLanguageLinks = array();
|
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-07-25 01:27:51 +00:00
|
|
|
var $mScripts = '', $mLinkColours, $mPageLinkTitle = '', $mHeadItems = array();
|
2010-09-04 04:00:09 +00:00
|
|
|
var $mModules = array(), $mModuleScripts = array(), $mModuleStyles = array(), $mModuleMessages = array();
|
2010-09-29 19:04:04 +00:00
|
|
|
var $mResourceLoader;
|
2009-09-17 01:19:02 +00:00
|
|
|
var $mInlineMsg = array();
|
|
|
|
|
|
2008-07-25 01:27:51 +00:00
|
|
|
var $mTemplateIds = array();
|
2006-05-11 22:40:38 +00:00
|
|
|
|
2007-05-08 20:48:02 +00:00
|
|
|
var $mAllowUserJs;
|
2008-07-25 01:27:51 +00:00
|
|
|
var $mSuppressQuickbar = false;
|
|
|
|
|
var $mDoNothing = false;
|
|
|
|
|
var $mContainsOldMagic = 0, $mContainsNewMagic = 0;
|
|
|
|
|
var $mIsArticleRelated = true;
|
|
|
|
|
protected $mParserOptions = null; // lazy initialised, use parserOptions()
|
2009-11-07 09:26:02 +00:00
|
|
|
|
2009-09-30 17:35:41 +00:00
|
|
|
var $mFeedLinks = array();
|
2009-11-07 09:26:02 +00:00
|
|
|
|
2006-05-11 22:40:38 +00:00
|
|
|
var $mEnableClientCache = true;
|
|
|
|
|
var $mArticleBodyOnly = false;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2006-05-11 22:40:38 +00:00
|
|
|
var $mNewSectionLink = false;
|
2009-02-19 22:14:59 +00:00
|
|
|
var $mHideNewSectionLink = false;
|
2006-06-13 18:35:11 +00:00
|
|
|
var $mNoGallery = false;
|
2007-07-22 14:45:12 +00:00
|
|
|
var $mPageTitleActionText = '';
|
2007-12-10 06:02:29 +00:00
|
|
|
var $mParseWarnings = array();
|
2008-07-25 01:27:51 +00:00
|
|
|
var $mSquidMaxage = 0;
|
|
|
|
|
var $mRevisionId = null;
|
2009-04-09 02:22:36 +00:00
|
|
|
protected $mTitle = null;
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2008-08-21 14:09:57 +00:00
|
|
|
/**
|
|
|
|
|
* An array of stylesheet filenames (relative from skins path), with options
|
|
|
|
|
* for CSS media, IE conditions, and RTL/LTR direction.
|
|
|
|
|
* For internal use; add settings in the skin via $this->addStyle()
|
|
|
|
|
*/
|
|
|
|
|
var $styles = array();
|
|
|
|
|
|
2010-01-23 20:11:42 +00:00
|
|
|
/**
|
|
|
|
|
* Whether to load jQuery core.
|
|
|
|
|
*/
|
2010-01-27 04:17:49 +00:00
|
|
|
protected $mJQueryDone = false;
|
2010-01-23 20:11:42 +00:00
|
|
|
|
2008-07-23 19:05:43 +00:00
|
|
|
private $mIndexPolicy = 'index';
|
|
|
|
|
private $mFollowPolicy = 'follow';
|
2010-05-22 12:18:22 +00:00
|
|
|
private $mVaryHeader = array(
|
|
|
|
|
'Accept-Encoding' => array( 'list-contains=gzip' ),
|
|
|
|
|
'Cookie' => null
|
|
|
|
|
);
|
2010-01-28 21:58:50 +00:00
|
|
|
|
2004-09-17 15:24:43 +00:00
|
|
|
/**
|
|
|
|
|
* Constructor
|
|
|
|
|
* Initialise private variables
|
|
|
|
|
*/
|
2007-01-20 13:34:31 +00:00
|
|
|
function __construct() {
|
2007-05-08 20:48:02 +00:00
|
|
|
global $wgAllowUserJs;
|
|
|
|
|
$this->mAllowUserJs = $wgAllowUserJs;
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2010-01-28 21:58:50 +00:00
|
|
|
/**
|
|
|
|
|
* Redirect to $url rather than displaying the normal page
|
|
|
|
|
*
|
|
|
|
|
* @param $url String: URL
|
|
|
|
|
* @param $responsecode String: HTTP status code
|
|
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function redirect( $url, $responsecode = '302' ) {
|
2006-06-23 03:56:03 +00:00
|
|
|
# Strip newlines as a paranoia check for header injection in PHP<5.1.2
|
|
|
|
|
$this->mRedirect = str_replace( "\n", '', $url );
|
|
|
|
|
$this->mRedirectCode = $responsecode;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2010-01-28 21:58:50 +00:00
|
|
|
/**
|
|
|
|
|
* Get the URL to redirect to, or an empty string if not redirect URL set
|
|
|
|
|
*
|
|
|
|
|
* @return String
|
|
|
|
|
*/
|
2007-11-06 01:16:25 +00:00
|
|
|
public function getRedirect() {
|
|
|
|
|
return $this->mRedirect;
|
|
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2006-11-07 05:37:31 +00:00
|
|
|
/**
|
|
|
|
|
* Set the HTTP status code to send with the output.
|
|
|
|
|
*
|
2010-01-28 21:58:50 +00:00
|
|
|
* @param $statusCode Integer
|
2006-11-07 05:37:31 +00:00
|
|
|
* @return nothing
|
|
|
|
|
*/
|
2010-01-28 21:58:50 +00:00
|
|
|
public function setStatusCode( $statusCode ) {
|
|
|
|
|
$this->mStatusCode = $statusCode;
|
|
|
|
|
}
|
|
|
|
|
|
2008-08-21 14:09:57 +00:00
|
|
|
/**
|
|
|
|
|
* Add a new <meta> tag
|
|
|
|
|
* To add an http-equiv meta tag, precede the name with "http:"
|
|
|
|
|
*
|
|
|
|
|
* @param $name tag name
|
|
|
|
|
* @param $val tag value
|
|
|
|
|
*/
|
|
|
|
|
function addMeta( $name, $val ) {
|
|
|
|
|
array_push( $this->mMetatags, array( $name, $val ) );
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-28 21:58:50 +00:00
|
|
|
/**
|
|
|
|
|
* Add a keyword or a list of keywords in the page header
|
|
|
|
|
*
|
|
|
|
|
* @param $text String or array of strings
|
|
|
|
|
*/
|
2009-05-30 05:07:46 +00:00
|
|
|
function addKeyword( $text ) {
|
2010-01-28 21:58:50 +00:00
|
|
|
if( is_array( $text ) ) {
|
2009-05-30 05:07:46 +00:00
|
|
|
$this->mKeywords = array_merge( $this->mKeywords, $text );
|
2009-07-15 00:55:58 +00:00
|
|
|
} else {
|
2009-05-30 05:07:46 +00:00
|
|
|
array_push( $this->mKeywords, $text );
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-01-28 21:58:50 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add a new \<link\> tag to the page header
|
|
|
|
|
*
|
|
|
|
|
* @param $linkarr Array: associative array of attributes.
|
|
|
|
|
*/
|
|
|
|
|
function addLink( $linkarr ) {
|
|
|
|
|
array_push( $this->mLinktags, $linkarr );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add a new \<link\> with "rel" attribute set to "meta"
|
|
|
|
|
*
|
|
|
|
|
* @param $linkarr Array: associative array mapping attribute names to their
|
|
|
|
|
* values, both keys and values will be escaped, and the
|
|
|
|
|
* "rel" attribute will be automatically added
|
|
|
|
|
*/
|
|
|
|
|
function addMetadataLink( $linkarr ) {
|
|
|
|
|
# note: buggy CC software only reads first "meta" link
|
|
|
|
|
static $haveMeta = false;
|
|
|
|
|
$linkarr['rel'] = $haveMeta ? 'alternate meta' : 'meta';
|
|
|
|
|
$this->addLink( $linkarr );
|
|
|
|
|
$haveMeta = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add raw HTML to the list of scripts (including \<script\> tag, etc.)
|
|
|
|
|
*
|
|
|
|
|
* @param $script String: raw HTML
|
|
|
|
|
*/
|
2009-08-07 00:16:54 +00:00
|
|
|
function addScript( $script ) {
|
2009-08-22 20:15:22 +00:00
|
|
|
$this->mScripts .= $script . "\n";
|
2009-08-07 00:16:54 +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
|
|
|
|
2009-07-26 16:57:45 +00:00
|
|
|
/**
|
2009-08-07 00:16:54 +00:00
|
|
|
* Register and add a stylesheet from an extension directory.
|
2010-01-28 21:58:50 +00:00
|
|
|
*
|
2009-07-26 16:57:45 +00:00
|
|
|
* @param $url String path to sheet. Provide either a full url (beginning
|
|
|
|
|
* with 'http', etc) or a relative path from the document root
|
|
|
|
|
* (beginning with '/'). Otherwise it behaves identically to
|
|
|
|
|
* addStyle() and draws from the /skins folder.
|
|
|
|
|
*/
|
|
|
|
|
public function addExtensionStyle( $url ) {
|
2009-08-11 00:09:24 +00:00
|
|
|
array_push( $this->mExtStyles, $url );
|
2008-08-10 07:14:08 +00:00
|
|
|
}
|
2006-12-08 06:09:15 +00:00
|
|
|
|
2010-01-28 21:58:50 +00:00
|
|
|
/**
|
|
|
|
|
* Get all links added by extensions
|
|
|
|
|
*
|
|
|
|
|
* @return Array
|
|
|
|
|
*/
|
|
|
|
|
function getExtStyle() {
|
|
|
|
|
return $this->mExtStyles;
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-09 20:18:35 +00:00
|
|
|
/**
|
|
|
|
|
* Add a JavaScript file out of skins/common, or a given relative path.
|
2010-01-28 21:58:50 +00:00
|
|
|
*
|
|
|
|
|
* @param $file String: filename in skins/common or complete on-server path
|
|
|
|
|
* (/foo/bar.js)
|
2010-06-04 19:13:16 +00:00
|
|
|
* @param $version String: style version of the file. Defaults to $wgStyleVersion
|
2008-05-09 20:18:35 +00:00
|
|
|
*/
|
2010-06-04 19:13:16 +00:00
|
|
|
public function addScriptFile( $file, $version = null ) {
|
2010-01-24 19:43:02 +00:00
|
|
|
global $wgStylePath, $wgStyleVersion;
|
2010-08-20 01:47:52 +00:00
|
|
|
// See if $file parameter is an absolute URL or begins with a slash
|
2010-02-26 02:41:49 +00:00
|
|
|
if( substr( $file, 0, 1 ) == '/' || preg_match( '#^[a-z]*://#i', $file ) ) {
|
2008-05-09 20:18:35 +00:00
|
|
|
$path = $file;
|
|
|
|
|
} else {
|
2010-05-22 12:18:22 +00:00
|
|
|
$path = "{$wgStylePath}/common/{$file}";
|
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-06-04 19:13:16 +00:00
|
|
|
if ( is_null( $version ) )
|
|
|
|
|
$version = $wgStyleVersion;
|
|
|
|
|
$this->addScript( Html::linkedScript( wfAppendQuery( $path, $version ) ) );
|
2008-05-09 20:18:35 +00:00
|
|
|
}
|
2009-07-15 00:55:58 +00:00
|
|
|
|
2006-12-08 06:09:15 +00:00
|
|
|
/**
|
|
|
|
|
* Add a self-contained script tag with the given contents
|
2010-01-28 21:58:50 +00:00
|
|
|
*
|
|
|
|
|
* @param $script String: JavaScript text, no <script> tags
|
2006-12-08 06:09:15 +00:00
|
|
|
*/
|
2010-01-28 21:58:50 +00:00
|
|
|
public function addInlineScript( $script ) {
|
2009-08-22 20:15:22 +00:00
|
|
|
$this->mScripts .= Html::inlineScript( "\n$script\n" ) . "\n";
|
2006-12-08 06:09:15 +00:00
|
|
|
}
|
|
|
|
|
|
2009-09-10 06:43:01 +00:00
|
|
|
/**
|
|
|
|
|
* Get all registered JS and CSS tags for the header.
|
2010-01-28 21:58:50 +00:00
|
|
|
*
|
|
|
|
|
* @return String
|
2009-09-10 06:43:01 +00:00
|
|
|
*/
|
2008-04-14 07:45:50 +00:00
|
|
|
function getScript() {
|
2009-11-26 12:00:36 +00:00
|
|
|
return $this->mScripts . $this->getHeadItems();
|
2007-04-03 21:58:18 +00:00
|
|
|
}
|
|
|
|
|
|
2010-09-04 04:00:09 +00:00
|
|
|
/**
|
|
|
|
|
* Get the list of modules to include on this page
|
2010-09-07 21:05:09 +00:00
|
|
|
*
|
|
|
|
|
* @return Array of module names
|
2010-09-04 04:00:09 +00:00
|
|
|
*/
|
|
|
|
|
public function getModules() {
|
|
|
|
|
return $this->mModules;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add one or more modules recognized by the resource loader. Modules added
|
|
|
|
|
* through this function will be loaded by the resource loader when the
|
|
|
|
|
* page loads.
|
2010-09-07 21:05:09 +00:00
|
|
|
*
|
|
|
|
|
* @param $modules Mixed: module name (string) or array of module names
|
2010-09-04 04:00:09 +00:00
|
|
|
*/
|
|
|
|
|
public function addModules( $modules ) {
|
|
|
|
|
$this->mModules = array_merge( $this->mModules, (array)$modules );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the list of module JS to include on this page
|
|
|
|
|
* @return array of module names
|
|
|
|
|
*/
|
|
|
|
|
public function getModuleScripts() {
|
|
|
|
|
return $this->mModuleScripts;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add only JS of one or more modules recognized by the resource loader. Module
|
|
|
|
|
* scripts added through this function will be loaded by the resource loader when
|
|
|
|
|
* the page loads.
|
2010-09-07 21:05:09 +00:00
|
|
|
*
|
|
|
|
|
* @param $modules Mixed: module name (string) or array of module names
|
2010-09-04 04:00:09 +00:00
|
|
|
*/
|
|
|
|
|
public function addModuleScripts( $modules ) {
|
|
|
|
|
$this->mModuleScripts = array_merge( $this->mModuleScripts, (array)$modules );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the list of module CSS to include on this page
|
2010-09-07 21:05:09 +00:00
|
|
|
*
|
|
|
|
|
* @return Array of module names
|
2010-09-04 04:00:09 +00:00
|
|
|
*/
|
|
|
|
|
public function getModuleStyles() {
|
|
|
|
|
return $this->mModuleStyles;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add only CSS of one or more modules recognized by the resource loader. Module
|
|
|
|
|
* styles added through this function will be loaded by the resource loader when
|
|
|
|
|
* the page loads.
|
2010-09-07 21:05:09 +00:00
|
|
|
*
|
|
|
|
|
* @param $modules Mixed: module name (string) or array of module names
|
2010-09-04 04:00:09 +00:00
|
|
|
*/
|
|
|
|
|
public function addModuleStyles( $modules ) {
|
|
|
|
|
$this->mModuleStyles = array_merge( $this->mModuleStyles, (array)$modules );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the list of module messages to include on this page
|
2010-09-07 21:05:09 +00:00
|
|
|
*
|
|
|
|
|
* @return Array of module names
|
2010-09-04 04:00:09 +00:00
|
|
|
*/
|
|
|
|
|
public function getModuleMessages() {
|
|
|
|
|
return $this->mModuleMessages;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add only messages of one or more modules recognized by the resource loader.
|
|
|
|
|
* Module messages added through this function will be loaded by the resource
|
|
|
|
|
* loader when the page loads.
|
2010-09-07 21:05:09 +00:00
|
|
|
*
|
|
|
|
|
* @param $modules Mixed: module name (string) or array of module names
|
2010-09-04 04:00:09 +00:00
|
|
|
*/
|
|
|
|
|
public function addModuleMessages( $modules ) {
|
|
|
|
|
$this->mModuleMessages = array_merge( $this->mModuleMessages, (array)$modules );
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-28 21:58:50 +00:00
|
|
|
/**
|
|
|
|
|
* Get all header items in a string
|
|
|
|
|
*
|
|
|
|
|
* @return String
|
|
|
|
|
*/
|
2007-04-03 21:58:18 +00:00
|
|
|
function getHeadItems() {
|
|
|
|
|
$s = '';
|
|
|
|
|
foreach ( $this->mHeadItems as $item ) {
|
|
|
|
|
$s .= $item;
|
|
|
|
|
}
|
|
|
|
|
return $s;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-28 21:58:50 +00:00
|
|
|
/**
|
|
|
|
|
* Add or replace an header item to the output
|
|
|
|
|
*
|
|
|
|
|
* @param $name String: item name
|
|
|
|
|
* @param $value String: raw HTML
|
|
|
|
|
*/
|
|
|
|
|
public function addHeadItem( $name, $value ) {
|
2007-04-29 10:15:05 +00:00
|
|
|
$this->mHeadItems[$name] = $value;
|
|
|
|
|
}
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2010-01-28 21:58:50 +00:00
|
|
|
/**
|
|
|
|
|
* Check if the header item $name is already set
|
|
|
|
|
*
|
|
|
|
|
* @param $name String: item name
|
|
|
|
|
* @return Boolean
|
|
|
|
|
*/
|
|
|
|
|
public function hasHeadItem( $name ) {
|
Basic integrated audio/video support, with Ogg implementation.
* JavaScript video player based loosely on Greg Maxwell's player
* Image page text snippet customisation
* Abstraction of transform parameters in the parser. Introduced Linker::makeImageLink2().
* Made canRender(), mustRender() depend on file, not just on handler. Moved width=0, height=0 checking to ImageHandler::canRender(), since audio streams have width=height=0 but should be rendered.
Also:
* Automatic upgrade for oldimage rows on image page view, allows media handler selection based on oi_*_mime
* oi_*_mime unconditionally referenced, REQUIRES SCHEMA UPGRADE
* Don't destroy file info for missing files on upgrade
* Simple, centralised extension message file handling
* Made MessageCache::loadAllMessages non-static, optimised for repeated-call case due to abuse in User.php
* Support for lightweight parser output hooks, with callback whitelist for security
* Moved Linker::formatSize() to Language, to join the new formatTimePeriod() and formatBitrate()
* Introduced MagicWordArray, regex capture trick requires that magic word IDs DO NOT CONTAIN HYPHENS.
2007-08-15 10:50:09 +00:00
|
|
|
return isset( $this->mHeadItems[$name] );
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-28 21:58:50 +00:00
|
|
|
/**
|
|
|
|
|
* Set the value of the ETag HTTP header, only used if $wgUseETag is true
|
|
|
|
|
*
|
|
|
|
|
* @param $tag String: value of "ETag" header
|
|
|
|
|
*/
|
|
|
|
|
function setETag( $tag ) {
|
|
|
|
|
$this->mETag = $tag;
|
2004-04-10 11:19:33 +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
|
|
|
|
2010-01-28 21:58:50 +00:00
|
|
|
/**
|
|
|
|
|
* Set whether the output should only contain the body of the article,
|
|
|
|
|
* without any skin, sidebar, etc.
|
2010-02-01 18:04:17 +00:00
|
|
|
* Used e.g. when calling with "action=render".
|
2010-01-28 21:58:50 +00:00
|
|
|
*
|
|
|
|
|
* @param $only Boolean: whether to output only the body of the article
|
|
|
|
|
*/
|
|
|
|
|
public function setArticleBodyOnly( $only ) {
|
|
|
|
|
$this->mArticleBodyOnly = $only;
|
2008-08-10 07:14:08 +00:00
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2010-01-28 21:58:50 +00:00
|
|
|
/**
|
|
|
|
|
* Return whether the output will contain only the body of the article
|
|
|
|
|
*
|
|
|
|
|
* @return Boolean
|
|
|
|
|
*/
|
|
|
|
|
public function getArticleBodyOnly() {
|
|
|
|
|
return $this->mArticleBodyOnly;
|
2004-04-04 22:33:11 +00:00
|
|
|
}
|
2004-04-04 21:58:05 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* checkLastModified tells the client to use the client-cached page if
|
|
|
|
|
* possible. If sucessful, the OutputPage is disabled so that
|
2006-11-07 05:37:31 +00:00
|
|
|
* any future call to OutputPage->output() have no effect.
|
|
|
|
|
*
|
2008-08-29 08:40:13 +00:00
|
|
|
* Side effect: sets mLastModified for Last-Modified header
|
|
|
|
|
*
|
2010-01-28 21:58:50 +00:00
|
|
|
* @return Boolean: true iff cache-ok headers was sent.
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2010-01-28 21:58:50 +00:00
|
|
|
public function checkLastModified( $timestamp ) {
|
2006-08-14 18:18:35 +00:00
|
|
|
global $wgCachePages, $wgCacheEpoch, $wgUser, $wgRequest;
|
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
|
|
|
|
2005-03-20 03:59:06 +00:00
|
|
|
if ( !$timestamp || $timestamp == '19700101000000' ) {
|
2008-04-16 13:46:16 +00:00
|
|
|
wfDebug( __METHOD__ . ": CACHE DISABLED, NO TIMESTAMP\n" );
|
2008-08-29 08:40:13 +00:00
|
|
|
return false;
|
2005-03-20 03:59:06 +00:00
|
|
|
}
|
2003-07-10 04:55:41 +00:00
|
|
|
if( !$wgCachePages ) {
|
2008-04-16 13:46:16 +00:00
|
|
|
wfDebug( __METHOD__ . ": CACHE DISABLED\n", false );
|
2008-08-29 08:40:13 +00:00
|
|
|
return false;
|
2003-07-10 04:55:41 +00:00
|
|
|
}
|
2004-08-22 17:24:50 +00:00
|
|
|
if( $wgUser->getOption( 'nocache' ) ) {
|
2008-04-16 13:46:16 +00:00
|
|
|
wfDebug( __METHOD__ . ": USER DISABLED CACHE\n", false );
|
2008-08-29 08:40:13 +00:00
|
|
|
return false;
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2004-03-20 15:03:26 +00:00
|
|
|
|
2008-08-29 08:40:13 +00:00
|
|
|
$timestamp = wfTimestamp( TS_MW, $timestamp );
|
|
|
|
|
$modifiedTimes = array(
|
|
|
|
|
'page' => $timestamp,
|
|
|
|
|
'user' => $wgUser->getTouched(),
|
|
|
|
|
'epoch' => $wgCacheEpoch
|
|
|
|
|
);
|
|
|
|
|
wfRunHooks( 'OutputPageCheckLastModified', array( &$modifiedTimes ) );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-08-29 08:40:13 +00:00
|
|
|
$maxModified = max( $modifiedTimes );
|
|
|
|
|
$this->mLastModified = wfTimestamp( TS_RFC2822, $maxModified );
|
|
|
|
|
|
|
|
|
|
if( empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) {
|
2008-04-16 13:46:16 +00:00
|
|
|
wfDebug( __METHOD__ . ": client did not send If-Modified-Since header\n", false );
|
2008-08-29 08:40:13 +00:00
|
|
|
return false;
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2008-08-29 08:40:13 +00:00
|
|
|
|
|
|
|
|
# Make debug info
|
|
|
|
|
$info = '';
|
2008-12-23 19:39:00 +00:00
|
|
|
foreach ( $modifiedTimes as $name => $value ) {
|
|
|
|
|
if ( $info !== '' ) {
|
2008-08-29 08:40:13 +00:00
|
|
|
$info .= ', ';
|
|
|
|
|
}
|
|
|
|
|
$info .= "$name=" . wfTimestamp( TS_ISO_8601, $value );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# IE sends sizes after the date like this:
|
|
|
|
|
# Wed, 20 Aug 2003 06:51:19 GMT; length=5202
|
|
|
|
|
# this breaks strtotime().
|
|
|
|
|
$clientHeader = preg_replace( '/;.*$/', '', $_SERVER["HTTP_IF_MODIFIED_SINCE"] );
|
|
|
|
|
|
2008-12-23 19:39:00 +00:00
|
|
|
wfSuppressWarnings(); // E_STRICT system time bitching
|
|
|
|
|
$clientHeaderTime = strtotime( $clientHeader );
|
|
|
|
|
wfRestoreWarnings();
|
|
|
|
|
if ( !$clientHeaderTime ) {
|
2008-08-29 08:40:13 +00:00
|
|
|
wfDebug( __METHOD__ . ": unable to parse the client's If-Modified-Since header: $clientHeader\n" );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
$clientHeaderTime = wfTimestamp( TS_MW, $clientHeaderTime );
|
|
|
|
|
|
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
|
|
|
wfDebug( __METHOD__ . ": client sent If-Modified-Since: " .
|
2008-08-29 08:40:13 +00:00
|
|
|
wfTimestamp( TS_ISO_8601, $clientHeaderTime ) . "\n", false );
|
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
|
|
|
wfDebug( __METHOD__ . ": effective Last-Modified: " .
|
2008-08-29 08:40:13 +00:00
|
|
|
wfTimestamp( TS_ISO_8601, $maxModified ) . "\n", false );
|
|
|
|
|
if( $clientHeaderTime < $maxModified ) {
|
|
|
|
|
wfDebug( __METHOD__ . ": STALE, $info\n", false );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-23 19:39:00 +00:00
|
|
|
# Not modified
|
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
|
|
|
# Give a 304 response code and disable body output
|
2008-12-23 19:39:00 +00:00
|
|
|
wfDebug( __METHOD__ . ": NOT MODIFIED, $info\n", false );
|
2010-05-22 12:18:22 +00:00
|
|
|
ini_set( 'zlib.output_compression', 0 );
|
2008-08-29 08:40:13 +00:00
|
|
|
$wgRequest->response()->header( "HTTP/1.1 304 Not Modified" );
|
|
|
|
|
$this->sendCacheControl();
|
|
|
|
|
$this->disable();
|
|
|
|
|
|
|
|
|
|
// Don't output a compressed blob when using ob_gzhandler;
|
|
|
|
|
// it's technically against HTTP spec and seems to confuse
|
|
|
|
|
// Firefox when the response gets split over two packets.
|
|
|
|
|
wfClearOutputBuffers();
|
|
|
|
|
|
|
|
|
|
return true;
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2010-04-05 16:14:58 +00:00
|
|
|
/**
|
|
|
|
|
* Override the last modified timestamp
|
|
|
|
|
*
|
|
|
|
|
* @param $timestamp String: new timestamp, in a format readable by
|
|
|
|
|
* wfTimestamp()
|
|
|
|
|
*/
|
|
|
|
|
public function setLastModified( $timestamp ) {
|
|
|
|
|
$this->mLastModified = wfTimestamp( TS_RFC2822, $timestamp );
|
|
|
|
|
}
|
|
|
|
|
|
2008-07-23 19:05:43 +00:00
|
|
|
/**
|
|
|
|
|
* Set the robot policy for the page: <http://www.robotstxt.org/meta.html>
|
|
|
|
|
*
|
2010-01-28 21:58:50 +00:00
|
|
|
* @param $policy String: the literal string to output as the contents of
|
2008-07-23 19:05:43 +00:00
|
|
|
* the meta tag. Will be parsed according to the spec and output in
|
|
|
|
|
* standardized form.
|
|
|
|
|
* @return null
|
|
|
|
|
*/
|
|
|
|
|
public function setRobotPolicy( $policy ) {
|
2009-08-31 19:19:12 +00:00
|
|
|
$policy = Article::formatRobotPolicy( $policy );
|
2008-07-23 19:05:43 +00:00
|
|
|
|
2010-05-22 12:18:22 +00:00
|
|
|
if( isset( $policy['index'] ) ) {
|
2009-08-31 19:19:12 +00:00
|
|
|
$this->setIndexPolicy( $policy['index'] );
|
2010-01-28 21:58:50 +00:00
|
|
|
}
|
2010-05-22 12:18:22 +00:00
|
|
|
if( isset( $policy['follow'] ) ) {
|
2009-08-31 19:19:12 +00:00
|
|
|
$this->setFollowPolicy( $policy['follow'] );
|
2010-01-28 21:58:50 +00:00
|
|
|
}
|
2008-07-23 19:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the index policy for the page, but leave the follow policy un-
|
|
|
|
|
* touched.
|
|
|
|
|
*
|
|
|
|
|
* @param $policy string Either 'index' or 'noindex'.
|
|
|
|
|
* @return null
|
|
|
|
|
*/
|
|
|
|
|
public function setIndexPolicy( $policy ) {
|
|
|
|
|
$policy = trim( $policy );
|
|
|
|
|
if( in_array( $policy, array( 'index', 'noindex' ) ) ) {
|
|
|
|
|
$this->mIndexPolicy = $policy;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the follow policy for the page, but leave the index policy un-
|
|
|
|
|
* touched.
|
|
|
|
|
*
|
2010-01-28 21:58:50 +00:00
|
|
|
* @param $policy String: either 'follow' or 'nofollow'.
|
2008-07-23 19:05:43 +00:00
|
|
|
* @return null
|
|
|
|
|
*/
|
|
|
|
|
public function setFollowPolicy( $policy ) {
|
|
|
|
|
$policy = trim( $policy );
|
|
|
|
|
if( in_array( $policy, array( 'follow', 'nofollow' ) ) ) {
|
|
|
|
|
$this->mFollowPolicy = $policy;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-28 21:58:50 +00:00
|
|
|
/**
|
|
|
|
|
* Set the new value of the "action text", this will be added to the
|
|
|
|
|
* "HTML title", separated from it with " - ".
|
|
|
|
|
*
|
|
|
|
|
* @param $text String: new value of the "action text"
|
|
|
|
|
*/
|
|
|
|
|
public function setPageTitleActionText( $text ) {
|
|
|
|
|
$this->mPageTitleActionText = $text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the value of the "action text"
|
|
|
|
|
*
|
|
|
|
|
* @return String
|
|
|
|
|
*/
|
|
|
|
|
public function getPageTitleActionText() {
|
|
|
|
|
if ( isset( $this->mPageTitleActionText ) ) {
|
|
|
|
|
return $this->mPageTitleActionText;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-09 05:15:43 +00:00
|
|
|
/**
|
2010-04-10 05:46:01 +00:00
|
|
|
* "HTML title" means the contents of <title>.
|
|
|
|
|
* It is stored as plain, unescaped text and will be run through htmlspecialchars in the skin file.
|
2009-04-09 05:15:43 +00:00
|
|
|
*/
|
2010-04-10 13:38:50 +00:00
|
|
|
public function setHTMLTitle( $name ) {
|
|
|
|
|
$this->mHTMLtitle = $name;
|
2009-04-09 05:15:43 +00:00
|
|
|
}
|
|
|
|
|
|
2010-01-28 21:58:50 +00:00
|
|
|
/**
|
|
|
|
|
* Return the "HTML title", i.e. the content of the <title> tag.
|
|
|
|
|
*
|
|
|
|
|
* @return String
|
|
|
|
|
*/
|
|
|
|
|
public function getHTMLTitle() {
|
|
|
|
|
return $this->mHTMLtitle;
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-09 05:15:43 +00:00
|
|
|
/**
|
2010-02-01 18:04:17 +00:00
|
|
|
* "Page title" means the contents of \<h1\>. It is stored as a valid HTML fragment.
|
|
|
|
|
* This function allows good tags like \<sup\> in the \<h1\> tag, but not bad tags like \<script\>.
|
|
|
|
|
* This function automatically sets \<title\> to the same content as \<h1\> but with all tags removed.
|
|
|
|
|
* Bad tags that were escaped in \<h1\> will still be escaped in \<title\>, and good tags like \<i\> will be dropped entirely.
|
2009-11-14 21:27:13 +00:00
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function setPageTitle( $name ) {
|
2009-04-09 05:15:43 +00:00
|
|
|
# change "<script>foo&bar</script>" to "<script>foo&bar</script>"
|
|
|
|
|
# but leave "<i>foobar</i>" alone
|
|
|
|
|
$nameWithTags = Sanitizer::normalizeCharReferences( Sanitizer::removeHTMLtags( $name ) );
|
|
|
|
|
$this->mPagetitle = $nameWithTags;
|
2009-02-04 19:43:30 +00:00
|
|
|
|
2010-05-22 12:18:22 +00:00
|
|
|
$taction = $this->getPageTitleActionText();
|
2009-02-04 19:43:30 +00:00
|
|
|
if( !empty( $taction ) ) {
|
|
|
|
|
$name .= ' - '.$taction;
|
2004-04-25 00:32:24 +00:00
|
|
|
}
|
2008-12-31 16:49:38 +00:00
|
|
|
|
2009-04-09 05:15:43 +00:00
|
|
|
# change "<i>foo&bar</i>" to "foo&bar"
|
2010-04-10 18:29:24 +00:00
|
|
|
$this->setHTMLTitle( wfMsg( 'pagetitle', Sanitizer::stripAllTags( $nameWithTags ) ) );
|
2004-04-25 00:32:24 +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
|
|
|
|
2010-01-28 21:58:50 +00:00
|
|
|
/**
|
2010-02-02 16:26:52 +00:00
|
|
|
* Return the "page title", i.e. the content of the \<h1\> tag.
|
2010-01-28 21:58:50 +00:00
|
|
|
*
|
|
|
|
|
* @return String
|
|
|
|
|
*/
|
|
|
|
|
public function getPageTitle() {
|
|
|
|
|
return $this->mPagetitle;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the Title object to use
|
|
|
|
|
*
|
|
|
|
|
* @param $t Title object
|
|
|
|
|
*/
|
2009-04-09 02:22:36 +00:00
|
|
|
public function setTitle( $t ) {
|
|
|
|
|
$this->mTitle = $t;
|
|
|
|
|
}
|
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-01-28 21:58:50 +00:00
|
|
|
/**
|
|
|
|
|
* Get the Title object used in this instance
|
|
|
|
|
*
|
|
|
|
|
* @return Title
|
|
|
|
|
*/
|
2009-04-09 02:22:36 +00:00
|
|
|
public function getTitle() {
|
|
|
|
|
if ( $this->mTitle instanceof Title ) {
|
|
|
|
|
return $this->mTitle;
|
2010-01-28 21:58:50 +00:00
|
|
|
} else {
|
2010-08-11 16:49:59 +00:00
|
|
|
wfDebug( __METHOD__ . " called and \$mTitle is null. Return \$wgTitle for sanity\n" );
|
2009-04-09 02:22:36 +00:00
|
|
|
global $wgTitle;
|
|
|
|
|
return $wgTitle;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-02-04 19:43:30 +00:00
|
|
|
|
2010-01-28 21:58:50 +00:00
|
|
|
/**
|
|
|
|
|
* Replace the subtile with $str
|
|
|
|
|
*
|
|
|
|
|
* @param $str String: new value of the subtitle
|
|
|
|
|
*/
|
|
|
|
|
public function setSubtitle( $str ) {
|
|
|
|
|
$this->mSubtitle = /*$this->parse(*/ $str /*)*/; // @bug 2514
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add $str to the subtitle
|
|
|
|
|
*
|
|
|
|
|
* @param $str String to add to the subtitle
|
|
|
|
|
*/
|
|
|
|
|
public function appendSubtitle( $str ) {
|
|
|
|
|
$this->mSubtitle .= /*$this->parse(*/ $str /*)*/; // @bug 2514
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the subtitle
|
|
|
|
|
*
|
|
|
|
|
* @return String
|
|
|
|
|
*/
|
|
|
|
|
public function getSubtitle() {
|
|
|
|
|
return $this->mSubtitle;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the page as printable, i.e. it'll be displayed with with all
|
|
|
|
|
* print styles included
|
|
|
|
|
*/
|
|
|
|
|
public function setPrintable() {
|
|
|
|
|
$this->mPrintable = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return whether the page is "printable"
|
|
|
|
|
*
|
|
|
|
|
* @return Boolean
|
|
|
|
|
*/
|
|
|
|
|
public function isPrintable() {
|
|
|
|
|
return $this->mPrintable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Disable output completely, i.e. calling output() will have no effect
|
|
|
|
|
*/
|
|
|
|
|
public function disable() {
|
|
|
|
|
$this->mDoNothing = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return whether the output will be completely disabled
|
|
|
|
|
*
|
|
|
|
|
* @return Boolean
|
|
|
|
|
*/
|
|
|
|
|
public function isDisabled() {
|
|
|
|
|
return $this->mDoNothing;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-29 21:32:45 +00:00
|
|
|
/**
|
|
|
|
|
* Show an "add new section" link?
|
|
|
|
|
*
|
|
|
|
|
* @return Boolean
|
|
|
|
|
*/
|
|
|
|
|
public function showNewSectionLink() {
|
|
|
|
|
return $this->mNewSectionLink;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Forcibly hide the new section link?
|
|
|
|
|
*
|
|
|
|
|
* @return Boolean
|
|
|
|
|
*/
|
|
|
|
|
public function forceHideNewSectionLink() {
|
|
|
|
|
return $this->mHideNewSectionLink;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-26 20:47:34 +00:00
|
|
|
/**
|
|
|
|
|
* Add or remove feed links in the page header
|
|
|
|
|
* This is mainly kept for backward compatibility, see OutputPage::addFeedLink()
|
|
|
|
|
* for the new version
|
|
|
|
|
* @see addFeedLink()
|
|
|
|
|
*
|
|
|
|
|
* @param $show Boolean: true: add default feeds, false: remove all feeds
|
|
|
|
|
*/
|
2010-01-13 20:23:14 +00:00
|
|
|
public function setSyndicated( $show = true ) {
|
|
|
|
|
if ( $show ) {
|
|
|
|
|
$this->setFeedAppendQuery( false );
|
|
|
|
|
} else {
|
|
|
|
|
$this->mFeedLinks = array();
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-10-24 21:32:53 +00:00
|
|
|
|
2010-01-26 20:47:34 +00:00
|
|
|
/**
|
|
|
|
|
* Add default feeds to the page header
|
|
|
|
|
* This is mainly kept for backward compatibility, see OutputPage::addFeedLink()
|
|
|
|
|
* for the new version
|
|
|
|
|
* @see addFeedLink()
|
|
|
|
|
*
|
|
|
|
|
* @param $val String: query to append to feed links or false to output
|
|
|
|
|
* default links
|
|
|
|
|
*/
|
2009-09-30 17:35:41 +00:00
|
|
|
public function setFeedAppendQuery( $val ) {
|
2010-01-26 20:52:55 +00:00
|
|
|
global $wgAdvertisedFeedTypes;
|
2009-10-24 21:32:53 +00:00
|
|
|
|
2009-09-30 17:35:41 +00:00
|
|
|
$this->mFeedLinks = array();
|
2009-10-24 21:32:53 +00:00
|
|
|
|
2010-01-13 21:29:47 +00:00
|
|
|
foreach ( $wgAdvertisedFeedTypes as $type ) {
|
2010-01-13 20:23:14 +00:00
|
|
|
$query = "feed=$type";
|
2010-01-13 21:29:47 +00:00
|
|
|
if ( is_string( $val ) ) {
|
2010-01-13 20:23:14 +00:00
|
|
|
$query .= '&' . $val;
|
2010-01-13 21:29:47 +00:00
|
|
|
}
|
2009-09-30 17:35:41 +00:00
|
|
|
$this->mFeedLinks[$type] = $this->getTitle()->getLocalURL( $query );
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-10-24 21:32:53 +00:00
|
|
|
|
2010-01-26 20:47:34 +00:00
|
|
|
/**
|
|
|
|
|
* Add a feed link to the page header
|
|
|
|
|
*
|
|
|
|
|
* @param $format String: feed type, should be a key of $wgFeedClasses
|
|
|
|
|
* @param $href String: URL
|
|
|
|
|
*/
|
2009-09-30 17:35:41 +00:00
|
|
|
public function addFeedLink( $format, $href ) {
|
2010-05-11 19:36:47 +00:00
|
|
|
global $wgAdvertisedFeedTypes;
|
|
|
|
|
|
|
|
|
|
if ( in_array( $format, $wgAdvertisedFeedTypes ) ) {
|
|
|
|
|
$this->mFeedLinks[$format] = $href;
|
|
|
|
|
}
|
2009-09-30 17:35:41 +00:00
|
|
|
}
|
2009-10-24 21:32:53 +00:00
|
|
|
|
2010-01-26 20:47:34 +00:00
|
|
|
/**
|
2010-01-27 00:11:13 +00:00
|
|
|
* Should we output feed links for this page?
|
2010-01-26 20:47:34 +00:00
|
|
|
* @return Boolean
|
|
|
|
|
*/
|
2010-01-28 21:58:50 +00:00
|
|
|
public function isSyndicated() {
|
|
|
|
|
return count( $this->mFeedLinks ) > 0;
|
|
|
|
|
}
|
2006-11-07 05:37:31 +00:00
|
|
|
|
2010-01-29 21:32:45 +00:00
|
|
|
/**
|
|
|
|
|
* Return URLs for each supported syndication format for this page.
|
|
|
|
|
* @return array associating format keys with URLs
|
|
|
|
|
*/
|
|
|
|
|
public function getSyndicationLinks() {
|
|
|
|
|
return $this->mFeedLinks;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-28 21:58:50 +00:00
|
|
|
/**
|
|
|
|
|
* Will currently always return null
|
|
|
|
|
*
|
|
|
|
|
* @return null
|
|
|
|
|
*/
|
|
|
|
|
public function getFeedAppendQuery() {
|
|
|
|
|
return $this->mFeedLinksAppendQuery;
|
|
|
|
|
}
|
2010-01-26 20:47:34 +00:00
|
|
|
|
2010-01-28 21:58:50 +00:00
|
|
|
/**
|
|
|
|
|
* Set whether the displayed content is related to the source of the
|
|
|
|
|
* corresponding article on the wiki
|
|
|
|
|
* Setting true will cause the change "article related" toggle to true
|
|
|
|
|
*
|
|
|
|
|
* @param $v Boolean
|
|
|
|
|
*/
|
|
|
|
|
public function setArticleFlag( $v ) {
|
|
|
|
|
$this->mIsarticle = $v;
|
|
|
|
|
if ( $v ) {
|
|
|
|
|
$this->mIsArticleRelated = $v;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return whether the content displayed page is related to the source of
|
|
|
|
|
* the corresponding article on the wiki
|
|
|
|
|
*
|
|
|
|
|
* @return Boolean
|
|
|
|
|
*/
|
|
|
|
|
public function isArticle() {
|
|
|
|
|
return $this->mIsarticle;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set whether this page is related an article on the wiki
|
|
|
|
|
* Setting false will cause the change of "article flag" toggle to false
|
|
|
|
|
*
|
|
|
|
|
* @param $v Boolean
|
|
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function setArticleRelated( $v ) {
|
2004-01-17 09:49:43 +00:00
|
|
|
$this->mIsArticleRelated = $v;
|
|
|
|
|
if ( !$v ) {
|
|
|
|
|
$this->mIsarticle = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-01-28 21:58:50 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return whether this page is related an article on the wiki
|
|
|
|
|
*
|
|
|
|
|
* @return Boolean
|
|
|
|
|
*/
|
|
|
|
|
public function isArticleRelated() {
|
|
|
|
|
return $this->mIsArticleRelated;
|
2004-01-17 09:49:43 +00:00
|
|
|
}
|
|
|
|
|
|
2010-01-28 21:58:50 +00:00
|
|
|
/**
|
|
|
|
|
* Add new language links
|
|
|
|
|
*
|
|
|
|
|
* @param $newLinkArray Associative array mapping language code to the page
|
|
|
|
|
* name
|
|
|
|
|
*/
|
|
|
|
|
public function addLanguageLinks( $newLinkArray ) {
|
2004-06-01 18:29:31 +00:00
|
|
|
$this->mLanguageLinks += $newLinkArray;
|
|
|
|
|
}
|
2010-01-28 21:58:50 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Reset the language links and add new language links
|
|
|
|
|
*
|
|
|
|
|
* @param $newLinkArray Associative array mapping language code to the page
|
|
|
|
|
* name
|
|
|
|
|
*/
|
|
|
|
|
public function setLanguageLinks( $newLinkArray ) {
|
2004-06-01 18:29:31 +00:00
|
|
|
$this->mLanguageLinks = $newLinkArray;
|
|
|
|
|
}
|
2004-09-17 15:24:43 +00:00
|
|
|
|
2010-01-28 21:58:50 +00:00
|
|
|
/**
|
|
|
|
|
* Get the list of language links
|
|
|
|
|
*
|
|
|
|
|
* @return Associative array mapping language code to the page name
|
|
|
|
|
*/
|
|
|
|
|
public function getLanguageLinks() {
|
|
|
|
|
return $this->mLanguageLinks;
|
2004-07-08 14:53:54 +00:00
|
|
|
}
|
2005-12-30 09:33:11 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add an array of categories, with names in the keys
|
2010-01-28 21:58:50 +00:00
|
|
|
*
|
|
|
|
|
* @param $categories Associative array mapping category name to its sort key
|
2005-12-30 09:33:11 +00:00
|
|
|
*/
|
2008-02-20 08:53:12 +00:00
|
|
|
public function addCategoryLinks( $categories ) {
|
2008-02-25 16:38:25 +00:00
|
|
|
global $wgUser, $wgContLang;
|
2005-12-30 09:33:11 +00:00
|
|
|
|
2008-02-25 16:38:25 +00:00
|
|
|
if ( !is_array( $categories ) || count( $categories ) == 0 ) {
|
2008-02-20 08:53:12 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2008-02-25 16:38:25 +00:00
|
|
|
|
2008-02-20 08:53:12 +00:00
|
|
|
# Add the links to a LinkBatch
|
2005-12-30 09:33:11 +00:00
|
|
|
$arr = array( NS_CATEGORY => $categories );
|
|
|
|
|
$lb = new LinkBatch;
|
|
|
|
|
$lb->setArray( $arr );
|
|
|
|
|
|
2008-02-20 08:53:12 +00:00
|
|
|
# Fetch existence plus the hiddencat property
|
|
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
|
|
|
|
$pageTable = $dbr->tableName( 'page' );
|
|
|
|
|
$where = $lb->constructSet( 'page', $dbr );
|
2008-02-25 16:38:25 +00:00
|
|
|
$propsTable = $dbr->tableName( 'page_props' );
|
2010-06-15 14:37:13 +00:00
|
|
|
$sql = "SELECT page_id, page_namespace, page_title, page_len, page_is_redirect, page_latest, pp_value
|
2008-04-09 13:02:34 +00:00
|
|
|
FROM $pageTable LEFT JOIN $propsTable ON pp_propname='hiddencat' AND pp_page=page_id WHERE $where";
|
2008-02-20 08:53:12 +00:00
|
|
|
$res = $dbr->query( $sql, __METHOD__ );
|
|
|
|
|
|
|
|
|
|
# Add the results to the link cache
|
|
|
|
|
$lb->addResultToCache( LinkCache::singleton(), $res );
|
|
|
|
|
|
2008-02-25 16:38:25 +00:00
|
|
|
# Set all the values to 'normal'. This can be done with array_fill_keys in PHP 5.2.0+
|
2010-05-22 12:18:22 +00:00
|
|
|
$categories = array_combine(
|
|
|
|
|
array_keys( $categories ),
|
|
|
|
|
array_fill( 0, count( $categories ), 'normal' )
|
|
|
|
|
);
|
2008-02-25 16:38:25 +00:00
|
|
|
|
|
|
|
|
# Mark hidden categories
|
2008-02-20 08:53:12 +00:00
|
|
|
foreach ( $res as $row ) {
|
2008-02-25 16:38:25 +00:00
|
|
|
if ( isset( $row->pp_value ) ) {
|
|
|
|
|
$categories[$row->page_title] = 'hidden';
|
2008-02-20 08:53:12 +00:00
|
|
|
}
|
|
|
|
|
}
|
2008-02-25 16:38:25 +00:00
|
|
|
|
2008-02-20 08:53:12 +00:00
|
|
|
# Add the remaining categories to the skin
|
2008-07-02 20:02:51 +00:00
|
|
|
if ( wfRunHooks( 'OutputPageMakeCategoryLinks', array( &$this, $categories, &$this->mCategoryLinks ) ) ) {
|
|
|
|
|
$sk = $wgUser->getSkin();
|
|
|
|
|
foreach ( $categories as $category => $type ) {
|
2009-02-02 07:54:43 +00:00
|
|
|
$origcategory = $category;
|
2008-07-02 20:02:51 +00:00
|
|
|
$title = Title::makeTitleSafe( NS_CATEGORY, $category );
|
2009-02-02 07:54:43 +00:00
|
|
|
$wgContLang->findVariantLink( $category, $title, true );
|
2010-05-22 12:18:22 +00:00
|
|
|
if ( $category != $origcategory ) {
|
|
|
|
|
if ( array_key_exists( $category, $categories ) ) {
|
2009-02-02 07:54:43 +00:00
|
|
|
continue;
|
2010-05-22 12:18:22 +00:00
|
|
|
}
|
|
|
|
|
}
|
2008-07-02 20:02:51 +00:00
|
|
|
$text = $wgContLang->convertHtml( $title->getText() );
|
2009-11-19 00:37:00 +00:00
|
|
|
$this->mCategories[] = $title->getText();
|
2009-05-08 23:24:31 +00:00
|
|
|
$this->mCategoryLinks[$type][] = $sk->link( $title, $text );
|
2008-07-02 20:02:51 +00:00
|
|
|
}
|
2005-12-30 09:33:11 +00:00
|
|
|
}
|
2004-06-19 06:46:54 +00:00
|
|
|
}
|
2005-12-30 09:33:11 +00:00
|
|
|
|
2010-01-28 21:58:50 +00:00
|
|
|
/**
|
|
|
|
|
* Reset the category links (but not the category list) and add $categories
|
|
|
|
|
*
|
|
|
|
|
* @param $categories Associative array mapping category name to its sort key
|
|
|
|
|
*/
|
|
|
|
|
public function setCategoryLinks( $categories ) {
|
2005-12-30 09:33:11 +00:00
|
|
|
$this->mCategoryLinks = array();
|
2010-01-28 21:58:50 +00:00
|
|
|
$this->addCategoryLinks( $categories );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the list of category links, in a 2-D array with the following format:
|
|
|
|
|
* $arr[$type][] = $link, where $type is either "normal" or "hidden" (for
|
|
|
|
|
* hidden categories) and $link a HTML fragment with a link to the category
|
|
|
|
|
* page
|
|
|
|
|
*
|
|
|
|
|
* @return Array
|
|
|
|
|
*/
|
|
|
|
|
public function getCategoryLinks() {
|
|
|
|
|
return $this->mCategoryLinks;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the list of category names this page belongs to
|
|
|
|
|
*
|
|
|
|
|
* @return Array of strings
|
|
|
|
|
*/
|
|
|
|
|
public function getCategories() {
|
|
|
|
|
return $this->mCategories;
|
2004-06-19 06:46:54 +00:00
|
|
|
}
|
|
|
|
|
|
2010-01-29 21:32:45 +00:00
|
|
|
/**
|
|
|
|
|
* Suppress the quickbar from the output, only for skin supporting
|
|
|
|
|
* the quickbar
|
|
|
|
|
*/
|
|
|
|
|
public function suppressQuickbar() {
|
|
|
|
|
$this->mSuppressQuickbar = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return whether the quickbar should be suppressed from the output
|
|
|
|
|
*
|
|
|
|
|
* @return Boolean
|
|
|
|
|
*/
|
|
|
|
|
public function isQuickbarSuppressed() {
|
|
|
|
|
return $this->mSuppressQuickbar;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Remove user JavaScript from scripts to load
|
|
|
|
|
*/
|
|
|
|
|
public function disallowUserJs() {
|
|
|
|
|
$this->mAllowUserJs = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return whether user JavaScript is allowed for this page
|
|
|
|
|
*
|
|
|
|
|
* @return Boolean
|
|
|
|
|
*/
|
|
|
|
|
public function isUserJsAllowed() {
|
|
|
|
|
return $this->mAllowUserJs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Prepend $text to the body HTML
|
|
|
|
|
*
|
|
|
|
|
* @param $text String: HTML
|
|
|
|
|
*/
|
|
|
|
|
public function prependHTML( $text ) {
|
|
|
|
|
$this->mBodytext = $text . $this->mBodytext;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Append $text to the body HTML
|
|
|
|
|
*
|
|
|
|
|
* @param $text String: HTML
|
|
|
|
|
*/
|
|
|
|
|
public function addHTML( $text ) {
|
|
|
|
|
$this->mBodytext .= $text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Clear the body HTML
|
|
|
|
|
*/
|
|
|
|
|
public function clearHTML() {
|
|
|
|
|
$this->mBodytext = '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the body HTML
|
|
|
|
|
*
|
|
|
|
|
* @return String: HTML
|
|
|
|
|
*/
|
|
|
|
|
public function getHTML() {
|
|
|
|
|
return $this->mBodytext;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add $text to the debug output
|
|
|
|
|
*
|
|
|
|
|
* @param $text String: debug text
|
|
|
|
|
*/
|
|
|
|
|
public function debug( $text ) {
|
|
|
|
|
$this->mDebugtext .= $text;
|
|
|
|
|
}
|
2007-05-08 20:48:02 +00:00
|
|
|
|
2010-01-29 21:32:45 +00:00
|
|
|
/**
|
|
|
|
|
* @deprecated use parserOptions() instead
|
|
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function setParserOptions( $options ) {
|
2008-04-16 13:46:16 +00:00
|
|
|
wfDeprecated( __METHOD__ );
|
2006-07-26 07:15:39 +00:00
|
|
|
return $this->parserOptions( $options );
|
2005-12-21 02:38:54 +00:00
|
|
|
}
|
|
|
|
|
|
2010-01-29 21:32:45 +00:00
|
|
|
/**
|
|
|
|
|
* Get/set the ParserOptions object to use for wikitext parsing
|
|
|
|
|
*
|
|
|
|
|
* @param $options either the ParserOption to use or null to only get the
|
|
|
|
|
* current ParserOption object
|
|
|
|
|
* @return current ParserOption object
|
|
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function parserOptions( $options = null ) {
|
2006-07-26 07:15:39 +00:00
|
|
|
if ( !$this->mParserOptions ) {
|
|
|
|
|
$this->mParserOptions = new ParserOptions;
|
|
|
|
|
}
|
2004-02-29 08:43:29 +00:00
|
|
|
return wfSetVar( $this->mParserOptions, $options );
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-11-27 06:04:41 +00:00
|
|
|
/**
|
|
|
|
|
* Set the revision ID which will be seen by the wiki text parser
|
|
|
|
|
* for things such as embedded {{REVISIONID}} variable use.
|
2010-01-29 21:32:45 +00:00
|
|
|
*
|
|
|
|
|
* @param $revid Mixed: an positive integer, or null
|
|
|
|
|
* @return Mixed: previous value
|
2005-11-27 06:04:41 +00:00
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function setRevisionId( $revid ) {
|
2005-11-27 06:04:41 +00:00
|
|
|
$val = is_null( $revid ) ? null : intval( $revid );
|
|
|
|
|
return wfSetVar( $this->mRevisionId, $val );
|
|
|
|
|
}
|
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-01-29 21:32:45 +00:00
|
|
|
/**
|
|
|
|
|
* Get the current revision ID
|
|
|
|
|
*
|
|
|
|
|
* @return Integer
|
|
|
|
|
*/
|
2008-08-11 13:23:45 +00:00
|
|
|
public function getRevisionId() {
|
|
|
|
|
return $this->mRevisionId;
|
|
|
|
|
}
|
2004-02-29 08:43:29 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* Convert wikitext to HTML and add it to the buffer
|
2010-01-29 21:32:45 +00:00
|
|
|
* Default assumes that the current page title will be used.
|
2006-11-07 05:37:31 +00:00
|
|
|
*
|
2010-01-29 21:32:45 +00:00
|
|
|
* @param $text String
|
|
|
|
|
* @param $linestart Boolean: is this the start of a line?
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function addWikiText( $text, $linestart = true ) {
|
2009-04-09 08:53:15 +00:00
|
|
|
$title = $this->getTitle(); // Work arround E_STRICT
|
|
|
|
|
$this->addWikiTextTitle( $text, $title, $linestart );
|
2005-05-21 17:26:42 +00:00
|
|
|
}
|
|
|
|
|
|
2010-01-29 21:32:45 +00:00
|
|
|
/**
|
|
|
|
|
* Add wikitext with a custom Title object
|
|
|
|
|
*
|
|
|
|
|
* @param $text String: wikitext
|
|
|
|
|
* @param $title Title object
|
|
|
|
|
* @param $linestart Boolean: is this the start of a line?
|
|
|
|
|
*/
|
|
|
|
|
public function addWikiTextWithTitle( $text, &$title, $linestart = true ) {
|
|
|
|
|
$this->addWikiTextTitle( $text, $title, $linestart );
|
2005-05-21 17:26:42 +00:00
|
|
|
}
|
2005-07-01 00:03:31 +00:00
|
|
|
|
2010-01-29 21:32:45 +00:00
|
|
|
/**
|
2010-05-22 11:47:56 +00:00
|
|
|
* Add wikitext with a custom Title object and
|
2010-01-29 21:32:45 +00:00
|
|
|
*
|
|
|
|
|
* @param $text String: wikitext
|
|
|
|
|
* @param $title Title object
|
|
|
|
|
* @param $linestart Boolean: is this the start of a line?
|
|
|
|
|
*/
|
|
|
|
|
function addWikiTextTitleTidy( $text, &$title, $linestart = true ) {
|
2007-01-14 17:37:29 +00:00
|
|
|
$this->addWikiTextTitle( $text, $title, $linestart, true );
|
2007-01-10 23:32:38 +00:00
|
|
|
}
|
|
|
|
|
|
2010-01-29 21:32:45 +00:00
|
|
|
/**
|
|
|
|
|
* Add wikitext with tidy enabled
|
|
|
|
|
*
|
|
|
|
|
* @param $text String: wikitext
|
|
|
|
|
* @param $linestart Boolean: is this the start of a line?
|
|
|
|
|
*/
|
|
|
|
|
public function addWikiTextTidy( $text, $linestart = true ) {
|
|
|
|
|
$title = $this->getTitle();
|
2010-05-22 12:18:22 +00:00
|
|
|
$this->addWikiTextTitleTidy( $text, $title, $linestart );
|
2010-01-29 21:32:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add wikitext with a custom Title object
|
|
|
|
|
*
|
|
|
|
|
* @param $text String: wikitext
|
|
|
|
|
* @param $title Title object
|
|
|
|
|
* @param $linestart Boolean: is this the start of a line?
|
|
|
|
|
* @param $tidy Boolean: whether to use tidy
|
|
|
|
|
*/
|
|
|
|
|
public function addWikiTextTitle( $text, &$title, $linestart, $tidy = false ) {
|
2005-12-04 18:27:59 +00:00
|
|
|
global $wgParser;
|
2007-01-10 23:32:38 +00:00
|
|
|
|
2008-04-16 13:46:16 +00:00
|
|
|
wfProfileIn( __METHOD__ );
|
2007-01-10 23:32:38 +00:00
|
|
|
|
2008-04-16 13:46:16 +00:00
|
|
|
wfIncrStats( 'pcache_not_possible' );
|
2007-01-10 23:32:38 +00:00
|
|
|
|
|
|
|
|
$popts = $this->parserOptions();
|
2008-04-16 13:46:16 +00:00
|
|
|
$oldTidy = $popts->setTidy( $tidy );
|
2007-01-10 23:32:38 +00:00
|
|
|
|
2010-05-22 12:18:22 +00:00
|
|
|
$parserOutput = $wgParser->parse(
|
|
|
|
|
$text, $title, $popts,
|
|
|
|
|
$linestart, true, $this->mRevisionId
|
|
|
|
|
);
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2007-09-11 18:22:37 +00:00
|
|
|
$popts->setTidy( $oldTidy );
|
2007-01-10 23:32:38 +00:00
|
|
|
|
2006-01-01 20:08:08 +00:00
|
|
|
$this->addParserOutput( $parserOutput );
|
2007-01-10 23:32:38 +00:00
|
|
|
|
2008-04-16 13:46:16 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2006-01-01 20:08:08 +00:00
|
|
|
}
|
|
|
|
|
|
2006-11-07 05:37:31 +00:00
|
|
|
/**
|
2010-01-29 21:32:45 +00:00
|
|
|
* Add wikitext to the buffer, assuming that this is the primary text for a page view
|
|
|
|
|
* Saves the text into the parser cache if possible.
|
|
|
|
|
*
|
|
|
|
|
* @param $text String: wikitext
|
|
|
|
|
* @param $article Article object
|
|
|
|
|
* @param $cache Boolean
|
|
|
|
|
* @deprecated Use Article::outputWikitext
|
|
|
|
|
*/
|
|
|
|
|
public function addPrimaryWikiText( $text, $article, $cache = true ) {
|
|
|
|
|
global $wgParser;
|
|
|
|
|
|
|
|
|
|
wfDeprecated( __METHOD__ );
|
|
|
|
|
|
|
|
|
|
$popts = $this->parserOptions();
|
2010-05-22 12:18:22 +00:00
|
|
|
$popts->setTidy( true );
|
|
|
|
|
$parserOutput = $wgParser->parse(
|
|
|
|
|
$text, $article->mTitle,
|
|
|
|
|
$popts, true, true, $this->mRevisionId
|
|
|
|
|
);
|
|
|
|
|
$popts->setTidy( false );
|
2010-08-09 15:28:23 +00:00
|
|
|
if ( $cache && $article && $parserOutput->isCacheable() ) {
|
2010-01-29 21:32:45 +00:00
|
|
|
$parserCache = ParserCache::singleton();
|
2010-05-22 12:18:22 +00:00
|
|
|
$parserCache->save( $parserOutput, $article, $popts );
|
2010-01-29 21:32:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->addParserOutput( $parserOutput );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @deprecated use addWikiTextTidy()
|
|
|
|
|
*/
|
|
|
|
|
public function addSecondaryWikiText( $text, $linestart = true ) {
|
|
|
|
|
wfDeprecated( __METHOD__ );
|
2010-05-22 12:18:22 +00:00
|
|
|
$this->addWikiTextTitleTidy( $text, $this->getTitle(), $linestart );
|
2010-01-29 21:32:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add a ParserOutput object, but without Html
|
|
|
|
|
*
|
|
|
|
|
* @param $parserOutput ParserOutput object
|
2006-11-07 05:37:31 +00:00
|
|
|
*/
|
|
|
|
|
public function addParserOutputNoText( &$parserOutput ) {
|
2004-08-21 14:56:07 +00:00
|
|
|
$this->mLanguageLinks += $parserOutput->getLanguageLinks();
|
2005-12-30 09:33:11 +00:00
|
|
|
$this->addCategoryLinks( $parserOutput->getCategories() );
|
2006-05-01 20:35:08 +00:00
|
|
|
$this->mNewSectionLink = $parserOutput->getNewSection();
|
2009-02-19 22:14:59 +00:00
|
|
|
$this->mHideNewSectionLink = $parserOutput->getHideNewSection();
|
2008-07-24 18:02:20 +00:00
|
|
|
|
2007-12-10 06:02:29 +00:00
|
|
|
$this->mParseWarnings = $parserOutput->getWarnings();
|
2010-06-01 14:28:51 +00:00
|
|
|
if ( !$parserOutput->isCacheable() ) {
|
2005-05-28 11:09:22 +00:00
|
|
|
$this->enableClientCache( false );
|
|
|
|
|
}
|
2006-08-24 17:05:52 +00:00
|
|
|
$this->mNoGallery = $parserOutput->getNoGallery();
|
2010-01-16 13:07:58 +00:00
|
|
|
$this->mHeadItems = array_merge( $this->mHeadItems, $parserOutput->getHeadItems() );
|
2010-09-04 04:00:09 +00:00
|
|
|
$this->addModules( $parserOutput->getModules() );
|
2007-05-31 16:01:26 +00:00
|
|
|
// Versioning...
|
2008-11-01 23:20:25 +00:00
|
|
|
foreach ( (array)$parserOutput->mTemplateIds as $ns => $dbks ) {
|
|
|
|
|
if ( isset( $this->mTemplateIds[$ns] ) ) {
|
|
|
|
|
$this->mTemplateIds[$ns] = $dbks + $this->mTemplateIds[$ns];
|
|
|
|
|
} else {
|
|
|
|
|
$this->mTemplateIds[$ns] = $dbks;
|
|
|
|
|
}
|
|
|
|
|
}
|
Basic integrated audio/video support, with Ogg implementation.
* JavaScript video player based loosely on Greg Maxwell's player
* Image page text snippet customisation
* Abstraction of transform parameters in the parser. Introduced Linker::makeImageLink2().
* Made canRender(), mustRender() depend on file, not just on handler. Moved width=0, height=0 checking to ImageHandler::canRender(), since audio streams have width=height=0 but should be rendered.
Also:
* Automatic upgrade for oldimage rows on image page view, allows media handler selection based on oi_*_mime
* oi_*_mime unconditionally referenced, REQUIRES SCHEMA UPGRADE
* Don't destroy file info for missing files on upgrade
* Simple, centralised extension message file handling
* Made MessageCache::loadAllMessages non-static, optimised for repeated-call case due to abuse in User.php
* Support for lightweight parser output hooks, with callback whitelist for security
* Moved Linker::formatSize() to Language, to join the new formatTimePeriod() and formatBitrate()
* Introduced MagicWordArray, regex capture trick requires that magic word IDs DO NOT CONTAIN HYPHENS.
2007-08-15 10:50:09 +00:00
|
|
|
|
2008-02-20 08:53:12 +00:00
|
|
|
// Hooks registered in the object
|
Basic integrated audio/video support, with Ogg implementation.
* JavaScript video player based loosely on Greg Maxwell's player
* Image page text snippet customisation
* Abstraction of transform parameters in the parser. Introduced Linker::makeImageLink2().
* Made canRender(), mustRender() depend on file, not just on handler. Moved width=0, height=0 checking to ImageHandler::canRender(), since audio streams have width=height=0 but should be rendered.
Also:
* Automatic upgrade for oldimage rows on image page view, allows media handler selection based on oi_*_mime
* oi_*_mime unconditionally referenced, REQUIRES SCHEMA UPGRADE
* Don't destroy file info for missing files on upgrade
* Simple, centralised extension message file handling
* Made MessageCache::loadAllMessages non-static, optimised for repeated-call case due to abuse in User.php
* Support for lightweight parser output hooks, with callback whitelist for security
* Moved Linker::formatSize() to Language, to join the new formatTimePeriod() and formatBitrate()
* Introduced MagicWordArray, regex capture trick requires that magic word IDs DO NOT CONTAIN HYPHENS.
2007-08-15 10:50:09 +00:00
|
|
|
global $wgParserOutputHooks;
|
|
|
|
|
foreach ( $parserOutput->getOutputHooks() as $hookInfo ) {
|
|
|
|
|
list( $hookName, $data ) = $hookInfo;
|
|
|
|
|
if ( isset( $wgParserOutputHooks[$hookName] ) ) {
|
|
|
|
|
call_user_func( $wgParserOutputHooks[$hookName], $this, $parserOutput, $data );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-08-24 17:05:52 +00:00
|
|
|
wfRunHooks( 'OutputPageParserOutput', array( &$this, $parserOutput ) );
|
2006-01-01 20:08:08 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2006-11-07 05:37:31 +00:00
|
|
|
/**
|
2010-01-29 21:32:45 +00:00
|
|
|
* Add a ParserOutput object
|
|
|
|
|
*
|
|
|
|
|
* @param $parserOutput ParserOutput
|
2006-11-07 05:37:31 +00:00
|
|
|
*/
|
2006-01-01 20:08:08 +00:00
|
|
|
function addParserOutput( &$parserOutput ) {
|
|
|
|
|
$this->addParserOutputNoText( $parserOutput );
|
2009-09-18 20:10:25 +00:00
|
|
|
$text = $parserOutput->getText();
|
2010-05-22 12:18:22 +00:00
|
|
|
wfRunHooks( 'OutputPageBeforeHTML', array( &$this, &$text ) );
|
2006-08-24 17:05:52 +00:00
|
|
|
$this->addHTML( $text );
|
2005-07-01 00:03:31 +00:00
|
|
|
}
|
|
|
|
|
|
2006-01-23 18:37:46 +00:00
|
|
|
|
2004-11-25 06:04:16 +00:00
|
|
|
/**
|
|
|
|
|
* Add the output of a QuickTemplate to the output buffer
|
2006-11-07 05:37:31 +00:00
|
|
|
*
|
2010-01-29 21:32:45 +00:00
|
|
|
* @param $template QuickTemplate
|
2004-11-25 06:04:16 +00:00
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function addTemplate( &$template ) {
|
2004-11-25 06:04:16 +00:00
|
|
|
ob_start();
|
|
|
|
|
$template->execute();
|
2005-12-30 09:33:11 +00:00
|
|
|
$this->addHTML( ob_get_contents() );
|
2004-11-25 06:04:16 +00:00
|
|
|
ob_end_clean();
|
|
|
|
|
}
|
2004-11-29 11:26:24 +00:00
|
|
|
|
|
|
|
|
/**
|
2006-04-29 13:15:19 +00:00
|
|
|
* Parse wikitext and return the HTML.
|
2006-11-07 05:37:31 +00:00
|
|
|
*
|
2010-01-29 21:32:45 +00:00
|
|
|
* @param $text String
|
|
|
|
|
* @param $linestart Boolean: is this the start of a line?
|
2010-01-30 17:40:17 +00:00
|
|
|
* @param $interface Boolean: use interface language ($wgLang instead of
|
|
|
|
|
* $wgContLang) while parsing language sensitive magic
|
|
|
|
|
* words like GRAMMAR and PLURAL
|
2010-01-29 21:32:45 +00:00
|
|
|
* @return String: HTML
|
2004-11-29 11:26:24 +00:00
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function parse( $text, $linestart = true, $interface = false ) {
|
2009-04-09 02:22:36 +00:00
|
|
|
global $wgParser;
|
|
|
|
|
if( is_null( $this->getTitle() ) ) {
|
|
|
|
|
throw new MWException( 'Empty $mTitle in ' . __METHOD__ );
|
2008-11-24 01:58:15 +00:00
|
|
|
}
|
2006-07-26 07:15:39 +00:00
|
|
|
$popts = $this->parserOptions();
|
2010-05-22 12:18:22 +00:00
|
|
|
if ( $interface ) {
|
|
|
|
|
$popts->setInterfaceMessage( true );
|
|
|
|
|
}
|
|
|
|
|
$parserOutput = $wgParser->parse(
|
|
|
|
|
$text, $this->getTitle(), $popts,
|
|
|
|
|
$linestart, true, $this->mRevisionId
|
|
|
|
|
);
|
|
|
|
|
if ( $interface ) {
|
|
|
|
|
$popts->setInterfaceMessage( false );
|
|
|
|
|
}
|
2004-11-29 11:26:24 +00:00
|
|
|
return $parserOutput->getText();
|
|
|
|
|
}
|
2005-07-01 00:03:31 +00:00
|
|
|
|
2010-01-29 21:32:45 +00:00
|
|
|
/**
|
|
|
|
|
* Parse wikitext, strip paragraphs, and return the HTML.
|
|
|
|
|
*
|
|
|
|
|
* @param $text String
|
|
|
|
|
* @param $linestart Boolean: is this the start of a line?
|
2010-01-30 17:40:17 +00:00
|
|
|
* @param $interface Boolean: use interface language ($wgLang instead of
|
|
|
|
|
* $wgContLang) while parsing language sensitive magic
|
|
|
|
|
* words like GRAMMAR and PLURAL
|
2010-01-29 21:32:45 +00:00
|
|
|
* @return String: HTML
|
|
|
|
|
*/
|
2009-01-31 01:59:13 +00:00
|
|
|
public function parseInline( $text, $linestart = true, $interface = false ) {
|
|
|
|
|
$parsed = $this->parse( $text, $linestart, $interface );
|
|
|
|
|
|
|
|
|
|
$m = array();
|
|
|
|
|
if ( preg_match( '/^<p>(.*)\n?<\/p>\n?/sU', $parsed, $m ) ) {
|
|
|
|
|
$parsed = $m[1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $parsed;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-17 15:24:43 +00:00
|
|
|
/**
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
* @deprecated
|
2005-04-15 18:37:39 +00:00
|
|
|
*
|
2010-01-29 21:32:45 +00:00
|
|
|
* @param $article Article
|
|
|
|
|
* @return Boolean: true if successful, else false.
|
2004-09-17 15:24:43 +00:00
|
|
|
*/
|
2009-03-18 23:27:48 +00:00
|
|
|
public function tryParserCache( &$article ) {
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
wfDeprecated( __METHOD__ );
|
|
|
|
|
$parserOutput = ParserCache::singleton()->get( $article, $article->getParserOptions() );
|
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-05-22 12:18:22 +00:00
|
|
|
if ( $parserOutput !== false ) {
|
2006-08-24 17:05:52 +00:00
|
|
|
$this->addParserOutput( $parserOutput );
|
2004-06-04 10:40:44 +00:00
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2010-01-29 21:32:45 +00:00
|
|
|
* Set the value of the "s-maxage" part of the "Cache-control" HTTP header
|
|
|
|
|
*
|
|
|
|
|
* @param $maxage Integer: maximum cache time on the Squid, in seconds.
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function setSquidMaxage( $maxage ) {
|
2004-03-13 13:42:17 +00:00
|
|
|
$this->mSquidMaxage = $maxage;
|
2004-02-08 21:12:07 +00:00
|
|
|
}
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* Use enableClientCache(false) to force it to send nocache headers
|
2010-01-29 21:32:45 +00:00
|
|
|
*
|
2006-11-07 05:37:31 +00:00
|
|
|
* @param $state ??
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function enableClientCache( $state ) {
|
2004-03-23 10:19:31 +00:00
|
|
|
return wfSetVar( $this->mEnableClientCache, $state );
|
|
|
|
|
}
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2010-01-29 21:32:45 +00:00
|
|
|
/**
|
|
|
|
|
* Get the list of cookies that will influence on the cache
|
|
|
|
|
*
|
|
|
|
|
* @return Array
|
|
|
|
|
*/
|
2008-02-20 04:13:24 +00:00
|
|
|
function getCacheVaryCookies() {
|
2008-04-10 08:42:36 +00:00
|
|
|
global $wgCookiePrefix, $wgCacheVaryCookies;
|
|
|
|
|
static $cookies;
|
|
|
|
|
if ( $cookies === null ) {
|
2008-04-14 07:45:50 +00:00
|
|
|
$cookies = array_merge(
|
2008-04-10 08:42:36 +00:00
|
|
|
array(
|
|
|
|
|
"{$wgCookiePrefix}Token",
|
|
|
|
|
"{$wgCookiePrefix}LoggedOut",
|
|
|
|
|
session_name()
|
|
|
|
|
),
|
|
|
|
|
$wgCacheVaryCookies
|
|
|
|
|
);
|
2010-05-22 12:18:22 +00:00
|
|
|
wfRunHooks( 'GetCacheVaryCookies', array( $this, &$cookies ) );
|
2008-04-10 08:42:36 +00:00
|
|
|
}
|
|
|
|
|
return $cookies;
|
2008-02-20 04:13:24 +00:00
|
|
|
}
|
|
|
|
|
|
2010-01-29 21:32:45 +00:00
|
|
|
/**
|
|
|
|
|
* Return whether this page is not cacheable because "useskin" or "uselang"
|
2010-05-22 12:18:22 +00:00
|
|
|
* URL parameters were passed.
|
2010-01-29 21:32:45 +00:00
|
|
|
*
|
|
|
|
|
* @return Boolean
|
|
|
|
|
*/
|
2008-02-20 04:13:24 +00:00
|
|
|
function uncacheableBecauseRequestVars() {
|
2005-07-24 06:55:45 +00:00
|
|
|
global $wgRequest;
|
2010-05-22 12:18:22 +00:00
|
|
|
return $wgRequest->getText( 'useskin', false ) === false
|
|
|
|
|
&& $wgRequest->getText( 'uselang', false ) === false;
|
2005-07-24 06:55:45 +00:00
|
|
|
}
|
|
|
|
|
|
2008-02-20 04:13:24 +00:00
|
|
|
/**
|
|
|
|
|
* Check if the request has a cache-varying cookie header
|
|
|
|
|
* If it does, it's very important that we don't allow public caching
|
2010-01-29 21:32:45 +00:00
|
|
|
*
|
|
|
|
|
* @return Boolean
|
2008-02-20 04:13:24 +00:00
|
|
|
*/
|
|
|
|
|
function haveCacheVaryCookies() {
|
2008-11-18 21:37:11 +00:00
|
|
|
global $wgRequest;
|
2008-02-20 04:13:24 +00:00
|
|
|
$cookieHeader = $wgRequest->getHeader( 'cookie' );
|
|
|
|
|
if ( $cookieHeader === false ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
$cvCookies = $this->getCacheVaryCookies();
|
|
|
|
|
foreach ( $cvCookies as $cookieName ) {
|
|
|
|
|
# Check for a simple string match, like the way squid does it
|
2010-07-23 05:11:18 +00:00
|
|
|
if ( strpos( $cookieHeader, $cookieName ) !== false ) {
|
2010-05-22 12:18:22 +00:00
|
|
|
wfDebug( __METHOD__ . ": found $cookieName\n" );
|
2008-02-20 04:13:24 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-05-22 12:18:22 +00:00
|
|
|
wfDebug( __METHOD__ . ": no cache-varying cookies found\n" );
|
2008-02-20 04:13:24 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-29 21:32:45 +00:00
|
|
|
/**
|
|
|
|
|
* Add an HTTP header that will influence on the cache
|
|
|
|
|
*
|
|
|
|
|
* @param $header String: header name
|
|
|
|
|
* @param $option either an Array or null
|
|
|
|
|
*/
|
2009-11-29 06:47:51 +00:00
|
|
|
public function addVaryHeader( $header, $option = null ) {
|
|
|
|
|
if ( !array_key_exists( $header, $this->mVaryHeader ) ) {
|
|
|
|
|
$this->mVaryHeader[$header] = $option;
|
2010-05-22 12:18:22 +00:00
|
|
|
} elseif( is_array( $option ) ) {
|
2009-11-29 06:47:51 +00:00
|
|
|
if( is_array( $this->mVaryHeader[$header] ) ) {
|
|
|
|
|
$this->mVaryHeader[$header] = array_merge( $this->mVaryHeader[$header], $option );
|
2010-05-22 12:18:22 +00:00
|
|
|
} else {
|
2009-11-29 06:47:51 +00:00
|
|
|
$this->mVaryHeader[$header] = $option;
|
2009-11-28 19:13:23 +00:00
|
|
|
}
|
|
|
|
|
}
|
2009-11-29 06:47:51 +00:00
|
|
|
$this->mVaryHeader[$header] = array_unique( $this->mVaryHeader[$header] );
|
2009-11-28 19:13:23 +00:00
|
|
|
}
|
|
|
|
|
|
2010-01-29 21:32:45 +00:00
|
|
|
/**
|
|
|
|
|
* Get a complete X-Vary-Options header
|
|
|
|
|
*
|
|
|
|
|
* @return String
|
|
|
|
|
*/
|
2008-02-08 07:12:38 +00:00
|
|
|
public function getXVO() {
|
2008-02-20 04:13:24 +00:00
|
|
|
$cvCookies = $this->getCacheVaryCookies();
|
2010-05-22 11:47:56 +00:00
|
|
|
|
2009-11-28 19:13:23 +00:00
|
|
|
$cookiesOption = array();
|
2008-02-20 04:13:24 +00:00
|
|
|
foreach ( $cvCookies as $cookieName ) {
|
2009-11-28 19:13:23 +00:00
|
|
|
$cookiesOption[] = 'string-contains=' . $cookieName;
|
|
|
|
|
}
|
2009-11-29 06:47:51 +00:00
|
|
|
$this->addVaryHeader( 'Cookie', $cookiesOption );
|
2010-05-22 11:47:56 +00:00
|
|
|
|
2009-11-28 19:13:23 +00:00
|
|
|
$headers = array();
|
2009-11-29 06:47:51 +00:00
|
|
|
foreach( $this->mVaryHeader as $header => $option ) {
|
2009-11-28 19:13:23 +00:00
|
|
|
$newheader = $header;
|
2010-05-22 12:18:22 +00:00
|
|
|
if( is_array( $option ) ) {
|
2009-11-28 19:13:23 +00:00
|
|
|
$newheader .= ';' . implode( ';', $option );
|
2010-05-22 12:18:22 +00:00
|
|
|
}
|
2009-11-28 19:13:23 +00:00
|
|
|
$headers[] = $newheader;
|
|
|
|
|
}
|
|
|
|
|
$xvo = 'X-Vary-Options: ' . implode( ',', $headers );
|
2010-05-22 11:47:56 +00:00
|
|
|
|
2008-02-20 04:13:24 +00:00
|
|
|
return $xvo;
|
2008-02-08 07:12:38 +00:00
|
|
|
}
|
|
|
|
|
|
2010-01-29 21:32:45 +00:00
|
|
|
/**
|
|
|
|
|
* bug 21672: Add Accept-Language to Vary and XVO headers
|
2010-01-30 17:40:17 +00:00
|
|
|
* if there's no 'variant' parameter existed in GET.
|
2010-01-29 21:32:45 +00:00
|
|
|
*
|
|
|
|
|
* For example:
|
|
|
|
|
* /w/index.php?title=Main_page should always be served; but
|
|
|
|
|
* /w/index.php?title=Main_page&variant=zh-cn should never be served.
|
|
|
|
|
*/
|
2009-12-21 18:55:42 +00:00
|
|
|
function addAcceptLanguage() {
|
2009-12-22 14:12:23 +00:00
|
|
|
global $wgRequest, $wgContLang;
|
2010-05-22 12:18:22 +00:00
|
|
|
if( !$wgRequest->getCheck( 'variant' ) && $wgContLang->hasVariants() ) {
|
2009-12-21 18:55:42 +00:00
|
|
|
$variants = $wgContLang->getVariants();
|
|
|
|
|
$aloption = array();
|
|
|
|
|
foreach ( $variants as $variant ) {
|
2010-05-22 12:18:22 +00:00
|
|
|
if( $variant === $wgContLang->getCode() ) {
|
2009-12-21 18:55:42 +00:00
|
|
|
continue;
|
2010-05-22 12:18:22 +00:00
|
|
|
} else {
|
2010-10-28 16:58:39 +00:00
|
|
|
$aloption[] = 'string-contains=' . $variant;
|
|
|
|
|
|
|
|
|
|
// IE and some other browsers use another form of language code
|
|
|
|
|
// in their Accept-Language header, like "zh-CN" or "zh-TW".
|
|
|
|
|
// We should handle these too.
|
|
|
|
|
$ievariant = explode( '-', $variant );
|
|
|
|
|
if ( count( $ievariant ) == 2 ) {
|
|
|
|
|
$ievariant[1] = strtoupper( $ievariant[1] );
|
|
|
|
|
$ievariant = implode( '-', $ievariant );
|
|
|
|
|
$aloption[] = 'string-contains=' . $ievariant;
|
|
|
|
|
}
|
2010-05-22 12:18:22 +00:00
|
|
|
}
|
2009-12-21 18:55:42 +00:00
|
|
|
}
|
|
|
|
|
$this->addVaryHeader( 'Accept-Language', $aloption );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-29 21:32:45 +00:00
|
|
|
/**
|
|
|
|
|
* Send cache control HTTP headers
|
|
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function sendCacheControl() {
|
2009-07-24 20:01:23 +00:00
|
|
|
global $wgUseSquid, $wgUseESI, $wgUseETag, $wgSquidMaxage, $wgRequest, $wgUseXVO;
|
2005-07-01 00:03:31 +00:00
|
|
|
|
2008-02-08 07:12:38 +00:00
|
|
|
$response = $wgRequest->response();
|
2010-05-22 12:18:22 +00:00
|
|
|
if ( $wgUseETag && $this->mETag ) {
|
|
|
|
|
$response->header( "ETag: $this->mETag" );
|
|
|
|
|
}
|
2008-12-23 19:39:00 +00:00
|
|
|
|
2009-12-21 18:55:42 +00:00
|
|
|
$this->addAcceptLanguage();
|
|
|
|
|
|
2008-12-23 19:39:00 +00:00
|
|
|
# don't serve compressed data to clients who can't handle it
|
2005-03-08 02:58:43 +00:00
|
|
|
# maintain different caches for logged-in users and non-logged in ones
|
2009-11-29 06:47:51 +00:00
|
|
|
$response->header( 'Vary: ' . join( ', ', array_keys( $this->mVaryHeader ) ) );
|
2008-02-08 07:12:38 +00:00
|
|
|
|
2009-07-24 20:01:23 +00:00
|
|
|
if ( $wgUseXVO ) {
|
|
|
|
|
# Add an X-Vary-Options header for Squid with Wikimedia patches
|
|
|
|
|
$response->header( $this->getXVO() );
|
|
|
|
|
}
|
2008-02-08 07:12:38 +00:00
|
|
|
|
2008-02-20 04:13:24 +00:00
|
|
|
if( !$this->uncacheableBecauseRequestVars() && $this->mEnableClientCache ) {
|
2010-05-22 12:18:22 +00:00
|
|
|
if(
|
|
|
|
|
$wgUseSquid && session_id() == '' && !$this->isPrintable() &&
|
|
|
|
|
$this->mSquidMaxage != 0 && !$this->haveCacheVaryCookies()
|
|
|
|
|
)
|
2004-02-04 00:45:48 +00:00
|
|
|
{
|
2008-12-23 19:39:00 +00:00
|
|
|
if ( $wgUseESI ) {
|
2004-02-02 01:40:03 +00:00
|
|
|
# We'll purge the proxy cache explicitly, but require end user agents
|
2004-01-31 12:45:09 +00:00
|
|
|
# to revalidate against the proxy on each visit.
|
|
|
|
|
# Surrogate-Control controls our Squid, Cache-Control downstream caches
|
2008-04-16 13:46:16 +00:00
|
|
|
wfDebug( __METHOD__ . ": proxy caching with ESI; {$this->mLastModified} **\n", false );
|
2004-01-31 12:45:09 +00:00
|
|
|
# start with a shorter timeout for initial testing
|
|
|
|
|
# header( 'Surrogate-Control: max-age=2678400+2678400, content="ESI/1.0"');
|
2008-02-08 07:12:38 +00:00
|
|
|
$response->header( 'Surrogate-Control: max-age='.$wgSquidMaxage.'+'.$this->mSquidMaxage.', content="ESI/1.0"');
|
|
|
|
|
$response->header( 'Cache-Control: s-maxage=0, must-revalidate, max-age=0' );
|
2004-01-31 12:45:09 +00:00
|
|
|
} else {
|
|
|
|
|
# We'll purge the proxy cache for anons explicitly, but require end user agents
|
|
|
|
|
# to revalidate against the proxy on each visit.
|
2004-07-08 14:53:54 +00:00
|
|
|
# IMPORTANT! The Squid needs to replace the Cache-Control header with
|
2004-01-31 12:45:09 +00:00
|
|
|
# Cache-Control: s-maxage=0, must-revalidate, max-age=0
|
2008-04-16 13:46:16 +00:00
|
|
|
wfDebug( __METHOD__ . ": local proxy caching; {$this->mLastModified} **\n", false );
|
2004-01-31 12:45:09 +00:00
|
|
|
# start with a shorter timeout for initial testing
|
|
|
|
|
# header( "Cache-Control: s-maxage=2678400, must-revalidate, max-age=0" );
|
2008-02-08 07:12:38 +00:00
|
|
|
$response->header( 'Cache-Control: s-maxage='.$this->mSquidMaxage.', must-revalidate, max-age=0' );
|
2004-01-31 12:45:09 +00:00
|
|
|
}
|
2004-01-31 10:29:31 +00:00
|
|
|
} else {
|
|
|
|
|
# We do want clients to cache if they can, but they *must* check for updates
|
|
|
|
|
# on revisiting the page.
|
2008-04-16 13:46:16 +00:00
|
|
|
wfDebug( __METHOD__ . ": private caching; {$this->mLastModified} **\n", false );
|
2008-02-08 07:12:38 +00:00
|
|
|
$response->header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', 0 ) . ' GMT' );
|
|
|
|
|
$response->header( "Cache-Control: private, must-revalidate, max-age=0" );
|
2004-01-31 10:29:31 +00:00
|
|
|
}
|
2008-12-23 19:39:00 +00:00
|
|
|
if($this->mLastModified) {
|
2008-08-29 08:40:13 +00:00
|
|
|
$response->header( "Last-Modified: {$this->mLastModified}" );
|
|
|
|
|
}
|
2003-07-03 10:18:07 +00:00
|
|
|
} else {
|
2008-04-16 13:46:16 +00:00
|
|
|
wfDebug( __METHOD__ . ": no caching **\n", false );
|
2004-03-23 10:19:31 +00:00
|
|
|
|
|
|
|
|
# In general, the absence of a last modified header should be enough to prevent
|
|
|
|
|
# the client from using its cache. We send a few other things just to make sure.
|
2008-02-08 07:12:38 +00:00
|
|
|
$response->header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', 0 ) . ' GMT' );
|
|
|
|
|
$response->header( 'Cache-Control: no-cache, no-store, max-age=0, must-revalidate' );
|
|
|
|
|
$response->header( 'Pragma: no-cache' );
|
2003-07-03 10:18:07 +00:00
|
|
|
}
|
|
|
|
|
}
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2009-12-01 20:56:43 +00:00
|
|
|
/**
|
|
|
|
|
* Get the message associed with the HTTP response code $code
|
|
|
|
|
*
|
|
|
|
|
* @param $code Integer: status code
|
|
|
|
|
* @return String or null: message or null if $code is not in the list of
|
|
|
|
|
* messages
|
|
|
|
|
*/
|
|
|
|
|
public static function getStatusMessage( $code ) {
|
|
|
|
|
static $statusMessage = array(
|
|
|
|
|
100 => 'Continue',
|
|
|
|
|
101 => 'Switching Protocols',
|
|
|
|
|
102 => 'Processing',
|
|
|
|
|
200 => 'OK',
|
|
|
|
|
201 => 'Created',
|
|
|
|
|
202 => 'Accepted',
|
|
|
|
|
203 => 'Non-Authoritative Information',
|
|
|
|
|
204 => 'No Content',
|
|
|
|
|
205 => 'Reset Content',
|
|
|
|
|
206 => 'Partial Content',
|
|
|
|
|
207 => 'Multi-Status',
|
|
|
|
|
300 => 'Multiple Choices',
|
|
|
|
|
301 => 'Moved Permanently',
|
|
|
|
|
302 => 'Found',
|
|
|
|
|
303 => 'See Other',
|
|
|
|
|
304 => 'Not Modified',
|
|
|
|
|
305 => 'Use Proxy',
|
|
|
|
|
307 => 'Temporary Redirect',
|
|
|
|
|
400 => 'Bad Request',
|
|
|
|
|
401 => 'Unauthorized',
|
|
|
|
|
402 => 'Payment Required',
|
|
|
|
|
403 => 'Forbidden',
|
|
|
|
|
404 => 'Not Found',
|
|
|
|
|
405 => 'Method Not Allowed',
|
|
|
|
|
406 => 'Not Acceptable',
|
|
|
|
|
407 => 'Proxy Authentication Required',
|
|
|
|
|
408 => 'Request Timeout',
|
|
|
|
|
409 => 'Conflict',
|
|
|
|
|
410 => 'Gone',
|
|
|
|
|
411 => 'Length Required',
|
|
|
|
|
412 => 'Precondition Failed',
|
|
|
|
|
413 => 'Request Entity Too Large',
|
|
|
|
|
414 => 'Request-URI Too Large',
|
|
|
|
|
415 => 'Unsupported Media Type',
|
|
|
|
|
416 => 'Request Range Not Satisfiable',
|
|
|
|
|
417 => 'Expectation Failed',
|
|
|
|
|
422 => 'Unprocessable Entity',
|
|
|
|
|
423 => 'Locked',
|
|
|
|
|
424 => 'Failed Dependency',
|
|
|
|
|
500 => 'Internal Server Error',
|
|
|
|
|
501 => 'Not Implemented',
|
|
|
|
|
502 => 'Bad Gateway',
|
|
|
|
|
503 => 'Service Unavailable',
|
|
|
|
|
504 => 'Gateway Timeout',
|
|
|
|
|
505 => 'HTTP Version Not Supported',
|
|
|
|
|
507 => 'Insufficient Storage'
|
|
|
|
|
);
|
|
|
|
|
return isset( $statusMessage[$code] ) ? $statusMessage[$code] : null;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* Finally, all the text has been munged and accumulated into
|
|
|
|
|
* the object, let's actually output it:
|
|
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function output() {
|
2006-08-14 18:18:35 +00:00
|
|
|
global $wgUser, $wgOutputEncoding, $wgRequest;
|
2010-09-07 22:37:55 +00:00
|
|
|
global $wgLanguageCode, $wgDebugRedirects, $wgMimeType;
|
2009-08-11 00:09:24 +00:00
|
|
|
global $wgUseAjax, $wgAjaxWatch;
|
2008-10-10 01:15:11 +00:00
|
|
|
global $wgEnableMWSuggest, $wgUniversalEditButton;
|
2010-09-04 13:27:12 +00:00
|
|
|
global $wgArticle;
|
2004-10-08 04:27:07 +00:00
|
|
|
|
2010-05-22 12:18:22 +00:00
|
|
|
if( $this->mDoNothing ) {
|
2008-12-31 17:56:04 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2008-04-16 13:46:16 +00:00
|
|
|
wfProfileIn( __METHOD__ );
|
2010-01-06 19:59:42 +00:00
|
|
|
if ( $this->mRedirect != '' ) {
|
2008-02-13 05:59:14 +00:00
|
|
|
# Standards require redirect URLs to be absolute
|
|
|
|
|
$this->mRedirect = wfExpandUrl( $this->mRedirect );
|
2009-12-01 20:56:43 +00:00
|
|
|
if( $this->mRedirectCode == '301' || $this->mRedirectCode == '303' ) {
|
2004-03-05 03:18:31 +00:00
|
|
|
if( !$wgDebugRedirects ) {
|
2009-12-01 20:56:43 +00:00
|
|
|
$message = self::getStatusMessage( $this->mRedirectCode );
|
|
|
|
|
$wgRequest->response()->header( "HTTP/1.1 {$this->mRedirectCode} $message" );
|
2004-03-05 03:18:31 +00:00
|
|
|
}
|
2004-12-19 11:11:52 +00:00
|
|
|
$this->mLastModified = wfTimestamp( TS_RFC2822 );
|
2004-03-01 22:16:39 +00:00
|
|
|
}
|
|
|
|
|
$this->sendCacheControl();
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2009-12-01 20:56:43 +00:00
|
|
|
$wgRequest->response()->header( "Content-Type: text/html; charset=utf-8" );
|
2004-03-05 03:18:31 +00:00
|
|
|
if( $wgDebugRedirects ) {
|
|
|
|
|
$url = htmlspecialchars( $this->mRedirect );
|
|
|
|
|
print "<html>\n<head>\n<title>Redirect</title>\n</head>\n<body>\n";
|
|
|
|
|
print "<p>Location: <a href=\"$url\">$url</a></p>\n";
|
|
|
|
|
print "</body>\n</html>\n";
|
|
|
|
|
} else {
|
2009-12-01 20:56:43 +00:00
|
|
|
$wgRequest->response()->header( 'Location: ' . $this->mRedirect );
|
2004-03-05 03:18:31 +00:00
|
|
|
}
|
2008-04-16 13:46:16 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2003-04-14 23:10:40 +00:00
|
|
|
return;
|
2009-12-01 20:56:43 +00:00
|
|
|
} elseif ( $this->mStatusCode ) {
|
|
|
|
|
$message = self::getStatusMessage( $this->mStatusCode );
|
2010-05-22 12:18:22 +00:00
|
|
|
if ( $message ) {
|
2009-12-01 20:56:43 +00:00
|
|
|
$wgRequest->response()->header( 'HTTP/1.1 ' . $this->mStatusCode . ' ' . $message );
|
2010-05-22 12:18:22 +00:00
|
|
|
}
|
2005-10-12 03:12:40 +00:00
|
|
|
}
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2008-01-14 10:23:48 +00:00
|
|
|
$sk = $wgUser->getSkin();
|
2010-10-02 13:45:35 +00:00
|
|
|
|
2010-09-04 04:00:09 +00:00
|
|
|
// Add base resources
|
|
|
|
|
$this->addModules( array( 'mediawiki.legacy.wikibits' ) );
|
2010-10-23 17:24:07 +00:00
|
|
|
$this->addModules( array( 'mediawiki.util' ) );
|
2010-10-02 13:45:35 +00:00
|
|
|
|
2010-09-04 04:00:09 +00:00
|
|
|
// Add various resources if required
|
2008-01-14 10:23:48 +00:00
|
|
|
if ( $wgUseAjax ) {
|
2010-09-04 04:00:09 +00:00
|
|
|
$this->addModules( 'mediawiki.legacy.ajax' );
|
2008-01-14 10:23:48 +00:00
|
|
|
|
|
|
|
|
wfRunHooks( 'AjaxAddScript', array( &$this ) );
|
|
|
|
|
|
|
|
|
|
if( $wgAjaxWatch && $wgUser->isLoggedIn() ) {
|
2010-09-04 04:00:09 +00:00
|
|
|
$this->addModules( 'mediawiki.legacy.ajaxwatch' );
|
2008-01-14 10:23:48 +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
|
|
|
|
2010-05-22 12:18:22 +00:00
|
|
|
if ( $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ) {
|
2010-09-04 04:00:09 +00:00
|
|
|
$this->addModules( 'mediawiki.legacy.mwsuggest' );
|
2008-04-15 23:06:28 +00:00
|
|
|
}
|
2008-01-14 10:23:48 +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-05-12 23:37:51 +00:00
|
|
|
if( $wgUser->getBoolOption( 'editsectiononrightclick' ) ) {
|
2010-10-31 23:42:08 +00:00
|
|
|
$this->addModules( 'mediawiki.advanced.rightclickedit' );
|
2008-05-12 23:37:51 +00:00
|
|
|
}
|
2009-09-10 06:43:01 +00:00
|
|
|
|
2008-10-10 01:15:11 +00:00
|
|
|
if( $wgUniversalEditButton ) {
|
2009-04-09 02:22:36 +00:00
|
|
|
if( isset( $wgArticle ) && $this->getTitle() && $this->getTitle()->quickUserCan( 'edit' )
|
|
|
|
|
&& ( $this->getTitle()->exists() || $this->getTitle()->quickUserCan( 'create' ) ) ) {
|
2008-10-22 18:07:15 +00:00
|
|
|
// Original UniversalEditButton
|
2010-05-22 12:18:22 +00:00
|
|
|
$msg = wfMsg( 'edit' );
|
2008-10-10 01:15:11 +00:00
|
|
|
$this->addLink( array(
|
|
|
|
|
'rel' => 'alternate',
|
|
|
|
|
'type' => 'application/x-wiki',
|
2009-09-07 18:54:58 +00:00
|
|
|
'title' => $msg,
|
2009-04-09 02:22:36 +00:00
|
|
|
'href' => $this->getTitle()->getLocalURL( 'action=edit' )
|
2008-10-10 01:15:11 +00:00
|
|
|
) );
|
2008-10-22 18:07:15 +00:00
|
|
|
// Alternate edit link
|
|
|
|
|
$this->addLink( array(
|
|
|
|
|
'rel' => 'edit',
|
2009-09-07 18:54:58 +00:00
|
|
|
'title' => $msg,
|
2009-04-09 02:22:36 +00:00
|
|
|
'href' => $this->getTitle()->getLocalURL( 'action=edit' )
|
2008-10-22 18:07:15 +00:00
|
|
|
) );
|
2008-10-10 01:15:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
2010-05-22 11:47:56 +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
|
|
|
|
2004-11-12 09:34:11 +00:00
|
|
|
# Buffer output; final headers may depend on later processing
|
2008-09-15 01:27:22 +00:00
|
|
|
ob_start();
|
2004-11-12 09:34:11 +00:00
|
|
|
|
2006-08-14 18:18:35 +00:00
|
|
|
$wgRequest->response()->header( "Content-type: $wgMimeType; charset={$wgOutputEncoding}" );
|
2010-09-07 22:37:55 +00:00
|
|
|
$wgRequest->response()->header( 'Content-language: ' . $wgLanguageCode );
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2010-05-22 12:18:22 +00:00
|
|
|
if ( $this->mArticleBodyOnly ) {
|
|
|
|
|
$this->out( $this->mBodytext );
|
2005-07-03 04:00:33 +00:00
|
|
|
} else {
|
2008-04-06 20:25:45 +00:00
|
|
|
// Hook that allows last minute changes to the output page, e.g.
|
|
|
|
|
// adding of CSS or Javascript by extensions.
|
2008-04-07 17:53:31 +00:00
|
|
|
wfRunHooks( 'BeforePageDisplay', array( &$this, &$sk ) );
|
2008-04-06 20:25:45 +00:00
|
|
|
|
2005-07-03 04:00:33 +00:00
|
|
|
wfProfileIn( 'Output-skin' );
|
|
|
|
|
$sk->outputPage( $this );
|
|
|
|
|
wfProfileOut( 'Output-skin' );
|
|
|
|
|
}
|
2005-07-01 00:03:31 +00:00
|
|
|
|
2004-11-12 09:34:11 +00:00
|
|
|
$this->sendCacheControl();
|
|
|
|
|
ob_end_flush();
|
2008-04-16 13:46:16 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2006-11-07 05:37:31 +00:00
|
|
|
/**
|
2009-04-07 18:21:07 +00:00
|
|
|
* Actually output something with print(). Performs an iconv to the
|
|
|
|
|
* output encoding, if needed.
|
2010-01-29 21:32:45 +00:00
|
|
|
*
|
|
|
|
|
* @param $ins String: the string to output
|
2006-11-07 05:37:31 +00:00
|
|
|
*/
|
|
|
|
|
public function out( $ins ) {
|
2004-09-24 13:14:52 +00:00
|
|
|
global $wgInputEncoding, $wgOutputEncoding, $wgContLang;
|
2003-04-14 23:10:40 +00:00
|
|
|
if ( 0 == strcmp( $wgInputEncoding, $wgOutputEncoding ) ) {
|
|
|
|
|
$outs = $ins;
|
|
|
|
|
} else {
|
2004-09-24 13:14:52 +00:00
|
|
|
$outs = $wgContLang->iconv( $wgInputEncoding, $wgOutputEncoding, $ins );
|
2010-05-22 12:18:22 +00:00
|
|
|
if ( false === $outs ) {
|
|
|
|
|
$outs = $ins;
|
|
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
print $outs;
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-07 05:37:31 +00:00
|
|
|
/**
|
|
|
|
|
* @todo document
|
|
|
|
|
*/
|
2006-11-29 05:45:03 +00:00
|
|
|
public static function setEncodings() {
|
2003-11-18 02:39:38 +00:00
|
|
|
global $wgInputEncoding, $wgOutputEncoding;
|
2003-04-14 23:10:40 +00:00
|
|
|
|
|
|
|
|
$wgInputEncoding = strtolower( $wgInputEncoding );
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2003-11-15 23:06:59 +00:00
|
|
|
if ( empty( $_SERVER['HTTP_ACCEPT_CHARSET'] ) ) {
|
2003-04-14 23:10:40 +00:00
|
|
|
$wgOutputEncoding = strtolower( $wgOutputEncoding );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$wgOutputEncoding = $wgInputEncoding;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2010-01-29 21:32:45 +00:00
|
|
|
* @deprecated use wfReportTime() instead.
|
|
|
|
|
*
|
|
|
|
|
* @return String
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function reportTime() {
|
2008-04-16 13:46:16 +00:00
|
|
|
wfDeprecated( __METHOD__ );
|
2005-09-24 13:37:26 +00:00
|
|
|
$time = wfReportTime();
|
|
|
|
|
return $time;
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2006-01-06 23:09:37 +00:00
|
|
|
/**
|
2006-11-07 05:37:31 +00:00
|
|
|
* Produce a "user is blocked" page.
|
|
|
|
|
*
|
2010-01-29 21:32:45 +00:00
|
|
|
* @param $return Boolean: whether to have a "return to $wgTitle" message or not.
|
2006-11-07 05:37:31 +00:00
|
|
|
* @return nothing
|
2006-01-06 23:09:37 +00:00
|
|
|
*/
|
2006-06-24 20:58:10 +00:00
|
|
|
function blockedPage( $return = true ) {
|
2009-04-09 02:22:36 +00:00
|
|
|
global $wgUser, $wgContLang, $wgLang;
|
2006-01-06 23:09:37 +00:00
|
|
|
|
|
|
|
|
$this->setPageTitle( wfMsg( 'blockedtitle' ) );
|
2008-07-23 19:05:43 +00:00
|
|
|
$this->setRobotPolicy( 'noindex,nofollow' );
|
2006-01-06 23:09:37 +00:00
|
|
|
$this->setArticleRelated( false );
|
|
|
|
|
|
2007-08-01 20:11:29 +00:00
|
|
|
$name = User::whoIs( $wgUser->blockedBy() );
|
2006-01-06 23:09:37 +00:00
|
|
|
$reason = $wgUser->blockedFor();
|
2007-11-15 14:42:20 +00:00
|
|
|
if( $reason == '' ) {
|
|
|
|
|
$reason = wfMsg( 'blockednoreason' );
|
|
|
|
|
}
|
2010-05-22 12:18:22 +00:00
|
|
|
$blockTimestamp = $wgLang->timeanddate(
|
|
|
|
|
wfTimestamp( TS_MW, $wgUser->mBlock->mTimestamp ), true
|
|
|
|
|
);
|
2006-06-01 08:19:02 +00:00
|
|
|
$ip = wfGetIP();
|
2006-01-06 23:09:37 +00:00
|
|
|
|
|
|
|
|
$link = '[[' . $wgContLang->getNsText( NS_USER ) . ":{$name}|{$name}]]";
|
|
|
|
|
|
2006-12-13 05:44:46 +00:00
|
|
|
$blockid = $wgUser->mBlock->mId;
|
|
|
|
|
|
2007-05-03 15:40:38 +00:00
|
|
|
$blockExpiry = $wgUser->mBlock->mExpiry;
|
|
|
|
|
if ( $blockExpiry == 'infinity' ) {
|
2007-05-04 05:46:44 +00:00
|
|
|
// Entry in database (table ipblocks) is 'infinity' but 'ipboptions' uses 'infinite' or 'indefinite'
|
2007-05-03 15:40:38 +00:00
|
|
|
// Search for localization in 'ipboptions'
|
|
|
|
|
$scBlockExpiryOptions = wfMsg( 'ipboptions' );
|
|
|
|
|
foreach ( explode( ',', $scBlockExpiryOptions ) as $option ) {
|
2010-05-22 12:18:22 +00:00
|
|
|
if ( strpos( $option, ':' ) === false ) {
|
2007-05-03 15:40:38 +00:00
|
|
|
continue;
|
2010-05-22 12:18:22 +00:00
|
|
|
}
|
|
|
|
|
list( $show, $value ) = explode( ':', $option );
|
2007-05-04 05:46:44 +00:00
|
|
|
if ( $value == 'infinite' || $value == 'indefinite' ) {
|
2007-05-03 15:40:38 +00:00
|
|
|
$blockExpiry = $show;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2010-05-22 12:18:22 +00:00
|
|
|
$blockExpiry = $wgLang->timeanddate(
|
|
|
|
|
wfTimestamp( TS_MW, $blockExpiry ),
|
|
|
|
|
true
|
|
|
|
|
);
|
2007-05-03 15:40:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $wgUser->mBlock->mAuto ) {
|
|
|
|
|
$msg = 'autoblockedtext';
|
|
|
|
|
} else {
|
|
|
|
|
$msg = 'blockedtext';
|
|
|
|
|
}
|
|
|
|
|
|
2007-06-02 00:03:22 +00:00
|
|
|
/* $ip returns who *is* being blocked, $intended contains who was meant to be blocked.
|
2010-05-22 12:18:22 +00:00
|
|
|
* This could be a username, an IP range, or a single IP. */
|
2007-06-02 00:03:22 +00:00
|
|
|
$intended = $wgUser->mBlock->mAddress;
|
2007-06-01 07:57:17 +00:00
|
|
|
|
2010-05-22 12:18:22 +00:00
|
|
|
$this->addWikiMsg(
|
|
|
|
|
$msg, $link, $reason, $ip, $name, $blockid, $blockExpiry,
|
|
|
|
|
$intended, $blockTimestamp
|
|
|
|
|
);
|
2007-07-31 13:59:29 +00:00
|
|
|
|
2006-04-29 23:30:46 +00:00
|
|
|
# Don't auto-return to special pages
|
2006-06-24 20:58:10 +00:00
|
|
|
if( $return ) {
|
2009-04-09 02:22:36 +00:00
|
|
|
$return = $this->getTitle()->getNamespace() > -1 ? $this->getTitle() : null;
|
2008-04-16 13:46:16 +00:00
|
|
|
$this->returnToMain( null, $return );
|
2006-06-24 20:58:10 +00:00
|
|
|
}
|
2006-01-06 23:09:37 +00:00
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2007-05-18 20:46:42 +00:00
|
|
|
* Output a standard error page
|
2006-11-07 05:37:31 +00:00
|
|
|
*
|
2010-01-29 21:32:45 +00:00
|
|
|
* @param $title String: message key for page title
|
|
|
|
|
* @param $msg String: message key for page text
|
|
|
|
|
* @param $params Array: message parameters
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2007-05-18 20:46:42 +00:00
|
|
|
public function showErrorPage( $title, $msg, $params = array() ) {
|
2009-04-09 02:22:36 +00:00
|
|
|
if ( $this->getTitle() ) {
|
|
|
|
|
$this->mDebugtext .= 'Original title: ' . $this->getTitle()->getPrefixedText() . "\n";
|
2008-01-13 12:29:43 +00:00
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
$this->setPageTitle( wfMsg( $title ) );
|
2004-08-22 17:24:50 +00:00
|
|
|
$this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
|
2008-07-23 19:05:43 +00:00
|
|
|
$this->setRobotPolicy( 'noindex,nofollow' );
|
2004-01-17 09:49:43 +00:00
|
|
|
$this->setArticleRelated( false );
|
2004-03-23 10:19:31 +00:00
|
|
|
$this->enableClientCache( false );
|
2004-08-22 17:24:50 +00:00
|
|
|
$this->mRedirect = '';
|
|
|
|
|
$this->mBodytext = '';
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2007-08-22 06:41:50 +00:00
|
|
|
array_unshift( $params, 'parse' );
|
2007-05-18 20:46:42 +00:00
|
|
|
array_unshift( $params, $msg );
|
2008-11-06 22:20:29 +00:00
|
|
|
$this->addHTML( call_user_func_array( 'wfMsgExt', $params ) );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-16 13:46:16 +00:00
|
|
|
$this->returnToMain();
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2007-08-06 11:30:40 +00:00
|
|
|
/**
|
|
|
|
|
* Output a standard permission error page
|
|
|
|
|
*
|
2010-01-29 21:32:45 +00:00
|
|
|
* @param $errors Array: error message keys
|
|
|
|
|
* @param $action String: action that was denied or null if unknown
|
2007-08-06 11:30:40 +00:00
|
|
|
*/
|
2010-01-29 21:32:45 +00:00
|
|
|
public function showPermissionsErrorPage( $errors, $action = null ) {
|
2007-08-01 10:19:26 +00:00
|
|
|
$this->mDebugtext .= 'Original title: ' .
|
2009-04-09 02:22:36 +00:00
|
|
|
$this->getTitle()->getPrefixedText() . "\n";
|
2007-08-01 10:19:26 +00:00
|
|
|
$this->setPageTitle( wfMsg( 'permissionserrors' ) );
|
|
|
|
|
$this->setHTMLTitle( wfMsg( 'permissionserrors' ) );
|
2008-07-23 19:05:43 +00:00
|
|
|
$this->setRobotPolicy( 'noindex,nofollow' );
|
2007-08-01 10:19:26 +00:00
|
|
|
$this->setArticleRelated( false );
|
|
|
|
|
$this->enableClientCache( false );
|
|
|
|
|
$this->mRedirect = '';
|
|
|
|
|
$this->mBodytext = '';
|
2008-05-23 10:34:11 +00:00
|
|
|
$this->addWikiText( $this->formatPermissionsErrorMessage( $errors, $action ) );
|
2007-08-01 10:19:26 +00:00
|
|
|
}
|
|
|
|
|
|
2005-06-26 06:49:56 +00:00
|
|
|
/**
|
|
|
|
|
* Display an error page indicating that a given version of MediaWiki is
|
|
|
|
|
* required to use it
|
|
|
|
|
*
|
2010-01-29 21:32:45 +00:00
|
|
|
* @param $version Mixed: the version of MediaWiki needed to use the page
|
2005-06-26 06:49:56 +00:00
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function versionRequired( $version ) {
|
2005-06-26 06:49:56 +00:00
|
|
|
$this->setPageTitle( wfMsg( 'versionrequired', $version ) );
|
|
|
|
|
$this->setHTMLTitle( wfMsg( 'versionrequired', $version ) );
|
2008-07-23 19:05:43 +00:00
|
|
|
$this->setRobotPolicy( 'noindex,nofollow' );
|
2005-06-26 06:49:56 +00:00
|
|
|
$this->setArticleRelated( false );
|
|
|
|
|
$this->mBodytext = '';
|
|
|
|
|
|
2008-02-18 07:25:35 +00:00
|
|
|
$this->addWikiMsg( 'versionrequiredtext', $version );
|
2005-06-26 06:49:56 +00:00
|
|
|
$this->returnToMain();
|
|
|
|
|
}
|
2005-07-01 00:03:31 +00:00
|
|
|
|
2005-06-19 06:25:53 +00:00
|
|
|
/**
|
|
|
|
|
* Display an error page noting that a given permission bit is required.
|
2006-11-07 05:37:31 +00:00
|
|
|
*
|
2010-01-29 21:32:45 +00:00
|
|
|
* @param $permission String: key required
|
2005-06-19 06:25:53 +00:00
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function permissionRequired( $permission ) {
|
2009-04-09 08:53:15 +00:00
|
|
|
global $wgLang;
|
2005-06-19 06:25:53 +00:00
|
|
|
|
|
|
|
|
$this->setPageTitle( wfMsg( 'badaccess' ) );
|
|
|
|
|
$this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
|
2008-07-23 19:05:43 +00:00
|
|
|
$this->setRobotPolicy( 'noindex,nofollow' );
|
2005-06-19 06:25:53 +00:00
|
|
|
$this->setArticleRelated( false );
|
|
|
|
|
$this->mBodytext = '';
|
|
|
|
|
|
2008-08-05 05:32:30 +00:00
|
|
|
$groups = array_map( array( 'User', 'makeGroupLinkWiki' ),
|
|
|
|
|
User::getGroupsWithPermission( $permission ) );
|
|
|
|
|
if( $groups ) {
|
2010-05-22 12:18:22 +00:00
|
|
|
$this->addWikiMsg(
|
|
|
|
|
'badaccess-groups',
|
2009-03-08 19:40:09 +00:00
|
|
|
$wgLang->commaList( $groups ),
|
2010-05-22 12:18:22 +00:00
|
|
|
count( $groups )
|
|
|
|
|
);
|
2008-08-05 05:32:30 +00:00
|
|
|
} else {
|
|
|
|
|
$this->addWikiMsg( 'badaccess-group0' );
|
2007-08-27 21:05:19 +00:00
|
|
|
}
|
2008-04-16 13:46:16 +00:00
|
|
|
$this->returnToMain();
|
2007-08-26 09:49:28 +00:00
|
|
|
}
|
2005-07-01 00:03:31 +00:00
|
|
|
|
2006-05-02 15:37:06 +00:00
|
|
|
/**
|
|
|
|
|
* Produce the stock "please login to use the wiki" page
|
|
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function loginToUse() {
|
2010-05-22 12:18:22 +00:00
|
|
|
global $wgUser;
|
2006-09-06 17:19:43 +00:00
|
|
|
|
|
|
|
|
if( $wgUser->isLoggedIn() ) {
|
|
|
|
|
$this->permissionRequired( 'read' );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-08 07:12:03 +00:00
|
|
|
$skin = $wgUser->getSkin();
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2004-08-22 17:24:50 +00:00
|
|
|
$this->setPageTitle( wfMsg( 'loginreqtitle' ) );
|
2006-05-02 15:37:06 +00:00
|
|
|
$this->setHtmlTitle( wfMsg( 'errorpagetitle' ) );
|
|
|
|
|
$this->setRobotPolicy( 'noindex,nofollow' );
|
2004-03-05 13:19:19 +00:00
|
|
|
$this->setArticleFlag( false );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2006-10-30 06:25:31 +00:00
|
|
|
$loginTitle = SpecialPage::getTitleFor( 'Userlogin' );
|
2009-06-07 15:02:12 +00:00
|
|
|
$loginLink = $skin->link(
|
|
|
|
|
$loginTitle,
|
|
|
|
|
wfMsgHtml( 'loginreqlink' ),
|
|
|
|
|
array(),
|
2009-06-15 12:32:59 +00:00
|
|
|
array( 'returnto' => $this->getTitle()->getPrefixedText() ),
|
2009-06-07 15:02:12 +00:00
|
|
|
array( 'known', 'noclasses' )
|
|
|
|
|
);
|
2008-11-06 22:20:29 +00:00
|
|
|
$this->addHTML( wfMsgWikiHtml( 'loginreqpagetext', $loginLink ) );
|
2010-05-22 12:18:22 +00:00
|
|
|
$this->addHTML( "\n<!--" . $this->getTitle()->getPrefixedUrl() . '-->' );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2006-08-31 17:15:30 +00:00
|
|
|
# Don't return to the main page if the user can't read it
|
|
|
|
|
# otherwise we'll end up in a pointless loop
|
2006-12-03 00:22:14 +00:00
|
|
|
$mainPage = Title::newMainPage();
|
2010-05-22 12:18:22 +00:00
|
|
|
if( $mainPage->userCanRead() ) {
|
2008-04-16 13:46:16 +00:00
|
|
|
$this->returnToMain( null, $mainPage );
|
2010-05-22 12:18:22 +00:00
|
|
|
}
|
2004-03-05 13:19:19 +00:00
|
|
|
}
|
|
|
|
|
|
2007-08-03 09:27:28 +00:00
|
|
|
/**
|
2010-01-29 21:32:45 +00:00
|
|
|
* Format a list of error messages
|
|
|
|
|
*
|
|
|
|
|
* @param $errors An array of arrays returned by Title::getUserPermissionsErrors
|
|
|
|
|
* @param $action String: action that was denied or null if unknown
|
|
|
|
|
* @return String: the wikitext error-messages, formatted into a list.
|
2007-08-03 09:27:28 +00:00
|
|
|
*/
|
2008-05-23 10:34:11 +00:00
|
|
|
public function formatPermissionsErrorMessage( $errors, $action = null ) {
|
2010-05-22 12:18:22 +00:00
|
|
|
if ( $action == null ) {
|
|
|
|
|
$text = wfMsgNoTrans( 'permissionserrorstext', count( $errors ) ) . "\n\n";
|
2008-05-23 10:34:11 +00:00
|
|
|
} else {
|
2009-05-25 13:49:01 +00:00
|
|
|
$action_desc = wfMsgNoTrans( "action-$action" );
|
2010-05-22 12:18:22 +00:00
|
|
|
$text = wfMsgNoTrans(
|
|
|
|
|
'permissionserrorstext-withaction',
|
|
|
|
|
count( $errors ),
|
|
|
|
|
$action_desc
|
|
|
|
|
) . "\n\n";
|
2008-05-23 10:34:11 +00:00
|
|
|
}
|
2008-01-02 01:16:44 +00:00
|
|
|
|
2010-05-22 12:18:22 +00:00
|
|
|
if ( count( $errors ) > 1 ) {
|
2007-08-16 07:05:38 +00:00
|
|
|
$text .= '<ul class="permissions-errors">' . "\n";
|
|
|
|
|
|
2010-05-22 12:18:22 +00:00
|
|
|
foreach( $errors as $error ) {
|
2007-08-16 07:05:38 +00:00
|
|
|
$text .= '<li>';
|
2008-02-18 07:25:35 +00:00
|
|
|
$text .= call_user_func_array( 'wfMsgNoTrans', $error );
|
2007-08-16 07:05:38 +00:00
|
|
|
$text .= "</li>\n";
|
|
|
|
|
}
|
|
|
|
|
$text .= '</ul>';
|
|
|
|
|
} else {
|
2010-05-22 12:18:22 +00:00
|
|
|
$text .= "<div class=\"permissions-errors\">\n" .
|
|
|
|
|
call_user_func_array( 'wfMsgNoTrans', reset( $errors ) ) .
|
|
|
|
|
"\n</div>";
|
2007-08-03 09:27:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $text;
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-07 05:37:31 +00:00
|
|
|
/**
|
2007-12-09 00:16:59 +00:00
|
|
|
* Display a page stating that the Wiki is in read-only mode,
|
|
|
|
|
* and optionally show the source of the page that the user
|
|
|
|
|
* was trying to edit. Should only be called (for this
|
|
|
|
|
* purpose) after wfReadOnly() has returned true.
|
|
|
|
|
*
|
|
|
|
|
* For historical reasons, this function is _also_ used to
|
|
|
|
|
* show the error message when a user tries to edit a page
|
|
|
|
|
* they are not allowed to edit. (Unless it's because they're
|
|
|
|
|
* blocked, then we show blockedPage() instead.) In this
|
|
|
|
|
* case, the second parameter should be set to true and a list
|
|
|
|
|
* of reasons supplied as the third parameter.
|
|
|
|
|
*
|
|
|
|
|
* @todo Needs to be split into multiple functions.
|
|
|
|
|
*
|
2010-01-29 21:32:45 +00:00
|
|
|
* @param $source String: source code to show (or null).
|
|
|
|
|
* @param $protected Boolean: is this a permissions error?
|
|
|
|
|
* @param $reasons Array: list of reasons for this error, as returned by Title::getUserPermissionsErrors().
|
|
|
|
|
* @param $action String: action that was denied or null if unknown
|
2006-11-07 05:37:31 +00:00
|
|
|
*/
|
2008-05-23 10:34:11 +00:00
|
|
|
public function readOnlyPage( $source = null, $protected = false, $reasons = array(), $action = null ) {
|
2009-04-09 02:22:36 +00:00
|
|
|
global $wgUser;
|
2007-12-09 16:16:33 +00:00
|
|
|
$skin = $wgUser->getSkin();
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2008-07-23 19:05:43 +00:00
|
|
|
$this->setRobotPolicy( 'noindex,nofollow' );
|
2004-01-17 09:49:43 +00:00
|
|
|
$this->setArticleRelated( false );
|
2008-01-24 01:59:35 +00:00
|
|
|
|
2007-12-09 00:16:59 +00:00
|
|
|
// If no reason is given, just supply a default "I can't let you do
|
|
|
|
|
// that, Dave" message. Should only occur if called by legacy code.
|
2010-05-22 12:18:22 +00:00
|
|
|
if ( $protected && empty( $reasons ) ) {
|
2007-12-09 00:16:59 +00:00
|
|
|
$reasons[] = array( 'badaccess-group0' );
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-22 12:18:22 +00:00
|
|
|
if ( !empty( $reasons ) ) {
|
2007-12-09 00:16:59 +00:00
|
|
|
// Permissions error
|
2008-01-02 02:49:31 +00:00
|
|
|
if( $source ) {
|
2010-09-28 15:58:53 +00:00
|
|
|
$this->setPageTitle( wfMsg( 'viewsource' ) );
|
|
|
|
|
$this->setSubtitle(
|
|
|
|
|
wfMsg( 'viewsourcefor', $skin->linkKnown( $this->getTitle() ) )
|
|
|
|
|
);
|
2008-01-02 02:49:31 +00:00
|
|
|
} else {
|
|
|
|
|
$this->setPageTitle( wfMsg( 'badaccess' ) );
|
|
|
|
|
}
|
2008-05-23 10:34:11 +00:00
|
|
|
$this->addWikiText( $this->formatPermissionsErrorMessage( $reasons, $action ) );
|
2003-11-09 11:45:12 +00:00
|
|
|
} else {
|
2007-12-09 00:16:59 +00:00
|
|
|
// Wiki is read only
|
2004-08-22 17:24:50 +00:00
|
|
|
$this->setPageTitle( wfMsg( 'readonly' ) );
|
2008-02-24 03:50:05 +00:00
|
|
|
$reason = wfReadOnlyReason();
|
2010-05-28 21:22:45 +00:00
|
|
|
$this->wrapWikiMsg( "<div class='mw-readonly-error'>\n$1\n</div>", array( 'readonlytext', $reason ) );
|
2003-11-09 11:45:12 +00:00
|
|
|
}
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2007-12-09 00:16:59 +00:00
|
|
|
// Show source, if supplied
|
2004-04-30 07:18:38 +00:00
|
|
|
if( is_string( $source ) ) {
|
2008-02-18 07:25:35 +00:00
|
|
|
$this->addWikiMsg( 'viewsourcetext' );
|
2009-09-18 20:10:25 +00:00
|
|
|
|
|
|
|
|
$params = array(
|
|
|
|
|
'id' => 'wpTextbox1',
|
|
|
|
|
'name' => 'wpTextbox1',
|
|
|
|
|
'cols' => $wgUser->getOption( 'cols' ),
|
|
|
|
|
'rows' => $wgUser->getOption( 'rows' ),
|
|
|
|
|
'readonly' => 'readonly'
|
|
|
|
|
);
|
|
|
|
|
$this->addHTML( Html::element( 'textarea', $params, $source ) );
|
2007-12-09 00:16:59 +00:00
|
|
|
|
|
|
|
|
// Show templates used by this article
|
|
|
|
|
$skin = $wgUser->getSkin();
|
2009-04-09 02:22:36 +00:00
|
|
|
$article = new Article( $this->getTitle() );
|
2008-08-08 12:23:17 +00:00
|
|
|
$this->addHTML( "<div class='templatesUsed'>
|
|
|
|
|
{$skin->formatTemplates( $article->getUsedTemplates() )}
|
|
|
|
|
</div>
|
|
|
|
|
" );
|
2003-09-09 05:46:22 +00:00
|
|
|
}
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2008-01-02 02:49:31 +00:00
|
|
|
# If the title doesn't exist, it's fairly pointless to print a return
|
|
|
|
|
# link to it. After all, you just tried editing it and couldn't, so
|
|
|
|
|
# what's there to do there?
|
2009-04-09 02:22:36 +00:00
|
|
|
if( $this->getTitle()->exists() ) {
|
|
|
|
|
$this->returnToMain( null, $this->getTitle() );
|
2008-01-02 02:49:31 +00:00
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2010-08-09 16:17:00 +00:00
|
|
|
/**
|
|
|
|
|
* Adds JS-based password security checker
|
|
|
|
|
* @param $passwordId String ID of input box containing password
|
|
|
|
|
* @param $retypeId String ID of input box containing retyped password
|
|
|
|
|
* @return none
|
|
|
|
|
*/
|
2010-08-05 19:16:31 +00:00
|
|
|
public function addPasswordSecurity( $passwordId, $retypeId ) {
|
|
|
|
|
$data = array(
|
|
|
|
|
'password' => '#' . $passwordId,
|
|
|
|
|
'retype' => '#' . $retypeId,
|
|
|
|
|
'messages' => array(),
|
|
|
|
|
);
|
|
|
|
|
foreach ( array( 'password-strength', 'password-strength-bad', 'password-strength-mediocre',
|
|
|
|
|
'password-strength-acceptable', 'password-strength-good', 'password-retype', 'password-retype-mismatch'
|
|
|
|
|
) as $message ) {
|
|
|
|
|
$data['messages'][$message] = wfMsg( $message );
|
|
|
|
|
}
|
2010-08-12 14:37:39 +00:00
|
|
|
$this->addScript( Html::inlineScript( 'var passwordSecurity=' . FormatJson::encode( $data ) ) );
|
2010-09-04 04:00:09 +00:00
|
|
|
$this->addModules( 'mediawiki.legacy.password' );
|
2010-08-05 19:16:31 +00:00
|
|
|
}
|
|
|
|
|
|
2010-01-29 21:32:45 +00:00
|
|
|
/** @deprecated */
|
|
|
|
|
public function errorpage( $title, $msg ) {
|
|
|
|
|
wfDeprecated( __METHOD__ );
|
|
|
|
|
throw new ErrorPageError( $title, $msg );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** @deprecated */
|
|
|
|
|
public function databaseError( $fname, $sql, $error, $errno ) {
|
|
|
|
|
throw new MWException( "OutputPage::databaseError is obsolete\n" );
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-04 05:22:37 +00:00
|
|
|
/** @deprecated */
|
2006-11-07 05:37:31 +00:00
|
|
|
public function fatalError( $message ) {
|
2008-04-16 13:46:16 +00:00
|
|
|
wfDeprecated( __METHOD__ );
|
2008-04-14 07:45:50 +00:00
|
|
|
throw new FatalError( $message );
|
2006-06-07 06:40:24 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2007-04-04 05:22:37 +00:00
|
|
|
/** @deprecated */
|
2006-11-07 05:37:31 +00:00
|
|
|
public function unexpectedValueError( $name, $val ) {
|
2008-04-16 13:46:16 +00:00
|
|
|
wfDeprecated( __METHOD__ );
|
2006-06-07 06:40:24 +00:00
|
|
|
throw new FatalError( wfMsg( 'unexpected', $name, $val ) );
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-04 05:22:37 +00:00
|
|
|
/** @deprecated */
|
2006-11-07 05:37:31 +00:00
|
|
|
public function fileCopyError( $old, $new ) {
|
2008-04-16 13:46:16 +00:00
|
|
|
wfDeprecated( __METHOD__ );
|
2006-06-07 06:40:24 +00:00
|
|
|
throw new FatalError( wfMsg( 'filecopyerror', $old, $new ) );
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-04 05:22:37 +00:00
|
|
|
/** @deprecated */
|
2006-11-07 05:37:31 +00:00
|
|
|
public function fileRenameError( $old, $new ) {
|
2008-04-16 13:46:16 +00:00
|
|
|
wfDeprecated( __METHOD__ );
|
2006-06-07 06:40:24 +00:00
|
|
|
throw new FatalError( wfMsg( 'filerenameerror', $old, $new ) );
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-04 05:22:37 +00:00
|
|
|
/** @deprecated */
|
2006-11-07 05:37:31 +00:00
|
|
|
public function fileDeleteError( $name ) {
|
2008-04-16 13:46:16 +00:00
|
|
|
wfDeprecated( __METHOD__ );
|
2006-06-07 06:40:24 +00:00
|
|
|
throw new FatalError( wfMsg( 'filedeleteerror', $name ) );
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-04 05:22:37 +00:00
|
|
|
/** @deprecated */
|
2006-11-07 05:37:31 +00:00
|
|
|
public function fileNotFoundError( $name ) {
|
2008-04-16 13:46:16 +00:00
|
|
|
wfDeprecated( __METHOD__ );
|
2006-06-07 06:40:24 +00:00
|
|
|
throw new FatalError( wfMsg( 'filenotfound', $name ) );
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-07 05:37:31 +00:00
|
|
|
public function showFatalError( $message ) {
|
2010-05-22 12:18:22 +00:00
|
|
|
$this->setPageTitle( wfMsg( 'internalerror' ) );
|
|
|
|
|
$this->setRobotPolicy( 'noindex,nofollow' );
|
2004-01-17 09:49:43 +00:00
|
|
|
$this->setArticleRelated( false );
|
2004-03-23 10:19:31 +00:00
|
|
|
$this->enableClientCache( false );
|
2004-08-22 17:24:50 +00:00
|
|
|
$this->mRedirect = '';
|
2003-04-14 23:10:40 +00:00
|
|
|
$this->mBodytext = $message;
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-07 05:37:31 +00:00
|
|
|
public function showUnexpectedValueError( $name, $val ) {
|
2006-06-07 06:40:24 +00:00
|
|
|
$this->showFatalError( wfMsg( 'unexpected', $name, $val ) );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2006-11-07 05:37:31 +00:00
|
|
|
public function showFileCopyError( $old, $new ) {
|
2006-06-07 06:40:24 +00:00
|
|
|
$this->showFatalError( wfMsg( 'filecopyerror', $old, $new ) );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2006-11-07 05:37:31 +00:00
|
|
|
public function showFileRenameError( $old, $new ) {
|
2006-06-07 06:40:24 +00:00
|
|
|
$this->showFatalError( wfMsg( 'filerenameerror', $old, $new ) );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2006-11-07 05:37:31 +00:00
|
|
|
public function showFileDeleteError( $name ) {
|
2006-06-07 06:40:24 +00:00
|
|
|
$this->showFatalError( wfMsg( 'filedeleteerror', $name ) );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2006-11-07 05:37:31 +00:00
|
|
|
public function showFileNotFoundError( $name ) {
|
2006-06-07 06:40:24 +00:00
|
|
|
$this->showFatalError( wfMsg( 'filenotfound', $name ) );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2007-07-29 23:53:45 +00:00
|
|
|
* Add a "return to" link pointing to a specified title
|
|
|
|
|
*
|
2009-12-20 15:08:26 +00:00
|
|
|
* @param $title Title to link
|
|
|
|
|
* @param $query String: query string
|
2010-03-13 19:07:25 +00:00
|
|
|
* @param $text String text of the link (input is not escaped)
|
2007-07-29 23:53:45 +00:00
|
|
|
*/
|
2010-05-22 12:18:22 +00:00
|
|
|
public function addReturnTo( $title, $query = array(), $text = null ) {
|
2007-07-29 23:53:45 +00:00
|
|
|
global $wgUser;
|
2010-05-22 12:18:22 +00:00
|
|
|
$this->addLink( array( 'rel' => 'next', 'href' => $title->getFullURL() ) );
|
2010-05-22 11:47:56 +00:00
|
|
|
$link = wfMsgHtml(
|
|
|
|
|
'returnto',
|
2010-03-13 19:07:25 +00:00
|
|
|
$wgUser->getSkin()->link( $title, $text, array(), $query )
|
|
|
|
|
);
|
2009-06-15 11:11:17 +00:00
|
|
|
$this->addHTML( "<p id=\"mw-returnto\">{$link}</p>\n" );
|
2007-07-29 23:53:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add a "return to" link pointing to a specified title,
|
|
|
|
|
* or the title indicated in the request, or else the main page
|
|
|
|
|
*
|
2009-12-20 15:08:26 +00:00
|
|
|
* @param $unused No longer used
|
|
|
|
|
* @param $returnto Title or String to return to
|
|
|
|
|
* @param $returntoquery String: query string for the return to link
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2009-07-14 21:25:33 +00:00
|
|
|
public function returnToMain( $unused = null, $returnto = null, $returntoquery = null ) {
|
2007-07-29 23:53:45 +00:00
|
|
|
global $wgRequest;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2009-07-14 21:25:33 +00:00
|
|
|
if ( $returnto == null ) {
|
2004-04-01 12:44:54 +00:00
|
|
|
$returnto = $wgRequest->getText( 'returnto' );
|
|
|
|
|
}
|
2009-08-07 00:16:54 +00:00
|
|
|
|
2009-07-14 21:25:33 +00:00
|
|
|
if ( $returntoquery == null ) {
|
|
|
|
|
$returntoquery = $wgRequest->getText( 'returntoquery' );
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2010-01-06 19:59:42 +00:00
|
|
|
if ( $returnto === '' ) {
|
2006-12-03 00:22:14 +00:00
|
|
|
$returnto = Title::newMainPage();
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2006-06-21 16:28:04 +00:00
|
|
|
|
|
|
|
|
if ( is_object( $returnto ) ) {
|
|
|
|
|
$titleObj = $returnto;
|
|
|
|
|
} else {
|
|
|
|
|
$titleObj = Title::newFromText( $returnto );
|
|
|
|
|
}
|
2006-06-23 06:53:05 +00:00
|
|
|
if ( !is_object( $titleObj ) ) {
|
|
|
|
|
$titleObj = Title::newMainPage();
|
|
|
|
|
}
|
2006-06-21 16:28:04 +00:00
|
|
|
|
2009-07-14 21:25:33 +00:00
|
|
|
$this->addReturnTo( $titleObj, $returntoquery );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2009-09-17 01:19:02 +00:00
|
|
|
* @param $sk Skin The given Skin
|
2010-05-22 12:18:22 +00:00
|
|
|
* @param $includeStyle Boolean: unused
|
2010-01-29 21:32:45 +00:00
|
|
|
* @return String: The doctype, opening <html>, and head element.
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2009-09-22 16:52:40 +00:00
|
|
|
public function headElement( Skin $sk, $includeStyle = true ) {
|
2010-07-24 19:11:52 +00:00
|
|
|
global $wgOutputEncoding, $wgMimeType;
|
|
|
|
|
global $wgUseTrackbacks, $wgHtml5;
|
2010-01-15 01:16:52 +00:00
|
|
|
global $wgUser, $wgRequest, $wgLang;
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2009-07-07 21:49:45 +00:00
|
|
|
if ( $sk->commonPrintStylesheet() ) {
|
2010-09-10 00:21:36 +00:00
|
|
|
$this->addModuleStyles( 'mediawiki.legacy.wikiprintable' );
|
2009-07-07 21:49:45 +00:00
|
|
|
}
|
2008-08-21 14:09:57 +00:00
|
|
|
$sk->setupUserCss( $this );
|
|
|
|
|
|
2010-07-08 13:34:03 +00:00
|
|
|
$ret = Html::htmlHeader( array( 'lang' => wfUILang()->getCode() ) );
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2010-01-06 19:59:42 +00:00
|
|
|
if ( $this->getHTMLTitle() == '' ) {
|
2010-03-21 05:11:55 +00:00
|
|
|
$this->setHTMLTitle( wfMsg( 'pagetitle', $this->getPageTitle() ) );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2005-02-07 14:11:59 +00:00
|
|
|
|
2010-05-12 18:25:50 +00:00
|
|
|
$openHead = Html::openElement( 'head' );
|
|
|
|
|
if ( $openHead ) {
|
|
|
|
|
# Don't bother with the newline if $head == ''
|
|
|
|
|
$ret .= "$openHead\n";
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-15 22:55:30 +00:00
|
|
|
if ( $wgHtml5 ) {
|
2010-05-08 13:45:14 +00:00
|
|
|
# More succinct than <meta http-equiv=Content-Type>, has the
|
|
|
|
|
# same effect
|
|
|
|
|
$ret .= Html::element( 'meta', array( 'charset' => $wgOutputEncoding ) ) . "\n";
|
2009-07-15 22:55:30 +00:00
|
|
|
} else {
|
2010-03-21 05:12:15 +00:00
|
|
|
$this->addMeta( 'http:Content-Type', "$wgMimeType; charset=$wgOutputEncoding" );
|
2007-01-07 22:31:07 +00:00
|
|
|
}
|
2009-07-15 22:55:30 +00:00
|
|
|
|
2010-05-08 13:45:14 +00:00
|
|
|
$ret .= Html::element( 'title', null, $this->getHTMLTitle() ) . "\n";
|
2010-03-21 05:12:15 +00:00
|
|
|
|
2009-07-07 21:49:45 +00:00
|
|
|
$ret .= implode( "\n", array(
|
2010-09-04 04:00:09 +00:00
|
|
|
$this->getHeadLinks( $sk ),
|
2008-08-21 14:09:57 +00:00
|
|
|
$this->buildCssLinks(),
|
2010-09-04 04:00:09 +00:00
|
|
|
$this->getHeadItems(),
|
2010-03-21 05:11:55 +00:00
|
|
|
) );
|
|
|
|
|
if ( $sk->usercss ) {
|
2009-08-11 00:09:24 +00:00
|
|
|
$ret .= Html::inlineStyle( $sk->usercss );
|
2008-08-10 07:14:08 +00:00
|
|
|
}
|
2004-04-09 04:53:52 +00:00
|
|
|
|
2010-03-21 05:11:55 +00:00
|
|
|
if ( $wgUseTrackbacks && $this->isArticleRelated() ) {
|
2009-04-09 02:22:36 +00:00
|
|
|
$ret .= $this->getTitle()->trackbackRDF();
|
2010-03-21 05:11:55 +00:00
|
|
|
}
|
2005-07-23 05:47:25 +00:00
|
|
|
|
2010-03-21 05:12:02 +00:00
|
|
|
$closeHead = Html::closeElement( 'head' );
|
|
|
|
|
if ( $closeHead ) {
|
|
|
|
|
$ret .= "$closeHead\n";
|
|
|
|
|
}
|
2010-01-15 01:16:52 +00:00
|
|
|
|
|
|
|
|
$bodyAttrs = array();
|
|
|
|
|
|
|
|
|
|
# Crazy edit-on-double-click stuff
|
|
|
|
|
$action = $wgRequest->getVal( 'action', 'view' );
|
|
|
|
|
|
2010-05-22 12:18:22 +00:00
|
|
|
if (
|
|
|
|
|
$this->getTitle()->getNamespace() != NS_SPECIAL &&
|
|
|
|
|
!in_array( $action, array( 'edit', 'submit' ) ) &&
|
|
|
|
|
$wgUser->getOption( 'editondblclick' )
|
|
|
|
|
)
|
|
|
|
|
{
|
2010-01-17 01:47:44 +00:00
|
|
|
$bodyAttrs['ondblclick'] = "document.location = '" . Xml::escapeJsString( $this->getTitle()->getEditURL() ) . "'";
|
2010-01-15 01:16:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Class bloat
|
2010-07-08 13:34:03 +00:00
|
|
|
$dir = wfUILang()->getDir();
|
2010-01-15 01:16:52 +00:00
|
|
|
$bodyAttrs['class'] = "mediawiki $dir";
|
|
|
|
|
|
|
|
|
|
if ( $wgLang->capitalizeAllNouns() ) {
|
|
|
|
|
# A <body> class is probably not the best way to do this . . .
|
|
|
|
|
$bodyAttrs['class'] .= ' capitalize-all-nouns';
|
|
|
|
|
}
|
2010-01-17 01:47:44 +00:00
|
|
|
$bodyAttrs['class'] .= ' ns-' . $this->getTitle()->getNamespace();
|
|
|
|
|
if ( $this->getTitle()->getNamespace() == NS_SPECIAL ) {
|
2010-01-15 01:16:52 +00:00
|
|
|
$bodyAttrs['class'] .= ' ns-special';
|
2010-01-17 01:47:44 +00:00
|
|
|
} elseif ( $this->getTitle()->isTalkPage() ) {
|
2010-01-15 01:16:52 +00:00
|
|
|
$bodyAttrs['class'] .= ' ns-talk';
|
|
|
|
|
} else {
|
|
|
|
|
$bodyAttrs['class'] .= ' ns-subject';
|
|
|
|
|
}
|
2010-01-17 01:47:44 +00:00
|
|
|
$bodyAttrs['class'] .= ' ' . Sanitizer::escapeClass( 'page-' . $this->getTitle()->getPrefixedText() );
|
2010-01-15 01:16:52 +00:00
|
|
|
$bodyAttrs['class'] .= ' skin-' . Sanitizer::escapeClass( $wgUser->getSkin()->getSkinName() );
|
|
|
|
|
|
2010-10-04 05:38:48 +00:00
|
|
|
$sk->addToBodyAttributes( $this, $bodyAttrs ); // Allow skins to add body attributes they need
|
|
|
|
|
wfRunHooks( 'OutputPageBodyAttributes', array( $this, $sk, &$bodyAttrs ) );
|
2010-10-03 14:12:41 +00:00
|
|
|
|
2010-01-15 01:16:52 +00:00
|
|
|
$ret .= Html::openElement( 'body', $bodyAttrs ) . "\n";
|
|
|
|
|
|
2004-04-09 04:53:52 +00:00
|
|
|
return $ret;
|
|
|
|
|
}
|
2010-10-02 13:45:35 +00:00
|
|
|
|
2010-09-24 20:01:52 +00:00
|
|
|
// TODO: Document
|
2010-09-29 19:04:04 +00:00
|
|
|
protected function makeResourceLoaderLink( $skin, $modules, $only, $useESI = false ) {
|
2010-11-05 22:29:08 +00:00
|
|
|
global $wgUser, $wgLang, $wgLoadScript, $wgResourceLoaderUseESI,
|
2010-09-24 22:10:25 +00:00
|
|
|
$wgResourceLoaderInlinePrivateModules;
|
2010-09-29 19:04:04 +00:00
|
|
|
// Lazy-load ResourceLoader
|
|
|
|
|
if ( is_null( $this->mResourceLoader ) ) {
|
|
|
|
|
$this->mResourceLoader = new ResourceLoader();
|
|
|
|
|
}
|
2010-09-04 04:00:09 +00:00
|
|
|
// TODO: Should this be a static function of ResourceLoader instead?
|
2010-09-11 03:26:15 +00:00
|
|
|
// TODO: Divide off modules starting with "user", and add the user parameter to them
|
2010-09-04 04:00:09 +00:00
|
|
|
$query = array(
|
|
|
|
|
'lang' => $wgLang->getCode(),
|
2010-11-05 20:36:13 +00:00
|
|
|
'debug' => ResourceLoader::inDebugMode() ? 'true' : 'false',
|
2010-09-04 04:00:09 +00:00
|
|
|
'skin' => $wgUser->getSkin()->getSkinName(),
|
|
|
|
|
'only' => $only,
|
|
|
|
|
);
|
2010-09-20 21:54:15 +00:00
|
|
|
// Remove duplicate module requests
|
|
|
|
|
$modules = array_unique( (array) $modules );
|
|
|
|
|
// Sort module names so requests are more uniform
|
|
|
|
|
sort( $modules );
|
|
|
|
|
// Create keyed-by-group list of module objects from modules list
|
|
|
|
|
$groups = array();
|
2010-09-11 08:03:11 +00:00
|
|
|
foreach ( (array) $modules as $name ) {
|
2010-09-29 19:04:04 +00:00
|
|
|
$module = $this->mResourceLoader->getModule( $name );
|
2010-09-20 21:54:15 +00:00
|
|
|
$group = $module->getGroup();
|
|
|
|
|
if ( !isset( $groups[$group] ) ) {
|
|
|
|
|
$groups[$group] = array();
|
|
|
|
|
}
|
|
|
|
|
$groups[$group][$name] = $module;
|
2010-09-11 03:26:15 +00:00
|
|
|
}
|
|
|
|
|
$links = '';
|
2010-09-20 21:54:15 +00:00
|
|
|
foreach ( $groups as $group => $modules ) {
|
|
|
|
|
$query['modules'] = implode( '|', array_keys( $modules ) );
|
2010-09-24 22:10:25 +00:00
|
|
|
// Special handling for user-specific groups
|
|
|
|
|
if ( ( $group === 'user' || $group === 'private' ) && $wgUser->isLoggedIn() ) {
|
2010-09-20 21:54:15 +00:00
|
|
|
$query['user'] = $wgUser->getName();
|
|
|
|
|
}
|
2010-09-24 22:10:25 +00:00
|
|
|
// Support inlining of private modules if configured as such
|
|
|
|
|
if ( $group === 'private' && $wgResourceLoaderInlinePrivateModules ) {
|
2010-09-29 19:04:04 +00:00
|
|
|
$context = new ResourceLoaderContext( $this->mResourceLoader, new FauxRequest( $query ) );
|
2010-09-24 22:10:25 +00:00
|
|
|
if ( $only == 'styles' ) {
|
|
|
|
|
$links .= Html::inlineStyle(
|
2010-10-01 22:13:29 +00:00
|
|
|
$this->mResourceLoader->makeModuleResponse( $context, $modules )
|
2010-09-24 22:10:25 +00:00
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
$links .= Html::inlineScript(
|
|
|
|
|
ResourceLoader::makeLoaderConditionalScript(
|
2010-09-29 19:04:04 +00:00
|
|
|
$this->mResourceLoader->makeModuleResponse( $context, $modules )
|
2010-09-24 22:10:25 +00:00
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2010-09-20 21:54:15 +00:00
|
|
|
// Special handling for user and site groups; because users might change their stuff on-wiki like site or
|
|
|
|
|
// user pages, or user preferences; we need to find the highest timestamp of these user-changable modules so
|
|
|
|
|
// we can ensure cache misses on change
|
|
|
|
|
if ( $group === 'user' || $group === 'site' ) {
|
|
|
|
|
// Create a fake request based on the one we are about to make so modules return correct times
|
2010-09-29 19:04:04 +00:00
|
|
|
$context = new ResourceLoaderContext( $this->mResourceLoader, new FauxRequest( $query ) );
|
2010-09-20 21:54:15 +00:00
|
|
|
// Get the maximum timestamp
|
2010-09-30 21:20:09 +00:00
|
|
|
$timestamp = 1;
|
2010-09-20 21:54:15 +00:00
|
|
|
foreach ( $modules as $module ) {
|
2010-09-24 22:10:25 +00:00
|
|
|
$timestamp = max( $timestamp, $module->getModifiedTime( $context ) );
|
2010-09-11 03:26:15 +00:00
|
|
|
}
|
2010-09-20 21:54:15 +00:00
|
|
|
// Add a version parameter so cache will break when things change
|
2010-09-30 21:20:09 +00:00
|
|
|
$query['version'] = wfTimestamp( TS_ISO_8601_BASIC, round( $timestamp, -2 ) );
|
2010-09-20 21:54:15 +00:00
|
|
|
}
|
|
|
|
|
// Make queries uniform in order
|
|
|
|
|
ksort( $query );
|
2010-10-02 13:45:35 +00:00
|
|
|
|
2010-09-24 20:01:52 +00:00
|
|
|
$url = wfAppendQuery( $wgLoadScript, $query );
|
|
|
|
|
if ( $useESI && $wgResourceLoaderUseESI ) {
|
|
|
|
|
$esi = Xml::element( 'esi:include', array( 'src' => $url ) );
|
|
|
|
|
if ( $only == 'styles' ) {
|
|
|
|
|
$links .= Html::inlineStyle( $esi );
|
|
|
|
|
} else {
|
|
|
|
|
$links .= Html::inlineScript( $esi );
|
|
|
|
|
}
|
2010-09-20 21:54:15 +00:00
|
|
|
} else {
|
2010-09-24 20:01:52 +00:00
|
|
|
// Automatically select style/script elements
|
|
|
|
|
if ( $only === 'styles' ) {
|
|
|
|
|
$links .= Html::linkedStyle( wfAppendQuery( $wgLoadScript, $query ) ) . "\n";
|
|
|
|
|
} else {
|
|
|
|
|
$links .= Html::linkedScript( wfAppendQuery( $wgLoadScript, $query ) ) . "\n";
|
|
|
|
|
}
|
2010-09-11 03:26:15 +00:00
|
|
|
}
|
2010-09-04 04:00:09 +00:00
|
|
|
}
|
2010-09-11 03:26:15 +00:00
|
|
|
return $links;
|
2010-09-04 04:00:09 +00:00
|
|
|
}
|
2010-10-02 13:45:35 +00:00
|
|
|
|
2010-01-29 21:32:45 +00:00
|
|
|
/**
|
|
|
|
|
* Gets the global variables and mScripts; also adds userjs to the end if
|
2010-09-04 04:00:09 +00:00
|
|
|
* enabled. Despite the name, these scripts are no longer put in the
|
|
|
|
|
* <head> but at the bottom of the <body>
|
2009-09-22 01:00:06 +00:00
|
|
|
*
|
2010-01-29 21:32:45 +00:00
|
|
|
* @param $sk Skin object to use
|
|
|
|
|
* @return String: HTML fragment
|
|
|
|
|
*/
|
2009-09-22 16:52:40 +00:00
|
|
|
function getHeadScripts( Skin $sk ) {
|
2010-11-05 22:29:08 +00:00
|
|
|
global $wgUser, $wgRequest, $wgUseSiteJs;
|
2010-10-02 13:45:35 +00:00
|
|
|
|
2010-09-24 20:01:52 +00:00
|
|
|
// Startup - this will immediately load jquery and mediawiki modules
|
2010-09-29 19:04:04 +00:00
|
|
|
$scripts = $this->makeResourceLoaderLink( $sk, 'startup', 'scripts', true );
|
2010-10-02 13:45:35 +00:00
|
|
|
|
2010-09-11 03:26:15 +00:00
|
|
|
// Configuration -- This could be merged together with the load and go, but makeGlobalVariablesScript returns a
|
|
|
|
|
// whole script tag -- grumble grumble...
|
2010-09-04 04:00:09 +00:00
|
|
|
$scripts .= Skin::makeGlobalVariablesScript( $sk->getSkinName() ) . "\n";
|
2010-10-02 13:45:35 +00:00
|
|
|
|
2010-09-10 20:55:28 +00:00
|
|
|
// Script and Messages "only"
|
2010-11-05 20:36:13 +00:00
|
|
|
if ( ResourceLoader::inDebugMode() ) {
|
2010-09-04 04:00:09 +00:00
|
|
|
// Scripts
|
|
|
|
|
foreach ( $this->getModuleScripts() as $name ) {
|
2010-09-29 19:04:04 +00:00
|
|
|
$scripts .= $this->makeResourceLoaderLink( $sk, $name, 'scripts' );
|
2010-09-04 04:00:09 +00:00
|
|
|
}
|
|
|
|
|
// Messages
|
|
|
|
|
foreach ( $this->getModuleMessages() as $name ) {
|
2010-09-29 19:04:04 +00:00
|
|
|
$scripts .= $this->makeResourceLoaderLink( $sk, $name, 'messages' );
|
2010-09-04 04:00:09 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// Scripts
|
|
|
|
|
if ( count( $this->getModuleScripts() ) ) {
|
2010-09-29 19:04:04 +00:00
|
|
|
$scripts .= $this->makeResourceLoaderLink( $sk, $this->getModuleScripts(), 'scripts' );
|
2010-09-04 04:00:09 +00:00
|
|
|
}
|
|
|
|
|
// Messages
|
|
|
|
|
if ( count( $this->getModuleMessages() ) ) {
|
2010-09-29 19:04:04 +00:00
|
|
|
$scripts .= $this->makeResourceLoaderLink( $sk, $this->getModuleMessages(), 'messages' );
|
2010-09-04 04:00:09 +00:00
|
|
|
}
|
|
|
|
|
}
|
2010-10-02 13:45:35 +00:00
|
|
|
|
2010-09-10 20:55:28 +00:00
|
|
|
// Modules - let the client calculate dependencies and batch requests as it likes
|
2010-09-04 04:00:09 +00:00
|
|
|
if ( $this->getModules() ) {
|
|
|
|
|
$modules = FormatJson::encode( $this->getModules() );
|
|
|
|
|
$scripts .= Html::inlineScript(
|
2010-09-22 18:03:29 +00:00
|
|
|
"if ( window.mediaWiki ) { mediaWiki.loader.load( {$modules} ); mediaWiki.loader.go(); }"
|
2010-09-17 11:45:49 +00:00
|
|
|
) . "\n";
|
2009-09-30 14:00:56 +00:00
|
|
|
}
|
2010-10-02 13:45:35 +00:00
|
|
|
|
2010-09-14 21:47:59 +00:00
|
|
|
// Add user JS if enabled - trying to load user.options as a bundle if possible
|
|
|
|
|
$userOptionsAdded = false;
|
|
|
|
|
if ( $this->isUserJsAllowed() && $wgUser->isLoggedIn() ) {
|
2009-09-22 16:52:40 +00:00
|
|
|
$action = $wgRequest->getVal( 'action', 'view' );
|
2010-05-22 12:18:22 +00:00
|
|
|
if( $this->mTitle && $this->mTitle->isJsSubpage() && $sk->userCanPreview( $action ) ) {
|
2009-09-22 16:52:40 +00:00
|
|
|
# XXX: additional security check/prompt?
|
|
|
|
|
$this->addInlineScript( $wgRequest->getText( 'wpTextbox1' ) );
|
|
|
|
|
} else {
|
2010-09-29 19:04:04 +00:00
|
|
|
$scripts .= $this->makeResourceLoaderLink( $sk, array( 'user', 'user.options' ), 'scripts' );
|
2010-09-14 21:47:59 +00:00
|
|
|
$userOptionsAdded = true;
|
2009-09-22 16:52:40 +00:00
|
|
|
}
|
2009-09-22 01:00:06 +00:00
|
|
|
}
|
2010-09-14 21:47:59 +00:00
|
|
|
if ( !$userOptionsAdded ) {
|
2010-09-29 19:04:04 +00:00
|
|
|
$scripts .= $this->makeResourceLoaderLink( $sk, 'user.options', 'scripts' );
|
2010-09-14 21:47:59 +00:00
|
|
|
}
|
2009-11-26 12:00:36 +00:00
|
|
|
$scripts .= "\n" . $this->mScripts;
|
2010-10-02 13:45:35 +00:00
|
|
|
|
2010-09-04 04:00:09 +00:00
|
|
|
// Add site JS if enabled
|
|
|
|
|
if ( $wgUseSiteJs ) {
|
2010-09-29 19:04:04 +00:00
|
|
|
$scripts .= $this->makeResourceLoaderLink( $sk, 'site', 'scripts' );
|
2010-09-04 04:00:09 +00:00
|
|
|
}
|
2010-10-02 13:45:35 +00:00
|
|
|
|
2009-11-26 12:00:36 +00:00
|
|
|
return $scripts;
|
2009-09-22 01:00:06 +00:00
|
|
|
}
|
|
|
|
|
|
2010-01-29 21:32:45 +00:00
|
|
|
/**
|
|
|
|
|
* Add default \<meta\> tags
|
|
|
|
|
*/
|
2008-07-02 22:52:22 +00:00
|
|
|
protected function addDefaultMeta() {
|
2009-07-10 04:19:51 +00:00
|
|
|
global $wgVersion, $wgHtml5;
|
2009-07-07 21:49:45 +00:00
|
|
|
|
|
|
|
|
static $called = false;
|
|
|
|
|
if ( $called ) {
|
|
|
|
|
# Don't run this twice
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$called = true;
|
|
|
|
|
|
2009-07-10 04:19:51 +00:00
|
|
|
if ( !$wgHtml5 ) {
|
2010-05-22 12:18:22 +00:00
|
|
|
$this->addMeta( 'http:Content-Style-Type', 'text/css' ); // bug 15835
|
2009-07-10 04:19:51 +00:00
|
|
|
}
|
2008-11-08 15:06:50 +00:00
|
|
|
$this->addMeta( 'generator', "MediaWiki $wgVersion" );
|
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-07-23 19:05:43 +00:00
|
|
|
$p = "{$this->mIndexPolicy},{$this->mFollowPolicy}";
|
|
|
|
|
if( $p !== 'index,follow' ) {
|
2008-07-02 22:52:22 +00:00
|
|
|
// http://www.robotstxt.org/wc/meta-user.html
|
|
|
|
|
// Only show if it's different from the default robots policy
|
|
|
|
|
$this->addMeta( 'robots', $p );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( count( $this->mKeywords ) > 0 ) {
|
|
|
|
|
$strip = array(
|
2009-03-16 00:36:17 +00:00
|
|
|
"/<.*?" . ">/" => '',
|
2008-07-02 22:52:22 +00:00
|
|
|
"/_/" => ' '
|
|
|
|
|
);
|
2010-05-22 12:18:22 +00:00
|
|
|
$this->addMeta(
|
|
|
|
|
'keywords',
|
|
|
|
|
preg_replace(
|
|
|
|
|
array_keys( $strip ),
|
|
|
|
|
array_values( $strip ),
|
|
|
|
|
implode( ',', $this->mKeywords )
|
|
|
|
|
)
|
|
|
|
|
);
|
2008-07-02 22:52:22 +00:00
|
|
|
}
|
|
|
|
|
}
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2006-11-07 05:37:31 +00:00
|
|
|
/**
|
|
|
|
|
* @return string HTML tag links to be put in the header.
|
|
|
|
|
*/
|
2010-09-04 04:00:09 +00:00
|
|
|
public function getHeadLinks( $sk ) {
|
2010-11-05 22:29:08 +00:00
|
|
|
global $wgFeed;
|
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-07-02 22:52:22 +00:00
|
|
|
// Ideally this should happen earlier, somewhere. :P
|
|
|
|
|
$this->addDefaultMeta();
|
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-07-02 22:52:22 +00:00
|
|
|
$tags = array();
|
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
|
|
|
|
2003-04-14 23:10:40 +00:00
|
|
|
foreach ( $this->mMetatags as $tag ) {
|
2004-08-22 17:24:50 +00:00
|
|
|
if ( 0 == strcasecmp( 'http:', substr( $tag[0], 0, 5 ) ) ) {
|
|
|
|
|
$a = 'http-equiv';
|
2003-04-14 23:10:40 +00:00
|
|
|
$tag[0] = substr( $tag[0], 5 );
|
|
|
|
|
} else {
|
2004-08-22 17:24:50 +00:00
|
|
|
$a = 'name';
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2009-09-18 20:10:25 +00:00
|
|
|
$tags[] = Html::element( 'meta',
|
2008-07-02 22:52:22 +00:00
|
|
|
array(
|
|
|
|
|
$a => $tag[0],
|
2010-05-22 12:18:22 +00:00
|
|
|
'content' => $tag[1]
|
|
|
|
|
)
|
|
|
|
|
);
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
foreach ( $this->mLinktags as $tag ) {
|
2009-09-18 20:10:25 +00:00
|
|
|
$tags[] = Html::element( 'link', $tag );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-02-22 12:33:51 +00:00
|
|
|
if( $wgFeed ) {
|
|
|
|
|
foreach( $this->getSyndicationLinks() as $format => $link ) {
|
|
|
|
|
# Use the page name for the title (accessed through $wgTitle since
|
|
|
|
|
# there's no other way). In principle, this could lead to issues
|
|
|
|
|
# with having the same name for different feeds corresponding to
|
|
|
|
|
# the same page, but we can't avoid that at this low a level.
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-07-02 22:52:22 +00:00
|
|
|
$tags[] = $this->feedLink(
|
2008-02-22 12:33:51 +00:00
|
|
|
$format,
|
|
|
|
|
$link,
|
2010-01-13 21:29:47 +00:00
|
|
|
# Used messages: 'page-rss-feed' and 'page-atom-feed' (for an easier grep)
|
2010-05-22 12:18:22 +00:00
|
|
|
wfMsg( "page-{$format}-feed", $this->getTitle()->getPrefixedText() )
|
|
|
|
|
);
|
2008-02-22 12:33:51 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +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
|
|
|
# Recent changes feed should appear on every page (except recentchanges,
|
|
|
|
|
# that would be redundant). Put it after the per-page feed to avoid
|
|
|
|
|
# changing existing behavior. It's still available, probably via a
|
2008-08-08 01:41:14 +00:00
|
|
|
# menu in your browser. Some sites might have a different feed they'd
|
|
|
|
|
# like to promote instead of the RC feed (maybe like a "Recent New Articles"
|
|
|
|
|
# or "Breaking news" one). For this, we see if $wgOverrideSiteFeed is defined.
|
|
|
|
|
# If so, use it instead.
|
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-01-26 20:52:55 +00:00
|
|
|
global $wgOverrideSiteFeed, $wgSitename, $wgAdvertisedFeedTypes;
|
2008-02-22 12:33:51 +00:00
|
|
|
$rctitle = SpecialPage::getTitleFor( 'Recentchanges' );
|
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-08 21:02:52 +00:00
|
|
|
if ( $wgOverrideSiteFeed ) {
|
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
|
|
|
foreach ( $wgOverrideSiteFeed as $type => $feedUrl ) {
|
2010-05-22 12:18:22 +00:00
|
|
|
$tags[] = $this->feedLink(
|
2008-08-08 01:41:14 +00:00
|
|
|
$type,
|
|
|
|
|
htmlspecialchars( $feedUrl ),
|
2010-05-22 12:18:22 +00:00
|
|
|
wfMsg( "site-{$type}-feed", $wgSitename )
|
|
|
|
|
);
|
2008-08-08 01:41:14 +00:00
|
|
|
}
|
2010-01-13 21:29:47 +00:00
|
|
|
} elseif ( $this->getTitle()->getPrefixedText() != $rctitle->getPrefixedText() ) {
|
|
|
|
|
foreach ( $wgAdvertisedFeedTypes as $format ) {
|
2008-09-16 03:58:18 +00:00
|
|
|
$tags[] = $this->feedLink(
|
|
|
|
|
$format,
|
2009-02-20 20:49:47 +00:00
|
|
|
$rctitle->getLocalURL( "feed={$format}" ),
|
2010-05-22 12:18:22 +00:00
|
|
|
wfMsg( "site-{$format}-feed", $wgSitename ) # For grep: 'site-rss-feed', 'site-atom-feed'.
|
|
|
|
|
);
|
2008-09-16 03:58:18 +00:00
|
|
|
}
|
2008-06-12 00:51:04 +00:00
|
|
|
}
|
2004-03-19 08:05:36 +00:00
|
|
|
}
|
2005-01-18 00:05:35 +00:00
|
|
|
|
2010-09-04 04:00:09 +00:00
|
|
|
// Support individual script requests in debug mode
|
2010-11-05 20:36:13 +00:00
|
|
|
if ( ResourceLoader::inDebugMode() ) {
|
2010-09-04 04:00:09 +00:00
|
|
|
foreach ( $this->getModuleStyles() as $name ) {
|
2010-09-29 19:04:04 +00:00
|
|
|
$tags[] = $this->makeResourceLoaderLink( $sk, $name, 'styles' );
|
2010-09-04 04:00:09 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if ( count( $this->getModuleStyles() ) ) {
|
2010-09-29 19:04:04 +00:00
|
|
|
$tags[] = $this->makeResourceLoaderLink( $sk, $this->getModuleStyles(), 'styles' );
|
2010-09-04 04:00:09 +00:00
|
|
|
}
|
|
|
|
|
}
|
2010-10-02 13:45:35 +00:00
|
|
|
|
2009-09-21 20:06:28 +00:00
|
|
|
return implode( "\n", $tags );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-01-12 00:13:53 +00:00
|
|
|
/**
|
2010-01-29 21:32:45 +00:00
|
|
|
* Generate a <link rel/> for a feed.
|
|
|
|
|
*
|
|
|
|
|
* @param $type String: feed type
|
|
|
|
|
* @param $url String: URL to the feed
|
|
|
|
|
* @param $text String: value of the "title" attribute
|
|
|
|
|
* @return String: HTML fragment
|
2007-09-24 18:25:56 +00:00
|
|
|
*/
|
|
|
|
|
private function feedLink( $type, $url, $text ) {
|
2009-09-18 20:10:25 +00:00
|
|
|
return Html::element( 'link', array(
|
2007-09-24 18:25:56 +00:00
|
|
|
'rel' => 'alternate',
|
|
|
|
|
'type' => "application/$type+xml",
|
|
|
|
|
'title' => $text,
|
2010-05-22 12:18:22 +00:00
|
|
|
'href' => $url )
|
|
|
|
|
);
|
2007-09-24 18:25:56 +00:00
|
|
|
}
|
2005-07-01 00:03:31 +00:00
|
|
|
|
2008-08-21 14:09:57 +00:00
|
|
|
/**
|
|
|
|
|
* Add a local or specified stylesheet, with the given media options.
|
|
|
|
|
* Meant primarily for internal use...
|
|
|
|
|
*
|
2010-01-29 21:32:45 +00:00
|
|
|
* @param $style String: URL to the file
|
|
|
|
|
* @param $media String: to specify a media type, 'screen', 'printable', 'handheld' or any.
|
|
|
|
|
* @param $condition String: for IE conditional comments, specifying an IE version
|
|
|
|
|
* @param $dir String: set to 'rtl' or 'ltr' for direction-specific sheets
|
2008-08-21 14:09:57 +00:00
|
|
|
*/
|
2010-05-22 12:18:22 +00:00
|
|
|
public function addStyle( $style, $media = '', $condition = '', $dir = '' ) {
|
2008-08-21 14:09:57 +00:00
|
|
|
$options = array();
|
2009-08-18 21:22:59 +00:00
|
|
|
// Even though we expect the media type to be lowercase, but here we
|
|
|
|
|
// force it to lowercase to be safe.
|
2010-05-22 12:18:22 +00:00
|
|
|
if( $media ) {
|
2008-08-21 14:09:57 +00:00
|
|
|
$options['media'] = $media;
|
2010-05-22 12:18:22 +00:00
|
|
|
}
|
|
|
|
|
if( $condition ) {
|
2008-08-21 14:09:57 +00:00
|
|
|
$options['condition'] = $condition;
|
2010-05-22 12:18:22 +00:00
|
|
|
}
|
|
|
|
|
if( $dir ) {
|
2008-08-21 14:09:57 +00:00
|
|
|
$options['dir'] = $dir;
|
2010-05-22 12:18:22 +00:00
|
|
|
}
|
2008-08-21 14:09:57 +00:00
|
|
|
$this->styles[$style] = $options;
|
|
|
|
|
}
|
2009-07-15 00:55:58 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds inline CSS styles
|
|
|
|
|
* @param $style_css Mixed: inline CSS
|
|
|
|
|
*/
|
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
|
|
|
public function addInlineStyle( $style_css ){
|
2009-08-11 00:09:24 +00:00
|
|
|
$this->mScripts .= Html::inlineStyle( $style_css );
|
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
|
|
|
}
|
2009-07-15 00:55:58 +00:00
|
|
|
|
2008-08-21 14:09:57 +00:00
|
|
|
/**
|
|
|
|
|
* Build a set of <link>s for the stylesheets specified in the $this->styles array.
|
|
|
|
|
* These will be applied to various media & IE conditionals.
|
|
|
|
|
*/
|
|
|
|
|
public function buildCssLinks() {
|
2010-05-24 16:35:23 +00:00
|
|
|
return implode( "\n", $this->buildCssLinksArray() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function buildCssLinksArray() {
|
2008-08-21 14:09:57 +00:00
|
|
|
$links = array();
|
|
|
|
|
foreach( $this->styles as $file => $options ) {
|
|
|
|
|
$link = $this->styleLink( $file, $options );
|
2010-05-22 12:18:22 +00:00
|
|
|
if( $link ) {
|
2010-05-24 16:35:23 +00:00
|
|
|
$links[$file] = $link;
|
2010-05-22 12:18:22 +00:00
|
|
|
}
|
2008-08-21 14:09:57 +00:00
|
|
|
}
|
2010-05-24 16:35:23 +00:00
|
|
|
return $links;
|
2008-08-21 14:09:57 +00:00
|
|
|
}
|
|
|
|
|
|
2010-01-29 21:32:45 +00:00
|
|
|
/**
|
|
|
|
|
* Generate \<link\> tags for stylesheets
|
|
|
|
|
*
|
|
|
|
|
* @param $style String: URL to the file
|
|
|
|
|
* @param $options Array: option, can contain 'condition', 'dir', 'media'
|
|
|
|
|
* keys
|
|
|
|
|
* @return String: HTML fragment
|
|
|
|
|
*/
|
2008-08-21 14:09:57 +00:00
|
|
|
protected function styleLink( $style, $options ) {
|
|
|
|
|
if( isset( $options['dir'] ) ) {
|
2010-07-08 13:34:03 +00:00
|
|
|
$siteDir = wfUILang()->getDir();
|
2010-05-22 12:18:22 +00:00
|
|
|
if( $siteDir != $options['dir'] ) {
|
2008-08-21 14:09:57 +00:00
|
|
|
return '';
|
2010-05-22 12:18:22 +00:00
|
|
|
}
|
2008-08-21 14:09:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( isset( $options['media'] ) ) {
|
|
|
|
|
$media = $this->transformCssMedia( $options['media'] );
|
|
|
|
|
if( is_null( $media ) ) {
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2009-09-07 00:21:55 +00:00
|
|
|
$media = 'all';
|
2008-08-21 14:09:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( substr( $style, 0, 1 ) == '/' ||
|
|
|
|
|
substr( $style, 0, 5 ) == 'http:' ||
|
|
|
|
|
substr( $style, 0, 6 ) == 'https:' ) {
|
|
|
|
|
$url = $style;
|
|
|
|
|
} else {
|
|
|
|
|
global $wgStylePath, $wgStyleVersion;
|
|
|
|
|
$url = $wgStylePath . '/' . $style . '?' . $wgStyleVersion;
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-11 00:09:24 +00:00
|
|
|
$link = Html::linkedStyle( $url, $media );
|
2008-08-21 14:09:57 +00:00
|
|
|
|
|
|
|
|
if( isset( $options['condition'] ) ) {
|
|
|
|
|
$condition = htmlspecialchars( $options['condition'] );
|
|
|
|
|
$link = "<!--[if $condition]>$link<![endif]-->";
|
|
|
|
|
}
|
|
|
|
|
return $link;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-29 21:32:45 +00:00
|
|
|
/**
|
|
|
|
|
* Transform "media" attribute based on request parameters
|
|
|
|
|
*
|
|
|
|
|
* @param $media String: current value of the "media" attribute
|
|
|
|
|
* @return String: modified value of the "media" attribute
|
|
|
|
|
*/
|
2008-08-21 14:09:57 +00:00
|
|
|
function transformCssMedia( $media ) {
|
|
|
|
|
global $wgRequest, $wgHandheldForIPhone;
|
|
|
|
|
|
|
|
|
|
// Switch in on-screen display for media testing
|
|
|
|
|
$switches = array(
|
|
|
|
|
'printable' => 'print',
|
|
|
|
|
'handheld' => 'handheld',
|
|
|
|
|
);
|
|
|
|
|
foreach( $switches as $switch => $targetMedia ) {
|
|
|
|
|
if( $wgRequest->getBool( $switch ) ) {
|
|
|
|
|
if( $media == $targetMedia ) {
|
|
|
|
|
$media = '';
|
|
|
|
|
} elseif( $media == 'screen' ) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Expand longer media queries as iPhone doesn't grok 'handheld'
|
|
|
|
|
if( $wgHandheldForIPhone ) {
|
|
|
|
|
$mediaAliases = array(
|
|
|
|
|
'screen' => 'screen and (min-device-width: 481px)',
|
|
|
|
|
'handheld' => 'handheld, only screen and (max-device-width: 480px)',
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if( isset( $mediaAliases[$media] ) ) {
|
|
|
|
|
$media = $mediaAliases[$media];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $media;
|
|
|
|
|
}
|
|
|
|
|
|
2005-05-27 11:03:37 +00:00
|
|
|
/**
|
|
|
|
|
* Turn off regular page output and return an error reponse
|
|
|
|
|
* for when rate limiting has triggered.
|
|
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function rateLimited() {
|
2010-05-22 12:18:22 +00:00
|
|
|
$this->setPageTitle( wfMsg( 'actionthrottled' ) );
|
2007-11-20 17:32:43 +00:00
|
|
|
$this->setRobotPolicy( 'noindex,follow' );
|
2007-11-20 08:34:59 +00:00
|
|
|
$this->setArticleRelated( false );
|
|
|
|
|
$this->enableClientCache( false );
|
|
|
|
|
$this->mRedirect = '';
|
|
|
|
|
$this->clearHTML();
|
2010-05-22 12:18:22 +00:00
|
|
|
$this->setStatusCode( 503 );
|
2008-02-18 07:25:35 +00:00
|
|
|
$this->addWikiMsg( 'actionthrottledtext' );
|
2007-11-20 08:34:59 +00:00
|
|
|
|
2009-04-09 02:22:36 +00:00
|
|
|
$this->returnToMain( null, $this->getTitle() );
|
2005-05-27 11:03:37 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2007-05-18 20:17:53 +00:00
|
|
|
/**
|
|
|
|
|
* Show a warning about slave lag
|
|
|
|
|
*
|
2007-08-11 17:18:20 +00:00
|
|
|
* If the lag is higher than $wgSlaveLagCritical seconds,
|
|
|
|
|
* then the warning is a bit more obvious. If the lag is
|
|
|
|
|
* lower than $wgSlaveLagWarning, then no warning is shown.
|
2007-05-18 20:17:53 +00:00
|
|
|
*
|
2010-01-29 21:32:45 +00:00
|
|
|
* @param $lag Integer: slave lag
|
2007-05-18 20:17:53 +00:00
|
|
|
*/
|
|
|
|
|
public function showLagWarning( $lag ) {
|
2009-09-18 20:10:25 +00:00
|
|
|
global $wgSlaveLagWarning, $wgSlaveLagCritical, $wgLang;
|
2007-08-11 17:18:20 +00:00
|
|
|
if( $lag >= $wgSlaveLagWarning ) {
|
|
|
|
|
$message = $lag < $wgSlaveLagCritical
|
|
|
|
|
? 'lag-warn-normal'
|
|
|
|
|
: 'lag-warn-high';
|
2009-09-18 20:10:25 +00:00
|
|
|
$wrap = Html::rawElement( 'div', array( 'class' => "mw-{$message}" ), "\n$1\n" );
|
|
|
|
|
$this->wrapWikiMsg( "$wrap\n", array( $message, $wgLang->formatNum( $lag ) ) );
|
2007-08-11 17:18:20 +00:00
|
|
|
}
|
2007-05-18 20:17:53 +00:00
|
|
|
}
|
2007-12-10 06:02:29 +00:00
|
|
|
|
2008-02-18 07:25:35 +00:00
|
|
|
/**
|
|
|
|
|
* Add a wikitext-formatted message to the output.
|
|
|
|
|
* This is equivalent to:
|
|
|
|
|
*
|
|
|
|
|
* $wgOut->addWikiText( wfMsgNoTrans( ... ) )
|
|
|
|
|
*/
|
|
|
|
|
public function addWikiMsg( /*...*/ ) {
|
|
|
|
|
$args = func_get_args();
|
|
|
|
|
$name = array_shift( $args );
|
|
|
|
|
$this->addWikiMsgArray( $name, $args );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add a wikitext-formatted message to the output.
|
|
|
|
|
* Like addWikiMsg() except the parameters are taken as an array
|
|
|
|
|
* instead of a variable argument list.
|
|
|
|
|
*
|
|
|
|
|
* $options is passed through to wfMsgExt(), see that function for details.
|
|
|
|
|
*/
|
|
|
|
|
public function addWikiMsgArray( $name, $args, $options = array() ) {
|
|
|
|
|
$options[] = 'parse';
|
|
|
|
|
$text = wfMsgExt( $name, $options, $args );
|
|
|
|
|
$this->addHTML( $text );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2008-04-14 07:45:50 +00:00
|
|
|
* This function takes a number of message/argument specifications, wraps them in
|
2008-02-18 07:25:35 +00:00
|
|
|
* some overall structure, and then parses the result and adds it to the output.
|
|
|
|
|
*
|
2008-04-14 07:45:50 +00:00
|
|
|
* In the $wrap, $1 is replaced with the first message, $2 with the second, and so
|
|
|
|
|
* on. The subsequent arguments may either be strings, in which case they are the
|
2009-05-19 23:27:53 +00:00
|
|
|
* message names, or arrays, in which case the first element is the message name,
|
2008-02-18 07:25:35 +00:00
|
|
|
* and subsequent elements are the parameters to that message.
|
|
|
|
|
*
|
|
|
|
|
* The special named parameter 'options' in a message specification array is passed
|
2008-04-14 07:45:50 +00:00
|
|
|
* through to the $options parameter of wfMsgExt().
|
2008-02-18 07:25:35 +00:00
|
|
|
*
|
2008-04-18 06:31:37 +00:00
|
|
|
* Don't use this for messages that are not in users interface language.
|
|
|
|
|
*
|
2008-02-18 07:25:35 +00:00
|
|
|
* For example:
|
|
|
|
|
*
|
2010-05-28 21:22:45 +00:00
|
|
|
* $wgOut->wrapWikiMsg( "<div class='error'>\n$1\n</div>", 'some-error' );
|
2008-04-14 07:45:50 +00:00
|
|
|
*
|
2008-02-18 07:25:35 +00:00
|
|
|
* Is equivalent to:
|
|
|
|
|
*
|
2010-05-28 21:22:45 +00:00
|
|
|
* $wgOut->addWikiText( "<div class='error'>\n" . wfMsgNoTrans( 'some-error' ) . "\n</div>" );
|
2010-01-14 17:14:49 +00:00
|
|
|
*
|
|
|
|
|
* The newline after opening div is needed in some wikitext. See bug 19226.
|
2008-02-18 07:25:35 +00:00
|
|
|
*/
|
|
|
|
|
public function wrapWikiMsg( $wrap /*, ...*/ ) {
|
|
|
|
|
$msgSpecs = func_get_args();
|
|
|
|
|
array_shift( $msgSpecs );
|
|
|
|
|
$msgSpecs = array_values( $msgSpecs );
|
|
|
|
|
$s = $wrap;
|
|
|
|
|
foreach ( $msgSpecs as $n => $spec ) {
|
|
|
|
|
$options = array();
|
|
|
|
|
if ( is_array( $spec ) ) {
|
|
|
|
|
$args = $spec;
|
|
|
|
|
$name = array_shift( $args );
|
|
|
|
|
if ( isset( $args['options'] ) ) {
|
|
|
|
|
$options = $args['options'];
|
|
|
|
|
unset( $args['options'] );
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$args = array();
|
|
|
|
|
$name = $spec;
|
|
|
|
|
}
|
2009-01-30 16:45:09 +00:00
|
|
|
$s = str_replace( '$' . ( $n + 1 ), wfMsgExt( $name, $options, $args ), $s );
|
2008-02-18 07:25:35 +00:00
|
|
|
}
|
2008-04-18 06:31:37 +00:00
|
|
|
$this->addHTML( $this->parse( $s, /*linestart*/true, /*uilang*/true ) );
|
2008-02-18 07:25:35 +00:00
|
|
|
}
|
2010-01-23 20:11:42 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Include jQuery core. Use this to avoid loading it multiple times
|
2010-05-22 11:47:56 +00:00
|
|
|
* before we get a usable script loader.
|
2010-01-27 04:17:49 +00:00
|
|
|
*
|
2010-01-29 21:32:45 +00:00
|
|
|
* @param $modules Array: list of jQuery modules which should be loaded
|
|
|
|
|
* @return Array: the list of modules which were not loaded.
|
2010-02-24 16:21:52 +00:00
|
|
|
* @since 1.16
|
2010-09-04 04:00:09 +00:00
|
|
|
* @deprecated No longer needed as of 1.17
|
2010-01-23 20:11:42 +00:00
|
|
|
*/
|
2010-01-27 04:17:49 +00:00
|
|
|
public function includeJQuery( $modules = array() ) {
|
2010-09-04 04:00:09 +00:00
|
|
|
return array();
|
2010-01-23 20:11:42 +00:00
|
|
|
}
|
|
|
|
|
|
2007-08-16 07:05:38 +00:00
|
|
|
}
|