http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89257

Revision: 89257
Author:   yaron
Date:     2011-06-01 13:49:31 +0000 (Wed, 01 Jun 2011)
Log Message:
-----------
Replaced 'field_type' and 'field_type_id' fields with 'property_type' - simpler 
and clearer. Also simplified retrieval of property type.

Modified Paths:
--------------
    trunk/extensions/SemanticForms/includes/SF_TemplateField.php

Modified: trunk/extensions/SemanticForms/includes/SF_TemplateField.php
===================================================================
--- trunk/extensions/SemanticForms/includes/SF_TemplateField.php        
2011-06-01 13:47:14 UTC (rev 89256)
+++ trunk/extensions/SemanticForms/includes/SF_TemplateField.php        
2011-06-01 13:49:31 UTC (rev 89257)
@@ -14,8 +14,7 @@
        var $value_labels;
        var $label;
        var $semantic_property;
-       var $field_type;
-       var $field_type_id;
+       var $property_type;
        var $possible_values;
        var $is_list;
        var $input_type;
@@ -55,43 +54,39 @@
 
        function setTypeAndPossibleValues() {
                $proptitle = Title::makeTitleSafe( SMW_NS_PROPERTY, 
$this->semantic_property );
-               if ( $proptitle === NULL )
+               if ( $proptitle === null ) {
                        return;
+               }
+
                $store = smwfGetStore();
-               $types = SFUtils::getSMWPropertyValues( $store, 
$this->semantic_property, SMW_NS_PROPERTY, "Has type" );
                // 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" );
                // SMW 1.6+
                if ( class_exists( 'SMWDIProperty' ) ) {
                        $propValue = new SMWDIProperty( 
$this->semantic_property );
-                       $this->field_type_id = $propValue->findPropertyTypeID();
+                       $this->property_type = $propValue->findPropertyTypeID();
                } else {
                        $propValue = SMWPropertyValue::makeUserProperty( 
$this->semantic_property );
-                       $this->field_type_id = $propValue->getPropertyTypeID();
+                       $this->property_type = $propValue->getPropertyTypeID();
                }
-               // TODO - need handling for the case of more than one type.
-               if ( count( $types ) > 0 ) {
-                       $this->field_type = $types[0];
-               }
 
                foreach ( $allowed_values as $allowed_value ) {
                        // HTML-unencode each value
                        $this->possible_values[] = html_entity_decode( 
$allowed_value );
                        if ( count( $label_formats ) > 0 ) {
                                $label_format = $label_formats[0];
-                               $prop_instance = 
SMWDataValueFactory::findTypeID( $this->field_type );
+                               $prop_instance = 
SMWDataValueFactory::findTypeID( $this->property_type );
                                $label_value = 
SMWDataValueFactory::newTypeIDValue( $prop_instance, $wiki_value );
                                $label_value->setOutputFormat( $label_format );
                                $this->value_labels[$wiki_value] = 
html_entity_decode( $label_value->getWikiValue() );
                        }
                }
 
-               // HACK - if there were any possible values, set the field
+               // HACK - if there were any possible values, set the property
                // type to be 'enumeration', regardless of what the actual type 
is
                if ( count( $this->possible_values ) > 0 ) {
-                       $this->field_type = 'enumeration';
-                       $this->field_type_id = 'enumeration';
+                       $this->property_type = 'enumeration';
                }
        }
 


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to