r26186 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r26185‎ | r26186 | r26187 >
Date:18:23, 27 September 2007
Author:mkroetzsch
Status:old
Tags:
Comment:
Extensions now may add aliases for datatypes.
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DataValueFactory.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DataValueFactory.php
@@ -216,16 +216,6 @@
217217 }
218218
219219 /**
220 - * Register a new SMWDataValue class for dealing with some type. Will be included and
221 - * instantiated dynamically if needed.
222 - * @DEPRECATED
223 - */
224 - static public function registerDataValueClass($typestring, $filepart, $classname) {
225 - SMWDataValueFactory::initDatatypes();
226 - SMWDataValueFactory::$m_typeclasses[$typestring] = $classname;
227 - }
228 -
229 - /**
230220 * Gather all available datatypes and label<=>id<=>datatype associations. This method
231221 * is called before most methods of this factory.
232222 */
@@ -267,14 +257,23 @@
268258 * A function for registering/overwriting datatypes for SMW. Should be called from
269259 * within the hook 'smwInitDatatypes'.
270260 */
271 - static function registerDatatype($id, $classname, $label='') {
 261+ static function registerDatatype($id, $classname, $label=false) {
272262 SMWDataValueFactory::$m_typeclasses[$id] = $classname;
273 - if ($label != '') {
 263+ if ($label != false) {
274264 SMWDataValueFactory::$m_typelabels[$id] = $label;
275265 }
276266 }
277267
278268 /**
 269+ * Add a new alias label to an existing datatype id. Note that every ID should have a primary
 270+ * label, either provided by SMW or registered with registerDatatype. This function should be
 271+ * called from within the hook 'smwInitDatatypes'.
 272+ */
 273+ static function registerDatatypeAlias($id, $label) {
 274+ SMWDataValueFactory::$m_typealiases[$label] = $id;
 275+ }
 276+
 277+ /**
279278 * Look up the ID that identifies the datatype of the given label internally.
280279 * This id is used for all internal operations. Compound types are not supported
281280 * by this method (decomposition happens earlier). Custom types get their DBkeyed

Status & tagging log