Index: trunk/extensions/Storyboard/specials/StoryReview/StoryReview_body.php |
— | — | @@ -63,8 +63,8 @@ |
64 | 64 | <div id="storyreview-tabs"> |
65 | 65 | <ul> |
66 | 66 | <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> |
69 | 69 | </ul> |
70 | 70 | <div id="$unpublished"></div> |
71 | 71 | <div id="$published"></div> |
— | — | @@ -79,7 +79,7 @@ |
80 | 80 | }); |
81 | 81 | |
82 | 82 | jQuery('#storyreview-tabs').bind( 'tabsshow', function( event, ui ) { |
83 | | - stbShowReviewBoard( jQuery( ui.panel ) ); |
| 83 | + stbShowReviewBoard( jQuery( ui.panel ), ui.index ); |
84 | 84 | }); |
85 | 85 | </script> |
86 | 86 | EOT; |
Index: trunk/extensions/Storyboard/storyboard.js |
— | — | @@ -74,12 +74,14 @@ |
75 | 75 | * Story review functions |
76 | 76 | */ |
77 | 77 | |
78 | | -function stbShowReviewBoard( tab ) { |
| 78 | +function stbShowReviewBoard( tab, state ) { |
79 | 79 | tab.html( jQuery( "<div />" ) |
80 | 80 | .addClass( "storyreviewboard" ) |
81 | | - .attr( { "style": "height: 420px; width: 100%;" } ) ); |
| 81 | + .attr( { "style": "height: 420px; width: 100%;", "id": "storyreviewboard-" + state } ) ); |
82 | 82 | |
83 | | - jQuery( '.storyreviewboard' ).ajaxScroll( { |
| 83 | + window.reviewstate = state; |
| 84 | + |
| 85 | + jQuery( '#storyreviewboard-' + state ).ajaxScroll( { |
84 | 86 | updateBatch: stbUpdateReviewBoard, |
85 | 87 | maxOffset: 500, |
86 | 88 | batchSize: 2, |
— | — | @@ -97,7 +99,9 @@ |
98 | 100 | 'list': 'stories', |
99 | 101 | 'format': 'json', |
100 | 102 | 'stlimit': 8, |
101 | | - 'stlanguage': window.storyboardLanguage |
| 103 | + 'stlanguage': window.storyboardLanguage, |
| 104 | + 'streview': 1, |
| 105 | + 'ststate': window.reviewstate |
102 | 106 | }; |
103 | 107 | |
104 | 108 | jQuery.getJSON( wgScriptPath + '/api.php', |
— | — | @@ -135,12 +139,15 @@ |
136 | 140 | $storyBody.append( textAndImg ); |
137 | 141 | |
138 | 142 | $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." ) |
141 | 145 | ) |
142 | 146 | ); |
143 | 147 | |
144 | 148 | // TODO: add review controls |
| 149 | + $storyBody.append( |
| 150 | + jQuery( "<div />" ).append( jQuery( "<button />" ).text( "edit" ).attr( "onclick", "window.location='" + story.modifyurl + "'" ) ) |
| 151 | + ); |
145 | 152 | |
146 | 153 | $storyboard.append( $storyBody ); |
147 | 154 | } |
— | — | @@ -152,8 +159,6 @@ |
153 | 160 | * @param sender The UI element invocing the action, typically a button. |
154 | 161 | * @param storyid Id identifying the story. |
155 | 162 | * @param action The action that needs to be performed on the story. |
156 | | - * |
157 | | - * TODO: support multiple actions at once |
158 | 163 | */ |
159 | 164 | function stbDoStoryAction( sender, storyid, action ) { |
160 | 165 | sender.innerHTML = 'Working...'; // TODO: i18n |
Index: trunk/extensions/Storyboard/api/ApiQueryStories.php |
— | — | @@ -43,10 +43,13 @@ |
44 | 44 | * Retrieve the stories from the database. |
45 | 45 | */ |
46 | 46 | public function execute() { |
| 47 | + global $wgUser; |
| 48 | + |
47 | 49 | // Get the requests parameters. |
48 | 50 | $params = $this->extractRequestParams(); |
49 | 51 | |
50 | 52 | $this->addTables( 'storyboard' ); |
| 53 | + |
51 | 54 | $this->addFields( array( |
52 | 55 | 'story_id', |
53 | 56 | 'story_author_id', |
— | — | @@ -57,9 +60,27 @@ |
58 | 61 | 'story_created', |
59 | 62 | 'story_modified' |
60 | 63 | ) ); |
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 | + |
64 | 85 | $this->addOption( 'LIMIT', $params['limit'] + 1 ); |
65 | 86 | $this->addOption( 'ORDER BY', 'story_modified, story_id DESC' ); |
66 | 87 | |
— | — | @@ -95,7 +116,8 @@ |
96 | 117 | $this->setContinueEnumParameter( 'continue', wfTimestamp( TS_MW, $story->story_modified ) . '-' . $story->story_id ); |
97 | 118 | break; |
98 | 119 | } |
99 | | - $res = array( |
| 120 | + |
| 121 | + $result = array( |
100 | 122 | 'id' => $story->story_id, |
101 | 123 | 'author' => $story->story_author_name, |
102 | 124 | 'title' => $story->story_title, |
— | — | @@ -106,8 +128,15 @@ |
107 | 129 | 'imageurl' => $story->story_author_image, |
108 | 130 | 'permalink' => SpecialPage::getTitleFor( 'story', $story->story_title )->getFullURL() |
109 | 131 | ); |
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 ); |
112 | 141 | } |
113 | 142 | |
114 | 143 | // FIXME: continue parameter is not getting passed with the result |
— | — | @@ -130,7 +159,11 @@ |
131 | 160 | 'continue' => null, |
132 | 161 | 'language' => array( |
133 | 162 | 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 | + ) |
135 | 168 | ); |
136 | 169 | } |
137 | 170 | |
— | — | @@ -143,6 +176,8 @@ |
144 | 177 | 'continue' => 'Number of the first story to return', |
145 | 178 | 'limit' => 'Amount of stories to return', |
146 | 179 | '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' |
147 | 182 | ); |
148 | 183 | } |
149 | 184 | |
— | — | @@ -153,9 +188,19 @@ |
154 | 189 | public function getDescription() { |
155 | 190 | return 'This module returns stories for a storyboard'; |
156 | 191 | } |
157 | | - |
| 192 | + |
158 | 193 | /** |
159 | 194 | * (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) |
160 | 205 | * @see includes/api/ApiBase#getExamples() |
161 | 206 | */ |
162 | 207 | protected function getExamples() { |