r64363 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r64362‎ | r64363 | r64364 >
Date:21:39, 29 March 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
* Attempt to add edit action to Special:Story
* A bunch of small bug fixes and changes from the passed week
Modified paths:
  • /trunk/extensions/Storyboard/Storyboard.i18n.php (modified) (history)
  • /trunk/extensions/Storyboard/Storyboard.php (modified) (history)
  • /trunk/extensions/Storyboard/Storyboard_Utils.php (modified) (history)
  • /trunk/extensions/Storyboard/specials/Story/Story_body.php (modified) (history)
  • /trunk/extensions/Storyboard/specials/StoryReview/StoryReview_body.php (modified) (history)
  • /trunk/extensions/Storyboard/storyboard.css (modified) (history)
  • /trunk/extensions/Storyboard/tags/Storyboard/jquery.ajaxscroll.js (modified) (history)
  • /trunk/extensions/Storyboard/tags/Storyboard/storyboard.js (modified) (history)
  • /trunk/extensions/Storyboard/tags/Storysubmission/Storysubmission_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Storyboard/storyboard.css
@@ -11,15 +11,15 @@
1212 * Css for stories
1313 */
1414 .story {
15 - margin-left: 15px;
16 - margin-top: 5px;
 15+ margin: 5px 10px 0px 0px;
1716 float: left;
1817 overflow: hidden;
1918 }
2019 .story-title {
2120 font: 16px "Lucida Sans", Verdana;
 21+ margin-left: 15px;
 22+ margin-top: 5px;
2223 font-weight: bold;
23 - float: left;
2424 overflow: hidden;
2525 }
2626 .story-image {
Index: trunk/extensions/Storyboard/Storyboard.i18n.php
@@ -17,10 +17,12 @@
1818 // General
1919 'storyboard-name' => 'Storyboard',
2020 'storyboard-desc' => 'Provides a landing page for donors, a page where stories can be submitted, and a story moderation interface',
21 -
2221 'right-storyreview' => 'Review, edit, publish, and hide stories',
 22+ 'specialpages-group-contribution' => 'Contribution',
2323
2424 // Special:Story
 25+ 'story' => 'Story',
 26+ 'storyboard-viewstories' => 'View stories',
2527 'storyboard-nosuchstory' => 'The story you requested does not exist. It might have been removed.',
2628 'storyboard-unpublished' => 'The story you requested has not been published yet.',
2729 'storyboard-nostorytitle' => 'You need to specify the title or id of the story you want to view.',
@@ -28,7 +30,7 @@
2931 'storyboard-canedit' => 'You can [$1 edit] and publish this story.',
3032
3133 // Story review
32 - 'storyboard-storyreview' => 'Story review',
 34+ 'storyreview' => 'Story review',
3335 'storyboard-publish' => 'Publish',
3436 'storyboard-unpublish' => 'Unpublish',
3537 'storyboard-reviewed' => 'Reviewed',
@@ -49,7 +51,8 @@
5052 'storyboard-charsleft' => '($1 {{PLURAL:$1|character|characters}} left)',
5153 'storyboard-cannotbelonger' => 'Your story is <b>$1</b> {{PLURAL:$1|character|characters}} to long!',
5254 'storyboard-charsneeded' => '($1 more {{PLURAL:$1|character|characters}} needed)',
53 - 'storyboard-needtoagree' => 'You need to agree to the publication of your story to submit it.'
 55+ 'storyboard-needtoagree' => 'You need to agree to the publication of your story to submit it.',
 56+ 'storyboard-createdsucessfully' => 'Your story titled "$1" has been submitted sucesfully. It will be publicly accessible once it has been reviewed. View my story now.',
5457 );
5558
5659 /** Afrikaans (Afrikaans)
Index: trunk/extensions/Storyboard/tags/Storyboard/storyboard.js
@@ -9,8 +9,8 @@
1010 $( document ).ready( function() {
1111 $( '.storyboard' ).ajaxScroll( {
1212 updateBatch: updateStoryboard,
13 - batchSize: 3,
14 - batchNum: 2
 13+ batchSize: 4,
 14+ batchNum: 1
1515 } );
1616 } );
1717
@@ -20,11 +20,11 @@
2121 'action': 'query',
2222 'list': 'stories',
2323 'stcontinue': $storyboard.attr( 'offset' ),
24 - 'stlimit': 5,
 24+ 'stlimit': 4,
2525 'format': 'json'
2626 },
2727 function( data ) {
28 - var $div = $( "<div />" );
 28+ var html = '';
2929 for ( var i in data.query.stories ) {
3030 var story = data.query.stories[i];
3131 var $storyBody = $( "<div />" ).addClass( "storyboard-box" );
@@ -82,9 +82,9 @@
8383
8484 // TODO: add delete button that hides the story from the storyboard (=unpublish+hide?)
8585
86 - $div.append( $storyBody );
 86+ html += $storyBody;
8787 }
88 - $storyboard.html( $div );
 88+ $storyboard.html( html );
8989 }
9090 );
9191 }
Index: trunk/extensions/Storyboard/tags/Storyboard/jquery.ajaxscroll.js
@@ -111,7 +111,7 @@
112112 };
113113
114114 function vEnd(){
115 - if(ele.scrollTop>0&&ele.scrollHeight-ele.scrollTop<opt.eBound){
 115+ if(ele.scrollTop > 0 && ele.scrollHeight-ele.scrollTop < opt.eBound){
116116 offset=batch($sp,offset,opt);
117117 return 1;
118118 }
@@ -125,7 +125,7 @@
126126 };
127127
128128 function monEnd(){
129 - if(offset<opt.maxOffset){
 129+ if(offset < opt.maxOffset){
130130 setTimeout(monEnd,fnEnd());
131131 }
132132 }
Index: trunk/extensions/Storyboard/tags/Storysubmission/Storysubmission_body.php
@@ -152,16 +152,17 @@
153153 private static function doSubmissionAndGetResult() {
154154 global $wgRequest, $wgUser;
155155
 156+ $dbr = wfGetDB( DB_SLAVE );
156157 $dbw = wfGetDB( DB_MASTER );
 158+
 159+ $title = $wgRequest->getText( 'storytitle' );
157160
158 - // TODO: some sort of validation?
159 -
160161 $story = array(
161162 'story_author_name' => $wgRequest->getText( 'name' ),
162163 'story_author_location' => $wgRequest->getText( 'location' ),
163164 'story_author_occupation' => $wgRequest->getText( 'occupation' ),
164165 'story_author_contact' => $wgRequest->getText( 'contact' ),
165 - 'story_title' => $wgRequest->getText( 'storytitle' ),
 166+ 'story_title' => $title,
166167 'story_text' => $wgRequest->getText( 'storytext' ),
167168 'story_created' => $dbw->timestamp( time() ),
168169 'story_modified' => $dbw->timestamp( time() ),
@@ -174,7 +175,7 @@
175176
176177 $dbw->insert( 'storyboard', $story );
177178
178 - $responseHtml = ''; // TODO: create html response
 179+ $responseHtml = wfMsgExt( 'storyboard-createdsucessfully', htmlspecialchars( $title ) ); // TODO: create html response
179180
180181 return $responseHtml;
181182 }
Index: trunk/extensions/Storyboard/Storyboard_Utils.php
@@ -18,13 +18,16 @@
1919
2020 /**
2121 * Get the width or height from an arguments array, or use the default value if not specified or not valid
22 - * @param $arr Array of arguments
23 - * @param $name Key in $array
24 - * @param $default Default value to use if $arr[$name] is not set or not valid
 22+ *
 23+ * @param array $arr Array of arguments
 24+ * @param string $name Key in $array
 25+ * @param single $default Default value to use if $arr[$name] is not set or not valid
 26+ *
 27+ * @return string
2528 */
26 - public static function getDimension( $arr, $name, $default ) {
 29+ public static function getDimension( array $arr, $name, $default ) {
2730 $value = $default;
28 - if ( isset( $arr[$name] ) && preg_match( '/\d+(\.\d+)?%?/', $arr[$name] ) ) {
 31+ if ( isset( $arr[$name] ) && preg_match( '/^\d+(\.\d+)?(px|ex|em|%)?$/', $arr[$name] ) ) {
2932 $value = $arr[$name];
3033 }
3134 if ( !preg_match( '/(px|ex|em|%)$/', $value ) ) {
Index: trunk/extensions/Storyboard/specials/Story/Story_body.php
@@ -21,11 +21,9 @@
2222
2323 public function execute( $title ) {
2424 wfProfileIn( __METHOD__ );
25 -
2625 global $wgOut, $wgRequest, $wgUser;
2726
2827 $title = str_replace( '_', ' ', $title );
29 - $wgOut->setPageTitle( $title );
3028
3129 if ( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
3230 if ( $wgUser->isAllowed( 'storyreview' ) ) {
@@ -36,8 +34,10 @@
3735 }
3836
3937 if ( trim( $title ) != '' || $wgRequest->getIntOrNull( 'id' ) ) {
 38+ $wgOut->setPageTitle( $title );
4039 $this->queryAndShowStory( $title );
4140 } else {
 41+ $wgOut->setPageTitle( wfMsg( 'storyboard-viewstories' ) );
4242 $wgOut->addWikiMsg( 'storyboard-nostorytitle' );
4343 }
4444
@@ -98,9 +98,13 @@
9999 $wgOut->addWikiMsg( 'storyboard-unpublished' );
100100
101101 if ( $wgUser->isAllowed( 'storyreview' ) ) {
102 - $wgOut->addWikiMsg( // TODO: find out how to make the link working
103 - 'storyboard-canedit',
104 - $this->getTitle()->getLocalURL( 'action=edit' )
 102+ global $wgParser;
 103+
 104+ $wgOut->addWikiMsg(
 105+ $wgParser->recursiveTagParse(
 106+ 'storyboard-canedit',
 107+ $this->getTitle()->getLocalURL( 'action=edit' )
 108+ )
105109 );
106110 }
107111 }
@@ -129,11 +133,8 @@
130134 $text = htmlspecialchars( $story->story_text );
131135
132136 $wgOut->addHTML( <<<EOT
133 - <div class="story">
134 - <img src="$imageSrc" class="story-image">
135 - <div class="story-title">$title</div><br />
136 - $text
137 - </div>
 137+ <img src="$imageSrc" class="story-image">
 138+ $text
138139 EOT
139140 );
140141 }
Index: trunk/extensions/Storyboard/specials/StoryReview/StoryReview_body.php
@@ -24,7 +24,7 @@
2525
2626 global $wgUser, $wgOut;
2727
28 - $wgOut->setPageTitle( wfMsg( 'storyboard-storyreview' ) );
 28+ $wgOut->setPageTitle( wfMsg( 'storyreview' ) );
2929
3030 if ( $this->userCanExecute( $wgUser ) ) {
3131 // If the user has the storyreview permission and is not blocked, show the regular output.
Index: trunk/extensions/Storyboard/Storyboard.php
@@ -59,7 +59,9 @@
6060 // Hooks
6161 $wgHooks['ParserFirstCallInit'][] = 'efStoryboardParserFirstCallInit';
6262 $wgHooks['LoadExtensionSchemaUpdates'][] = 'efStoryboardSchemaUpdate';
 63+$wgHooks['SkinTemplateContentActions'][] = 'efStoryboardAddStoryEditAction';
6364
 65+
6466 /**
6567 * The 'storyboard' permission key can be given out to users
6668 * to enable them to review, edit, publish, and hide stories.
@@ -94,3 +96,20 @@
9597 $parser->setHook( 'storysubmission', array( 'TagStorysubmission', 'render' ) );
9698 return true;
9799 }
 100+
 101+function efStoryboardAddStoryEditAction( &$content_actions ) {
 102+ global $wgRequest, $wgRequest, $wgTitle;
 103+
 104+ $action = $wgRequest->getText( 'action' );
 105+
 106+ if ( $wgTitle->equals( SpecialPage::getTitleFor( 'story' ) ) ) {
 107+ $content_actions['edit'] = array(
 108+ 'class' => $action == 'edit' ? 'selected' : false,
 109+ 'text' => wfMsg( 'edit' ),
 110+ 'href' => $wgTitle->getLocalUrl( 'action=edit' )
 111+ );
 112+ }
 113+
 114+ return true;
 115+}
 116+

Status & tagging log