Index: trunk/extensions/Reviews/includes/ReviewsTag.php |
— | — | @@ -53,23 +53,39 @@ |
54 | 54 | * @since 0.1 |
55 | 55 | * |
56 | 56 | * @param IContextSource $contextSource |
| 57 | + * @param Parser $parser |
57 | 58 | * |
58 | 59 | * @return string |
59 | 60 | */ |
60 | | - public function render( IContextSource $contextSource ) { |
| 61 | + public function render( IContextSource $contextSource = null, Parser $parser = null ) { |
61 | 62 | static $loadedJs = false; |
62 | 63 | |
| 64 | + $source = false; |
| 65 | + |
| 66 | + if ( !is_null( $contextSource ) ) { |
| 67 | + $source = $contextSource; |
| 68 | + } |
| 69 | + |
| 70 | + if ( !is_null( $parser ) ) { |
| 71 | + $source = $parser; |
| 72 | + } |
| 73 | + |
63 | 74 | 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 | + } |
71 | 87 | } |
72 | 88 | |
73 | | - $reviews = $this->getReviews( $contextSource ); |
| 89 | + $reviews = $this->getReviews( $source->getTitle() ); |
74 | 90 | |
75 | 91 | if ( count( $reviews ) > 0 ) { |
76 | 92 | return $this->getList( $reviews ); |
— | — | @@ -84,11 +100,11 @@ |
85 | 101 | * |
86 | 102 | * @since 0.1 |
87 | 103 | * |
88 | | - * @param IContextSource $contextSource |
| 104 | + * @param Title $title |
89 | 105 | * |
90 | 106 | * @return array of Review |
91 | 107 | */ |
92 | | - protected function getReviews( IContextSource $contextSource ) { |
| 108 | + protected function getReviews( Title $title ) { |
93 | 109 | $conditions = array( |
94 | 110 | 'state' => array( Review::STATUS_NEW, Review::STATUS_REVIEWED ) |
95 | 111 | ); |
— | — | @@ -115,7 +131,7 @@ |
116 | 132 | } |
117 | 133 | } |
118 | 134 | else { |
119 | | - $conditions['page_id'] = $contextSource->getTitle()->getArticleID(); |
| 135 | + $conditions['page_id'] = $title->getArticleID(); |
120 | 136 | } |
121 | 137 | |
122 | 138 | if ( $this->contents['user'] ) { |
Index: trunk/extensions/Reviews/resources/jquery.reviewControl.js |
— | — | @@ -6,9 +6,14 @@ |
7 | 7 | * @author Jeroen De Dauw <jeroendedauw at gmail dot com> |
8 | 8 | */ |
9 | 9 | |
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 | + |
13 | 18 | var _this = this; |
14 | 19 | var $this = $( this ); |
15 | 20 | |
— | — | @@ -163,8 +168,6 @@ |
164 | 169 | }; |
165 | 170 | |
166 | 171 | this.setup(); |
| 172 | + } ); |
167 | 173 | |
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 @@ |
204 | 204 | */ |
205 | 205 | public static function onReviewsRender( $input, array $args, Parser $parser, PPFrame $frame ) { |
206 | 206 | $tag = new ReviewsTag( $args, $input ); |
207 | | - return $tag->render( $parser->getOutput() ); |
| 207 | + return $tag->render( null, $parser ); |
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |