r99350 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99349‎ | r99350 | r99351 >
Date:12:59, 9 October 2011
Author:werdna
Status:resolved (Comments)
Tags:todo 
Comment:
MoodBar: Implement hiding and restoring of entries on the feedback dashboard. No AJAX for now, but everything is abstracted enough to implement it easily
Modified paths:
  • /trunk/extensions/MoodBar/FeedbackItem.php (modified) (history)
  • /trunk/extensions/MoodBar/MoodBar.i18n.php (modified) (history)
  • /trunk/extensions/MoodBar/MoodBar.php (modified) (history)
  • /trunk/extensions/MoodBar/SpecialFeedbackDashboard.php (modified) (history)
  • /trunk/extensions/MoodBar/modules/ext.moodBar.dashboard/ext.moodBar.dashboard.css (modified) (history)

Diff [purge]

Index: trunk/extensions/MoodBar/SpecialFeedbackDashboard.php
@@ -4,6 +4,7 @@
55 */
66 class SpecialFeedbackDashboard extends SpecialPage {
77 protected $showHidden = false;
 8+ protected $action = false;
89
910 public function __construct() {
1011 parent::__construct( 'FeedbackDashboard' );
@@ -27,6 +28,12 @@
2829 if ( $wgRequest->getCheck( 'show-feedback' ) ) {
2930 $this->showHidden = true;
3031 }
 32+
 33+ if ( $wgRequest->getCheck( 'restore-feedback' ) ) {
 34+ $this->action = 'restore';
 35+ } elseif ( $wgRequest->getCheck( 'hide-feedback' ) ) {
 36+ $this->action = 'hide';
 37+ }
3138 } else {
3239 // Determine filters and offset from the query string
3340 $filters = array();
@@ -254,7 +261,7 @@
255262 $linkText = wfMessage('moodbar-feedback-show')->escaped();
256263 $query = array('show-feedback' => '1');
257264 $link = $GLOBALS['wgUser']->getSkin()
258 - ->link( $permalinkTitle, $linkText, array(), $query );
 265+ ->link( $permalinkTitle, $linkText );
259266 return Xml::tags( 'div', array( 'class' => 'fbd-item-show' ), "($link)" );
260267 }
261268 }
@@ -304,6 +311,26 @@
305312 $newerRow = $res['newerRow'];
306313 $html = "<ul id=\"fbd-list\">$list</ul>";
307314
 315+ // Only set for showing an individual row.
 316+ $form = null;
 317+ if ( $this->action == 'restore' ) {
 318+ $form = new MBRestoreForm( $row->mbf_id );
 319+ } elseif ( $this->action == 'hide' ) {
 320+ $form = new MBHideForm( $row->mbf_id );
 321+ }
 322+
 323+ if ( $form ) {
 324+ $result = $form->show();
 325+ if ( $result === true ) {
 326+ global $wgOut;
 327+ $title = SpecialPage::getTitleFor( 'FeedbackDashboard',
 328+ $row->mbf_id );
 329+ $wgOut->redirect( $title->getFullURL() );
 330+ } else {
 331+ $html .= "\n$result\n";
 332+ }
 333+ }
 334+
308335 // Output the "More" link
309336 $moreText = wfMessage( 'moodbar-feedback-more' )->escaped();
310337 $attribs = array( 'id' => 'fbd-list-more' );
Index: trunk/extensions/MoodBar/MoodBar.i18n.php
@@ -96,6 +96,12 @@
9797 'moodbar-feedback-hide' => 'hide feedback',
9898 'moodbar-hidden-footer' => 'Hidden Feedback $1',
9999 'moodbar-feedback-restore' => 'restore hidden feedback',
 100+ 'moodbar-action-item' => 'Feedback item:',
 101+ 'moodbar-hide-header' => 'Hide this item from view',
 102+ 'moodbar-hide-intro' => '',
 103+ 'moodbar-restore-header' => "Restore this item's visibility",
 104+ 'moodbar-restore-intro' => '',
 105+ 'moodbar-invalid-item' => 'The system was unable to find the correct feedback item.',
