r97272 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97271‎ | r97272 | r97273 >
Date:14:17, 16 September 2011
Author:reedy
Status:ok
Tags:
Comment:
REL1_18 MFT r96560, r96630
Modified paths:
  • /branches/REL1_18/extensions/FlaggedRevs/presentation/FlaggedPageView.php (modified) (history)
  • /branches/REL1_18/extensions/FlaggedRevs/presentation/FlaggedRevsUI.hooks.php (modified) (history)
  • /branches/REL1_18/extensions/OggHandler/OggHandler_body.php (modified) (history)
  • /branches/REL1_18/extensions/OggHandler/OggPlayer.js (modified) (history)

Diff [purge]

Index: branches/REL1_18/extensions/OggHandler/OggPlayer.js
@@ -51,6 +51,11 @@
5252 * Parameters are: id, videoUrl, width, height, length, linkUrl, isVideo
5353 */
5454 'init': function ( player, params ) {
 55+ // Expand params.videoUrl if protocol-relative
 56+ if ( params.videoUrl.substr( 0, 2 ) == '//' ) {
 57+ // window.location.protocol is something like 'http:'
 58+ params.videoUrl = window.location.protocol + params.videoUrl;
 59+ }
5560 elt = document.getElementById( params.id );
5661
5762 // Save still image HTML
Index: branches/REL1_18/extensions/OggHandler/OggHandler_body.php
@@ -443,12 +443,12 @@
444444 }
445445
446446 static function getMyScriptPath() {
447 - global $wgScriptPath;
448 - return "$wgScriptPath/extensions/OggHandler";
 447+ global $wgExtensionAssetsPath;
 448+ return "$wgExtensionAssetsPath/OggHandler";
449449 }
450450
451451 function setHeaders( $out ) {
452 - global $wgOggScriptVersion, $wgCortadoJarFile, $wgServer;
 452+ global $wgOggScriptVersion, $wgCortadoJarFile;
453453
454454 if ( $out->hasHeadItem( 'OggHandlerScript' ) && $out->hasHeadItem( 'OggHandlerInlineScript' ) &&
455455 $out->hasHeadItem( 'OggHandlerInlineCSS' ) ) {
@@ -466,8 +466,9 @@
467467 $cortadoUrl = $wgCortadoJarFile;
468468 $scriptPath = self::getMyScriptPath();
469469 if( substr( $cortadoUrl, 0, 1 ) != '/'
470 - && substr( $cortadoUrl, 0, 4 ) != 'http' ) {
471 - $cortadoUrl = "$wgServer$scriptPath/$cortadoUrl";
 470+ && substr( $cortadoUrl, 0, 4 ) != 'http' )
 471+ {
 472+ $cortadoUrl = wfExpandUrl( "$scriptPath/$cortadoUrl", PROTO_CURRENT );
472473 }
473474 $encCortadoUrl = Xml::encodeJsVar( $cortadoUrl );
474475 $encExtPathUrl = Xml::encodeJsVar( $scriptPath );
@@ -540,12 +541,7 @@
541542
542543 OggTransformOutput::$serial++;
543544
544 - if ( substr( $this->videoUrl, 0, 4 ) != 'http' ) {
545 - global $wgServer;
546 - $url = $wgServer . $this->videoUrl;
547 - } else {
548 - $url = $this->videoUrl;
549 - }
 545+ $url = wfExpandUrl( $this->videoUrl, PROTO_RELATIVE );
550546 // Normalize values
551547 $length = floatval( $this->length );
552548 $width = intval( $this->width );
Index: branches/REL1_18/extensions/FlaggedRevs/presentation/FlaggedRevsUI.hooks.php
@@ -101,7 +101,15 @@
102102 public static function onBeforePageDisplay( &$out, &$skin ) {
103103 if ( $out->getTitle()->getNamespace() != NS_SPECIAL ) {
104104 $view = FlaggedPageView::singleton();
 105+ $view->addStabilizationLink(); // link on protect form
105106 $view->displayTag(); // show notice bar/icon in subtitle
 107+ if ( $out->isArticleRelated() ) {
 108+ // Only use this hook if we want to prepend the form.
 109+ // We prepend the form for diffs, so only handle that case here.
 110+ if ( $view->diffRevsAreSet() ) {
 111+ $view->addReviewForm( $out ); // form to be prepended
 112+ }
 113+ }
106114 $view->setRobotPolicy(); // set indexing policy
107115 self::injectStyleAndJS(); // full CSS/JS
108116 } else {
@@ -323,9 +331,11 @@
324332 && FlaggedPageView::globalArticleInstance() != null )
325333 {
326334 $view = FlaggedPageView::singleton();
327 - $view->addReviewNotes( $data );
328 - $view->addReviewForm( $data );
329 - $view->addStabilizationLink( $data );
 335+ // Only use this hook if we want to append the form.
 336+ // We *prepend* the form for diffs, so skip that case here.
 337+ if ( !$view->diffRevsAreSet() ) {
 338+ $view->addReviewForm( $data ); // form to be appended
 339+ }
330340 }
331341 return true;
332342 }
Index: branches/REL1_18/extensions/FlaggedRevs/presentation/FlaggedPageView.php
@@ -12,7 +12,6 @@
1313 protected $isDiffFromStable = false;
1414 protected $isMultiPageDiff = false;
1515 protected $reviewNotice = '';
16 - protected $reviewNotes = '';
1716 protected $diffNoticeBox = '';
1817 protected $reviewFormRev = false;
1918
@@ -44,20 +43,20 @@
4544 * Load the global FlaggedPage instance
4645 */
4746 protected function load() {
48 - global $wgOut;
4947 if ( !$this->loaded ) {
5048 $this->loaded = true;
5149 $this->article = self::globalArticleInstance();
5250 if ( $this->article == null ) {
5351 throw new MWException( 'FlaggedPageView has no context article!' );
5452 }
55 - $this->out = $wgOut;
 53+ $this->out = RequestContext::getMain()->getOutput();
5654 }
5755 }
5856
5957 /**
6058 * Get the FlaggedPage instance associated with $wgTitle,
6159 * or false if there isn't such a title
 60+ * @return FlaggedPage|null
6261 */
6362 public static function globalArticleInstance() {
6463 $title = RequestContext::getMain()->getTitle();
@@ -67,6 +66,14 @@
6867 return null;
6968 }
7069
 70+ /*
 71+ * Check if the old and new diff revs are set for this page view
 72+ * @return bool
 73+ */
 74+ public function diffRevsAreSet() {
 75+ return (bool)$this->diffRevs;
 76+ }
 77+
7178 /**
7279 * Is this web response for a request to view a page where both:
7380 * (a) no specific page version was requested via URL params
@@ -1044,10 +1051,12 @@
10451052 }
10461053
10471054 /**
1048 - * Add review form to pages when necessary
1049 - * on a regular page view (action=view)
 1055+ * Add review form to pages when necessary on a regular page view (action=view).
 1056+ * If $output is an OutputPage then this prepends the form onto it.
 1057+ * If $output is a string then this appends the review form to it.
 1058+ * @param mixed string|OutputPage
10501059 */
1051 - public function addReviewForm( &$data ) {
 1060+ public function addReviewForm( &$output ) {
10521061 global $wgRequest, $wgUser;
10531062 $this->load();
10541063 if ( $this->out->isPrintable() ) {
@@ -1099,11 +1108,11 @@
11001109
11011110 list( $html, $status ) = $form->getHtml();
11021111 # Diff action: place the form at the top of the page
1103 - if ( $this->diffRevs ) {
1104 - $this->out->prependHTML( $html );
 1112+ if ( $output instanceof OutputPage ) {
 1113+ $output->prependHTML( $html );
11051114 # View action: place the form at the bottom of the page
11061115 } else {
1107 - $data .= $html;
 1116+ $output .= $html;
11081117 }
11091118 }
11101119 return true;
@@ -1112,7 +1121,7 @@
11131122 /**
11141123 * Add link to stable version setting to protection form
11151124 */
1116 - public function addStabilizationLink( &$data ) {
 1125+ public function addStabilizationLink() {
11171126 global $wgRequest;
11181127 $this->load();
11191128 if ( FlaggedRevs::useProtectionLevels() ) {
@@ -1876,16 +1885,4 @@
18771886 }
18781887 return $editPage->fr_baseRevId;
18791888 }
1880 -
1881 - /**
1882 - * Adds brief review notes to a page.
1883 - * @param OutputPage $out
1884 - */
1885 - public function addReviewNotes( &$data ) {
1886 - $this->load();
1887 - if ( $this->reviewNotes ) {
1888 - $data .= $this->reviewNotes;
1889 - }
1890 - return true;
1891 - }
18921889 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r96560OggHandler: Address issues with protocol-relative URLs. Live hack in r96400....catrope12:59, 8 September 2011
r96630* Moved $view->addStabilizationLink to BeforePageDisplay hook so it actually ...aaron23:37, 8 September 2011

Status & tagging log