Merge "Add RL targets support to OutputPage"
authorTrevor Parscal <tparscal@wikimedia.org>
Sat, 30 Mar 2013 00:13:16 +0000 (00:13 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sat, 30 Mar 2013 00:13:16 +0000 (00:13 +0000)
1  2 
includes/OutputPage.php

diff --combined includes/OutputPage.php
@@@ -253,6 -253,11 +253,11 @@@ class OutputPage extends ContextSource 
         */
        private $mProperties = array();
  
+       /**
+        * @var string|null: ResourceLoader target for load.php links. If null, will be omitted
+        */
+       private $mTarget = null;
        /**
         * Constructor for OutputPage. This should not be called directly.
         * Instead a new RequestContext should be created and it will implicitly create
                        $module = $resourceLoader->getModule( $val );
                        if( $module instanceof ResourceLoaderModule
                                && $module->getOrigin() <= $this->getAllowedModules( $type )
-                               && ( is_null( $position ) || $module->getPosition() == $position ) )
+                               && ( is_null( $position ) || $module->getPosition() == $position )
+                               && ( !$this->mTarget || in_array( $this->mTarget, $module->getTargets() ) ) )
                        {
                                $filteredModules[] = $val;
                        }
                $this->mModuleMessages = array_merge( $this->mModuleMessages, (array)$modules );
        }
  
+       /**
+        * @return null|string: ResourceLoader target
+        */
+       public function getTarget() {
+               return $this->mTarget;
+       }
+       /**
+        * Sets ResourceLoader target for load.php links. If null, will be omitted
+        *
+        * @param $target string|null
+        */
+       public function setTarget( $target ) {
+               $this->mTarget = $target;
+       }
        /**
         * Get an array of head items
         *
@@@ -2401,6 -2423,7 +2423,6 @@@ $template
                        $proto = PROTO_RELATIVE;
                }
  
 -              $this->addLink( array( 'rel' => 'next', 'href' => $title->getFullURL( '', false, $proto ) ) );
                $link = $this->msg( 'returnto' )->rawParams(
                        Linker::link( $title, $text, array(), $query, $options ) )->escaped();
                $this->addHTML( "<p id=\"mw-returnto\">{$link}</p>\n" );
                                return $links;
                        }
                }
+               if ( !is_null( $this->mTarget ) ) {
+                       $extraQuery['target'] = $this->mTarget;
+               }
  
                // Create keyed-by-group list of module objects from modules list
                $groups = array();
                                        && $only == ResourceLoaderModule::TYPE_SCRIPTS )
                                || ( $module->getOrigin() > $this->getAllowedModules( ResourceLoaderModule::TYPE_STYLES )
                                        && $only == ResourceLoaderModule::TYPE_STYLES )
+                               || ( $this->mTarget && !in_array( $this->mTarget, $module->getTargets() ) )
                                )
                        {
                                continue;