Index: trunk/extensions/Storyboard/specials/StoryReview/StoryReview_body.php |
— | — | @@ -23,8 +23,10 @@ |
24 | 24 | public function execute( $language ) { |
25 | 25 | global $wgUser; |
26 | 26 | if ( $wgUser->isAllowed( 'storyreview' ) && !$wgUser->isBlocked() ) { |
| 27 | + // If the user has the storyreview permission and is not blocked, show the regular output. |
27 | 28 | $this->addOutput(); |
28 | 29 | } else { |
| 30 | + // If the user is not authorized, show an error. |
29 | 31 | global $wgOut; |
30 | 32 | $wgOut->permissionRequired( 'storyreview' ); |
31 | 33 | } |
— | — | @@ -32,6 +34,80 @@ |
33 | 35 | |
34 | 36 | private function addOutput() { |
35 | 37 | global $wgOut; |
| 38 | + |
| 39 | + $wgOut->setPageTitle(wfMsg('storyboard-storyreview')); |
| 40 | + |
36 | 41 | $wgOut->includeJQuery(); |
| 42 | + |
| 43 | + // Get a slave db object to do read operations against. |
| 44 | + $dbr = wfGetDB( DB_SLAVE ); |
| 45 | + |
| 46 | + // Create a query to retrieve information about all non hidden stories. |
| 47 | + $stories = $dbr->select( |
| 48 | + Storyboard_TABLE, |
| 49 | + array( |
| 50 | + 'story_id', |
| 51 | + 'story_author_name', |
| 52 | + 'story_title', |
| 53 | + 'story_text', |
| 54 | + 'story_is_published' |
| 55 | + ), |
| 56 | + 'story_is_hidden = 0' |
| 57 | + ); |
| 58 | + |
| 59 | + // Arrays to hold the html segments for both the unreviewed and reviewed stories. |
| 60 | + $unreviewed = array(); |
| 61 | + $reviewed = array(); |
| 62 | + |
| 63 | + // Loop through all stories, get their html segments, and store in the appropriate array. |
| 64 | + while ($story = $dbr->fetchObject($stories)) { |
| 65 | + if ($story->story_is_published) { |
| 66 | + $reviewed = array_merge($reviewed, $this->getStorySegments($story)); |
| 67 | + } |
| 68 | + else { |
| 69 | + $unreviewed = array_merge($unreviewed, $this->getStorySegments($story)); |
| 70 | + } |
| 71 | + } |
| 72 | + |
| 73 | + // Create the page layout, and add the stories. |
| 74 | + $htmlSegments = array(); |
| 75 | + $htmlSegments[] = '<h2>' . wfMsg('storyboard-unreviewed') . '</h2>'; |
| 76 | + $htmlSegments[] = '<table width="100%">'; |
| 77 | + $htmlSegments = array_merge($htmlSegments, $unreviewed); |
| 78 | + $htmlSegments[] = '</table>'; |
| 79 | + $htmlSegments[] = '<h2>' . wfMsg('storyboard-reviewed') . '</h2>'; |
| 80 | + $htmlSegments[] = '<table width="100%">'; |
| 81 | + $htmlSegments = array_merge($htmlSegments, $reviewed); |
| 82 | + $htmlSegments[] = '</table>'; |
| 83 | + |
| 84 | + // Join all the html segments and add the resulting string to the page. |
| 85 | + $wgOut->addHTML(implode('', $htmlSegments)); |
37 | 86 | } |
38 | | -} |
| 87 | + |
| 88 | + /** |
| 89 | + * Returns the html segments for a single story. |
| 90 | + * |
| 91 | + * TODO: add \n's to get cleaner html output |
| 92 | + * |
| 93 | + * @param $story |
| 94 | + * @return array |
| 95 | + */ |
| 96 | + private function getStorySegments($story) { |
| 97 | + $segments = array(); |
| 98 | + $segments[] = '<tr><td><table width="100%" border="1"><tr><td rowspan="2" width="200px">'; |
| 99 | + $segments[] = '<img src="http://upload.wikimedia.org/wikipedia/mediawiki/9/99/SemanticMaps.png">'; // TODO: get cropped image here |
| 100 | + $segments[] = '</td><td><b>'; |
| 101 | + $segments[] = $story->story_title; |
| 102 | + $segments[] = '</b><br />'; |
| 103 | + $segments[] = $story->story_text; |
| 104 | + $segments[] = '</td></tr><tr><td align="center" height="35">'; |
| 105 | + $segments[] = '<button type="button">'; // TODO: figure out how to best update db info (page submit with form or onclick with ajax call?) |
| 106 | + $segments[] = wfMsg('storyboard-publish'); |
| 107 | + $segments[] = '</button> <button type="button">'; |
| 108 | + $segments[] = wfMsg('edit'); |
| 109 | + $segments[] = '</button> <button type="button">'; |
| 110 | + $segments[] = wfMsg('hide'); |
| 111 | + $segments[] = '</button></td></tr></table></td></tr>'; |
| 112 | + return $segments; |
| 113 | + } |
| 114 | +} |
\ No newline at end of file |
Index: trunk/extensions/Storyboard/Storyboard.sql |
— | — | @@ -3,10 +3,12 @@ |
4 | 4 | CREATE TABLE /*$wgDBprefix*/storyboard ( |
5 | 5 | story_id INT(8) unsigned NOT NULL auto_increment PRIMARY KEY, |
6 | 6 | story_author_id INT unsigned NULL, |
7 | | - story_author_name VARCHAR(255) NULL, |
| 7 | + story_author_name VARCHAR(255) NULL, |
8 | 8 | story_hit_count INT(8) unsigned NOT NULL, |
9 | 9 | story_title VARCHAR(255) NOT NULL, |
10 | 10 | story_text MEDIUMBLOB NULL, |
11 | 11 | story_modified CHAR(14) binary NOT NULL default '', |
12 | | - story_created CHAR(14) binary NOT NULL default '' |
13 | | -) /*$wgDBTableOptions*/; |
| 12 | + story_created CHAR(14) binary NOT NULL default '', |
| 13 | + story_is_published TINYINT NOT NULL default '0', |
| 14 | + story_is_hidden TINYINT NOT NULL default '0' |
| 15 | +) /*$wgDBTableOptions*/; |
\ No newline at end of file |
Index: trunk/extensions/Storyboard/Storyboard.i18n.php |
— | — | @@ -21,6 +21,7 @@ |
22 | 22 | 'right-storyreview' => 'Review, edit, publish, and hide stories', |
23 | 23 | |
24 | 24 | // Story review |
| 25 | + 'storyboard-storyreview' => 'Story review', |
25 | 26 | 'storyboard-publish' => 'Publish', |
26 | 27 | 'storyboard-reviewed' => 'Reviewed', |
27 | 28 | 'storyboard-unreviewed' => 'Unreviewed', |
Index: trunk/extensions/Storyboard/Storyboard.php |
— | — | @@ -23,6 +23,8 @@ |
24 | 24 | |
25 | 25 | define( 'Storyboard_VERSION', '0' ); |
26 | 26 | |
| 27 | +define( 'Storyboard_TABLE', 'storyboard' ); |
| 28 | + |
27 | 29 | // TODO: try to get out the hardcoded path. |
28 | 30 | $egStoryboardScriptPath = $wgScriptPath . '/extensions/Storyboard'; |
29 | 31 | $egStoryboardDir = dirname( __FILE__ ) . '/'; |
— | — | @@ -81,7 +83,7 @@ |
82 | 84 | 'path' => __FILE__, |
83 | 85 | 'name' => wfMsg( 'storyboard-name' ), |
84 | 86 | 'version' => Storyboard_VERSION, |
85 | | - 'author' => array( '[http://bn2vs.com Jeroen De Dauw]' ), |
| 87 | + 'author' => array( '[http://www.mediawiki.org/wiki/User:Jeroen_De_Dauw Jeroen De Dauw]' ), |
86 | 88 | 'url' => 'http://www.mediawiki.org/wiki/Extension:Storyboard', |
87 | 89 | 'description' => wfMsg( 'storyboard-desc' ), |
88 | 90 | 'descriptionmsg' => 'storyboard-desc', |
Index: trunk/extensions/Storyboard/tags/Storyboard/Storyboard_body.php |
— | — | @@ -26,7 +26,6 @@ |
27 | 27 | <script type="$wgJsMimeType">var storyboardPath = '$egStoryboardScriptPath';</script> |
28 | 28 | <div id="storyboard"></div> |
29 | 29 | <script type="$wgJsMimeType"> /*<![CDATA[*/ |
30 | | - jQuery(document).ready(function(){ jQuery("p").click(function(){ jQuery(this).hide(); }); }); |
31 | 30 | var storyboard = new Storyboard(); |
32 | 31 | storyboard.loadAjax(); |
33 | 32 | /*]]>*/ </script> |