http://www.mediawiki.org/wiki/Special:Code/MediaWiki/97272

Revision: 97272
Author:   reedy
Date:     2011-09-16 14:17:57 +0000 (Fri, 16 Sep 2011)
Log Message:
-----------
REL1_18 MFT r96560, r96630

Modified Paths:
--------------
    branches/REL1_18/extensions/FlaggedRevs/presentation/FlaggedPageView.php
    branches/REL1_18/extensions/FlaggedRevs/presentation/FlaggedRevsUI.hooks.php
    branches/REL1_18/extensions/OggHandler/OggHandler_body.php
    branches/REL1_18/extensions/OggHandler/OggPlayer.js

Modified: 
branches/REL1_18/extensions/FlaggedRevs/presentation/FlaggedPageView.php
===================================================================
--- branches/REL1_18/extensions/FlaggedRevs/presentation/FlaggedPageView.php    
2011-09-16 14:12:52 UTC (rev 97271)
+++ branches/REL1_18/extensions/FlaggedRevs/presentation/FlaggedPageView.php    
2011-09-16 14:17:57 UTC (rev 97272)
@@ -12,7 +12,6 @@
        protected $isDiffFromStable = false;
        protected $isMultiPageDiff = false;
        protected $reviewNotice = '';
-       protected $reviewNotes = '';
        protected $diffNoticeBox = '';
        protected $reviewFormRev = false;
 
