r105352 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105351‎ | r105352 | r105353 >
Date:21:13, 6 December 2011
Author:jeroendedauw
Status:reverted
Tags:
Comment:
tweaks
Modified paths:
  • /trunk/extensions/Reviews/Reviews.hooks.php (modified) (history)
  • /trunk/extensions/Reviews/includes/ReviewsTag.php (modified) (history)
  • /trunk/extensions/Reviews/resources/jquery.reviewControl.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Reviews/includes/ReviewsTag.php
@@ -53,23 +53,39 @@
5454 * @since 0.1
5555 *
5656 * @param IContextSource $contextSource
 57+ * @param Parser $parser
5758 *
5859 * @return string
5960 */
60 - public function render( IContextSource $contextSource ) {
 61+ public function render( IContextSource $contextSource = null, Parser $parser = null ) {
6162 static $loadedJs = false;
6263
 64+ $source = false;
 65+
 66+ if ( !is_null( $contextSource ) ) {
 67+ $source = $contextSource;
 68+ }
 69+
 70+ if ( !is_null( $parser ) ) {
 71+ $source = $parser;
 72+ }
 73+
6374 if ( !$loadedJs ) {
64 - $contextSource->getOutput()->addModules( 'ext.reviews.tag' );
65 - $contextSource->getOutput()->addHeadItem(
66 - 'wgReviewsSettings',
67 - Skin::makeVariablesScript( array(
68 - 'wgReviewsSettings' => ReviewsSettings::getSettings()
69 - ) )
70 - );
 75+ $js = Skin::makeVariablesScript( array(
 76+ 'wgReviewsSettings' => ReviewsSettings::getSettings()
 77+ ) );
 78+
 79+ $source->getOutput()->addModules( 'ext.reviews.tag' );
 80+
 81+ if ( is_null( $contextSource ) ) {
 82+ $source->getOutput()->addHeadItem( $js );
 83+ }
 84+ else {
 85+ $source->getOutput()->addHeadItem( 'wgReviewsSettings', $js );
 86+ }
7187 }
7288
73 - $reviews = $this->getReviews( $contextSource );
 89+ $reviews = $this->getReviews( $source->getTitle() );
7490
7591 if ( count( $reviews ) > 0 ) {
7692 return $this->getList( $reviews );
@@ -84,11 +100,11 @@
85101 *
86102 * @since 0.1
87103 *
88 - * @param IContextSource $contextSource
 104+ * @param Title $title
89105 *
90106 * @return array of Review
91107 */
92 - protected function getReviews( IContextSource $contextSource ) {
 108+ protected function getReviews( Title $title ) {
93109 $conditions = array(
94110 'state' => array( Review::STATUS_NEW, Review::STATUS_REVIEWED )
95111 );
@@ -115,7 +131,7 @@
116132 }
117133 }
118134 else {
119 - $conditions['page_id'] = $contextSource->getTitle()->getArticleID();
 135+ $conditions['page_id'] = $title->getArticleID();
120136 }
121137
122138 if ( $this->contents['user'] ) {
Index: trunk/extensions/Reviews/resources/jquery.reviewControl.js
@@ -6,9 +6,14 @@
77 * @author Jeroen De Dauw <jeroendedauw at gmail dot com>
88 */
99
10 -(function( $, mw, reviews ) {
11 -
12 - $.fn.reviewControl = function() {
 10+(function( $, mw, reviews ) { $.fn.reviewControl = function( options ) {
 11+
 12+ var settings = $.extend( {
 13+
 14+ }, options );
 15+
 16+ return this.each( function() {
 17+
1318 var _this = this;
1419 var $this = $( this );
1520
@@ -163,8 +168,6 @@
164169 };
165170
166171 this.setup();
 172+ } );
167173
168 - return this;
169 - };
170 -
171 -})( window.jQuery, window.mediaWiki, window.reviews );
 174+}; })( window.jQuery, window.mediaWiki, window.reviews );
Index: trunk/extensions/Reviews/Reviews.hooks.php
@@ -203,7 +203,7 @@
204204 */
205205 public static function onReviewsRender( $input, array $args, Parser $parser, PPFrame $frame ) {
206206 $tag = new ReviewsTag( $args, $input );
207 - return $tag->render( $parser->getOutput() );
 207+ return $tag->render( null, $parser );
208208 }
209209
210210 /**

Status & tagging log