Merge "tests: Remove unused TableCleanupTest class"
[lhc/web/wiklou.git] / includes / OutputPage.php
index 147527e..00143c7 100644 (file)
@@ -50,7 +50,7 @@ class OutputPage extends ContextSource {
 
        /**
         * @var array Additional stylesheets. Looks like this is for extensions.
-        *   Might be replaced by resource loader.
+        *   Might be replaced by ResourceLoader.
         */
        protected $mExtStyles = array();
 
@@ -132,7 +132,7 @@ class OutputPage extends ContextSource {
        private $mLanguageLinks = array();
 
        /**
-        * Used for JavaScript (pre resource loader)
+        * Used for JavaScript (predates ResourceLoader)
         * @todo We should split JS / CSS.
         * mScripts content is inserted as is in "<head>" by Skin. This might
         * contain either a link to a stylesheet or inline CSS.
@@ -151,8 +151,6 @@ class OutputPage extends ContextSource {
        /** @var array Array of elements in "<head>". Parser might add its own headers! */
        protected $mHeadItems = array();
 
-       // @todo FIXME: Next 5 variables probably come from the resource loader
-
        /** @var array */
        protected $mModules = array();
 
@@ -224,7 +222,7 @@ class OutputPage extends ContextSource {
        /**
         * @var bool Comes from the parser. This was probably made to load CSS/JS
         * only if we had "<gallery>". Used directly in CategoryPage.php.
-        * Looks like resource loader can replace this.
+        * Looks like ResourceLoader can replace this.
         */
        public $mNoGallery = false;
 
@@ -458,6 +456,8 @@ class OutputPage extends ContextSource {
 
        /**
         * Add raw HTML to the list of scripts (including \<script\> tag, etc.)
+        * Internal use only. Use OutputPage::addModules() or OutputPage::addJsConfigVars()
+        * if possible.
         *
         * @param string $script Raw HTML
         */
@@ -468,26 +468,31 @@ class OutputPage extends ContextSource {
        /**
         * Register and add a stylesheet from an extension directory.
         *
+        * @deprecated since 1.27 use addModuleStyles() or addStyle() instead
         * @param string $url 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 ) {
+               wfDeprecated( __METHOD__, '1.27' );
                array_push( $this->mExtStyles, $url );
        }
 
        /**
         * Get all styles added by extensions
         *
+        * @deprecated since 1.27
         * @return array
         */
        function getExtStyle() {
+               wfDeprecated( __METHOD__, '1.27' );
                return $this->mExtStyles;
        }
 
        /**
         * Add a JavaScript file out of skins/common, or a given relative path.
+        * Internal use only. Use OutputPage::addModules() if possible.
         *
         * @param string $file Filename in skins/common or complete on-server path
         *              (/foo/bar.js)
@@ -508,6 +513,7 @@ class OutputPage extends ContextSource {
 
        /**
         * Add a self-contained script tag with the given contents
+        * Internal use only. Use OutputPage::addModules() if possible.
         *
         * @param string $script JavaScript text, no "<script>" tags
         */
@@ -568,8 +574,8 @@ class OutputPage extends ContextSource {
        }
 
        /**
-        * Add one or more modules recognized by the resource loader. Modules added
-        * through this function will be loaded by the resource loader when the
+        * Add one or more modules recognized by ResourceLoader. Modules added
+        * through this function will be loaded by ResourceLoader when the
         * page loads.
         *
         * @param string|array $modules Module name (string) or array of module names
@@ -591,8 +597,8 @@ class OutputPage extends ContextSource {
        }
 
        /**
-        * 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
+        * Add only JS of one or more modules recognized by ResourceLoader. Module
+        * scripts added through this function will be loaded by ResourceLoader when
         * the page loads.
         *
         * @param string|array $modules Module name (string) or array of module names
@@ -614,7 +620,7 @@ class OutputPage extends ContextSource {
        }
 
        /**
-        * Add only CSS of one or more modules recognized by the resource loader.
+        * Add only CSS of one or more modules recognized by ResourceLoader.
         *
         * Module styles added through this function will be added using standard link CSS
         * tags, rather than as a combined Javascript and CSS package. Thus, they will
@@ -693,6 +699,12 @@ class OutputPage extends ContextSource {
        /**
         * Add or replace an header item to the output
         *
+        * Whenever possible, use more specific options like ResourceLoader modules,
+        * OutputPage::addLink(), OutputPage::addMetaLink() and OutputPage::addFeedLink()
+        * Fallback options for those are: OutputPage::addStyle, OutputPage::addScript(),
+        * OutputPage::addInlineScript() and OutputPage::addInlineStyle()
+        * This would be your very LAST fallback.
+        *
         * @param string $name Item name
         * @param string $value Raw HTML
         */
@@ -1027,6 +1039,7 @@ class OutputPage extends ContextSource {
         * @param string|Message $str String or Message to add to the subtitle
         */
        public function appendSubtitle( $str ) {
+               wfDeprecated( __METHOD__, '1.19' );
                $this->addSubtitle( $str );
        }
 
@@ -1341,6 +1354,8 @@ class OutputPage extends ContextSource {
                        array( &$this, $categories, &$this->mCategoryLinks ) )
                ) {
                        foreach ( $categories as $category => $type ) {
+                               // array keys will cast numeric category names to ints, so cast back to string
+                               $category = (string)$category;
                                $origcategory = $category;
                                $title = Title::makeTitleSafe( NS_CATEGORY, $category );
                                if ( !$title ) {
@@ -1750,6 +1765,7 @@ class OutputPage extends ContextSource {
         * @param ParserOutput $parserOutput
         */
        public function addParserOutputNoText( $parserOutput ) {
+               wfDeprecated( __METHOD__, '1.24' );
                $this->addParserOutputMetadata( $parserOutput );
        }
 
@@ -2330,6 +2346,7 @@ class OutputPage extends ContextSource {
         * @deprecated since 1.18
         */
        function blockedPage() {
+               wfDeprecated( __METHOD__, '1.18' );
                throw new UserBlockedError( $this->getUser()->mBlock );
        }
 
@@ -2481,6 +2498,7 @@ class OutputPage extends ContextSource {
         * @throws PermissionsError
         */
        public function permissionRequired( $permission ) {
+               wfDeprecated( __METHOD__, '1.18' );
                throw new PermissionsError( $permission );
        }
 
@@ -2490,6 +2508,7 @@ class OutputPage extends ContextSource {
         * @deprecated since 1.19; throw the exception directly
         */
        public function loginToUse() {
+               wfDeprecated( __METHOD__, '1.19' );
                throw new PermissionsError( 'read' );
        }
 
@@ -3292,7 +3311,11 @@ class OutputPage extends ContextSource {
         */
        public function userCanPreview() {
                $request = $this->getRequest();
-               if ( $request->getVal( 'action' ) !== 'submit' || !$request->wasPosted() ) {
+               if (
+                       $request->getVal( 'action' ) !== 'submit' ||
+                       !$request->getCheck( 'wpPreview' ) ||
+                       !$request->wasPosted()
+               ) {
                        return false;
                }
 
@@ -3603,7 +3626,7 @@ class OutputPage extends ContextSource {
 
        /**
         * Add a local or specified stylesheet, with the given media options.
-        * Meant primarily for internal use...
+        * Internal use only. Use OutputPage::addModuleStyles() if possible.
         *
         * @param string $style URL to the file
         * @param string $media To specify a media type, 'screen', 'printable', 'handheld' or any.
@@ -3628,6 +3651,8 @@ class OutputPage extends ContextSource {
 
        /**
         * Adds inline CSS styles
+        * Internal use only. Use OutputPage::addModuleStyles() if possible.
+        *
         * @param mixed $style_css Inline CSS
         * @param string $flip Set to 'flip' to flip the CSS if needed
         */
@@ -3942,6 +3967,7 @@ class OutputPage extends ContextSource {
         * @deprecated since 1.17
         */
        public function includeJQuery( array $modules = array() ) {
+               wfDeprecated( __METHOD__, '1.17' );
                return array();
        }