r60507 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60506‎ | r60507 | r60508 >
Date:12:42, 30 December 2009
Author:mkroetzsch
Status:deferred
Tags:
Comment:
Added Type:Telephone number for tel: URIs (Bug 20503)
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_URI.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DataValueFactory.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageAr.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageArz.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_LanguageIt.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageNl.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageNo.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/languages/SMW_LanguagePl.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/languages/SMW_LanguagePt.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageRu.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageSk.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageZh_cn.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageZh_tw.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_URI.php
@@ -7,9 +7,10 @@
88 define('SMW_URI_MODE_EMAIL',1);
99 define('SMW_URI_MODE_URI',3);
1010 define('SMW_URI_MODE_ANNOURI',4);
 11+define('SMW_URI_MODE_TEL',5);
1112
1213 /**
13 - * This datavalue implements URL/URI/ANNURI/EMAIL-Datavalues suitable for defining
 14+ * This datavalue implements URL/URI/ANNURI/PHONE/EMAIL-Datavalues suitable for defining
1415 * the respective types of properties.
1516 *
1617 * @author Nikolas Iwan
@@ -37,6 +38,9 @@
3839 case '_anu':
3940 $this->m_mode = SMW_URI_MODE_ANNOURI;
4041 break;
 42+ case '_tel':
 43+ $this->m_mode = SMW_URI_MODE_TEL;
 44+ break;
4145 case '_uri': case '_url': case '__spu': default:
4246 $this->m_mode = SMW_URI_MODE_URI;
4347 break;
@@ -114,6 +118,24 @@
115119 }
116120 }
117121 break;
 122+ case SMW_URI_MODE_TEL:
 123+ if (substr($value, 0, 4) === 'tel:') {
 124+ $value = substr($value, 4);
 125+ $this->m_value = $value;
 126+ }
 127+ $value = preg_replace('/(?<=[0-9]) (?=[0-9])/', '\1-\2', $value);
 128+ $value = str_replace(' ', '', $value);
 129+ if (substr($value, 0, 2) == '00') {
 130+ $value = '+' . substr($value, 2);
 131+ }
 132+ $value = 'tel:' . $value;
 133+ if ( (strlen(preg_replace('/[^0-9]/', '', $value)) < 6) ||
 134+ (preg_match('<[-+./][-./]>', $value)) ||
 135+ (!SMWURIValue::isValidTelURI($value)) ) { ///TODO: introduce error-message for "bad" phone number
 136+ $this->addError(wfMsgForContent('smw_baduri', $this->m_value));
 137+ }
 138+ $this->m_uri = $value;
 139+ break;
118140 case SMW_URI_MODE_EMAIL:
119141 if (strpos($value,'mailto:') === 0) { // accept optional "mailto"
120142 $value = substr($value, 7);
@@ -135,6 +157,17 @@
136158 return true;
137159 }
138160
 161+ /**
 162+ * Returns true if the argument is a valid RFC 3966 phone number.
 163+ * Only global phone numbers are supported, and no full validation
 164+ * of parameters (appended via ;param=value) is performed.
 165+ */
 166+ protected static function isValidTelURI($s) {
 167+ $tel_uri_regex = '<^tel:\+[0-9./-]*[0-9][0-9./-]*(;[0-9a-zA-Z-]+=(%[0-9a-zA-Z][0-9a-zA-Z]|[0-9a-zA-Z._~:/?#[\]@!$&\'()*+,;=-])*)*$>';
 168+ return (bool) preg_match($tel_uri_regex, $s);
 169+ }
 170+
 171+
