Index: trunk/extensions/SemanticForms/includes/SF_FormLinker.php |
— | — | @@ -33,12 +33,22 @@ |
34 | 34 | die( "ERROR: <a href=\"http://semantic-mediawiki.org\">Semantic MediaWiki</a> must be installed for Semantic Forms to run!" ); |
35 | 35 | } |
36 | 36 | $store = smwfGetStore(); |
37 | | - $title_text = SFUtils::titleString( $title ); |
38 | | - $value = SMWDataValueFactory::newTypeIDValue( '_wpg', $title_text ); |
| 37 | + // SMW 1.6+ |
| 38 | + if ( class_exists( 'SMWDataItem' ) ) { |
| 39 | + $value = new SMWDIWikiPage( $title->getText(), $title->getNamespace(), null ); |
| 40 | + } else { |
| 41 | + $title_text = SFUtils::titleString( $title ); |
| 42 | + $value = SMWDataValueFactory::newTypeIDValue( '_wpg', $title_text ); |
| 43 | + } |
39 | 44 | $properties = $store->getInProperties( $value ); |
40 | 45 | $propertyNames = array(); |
41 | 46 | foreach( $properties as $property ) { |
42 | | - $property_name = $property->getWikiValue(); |
| 47 | + // SMW 1.6+ |
| 48 | + if ( $property instanceof SMWDIProperty ) { |
| 49 | + $property_name = $property->getKey(); |
| 50 | + } else { |
| 51 | + $property_name = $property->getWikiValue(); |
| 52 | + } |
43 | 53 | if ( !empty( $property_name ) ) { |
44 | 54 | $propertyNames[] = $property_name; |
45 | 55 | } |
— | — | @@ -123,13 +133,8 @@ |
124 | 134 | } |
125 | 135 | |
126 | 136 | $store = smwfGetStore(); |
127 | | - $title = Title::makeTitleSafe( $page_namespace, $page_name ); |
128 | | - $property = SMWPropertyValue::makeProperty( $prop_smw_id ); |
| 137 | + $res = SFUtils::getSMWPropertyValues( $store, $page_name, $page_namespace, $prop_smw_id ); |
129 | 138 | |
130 | | - $res = $store->getPropertyValues( $title, $property ); |
131 | | - // FIXME: should probably change into something like this for SMW 1.6: |
132 | | - //$res = $store->getPropertyValues( $title, new SMWDIProperty( $title->getDBkey() ) ); |
133 | | - |
134 | 139 | $form_names = array(); |
135 | 140 | foreach ( $res as $wiki_page_value ) { |
136 | 141 | $form_title = $wiki_page_value->getTitle(); |
— | — | @@ -139,8 +144,7 @@ |
140 | 145 | } |
141 | 146 | // if we're using a non-English language, check for the English string as well |
142 | 147 | if ( ! class_exists( 'SF_LanguageEn' ) || ! $sfgContLang instanceof SF_LanguageEn ) { |
143 | | - $backup_property = SMWPropertyValue::makeProperty( $backup_prop_smw_id ); |
144 | | - $res = $store->getPropertyValues( $title, $backup_property ); |
| 148 | + $res = SFUtils::getSMWPropertyValues( $store, $page_name, $page_namespace, $backup_prop_smw_id ); |
145 | 149 | foreach ( $res as $wiki_page_value ) |
146 | 150 | $form_names[] = $wiki_page_value->getTitle()->getText(); |
147 | 151 | } |
Index: trunk/extensions/SemanticForms/includes/SF_Utils.php |
— | — | @@ -72,6 +72,24 @@ |
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
| 76 | + * Helper function to handle getPropertyValues() in both SMW 1.6 |
| 77 | + * and earlier versions. |
| 78 | + */ |
| 79 | + public static function getSMWPropertyValues( $store, $pageName, $pageNamespace, $propID, $requestOptions = null ) { |
| 80 | + // SMWDIProperty was added in SMW 1.6 |
| 81 | + if ( class_exists( 'SMWDIProperty' ) ) { |
| 82 | + |
| 83 | + $page = new SMWDIWikiPage( $pageName, $pageNamespace, null ); |
| 84 | + $property = new SMWDIProperty( $propID ); |
| 85 | + return $store->getPropertyValues( $page, $property, $requestOptions ); |
| 86 | + } else { |
| 87 | + $title = Title::makeTitleSafe( $pageNamespace, $pageName ); |
| 88 | + $property = SMWPropertyValue::makeProperty( $propID ); |
| 89 | + return $store->getPropertyValues( $title, $property, $requestOptions ); |
| 90 | + } |
| 91 | + } |
| 92 | + |
| 93 | + /** |
76 | 94 | * Helper function - gets names of categories for a page; |
77 | 95 | * based on Title::getParentCategories(), but simpler |
78 | 96 | * - this function doubles as a function to get all categories on |
— | — | @@ -348,7 +366,8 @@ |
349 | 367 | $requestoptions = new SMWRequestOptions(); |
350 | 368 | $requestoptions->limit = $sfgMaxAutocompleteValues; |
351 | 369 | $property = SMWPropertyValue::makeProperty( $property_name ); |
352 | | - $data_values = $store->getPropertyValues( null, $property, $requestoptions ); |
| 370 | + //$data_values = $store->getPropertyValues( null, $property, $requestoptions ); |
| 371 | + $data_values = self::getSMWPropertyValues( $store, null, null, $property, $requestoptions ); |
353 | 372 | $values = array(); |
354 | 373 | foreach ( $data_values as $dv ) { |
355 | 374 | // getPropertyValues() gets many repeat values - we want |