r65897 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65896‎ | r65897 | r65898 >
Date:07:59, 4 May 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Further implemented ajaxscroll for storyreview. Will add review controls soon.
Modified paths:
  • /trunk/extensions/Storyboard/api/ApiQueryStories.php (modified) (history)
  • /trunk/extensions/Storyboard/specials/StoryReview/StoryReview_body.php (modified) (history)
  • /trunk/extensions/Storyboard/storyboard.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Storyboard/specials/StoryReview/StoryReview_body.php
@@ -63,8 +63,8 @@
6464 <div id="storyreview-tabs">
6565 <ul>
6666 <li><a href="#$unpublished" id="$unpublished-tab">$unpublished</a></li>
67 - <!--<li><a href="#$published" id="$published-tab">$published</a></li>
68 - <li><a href="#$hidden" id="$hidden-tab">$hidden</a></li>-->
 67+ <li><a href="#$published" id="$published-tab">$published</a></li>
 68+ <li><a href="#$hidden" id="$hidden-tab">$hidden</a></li>
6969 </ul>
7070 <div id="$unpublished"></div>
7171 <div id="$published"></div>
@@ -79,7 +79,7 @@
8080 });
8181
8282 jQuery('#storyreview-tabs').bind( 'tabsshow', function( event, ui ) {
83 - stbShowReviewBoard( jQuery( ui.panel ) );
 83+ stbShowReviewBoard( jQuery( ui.panel ), ui.index );
8484 });
8585 </script>
8686 EOT;
Index: trunk/extensions/Storyboard/storyboard.js
@@ -74,12 +74,14 @@
7575 * Story review functions
7676 */
7777
78 -function stbShowReviewBoard( tab ) {
 78+function stbShowReviewBoard( tab, state ) {
7979 tab.html( jQuery( "<div />" )
8080 .addClass( "storyreviewboard" )
81 - .attr( { "style": "height: 420px; width: 100%;" } ) );
 81+ .attr( { "style": "height: 420px; width: 100%;", "id": "storyreviewboard-" + state } ) );
8282
83 - jQuery( '.storyreviewboard' ).ajaxScroll( {
 83+ window.reviewstate = state;
 84+
 85+ jQuery( '#storyreviewboard-' + state ).ajaxScroll( {
8486 updateBatch: stbUpdateReviewBoard,
8587 maxOffset: 500,
8688 batchSize: 2,
@@ -97,7 +99,9 @@
98100 'list': 'stories',
99101 'format': 'json',
100102 'stlimit': 8,
101 - 'stlanguage': window.storyboardLanguage
 103+ 'stlanguage': window.storyboardLanguage,
 104+ 'streview': 1,
 105+ 'ststate': window.reviewstate
102106 };
103107
104108 jQuery.getJSON( wgScriptPath + '/api.php',
@@ -135,12 +139,15 @@
136140 $storyBody.append( textAndImg );
137141
138142 $storyBody.append( // TODO: get the actual message here
139 - jQuery( "<div />" ).addClass( "story-metadata" ).append(
140 - jQuery("<span />").addClass( "story-metadata" ).text( " Submitted by $1 from $2 on $3, $4.")
 143+ jQuery( "<div />" ).addClass( "story-metadata" ).append(
 144+ jQuery("<span />").addClass( "story-metadata" ).text( " Submitted by $1 from $2 on $3, $4." )
141145 )
142146 );
143147
144148 // TODO: add review controls
 149+ $storyBody.append(
 150+ jQuery( "<div />" ).append( jQuery( "<button />" ).text( "edit" ).attr( "onclick", "window.location='" + story.modifyurl + "'" ) )
 151+ );
145152
146153 $storyboard.append( $storyBody );
147154 }
@@ -152,8 +159,6 @@
153160 * @param sender The UI element invocing the action, typically a button.
154161 * @param storyid Id identifying the story.
155162 * @param action The action that needs to be performed on the story.
156 - *
157 - * TODO: support multiple actions at once
158163 */
159164 function stbDoStoryAction( sender, storyid, action ) {
160165 sender.innerHTML = 'Working...'; // TODO: i18n
Index: trunk/extensions/Storyboard/api/ApiQueryStories.php
@@ -43,10 +43,13 @@
4444 * Retrieve the stories from the database.
4545 */
4646 public function execute() {
 47+ global $wgUser;
 48+
4749 // Get the requests parameters.
4850 $params = $this->extractRequestParams();
4951
5052 $this->addTables( 'storyboard' );
 53+
5154 $this->addFields( array(
5255 'story_id',
5356 'story_author_id',
@@ -57,9 +60,27 @@
5861 'story_created',
5962 'story_modified'
6063 ) );
61 - $this->addWhere( array(
62 - 'story_state' => Storyboard_STORY_PUBLISHED
63 - ) );
 64+
 65+ $isReview = !is_null( $params['review'] ) && $wgUser->isAllowed( 'storyreview' );
 66+
 67+ if ( $isReview ) {
 68+ if ( !isset( $params['state'] ) ) {
 69+ $this->dieUsageMsg( array( 'missingparam', 'state' ) );
 70+ }
 71+
 72+ $this->addFields( array(
 73+
 74+ ) );
 75+
 76+ $this->addWhere( array(
 77+ 'story_state' => $params['state']
 78+ ) );
 79+ } else {
 80+ $this->addWhere( array(
 81+ 'story_state' => Storyboard_STORY_PUBLISHED
 82+ ) );
 83+ }
 84+
6485 $this->addOption( 'LIMIT', $params['limit'] + 1 );
6586 $this->addOption( 'ORDER BY', 'story_modified, story_id DESC' );
6687
@@ -95,7 +116,8 @@
96117 $this->setContinueEnumParameter( 'continue', wfTimestamp( TS_MW, $story->story_modified ) . '-' . $story->story_id );
97118 break;
98119 }
99 - $res = array(
 120+
 121+ $result = array(
100122 'id' => $story->story_id,
101123 'author' => $story->story_author_name,
102124 'title' => $story->story_title,
@@ -106,8 +128,15 @@
107129 'imageurl' => $story->story_author_image,
108130 'permalink' => SpecialPage::getTitleFor( 'story', $story->story_title )->getFullURL()
109131 );
110 - ApiResult::setContent( $res, ( is_null( $story->story_text ) ? '' : $story->story_text ) );
111 - $this->getResult()->addValue( array( 'query', $this->getModuleName() ), null, $res );
 132+
 133+ if ( $isReview ) {
 134+ $result['modifyurl'] = SpecialPage::getTitleFor( 'story', $story->story_title )->getFullURL(
 135+ 'action=edit&returnto=' . SpecialPage::getTitleFor( 'storyreview' )->getPrefixedText()
 136+ );
 137+ }
 138+
 139+ ApiResult::setContent( $result, ( is_null( $story->story_text ) ? '' : $story->story_text ) );
 140+ $this->getResult()->addValue( array( 'query', $this->getModuleName() ), null, $result );
112141 }
113142
114143 // FIXME: continue parameter is not getting passed with the result
@@ -130,7 +159,11 @@
131160 'continue' => null,
132161 'language' => array(
133162 ApiBase :: PARAM_TYPE => 'string',
134 - )
 163+ ),
 164+ 'review' => null,
 165+ 'state' => array(
 166+ ApiBase :: PARAM_TYPE => array( Storyboard_STORY_UNPUBLISHED, Storyboard_STORY_PUBLISHED, Storyboard_STORY_HIDDEN ),
 167+ )
135168 );
136169 }
137170
@@ -143,6 +176,8 @@
144177 'continue' => 'Number of the first story to return',
145178 'limit' => 'Amount of stories to return',
146179 'language' => 'The language of the stories to return',
 180+ 'review' => 'Indicates that storyreview parameters shoudl be passed when set',
 181+ 'state' => 'The state of the stories which should be returned'
147182 );
148183 }
149184
@@ -153,9 +188,19 @@
154189 public function getDescription() {
155190 return 'This module returns stories for a storyboard';
156191 }
157 -
 192+
158193 /**
159194 * (non-PHPdoc)
 195+ * @see includes/api/ApiBase#getPossibleErrors()
 196+ */
 197+ public function getPossibleErrors() {
 198+ return array_merge( parent::getPossibleErrors(), array(
 199+ array( 'missingparam', 'state' ),
 200+ ) );
 201+ }
 202+
 203+ /**
 204+ * (non-PHPdoc)
160205 * @see includes/api/ApiBase#getExamples()
161206 */
162207 protected function getExamples() {

Status & tagging log