http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89280
Revision: 89280
Author: yaron
Date: 2011-06-01 19:07:37 +0000 (Wed, 01 Jun 2011)
Log Message:
-----------
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
trunk/extensions/SemanticForms/includes/SF_TemplateField.php
trunk/extensions/SemanticForms/includes/SF_Utils.php
Modified: trunk/extensions/SemanticForms/includes/SF_FormLinker.php
===================================================================
--- trunk/extensions/SemanticForms/includes/SF_FormLinker.php 2011-06-01
19:04:42 UTC (rev 89279)
+++ trunk/extensions/SemanticForms/includes/SF_FormLinker.php 2011-06-01
19:07:37 UTC (rev 89280)
@@ -133,12 +133,13 @@
}
$store = smwfGetStore();
- $form_names = SFUtils::getSMWPropertyValues( $store,
$page_name, $page_namespace, $prop_smw_id );
+ $subject = Title::makeTitleSafe( $page_namespace, $page_name );
+ $form_names = SFUtils::getSMWPropertyValues( $store, $subject,
$prop_smw_id );
// If we're using a non-English language, check for the English
// string as well.
if ( ! class_exists( 'SF_LanguageEn' ) || ! $sfgContLang
instanceof SF_LanguageEn ) {
- $backup_form_names = SFUtils::getSMWPropertyValues(
$store, $page_name, $page_namespace, $backup_prop_smw_id );
+ $backup_form_names = SFUtils::getSMWPropertyValues(
$store, $subject, $backup_prop_smw_id );
$form_names = array_merge( $form_names,
$backup_form_names );
}
// Add this data to the "cache".
Modified: trunk/extensions/SemanticForms/includes/SF_TemplateField.php
===================================================================
--- trunk/extensions/SemanticForms/includes/SF_TemplateField.php
2011-06-01 19:04:42 UTC (rev 89279)
+++ trunk/extensions/SemanticForms/includes/SF_TemplateField.php
2011-06-01 19:07:37 UTC (rev 89280)
@@ -60,11 +60,11 @@
$store = smwfGetStore();
// this returns an array of objects
- $allowed_values = SFUtils::getSMWPropertyValues( $store,
$this->semantic_property, SMW_NS_PROPERTY, "Allows value" );
- $label_formats = SFUtils::getSMWPropertyValues( $store,
$this->semantic_property, SMW_NS_PROPERTY, "Has field label format" );
+ $allowed_values = SFUtils::getSMWPropertyValues( $store,
$proptitle, "Allows value" );
+ $label_formats = SFUtils::getSMWPropertyValues( $store,
$proptitle, "Has field label format" );
// SMW 1.6+
if ( class_exists( 'SMWDIProperty' ) ) {
- $propValue = new SMWDIProperty(
$this->semantic_property );
+ $propValue = SMWDIProperty::newFromUserLabel(
$this->semantic_property );
$this->property_type = $propValue->findPropertyTypeID();
} else {
$propValue = SMWPropertyValue::makeUserProperty(
$this->semantic_property );
Modified: trunk/extensions/SemanticForms/includes/SF_Utils.php
===================================================================
--- trunk/extensions/SemanticForms/includes/SF_Utils.php 2011-06-01
19:04:42 UTC (rev 89279)
+++ trunk/extensions/SemanticForms/includes/SF_Utils.php 2011-06-01
19:07:37 UTC (rev 89280)
@@ -75,14 +75,13 @@
* Helper function to handle getPropertyValues() in both SMW 1.6
* and earlier versions.
*/
- public static function getSMWPropertyValues( $store, $pageName,
$pageNamespace, $propID, $requestOptions = null ) {
+ public static function getSMWPropertyValues( $store, $subject, $propID,
$requestOptions = null ) {
// SMWDIProperty was added in SMW 1.6
if ( class_exists( 'SMWDIProperty' ) ) {
- if ( is_null( $pageName ) ) {
+ if ( is_null( $subject ) ) {
$page = null;
} else {
- $pageName = str_replace( ' ', '_', $pageName );
- $page = new SMWDIWikiPage( $pageName,
$pageNamespace, null );
+ $page = SMWDIWikiPage::newFromTitle( $subject );
}
$property = SMWDIProperty::newFromUserLabel( $propID );
$res = $store->getPropertyValues( $page, $property,
$requestOptions );
@@ -99,9 +98,8 @@
}
return $values;
} else {
- $title = Title::makeTitleSafe( $pageNamespace,
$pageName );
$property = SMWPropertyValue::makeProperty( $propID );
- $res = $store->getPropertyValues( $title, $property,
$requestOptions );
+ $res = $store->getPropertyValues( $subject, $property,
$requestOptions );
$values = array();
foreach ( $res as $value ) {
if ( method_exists( $value, 'getTitle' ) ) {
@@ -433,7 +431,7 @@
$store = smwfGetStore();
$requestoptions = new SMWRequestOptions();
$requestoptions->limit = $sfgMaxAutocompleteValues;
- $values = self::getSMWPropertyValues( $store, null, null,
$property_name, $requestoptions );
+ $values = self::getSMWPropertyValues( $store, null,
$property_name, $requestoptions );
sort( $values );
return $values;
}
@@ -531,6 +529,10 @@
return array();
}
+ if ( class_exists( 'SMWDIWikiPage' ) ) {
+ // SMW 1.6
+ $concept = SMWDIWikiPage::newFromTitle( $concept );
+ }
$desc = new SMWConceptDescription( $concept );
$printout = new SMWPrintRequest( SMWPrintRequest::PRINT_THIS,
"" );
$desc->addPrintRequest( $printout );
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs