Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DataValueFactory.php |
— | — | @@ -50,14 +50,6 @@ |
51 | 51 | /** |
52 | 52 | * Array of data item classes, indexed by type id. |
53 | 53 | * |
54 | | - * @note This is only used for transition. Data items will not be created directly by SMWDataValueFactory in the future. |
55 | | - * @var array of string |
56 | | - */ |
57 | | - static private $mTypeDiClasses; |
58 | | - |
59 | | - /** |
60 | | - * Array of data item classes, indexed by type id. |
61 | | - * |
62 | 54 | * @var array of integer |
63 | 55 | */ |
64 | 56 | static private $mTypeDataItemIds; |
— | — | @@ -224,41 +216,6 @@ |
225 | 217 | '__key' => 'SMWStringValue', // Sort key of a page |
226 | 218 | ); |
227 | 219 | |
228 | | - self::$mTypeDiClasses = array( |
229 | | - '_txt' => 'SMWDIBlob', // Text type |
230 | | - '_cod' => 'SMWDIBlob', // Code type |
231 | | - '_str' => 'SMWDIString', // String type |
232 | | - '_ema' => 'SMWDIUri', // Email type |
233 | | - '_uri' => 'SMWDIUri', // URL/URI type |
234 | | - '_anu' => 'SMWDIUri', // Annotation URI type |
235 | | - '_tel' => 'SMWDIUri', // Phone number (URI) type |
236 | | - '_wpg' => 'SMWDIWikiPage', // Page type |
237 | | - '_wpp' => 'SMWDIWikiPage', // Property page type TODO: make available to user space |
238 | | - '_wpc' => 'SMWDIWikiPage', // Category page type TODO: make available to user space |
239 | | - '_wpf' => 'SMWDIWikiPage', // Form page type for Semantic Forms |
240 | | - '_num' => 'SMWDINumber', // Number type |
241 | | - '_tem' => 'SMWDINumber', // Temperature type |
242 | | - '_dat' => 'SMWDITime', // Time type |
243 | | - '_boo' => 'SMWDIBoolean', // Boolean type |
244 | | - '_rec' => 'SMWDIContainer', // Value list type (replacing former nary properties) |
245 | | - // Special types are not avaialble directly for users (and have no local language name): |
246 | | - '__typ' => 'SMWDIWikiPage', // Special type page type |
247 | | - '__tls' => 'SMWDIString', // Special type list for decalring _rec properties |
248 | | - '__con' => 'SMWDIConcept', // Special concept page type |
249 | | - '__sps' => 'SMWDIString', // Special string type |
250 | | - '__spu' => 'SMWDIUri', // Special uri type |
251 | | - '__sup' => 'SMWDIWikiPage', // Special subproperty type |
252 | | - '__suc' => 'SMWDIWikiPage', // Special subcategory type |
253 | | - '__spf' => 'SMWDIWikiPage', // Special Form page type for Semantic Forms |
254 | | - '__sin' => 'SMWDIWikiPage', // Special instance of type |
255 | | - '__red' => 'SMWDIWikiPage', // Special redirect type |
256 | | - '__lin' => 'SMWDINumber', // Special linear unit conversion type |
257 | | - '__err' => 'SMWDIString', // Special error type |
258 | | - '__imp' => 'SMWDIString', // Special import vocabulary type |
259 | | - '__pro' => 'SMWDIProperty', // Property type (possibly predefined, no always based on a page) |
260 | | - '__key' => 'SMWDIString', // Sort key of a page |
261 | | - ); |
262 | | - |
263 | 220 | self::$mTypeDataItemIds = array( |
264 | 221 | '_txt' => SMWDataItem::TYPE_BLOB, // Text type |
265 | 222 | '_cod' => SMWDataItem::TYPE_BLOB, // Code type |
— | — | @@ -298,34 +255,17 @@ |
299 | 256 | } |
300 | 257 | |
301 | 258 | /** |
302 | | - * A function for associating SMW dataitems with type IDs. This should |
303 | | - * be called from within the hook 'smwInitDatatypes' only. |
304 | | - * |
305 | | - * The dataitem must be one of SMW's data item classes. There is no |
306 | | - * support for adding new datat item classes to SMW. Moreover, note |
307 | | - * that the dataitem is indirectly determined by the datavalue class of |
308 | | - * the type ID. So both must be set/changed to be compatible. |
309 | | - * |
310 | | - * @todo This function should take a dataitem ID instead of a class |
311 | | - * name to prevent new classes from being registered here. |
312 | | - * |
313 | | - * @param $id string |
314 | | - * @param $className string |
315 | | - */ |
316 | | - static public function registerDataItem( $id, $className ) { |
317 | | - self::$mTypeDiClasses[$id] = $className; |
318 | | - } |
319 | | - |
320 | | - /** |
321 | 259 | * A function for registering/overwriting datatypes for SMW. Should be |
322 | 260 | * called from within the hook 'smwInitDatatypes'. |
323 | 261 | * |
324 | | - * @param string $id |
325 | | - * @param string $className |
326 | | - * @param mixed $label |
| 262 | + * @param $id string type ID for which this datatype is registered |
| 263 | + * @param $className string name of the according subclass of SMWDataValue |
| 264 | + * @param $dataItemId integer ID of the data item class that this data value uses, see SMWDataItem |
| 265 | + * @param $label mixed string label or false for types that cannot be accessed by users |
327 | 266 | */ |
328 | | - static public function registerDatatype( $id, $className, $label = false ) { |
| 267 | + static public function registerDatatype( $id, $className, $dataItemId, $label = false ) { |
329 | 268 | self::$mTypeClasses[$id] = $className; |
| 269 | + self::$mTypeDataItemIds[$id] = $dataItemId; |
330 | 270 | |
331 | 271 | if ( $label != false ) { |
332 | 272 | self::$mTypeLabels[$id] = $label; |