Index: trunk/extensions/SemanticForms/includes/SF_TemplateField.php |
— | — | @@ -14,8 +14,7 @@ |
15 | 15 | var $value_labels; |
16 | 16 | var $label; |
17 | 17 | var $semantic_property; |
18 | | - var $field_type; |
19 | | - var $field_type_id; |
| 18 | + var $property_type; |
20 | 19 | var $possible_values; |
21 | 20 | var $is_list; |
22 | 21 | var $input_type; |
— | — | @@ -55,43 +54,39 @@ |
56 | 55 | |
57 | 56 | function setTypeAndPossibleValues() { |
58 | 57 | $proptitle = Title::makeTitleSafe( SMW_NS_PROPERTY, $this->semantic_property ); |
59 | | - if ( $proptitle === NULL ) |
| 58 | + if ( $proptitle === null ) { |
60 | 59 | return; |
| 60 | + } |
| 61 | + |
61 | 62 | $store = smwfGetStore(); |
62 | | - $types = SFUtils::getSMWPropertyValues( $store, $this->semantic_property, SMW_NS_PROPERTY, "Has type" ); |
63 | 63 | // this returns an array of objects |
64 | 64 | $allowed_values = SFUtils::getSMWPropertyValues( $store, $this->semantic_property, SMW_NS_PROPERTY, "Allows value" ); |
65 | 65 | $label_formats = SFUtils::getSMWPropertyValues( $store, $this->semantic_property, SMW_NS_PROPERTY, "Has field label format" ); |
66 | 66 | // SMW 1.6+ |
67 | 67 | if ( class_exists( 'SMWDIProperty' ) ) { |
68 | 68 | $propValue = new SMWDIProperty( $this->semantic_property ); |
69 | | - $this->field_type_id = $propValue->findPropertyTypeID(); |
| 69 | + $this->property_type = $propValue->findPropertyTypeID(); |
70 | 70 | } else { |
71 | 71 | $propValue = SMWPropertyValue::makeUserProperty( $this->semantic_property ); |
72 | | - $this->field_type_id = $propValue->getPropertyTypeID(); |
| 72 | + $this->property_type = $propValue->getPropertyTypeID(); |
73 | 73 | } |
74 | | - // TODO - need handling for the case of more than one type. |
75 | | - if ( count( $types ) > 0 ) { |
76 | | - $this->field_type = $types[0]; |
77 | | - } |
78 | 74 | |
79 | 75 | foreach ( $allowed_values as $allowed_value ) { |
80 | 76 | // HTML-unencode each value |
81 | 77 | $this->possible_values[] = html_entity_decode( $allowed_value ); |
82 | 78 | if ( count( $label_formats ) > 0 ) { |
83 | 79 | $label_format = $label_formats[0]; |
84 | | - $prop_instance = SMWDataValueFactory::findTypeID( $this->field_type ); |
| 80 | + $prop_instance = SMWDataValueFactory::findTypeID( $this->property_type ); |
85 | 81 | $label_value = SMWDataValueFactory::newTypeIDValue( $prop_instance, $wiki_value ); |
86 | 82 | $label_value->setOutputFormat( $label_format ); |
87 | 83 | $this->value_labels[$wiki_value] = html_entity_decode( $label_value->getWikiValue() ); |
88 | 84 | } |
89 | 85 | } |
90 | 86 | |
91 | | - // HACK - if there were any possible values, set the field |
| 87 | + // HACK - if there were any possible values, set the property |
92 | 88 | // type to be 'enumeration', regardless of what the actual type is |
93 | 89 | if ( count( $this->possible_values ) > 0 ) { |
94 | | - $this->field_type = 'enumeration'; |
95 | | - $this->field_type_id = 'enumeration'; |
| 90 | + $this->property_type = 'enumeration'; |
96 | 91 | } |
97 | 92 | } |
98 | 93 | |