Merge "Fix calls to DatabaseBase static functions"
[lhc/web/wiklou.git] / includes / OutputPage.php
index b832a4c..6ea4953 100644 (file)
@@ -311,6 +311,7 @@ class OutputPage extends ContextSource {
         * Constructor for OutputPage. This should not be called directly.
         * Instead a new RequestContext should be created and it will implicitly create
         * a OutputPage tied to that context.
+        * @param IContextSource|null $context
         */
        function __construct( IContextSource $context = null ) {
                if ( $context === null ) {
@@ -369,7 +370,7 @@ class OutputPage extends ContextSource {
         *
         * @param array $linkarr Associative array of attributes.
         */
-       function addLink( $linkarr ) {
+       function addLink( array $linkarr ) {
                array_push( $this->mLinktags, $linkarr );
        }
 
@@ -380,7 +381,7 @@ class OutputPage extends ContextSource {
         *                 values, both keys and values will be escaped, and the
         *                 "rel" attribute will be automatically added
         */
-       function addMetadataLink( $linkarr ) {
+       function addMetadataLink( array $linkarr ) {
                $linkarr['rel'] = $this->getMetadataAttribute();
                $this->addLink( $linkarr );
        }
@@ -388,6 +389,7 @@ class OutputPage extends ContextSource {
        /**
         * Set the URL to be used for the <link rel=canonical>. This should be used
         * in preference to addLink(), to avoid duplicate link tags.
+        * @param string $url
         */
        function setCanonicalUrl( $url ) {
                $this->mCanonicalUrl = $url;
@@ -488,7 +490,7 @@ class OutputPage extends ContextSource {
         * @param string $type
         * @return array
         */
-       protected function filterModules( $modules, $position = null,
+       protected function filterModules( array $modules, $position = null,
                $type = ResourceLoaderModule::TYPE_COMBINED
        ) {
                $resourceLoader = $this->getResourceLoader();
@@ -1002,9 +1004,9 @@ class OutputPage extends ContextSource {
         * Add a subtitle containing a backlink to a page
         *
         * @param Title $title Title to link to
+        * @param array $query Array of additional parameters to include in the link
         */
-       public function addBacklinkSubtitle( Title $title ) {
-               $query = array();
+       public function addBacklinkSubtitle( Title $title, $query = array() ) {
                if ( $title->isRedirect() ) {
                        $query['redirect'] = 'no';
                }
@@ -1209,7 +1211,7 @@ class OutputPage extends ContextSource {
         * @param array $newLinkArray Associative array mapping language code to the page
         *                      name
         */
-       public function addLanguageLinks( $newLinkArray ) {
+       public function addLanguageLinks( array $newLinkArray ) {
                $this->mLanguageLinks += $newLinkArray;
        }
 
@@ -1219,7 +1221,7 @@ class OutputPage extends ContextSource {
         * @param array $newLinkArray Associative array mapping language code to the page
         *                      name
         */
-       public function setLanguageLinks( $newLinkArray ) {
+       public function setLanguageLinks( array $newLinkArray ) {
                $this->mLanguageLinks = $newLinkArray;
        }
 
@@ -1237,7 +1239,7 @@ class OutputPage extends ContextSource {
         *
         * @param array $categories Mapping category name => sort key
         */
-       public function addCategoryLinks( $categories ) {
+       public function addCategoryLinks( array $categories ) {
                global $wgContLang;
 
                if ( !is_array( $categories ) || count( $categories ) == 0 ) {
@@ -1266,11 +1268,8 @@ class OutputPage extends ContextSource {
                # Add the results to the link cache
                $lb->addResultToCache( LinkCache::singleton(), $res );
 
-               # Set all the values to 'normal'. This can be done with array_fill_keys in PHP 5.2.0+
-               $categories = array_combine(
-                       array_keys( $categories ),
-                       array_fill( 0, count( $categories ), 'normal' )
-               );
+               # Set all the values to 'normal'.
+               $categories = array_fill_keys( array_keys( $categories ), 'normal' );
 
                # Mark hidden categories
                foreach ( $res as $row ) {
@@ -1306,7 +1305,7 @@ class OutputPage extends ContextSource {
         *
         * @param array $categories Mapping category name => sort key
         */
-       public function setCategoryLinks( $categories ) {
+       public function setCategoryLinks( array $categories ) {
                $this->mCategoryLinks = array();
                $this->addCategoryLinks( $categories );
        }
@@ -1404,7 +1403,7 @@ class OutputPage extends ContextSource {
         * @param array $attribs
         * @param string $contents
         */
-       public function addElement( $element, $attribs = array(), $contents = '' ) {
+       public function addElement( $element, array $attribs = array(), $contents = '' ) {
                $this->addHTML( Html::element( $element, $attribs, $contents ) );
        }
 
@@ -1641,6 +1640,8 @@ class OutputPage extends ContextSource {
                $this->addModuleStyles( $parserOutput->getModuleStyles() );
                $this->addModuleMessages( $parserOutput->getModuleMessages() );
                $this->addJsConfigVars( $parserOutput->getJsConfigVars() );
+               $this->mPreventClickjacking = $this->mPreventClickjacking
+                       || $parserOutput->preventClickjacking();
 
                // Template versioning...
                foreach ( (array)$parserOutput->getTemplateIds() as $ns => $dbks ) {
@@ -1968,6 +1969,16 @@ class OutputPage extends ContextSource {
                $this->mPreventClickjacking = false;
        }
 
+       /**
+        * Get the prevent-clickjacking flag
+        *
+        * @since 1.24
+        * @return bool
+        */
+       public function getPreventClickjacking() {
+               return $this->mPreventClickjacking;
+       }
+
        /**
         * Get the X-Frame-Options header value (without the name part), or false
         * if there isn't one. This is used by Skin to determine whether to enable
@@ -2253,7 +2264,7 @@ class OutputPage extends ContextSource {
         * @param array $errors Error message keys
         * @param string $action Action that was denied or null if unknown
         */
-       public function showPermissionsErrorPage( $errors, $action = null ) {
+       public function showPermissionsErrorPage( array $errors, $action = null ) {
                // For some action (read, edit, create and upload), display a "login to do this action"
                // error if all of the following conditions are met:
                // 1. the user is not logged in
@@ -2358,7 +2369,7 @@ class OutputPage extends ContextSource {
         * @param string $action Action that was denied or null if unknown
         * @return string The wikitext error-messages, formatted into a list.
         */
-       public function formatPermissionsErrorMessage( $errors, $action = null ) {
+       public function formatPermissionsErrorMessage( array $errors, $action = null ) {
                if ( $action == null ) {
                        $text = $this->msg( 'permissionserrorstext', count( $errors ) )->plain() . "\n\n";
                } else {
@@ -2411,7 +2422,7 @@ class OutputPage extends ContextSource {
         * @throws ReadOnlyError
         */
        public function readOnlyPage( $source = null, $protected = false,
-               $reasons = array(), $action = null
+               array $reasons = array(), $action = null
        ) {
                $this->setRobotPolicy( 'noindex,nofollow' );
                $this->setArticleRelated( false );
@@ -2530,7 +2541,7 @@ $templates
         * @param string $text Text of the link (input is not escaped)
         * @param array $options Options array to pass to Linker
         */
-       public function addReturnTo( $title, $query = array(), $text = null, $options = array() ) {
+       public function addReturnTo( $title, array $query = array(), $text = null, $options = array() ) {
                $link = $this->msg( 'returnto' )->rawParams(
                        Linker::link( $title, $text, array(), $query, $options ) )->escaped();
                $this->addHTML( "<p id=\"mw-returnto\">{$link}</p>\n" );
@@ -2726,6 +2737,8 @@ $templates
                                        && $only == ResourceLoaderModule::TYPE_SCRIPTS )
                                || ( $module->getOrigin() > $this->getAllowedModules( ResourceLoaderModule::TYPE_STYLES )
                                        && $only == ResourceLoaderModule::TYPE_STYLES )
+                               || ( $module->getOrigin() > $this->getAllowedModules( ResourceLoaderModule::TYPE_COMBINED )
+                                       && $only == ResourceLoaderModule::TYPE_COMBINED )
                                || ( $this->mTarget && !in_array( $this->mTarget, $module->getTargets() ) )
                        ) {
                                continue;
@@ -2786,9 +2799,7 @@ $templates
                                                );
                                        } else {
                                                $links['html'] .= Html::inlineScript(
-                                                       ResourceLoader::makeLoaderConditionalScript(
-                                                               $resourceLoader->makeModuleResponse( $context, $grpModules )
-                                                       )
+                                                       $resourceLoader->makeModuleResponse( $context, $grpModules )
                                                );
                                        }
                                        $links['html'] .= "\n";
@@ -2862,7 +2873,7 @@ $templates
         * @param array $links
         * @return string HTML
         */
-       protected static function getHtmlFromLoaderLinks( Array $links ) {
+       protected static function getHtmlFromLoaderLinks( array $links ) {
                $html = '';
                $states = array();
                foreach ( $links as $link ) {
@@ -3631,7 +3642,7 @@ $templates
         * @param array $options Option, can contain 'condition', 'dir', 'media' keys
         * @return string HTML fragment
         */
-       protected function styleLink( $style, $options ) {
+       protected function styleLink( $style, array $options ) {
                if ( isset( $options['dir'] ) ) {
                        if ( $this->getLanguage()->getDir() != $options['dir'] ) {
                                return '';
@@ -3792,7 +3803,7 @@ $templates
         * @since 1.16
         * @deprecated since 1.17
         */
-       public function includeJQuery( $modules = array() ) {
+       public function includeJQuery( array $modules = array() ) {
                return array();
        }