Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Factbox.php |
— | — | @@ -60,7 +60,7 @@ |
61 | 61 | |
62 | 62 | switch ($special) { |
63 | 63 | case false: // normal attribute |
64 | | - $result = SMWDataValue::newAttributeValue($attribute,$value); |
| 64 | + $result = SMWDataValueFactory::newAttributeValue($attribute,$value); |
65 | 65 | if ($smwgStoreActive) { |
66 | 66 | SMWFactbox::$semdata->addAttributeTextValue($attribute,$result); |
67 | 67 | } |
— | — | @@ -71,12 +71,12 @@ |
72 | 72 | if ( $special === SMW_SP_SERVICE_LINK ) { // do some custom formatting in this case |
73 | 73 | global $wgContLang; |
74 | 74 | $v = str_replace(' ', '_', $value); //normalize slightly since messages distinguish '_' and ' ' |
75 | | - $result = SMWDataValue::newSpecialValue($special,$v); |
| 75 | + $result = SMWDataValueFactory::newSpecialValue($special,$v); |
76 | 76 | $v = $result->getXSDValue(); //possibly further sanitized, so let's be cautious |
77 | 77 | $result->setProcessedValues($value,$v); //set user value back to the input version |
78 | 78 | $result->setPrintoutString('[[' . $wgContLang->getNsText(NS_MEDIAWIKI) . ':smw_service_' . $v . "|$value]]"); |
79 | 79 | } else { // standard processing |
80 | | - $result = SMWDataValue::newSpecialValue($special,$value); |
| 80 | + $result = SMWDataValueFactory::newSpecialValue($special,$value); |
81 | 81 | } |
82 | 82 | if ($smwgStoreActive) { |
83 | 83 | SMWFactbox::$semdata->addSpecialValue($special,$result); |
— | — | @@ -132,7 +132,7 @@ |
133 | 133 | $msglines = preg_split("([\n][\s]?)",wfMsgForContent("smw_import_$onto_ns")); // get the definition for "$namespace:$section" |
134 | 134 | |
135 | 135 | if ( count($msglines) < 2 ) { //error: no elements for this namespace |
136 | | - $datavalue = SMWDataValue::newTypedValue(new SMWErrorTypeHandler(wfMsgForContent('smw_unknown_importns',$onto_ns)),$value); |
| 136 | + $datavalue = SMWDataValueFactory::newTypeHandlerValue(new SMWErrorTypeHandler(wfMsgForContent('smw_unknown_importns',$onto_ns)),$value); |
137 | 137 | if ($smwgStoreActive) { |
138 | 138 | SMWFactbox::$semdata->addSpecialValue(SMW_SP_IMPORTED_FROM,$datavalue); |
139 | 139 | } |
— | — | @@ -187,7 +187,7 @@ |
188 | 188 | } |
189 | 189 | |
190 | 190 | if (NULL != $error) { |
191 | | - $datavalue = SMWDataValue::newTypedValue(new SMWErrorTypeHandler($error),$value); |
| 191 | + $datavalue = SMWDataValueFactory::newTypeHandlerValue(new SMWErrorTypeHandler($error),$value); |
192 | 192 | if ($smwgStoreActive) { |
193 | 193 | SMWFactbox::$semdata->addSpecialValue(SMW_SP_IMPORTED_FROM, $datavalue); |
194 | 194 | } |
— | — | @@ -200,11 +200,11 @@ |
201 | 201 | $sth = new SMWStringTypeHandler(); // making one is enough ... |
202 | 202 | |
203 | 203 | if ($smwgStoreActive) { |
204 | | - $datavalue = SMWDataValue::newTypedValue($sth,$onto_uri); |
| 204 | + $datavalue = SMWDataValueFactory::newTypeHandlerValue($sth,$onto_uri); |
205 | 205 | SMWFactbox::$semdata->addSpecialValue(SMW_SP_EXT_BASEURI,$datavalue); |
206 | | - $datavalue = SMWDataValue::newTypedValue($sth,$onto_ns); |
| 206 | + $datavalue = SMWDataValueFactory::newTypeHandlerValue($sth,$onto_ns); |
207 | 207 | SMWFactbox::$semdata->addSpecialValue(SMW_SP_EXT_NSID,$datavalue); |
208 | | - $datavalue = SMWDataValue::newTypedValue($sth,$onto_section); |
| 208 | + $datavalue = SMWDataValueFactory::newTypeHandlerValue($sth,$onto_section); |
209 | 209 | SMWFactbox::$semdata->addSpecialValue(SMW_SP_EXT_SECTION,$datavalue); |
210 | 210 | if (NULL !== $datatype) { |
211 | 211 | SMWFactbox::$semdata->addSpecialValue(SMW_SP_HAS_TYPE,$datatype); |
— | — | @@ -212,7 +212,7 @@ |
213 | 213 | } |
214 | 214 | |
215 | 215 | // print the input (this property is usually not stored, see SMW_SQLStore.php) |
216 | | - $datavalue = SMWDataValue::newTypedValue($sth,"[$onto_uri$onto_section $value]"); |
| 216 | + $datavalue = SMWDataValueFactory::newTypeHandlerValue($sth,"[$onto_uri$onto_section $value]"); |
217 | 217 | // TODO: Unfortunatelly, the following line can break the tooltip code if $onto_name has markup. -- mak |
218 | 218 | // if ('' != $onto_name) $datavalue->setPrintoutString($onto_name, 'onto_name'); |
219 | 219 | if ('' != $onto_name) $datavalue->setPrintoutString("[$onto_uri$onto_section $value] ($onto_name)"); |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DataValueFactory.php |
— | — | @@ -20,9 +20,14 @@ |
21 | 21 | /** |
22 | 22 | * Cache for type labels, indexed by attribute name (both without namespace prefix). |
23 | 23 | */ |
24 | | - static private $m_attributelabels = array(); |
| 24 | + static private $m_attributelabels = array('testnary' => 'String;Integer;Wikipage;Date'); ///DEBUG |
25 | 25 | |
26 | 26 | /** |
| 27 | + * Was code for handling n-ary properties already included? |
| 28 | + */ |
| 29 | + static private $m_naryincluded = false; |
| 30 | + |
| 31 | + /** |
27 | 32 | * Create a value from a string supplied by a user for a given attribute. |
28 | 33 | * If no value is given, an empty container is created, the value of which |
29 | 34 | * can be set later on. |
— | — | @@ -87,13 +92,24 @@ |
88 | 93 | } |
89 | 94 | return new $dv[2]($dv[3]); |
90 | 95 | } else { |
91 | | - ///TODO |
92 | | - $type = SMWTypeHandlerFactory::getTypeHandlerByLabel($typestring); |
93 | | - $result = new SMWOldDataValue($type); |
94 | | - if ($value !== false) { |
95 | | - $result->setUserValue($value); |
| 96 | + // check for n-ary types |
| 97 | + $types = explode($typestring, ';'); |
| 98 | + if (count($types)>1) { |
| 99 | + if (SMWDataValueFactory::$m_naryincluded == false) { |
| 100 | + global $smwgIP; |
| 101 | + include_once($smwgIP . '/includes/SMW_DV_NAry.php'); |
| 102 | + SMWDataValueFactory::$m_naryincluded = true; |
| 103 | + } |
| 104 | + return new SMWNAryValue($types, $value); |
| 105 | + } else { |
| 106 | + ///TODO |
| 107 | + $type = SMWTypeHandlerFactory::getTypeHandlerByLabel($typestring); |
| 108 | + $result = new SMWOldDataValue($type); |
| 109 | + if ($value !== false) { |
| 110 | + $result->setUserValue($value); |
| 111 | + } |
| 112 | + return $result; |
96 | 113 | } |
97 | | - return $result; |
98 | 114 | } |
99 | 115 | } |
100 | 116 | |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_NAry.php |
— | — | @@ -0,0 +1,5 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +///TODO |
| 5 | + |
| 6 | +?> |
\ No newline at end of file |
Property changes on: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_NAry.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 7 | + native |