r26500 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r26499‎ | r26500 | r26501 >
Date:14:17, 8 October 2007
Author:mkroetzsch
Status:old
Tags:
Comment:
Simplified code.
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_String.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_String.php
@@ -10,21 +10,19 @@
1111 */
1212 class SMWStringValue extends SMWDataValue {
1313
14 - private $m_value = '';
15 - private $m_xsdvalue = '';
 14+ protected $m_value = ''; // XML-safe, HTML-safe, Wiki-compatible value representation
1615
1716 protected function parseUserValue($value) {
1817 if ($value!='') {
19 - $this->m_xsdvalue = smwfXMLContentEncode($value);
20 - if ( (strlen($this->m_xsdvalue) > 255) && ($this->m_typeid !== '_txt') ) { // limit size (for DB indexing)
21 - $this->addError(wfMsgForContent('smw_maxstring', mb_substr($value, 0, 42) . ' <span class="smwwarning">[&hellip;]</span> ' . mb_substr($value, mb_strlen($this->m_xsdvalue) - 42)));
 18+ $this->m_value = smwfXMLContentEncode($value);
 19+ if ( (strlen($this->m_value) > 255) && ($this->m_typeid !== '_txt') ) { // limit size (for DB indexing)
 20+ $this->addError(wfMsgForContent('smw_maxstring', mb_substr($value, 0, 42) . ' <span class="smwwarning">[&hellip;]</span> ' . mb_substr($value, mb_strlen($this->m_value) - 42)));
2221 }
23 - $this->m_value = $this->m_xsdvalue;
2422 } else {
2523 $this->addError(wfMsgForContent('smw_emptystring'));
2624 }
2725 if ($this->m_caption === false) {
28 - $this->m_caption = $this->m_value;
 26+ $this->m_caption = $value;
2927 }
3028 return true;
3129 }
@@ -64,7 +62,7 @@
6563 }
6664
6765 public function getXSDValue() {
68 - return $this->m_xsdvalue;
 66+ return $this->m_value;
6967 }
7068
7169 public function getWikiValue(){
@@ -80,7 +78,7 @@
8179 }
8280
8381 public function getHash() {
84 - return $this->getLongWikiText(false) . $this->m_xsdvalue ;
 82+ return $this->getLongWikiText(false) . $this->m_value;
8583 }
8684
8785 public function isNumeric() {
@@ -102,7 +100,7 @@
103101 * @return the line to be exported
104102 */
105103 public function exportToRDF($QName, ExportRDF $exporter) {
106 - return "\t\t<$QName rdf:datatype=\"http://www.w3.org/2001/XMLSchema#string\">$this->m_xsdvalue</$QName>\n";
 104+ return "\t\t<$QName rdf:datatype=\"http://www.w3.org/2001/XMLSchema#string\">$this->m_value</$QName>\n";
107105 }
108106
109107 /**

Status & tagging log