100106 // Mood types
101107 'moodbar-type-happy' => 'Happy',
102108 'moodbar-type-sad' => 'Sad',
@@ -104,6 +110,13 @@
105111 'moodbar-user-anonymized' => 'Anonymized',
106112 'moodbar-user-ip' => 'IP Address',
107113 'moodbar-user-user' => 'Registered user',
 114+ // Log types
 115+ 'moodbar-log-name' => 'Feedback log',
 116+ 'moodbar-log-header' => 'This is the log of actions taken on feedback items listed
 117+on the [[Special:FeedbackDashboard|feedback dashboard]].',
 118+
 119+ 'moodbar-log-hide' => 'hid [[$1]]',
 120+ 'moodbar-log-restore' => 'restored the visibility for [[$1]]',
108121 );
109122
110123 /** Message documentation (Message documentation)
Index: trunk/extensions/MoodBar/modules/ext.moodBar.dashboard/ext.moodBar.dashboard.css
@@ -84,6 +84,7 @@
8585 #fbd-list {
8686 margin: 0 0 0 13em;
8787 padding: 0;
 88+ min-height: 20em;
8889 list-style: none;
8990 }
9091
Index: trunk/extensions/MoodBar/FeedbackItem.php
@@ -205,11 +205,6 @@
206206 * @return The MBFeedbackItem's new ID.
207207 */
208208 public function save() {
209 -
210 - if ( $this->getProperty('id') ) {
211 - throw new MWException( "This ".__CLASS__." is already in the database." );
212 - }
213 -
214209 // Add edit count if necessary
215210 if ( $this->getProperty('user-editcount') === null &&
216211 $this->getProperty('user') )
@@ -254,14 +249,14 @@
255250 }
256251
257252 if ( $this->getProperty('id') ) {
 253+ $row['mbf_id'] = $this->getProperty('id');
258254 $dbw->replace( 'moodbar_feedback', array('mbf_id'), $row, __METHOD__ );
259255 } else {
260256 $row['mbf_id'] = $dbw->nextSequenceValue( 'moodbar_feedback_mbf_id' );
261257 $dbw->insert( 'moodbar_feedback', $row, __METHOD__ );
 258+ $this->setProperty( 'id', $dbw->insertId() );
262259 }
263260
264 - $this->setProperty( 'id', $dbw->insertId() );
265 -
266261 return $this->getProperty('id');
267262 }
268263
Index: trunk/extensions/MoodBar/MoodBar.php
@@ -36,6 +36,20 @@
3737 $wgAutoloadClasses['SpecialFeedbackDashboard'] = dirname( __FILE__ ) . '/SpecialFeedbackDashboard.php';
3838 $wgSpecialPages['FeedbackDashboard'] = 'SpecialFeedbackDashboard';
3939
 40+$dashboardFormsPath = dirname(__FILE__) . '/DashboardForms.php';
 41+$wgAutoloadClasses['MBDashboardForm'] = $dashboardFormsPath;
 42+$wgAutoloadClasses['MBActionForm'] = $dashboardFormsPath;
 43+$wgAutoloadClasses['MBHideForm'] = $dashboardFormsPath;
 44+$wgAutoloadClasses['MBRestoreForm'] = $dashboardFormsPath;
 45+
 46+$wgLogTypes[] = 'moodbar';
 47+$wgLogNames['moodbar'] = 'moodbar-log-name';
 48+$wgLogHeaders['moodbar'] = 'moodbar-log-header';
 49+$wgLogActions += array(
 50+ 'moodbar/hide' => 'moodbar-log-hide',
 51+ 'moodbar/restore' => 'moodbar-log-restore',
 52+);
 53+
4054 // User rights
4155 $wgAvailableRights[] = 'moodbar-view';
4256 $wgAvailableRights[] = 'moodbar-admin';

Follow-up revisions

RevisionCommit summaryAuthorDate
r99362* Remove stray newline (r99350)...raymond18:33, 9 October 2011
r99363Ignore empty messages from r99350raymond18:34, 9 October 2011
r99390Fix stupid c&p error by myself in r99363, ping r99350raymond06:01, 10 October 2011
r100025Adjustments to r99351 r99350 r99200 per code review:...werdna13:10, 17 October 2011

Comments

#Comment by Siebrand (talk | contribs)   14:58, 9 October 2011

Please add message documentation for the newly added messages. Thanks.

#Comment by Catrope (talk | contribs)   19:07, 15 October 2011
-					->link( $permalinkTitle, $linkText, array(), $query );
+					->link( $permalinkTitle, $linkText );

So $query is unused now?

#Comment by Werdna (talk | contribs)   13:10, 17 October 2011

Fixed in r100025.

Status & tagging log