r89280 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89279‎ | r89280 | r89281 >
Date:19:07, 1 June 2011
Author:yaron
Status:deferred
Tags:
Comment:
Changed getSMWPropertyValues() to take in a Title object instead of a page name and namespace; other fixes for SMW 1.6
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormLinker.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_TemplateField.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_Utils.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormLinker.php
@@ -133,12 +133,13 @@
134134 }
135135
136136 $store = smwfGetStore();
137 - $form_names = SFUtils::getSMWPropertyValues( $store, $page_name, $page_namespace, $prop_smw_id );
 137+ $subject = Title::makeTitleSafe( $page_namespace, $page_name );
 138+ $form_names = SFUtils::getSMWPropertyValues( $store, $subject, $prop_smw_id );
138139
139140 // If we're using a non-English language, check for the English
140141 // string as well.
141142 if ( ! class_exists( 'SF_LanguageEn' ) || ! $sfgContLang instanceof SF_LanguageEn ) {
142 - $backup_form_names = SFUtils::getSMWPropertyValues( $store, $page_name, $page_namespace, $backup_prop_smw_id );
 143+ $backup_form_names = SFUtils::getSMWPropertyValues( $store, $subject, $backup_prop_smw_id );
143144 $form_names = array_merge( $form_names, $backup_form_names );
144145 }
145146 // Add this data to the "cache".
Index: trunk/extensions/SemanticForms/includes/SF_TemplateField.php
@@ -60,11 +60,11 @@
6161
6262 $store = smwfGetStore();
6363 // this returns an array of objects
64 - $allowed_values = SFUtils::getSMWPropertyValues( $store, $this->semantic_property, SMW_NS_PROPERTY, "Allows value" );
65 - $label_formats = SFUtils::getSMWPropertyValues( $store, $this->semantic_property, SMW_NS_PROPERTY, "Has field label format" );
 64+ $allowed_values = SFUtils::getSMWPropertyValues( $store, $proptitle, "Allows value" );
 65+ $label_formats = SFUtils::getSMWPropertyValues( $store, $proptitle, "Has field label format" );
6666 // SMW 1.6+
6767 if ( class_exists( 'SMWDIProperty' ) ) {
68 - $propValue = new SMWDIProperty( $this->semantic_property );
 68+ $propValue = SMWDIProperty::newFromUserLabel( $this->semantic_property );
6969 $this->property_type = $propValue->findPropertyTypeID();
7070 } else {
7171 $propValue = SMWPropertyValue::makeUserProperty( $this->semantic_property );
Index: trunk/extensions/SemanticForms/includes/SF_Utils.php
@@ -75,14 +75,13 @@
7676 * Helper function to handle getPropertyValues() in both SMW 1.6
7777 * and earlier versions.
7878 */
79 - public static function getSMWPropertyValues( $store, $pageName, $pageNamespace, $propID, $requestOptions = null ) {
 79+ public static function getSMWPropertyValues( $store, $subject, $propID, $requestOptions = null ) {
8080 // SMWDIProperty was added in SMW 1.6
8181 if ( class_exists( 'SMWDIProperty' ) ) {
82 - if ( is_null( $pageName ) ) {
 82+ if ( is_null( $subject ) ) {
8383 $page = null;
8484 } else {
85 - $pageName = str_replace( ' ', '_', $pageName );
86 - $page = new SMWDIWikiPage( $pageName, $pageNamespace, null );
 85+ $page = SMWDIWikiPage::newFromTitle( $subject );
8786 }
8887 $property = SMWDIProperty::newFromUserLabel( $propID );
8988 $res = $store->getPropertyValues( $page, $property, $requestOptions );
@@ -99,9 +98,8 @@
10099 }
101100 return $values;
102101 } else {
103 - $title = Title::makeTitleSafe( $pageNamespace, $pageName );
104102 $property = SMWPropertyValue::makeProperty( $propID );
105 - $res = $store->getPropertyValues( $title, $property, $requestOptions );
 103+ $res = $store->getPropertyValues( $subject, $property, $requestOptions );
106104 $values = array();
107105 foreach ( $res as $value ) {
108106 if ( method_exists( $value, 'getTitle' ) ) {
@@ -433,7 +431,7 @@
434432 $store = smwfGetStore();
435433 $requestoptions = new SMWRequestOptions();
436434 $requestoptions->limit = $sfgMaxAutocompleteValues;
437 - $values = self::getSMWPropertyValues( $store, null, null, $property_name, $requestoptions );
 435+ $values = self::getSMWPropertyValues( $store, null, $property_name, $requestoptions );
438436 sort( $values );
439437 return $values;
440438 }
@@ -531,6 +529,10 @@
532530 return array();
533531 }
534532
 533+ if ( class_exists( 'SMWDIWikiPage' ) ) {
 534+ // SMW 1.6
 535+ $concept = SMWDIWikiPage::newFromTitle( $concept );
 536+ }
535537 $desc = new SMWConceptDescription( $concept );
536538 $printout = new SMWPrintRequest( SMWPrintRequest::PRINT_THIS, "" );
537539 $desc->addPrintRequest( $printout );