r65476 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65475‎ | r65476 | r65477 >
Date:19:28, 23 April 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Fixed the story state action buttons on SpecialStoryReview to work with story_state db field
Modified paths:
  • /trunk/extensions/Storyboard/jquery/jquery.ajaxscroll.js (modified) (history)
  • /trunk/extensions/Storyboard/specials/StoryReview/StoryReview_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Storyboard/jquery/jquery.ajaxscroll.js
@@ -6,7 +6,6 @@
77 * @author Jeroen De Dauw
88 * @license GPL
99 * @version 0.2
10 - *
1110 */
1211 (function($) {
1312 $.fn.ajaxScroll=function(opt){
Index: trunk/extensions/Storyboard/specials/StoryReview/StoryReview_body.php
@@ -10,7 +10,6 @@
1111 *
1212 * TODO: implement eternal load stuff for each list
1313 * TODO: fix layout
14 - * TODO: fix story blocks to work with new story state handling
1514 * TODO: ajax load tab contents?
1615 */
1716
@@ -97,14 +96,14 @@
9897 array( 'story_state' => $storyState )
9998 );
10099
101 - $html = '';
 100+ $storyBlocks = array();
102101
103102 // Loop through all stories, get their html, and add it to the appropriate string.
104103 while ( $story = $dbr->fetchObject( $stories ) ) {
105 - $html .= $this->getStorySegments( $story, $storyState );
 104+ $storyBlocks[] = $this->getStoryBlock( $story, $storyState );
106105 }
107106
108 - return "<div id='storyreview-tabs-$storyState'>$html</div>";
 107+ return "<div id='storyreview-tabs-$storyState'>" . implode( '<br />', $storyBlocks ) . '</div>';
109108 }
110109
111110 /**
@@ -114,7 +113,7 @@
115114 *
116115 * @return string
117116 */
118 - private function getStorySegments( $story, $storyState ) {
 117+ private function getStoryBlock( $story, $storyState ) {
119118 global $wgTitle;
120119
121120 $editUrl = SpecialPage::getTitleFor( 'story', $story->story_title )->getFullURL( 'action=edit&returnto=' . $wgTitle->getPrefixedText() );
@@ -131,8 +130,25 @@
132131 $hideMsg = htmlspecialchars( wfMsg( 'hide' ) );
133132
134133 $imageHtml = '';
135 - $imageButtonsHtml = '';
136134
 135+ $buttons = array();
 136+
 137+ if ( $storyState != Storyboard_STORY_PUBLISHED ) {
 138+ $buttons[] = $this->getStateActionButton( $story->story_id, 'publish', 'storyboard-publish' );
 139+ }
 140+
 141+ if ( $storyState != Storyboard_STORY_UNPUBLISHED ) {
 142+ $buttons[] = $this->getStateActionButton( $story->story_id, 'unpublish', 'storyboard-unpublish' );
 143+ }
 144+
 145+ if ( $storyState != Storyboard_STORY_HIDDEN ) {
 146+ $buttons[] = $this->getStateActionButton( $story->story_id, 'hide', 'storyboard-hide' );
 147+ }
 148+
 149+ $buttons[] = <<<EOT
 150+ <button type="button" onclick="window.location='$editUrl'">$editMsg</button>
 151+EOT;
 152+
137153 if ( $story->story_author_image ) {
138154 $imageAction = $story->story_image_hidden ? 'unhideimage' : 'hideimage';
139155 // Uses storyboard-unhideimage or storyboard-hideimage.
@@ -154,13 +170,18 @@
155171
156172 $imageHtml = Html::element( 'img', $imgAttribs );
157173
158 - $imageButtonsHtml = <<<EOT
159 - &nbsp;&nbsp;&nbsp;<button type="button"
160 - onclick="stbDoStoryAction( this, $story->story_id, '$imageAction' )" id="image_button_$story->story_id">$imageMsg</button>
161 - &nbsp;&nbsp;&nbsp;<button type="button" onclick="stbDeleteStoryImage( this, $story->story_id )">$deleteImageMsg</button>
 174+ $buttons[] = <<<EOT
 175+ <button type="button" onclick="stbDoStoryAction( this, $story->story_id, '$imageAction' )"
 176+ id="image_button_$story->story_id">$imageMsg</button>
162177 EOT;
 178+ $buttons[] = <<<EOT
 179+ <button type="button" onclick="stbDeleteStoryImage( this, $story->story_id )">$deleteImageMsg</button>
 180+EOT;
 181+
163182 }
164183
 184+ $buttonHtml = implode( '&nbsp;&nbsp;&nbsp;', $buttons );
 185+
165186 return <<<EOT
166187 <table width="100%" border="1" id="story_$story->story_id">
167188 <tr>
@@ -174,12 +195,17 @@
175196 </tr>
176197 <tr>
177198 <td align="center" height="35">
178 - <button type="button" onclick="stbDoStoryAction( this, $story->story_id, '$publishAction' )">$publishMsg</button>&nbsp;&nbsp;&nbsp;
179 - <button type="button" onclick="window.location='$editUrl'">$editMsg</button>&nbsp;&nbsp;&nbsp;
180 - <button type="button" onclick="stbDoStoryAction( this, $story->story_id, 'hide' )">$hideMsg</button>$imageButtonsHtml
 199+ $buttonHtml
181200 </td>
182201 </tr>
183202 </table>
184203 EOT;
185204 }
 205+
 206+ private function getStateActionButton( $storyId, $action, $messageKey ) {
 207+ $message = htmlspecialchars( wfMsg( $messageKey ) );
 208+ return <<<EOT
 209+ <button type="button" onclick="stbDoStoryAction( this, $storyId, '$action' )">$message</button>
 210+EOT;
 211+ }
186212 }
\ No newline at end of file

Status & tagging log