@@ -44,20 +43,20 @@
        * Load the global FlaggedPage instance
        */
        protected function load() {
-               global $wgOut;
                if ( !$this->loaded ) {
                        $this->loaded = true;
                        $this->article = self::globalArticleInstance();
                        if ( $this->article == null ) {
                                throw new MWException( 'FlaggedPageView has no 
context article!' );
                        }
-                       $this->out = $wgOut;
+                       $this->out = RequestContext::getMain()->getOutput();
                }
        }
 
        /**
         * Get the FlaggedPage instance associated with $wgTitle,
         * or false if there isn't such a title
+        * @return FlaggedPage|null
         */
        public static function globalArticleInstance() {
                $title = RequestContext::getMain()->getTitle();
@@ -67,6 +66,14 @@
                return null;
        }
 
+       /*
+        * Check if the old and new diff revs are set for this page view
+        * @return bool
+        */
+       public function diffRevsAreSet() {
+               return (bool)$this->diffRevs;
+       }
+
        /**
         * Is this web response for a request to view a page where both:
         * (a) no specific page version was requested via URL params
@@ -1044,10 +1051,12 @@
        }
 
         /**
-        * Add review form to pages when necessary
-        * on a regular page view (action=view)
+        * Add review form to pages when necessary on a regular page view 
(action=view).
+        * If $output is an OutputPage then this prepends the form onto it.
+        * If $output is a string then this appends the review form to it.
+        * @param mixed string|OutputPage
         */
-       public function addReviewForm( &$data ) {
+       public function addReviewForm( &$output ) {
                global $wgRequest, $wgUser;
                $this->load();
                if ( $this->out->isPrintable() ) {
@@ -1099,11 +1108,11 @@
 
                        list( $html, $status ) = $form->getHtml();
                        # Diff action: place the form at the top of the page
-                       if ( $this->diffRevs ) {
-                               $this->out->prependHTML( $html );
+                       if ( $output instanceof OutputPage ) {
+                               $output->prependHTML( $html );
                        # View action: place the form at the bottom of the page
                        } else {
-                               $data .= $html;
+                               $output .= $html;
                        }
                }
                return true;
@@ -1112,7 +1121,7 @@
         /**
         * Add link to stable version setting to protection form
         */
-       public function addStabilizationLink( &$data ) {
+       public function addStabilizationLink() {
                global $wgRequest;
                $this->load();
                if ( FlaggedRevs::useProtectionLevels() ) {
@@ -1876,16 +1885,4 @@
                }
                return $editPage->fr_baseRevId;
        }
-
-        /**
-        * Adds brief review notes to a page.
-        * @param OutputPage $out
-        */
-       public function addReviewNotes( &$data ) {
-               $this->load();
-               if ( $this->reviewNotes ) {
-                       $data .= $this->reviewNotes;
-               }
-               return true;
-       }
 }

Modified: 
branches/REL1_18/extensions/FlaggedRevs/presentation/FlaggedRevsUI.hooks.php
===================================================================
--- 
branches/REL1_18/extensions/FlaggedRevs/presentation/FlaggedRevsUI.hooks.php    
    2011-09-16 14:12:52 UTC (rev 97271)
+++ 
branches/REL1_18/extensions/FlaggedRevs/presentation/FlaggedRevsUI.hooks.php    
    2011-09-16 14:17:57 UTC (rev 97272)
@@ -101,7 +101,15 @@
        public static function onBeforePageDisplay( &$out, &$skin ) {
                if ( $out->getTitle()->getNamespace() != NS_SPECIAL ) {
                        $view = FlaggedPageView::singleton();
+                       $view->addStabilizationLink(); // link on protect form
                        $view->displayTag(); // show notice bar/icon in subtitle
+                       if ( $out->isArticleRelated() ) {
+                               // Only use this hook if we want to prepend the 
form.
+                               // We prepend the form for diffs, so only 
handle that case here.
+                               if ( $view->diffRevsAreSet() ) {
+                                       $view->addReviewForm( $out ); // form 
to be prepended
+                               }
+                       }
                        $view->setRobotPolicy(); // set indexing policy
                        self::injectStyleAndJS(); // full CSS/JS
                } else {
@@ -323,9 +331,11 @@
                        && FlaggedPageView::globalArticleInstance() != null )
                {
                        $view = FlaggedPageView::singleton();
-                       $view->addReviewNotes( $data );
-                       $view->addReviewForm( $data );
-                       $view->addStabilizationLink( $data );
+                       // Only use this hook if we want to append the form.
+                       // We *prepend* the form for diffs, so skip that case 
here.
+                       if ( !$view->diffRevsAreSet() ) {
+                               $view->addReviewForm( $data ); // form to be 
appended
+                       }
                }
                return true;
        }

Modified: branches/REL1_18/extensions/OggHandler/OggHandler_body.php
===================================================================
--- branches/REL1_18/extensions/OggHandler/OggHandler_body.php  2011-09-16 
14:12:52 UTC (rev 97271)
+++ branches/REL1_18/extensions/OggHandler/OggHandler_body.php  2011-09-16 
14:17:57 UTC (rev 97272)
@@ -443,12 +443,12 @@
        }
 
        static function getMyScriptPath() {
-               global $wgScriptPath;
-               return "$wgScriptPath/extensions/OggHandler";
+               global $wgExtensionAssetsPath;
+               return "$wgExtensionAssetsPath/OggHandler";
        }
 
        function setHeaders( $out ) {
-               global $wgOggScriptVersion, $wgCortadoJarFile, $wgServer;
+               global $wgOggScriptVersion, $wgCortadoJarFile;
 
                if ( $out->hasHeadItem( 'OggHandlerScript' ) && 
$out->hasHeadItem( 'OggHandlerInlineScript' ) &&
                        $out->hasHeadItem( 'OggHandlerInlineCSS' ) ) {
@@ -466,8 +466,9 @@
                $cortadoUrl = $wgCortadoJarFile;
                $scriptPath = self::getMyScriptPath();
                if( substr( $cortadoUrl, 0, 1 ) != '/'
-                       && substr( $cortadoUrl, 0, 4 ) != 'http' ) {
-                       $cortadoUrl = "$wgServer$scriptPath/$cortadoUrl";
+                               && substr( $cortadoUrl, 0, 4 ) != 'http' )
+               {
+                       $cortadoUrl = wfExpandUrl( "$scriptPath/$cortadoUrl", 
PROTO_CURRENT );
                }
                $encCortadoUrl = Xml::encodeJsVar( $cortadoUrl );
                $encExtPathUrl = Xml::encodeJsVar( $scriptPath );
@@ -540,12 +541,7 @@
 
                OggTransformOutput::$serial++;
 
-               if ( substr( $this->videoUrl, 0, 4 ) != 'http' ) {
-                       global $wgServer;
-                       $url = $wgServer . $this->videoUrl;
-               } else {
-                       $url = $this->videoUrl;
-               }
+               $url = wfExpandUrl( $this->videoUrl, PROTO_RELATIVE );
                // Normalize values
                $length = floatval( $this->length );
                $width = intval( $this->width );

Modified: branches/REL1_18/extensions/OggHandler/OggPlayer.js
===================================================================
--- branches/REL1_18/extensions/OggHandler/OggPlayer.js 2011-09-16 14:12:52 UTC 
(rev 97271)
+++ branches/REL1_18/extensions/OggHandler/OggPlayer.js 2011-09-16 14:17:57 UTC 
(rev 97272)
@@ -51,6 +51,11 @@
         * Parameters are: id, videoUrl, width, height, length, linkUrl, isVideo
         */
        'init': function ( player, params ) {
+               // Expand params.videoUrl if protocol-relative
+               if ( params.videoUrl.substr( 0, 2 ) == '//' ) {
+                       // window.location.protocol is something like 'http:'
+                       params.videoUrl = window.location.protocol + 
params.videoUrl;
+               }
                elt = document.getElementById( params.id );
 
                // Save still image HTML


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to