r26182 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r26181‎ | r26182 | r26183 >
Date:17:00, 27 September 2007
Author:mkroetzsch
Status:old
Tags:
Comment:
Improved type management, support for datatype alias names, support for extension datatypes (via hook)
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DT_Boolean.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DT_DateTime.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DT_Enum.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DT_Float.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DT_GeoCoords.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DT_Integer.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DT_URI.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_NAry.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Types.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_WikiPage.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DataValueFactory.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_Datatype.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/languages/SMW_Language.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageDe.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageEn.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageEs.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageFr.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageHe.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageNl.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/languages/SMW_LanguagePl.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageRu.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageSk.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/QueryPages/SMW_SpecialTypes.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/specials/QueryPages/SMW_SpecialTypes.php
@@ -55,7 +55,7 @@
5656 $sql = "(SELECT 'Types' as type, {$NStype} as namespace, page_title as title, " .
5757 "page_title as value, 1 as count FROM $page WHERE page_namespace = $NStype)";
5858 // make SQL for built-in datatypes
59 - foreach ($smwgContLang->getAllDatatypeLabels() as $label) {
 59+ foreach (SMWDataValueFactory::getKnownTypeLabels() as $label) {
6060 $label = str_replace(' ', '_', $label); // DBkey form so that SQL can elminate duplicates
6161 $sql .= " UNION (SELECT 'Types' as type, {$NStype} as namespace, '$label' as title, " .
6262 "'$label' as value, 1 as count)";
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DT_DateTime.php
@@ -17,7 +17,7 @@
1818 /** @public */
1919
2020 function getID() {
21 - return 'datetime';
 21+ return '_dat';
2222 }
2323
2424 function getXSDType() {
@@ -129,8 +129,4 @@
130130 }
131131 } //SMWDateTimeTypeHandler
132132
133 -//register type handler:
134 -//SMWTypeHandlerFactory::registerTypeHandler($smwgContLang->getDatatypeLabel('smw_datetime'),
135 -// new SMWDateTimeTypeHandler());
136133
137 -
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DT_Integer.php
@@ -11,7 +11,7 @@
1212 class SMWIntegerTypeHandler implements SMWTypeHandler {
1313
1414 function getID() {
15 - return 'int';
 15+ return '_int';
1616 }
1717
1818 function getXSDType() {
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DT_URI.php
@@ -48,10 +48,10 @@
4949
5050 function getID() {
5151 switch ($this->mMode) {
52 - case SMW_URI_MODE_EMAIL: return 'email';
53 - case SMW_URI_MODE_URL: return 'url';
54 - case SMW_URI_MODE_URI: return 'uri';
55 - case SMW_URI_MODE_ANNOURI: return 'annouri';
 52+ case SMW_URI_MODE_EMAIL: return '_ema';
 53+ case SMW_URI_MODE_URL: return '_url';
 54+ case SMW_URI_MODE_URI: return '_uri';
 55+ case SMW_URI_MODE_ANNOURI: return '_anu';
5656 }
5757 }
5858
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_WikiPage.php
@@ -33,7 +33,7 @@
3434 $this->m_namespace = $this->m_title->getNamespace();
3535 $this->m_id = false; // unset id
3636 if ($this->m_caption === false) {
37 - $this->m_caption = $this->m_prefixedtext;
 37+ $this->m_caption = $value;
3838 }
3939 } else {
4040 $this->addError('Invalid title string'); // TODO: internationalise
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DT_Enum.php
@@ -12,7 +12,7 @@
1313 class SMWEnumTypeHandler implements SMWTypeHandler {
1414
1515 function getID() {
16 - return 'enum';
 16+ return '_enu';
1717 }
1818
1919 // Can't represent any better way than as a string
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DT_Float.php
@@ -28,7 +28,7 @@
2929 * ID string for the datatype object
3030 * @access protected
3131 */
32 - protected $typeid = 'float';
 32+ protected $typeid = '_flt';
3333 /**
3434 * Primary unit for this type, false if none.
3535 * @see getPrimaryUnit()
@@ -351,7 +351,7 @@
352352
353353 } // End SMWFloatTypeHandler}
354354
355 -SMWTypeHandlerFactory::registerTypeHandler($smwgContLang->getDatatypeLabel('smw_float'),
 355+SMWTypeHandlerFactory::registerTypeHandler('_flt',
356356 new SMWFloatTypeHandler());
357357
358358
@@ -534,7 +534,7 @@
535535 /**#@+
536536 * @access private
537537 */
538 - var $typeid = 'temperature';
 538+ var $typeid = '_tem';
539539 var $primaryUnit = 'K';
540540 var $otherDisplayUnits = array('°C', '°F');
541541
@@ -595,7 +595,7 @@
596596 }
597597 } // End class SMWTemperatureTypeHandler
598598
599 -SMWTypeHandlerFactory::registerTypeHandler($smwgContLang->getDatatypeLabel('smw_temperature'),
 599+SMWTypeHandlerFactory::registerTypeHandler('_tem',
600600 new SMWTemperatureTypeHandler());
601601
602602
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Types.php
@@ -15,39 +15,9 @@
1616 class SMWTypesValue extends SMWDataValue {
1717
1818 private $m_typelabels = false;
 19+ private $m_typecaptions = false;
1920 private $m_xsdvalue = false;
2021
21 - /**
22 - * This associative array links message ids for type label to internal type
23 - * ids. Datavalue classes register for certain internal type ids, and this
24 - * class establishes the required mapping. No id must be duplicated, and
25 - * ids should in general not be changed, since they act as universal handles
26 - * for types throughout the code. The registration happens in
27 - * SMW_DataValueFactory.php
28 - */
29 - static private $m_typeids = array(
30 - 'smw_wikipage' => '_wpg',
31 - 'smw_string' => '_str',
32 - 'smw_text' => '_txt',
33 - 'smw_enum' => '_enu',
34 - 'smw_bool' => '_boo',
35 - 'smw_int' => '_int',
36 - 'smw_float' => '_flt',
37 - //case 'smw_length'
38 - //case 'smw_area'
39 - //case 'smw_geolength'
40 - //case 'smw_geoarea'
41 - 'smw_geocoordinate' => '_crd',
42 - //case 'smw_mass'
43 - 'smw_time' => '_tim',
44 - 'smw_temperature' => '_tmp',
45 - 'smw_datetime' => '_dat',
46 - 'smw_email' => '_ema',
47 - 'smw_url' => '_url',
48 - 'smw_uri' => '_uri',
49 - 'smw_annouri' => '_anu'
50 - );
51 -
5222 protected function parseUserValue($value) {
5323 // no use for being lazy here: plain user values are never useful
5424 $this->m_typelabels = array();
@@ -57,7 +27,8 @@
5828 $type = rtrim($type, ' ]');
5929 $ttype = Title::newFromText($type,SMW_NS_TYPE);
6030 if ($ttype->getNamespace() == SMW_NS_TYPE) {
61 - $this->m_typelabels[] = $ttype->getText();
 31+ $this->m_typecaptions[] = $type;
 32+ $this->m_typelabels[] = SMWDataValueFactory::findTypeLabel(SMWDataValueFactory::findTypeID($ttype->getText()));
6233 } // else: wrong namespace given -- what now? TODO
6334 }
6435 }
@@ -71,17 +42,68 @@
7243 }
7344
7445 public function getShortWikiText($linked = NULL) {
75 - if ($this->m_caption !== false) {
76 - return $this->m_caption;
 46+ if ( ($linked === NULL) || ($linked === false) ) {
 47+ if ($this->m_caption !== false) {
 48+ return $this->m_caption;
 49+ } else {
 50+ return str_replace('_',' ',implode(', ', $this->getTypeCaptions()));
 51+ }
 52+ } else {
 53+ global $wgContLang;
 54+ $typenamespace = $wgContLang->getNsText(SMW_NS_TYPE);
 55+ if ($this->m_caption !== false) {
 56+ if ($this->isUnary()) {
 57+ return '[[' . $typenamespace . ':' . $this->getWikiValue() . '|' . $this->m_caption . ']]';
 58+ } else {
 59+ return $this->m_caption;
 60+ }
 61+ }
 62+ $result = '';
 63+ $first = true;
 64+ $captions = $this->getTypeCaptions();
 65+ reset($captions);
 66+ foreach ($this->getTypeLabels() as $type) {
 67+ $caption = next($captions);
 68+ if ($first) {
 69+ $first = false;
 70+ } else {
 71+ $result .= ', ';
 72+ }
 73+ $result .= '[[' . $typenamespace . ':' . $type . '|' . $caption . ']]';
 74+ }
 75+ return $result;
7776 }
78 - return $this->getLongWikiText($linked);
7977 }
8078
8179 public function getShortHTMLText($linker = NULL) {
82 - if ($this->m_caption !== false) {
83 - return htmlspecialchars($this->m_caption);
 80+ if ( ($linker === NULL) || ($linker === false) ) {
 81+ if ($this->m_caption !== false) {
 82+ return htmlspecialchars($this->m_caption);
 83+ } else {
 84+ return str_replace('_',' ',implode(', ', $this->getTypeCaptions()));
 85+ }
 86+ } else {
 87+ if ($this->m_caption !== false) {
 88+ if ($this->isUnary()) {
 89+ $title = Title::newFromText($this->getWikiValue(), SMW_NS_TYPE);
 90+ return $linker->makeLinkObj($title, $this->m_caption);
 91+ } else {
 92+ return htmlspecialchars($this->m_caption);
 93+ }
 94+ }
 95+ $result = '';
 96+ $first = true;
 97+ foreach ($this->getTypeLabels() as $type) {
 98+ if ($first) {
 99+ $first = false;
 100+ } else {
 101+ $result .= ', ';
 102+ }
 103+ $title = Title::newFromText($type, SMW_NS_TYPE);
 104+ $result .= $linker->makeLinkObj( $title, $type);
 105+ }
 106+ return $result;
84107 }
85 - return $this->getLongHTMLText($linker);
86108 }
87109
88110 public function getLongWikiText($linked = NULL) {
@@ -134,7 +156,7 @@
135157 } else {
136158 $this->m_xsdvalue .= ';';
137159 }
138 - $this->m_xsdvalue .= SMWTypesValue::findTypeID($label);
 160+ $this->m_xsdvalue .= SMWDataValueFactory::findTypeID($label);
139161 }
140162 }
141163 return $this->m_xsdvalue;
@@ -181,7 +203,7 @@
182204 }
183205
184206 /**
185 - * Is this a built-in datatype shipped with SMW?
 207+ * Is this a built-in datatype shipped with SMW (or an extension of SMW)?
186208 * (Alternatively it would be a user-defined derived datatype.)
187209 */
188210 public function isBuiltIn() {
@@ -193,16 +215,40 @@
194216 * Retrieve type labels if needed. Can be done lazily.
195217 */
196218 public function getTypeLabels() {
 219+ $this->initTypeData();
 220+ if ($this->m_typelabels === false) {
 221+ return array(); // fallback for unary callers
 222+ } else {
 223+ return $this->m_typelabels;
 224+ }
 225+ }
 226+
 227+ /**
 228+ * Retrieve type captions if needed. Can be done lazily. The captions
 229+ * are different from the labels if type aliases are used.
 230+ */
 231+ public function getTypeCaptions() {
 232+ $this->initTypeData();
 233+ if ($this->m_typecaptions === false) {
 234+ return array(); // fallback for unary callers
 235+ } else {
 236+ return $this->m_typecaptions;
 237+ }
 238+ }
 239+
 240+ /**
 241+ * Internal method to extract data from XSD-representation. Called lazily.
 242+ */
 243+ protected function initTypeData() {
197244 if ( ($this->m_typelabels === false) && ($this->m_xsdvalue !== false) ) {
198245 $this->m_typelabels = array();
199246 $ids = explode(';', $this->m_xsdvalue);
200247 foreach ($ids as $id) {
201 - $this->m_typelabels[] = SMWTypesValue::findTypeLabel($id);
 248+ $label = SMWDataValueFactory::findTypeLabel($id);
 249+ $this->m_typelabels[] = $label;
 250+ $this->m_typecaptions[] = $label;
202251 }
203 - } elseif ($this->m_typelabels === false) {
204 - return array(); // fallback for unwary callers
205252 }
206 - return $this->m_typelabels; // false only if nothing set yet
207253 }
208254
209255 /**
@@ -219,39 +265,5 @@
220266 return $result;
221267 }
222268
223 - /**
224 - * Get the language independent id for some type label (e.g. "_int" for "Integer").
225 - * This id is used for all internal operations. Compound types are not supported
226 - * by this method (decomposition happens earlier). Custom types get their DBkeyed
227 - * label as id. All ids are prefixed by an underscore in order to distinguish them
228 - * from custom types.
229 - */
230 - static public function findTypeID($label) {
231 - global $smwgContLang;
232 - $msgid = $smwgContLang->findDatatypeMsgID($label);
233 - if ( ($msgid !== false) && (array_key_exists($msgid, SMWTypesValue::$m_typeids)) ) {
234 - return SMWTypesValue::$m_typeids[$msgid];
235 - } else { // hopefully $msgid was just FALSE ...
236 - return str_replace(' ', '_', $label);
237 - }
238 - }
239 -
240 - /**
241 - * Inverse of findTypeID();
242 - */
243 - static public function findTypeLabel($id) {
244 - global $smwgContLang;
245 - if ($id{0} === '_') {
246 - $key = array_search($id, SMWTypesValue::$m_typeids);
247 - if ($key !== false) {
248 - return $smwgContLang->getDatatypeLabel($key);
249 - } else { // maybe some no longer supported type?
250 - return str_replace('_', ' ', $id);
251 - }
252 - } else {
253 - return str_replace('_', ' ', $id);
254 - }
255 - }
256 -
257269 }
258270
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DataValueFactory.php
@@ -16,17 +16,27 @@
1717 class SMWDataValueFactory {
1818
1919 /**
20 - * Array of class names and initialisation data for creating
21 - * new SMWDataValues. Indexed by type label (without namespace).
22 - * Each entry has the form
23 - * array(included?, filepart, classname);
 20+ * Array of type labels indexed by type ids. Used for datatype
 21+ * resolution.
2422 */
25 - static private $m_valueclasses = array();
 23+ static private $m_typelabels;
2624
2725 /**
 26+ * Array of ids indexed by type aliases. Used for datatype
 27+ * resolution.
 28+ */
 29+ static private $m_typealiases;
 30+
 31+ /**
 32+ * Array of class names for creating new SMWDataValues, indexed by
 33+ * type id.
 34+ */
 35+ static private $m_typeclasses;
 36+
 37+ /**
2838 * Cache for type specifications (type datavalues), indexed by property name (both without namespace prefix).
2939 */
30 - static private $m_typelabels = array();
 40+ static private $m_typebyproperty = array();
3141
3242 /**
3343 * Create a value from a string supplied by a user for a given property.
@@ -35,8 +45,8 @@
3646 */
3747 static public function newPropertyValue($propertyname, $value=false, $caption=false) {
3848 wfProfileIn("SMWDataValueFactory::newPropertyValue (SMW)");
39 - if(array_key_exists($propertyname,SMWDataValueFactory::$m_typelabels)) { // use cache
40 - $result = SMWDataValueFactory::newTypeObjectValue(SMWDataValueFactory::$m_typelabels[$propertyname], $value, $caption, $propertyname);
 49+ if(array_key_exists($propertyname,SMWDataValueFactory::$m_typebyproperty)) { // use cache
 50+ $result = SMWDataValueFactory::newTypeObjectValue(SMWDataValueFactory::$m_typebyproperty[$propertyname], $value, $caption, $propertyname);
4151 wfProfileOut("SMWDataValueFactory::newPropertyValue (SMW)");
4252 return $result;
4353 } // else: find type for property:
@@ -47,7 +57,7 @@
4858 } else {
4959 $type = SMWDataValueFactory::newTypeIDValue('__typ');
5060 $type->setXSDValue('_wpg');
51 - SMWDataValueFactory::$m_typelabels[$propertyname] = $type;
 61+ SMWDataValueFactory::$m_typebyproperty[$propertyname] = $type;
5262 $result = SMWDataValueFactory::newTypeIDValue('_wpg',$value,$caption,$propertyname);
5363 }
5464 wfProfileOut("SMWDataValueFactory::newPropertyValue (SMW)");
@@ -61,19 +71,19 @@
6272 */
6373 static public function newPropertyObjectValue(Title $property, $value=false, $caption=false) {
6474 $propertyname = $property->getText();
65 - if(array_key_exists($propertyname,SMWDataValueFactory::$m_typelabels)) { // use cache
66 - return SMWDataValueFactory::newTypeObjectValue(SMWDataValueFactory::$m_typelabels[$propertyname], $value, $caption, $propertyname);
 75+ if(array_key_exists($propertyname,SMWDataValueFactory::$m_typebyproperty)) { // use cache
 76+ return SMWDataValueFactory::newTypeObjectValue(SMWDataValueFactory::$m_typebyproperty[$propertyname], $value, $caption, $propertyname);
6777 } // else: find type for property:
6878
6979 $typearray = smwfGetStore()->getSpecialValues($property,SMW_SP_HAS_TYPE);
7080 if (count($typearray)==1) {
71 - SMWDataValueFactory::$m_typelabels[$propertyname] = $typearray[0];
72 - $result = SMWDataValueFactory::newTypeObjectValue(SMWDataValueFactory::$m_typelabels[$propertyname], $value, $caption, $propertyname);
 81+ SMWDataValueFactory::$m_typebyproperty[$propertyname] = $typearray[0];
 82+ $result = SMWDataValueFactory::newTypeObjectValue(SMWDataValueFactory::$m_typebyproperty[$propertyname], $value, $caption, $propertyname);
7383 return $result;
7484 } elseif (count($typearray)==0) {
7585 $type = SMWDataValueFactory::newTypeIDValue('__typ');
7686 $type->setXSDValue('_wpg');
77 - SMWDataValueFactory::$m_typelabels[$propertyname] = $type;
 87+ SMWDataValueFactory::$m_typebyproperty[$propertyname] = $type;
7888 return SMWDataValueFactory::newTypeIDValue('_wpg',$value,$caption,$propertyname);
7989 } else {
8090 global $smwgIP;
@@ -123,7 +133,8 @@
124134 * @param $propertyname text name of according property, or false (may be relevant for getting further parameters)
125135 */
126136 static public function newTypeObjectValue(/*SMWDataValue*/ $typevalue, $value=false, $caption=false, $propertyname=false) {
127 - if (array_key_exists($typevalue->getXSDValue(), SMWDataValueFactory::$m_valueclasses)) {
 137+ SMWDataValueFactory::initDatatypes();
 138+ if (array_key_exists($typevalue->getXSDValue(), SMWDataValueFactory::$m_typeclasses)) {
128139 return SMWDataValueFactory::newTypeIDValue($typevalue->getXSDValue(), $value, $caption, $propertyname);
129140 } else {
130141 if (!$typevalue->isUnary()) { // n-ary type?
@@ -132,7 +143,7 @@
133144 } else { ///TODO migrate to new system
134145 global $smwgIP;
135146 include_once($smwgIP . '/includes/SMW_OldDataValue.php');
136 - $type = SMWTypeHandlerFactory::getTypeHandlerByLabel($typevalue->getWikiValue());
 147+ $type = SMWTypeHandlerFactory::getTypeHandlerByLabel($typevalue->getXSDValue());
137148 $result = new SMWOldDataValue($type);
138149 }
139150 }
@@ -156,20 +167,9 @@
157168 * @param $propertyname text name of according property, or false (may be relevant for getting further parameters)
158169 */
159170 static public function newTypeIDValue($typeid, $value=false, $caption=false, $propertyname=false) {
160 - if (array_key_exists($typeid, SMWDataValueFactory::$m_valueclasses)) {
161 - $vc = SMWDataValueFactory::$m_valueclasses[$typeid];
162 - // check if class file was already included for this class
163 - if ($vc[0] == false) {
164 - global $smwgIP;
165 - if (file_exists($smwgIP . '/includes/SMW_DV_'. $vc[1] . '.php')) {
166 - include_once($smwgIP . '/includes/SMW_DV_'. $vc[1] . '.php');
167 - } else { // file for registered type missing
168 - include_once($smwgIP . '/includes/SMW_DV_Error.php');
169 - new SMWErrorValue(wfMsgForContent('smw_unknowntype'), $value, $caption);
170 - }
171 - $vc[0] = true;
172 - }
173 - $result = new $vc[2]($typeid);
 171+ SMWDataValueFactory::initDatatypes();
 172+ if (array_key_exists($typeid, SMWDataValueFactory::$m_typeclasses)) {
 173+ $result = new SMWDataValueFactory::$m_typeclasses[$typeid]($typeid);
174174 } else {
175175 $typevalue = SMWDataValueFactory::newTypeIDValue('__typ');
176176 $typevalue->setXSDValue($typeid);
@@ -190,9 +190,9 @@
191191 */
192192 static public function getPropertyObjectTypeID(Title $property) {
193193 $propertyname = $property->getText();
194 - if (array_key_exists($propertyname, SMWDataValueFactory::$m_typelabels)) {
195 - if (SMWDataValueFactory::$m_typelabels[$propertyname]->isUnary() ) {
196 - return SMWDataValueFactory::$m_typelabels[$propertyname]->getXSDValue();
 194+ if (array_key_exists($propertyname, SMWDataValueFactory::$m_typebyproperty)) {
 195+ if (SMWDataValueFactory::$m_typebyproperty[$propertyname]->isUnary() ) {
 196+ return SMWDataValueFactory::$m_typebyproperty[$propertyname]->getXSDValue();
197197 } else {
198198 return '__nry';
199199 }
@@ -208,68 +208,124 @@
209209 static public function getPropertyObjectTypeValue(Title $property) {
210210 $propertyname = $property->getText();
211211 SMWDataValueFactory::newPropertyObjectValue($property);
212 - if (array_key_exists($propertyname, SMWDataValueFactory::$m_typelabels)) {
213 - return SMWDataValueFactory::$m_typelabels[$propertyname];
 212+ if (array_key_exists($propertyname, SMWDataValueFactory::$m_typebyproperty)) {
 213+ return SMWDataValueFactory::$m_typebyproperty[$propertyname];
214214 } else { // no type found
215215 return NULL;
216216 }
217217 }
218218
219219 /**
220 - * Create a value from a user-supplied string for which a type handler is known
221 - * If no value is given, an empty container is created, the value of which
222 - * can be set later on.
223 - *
 220+ * Register a new SMWDataValue class for dealing with some type. Will be included and
 221+ * instantiated dynamically if needed.
224222 * @DEPRECATED
225223 */
226 - static public function newTypeHandlerValue(SMWTypeHandler $type, $value=false) {
227 - global $smwgIP;
228 - include_once($smwgIP . '/includes/SMW_OldDataValue.php');
229 - $result = new SMWOldDataValue($type);
230 - if ($value !== false) {
231 - $result->setUserValue($value);
 224+ static public function registerDataValueClass($typestring, $filepart, $classname) {
 225+ SMWDataValueFactory::initDatatypes();
 226+ SMWDataValueFactory::$m_typeclasses[$typestring] = $classname;
 227+ }
 228+
 229+ /**
 230+ * Gather all available datatypes and label<=>id<=>datatype associations. This method
 231+ * is called before most methods of this factory.
 232+ */
 233+ static protected function initDatatypes() {
 234+ if (is_array(SMWDataValueFactory::$m_typelabels)) {
 235+ return; //init happened before
232236 }
233 - return $result;
 237+
 238+ global $smwgContLang, $smwgIP, $wgAutoloadClasses;
 239+ SMWDataValueFactory::$m_typelabels = $smwgContLang->getDatatypeLabels();
 240+ SMWDataValueFactory::$m_typealiases = $smwgContLang->getDatatypeAliases();
 241+ // Setup built-in datatypes.
 242+ // NOTE: all ids must start with underscores, where two underscores indicate
 243+ // truly internal (non user-acessible types). All others should also get a
 244+ // translation in the language files, or they won't be available for users.
 245+ $wgAutoloadClasses['SMWStringValue'] = $smwgIP . '/includes/SMW_DV_String.php';
 246+ $wgAutoloadClasses['SMWWikiPageValue'] = $smwgIP . '/includes/SMW_DV_WikiPage.php';
 247+ $wgAutoloadClasses['SMWURIValue'] = $smwgIP . '/includes/SMW_DV_URI.php';
 248+ $wgAutoloadClasses['SMWTypesValue'] = $smwgIP . '/includes/SMW_DV_Types.php';
 249+ $wgAutoloadClasses['SMWNAryValue'] = $smwgIP . '/includes/SMW_DV_NAry.php';
 250+ $wgAutoloadClasses['SMWErrorValue'] = $smwgIP . '/includes/SMW_DV_Error.php';
 251+ SMWDataValueFactory::$m_typeclasses = array(
 252+ '_txt' => 'SMWStringValue',
 253+ '_str' => 'SMWStringValue',
 254+// '_ema' => 'SMWURIValue',
 255+// '_uri' => 'SMWURIValue',
 256+// '_url' => 'SMWURIValue',
 257+// '_anu' => 'SMWURIValue',
 258+ '_wpg' => 'SMWWikiPageValue',
 259+ '__typ' => 'SMWTypesValue',
 260+ '__nry' => 'SMWNAryValue',
 261+ '__err' => 'SMWErrorValue'
 262+ );
 263+
 264+ wfRunHooks( 'smwInitDatatypes' );
234265 }
235266
236267 /**
237 - * @DEPRECATED
 268+ * A function for registering/overwriting datatypes for SMW. Should be called from
 269+ * within the hook 'smwInitDatatypes'.
238270 */
239 - static public function newAttributeValue($property, $value=false, $caption=false) {
240 - trigger_error("Function newAttributeValue is deprecated. Use new property methods.", E_USER_NOTICE);
241 - return SMWDataValueFactory::newPropertyValue($property, $value, $caption);
 271+ static function registerDatatype($id, $classname, $label='') {
 272+ SMWDataValueFactory::$m_typeclasses[$id] = $classname;
 273+ if ($label != '') {
 274+ SMWDataValueFactory::$m_typelabels[$id] = $label;
 275+ }
242276 }
243277
244278 /**
245 - * @DEPRECATED
 279+ * Look up the ID that identifies the datatype of the given label internally.
 280+ * This id is used for all internal operations. Compound types are not supported
 281+ * by this method (decomposition happens earlier). Custom types get their DBkeyed
 282+ * label as id. All ids are prefixed by an underscore in order to distinguish them
 283+ * from custom types.
 284+ *
 285+ * This method may or may not take aliases into account. For unknown labels, the
 286+ * normalised (DB-version) label is used as an ID.
246287 */
247 - static public function newAttributeObjectValue(Title $property, $value=false, $caption=false) {
248 - trigger_error("Function newAttributeObjectValue is deprecated. Use new property methods.", E_USER_NOTICE);
249 - return SMWDataValueFactory::newPropertyObjectValue($property, $value, $caption);
 288+ static public function findTypeID($label, $useAlias = true) {
 289+ SMWDataValueFactory::initDatatypes();
 290+ $id = array_search($label, SMWDataValueFactory::$m_typelabels);
 291+ if ($id !== false) {
 292+ return $id;
 293+ } elseif (array_key_exists($label, SMWDataValueFactory::$m_typealiases)) {
 294+ return SMWDataValueFactory::$m_typealiases[$label];
 295+ } else {
 296+ return str_replace(' ', '_', $label);
 297+ }
250298 }
251299
 300+ /**
 301+ * Get the translated user label for a given internal ID. If the ID does
 302+ * not have a label associated with it in the current language, the ID itself
 303+ * is transformed into a label (appropriate for user defined types).
 304+ */
 305+ static public function findTypeLabel($id) {
 306+ SMWDataValueFactory::initDatatypes();
 307+ if ($id{0} === '_') {
 308+ if (array_key_exists($id, SMWDataValueFactory::$m_typelabels)) {
 309+ return SMWDataValueFactory::$m_typelabels[$id];
 310+ } else { //internal type without translation to user space;
 311+ //might also happen for historic types after upgrade --
 312+ //alas, we have no idea what the former label would have been
 313+ return str_replace('_', ' ', $id);
 314+ }
 315+ } else { // non-builtin type, use id as label
 316+ return str_replace('_', ' ', $id);
 317+ }
 318+ }
252319
253320 /**
254 - * Register a new SMWDataValue class for dealing with some type. Will be included and
255 - * instantiated dynamically if needed.
 321+ * Return an array of all labels that a user might specify as the type of
 322+ * a property, and that are internal (i.e. not user defined). No labels are
 323+ * returned for internal types without user labels (e.g. the special types for
 324+ * some special properties), and for user defined types.
256325 */
257 - static public function registerDataValueClass($typestring, $filepart, $classname) {
258 - SMWDataValueFactory::$m_valueclasses[$typestring] = array(false,$filepart,$classname);
 326+ static public function getKnownTypeLabels() {
 327+ SMWDataValueFactory::initDatatypes();
 328+ return SMWDataValueFactory::$m_typelabels;
259329 }
260330
261331 }
262332
263 -/// NOTE: the type constants are registered to translated labels in SMW_TypeValue.php.
264 -/// However, types that are not available to users can also have ids for being registered here, but
265 -/// these ids should start with two underscores.
266 -SMWDataValueFactory::registerDataValueClass('_txt','String','SMWStringValue');
267 -SMWDataValueFactory::registerDataValueClass('_str','String','SMWStringValue');
268 -// SMWDataValueFactory::registerDataValueClass('ema','URI','SMWURIValue');
269 -// SMWDataValueFactory::registerDataValueClass('uri','URI','SMWURIValue');
270 -// SMWDataValueFactory::registerDataValueClass('url','URI','SMWURIValue');
271 -// SMWDataValueFactory::registerDataValueClass('anu','URI','SMWURIValue');
272 -SMWDataValueFactory::registerDataValueClass('_wpg','WikiPage','SMWWikiPageValue');
273 -
274 -SMWDataValueFactory::registerDataValueClass('__typ','Types','SMWTypesValue');
275 -SMWDataValueFactory::registerDataValueClass('__nry','NAry','SMWNAryValue');
276 -SMWDataValueFactory::registerDataValueClass('__err','Error','SMWErrorValue');
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_NAry.php
@@ -286,7 +286,7 @@
287287 $typelabels = $this->m_type->getTypeLabels();
288288 for ($i = 0; $i < $this->m_count; $i++) {
289289 if ( ($i < count($datavalues) ) && ($datavalues[$i] !== NULL) ) {
290 - //&& ($datavalues[$i]->getTypeID() == SMWTypesValue::findTypeID($typelabels[$i])) ) {
 290+ //&& ($datavalues[$i]->getTypeID() == SMWDataValueFactory::findTypeID($typelabels[$i])) ) {
291291 ///TODO: is the above typcheck required, or can we assume responsible callers?
292292 $this->m_values[$i] = $datavalues[$i];
293293 } else {
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DT_Boolean.php
@@ -11,7 +11,7 @@
1212 class SMWBooleanTypeHandler implements SMWTypeHandler {
1313
1414 function getID() {
15 - return 'boolean';
 15+ return '_boo';
1616 }
1717
1818 function getXSDType() {
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DT_GeoCoords.php
@@ -51,7 +51,7 @@
5252 }
5353
5454 function getID() {
55 - return 'geocoords';
 55+ return '_geo';
5656 }
5757
5858 function getXSDType() {
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Datatype.php
@@ -59,7 +59,6 @@
6060
6161 static private $typeHandlersByLabel = Array();
6262 static private $typeHandlersByAttribute = Array();
63 - static private $typeLabelsByID = Array();
6463 static private $desiredUnitsByAttribute = Array();
6564 static private $possibleValuesByAttribute = Array();
6665 static private $serviceLinksByAttribute = Array();
@@ -71,7 +70,6 @@
7271 */
7372 static function registerTypeHandler($label, $th) {
7473 SMWTypeHandlerFactory::$typeHandlersByLabel[$label] = $th;
75 - SMWTypeHandlerFactory::$typeLabelsByID[$th->getID()] = $label;
7674 }
7775
7876 /**
@@ -82,19 +80,9 @@
8381 */
8482 static function announceTypeHandler($label, $id, $filepart, $class, $param = NULL) {
8583 SMWTypeHandlerFactory::$typeHandlersByLabel[$label] = array($filepart, $class, $param);
86 - SMWTypeHandlerFactory::$typeLabelsByID[$id] = $label;
8784 }
8885
8986 /**
90 - * This method returns an array of the labels of built-in types (those
91 - * announced in code rather than user-defined types with custom units).
92 - * Needed since typeHandlersByLabel is private.
93 - */
94 - static function getTypeLabels() {
95 - return array_keys(SMWTypeHandlerFactory::$typeHandlersByLabel);
96 - }
97 -
98 - /**
9987 * This method returns the type handler object for a given type label
10088 * (i.e. a localized type name), or an error type handler if the label
10189 * is not associated with some handler. The label is usually the article
@@ -120,7 +108,7 @@
121109 if (!$findConversions) return NULL;
122110 $conversionFactors = SMWTypeHandlerFactory::getConversionFactors($typelabel);
123111 if (count($conversionFactors) !== 0) {
124 - $instance = new SMWLinearTypeHandler('Type:' . $typelabel, $conversionFactors); // no localisation needed -- "Type:" is just a disamb. string in the DB
 112+ $instance = new SMWLinearTypeHandler($typelabel, $conversionFactors);
125113 SMWTypeHandlerFactory::$typeHandlersByLabel[$typelabel] = $instance;
126114 return SMWTypeHandlerFactory::$typeHandlersByLabel[$typelabel];
127115 }
@@ -239,23 +227,23 @@
240228 * then you must add it to this list!
241229 */
242230 // Integer
243 -SMWTypeHandlerFactory::announceTypeHandler($smwgContLang->getDatatypeLabel('smw_int'),'int','Integer','SMWIntegerTypeHandler');
 231+SMWTypeHandlerFactory::announceTypeHandler('_int','int','Integer','SMWIntegerTypeHandler');
244232 // URLs etc.
245 -SMWTypeHandlerFactory::announceTypeHandler($smwgContLang->getDatatypeLabel('smw_email'),'email','URI','SMWURITypeHandler','email');
246 -SMWTypeHandlerFactory::announceTypeHandler($smwgContLang->getDatatypeLabel('smw_url'),'url','URI','SMWURITypeHandler','url');
247 -SMWTypeHandlerFactory::announceTypeHandler($smwgContLang->getDatatypeLabel('smw_uri'),'uri','URI','SMWURITypeHandler','uri');
248 -SMWTypeHandlerFactory::announceTypeHandler($smwgContLang->getDatatypeLabel('smw_annouri'),'annouri','URI','SMWURITypeHandler','annouri');
 233+SMWTypeHandlerFactory::announceTypeHandler('_ema','email','URI','SMWURITypeHandler','email');
 234+SMWTypeHandlerFactory::announceTypeHandler('_url','url','URI','SMWURITypeHandler','url');
 235+SMWTypeHandlerFactory::announceTypeHandler('_uri','uri','URI','SMWURITypeHandler','uri');
 236+SMWTypeHandlerFactory::announceTypeHandler('_ari','annouri','URI','SMWURITypeHandler','annouri');
249237 // Dates & times
250 -SMWTypeHandlerFactory::announceTypeHandler($smwgContLang->getDatatypeLabel('smw_datetime'),'datetime','DateTime','SMWDateTimeTypeHandler');
 238+SMWTypeHandlerFactory::announceTypeHandler('_dat','datetime','DateTime','SMWDateTimeTypeHandler');
251239 // Geographic coordinates
252 -SMWTypeHandlerFactory::announceTypeHandler($smwgContLang->getDatatypeLabel('smw_geocoordinate'),'geocoords','GeoCoords','SMWGeographicLocationTypeHandler');
 240+SMWTypeHandlerFactory::announceTypeHandler('_geo','geocoords','GeoCoords','SMWGeographicLocationTypeHandler');
253241 // Enums
254 -SMWTypeHandlerFactory::announceTypeHandler($smwgContLang->getDatatypeLabel('smw_enum'),'enum','Enum','SMWEnumTypeHandler');
 242+SMWTypeHandlerFactory::announceTypeHandler('_enu','enum','Enum','SMWEnumTypeHandler');
255243 // Text
256 -SMWTypeHandlerFactory::announceTypeHandler($smwgContLang->getDatatypeLabel('smw_text'),'text','Text','SMWTextTypeHandler');
 244+//SMWTypeHandlerFactory::announceTypeHandler('_txt','text','Text','SMWTextTypeHandler');
257245 // Bools
258246 // Booleans can (and more problematic: will) be modelled by two-valued enums; too much choice yields confusion (note that Categories are also addressing a simliar modelling problem already -- let's not introduce three ways of encoding this)
259 -//SMWTypeHandlerFactory::announceTypeHandler($smwgContLang->getDatatypeLabel('smw_bool'),'bool','Boolean','SMWBooleanTypeHandler');
 247+//SMWTypeHandlerFactory::announceTypeHandler('_boo'),'bool','Boolean','SMWBooleanTypeHandler');
260248
261249 /*********************************************************************/
262250 /* Basic typehandler classes */
@@ -369,53 +357,53 @@
370358 /**
371359 * Class for managing string types. Very simple.
372360 */
373 -class SMWStringTypeHandler implements SMWTypeHandler {
 361+// class SMWStringTypeHandler implements SMWTypeHandler {
 362+//
 363+// function getID() {
 364+// return 'string';
 365+// }
 366+//
 367+// function getXSDType() {
 368+// return 'http://www.w3.org/2001/XMLSchema#string';
 369+// }
 370+//
 371+// function getUnits() { //no units for strings
 372+// return array('STDUNIT'=>false, 'ALLUNITS'=>array());
 373+// }
 374+//
 375+// function processValue($value,&$datavalue) {
 376+// if ($value!='') { //do not accept empty strings
 377+// $xsdvalue = smwfXMLContentEncode($value);
 378+// // 255 below matches smw_attributes.value_xsd definition in smwfMakeSemanticTables()
 379+// // Note that depending on database encoding and UTF-8 settings, longer or
 380+// // shorter strings than this with int'l characters may exceed database field.
 381+// if (strlen($xsdvalue) > 255) {
 382+// $datavalue->setError(wfMsgForContent('smw_maxstring', $xsdvalue));
 383+// } else {
 384+// $datavalue->setProcessedValues($value, $xsdvalue);
 385+// $datavalue->setPrintoutString($value);
 386+// $datavalue->addQuicksearchLink();
 387+// // TODO: Performance: this causes a SpecialProperties database query and some callers don't use it.
 388+// $datavalue->addServiceLinks(urlencode($value));
 389+// }
 390+// } else {
 391+// $datavalue->setError(wfMsgForContent('smw_emptystring'));
 392+// }
 393+// return true;
 394+// }
 395+//
 396+// function processXSDValue($value,$unit,&$datavalue) {
 397+// return $this->processValue($value,$datavalue);
 398+// }
 399+//
 400+// function isNumeric() {
 401+// return false;
 402+// }
 403+// }
 404+//
 405+// SMWTypeHandlerFactory::registerTypeHandler('_str'),
 406+// new SMWStringTypeHandler());
374407
375 - function getID() {
376 - return 'string';
377 - }
378 -
379 - function getXSDType() {
380 - return 'http://www.w3.org/2001/XMLSchema#string';
381 - }
382 -
383 - function getUnits() { //no units for strings
384 - return array('STDUNIT'=>false, 'ALLUNITS'=>array());
385 - }
386 -
387 - function processValue($value,&$datavalue) {
388 - if ($value!='') { //do not accept empty strings
389 - $xsdvalue = smwfXMLContentEncode($value);
390 - // 255 below matches smw_attributes.value_xsd definition in smwfMakeSemanticTables()
391 - // Note that depending on database encoding and UTF-8 settings, longer or
392 - // shorter strings than this with int'l characters may exceed database field.
393 - if (strlen($xsdvalue) > 255) {
394 - $datavalue->setError(wfMsgForContent('smw_maxstring', $xsdvalue));
395 - } else {
396 - $datavalue->setProcessedValues($value, $xsdvalue);
397 - $datavalue->setPrintoutString($value);
398 - $datavalue->addQuicksearchLink();
399 - // TODO: Performance: this causes a SpecialProperties database query and some callers don't use it.
400 - $datavalue->addServiceLinks(urlencode($value));
401 - }
402 - } else {
403 - $datavalue->setError(wfMsgForContent('smw_emptystring'));
404 - }
405 - return true;
406 - }
407 -
408 - function processXSDValue($value,$unit,&$datavalue) {
409 - return $this->processValue($value,$datavalue);
410 - }
411 -
412 - function isNumeric() {
413 - return false;
414 - }
415 -}
416 -
417 -SMWTypeHandlerFactory::registerTypeHandler($smwgContLang->getDatatypeLabel('smw_string'),
418 - new SMWStringTypeHandler());
419 -
420408 /**
421409 * This method formats a float number value according to the given
422410 * language and precision settings, with some intelligence to
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageEs.php
@@ -187,23 +187,37 @@
188188 'smw_result_noresults' => 'Lo siento, no hay resultados.'
189189 );
190190
191 -protected $smwDatatypeLabels = array(
192 - 'smw_wikipage' => 'Page', // name of page datatype //TODO translate
193 - 'smw_string' => 'Cadena de caracteres', // name of the string type
194 - 'smw_text' => 'Texto', // name of the text type (very long strings)
195 - 'smw_enum' => 'Enumeración', // name of the enum type
196 - 'smw_bool' => 'Booleano', // name of the boolean type
197 - 'smw_int' => 'Número entero', // name of the int type
198 - 'smw_float' => 'Número con coma', // name of the floating point type
199 - 'smw_geocoordinate' => 'Coordenadas geográficas', // name of the geocoord type
200 - 'smw_temperature' => 'Temperatura', // name of the temperature type
201 - 'smw_datetime' => 'Fecha', // name of the datetime (calendar) type
202 - 'smw_email' => 'Dirección electrónica', // name of the email (URI) type
203 - 'smw_url' => 'URL', // name of the URL type (string datatype property)
204 - 'smw_uri' => 'URI', // name of the URI type (object property)
205 - 'smw_annouri' => 'Anotación-URI' // name of the annotation URI type (annotation property)
 191+protected $m_DatatypeLabels = array(
 192+ '_wpg' => 'Page', // name of page datatype //TODO translate
 193+ '_str' => 'Cadena de caracteres', // name of the string type
 194+ '_txt' => 'Texto', // name of the text type (very long strings)
 195+ '_enu' => 'Enumeración', // name of the enum type
 196+ //'_boo' => 'Booleano', // name of the boolean type
 197+ '_int' => 'Número entero', // name of the int type
 198+ '_flt' => 'Número con coma', // name of the floating point type
 199+ '_geo' => 'Coordenadas geográficas', // name of the geocoord type
 200+ '_tem' => 'Temperatura', // name of the temperature type
 201+ '_dat' => 'Fecha', // name of the datetime (calendar) type
 202+ '_ema' => 'Dirección electrónica', // name of the email (URI) type
 203+ '_url' => 'URL', // name of the URL type (string datatype property)
 204+ '_uri' => 'URI', // name of the URI type (object property)
 205+ '_anu' => 'Anotación-URI' // name of the annotation URI type (annotation property)
206206 );
207207
 208+protected $m_DatatypeAliases = array(
 209+ // support English aliases:
 210+ 'Page' => '_wpg',
 211+ 'String' => '_str',
 212+ 'Text' => '_txt',
 213+ 'Integer' => '_int',
 214+ 'Float' => '_flt',
 215+ 'Geographic coordinate' => '_geo',
 216+ 'Temperature' => '_tem',
 217+ 'Date' => '_dat',
 218+ 'Email' => '_ema',
 219+ 'Annotation URI' => '_anu'
 220+);
 221+
208222 protected $smwSpecialProperties = array(
209223 //always start upper-case
210224 SMW_SP_HAS_TYPE => 'Tiene tipo de datos',
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageFr.php
@@ -188,23 +188,37 @@
189189 'smw_result_noresults' => 'Désolé, aucun résultat.',
190190 );
191191
192 -protected $smwDatatypeLabels = array(
193 - 'smw_wikipage' => 'Page', // name of page datatype //TODO translate
194 - 'smw_string' => 'Chaîne de caractères', // name of the string type
195 - 'smw_text' => 'Text', // name of the text type (very long strings) //TODO: translate
196 - 'smw_enum' => 'Énumeration', // name of the enum type
197 - 'smw_bool' => 'Booléen', // name of the boolean type
198 - 'smw_int' => 'Nombre entier', // name of the int type
199 - 'smw_float' => 'Nombre décimal', // name of the floating point type
200 - 'smw_geocoordinate' => 'Coordonnées géographiques', // name of the geocoord type
201 - 'smw_temperature' => 'Température', // name of the temperature type
202 - 'smw_datetime' => 'Date', // name of the datetime (calendar) type
203 - 'smw_email' => 'Adresse électronique', // name of the email (URI) type
204 - 'smw_url' => 'URL', // name of the URL type (string datatype property)
205 - 'smw_uri' => 'URI', // name of the URI type (object property)
206 - 'smw_annouri' => 'Annotation-URI' // name of the annotation URI type (annotation property)
 192+protected $m_DatatypeLabels = array(
 193+ '_wpg' => 'Page', // name of page datatype //TODO translate
 194+ '_str' => 'Chaîne de caractères', // name of the string type
 195+ '_txt' => 'Text', // name of the text type (very long strings) //TODO: translate
 196+ '_enu' => 'Énumeration', // name of the enum type
 197+ //'_boo' => 'Booléen', // name of the boolean type
 198+ '_int' => 'Nombre entier', // name of the int type
 199+ '_flt' => 'Nombre décimal', // name of the floating point type
 200+ '_geo' => 'Coordonnées géographiques', // name of the geocoord type
 201+ '_tem' => 'Température', // name of the temperature type
 202+ '_dat' => 'Date', // name of the datetime (calendar) type
 203+ '_ema' => 'Adresse électronique', // name of the email (URI) type
 204+ '_url' => 'URL', // name of the URL type (string datatype property)
 205+ '_uri' => 'URI', // name of the URI type (object property)
 206+ '_anu' => 'Annotation-URI' // name of the annotation URI type (annotation property)
207207 );
208208
 209+protected $m_DatatypeAliases = array(
 210+ // support English aliases:
 211+ 'Page' => '_wpg',
 212+ 'String' => '_str',
 213+ 'Text' => '_txt',
 214+ 'Integer' => '_int',
 215+ 'Float' => '_flt',
 216+ 'Geographic coordinate' => '_geo',
 217+ 'Temperature' => '_tem',
 218+ 'Date' => '_dat',
 219+ 'Email' => '_ema',
 220+ 'Annotation URI' => '_anu'
 221+);
 222+
209223 protected $smwSpecialProperties = array(
210224 //always start upper-case
211225 SMW_SP_HAS_TYPE => 'A le type',
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageDe.php
@@ -177,30 +177,43 @@
178178 'smw_result_noresults' => 'Keine Ergebnisse gefunden.'
179179 );
180180
181 -protected $smwDatatypeLabels = array(
182 - 'smw_wikipage' => 'Seite', // name of page datatype
183 - 'smw_string' => 'Zeichenkette', // name of the string type
184 - 'smw_text' => 'Text', // name of the text type
185 - 'smw_enum' => 'Aufzählung', // name of the enum type
186 - 'smw_bool' => 'Wahrheitswert', // name of the boolean type
187 - 'smw_int' => 'Ganze Zahl', // name of the int type
188 - 'smw_float' => 'Dezimalzahl', // name of the floating point type
189 - 'smw_geocoordinate' => 'Geografische Koordinaten', // name of the geocoord type
190 - 'smw_temperature' => 'Temperatur', // name of the temperature type
191 - 'smw_datetime' => 'Datum', // name of the datetime (calendar) type
192 - 'smw_email' => 'Email', // name of the email (URI) type
193 - 'smw_url' => 'URL', // name of the URL type (string datatype property)
194 - 'smw_uri' => 'URI', // name of the URI type (object property)
195 - 'smw_annouri' => 'URI-Annotation' // name of the annotation URI type (annotation property)
 181+protected $m_DatatypeLabels = array(
 182+ '_wpg' => 'Seite', // name of page datatype
 183+ '_str' => 'Zeichenkette', // name of the string type
 184+ '_txt' => 'Text', // name of the text type
 185+ '_enu' => 'Aufzählung', // name of the enum type
 186+ //'_boo' => 'Wahrheitswert', // name of the boolean type
 187+ '_int' => 'Ganze Zahl', // name of the int type
 188+ '_flt' => 'Dezimalzahl', // name of the floating point type
 189+ '_geo' => 'Geografische Koordinaten', // name of the geocoord type
 190+ '_tem' => 'Temperatur', // name of the temperature type
 191+ '_dat' => 'Datum', // name of the datetime (calendar) type
 192+ '_ema' => 'Email', // name of the email (URI) type
 193+ '_url' => 'URL', // name of the URL type (string datatype property)
 194+ '_uri' => 'URI', // name of the URI type (object property)
 195+ '_anu' => 'URI-Annotation' // name of the annotation URI type (annotation property)
196196 );
197197
 198+protected $m_DatatypeAliases = array(
 199+ // support English aliases:
 200+ 'Page' => '_wpg',
 201+ 'String' => '_str',
 202+ 'Text' => '_txt',
 203+ 'Integer' => '_int',
 204+ 'Float' => '_flt',
 205+ 'Geographic coordinate' => '_geo',
 206+ 'Temperature' => '_tem',
 207+ 'Date' => '_dat',
 208+ 'Email' => '_ema',
 209+ 'Annotation URI' => '_anu'
 210+);
 211+
198212 protected $smwSpecialProperties = array(
199213 //always start upper-case
200214 SMW_SP_HAS_TYPE => 'Hat Datentyp',
201215 SMW_SP_HAS_URI => 'Gleichwertige URI',
202216 SMW_SP_SUBPROPERTY_OF => 'Untereigenschaft von',
203217 SMW_SP_MAIN_DISPLAY_UNIT => 'Erste Ausgabeeinheit',
204 - // SMW_SP_MAIN_DISPLAY_UNIT => 'Primärmaßeinheit für Schirmanzeige', // Great! We really should keep this wonderful translation here! Still, I am not fully certain about my versions either. -- mak
205218 SMW_SP_DISPLAY_UNIT => 'Ausgabeeinheit',
206219 SMW_SP_IMPORTED_FROM => 'Importiert aus',
207220 SMW_SP_CONVERSION_FACTOR => 'Entspricht',
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageNl.php
@@ -173,23 +173,37 @@
174174 'smw_result_noresults' => 'Sorry, geen resultaten.'
175175 );
176176
177 -protected $smwDatatypeLabels = array(
178 - 'smw_wikipage' => 'Pagina', // name of page datatype
179 - 'smw_string' => 'String', // name of the string type
180 - 'smw_text' => 'Tekst', // name of the text type
181 - 'smw_enum' => 'Opsomming', // name of the enum type
182 - 'smw_bool' => 'Booleans', // name of the boolean type
183 - 'smw_int' => 'Integer', // name of the int type
184 - 'smw_float' => 'Float', // name of the floating point type
185 - 'smw_geocoordinate' => 'Geographische coordinaat', // name of the geocoord type
186 - 'smw_temperature' => 'Temperatuur', // name of the temperature type
187 - 'smw_datetime' => 'Datum', // name of the datetime (calendar) type
188 - 'smw_email' => 'E-mail', // name of the email (URI) type
189 - 'smw_url' => 'URL', // name of the URL type (string datatype property)
190 - 'smw_uri' => 'URI', // name of the URI type (object property)
191 - 'smw_annouri' => 'Annotatie URI' // name of the annotation URI type (annotation property)
 177+protected $m_DatatypeLabels = array(
 178+ '_wpg' => 'Pagina', // name of page datatype
 179+ '_str' => 'String', // name of the string type
 180+ '_txt' => 'Tekst', // name of the text type
 181+ '_enu' => 'Opsomming', // name of the enum type
 182+ '_boo' => 'Booleans', // name of the boolean type
 183+ '_int' => 'Integer', // name of the int type
 184+ '_flt' => 'Float', // name of the floating point type
 185+ '_geo' => 'Geographische coordinaat', // name of the geocoord type
 186+ '_tem' => 'Temperatuur', // name of the temperature type
 187+ '_dat' => 'Datum', // name of the datetime (calendar) type
 188+ '_ema' => 'E-mail', // name of the email (URI) type
 189+ '_url' => 'URL', // name of the URL type (string datatype property)
 190+ '_uri' => 'URI', // name of the URI type (object property)
 191+ '_anu' => 'Annotatie URI' // name of the annotation URI type (annotation property)
192192 );
193193
 194+protected $m_DatatypeAliases = array(
 195+ // support English aliases:
 196+ 'Page' => '_wpg',
 197+ 'String' => '_str',
 198+ 'Text' => '_txt',
 199+ 'Integer' => '_int',
 200+ 'Float' => '_flt',
 201+ 'Geographic coordinate' => '_geo',
 202+ 'Temperature' => '_tem',
 203+ 'Date' => '_dat',
 204+ 'Email' => '_ema',
 205+ 'Annotation URI' => '_anu'
 206+);
 207+
194208 protected $smwSpecialProperties = array(
195209 //always start upper-case
196210 SMW_SP_HAS_TYPE => 'Heeft type',
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguagePl.php
@@ -219,23 +219,37 @@
220220 'smw_result_noresults' => 'Niestety, brak wyników.'
221221 );
222222
223 -protected $smwDatatypeLabels = array(
224 - 'smw_wikipage' => 'Page', // name of page datatype //TODO translate
225 - 'smw_string' => 'Łańcuch znaków', // name of the string type
226 - 'smw_text' => 'Text', // name of the text type (very long strings) //TODO: translate
227 - 'smw_enum' => 'Wyliczenie', // name of the enum type
228 - 'smw_bool' => 'Wartość logiczna', // name of the boolean type
229 - 'smw_int' => 'Liczba całkowita', // name of the int type
230 - 'smw_float' => 'Liczba zmiennoprzecinkowa', // name of the floating point type
231 - 'smw_geocoordinate' => 'Współrzędne geograficzne', // name of the geocoord type
232 - 'smw_temperature' => 'Temperatura', // name of the temperature type
233 - 'smw_datetime' => 'Data', // name of the datetime (calendar) type
234 - 'smw_email' => 'Email', // name of the email (URI) type
235 - 'smw_url' => 'URL', // name of the URL type (string datatype property)
236 - 'smw_uri' => 'URI', // name of the URI type (object property)
237 - 'smw_annouri' => 'Annotation URI' // name of the annotation URI type (annotation property) //TODO: translate
 223+protected $m_DatatypeLabels = array(
 224+ '_wpg' => 'Page', // name of page datatype //TODO translate
 225+ '_str' => 'Łańcuch znaków', // name of the string type
 226+ '_txt' => 'Text', // name of the text type (very long strings) //TODO: translate
 227+ '_enu' => 'Wyliczenie', // name of the enum type
 228+ '_boo' => 'Wartość logiczna', // name of the boolean type
 229+ '_int' => 'Liczba całkowita', // name of the int type
 230+ '_flt' => 'Liczba zmiennoprzecinkowa', // name of the floating point type
 231+ '_geo' => 'Współrzędne geograficzne', // name of the geocoord type
 232+ '_tem' => 'Temperatura', // name of the temperature type
 233+ '_dat' => 'Data', // name of the datetime (calendar) type
 234+ '_ema' => 'Email', // name of the email (URI) type
 235+ '_url' => 'URL', // name of the URL type (string datatype property)
 236+ '_uri' => 'URI', // name of the URI type (object property)
 237+ '_anu' => 'Annotation URI' // name of the annotation URI type (annotation property) //TODO: translate
238238 );
239239
 240+protected $m_DatatypeAliases = array(
 241+ // support English aliases:
 242+ 'Page' => '_wpg',
 243+ 'String' => '_str',
 244+ 'Text' => '_txt',
 245+ 'Integer' => '_int',
 246+ 'Float' => '_flt',
 247+ 'Geographic coordinate' => '_geo',
 248+ 'Temperature' => '_tem',
 249+ 'Date' => '_dat',
 250+ 'Email' => '_ema',
 251+ 'Annotation URI' => '_anu'
 252+);
 253+
240254 protected $smwSpecialProperties = array(
241255 //always start upper-case
242256 SMW_SP_HAS_TYPE => 'Ma typ',
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageHe.php
@@ -197,23 +197,38 @@
198198 'smw_result_noresults' => 'מצטערת, אין תוצאות'
199199 );
200200
201 -protected $smwDatatypeLabels = array(
202 - 'smw_wikipage' => 'Page', // name of page datatype //TODO translate
203 - 'smw_string' => 'מחרוזת', // name of the string type
204 - 'smw_text' => 'Text', // name of the text type (very long strings) //TODO: translate
205 - 'smw_enum' => 'Enumeration', // name of the enum type
206 - 'smw_bool' => 'נכוןלאנכון', // name of the boolean type
207 - 'smw_int' => 'שלם', // name of the int type
208 - 'smw_float' => 'נקודהצפה', // name of the floating point type
209 - 'smw_geocoordinate' => 'קורדינטות גיאוגרפיות', // name of the geocoord type
210 - 'smw_temperature' => 'טמפרטורה', // name of the temperature type
211 - 'smw_datetime' => 'תאריך', // name of the datetime (calendar) type
212 - 'smw_email' => 'דואל', // name of the email (URI) type
213 - 'smw_url' => 'URL', // name of the URL type (string datatype property)
214 - 'smw_uri' => 'מזהה יחודי', // name of the URI type (object property)
215 - 'smw_annouri' => 'Annotation URI' // name of the annotation URI type (annotation property)
 201+protected $m_DatatypeLabels = array(
 202+ '_wpg' => 'Page', // name of page datatype //TODO translate
 203+ '_str' => 'מחרוזת', // name of the string type
 204+ '_txt' => 'Text', // name of the text type (very long strings) //TODO: translate
 205+ '_enu' => 'Enumeration', // name of the enum type
 206+ //'_boo' => 'נכוןלאנכון', // name of the boolean type
 207+ '_int' => 'שלם', // name of the int type
 208+ '_flt' => 'נקודהצפה', // name of the floating point type
 209+ '_geo' => 'קורדינטות גיאוגרפיות', // name of the geocoord type
 210+ '_tem' => 'טמפרטורה', // name of the temperature type
 211+ '_dat' => 'תאריך', // name of the datetime (calendar) type
 212+ '_ema' => 'דואל', // name of the email (URI) type
 213+ '_url' => 'URL', // name of the URL type (string datatype property)
 214+ '_uri' => 'מזהה יחודי', // name of the URI type (object property)
 215+ '_anu' => 'Annotation URI' // name of the annotation URI type (annotation property)
216216 );
217217
 218+protected $m_DatatypeAliases = array(
 219+ // support English aliases:
 220+ 'Page' => '_wpg',
 221+ 'String' => '_str',
 222+ 'Text' => '_txt',
 223+ 'Integer' => '_int',
 224+ 'Float' => '_flt',
 225+ 'Geographic coordinate' => '_geo',
 226+ 'Temperature' => '_tem',
 227+ 'Date' => '_dat',
 228+ 'Email' => '_ema',
 229+ 'URI' => '_uri',
 230+ 'Annotation URI' => '_anu'
 231+);
 232+
218233 protected $smwSpecialProperties = array(
219234 //always start upper-case
220235 SMW_SP_HAS_TYPE => 'מטיפוס',
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageSk.php
@@ -196,23 +196,37 @@
197197 'smw_result_noresult' => 'Prepáčte, žiadne výsledky.'
198198 );
199199
200 -protected $smwDatatypeLabels = array(
201 - 'smw_wikipage' => 'Page', // name of page datatype //TODO translate
202 - 'smw_string' => 'Reťazec', // name of the string type
203 - 'smw_text' => 'Text', // name of the text type (very long strings) //TODO: translate
204 - 'smw_enum' => 'Enumeration', // name of the enum type TODO: translate
205 - 'smw_bool' => 'Boolean', // name of the boolean type TODO: translate
206 - 'smw_int' => 'Celé číslo', // name of the int type
207 - 'smw_float' => 'Desatinné číslo', // name of the floating point type
208 - 'smw_geocoordinate' => 'Zemepisné súradnice', // name of the geocoord type
209 - 'smw_temperature' => 'Teplota', // name of the temperature type
210 - 'smw_datetime' => 'Dátum', // name of the datetime (calendar) type
211 - 'smw_email' => 'Email', // name of the email (URI) type
212 - 'smw_url' => 'URL', // name of the URL type (string datatype property)
213 - 'smw_uri' => 'URI', // name of the URI type (object property)
214 - 'smw_annouri' => 'URI anotácie' // name of the annotation URI type (annotation property)
 200+protected $m_DatatypeLabels = array(
 201+ '_wpg' => 'Page', // name of page datatype //TODO translate
 202+ '_str' => 'Reťazec', // name of the string type
 203+ '_txt' => 'Text', // name of the text type (very long strings) //TODO: translate
 204+ '_enu' => 'Enumeration', // name of the enum type TODO: translate
 205+ '_boo' => 'Boolean', // name of the boolean type TODO: translate
 206+ '_int' => 'Celé číslo', // name of the int type
 207+ '_flt' => 'Desatinné číslo', // name of the floating point type
 208+ '_geo' => 'Zemepisné súradnice', // name of the geocoord type
 209+ '_tem' => 'Teplota', // name of the temperature type
 210+ '_dat' => 'Dátum', // name of the datetime (calendar) type
 211+ '_ema' => 'Email', // name of the email (URI) type
 212+ '_url' => 'URL', // name of the URL type (string datatype property)
 213+ '_uri' => 'URI', // name of the URI type (object property)
 214+ '_anu' => 'URI anotácie' // name of the annotation URI type (annotation property)
215215 );
216216
 217+protected $m_DatatypeAliases = array(
 218+ // support English aliases:
 219+ 'Page' => '_wpg',
 220+ 'String' => '_str',
 221+ 'Text' => '_txt',
 222+ 'Integer' => '_int',
 223+ 'Float' => '_flt',
 224+ 'Geographic coordinate' => '_geo',
 225+ 'Temperature' => '_tem',
 226+ 'Date' => '_dat',
 227+ 'Email' => '_ema',
 228+ 'Annotation URI' => '_anu'
 229+);
 230+
217231 protected $smwSpecialProperties = array(
218232 //always start upper-case
219233 SMW_SP_HAS_TYPE => 'Má typ',
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_Language.php
@@ -11,8 +11,9 @@
1212 // the message arrays ...
1313 protected $smwContentMessages;
1414 protected $smwUserMessages;
15 - protected $smwDatatypeLabels;
1615 protected $smwSpecialProperties;
 16+ protected $m_DatatypeLabels;
 17+ protected $m_DatatypeAliases = array();
1718
1819 /**
1920 * Function that returns an array of namespace identifiers.
@@ -20,7 +21,26 @@
2122 abstract function getNamespaceArray();
2223
2324 /**
 25+ * Return all labels that are available as names for built-in datatypes. Those
 26+ * are the types that users can access via [[has type::...]] (more built-in
 27+ * types may exist for internal purposes but the user won't need to
 28+ * know this). The returned array is indexed by (internal) type ids.
 29+ */
 30+ function getDatatypeLabels() {
 31+ return $this->m_DatatypeLabels;
 32+ }
 33+
 34+ /**
 35+ * Return an array that maps aliases to internal type ids. All ids used here
 36+ * should also have a primary label defined in m_DatatypeLabels.
 37+ */
 38+ function getDatatypeAliases() {
 39+ return $this->m_DatatypeAliases;
 40+ }
 41+
 42+ /**
2443 * Function that returns the localised label for a datatype.
 44+ * @DEPRECATED
2545 */
2646 function getDatatypeLabel($msgid) {
2747 return $this->smwDatatypeLabels[$msgid];
@@ -31,6 +51,7 @@
3252 * are exactly the types that users can access via [[has type::...]] (more
3353 * built-in types may exist for internal purposes but the user won't need to
3454 * know this).
 55+ * @DEPRECATED
3556 */
3657 function getAllDatatypeLabels() {
3758 return $this->smwDatatypeLabels;
@@ -40,6 +61,7 @@
4162 * Find the internal message id of some localised message string
4263 * for a datatype. If no type of the given name exists (maybe a
4364 * custom of compound type) then FALSE is returned.
 65+ * @DEPRECATED
4466 */
4567 function findDatatypeMsgID($label) {
4668 return array_search($label, $this->smwDatatypeLabels);
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageEn.php
@@ -179,21 +179,21 @@
180180 'smw_result_noresults' => 'Sorry, no results.'
181181 );
182182
183 -protected $smwDatatypeLabels = array(
184 - 'smw_wikipage' => 'Page', // name of page datatype
185 - 'smw_string' => 'String', // name of the string type
186 - 'smw_text' => 'Text', // name of the text type
187 - 'smw_enum' => 'Enumeration', // name of the enum type
188 - 'smw_bool' => 'Boolean', // name of the boolean type
189 - 'smw_int' => 'Integer', // name of the int type
190 - 'smw_float' => 'Float', // name of the floating point type
191 - 'smw_geocoordinate' => 'Geographic coordinate', // name of the geocoord type
192 - 'smw_temperature' => 'Temperature', // name of the temperature type
193 - 'smw_datetime' => 'Date', // name of the datetime (calendar) type
194 - 'smw_email' => 'Email', // name of the email (URI) type
195 - 'smw_url' => 'URL', // name of the URL type (string datatype property)
196 - 'smw_uri' => 'URI', // name of the URI type (object property)
197 - 'smw_annouri' => 'Annotation URI' // name of the annotation URI type (annotation property)
 183+protected $m_DatatypeLabels = array(
 184+ '_wpg' => 'Page', // name of page datatype
 185+ '_str' => 'String', // name of the string type
 186+ '_txt' => 'Text', // name of the text type
 187+ '_enu' => 'Enumeration', // name of the enum type
 188+ //'_boo' => 'Boolean', // name of the boolean type
 189+ '_int' => 'Integer', // name of the int type
 190+ '_flt' => 'Float', // name of the floating point type
 191+ '_geo' => 'Geographic coordinate', // name of the geocoord type
 192+ '_tem' => 'Temperature', // name of the temperature type
 193+ '_dat' => 'Date', // name of the datetime (calendar) type
 194+ '_ema' => 'Email', // name of the email (URI) type
 195+ '_url' => 'URL', // name of the URL type (string datatype property)
 196+ '_uri' => 'URI', // name of the URI type (object property)
 197+ '_anu' => 'Annotation URI' // name of the annotation URI type (annotation property)
198198 );
199199
200200 protected $smwSpecialProperties = array(
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageRu.php
@@ -195,23 +195,37 @@
196196 'smw_result_noresults' => 'Извините, но ничего не найдено.'
197197 );
198198
199 -protected $smwDatatypeLabels = array(
200 - 'smw_wikipage' => 'Page', // name of page datatype //TODO translate
201 - 'smw_string' => 'Строка', // name of the string type
202 - 'smw_text' => 'Text', // name of the text type (very long strings) //TODO: translate
203 - 'smw_enum' => 'Перечисление', // name of the enum type
204 - 'smw_bool' => 'Булево', // name of the boolean type
205 - 'smw_int' => 'Целое', // name of the int type
206 - 'smw_float' => 'Десятичное', // name of the floating point type
207 - 'smw_geocoordinate' => 'Географическая координата', // name of the geocoord type
208 - 'smw_temperature' => 'Температура', // name of the temperature type
209 - 'smw_datetime' => 'Дата', // name of the datetime (calendar) type
210 - 'smw_email' => 'Почта', // name of the email (URI) type
211 - 'smw_url' => 'URL', // name of the URL type (string datatype property)
212 - 'smw_uri' => 'URI', // name of the URI type (object property)
213 - 'smw_annouri' => 'URI аннотации' // name of the annotation URI type (annotation property)
 199+protected $m_DatatypeLabels = array(
 200+ '_wpg' => 'Page', // name of page datatype //TODO translate
 201+ '_str' => 'Строка', // name of the string type
 202+ '_txt' => 'Text', // name of the text type (very long strings) //TODO: translate
 203+ '_enu' => 'Перечисление', // name of the enum type
 204+ '_boo' => 'Булево', // name of the boolean type
 205+ '_int' => 'Целое', // name of the int type
 206+ '_flt' => 'Десятичное', // name of the floating point type
 207+ '_geo' => 'Географическая координата', // name of the geocoord type
 208+ '_tem' => 'Температура', // name of the temperature type
 209+ '_dat' => 'Дата', // name of the datetime (calendar) type
 210+ '_ema' => 'Почта', // name of the email (URI) type
 211+ '_url' => 'URL', // name of the URL type (string datatype property)
 212+ '_uri' => 'URI', // name of the URI type (object property)
 213+ '_anu' => 'URI аннотации' // name of the annotation URI type (annotation property)
214214 );
215215
 216+protected $m_DatatypeAliases = array(
 217+ // support English aliases:
 218+ 'Page' => '_wpg',
 219+ 'String' => '_str',
 220+ 'Text' => '_txt',
 221+ 'Integer' => '_int',
 222+ 'Float' => '_flt',
 223+ 'Geographic coordinate' => '_geo',
 224+ 'Temperature' => '_tem',
 225+ 'Date' => '_dat',
 226+ 'Email' => '_ema',
 227+ 'Annotation URI' => '_anu'
 228+);
 229+
216230 protected $smwSpecialProperties = array(
217231 //always start upper-case
218232 SMW_SP_HAS_TYPE => 'Имеет тип',

Status & tagging log