r49215 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r49214‎ | r49215 | r49216 >
Date:16:05, 5 April 2009
Author:mkroetzsch
Status:deferred
Tags:
Comment:
Enable localized names for result formats to improve format selection in Special_Ask
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QP_Auto.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QP_CSV.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QP_Embedded.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QP_JSONlink.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QP_List.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QP_RSSlink.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QP_Table.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QP_Template.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QueryPrinter.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/languages/SMW_Messages.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialAsk.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialAsk.php
@@ -193,7 +193,7 @@
194194 $printer = SMWQueryProcessor::getResultPrinter($this->m_params['format'], SMWQueryProcessor::SPECIAL_PAGE);
195195 $result_mime = $printer->getMimeType($res);
196196 if ($result_mime == false) {
197 - if ($res->getCount() > 0) {
 197+ if ( $res->getCount() > 0 ) {
198198 $navigation = $this->getNavigationBar($res, $urltail);
199199 $result = '<div style="text-align: center;">' . $navigation;
200200 $result .= '</div>' . $printer->getResult($res, $this->m_params,SMW_OUTPUT_HTML);
@@ -264,21 +264,27 @@
265265 $result .= '<a href="' . htmlspecialchars($skin->makeSpecialUrl('Ask',$urltail . '&eq=yes&sc=1')) . '" rel="nofollow">' . wfMsg('smw_add_sortcondition') . '</a>'; // note that $urltail uses a , separated list for sorting, so setting sc to 1 always adds one new condition
266266 }
267267
268 - $result .= '<div>'.wfMsg('smw_ask_format_as').' <input type="hidden" name="eq" value="yes"/>' .
 268+ $printer = SMWQueryProcessor::getResultPrinter('broadtable',SMWQueryProcessor::SPECIAL_PAGE);
 269+ $result .= '<br /><br />' . wfMsg('smw_ask_format_as').' <input type="hidden" name="eq" value="yes"/>' .
269270 '<select name="p">' .
270 - '<option value="format=broadtable"'.($this->m_params['format'] == 'broadtable' ? ' selected' : '').'>broadtable ('.wfMsg('smw_ask_defaultformat').')</option>'."\n";
 271+ '<option value="format=broadtable"'.($this->m_params['format'] == 'broadtable' ? ' selected' : ''). '>' .
 272+ $printer->getName() . ' ('.wfMsg('smw_ask_defaultformat').')</option>'."\n";
271273
272 - foreach (array_keys($smwgResultFormats) as $format)
273 - {
274 - if ($format != 'broadtable')
275 - {
276 - $result .= '<option value="format='.$format.'"'.($this->m_params['format'] == $format ? ' selected' : '').'>'.$format."</option>\n";
 274+ $formats = array();
 275+ foreach (array_keys($smwgResultFormats) as $format) {
 276+ if ( ($format != 'broadtable') && ($format != 'count') && ($format != 'debug') ) { // special formats "count" and "debug" currently not supported
 277+ $printer = SMWQueryProcessor::getResultPrinter($format,SMWQueryProcessor::SPECIAL_PAGE);
 278+ $formats[$format] = $printer->getName();
277279 }
278280 }
 281+ natcasesort($formats);
 282+ foreach ($formats as $format => $name) {
 283+ $result .= '<option value="format='.$format.'"'.($this->m_params['format'] == $format ? ' selected' : '').'>'.$name."</option>\n";
 284+ }
279285
280 - $result .= '</select></div>';
 286+ $result .= '</select><br />';
281287
282 - $result .= '<input type="submit" value="' . wfMsg('smw_ask_submit') . '"/>' .
 288+ $result .= '<br /><input type="submit" value="' . wfMsg('smw_ask_submit') . '"/>' .
283289 '<input type="hidden" name="eq" value="yes"/>' .
284290 ' <a href="' . htmlspecialchars($skin->makeSpecialUrl('Ask',$urltail)) . '" rel="nofollow">' . wfMsg('smw_ask_hidequery') . '</a> ' .
285291 SMWAskPage::$pipeseparator .
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QP_Auto.php
@@ -30,4 +30,9 @@
3131 return ''; // acutally not needed in this implementation
3232 }
3333
 34+ public function getName() {
 35+ wfLoadExtensionMessages('SemanticMediaWiki');
 36+ return wfMsgForContent('smw_printername_auto');
 37+ }
 38+
3439 }
\ No newline at end of file
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryPrinter.php
@@ -305,6 +305,17 @@
306306 }
307307
308308 /**
 309+ * Get a human readable label for this printer. The default is to
 310+ * return just the format identifier. Concrete implementations may
 311+ * refer to messages here. The format name is normally not used in
 312+ * wiki text but only in forms etc. hence the user language should be
 313+ * used when retrieving messages.
 314+ */
 315+ public function getName() {
 316+ return $this->mFormat;
 317+ }
 318+
 319+ /**
309320 * Provides a simple formatted string of all the error messages that occurred.
310321 * Can be used if not specific error formatting is desired. Compatible with HTML
311322 * and Wiki.
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QP_List.php
@@ -36,6 +36,10 @@
3737 }
3838 }
3939
 40+ public function getName() {
 41+ wfLoadExtensionMessages('SemanticMediaWiki');
 42+ return wfMsgForContent('smw_printername_' . $this->mFormat);
 43+ }
4044
4145 protected function getResultText($res,$outputmode) {
4246 // Determine mark-up strings used around list items:
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QP_RSSlink.php
@@ -40,6 +40,11 @@
4141 return ($context==SMWQueryProcessor::SPECIAL_PAGE)?SMWQuery::MODE_INSTANCES:SMWQuery::MODE_NONE;
4242 }
4343
 44+ public function getName() {
 45+ wfLoadExtensionMessages('SemanticMediaWiki');
 46+ return wfMsgForContent('smw_printername_rss');
 47+ }
 48+
4449 protected function getResultText($res, $outputmode) {
4550 global $smwgIQRunningNumber, $wgSitename, $wgServer, $smwgRSSEnabled, $wgRequest;
4651 $result = '';
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QP_Table.php
@@ -13,6 +13,12 @@
1414 */
1515 class SMWTableResultPrinter extends SMWResultPrinter {
1616
 17+ public function getName() {
 18+ wfLoadExtensionMessages('SemanticMediaWiki');
 19+ return wfMsgForContent('smw_printername_' . $this->mFormat);
 20+ }
 21+
 22+
1723 protected function getResultText($res, $outputmode) {
1824 global $smwgIQRunningNumber;
1925 SMWOutputs::requireHeadItem(SMW_HEADER_SORTTABLE);
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QP_JSONlink.php
@@ -30,6 +30,11 @@
3131 return ($context==SMWQueryProcessor::SPECIAL_PAGE)?SMWQuery::MODE_INSTANCES:SMWQuery::MODE_NONE;
3232 }
3333
 34+ public function getName() {
 35+ wfLoadExtensionMessages('SemanticMediaWiki');
 36+ return wfMsgForContent('smw_printername_json');
 37+ }
 38+
3439 protected function getResultText($res, $outputmode) {
3540 global $smwgIQRunningNumber, $wgSitename, $wgServer, $wgScriptPath;
3641 $result = '';
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QP_Embedded.php
@@ -36,6 +36,11 @@
3737 }
3838 }
3939
 40+ public function getName() {
 41+ wfLoadExtensionMessages('SemanticMediaWiki');
 42+ return wfMsgForContent('smw_printername_embedded');
 43+ }
 44+
4045 protected function getResultText($res,$outputmode) {
4146 global $wgParser;
4247 // No page should embed itself, find out who we are:
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QP_CSV.php
@@ -35,6 +35,11 @@
3636 return ($context==SMWQueryProcessor::SPECIAL_PAGE)?SMWQuery::MODE_INSTANCES:SMWQuery::MODE_NONE;
3737 }
3838
 39+ public function getName() {
 40+ wfLoadExtensionMessages('SemanticMediaWiki');
 41+ return wfMsgForContent('smw_printername_csv');
 42+ }
 43+
3944 protected function getResultText($res, $outputmode) {
4045 $result = '';
4146 if ($outputmode == SMW_OUTPUT_FILE) { // make CSV file
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QP_Template.php
@@ -33,6 +33,11 @@
3434 }
3535 }
3636
 37+ public function getName() {
 38+ wfLoadExtensionMessages('SemanticMediaWiki');
 39+ return wfMsgForContent('smw_printername_template');
 40+ }
 41+
3742 protected function getResultText($res, $outputmode) {
3843 // print all result rows
3944 if ($this->m_template == false) {
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_Messages.php
@@ -39,6 +39,21 @@
4040 // Link to JSON feeds
4141 'smw_json_link' => 'JSON',
4242
 43+ // Names for result formats:
 44+ 'smw_printername_auto' => 'Automatic',
 45+ 'smw_printername_count' => 'Count results',
 46+ 'smw_printername_csv' => 'CSV export',
 47+ 'smw_printername_debug' => 'Debug query (for experts)',
 48+ 'smw_printername_embedded' => 'Embed page contents',
 49+ 'smw_printername_json' => 'JSON export',
 50+ 'smw_printername_list' => 'List',
 51+ 'smw_printername_ol' => 'Enumeration',
 52+ 'smw_printername_ul' => 'Itemization',
 53+ 'smw_printername_rss' => 'RSS export',
 54+ 'smw_printername_table' => 'Table',
 55+ 'smw_printername_broadtable' => 'Broad table',
 56+ 'smw_printername_template' => 'Template',
 57+
4358 // Messages and strings for inline queries
4459 'smw_iq_disabled' => "Semantic queries have been disabled for this wiki.",
4560 'smw_iq_moreresults' => '… further results',

Status & tagging log