r62976 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62975‎ | r62976 | r62977 >
Date:22:10, 25 February 2010
Author:jeroendedauw
Status:ok (Comments)
Tags:
Comment:
Modified paths:
  • /trunk/extensions/Storyboard/specials/StoryReview/StoryReview_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Storyboard/specials/StoryReview/StoryReview_body.php
@@ -58,59 +58,75 @@
5959 array( 'story_is_hidden' => 0 )
6060 );
6161
62 - // Arrays to hold the html segments for both the unreviewed and reviewed stories.
63 - $unreviewed = array();
64 - $reviewed = array();
 62+ // String to hold the html for both the unreviewed and reviewed stories.
 63+ $unreviewed = '';
 64+ $reviewed = '';
6565
66 - // Loop through all stories, get their html segments, and store in the appropriate array.
 66+ // Loop through all stories, get their html, and add it to the appropriate string.
6767 while ( $story = $dbr->fetchObject( $stories ) ) {
6868 if ( $story->story_is_published ) {
69 - $reviewed = array_merge( $reviewed, $this->getStorySegments( $story ) );
 69+ $reviewed .= $this->getStorySegments( $story, $story->story_is_published );
7070 }
7171 else {
72 - $unreviewed = array_merge( $unreviewed, $this->getStorySegments( $story ) );
 72+ $unreviewed .= $this->getStorySegments( $story, $story->story_is_published );
7373 }
7474 }
 75+
 76+ $unrevMsg = wfMsg( 'storyboard-unreviewed' );
 77+ $revMsg = wfMsg( 'storyboard-reviewed' );
7578
76 - // Create the page layout, and add the stories.
77 - $htmlSegments = array();
78 - $htmlSegments[] = '<h2>' . wfMsg( 'storyboard-unreviewed' ) . '</h2>';
79 - $htmlSegments[] = '<table width="100%">';
80 - $htmlSegments = array_merge( $htmlSegments, $unreviewed );
81 - $htmlSegments[] = '</table>';
82 - $htmlSegments[] = '<h2>' . wfMsg( 'storyboard-reviewed' ) . '</h2>';
83 - $htmlSegments[] = '<table width="100%">';
84 - $htmlSegments = array_merge( $htmlSegments, $reviewed );
85 - $htmlSegments[] = '</table>';
86 -
87 - // Join all the html segments and add the resulting string to the page.
88 - $wgOut->addHTML( implode( '', $htmlSegments ) );
 79+ // Output the html for the stories.
 80+ $wgOut->addHTML(<<<EOT
 81+ <h2>$unrevMsg</h2>
 82+ <table width="100%">
 83+ $unreviewed
 84+ </table>
 85+ <h2>$revMsg</h2>
 86+ <table width="100%">
 87+ $reviewed
 88+ </table>
 89+EOT
 90+ );
8991 }
9092
9193 /**
9294 * Returns the html segments for a single story.
9395 *
94 - * TODO: add \n's to get cleaner html output
 96+ * @param $story
9597 *
96 - * @param $story
97 - * @return array
 98+ * @return string
9899 */
99 - private function getStorySegments( $story ) {
100 - $segments = array();
101 - $segments[] = '<tr><td><table width="100%" border="1"><tr><td rowspan="2" width="200px">';
102 - $segments[] = '<img src="http://upload.wikimedia.org/wikipedia/mediawiki/9/99/SemanticMaps.png">'; // TODO: get cropped image here
103 - $segments[] = '</td><td><b>';
104 - $segments[] = htmlspecialchars( $story->story_title );
105 - $segments[] = '</b><br />';
106 - $segments[] = htmlspecialchars( $story->story_text );
107 - $segments[] = '</td></tr><tr><td align="center" height="35">';
108 - $segments[] = '<button type="button">'; // TODO: figure out how to best update db info (page submit with form or onclick with ajax call?)
109 - $segments[] = wfMsg( 'storyboard-publish' );
110 - $segments[] = '</button> &nbsp;&nbsp;&nbsp; <button type="button">';
111 - $segments[] = wfMsg( 'edit' );
112 - $segments[] = '</button> &nbsp;&nbsp;&nbsp; <button type="button">';
113 - $segments[] = wfMsg( 'hide' );
114 - $segments[] = '</button></td></tr></table></td></tr>';
115 - return $segments;
 100+ private function getStorySegments( $story, $published ) {
 101+ $imageSrc = 'http://upload.wikimedia.org/wikipedia/mediawiki/9/99/SemanticMaps.png'; // TODO: get cropped image here
 102+ $title = htmlspecialchars( $story->story_title );
 103+ $text = htmlspecialchars( $story->story_text );
 104+ $publish = $published ? wfMsg( 'storyboard-unpublish' ) : wfMsg( 'storyboard-publish' );
 105+ $edit = wfMsg( 'edit' );
 106+ $hide = wfMsg( 'hide' );
 107+
 108+ return <<<EOT
 109+ <tr>
 110+ <td>
 111+ <table width="100%" border="1">
 112+ <tr>
 113+ <td rowspan="2" width="200px">
 114+ <img src="$imageSrc">
 115+ </td>
 116+ <td>
 117+ <b>$title</b>
 118+ <br />$text
 119+ </td>
 120+ </tr>
 121+ <tr>
 122+ <td align="center" height="35">
 123+ <button type="button">$publish</button>&nbsp;&nbsp;&nbsp;
 124+ <button type="button">$edit</button>&nbsp;&nbsp;&nbsp;
 125+ <button type="button">$hide</button>
 126+ </td>
 127+ </tr>
 128+ </table>
 129+ </td>
 130+ </tr>
 131+EOT;
116132 }
117133 }
\ No newline at end of file

Comments

#Comment by Catrope (talk | contribs)   22:36, 25 February 2010
+		$imageSrc = '[http://upload.wikimedia.org/wikipedia/mediawiki/9/99/SemanticMaps.png'; http://upload.wikimedia.org/wikipedia/mediawiki/9/99/SemanticMaps.png';] // TODO: get cropped image here

Just put this image in the extension directory somewhere, as you do with JS and CSS files.

#Comment by Jeroen De Dauw (talk | contribs)   22:47, 25 February 2010

I need to make the user able to upload an image when submitting a story. This image will be displayed here. Since I have not done that work yet, this image is serving as a simple place holder, until I can get the image the user actually uploaded.

#Comment by Catrope (talk | contribs)   23:00, 25 February 2010

Gotcha, no worries then.

Status & tagging log