r65588 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65587‎ | r65588 | r65589 >
Date:22:01, 27 April 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Fixed language filter for storyboard tag
Modified paths:
  • /trunk/extensions/Storyboard/api/ApiQueryStories.php (modified) (history)
  • /trunk/extensions/Storyboard/specials/StoryReview/StoryReview_body.php (modified) (history)
  • /trunk/extensions/Storyboard/tags/Storyboard/Storyboard_body.php (modified) (history)
  • /trunk/extensions/Storyboard/tags/Storyboard/storyboard.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Storyboard/tags/Storyboard/storyboard.js
@@ -11,7 +11,7 @@
1212 updateBatch: updateStoryboard,
1313 maxOffset: 500,
1414 batchSize: 4,
15 - batchNum: 2,
 15+ batchNum: 1,
1616 batchClass: "batch",
1717 boxClass: "storyboard-box",
1818 emptyBatchClass: "storyboard-empty",
@@ -26,6 +26,7 @@
2727 'list': 'stories',
2828 'stcontinue': $storyboard.attr( 'offset' ) + '-0', // TODO: get modification date and id of the last story
2929 'stlimit': 4,
 30+ 'stlanguage': window.storyboardLanguage,
3031 'format': 'json'
3132 },
3233 function( data ) {
Index: trunk/extensions/Storyboard/tags/Storyboard/Storyboard_body.php
@@ -25,8 +25,6 @@
2626 * @param $frame
2727 *
2828 * @return array
29 - *
30 - * TODO: add language filter
3129 */
3230 public static function render( $input, array $args, Parser $parser, $frame ) {
3331 global $wgJsMimeType, $wgScriptPath, $wgStylePath, $wgStyleVersion, $wgContLanguageCode;
@@ -45,14 +43,18 @@
4644 $width = StoryboardUtils::getDimension( $args, 'width', $egStoryboardWidth );
4745 $height = StoryboardUtils::getDimension( $args, 'height', $egStoryboardHeight );
4846
49 - // TODO: use this value in the js
5047 $languages = Language::getLanguageNames();
 48+
5149 if ( array_key_exists( 'language', $args ) && array_key_exists( $args['language'], $languages ) ) {
5250 $language = $args['language'];
5351 } else {
5452 $language = $wgContLanguageCode;
5553 }
5654
 55+ $parser->getOutput()->addHeadItem(
 56+ Html::inlineScript( "var storyboardLanguage = '$language';" )
 57+ );
 58+
5759 $output = Html::element( 'div', array(
5860 'class' => 'storyboard',
5961 'style' => "height: $height; width: $width;"
Index: trunk/extensions/Storyboard/specials/StoryReview/StoryReview_body.php
@@ -75,6 +75,23 @@
7676 jQuery(function() {
7777 jQuery("#storyreview-tabs").tabs();
7878 });
 79+ /*
 80+ $('#$unpublished').click( stbLoadStoriesForReview );
 81+
 82+ function stbLoadStoriesForReview() {
 83+ $.getJSON(
 84+ wgScriptPath + '/api.php',
 85+ {
 86+ 'action': 'query',
 87+ 'list': 'stories',
 88+
 89+ },
 90+ function ( data ) {
 91+
 92+ }
 93+ );
 94+ }
 95+ */
7996 </script>
8097 EOT;
8198
@@ -177,7 +194,6 @@
178195 $buttons[] = <<<EOT
179196 <button type="button" onclick="stbDeleteStoryImage( this, $story->story_id )">$deleteImageMsg</button>
180197 EOT;
181 -
182198 }
183199
184200 $buttonHtml = implode( '&nbsp;&nbsp;&nbsp;', $buttons );
@@ -198,7 +214,7 @@
199215 $buttonHtml
200216 </td>
201217 </tr>
202 - </table>
 218+ </table>
203219 EOT;
204220 }
205221
Index: trunk/extensions/Storyboard/api/ApiQueryStories.php
@@ -63,6 +63,10 @@
6464 $this->addOption( 'LIMIT', $params['limit'] + 1 );
6565 $this->addOption( 'ORDER BY', 'story_modified, story_id DESC' );
6666
 67+ if ( !is_null( $params['language'] ) ) {
 68+ $this->addWhere( "story_lang_code = '$params[language]'" );
 69+ }
 70+
6771 if ( !is_null( $params['continue'] ) ) {
6872 $continueParams = explode( '-', $params['continue'] );
6973 if ( count( $continueParams ) != 2 ) {
@@ -123,6 +127,9 @@
124128 ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_BIG2
125129 ),
126130 'continue' => null,
 131+ 'language' => array(
 132+ ApiBase :: PARAM_TYPE => 'string',
 133+ )
127134 );
128135 }
129136
@@ -134,6 +141,7 @@
135142 return array (
136143 'continue' => 'Number of the first story to return',
137144 'limit' => 'Amount of stories to return',
 145+ 'language' => 'The language of the stories to return',
138146 );
139147 }
140148
@@ -152,7 +160,7 @@
153161 protected function getExamples() {
154162 return array (
155163 'api.php?action=query&list=stories',
156 - 'api.php?action=query&list=stories&stlimit=42',
 164+ 'api.php?action=query&list=stories&stlimit=42&stlanguage=en',
157165 'api.php?action=query&list=stories&stcontinue=20100319202223|4&stlimit=2',
158166 );
159167 }

Status & tagging log