http://www.mediawiki.org/wiki/Special:Code/MediaWiki/65476
Revision: 65476 Author: jeroendedauw Date: 2010-04-23 19:28:35 +0000 (Fri, 23 Apr 2010) Log Message: ----------- Fixed the story state action buttons on SpecialStoryReview to work with story_state db field Modified Paths: -------------- trunk/extensions/Storyboard/jquery/jquery.ajaxscroll.js trunk/extensions/Storyboard/specials/StoryReview/StoryReview_body.php Modified: trunk/extensions/Storyboard/jquery/jquery.ajaxscroll.js =================================================================== --- trunk/extensions/Storyboard/jquery/jquery.ajaxscroll.js 2010-04-23 19:06:52 UTC (rev 65475) +++ trunk/extensions/Storyboard/jquery/jquery.ajaxscroll.js 2010-04-23 19:28:35 UTC (rev 65476) @@ -6,7 +6,6 @@ * @author Jeroen De Dauw * @license GPL * @version 0.2 - * */ (function($) { $.fn.ajaxScroll=function(opt){ Modified: trunk/extensions/Storyboard/specials/StoryReview/StoryReview_body.php =================================================================== --- trunk/extensions/Storyboard/specials/StoryReview/StoryReview_body.php 2010-04-23 19:06:52 UTC (rev 65475) +++ trunk/extensions/Storyboard/specials/StoryReview/StoryReview_body.php 2010-04-23 19:28:35 UTC (rev 65476) @@ -10,7 +10,6 @@ * * TODO: implement eternal load stuff for each list * TODO: fix layout - * TODO: fix story blocks to work with new story state handling * TODO: ajax load tab contents? */ @@ -97,14 +96,14 @@ array( 'story_state' => $storyState ) ); - $html = ''; + $storyBlocks = array(); // Loop through all stories, get their html, and add it to the appropriate string. while ( $story = $dbr->fetchObject( $stories ) ) { - $html .= $this->getStorySegments( $story, $storyState ); + $storyBlocks[] = $this->getStoryBlock( $story, $storyState ); } - return "<div id='storyreview-tabs-$storyState'>$html</div>"; + return "<div id='storyreview-tabs-$storyState'>" . implode( '<br />', $storyBlocks ) . '</div>'; } /** @@ -114,7 +113,7 @@ * * @return string */ - private function getStorySegments( $story, $storyState ) { + private function getStoryBlock( $story, $storyState ) { global $wgTitle; $editUrl = SpecialPage::getTitleFor( 'story', $story->story_title )->getFullURL( 'action=edit&returnto=' . $wgTitle->getPrefixedText() ); @@ -131,8 +130,25 @@ $hideMsg = htmlspecialchars( wfMsg( 'hide' ) ); $imageHtml = ''; - $imageButtonsHtml = ''; + $buttons = array(); + + if ( $storyState != Storyboard_STORY_PUBLISHED ) { + $buttons[] = $this->getStateActionButton( $story->story_id, 'publish', 'storyboard-publish' ); + } + + if ( $storyState != Storyboard_STORY_UNPUBLISHED ) { + $buttons[] = $this->getStateActionButton( $story->story_id, 'unpublish', 'storyboard-unpublish' ); + } + + if ( $storyState != Storyboard_STORY_HIDDEN ) { + $buttons[] = $this->getStateActionButton( $story->story_id, 'hide', 'storyboard-hide' ); + } + + $buttons[] = <<<EOT + <button type="button" onclick="window.location='$editUrl'">$editMsg</button> +EOT; + if ( $story->story_author_image ) { $imageAction = $story->story_image_hidden ? 'unhideimage' : 'hideimage'; // Uses storyboard-unhideimage or storyboard-hideimage. @@ -154,13 +170,18 @@ $imageHtml = Html::element( 'img', $imgAttribs ); - $imageButtonsHtml = <<<EOT - <button type="button" - onclick="stbDoStoryAction( this, $story->story_id, '$imageAction' )" id="image_button_$story->story_id">$imageMsg</button> - <button type="button" onclick="stbDeleteStoryImage( this, $story->story_id )">$deleteImageMsg</button> + $buttons[] = <<<EOT + <button type="button" onclick="stbDoStoryAction( this, $story->story_id, '$imageAction' )" + id="image_button_$story->story_id">$imageMsg</button> EOT; + $buttons[] = <<<EOT + <button type="button" onclick="stbDeleteStoryImage( this, $story->story_id )">$deleteImageMsg</button> +EOT; + } + $buttonHtml = implode( ' ', $buttons ); + return <<<EOT <table width="100%" border="1" id="story_$story->story_id"> <tr> @@ -174,12 +195,17 @@ </tr> <tr> <td align="center" height="35"> - <button type="button" onclick="stbDoStoryAction( this, $story->story_id, '$publishAction' )">$publishMsg</button> - <button type="button" onclick="window.location='$editUrl'">$editMsg</button> - <button type="button" onclick="stbDoStoryAction( this, $story->story_id, 'hide' )">$hideMsg</button>$imageButtonsHtml + $buttonHtml </td> </tr> </table> EOT; } + + private function getStateActionButton( $storyId, $action, $messageKey ) { + $message = htmlspecialchars( wfMsg( $messageKey ) ); + return <<<EOT + <button type="button" onclick="stbDoStoryAction( this, $storyId, '$action' )">$message</button> +EOT; + } } \ No newline at end of file _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs