r86824 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86823‎ | r86824 | r86825 >
Date:17:33, 24 April 2011
Author:yaron
Status:deferred
Tags:
Comment:
Added new function, getSMWPropertyValues - wrapper around old and new versions of SMW's getPropertyValues()
Modified paths:
  • /trunk/extensions/SemanticDrilldown/includes/SD_Utils.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticDrilldown/includes/SD_Utils.php
@@ -10,6 +10,23 @@
1111 class SDUtils {
1212
1313 /**
 14+ * Helper function to handle getPropertyValues() in both SMW 1.6
 15+ * and earlier versions.
 16+ */
 17+ public static function getSMWPropertyValues( $store, $pageName, $pageNamespace, $propID, $requestOptions = null ) {
 18+ // SMWDIProperty was added in SMW 1.6
 19+ if ( class_exists( 'SMWDIProperty' ) ) {
 20+ $page = new SMWDIWikiPage( $pageName, $pageNamespace, null );
 21+ $property = new SMWDIProperty( $propID );
 22+ return $store->getPropertyValues( $page, $property, $requestOptions );
 23+ } else {
 24+ $title = Title::makeTitleSafe( $pageNamespace, $pageName );
 25+ $property = SMWPropertyValue::makeProperty( $propID );
 26+ return $store->getPropertyValues( $title, $property, $requestOptions );
 27+ }
 28+ }
 29+
 30+ /**
1431 * Gets a list of the names of all categories in the wiki that aren't
1532 * children of some other category - this list additionally includes,
1633 * and excludes, categories that are manually set with
@@ -115,9 +132,7 @@
116133 */
117134 static function getValuesForProperty( $subject, $subject_namespace, $special_prop ) {
118135 $store = smwfGetStore();
119 - $subject_title = Title::newFromText( $subject, $subject_namespace );
120 - $property = SMWPropertyValue::makeProperty( $special_prop );
121 - $res = $store->getPropertyValues( $subject_title, $property );
 136+ $res = self::getSMWPropertyValues( $store, $subject, $subject_namespace, $special_prop );
122137 $values = array();
123138 foreach ( $res as $prop_val ) {
124139 // depends on version of SMW

Status & tagging log