Index: trunk/extensions/MoodBar/SpecialMoodBarFeedback.php |
— | — | @@ -0,0 +1,116 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class SpecialMoodBarFeedback extends SpecialPage { |
| 5 | + public function __construct() { |
| 6 | + parent::__construct( 'MoodBarFeedback' ); |
| 7 | + } |
| 8 | + |
| 9 | + public function getDescription() { |
| 10 | + return wfMessage( 'moodbar-feedback-title' )->plain(); |
| 11 | + } |
| 12 | + |
| 13 | + public function execute( $par ) { |
| 14 | + global $wgOut; |
| 15 | + |
| 16 | + $wgOut->setPageTitle( wfMsg( 'moodbar-feedback-title' ) ); |
| 17 | + $wgOut->addHTML( $this->buildForm() ); |
| 18 | + $res = $this->doQuery(); |
| 19 | + $wgOut->addHTML( $this->buildList( $res ) ); |
| 20 | + $wgOut->addModuleStyles( 'ext.moodBar.dashboard.styles' ); |
| 21 | + } |
| 22 | + |
| 23 | + public function buildForm() { |
| 24 | + $filtersMsg = wfMessage( 'moodbar-feedback-filters' )->escaped(); |
| 25 | + $typeMsg = wfMessage( 'moodbar-feedback-filters-type' )->escaped(); |
| 26 | + $praiseMsg = wfMessage( 'moodbar-feedback-filters-type-happy' )->escaped(); |
| 27 | + $confusionMsg = wfMessage( 'moodbar-feedback-filters-type-confused' )->escaped(); |
| 28 | + $issuesMsg = wfMessage( 'moodbar-feedback-filters-type-sad' )->escaped(); |
| 29 | + $usernameMsg = wfMessage( 'moodbar-feedback-filters-username' )->escaped(); |
| 30 | + $setFiltersMsg = wfMessage( 'moodbar-feedback-filters-button' )->escaped(); |
| 31 | + $whatIsMsg = wfMessage( 'moodbar-feedback-whatis' )->escaped(); |
| 32 | + |
| 33 | + return <<<HTML |
| 34 | + <div id="fbd-filters"> |
| 35 | + <form> |
| 36 | + <h3 id="fbd-filters-title">$filtersMsg</h3> |
| 37 | + <fieldset id="fbd-filters-types"> |
| 38 | + <legend class="fbd-filters-label">$typeMsg</legend> |
| 39 | + <ul> |
| 40 | + <li> |
| 41 | + <input type="checkbox" id="fbd-filters-type-praise"> |
| 42 | + <label for="fbd-filters-type-praise" id="fbd-filters-type-praise-label">$praiseMsg</label> |
| 43 | + </li> |
| 44 | + <li> |
| 45 | + <input type="checkbox" id="fbd-filters-type-confusion"> |
| 46 | + <label for="fbd-filters-type-confusion" id="fbd-filters-type-confusion-label">$confusionMsg</label> |
| 47 | + </li> |
| 48 | + <li> |
| 49 | + <input type="checkbox" id="fbd-filters-type-issues"> |
| 50 | + <label for="fbd-filters-type-issues" id="fbd-filters-type-issues-label">$issuesMsg</label> |
| 51 | + </li> |
| 52 | + </ul> |
| 53 | + </fieldset> |
| 54 | + <label for="fbd-filters-username" class="fbd-filters-label">$usernameMsg</label> |
| 55 | + <input type="text" id="fbd-filters-username" class="fbd-filters-input" /> |
| 56 | + <button type="submit" id="fbd-filters-set">$setFiltersMsg</button> |
| 57 | + </form> |
| 58 | + <a href="#" id="fbd-about">$whatIsMsg</a> |
| 59 | + </div> |
| 60 | +HTML; |
| 61 | + } |
| 62 | + |
| 63 | + public function buildList( $rows ) { |
| 64 | + global $wgLang; |
| 65 | + $now = wfTimestamp( TS_UNIX ); |
| 66 | + $html = '<ul id="fbd-list">'; |
| 67 | + foreach ( $rows as $row ) { |
| 68 | + $type = $row->mbf_type; |
| 69 | + $typeMsg = wfMessage( "moodbar-type-$type" )->escaped(); |
| 70 | + $time = $wgLang->formatTimePeriod( $now - wfTimestamp( TS_UNIX, $row->mbf_timestamp ), |
| 71 | + 'avoidminutes', 'noabbrevs' |
| 72 | + ); |
| 73 | + $timeMsg = wfMessage( 'ago' )->params( $time )->escaped(); |
| 74 | + $username = htmlspecialchars( $row->user_name === null ? $row->mbf_user_ip : $row->user_name ); |
| 75 | + $links = Linker::userToolLinks( $row->mbf_user_id, $username ); |
| 76 | + $comment = htmlspecialchars( $row->mbf_comment ); |
| 77 | + $permalinkURL = $this->getTitle( $row->mbf_id )->getLinkURL(); |
| 78 | + $permalinkText = wfMessage( 'moodbar-feedback-permalink' )->escaped(); |
| 79 | + |
| 80 | + $html .= <<<HTML |
| 81 | + <li class="fbd-item"> |
| 82 | + <div class="fbd-item-emoticon fbd-item-emoticon-$type"> |
| 83 | + <span class="fbd-item-emoticon-label">$typeMsg</span> |
| 84 | + </div> |
| 85 | + <div class="fbd-item-time">$timeMsg</div> |
| 86 | + <h3 class="fbd-item-userName"> |
| 87 | + <a href="#">$username</a> |
| 88 | + <sup class="fbd-item-userLinks"> |
| 89 | + $links |
| 90 | + </sup> |
| 91 | + </h3> |
| 92 | + <div class="fbd-item-message">$comment</div> |
| 93 | + <div class="fbd-item-permalink">(<a href="$permalinkURL">$permalinkText</a>)</div> |
| 94 | + <div style="clear:both"></div> |
| 95 | + </li> |
| 96 | +HTML; |
| 97 | + } |
| 98 | + |
| 99 | + $moreURL = '#'; //TODO |
| 100 | + $moreText = wfMessage( 'moodbar-feedback-more' )->escaped(); |
| 101 | + $html .= '</ul><div id="fbd-list-more"><a href="#">More</a></div>'; |
| 102 | + return $html; |
| 103 | + } |
| 104 | + |
| 105 | + public function doQuery() { |
| 106 | + $dbr = wfGetDB( DB_SLAVE ); |
| 107 | + return $dbr->select( array( 'moodbar_feedback', 'user' ), array( |
| 108 | + 'user_name', 'mbf_id', 'mbf_type', |
| 109 | + 'mbf_timestamp', 'mbf_user_id', 'mbf_user_ip', 'mbf_comment' |
| 110 | + ), array( |
| 111 | + '1=1', //TODO |
| 112 | + ), __METHOD__, |
| 113 | + array( 'LIMIT' => 20 /*TODO*/, 'ORDER BY' => 'mbf_timestamp DESC' ), |
| 114 | + array( 'user' => array( 'LEFT JOIN', 'user_id=mbf_user_id' ) ) |
| 115 | + ); |
| 116 | + } |
| 117 | +} |
Property changes on: trunk/extensions/MoodBar/SpecialMoodBarFeedback.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 118 | + native |
Index: trunk/extensions/MoodBar/MoodBar.i18n.php |
— | — | @@ -72,6 +72,17 @@ |
73 | 73 | 'moodbar-header-user-editcount' => 'User edit count', |
74 | 74 | 'moodbar-header-namespace' => 'Namespace', |
75 | 75 | 'moodbar-header-own-talk' => 'Own talk page', |
| 76 | + // Special:MoodBarFeedback |
| 77 | + 'moodbar-feedback-title' => 'Feedback dashboard', |
| 78 | + 'moodbar-feedback-filters' => 'Filters', |
| 79 | + 'moodbar-feedback-filters-type' => 'Type:', |
| 80 | + 'moodbar-feedback-filters-type-happy' => 'Praise', |
| 81 | + 'moodbar-feedback-filters-type-confused' => 'Confusion', |
| 82 | + 'moodbar-feedback-filters-type-sad' => 'Issues', |
| 83 | + 'moodbar-feedback-filters-username' => 'Username', |
| 84 | + 'moodbar-feedback-filters-button' => 'Set filters', |
| 85 | + 'moodbar-feedback-whatis' => 'What is this feature?', |
| 86 | + 'moodbar-feedback-permalink' => 'link to here', |
76 | 87 | // Mood types |
77 | 88 | 'moodbar-type-happy' => 'Happy', |
78 | 89 | 'moodbar-type-sad' => 'Sad', |
Index: trunk/extensions/MoodBar/MoodBar.php |
— | — | @@ -30,9 +30,11 @@ |
31 | 31 | $wgHooks['MakeGlobalVariablesScript'][] = 'MoodBarHooks::makeGlobalVariablesScript'; |
32 | 32 | $wgHooks['LoadExtensionSchemaUpdates'][] = 'MoodBarHooks::onLoadExtensionSchemaUpdates'; |
33 | 33 | |
34 | | -// Special page |
| 34 | +// Special pages |
35 | 35 | $wgAutoloadClasses['SpecialMoodBar'] = dirname(__FILE__).'/SpecialMoodBar.php'; |
36 | 36 | $wgSpecialPages['MoodBar'] = 'SpecialMoodBar'; |
| 37 | +$wgAutoloadClasses['SpecialMoodBarFeedback'] = dirname( __FILE__ ) . '/SpecialMoodBarFeedback.php'; |
| 38 | +$wgSpecialPages['MoodBarFeedback'] = 'SpecialMoodBarFeedback'; |
37 | 39 | |
38 | 40 | // User rights |
39 | 41 | $wgAvailableRights[] = 'moodbar-view'; |
— | — | @@ -113,6 +115,9 @@ |
114 | 116 | 'position' => 'bottom', |
115 | 117 | ); |
116 | 118 | |
| 119 | +$wgResourceModules['ext.moodBar.dashboard.styles'] = $mbResourceTemplate + array( |
| 120 | + 'styles' => 'ext.moodBar.dashboard/page.css', |
| 121 | +); |
117 | 122 | |
118 | 123 | $wgResourceModules['jquery.moodBar'] = $mbResourceTemplate + array( |
119 | 124 | 'scripts' => 'jquery.moodBar/jquery.moodBar.js', |