139172 protected function parseDBkeys($args) {
140173 $this->m_uri = $args[0];
141174 $this->m_value = $this->m_uri;
@@ -148,6 +181,12 @@
149182 $this->m_uri = 'mailto:' . $this->m_value;
150183 $this->m_url = $this->m_uri;
151184 }
 185+ } elseif ($this->m_mode == SMW_URI_MODE_TEL) {
 186+ $this->m_url = $this->m_value;
 187+ if (strpos($this->m_uri,'tel:') === 0) { // catch inconsistencies in DB, should usually be the case
 188+ $this->m_caption = substr($this->m_value, 4);
 189+ $this->m_value = $this->m_caption;
 190+ }
152191 } else {
153192 $parts = explode(':', $this->m_uri, 2); // try to split "schema:rest"
154193 global $wgUrlProtocols;
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DataValueFactory.php
@@ -118,6 +118,7 @@
119119 '_ema' => 'SMWURIValue', // Email type
120120 '_uri' => 'SMWURIValue', // URL/URI type
121121 '_anu' => 'SMWURIValue', // Annotation URI type
 122+ '_tel' => 'SMWURIValue', // Phone number (URI) type
122123 '_wpg' => 'SMWWikiPageValue', // Page type
123124 '_wpp' => 'SMWWikiPageValue', // Property page type TODO: make available to user space
124125 '_wpc' => 'SMWWikiPageValue', // Category page type TODO: make available to user space
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageZh_cn.php
@@ -37,6 +37,7 @@
3838 '_ema' => 'Email', //'Email', // name of the email type
3939 '_uri' => 'URL', //'URL', // name of the URL type
4040 '_anu' => 'URI的注解', //'Annotation URI' // name of the annotation URI type (OWL annotation property)
 41+ '_tel' => 'Telephone number', // name of the telephone (URI) type //TODO: translate
4142 );
4243
4344 protected $m_DatatypeAliases = array(
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageAr.php
@@ -34,7 +34,8 @@
3535 '_dat' => 'التاريخ', // name of the datetime (calendar) type
3636 '_ema' => 'البريد الإلكتروني', // name of the email type
3737 '_uri' => 'مسار', // name of the URL type
38 - '_anu' => 'التعليق علي معرف الموارد الموحد' // name of the annotation URI type (OWL annotation property)
 38+ '_anu' => 'التعليق علي معرف الموارد الموحد', // name of the annotation URI type (OWL annotation property)
 39+ '_tel' => 'Telephone number', // name of the telephone (URI) type //TODO: translate
3940 );
4041
4142 protected $m_DatatypeAliases = array(
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageEn.php
@@ -37,14 +37,16 @@
3838 '_dat' => 'Date', // name of the datetime (calendar) type
3939 '_ema' => 'Email', // name of the email type
4040 '_uri' => 'URL', // name of the URL type
41 - '_anu' => 'Annotation URI' // name of the annotation URI type (OWL annotation property)
 41+ '_anu' => 'Annotation URI', // name of the annotation URI type (OWL annotation property)
 42+ '_tel' => 'Telephone number', // name of the telephone (URI) type
4243 );
4344
4445 protected $m_DatatypeAliases = array(
4546 'URI' => '_uri',
4647 'Float' => '_num',
4748 'Integer' => '_num',
48 - 'Enumeration' => '_str'
 49+ 'Enumeration' => '_str',
 50+ 'Phone number'=> '_tel',
4951 );
5052
5153 protected $m_SpecialProperties = array(
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageEs.php
@@ -34,7 +34,8 @@
3535 '_dat' => 'Fecha', // name of the datetime (calendar) type
3636 '_ema' => 'Dirección electrónica', // name of the email type
3737 '_uri' => 'URL', // name of the URL type
38 - '_anu' => 'Anotación-URI' // name of the annotation URI type (OWL annotation property)
 38+ '_anu' => 'Anotación-URI', // name of the annotation URI type (OWL annotation property)
 39+ '_tel' => 'Telephone number', // name of the telephone (URI) type //TODO: translate
3940 );
4041
4142 protected $m_DatatypeAliases = array(
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageFr.php
@@ -34,7 +34,8 @@
3535 '_dat' => 'Date', // name of the datetime (calendar) type
3636 '_ema' => 'Adresse électronique', // name of the email type
3737 '_uri' => 'URL', // name of the URI type
38 - '_anu' => 'Annotation-URI' // name of the annotation URI type (OWL annotation property)
 38+ '_anu' => 'Annotation-URI', // name of the annotation URI type (OWL annotation property)
 39+ '_tel' => 'Telephone number', // name of the telephone (URI) type //TODO: translate
3940 );
4041
4142 protected $m_DatatypeAliases = array(
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageNl.php
@@ -36,7 +36,8 @@
3737 '_dat' => 'Datum', // name of the datetime (calendar) type
3838 '_ema' => 'E-mail', // name of the email type
3939 '_uri' => 'URL', // name of the URL type
40 - '_anu' => 'Annotatie URI' // name of the annotation URI type (OWL annotation property)
 40+ '_anu' => 'Annotatie URI', // name of the annotation URI type (OWL annotation property)
 41+ '_tel' => 'Telephone number', // name of the telephone (URI) type //TODO: translate
4142 );
4243
4344 protected $m_DatatypeAliases = array(
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguagePl.php
@@ -53,7 +53,8 @@
5454 '_dat' => 'Data', // name of the datetime (calendar) type
5555 '_ema' => 'Email', // name of the email type
5656 '_uri' => 'URL', // name of the URL type
57 - '_anu' => 'URI adnotacji' // name of the annotation URI type (OWL annotation property)
 57+ '_anu' => 'URI adnotacji', // name of the annotation URI type (OWL annotation property)
 58+ '_tel' => 'Telephone number', // name of the telephone (URI) type //TODO: translate
5859 );
5960
6061 protected $m_DatatypeAliases = array(
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageIt.php
@@ -35,7 +35,8 @@
3636 '_dat' => 'Data', // name of the datetime (calendar) type
3737 '_ema' => 'Email', // name of the email type
3838 '_uri' => 'URL', // name of the URL type
39 - '_anu' => 'Annotazione URI' // name of the annotation URI type (OWL annotation property)
 39+ '_anu' => 'Annotazione URI', // name of the annotation URI type (OWL annotation property)
 40+ '_tel' => 'Telephone number', // name of the telephone (URI) type //TODO: translate
4041 );
4142
4243 protected $m_DatatypeAliases = array(
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageNo.php
@@ -34,7 +34,8 @@
3535 '_dat' => 'Dato', // name of the datetime (calendar) type
3636 '_ema' => 'E-post', // name of the email type
3737 '_uri' => 'URL', // name of the URL type
38 - '_anu' => 'URI-merknad' // name of the annotation URI type (OWL annotation property)
 38+ '_anu' => 'URI-merknad', // name of the annotation URI type (OWL annotation property)
 39+ '_tel' => 'Telephone number', // name of the telephone (URI) type //TODO: translate
3940 );
4041
4142 protected $m_DatatypeAliases = array(
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageSk.php
@@ -34,7 +34,8 @@
3535 '_dat' => 'Dátum', // name of the datetime (calendar) type
3636 '_ema' => 'Email', // name of the email type
3737 '_uri' => 'URL', // name of the URL type
38 - '_anu' => 'URI anotácie' // name of the annotation URI type (OWL annotation property)
 38+ '_anu' => 'URI anotácie', // name of the annotation URI type (OWL annotation property)
 39+ '_tel' => 'Telephone number', // name of the telephone (URI) type //TODO: translate
3940 );
4041
4142 protected $m_DatatypeAliases = array(
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguagePt.php
@@ -34,7 +34,8 @@
3535 '_dat' => 'Data', // name of the datetime (calendar) type
3636 '_ema' => 'Email', // name of the email type (Portuguese does not have another word for this)
3737 '_uri' => 'URL', // name of the URI type
38 - '_anu' => 'Anotação-URI' // name of the annotation URI type (OWL annotation property)
 38+ '_anu' => 'Anotação-URI', // name of the annotation URI type (OWL annotation property)
 39+ '_tel' => 'Telephone number', // name of the telephone (URI) type //TODO: translate
3940 );
4041
4142 protected $m_DatatypeAliases = array(
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageRu.php
@@ -34,7 +34,8 @@
3535 '_dat' => 'Дата', // name of the datetime (calendar) type
3636 '_ema' => 'Почта', // name of the email type
3737 '_uri' => 'URL', // name of the URL type
38 - '_anu' => 'URI аннотации' // name of the annotation URI type (OWL annotation property)
 38+ '_anu' => 'URI аннотации', // name of the annotation URI type (OWL annotation property)
 39+ '_tel' => 'Telephone number', // name of the telephone (URI) type //TODO: translate
3940 );
4041
4142 protected $m_DatatypeAliases = array(
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageDe.php
@@ -42,7 +42,8 @@
4343 '_dat' => 'Datum', // name of the datetime (calendar) type
4444 '_ema' => 'Email', // name of the email type
4545 '_uri' => 'URL', // name of the URL type
46 - '_anu' => 'URI-Annotation' // name of the annotation URI type (OWL annotation property)
 46+ '_anu' => 'URI-Annotation', // name of the annotation URI type (OWL annotation property)
 47+ '_tel' => 'Telefonnummer', // name of the telephone number URI datatype
4748 );
4849
4950 protected $m_DatatypeAliases = array(
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageZh_tw.php
@@ -35,6 +35,7 @@
3636 '_ema' => 'Email', //'Email', // name of the email type
3737 '_uri' => 'URL', //'URL', // name of the URL type
3838 '_anu' => 'URI的註解', //'Annotation URI' // name of the annotation URI type (OWL annotation property)
 39+ '_tel' => 'Telephone number', // name of the telephone (URI) type //TODO: translate
3940 );
4041
4142 protected $m_DatatypeAliases = array(
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageHe.php
@@ -34,7 +34,8 @@
3535 '_dat' => 'תאריך', // name of the datetime (calendar) type
3636 '_ema' => 'דואל', // name of the email (URI) type
3737 '_uri' => 'כתובת כללית', // name of the URL type
38 - '_anu' => 'מזהה יחודי לפירוש' // name of the annotation URI type (OWL annotation property)
 38+ '_anu' => 'מזהה יחודי לפירוש', // name of the annotation URI type (OWL annotation property)
 39+ '_tel' => 'Telephone number', // name of the telephone (URI) type //TODO: translate
3940 );
4041
4142 protected $m_DatatypeAliases = array(
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageArz.php
@@ -34,7 +34,8 @@
3535 '_dat' => 'التاريخ', // name of the datetime (calendar) type
3636 '_ema' => 'البريد الإلكترونى', // name of the email type
3737 '_uri' => 'مسار', // name of the URL type
38 - '_anu' => 'التعليق علي معرف الموارد الموحد' // name of the annotation URI type (OWL annotation property)
 38+ '_anu' => 'التعليق علي معرف الموارد الموحد', // name of the annotation URI type (OWL annotation property)
 39+ '_tel' => 'Telephone number', // name of the telephone (URI) type //TODO: translate
3940 );
4041
4142 protected $m_DatatypeAliases = array(

Status & tagging log