Index: trunk/extensions/SemanticDrilldown/includes/SD_Filter.php |
— | — | @@ -31,7 +31,11 @@ |
32 | 32 | $proptitle = Title::newFromText( $f->property, SMW_NS_PROPERTY ); |
33 | 33 | if ( $proptitle != null ) { |
34 | 34 | $store = smwfGetStore(); |
35 | | - if ( class_exists( 'SMWPropertyValue' ) ) { |
| 35 | + if ( class_exists( 'SMWDIProperty' ) ) { |
| 36 | + // SMW 1.6 |
| 37 | + $propPage = new SMWDIWikiPage( $f->escaped_property, SMW_NS_PROPERTY, null ); |
| 38 | + $types = $store->getPropertyValues( $propPage, new SMWDIProperty( '_TYPE' ) ); |
| 39 | + } elseif ( class_exists( 'SMWPropertyValue' ) ) { |
36 | 40 | $types = $store->getPropertyValues( $proptitle, SMWPropertyValue::makeUserProperty( 'Has type' ) ); |
37 | 41 | } else { |
38 | 42 | $types = $store->getSpecialValues( $proptitle, SMW_SP_HAS_TYPE ); |
— | — | @@ -39,13 +43,19 @@ |
40 | 44 | global $smwgContLang; |
41 | 45 | $datatypeLabels = $smwgContLang->getDatatypeLabels(); |
42 | 46 | if ( count( $types ) > 0 ) { |
43 | | - if ( $types[0]->getWikiValue() != $datatypeLabels['_wpg'] ) { |
| 47 | + if ( $types[0] instanceof SMWDIWikiPage ) { |
| 48 | + // SMW 1.6 |
| 49 | + $typeValue = $types[0]->getDBkey(); |
| 50 | + } else { |
| 51 | + $typeValue = $types[0]->getWikiValue(); |
| 52 | + } |
| 53 | + if ( $typeValue != $datatypeLabels['_wpg'] ) { |
44 | 54 | $f->is_relation = false; |
45 | 55 | } |
46 | | - if ( $types[0]->getWikiValue() == $datatypeLabels['_boo'] ) { |
| 56 | + if ( $typeValue == $datatypeLabels['_boo'] ) { |
47 | 57 | $f->is_boolean = true; |
48 | 58 | } |
49 | | - if ( $types[0]->getWikiValue() == $datatypeLabels['_dat'] ) { |
| 59 | + if ( $typeValue == $datatypeLabels['_dat'] ) { |
50 | 60 | $f->is_date = true; |
51 | 61 | } |
52 | 62 | } |
Index: trunk/extensions/SemanticDrilldown/includes/SD_GlobalFunctions.php |
— | — | @@ -72,8 +72,8 @@ |
73 | 73 | $sdgNamespaceIndex = 170; |
74 | 74 | } |
75 | 75 | |
76 | | - define( 'SD_NS_FILTER', $sdgNamespaceIndex ); |
77 | | - define( 'SD_NS_FILTER_TALK', $sdgNamespaceIndex + 1 ); |
| 76 | + define( 'SD_NS_FILTER', $sdgNamespaceIndex ); |
| 77 | + define( 'SD_NS_FILTER_TALK', $sdgNamespaceIndex + 1 ); |
78 | 78 | |
79 | 79 | sdfInitContentLanguage( $wgLanguageCode ); |
80 | 80 | |
— | — | @@ -139,11 +139,11 @@ |
140 | 140 | include_once( $sdgIP . '/languages/' . $sdLangClass . '.php' ); |
141 | 141 | } |
142 | 142 | |
143 | | - // fallback if language not supported |
144 | | - if ( !class_exists( $sdLangClass ) ) { |
145 | | - include_once( $sdgIP . '/languages/SD_LanguageEn.php' ); |
146 | | - $sdLangClass = 'SD_LanguageEn'; |
147 | | - } |
| 143 | + // fallback if language not supported |
| 144 | + if ( !class_exists( $sdLangClass ) ) { |
| 145 | + include_once( $sdgIP . '/languages/SD_LanguageEn.php' ); |
| 146 | + $sdLangClass = 'SD_LanguageEn'; |
| 147 | + } |
148 | 148 | |
149 | 149 | $sdgLang = new $sdLangClass(); |
150 | 150 | } |
— | — | @@ -166,30 +166,38 @@ |
167 | 167 | $sd_prop_labels = $sdgContLang->getPropertyLabels(); |
168 | 168 | foreach ( $sd_prop_labels as $prop_id => $prop_alias ) { |
169 | 169 | $prop_vals = $sd_property_vals[$prop_id]; |
170 | | - SMWPropertyValue::registerProperty( $prop_vals[0], $prop_vals[1], $prop_alias, true ); |
| 170 | + if ( class_exists( 'SMWDIProperty' ) ) { |
| 171 | + SMWDIProperty::registerProperty( $prop_vals[0], $prop_vals[1], $prop_alias, true ); |
| 172 | + } else { |
| 173 | + SMWPropertyValue::registerProperty( $prop_vals[0], $prop_vals[1], $prop_alias, true ); |
| 174 | + } |
171 | 175 | } |
172 | 176 | // if it's not English, add the English-language aliases as well |
173 | 177 | if ( $wgLanguageCode != 'en' ) { |
174 | 178 | $sd_prop_aliases = $sdgContLang->getPropertyAliases(); |
175 | 179 | foreach ( $sd_prop_aliases as $prop_alias => $prop_id ) { |
176 | 180 | $prop_vals = $sd_property_vals[$prop_id]; |
177 | | - SMWPropertyValue::registerPropertyAlias( $prop_vals[0], $prop_alias ); |
| 181 | + if ( class_exists( 'SMWDIProperty' ) ) { |
| 182 | + SMWDIProperty::registerPropertyAlias( $prop_vals[0], $prop_alias ); |
| 183 | + } else { |
| 184 | + SMWPropertyValue::registerPropertyAlias( $prop_vals[0], $prop_alias ); |
| 185 | + } |
178 | 186 | } |
179 | 187 | } |
180 | | - return true; |
| 188 | + return true; |
181 | 189 | } |
182 | 190 | |
183 | 191 | function sdfAddToAdminLinks( &$admin_links_tree ) { |
184 | | - $browse_search_section = $admin_links_tree->getSection( wfMsg( 'adminlinks_browsesearch' ) ); |
185 | | - $sd_row = new ALRow( 'sd' ); |
186 | | - $sd_row->addItem( ALItem::newFromSpecialPage( 'BrowseData' ) ); |
187 | | - $sd_row->addItem( ALItem::newFromSpecialPage( 'Filters' ) ); |
188 | | - $sd_row->addItem( ALItem::newFromSpecialPage( 'CreateFilter' ) ); |
189 | | - $sd_name = wfMsg( 'specialpages-group-sd_group' ); |
190 | | - $sd_docu_label = wfMsg( 'adminlinks_documentation', $sd_name ); |
191 | | - $sd_row->addItem( AlItem::newFromExternalLink( "http://www.mediawiki.org/wiki/Extension:Semantic_Drilldown", $sd_docu_label ) ); |
| 192 | + $browse_search_section = $admin_links_tree->getSection( wfMsg( 'adminlinks_browsesearch' ) ); |
| 193 | + $sd_row = new ALRow( 'sd' ); |
| 194 | + $sd_row->addItem( ALItem::newFromSpecialPage( 'BrowseData' ) ); |
| 195 | + $sd_row->addItem( ALItem::newFromSpecialPage( 'Filters' ) ); |
| 196 | + $sd_row->addItem( ALItem::newFromSpecialPage( 'CreateFilter' ) ); |
| 197 | + $sd_name = wfMsg( 'specialpages-group-sd_group' ); |
| 198 | + $sd_docu_label = wfMsg( 'adminlinks_documentation', $sd_name ); |
| 199 | + $sd_row->addItem( AlItem::newFromExternalLink( "http://www.mediawiki.org/wiki/Extension:Semantic_Drilldown", $sd_docu_label ) ); |
192 | 200 | |
193 | | - $browse_search_section->addRow( $sd_row ); |
| 201 | + $browse_search_section->addRow( $sd_row ); |
194 | 202 | |
195 | | - return true; |
| 203 | + return true; |
196 | 204 | } |
Index: trunk/extensions/SemanticDrilldown/includes/SD_Utils.php |
— | — | @@ -16,6 +16,7 @@ |
17 | 17 | public static function getSMWPropertyValues( $store, $pageName, $pageNamespace, $propID, $requestOptions = null ) { |
18 | 18 | // SMWDIProperty was added in SMW 1.6 |
19 | 19 | if ( class_exists( 'SMWDIProperty' ) ) { |
| 20 | + $pageName = str_replace( ' ', '_', $pageName ); |
20 | 21 | $page = new SMWDIWikiPage( $pageName, $pageNamespace, null ); |
21 | 22 | $property = new SMWDIProperty( $propID ); |
22 | 23 | return $store->getPropertyValues( $page, $property, $requestOptions ); |
— | — | @@ -127,8 +128,6 @@ |
128 | 129 | /** |
129 | 130 | * Generic static function - gets all the values that a specific page |
130 | 131 | * points to with a specific property |
131 | | - * ($special_prop and $prop represent the same value, depending on |
132 | | - * whether we're using SMW 1.4 or an earlier version) |
133 | 132 | */ |
134 | 133 | static function getValuesForProperty( $subject, $subject_namespace, $special_prop ) { |
135 | 134 | $store = smwfGetStore(); |
— | — | @@ -136,7 +135,11 @@ |
137 | 136 | $values = array(); |
138 | 137 | foreach ( $res as $prop_val ) { |
139 | 138 | // depends on version of SMW |
140 | | - if ( method_exists( $prop_val, 'getValueKey' ) ) { |
| 139 | + if ( $prop_val instanceof SMWDIWikiPage ) { |
| 140 | + $actual_val = $prop_val->getDBkey(); |
| 141 | + } elseif ( $prop_val instanceof SMWDIString ) { |
| 142 | + $actual_val = $prop_val->getString(); |
| 143 | + } elseif ( method_exists( $prop_val, 'getValueKey' ) ) { |
141 | 144 | $actual_val = $prop_val->getValueKey(); |
142 | 145 | } else { |
143 | 146 | $actual_val = $prop_val->getXSDValue(); |