Index: trunk/extensions/Storyboard/specials/StoryReview/StoryReview_body.php |
— | — | @@ -58,59 +58,75 @@ |
59 | 59 | array( 'story_is_hidden' => 0 ) |
60 | 60 | ); |
61 | 61 | |
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 = ''; |
65 | 65 | |
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. |
67 | 67 | while ( $story = $dbr->fetchObject( $stories ) ) { |
68 | 68 | if ( $story->story_is_published ) { |
69 | | - $reviewed = array_merge( $reviewed, $this->getStorySegments( $story ) ); |
| 69 | + $reviewed .= $this->getStorySegments( $story, $story->story_is_published ); |
70 | 70 | } |
71 | 71 | else { |
72 | | - $unreviewed = array_merge( $unreviewed, $this->getStorySegments( $story ) ); |
| 72 | + $unreviewed .= $this->getStorySegments( $story, $story->story_is_published ); |
73 | 73 | } |
74 | 74 | } |
| 75 | + |
| 76 | + $unrevMsg = wfMsg( 'storyboard-unreviewed' ); |
| 77 | + $revMsg = wfMsg( 'storyboard-reviewed' ); |
75 | 78 | |
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 | + ); |
89 | 91 | } |
90 | 92 | |
91 | 93 | /** |
92 | 94 | * Returns the html segments for a single story. |
93 | 95 | * |
94 | | - * TODO: add \n's to get cleaner html output |
| 96 | + * @param $story |
95 | 97 | * |
96 | | - * @param $story |
97 | | - * @return array |
| 98 | + * @return string |
98 | 99 | */ |
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> <button type="button">'; |
111 | | - $segments[] = wfMsg( 'edit' ); |
112 | | - $segments[] = '</button> <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> |
| 124 | + <button type="button">$edit</button> |
| 125 | + <button type="button">$hide</button> |
| 126 | + </td> |
| 127 | + </tr> |
| 128 | + </table> |
| 129 | + </td> |
| 130 | + </tr> |
| 131 | +EOT; |
116 | 132 | } |
117 | 133 | } |
\ No newline at end of file |