r69662 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69661‎ | r69662 | r69663 >
Date:10:00, 21 July 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Removed default format support I added earlier on. A single hook that allows extensions to override the default format should suffice.
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/SMW_Settings.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QP_Auto.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QP_Auto.php
@@ -29,46 +29,17 @@
3030 * @return string
3131 */
3232 public function getResult( /* SMWQueryResult */ $results, $params, $outputmode ) {
33 - global $smwgUseResultDefaults, $smwgResultDefaults, $smwgAddedResultDefaults;
34 -
35 - if ( !$smwgAddedResultDefaults ) {
36 - $smwgAddedResultDefaults = true;
37 -
38 - /**
39 - * This hook allows extensions to specify default result formats for
40 - * datavalues. For example, Semantic Maps can specify the result format
41 - * for geographical coordinates is the map one.
42 - *
43 - * @since 1.5.2
44 - */
45 - wfRunHooks( 'SMWResultDefaults', array( &$smwgResultDefaults ) );
46 - }
47 -
4833 $format = false;
4934
5035 /**
5136 * This hook allows extensions to override SMWs implementation of default result
52 - * format handling. Extensions might choose do so even when $smwgUseResultDefaults is false.
 37+ * format handling.
5338 *
5439 * @since 1.5.2
5540 */
5641 wfRunHooks( 'SMWResultFormat', array( &$format, $results->getPrintRequests(), $params ) );
5742
58 - // If $smwgUseResultDefaults is true, and there are no multiple columns, see if there is a default format.
59 - if ( $smwgUseResultDefaults && $format === false && $results->getColumnCount() <= 2 ) {
60 - $printReqs = $results->getPrintRequests();
61 - $typeId = array_shift( $printReqs )->getTypeID();
62 -
63 - if ( $typeId == '_wpg' ) {
64 - $typeId = array_shift( $printReqs )->getTypeID();
65 - }
66 -
67 - if ( $typeId !== false && array_key_exists( $typeId, $smwgResultDefaults ) ) {
68 - $format = $smwgResultDefaults[$typeId];
69 - }
70 - }
71 -
72 - // If no default was found, use a table or list, depending on the column count.
 43+ // If no default was set by an extension, use a table or list, depending on the column count.
7344 if ( $format === false ) {
7445 $format = $results->getColumnCount() > 1 ? 'table' : 'list';
7546 }
Index: trunk/extensions/SemanticMediaWiki/SMW_Settings.php
@@ -299,18 +299,6 @@
300300 $smwgResultAliases = array();
301301 ##
302302
303 -### Predefined default result formats
304 -# Array of default result formats, optionlly defined per datatype. Can be redefined in
305 -# the settings to remove or add certain defaults.
306 -##
307 -$smwgResultDefaults = array();
308 -##
309 -
310 -### Indicates if result format defaulting should be applied by SMW core.
311 -##
312 -$smwgUseResultDefaults = false;
313 -##
314 -
315303 ### Predefined sources for queries
316304 # Array of available sources for answering queries. Can be redefined in
317305 # the settings to register new sources (usually an extension will do so

Follow-up revisions

RevisionCommit summaryAuthorDate
r69678Follow up to r69662 - re-implemented default format support for coordinate re...jeroendedauw13:24, 21 July 2010

Status & tagging log