r36808 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r36807‎ | r36808 | r36809 >
Date:09:21, 30 June 2008
Author:mkroetzsch
Status:old
Tags:
Comment:
New datatype "Code" (minor variant of "Text", trying to preserve input literally, preventing automated
markup and modified display)
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_String.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DataValueFactory.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.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_LanguageKo.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/languages/SMW_LanguageZh_cn.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageZh_tw.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore.php
@@ -79,7 +79,7 @@
8080 case '_wpg':
8181 $do_rels = true;
8282 break;
83 - case '_txt':
 83+ case '_txt': case '_cod':
8484 $do_text = true;
8585 break;
8686 case '__nry':
@@ -442,7 +442,7 @@
443443 $result = array();
444444 $id = SMWDataValueFactory::getPropertyObjectTypeID($property);
445445 switch ($id) {
446 - case '_txt':
 446+ case '_txt': case '_cod':
447447 $res = $db->select( $db->tableName('smw_longstrings'),
448448 'value_blob',
449449 $subjectcond .
@@ -568,7 +568,7 @@
569569 $db =& wfGetDB( DB_SLAVE );
570570
571571 switch ($value->getTypeID()) {
572 - case '_txt': // not supported
 572+ case '_txt': case '_cod': // not supported
573573 wfProfileOut("SMWSQLStore::getPropertySubjects (SMW)");
574574 return array();
575575 break;
@@ -595,7 +595,7 @@
596596 continue;
597597 }
598598 switch ($dv->getTypeID()) {
599 - case '_txt': // not supported
 599+ case '_txt': case '_cod': // not supported
600600 break;
601601 case '_wpg':
602602 $from .= ' INNER JOIN ' . $db->tableName('smw_nary_relations') . ' AS nary' . $count .
@@ -643,7 +643,7 @@
644644 $db =& wfGetDB( DB_SLAVE );
645645 $id = SMWDataValueFactory::getPropertyObjectTypeID($property);
646646 switch ($id) {
647 - case '_txt':
 647+ case '_txt': case '_cod':
648648 $tablename = 'smw_longstrings';
649649 $pcolumn = 'attribute_title';
650650 $extraconds = '';
@@ -797,7 +797,7 @@
798798 if ($property instanceof Title) { // normal property
799799 foreach($propertyValueArray as $value) {
800800 if ($value->isValid()) {
801 - if ($value->getTypeID() == '_txt') {
 801+ if ( ($value->getTypeID() == '_txt') || ($value->getTypeID() == '_cod') ){
802802 $up_longstrings[] =
803803 array( 'subject_id' => $subject->getArticleID(),
804804 'subject_namespace' => $subject->getNamespace(),
@@ -837,7 +837,7 @@
838838 'object_title' => $dv->getDBkey(),
839839 'object_id' => $oid );
840840 break;
841 - case '_txt':
 841+ case '_txt': case '_cod':
842842 $up_nary_longstrings[] =
843843 array( 'subject_id' => $subject->getArticleID(),
844844 'nary_key' => $nkey,
@@ -1924,7 +1924,7 @@
19251925 }
19261926 } elseif ($description instanceof SMWValueDescription) {
19271927 switch ($description->getDatavalue()->getTypeID()) {
1928 - case '_txt': // possibly pull in longstring table (for naries)
 1928+ case '_txt': case '_cod': // possibly pull in longstring table (for naries)
19291929 $this->addJoin('pTEXT', $from, $db, $curtables, $nary_pos);
19301930 break;
19311931 case '_wpg':
@@ -2045,7 +2045,7 @@
20462046 $sortfield = 'object_title';
20472047 }
20482048 break;
2049 - case '_txt':
 2049+ case '_txt': case '_cod':
20502050 $tablename = 'TEXT';
20512051 $pcolumn = 'attribute_title';
20522052 $sub = false; //no recursion: we do not support further conditions on text-type values
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php
@@ -67,7 +67,8 @@
6868 foreach ($filter as $value) {
6969 switch ($value) {
7070 case '_wpg': $tasks = $tasks | SMW_SQL2_RELS2; break;
71 - case '_txt': $tasks = $tasks | SMW_SQL2_TEXT2; break;
 71+ case '_txt': case '_cod':
 72+ $tasks = $tasks | SMW_SQL2_TEXT2; break;
7273 case '__nry': $tasks = $tasks | SMW_SQL2_NARY2; break;
7374 case SMW_SP_INSTANCE_OF: $tasks = $tasks | SMW_SQL2_INST2; break;
7475 case SMW_SP_REDIRECTS_TO: $tasks = $tasks | SMW_SQL2_REDI2; break;
@@ -387,7 +388,7 @@
388389 }
389390
390391 switch ($typeid) {
391 - case '_txt': break; // not supported
 392+ case '_txt': case '_cod': break; // not supported
392393 case '_wpg': // wikipage
393394 if ($value !== NULL) {
394395 $oid = $this->getSMWPageID($value->getDBkey(),$value->getNamespace(),$value->getInterwiki());
@@ -416,7 +417,7 @@
417418 }
418419 $npid = $this->makeSMWPageID(strval($count),SMW_NS_PROPERTY,SMW_SQL2_SMWIW); // might be cached
419420 switch ($dv->getTypeID()) {
420 - case '_txt': break; // not supported
 421+ case '_txt': case '_cod': break; // not supported
421422 case '_wpg':
422423 $from .= " INNER JOIN $smw_rels2 AS t$count ON t.o_id=t$count.s_id INNER JOIN $smw_ids AS i$count ON t$count.o_id=i$count.smw_id";
423424 $where .= " AND t$count.p_id=" . $db->addQuotes($npid) .
@@ -560,7 +561,7 @@
561562 if ($property instanceof Title) { // normal property
562563 foreach($propertyValueArray as $value) {
563564 if ($value->isValid()) {
564 - if ($value->getTypeID() == '_txt') {
 565+ if ( ($value->getTypeID() == '_txt') || ($value->getTypeID() == '_cod') ){
565566 $up_text2[] =
566567 array( 's_id' => $sid,
567568 'p_id' => $this->makeSMWPageID($property->getDBkey(),SMW_NS_PROPERTY,''),
@@ -587,7 +588,7 @@
588589 'p_id' => $pid,
589590 'o_id' => $this->makeSMWPageID($dv->getDBkey(),$dv->getNamespace(),$dv->getInterwiki()) );
590591 break;
591 - case '_txt':
 592+ case '_txt': case '_cod':
592593 $up_text2[] =
593594 array( 's_id' => $bnode,
594595 'p_id' => $pid,
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DataValueFactory.php
@@ -248,9 +248,10 @@
249249 $wgAutoloadClasses['SMWLinearValue'] = $smwgIP . '/includes/SMW_DV_Linear.php';
250250 $wgAutoloadClasses['SMWTimeValue'] = $smwgIP . '/includes/SMW_DV_Time.php';
251251 $wgAutoloadClasses['SMWGeoCoordsValue'] = $smwgIP . '/includes/SMW_DV_GeoCoords.php';
252 - $wgAutoloadClasses['SMWBoolValue'] = $smwgIP . '/includes/SMW_DV_Bool.php';
 252+ $wgAutoloadClasses['SMWBoolValue'] = $smwgIP . '/includes/SMW_DV_Bool.php';
253253 SMWDataValueFactory::$m_typeclasses = array(
254254 '_txt' => 'SMWStringValue',
 255+ '_cod' => 'SMWStringValue',
255256 '_str' => 'SMWStringValue',
256257 '_ema' => 'SMWURIValue',
257258 '_uri' => 'SMWURIValue',
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_String.php
@@ -16,14 +16,14 @@
1717 protected function parseUserValue($value) {
1818 if ($value!='') {
1919 $this->m_value = smwfXMLContentEncode($value);
20 - if ( (strlen($this->m_value) > 255) && ($this->m_typeid !== '_txt') ) { // limit size (for DB indexing)
 20+ if ( (strlen($this->m_value) > 255) && ($this->m_typeid == '_str') ) { // limit size (for DB indexing)
2121 $this->addError(wfMsgForContent('smw_maxstring', mb_substr($value, 0, 42) . ' <span class="smwwarning">[&hellip;]</span> ' . mb_substr($value, mb_strlen($this->m_value) - 42)));
2222 }
2323 } else {
2424 $this->addError(wfMsgForContent('smw_emptystring'));
2525 }
2626 if ($this->m_caption === false) {
27 - $this->m_caption = $value;
 27+ $this->m_caption = ($this->m_typeid=='_cod')?$this->getCodeDisplay($value):$value;
2828 }
2929 return true;
3030 }
@@ -67,7 +67,7 @@
6868 }
6969
7070 public function getInfolinks() {
71 - if ($this->m_typeid !== '_txt') {
 71+ if ($this->m_typeid == '_str') {
7272 return SMWDataValue::getInfolinks();
7373 }
7474 return $this->m_infolinks;
@@ -77,7 +77,7 @@
7878 // Create links to mapping services based on a wiki-editable message. The parameters
7979 // available to the message are:
8080 // $1: urlencoded string
81 - if ($this->m_typeid === '_txt') {
 81+ if ($this->m_typeid == '_str') {
8282 return false; // no services for Type:Text
8383 } else {
8484 return array(rawurlencode($this->m_value));
@@ -98,17 +98,31 @@
9999 */
100100 protected function getAbbValue($linked) {
101101 $len = mb_strlen($this->m_value);
102 - if ($len > 255) {
 102+ $starttag = ($this->m_typeid=='_cod')?'<pre>':'';
 103+ $endtag = ($this->m_typeid=='_cod')?'</pre>':'';
 104+ if ( ($len > 255) && ($this->m_typeid != '_cod') ) {
103105 if ( ($linked === NULL)||($linked === false) ) {
104106 return mb_substr($this->m_value, 0, 42) . ' <span class="smwwarning">&hellip;</span> ' . mb_substr($this->m_value, $len - 42);
105107 } else {
106108 smwfRequireHeadItem(SMW_HEADER_TOOLTIP);
107109 return mb_substr($this->m_value, 0, 42) . ' <span class="smwttpersist"> &hellip; <span class="smwttcontent">' . $this->m_value . '</span></span> ' . mb_substr($this->m_value, $len - 42);
108110 }
 111+ } elseif ($len > 255) {
 112+ return $this->getCodeDisplay($this->m_value,true);
109113 } else {
110114 return $this->m_value;
111115 }
112116 }
113117
 118+ /**
 119+ * Special features for Type:Code formating.
 120+ */
 121+ protected function getCodeDisplay($value, $scroll = false) {
 122+ $result = str_replace( array('<', '>', ' ','://'), array('&lt;', '&gt;', '&nbsp;', '<!-- -->://<!-- -->'), $value);
 123+ if ($scroll) {
 124+ $result = "<div style=\"height:5em; overflow:auto;\">$result</div>";
 125+ }
 126+ return "<pre>$result</pre>";
 127+ }
114128
115129 }
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageZh_cn.php
@@ -18,6 +18,7 @@
1919 '_wpg' => '页面', //'Page', // name of page datatype
2020 '_str' => '字串', //'String', // name of the string type
2121 '_txt' => '文字', //'Text', // name of the text type
 22+ '_cod' => 'Code', // name of the (source) code type //TODO: translate
2223 '_boo' => '布林', //'Boolean', // name of the boolean type
2324 '_num' => '数字', //'Number', // name for the datatype of numbers
2425 '_geo' => '地理学的座标', //'Geographic coordinate', // name of the geocoord type
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageAr.php
@@ -19,6 +19,7 @@
2020 '_wpg' => 'الصفحة', // name of page datatype
2121 '_str' => 'سلسلة أحرف', // name of the string type
2222 '_txt' => 'نص', // name of the text type
 23+ '_cod' => 'Code', // name of the (source) code type //TODO: translate
2324 '_boo' => 'منطقي', // name of the boolean type
2425 '_num' => 'عدد', // name for the datatype of numbers
2526 '_geo' => 'الإحداثيات', // name of the geocoord type
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageEn.php
@@ -18,6 +18,7 @@
1919 '_wpg' => 'Page', // name of page datatype
2020 '_str' => 'String', // name of the string type
2121 '_txt' => 'Text', // name of the text type
 22+ '_cod' => 'Code', // name of the (source) code type
2223 '_boo' => 'Boolean', // name of the boolean type
2324 '_num' => 'Number', // name for the datatype of numbers
2425 '_geo' => 'Geographic coordinate', // name of the geocoord type
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageEs.php
@@ -18,6 +18,7 @@
1919 '_wpg' => 'Page', // name of page datatype //TODO translate
2020 '_str' => 'Cadena de caracteres', // name of the string type
2121 '_txt' => 'Texto', // name of the text type (very long strings)
 22+ '_cod' => 'Code', // name of the (source) code type //TODO: translate
2223 '_boo' => 'Booleano', // name of the boolean type
2324 '_num' => 'Número', // name for the datatype of numbers
2425 '_geo' => 'Coordenadas geográficas', // name of the geocoord type
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageFr.php
@@ -18,6 +18,7 @@
1919 '_wpg' => 'Page', // name of page datatype
2020 '_str' => 'Chaîne de caractères', // name of the string type
2121 '_txt' => 'Texte', // name of the text type (very long strings)
 22+ '_cod' => 'Code', // name of the (source) code type //TODO: translate
2223 '_boo' => 'Booléen', // name of the boolean type
2324 '_num' => 'Nombre', // name for the datatype of numbers
2425 '_geo' => 'Coordonnées géographiques', // name of the geocoord type
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageKo.php
@@ -21,6 +21,7 @@
2222 '_wpg' => '인공', // name of page datatype
2323 '_str' => '배열의 문자', // name of the string type
2424 '_txt' => '텍스트', // name of the text type
 25+ '_cod' => 'Code', // name of the (source) code type //TODO: translate
2526 '_boo' => '부울', // name of the boolean type
2627 '_num' => '번호', // name for the datatype of numbers
2728 '_geo' => '지리적 좌표', // name of the geocoord type
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageNl.php
@@ -18,6 +18,7 @@
1919 '_wpg' => 'Pagina', // name of page datatype
2020 '_str' => 'String', // name of the string type
2121 '_txt' => 'Tekst', // name of the text type
 22+ '_cod' => 'Code', // name of the (source) code type //TODO: translate
2223 '_boo' => 'Booleans', // name of the boolean type
2324 '_num' => 'Number', // name for the datatype of numbers // TODO: translate
2425 '_geo' => 'Geographische coordinaat', // name of the geocoord type
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguagePl.php
@@ -38,6 +38,7 @@
3939 '_wpg' => 'Page', // name of page datatype //TODO translate
4040 '_str' => 'Łańcuch znaków', // name of the string type
4141 '_txt' => 'Text', // name of the text type (very long strings) //TODO: translate
 42+ '_cod' => 'Code', // name of the (source) code type //TODO: translate
4243 '_boo' => 'Wartość logiczna', // name of the boolean type
4344 '_num' => 'Liczba', // name for the datatype of numbers // TODO: check translation (done by pattern matching. mak)
4445 '_geo' => 'Współrzędne geograficzne', // name of the geocoord type
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageIt.php
@@ -18,6 +18,7 @@
1919 '_wpg' => 'Pagina', // name of page datatypee
2020 '_str' => 'Stringa', //name of the string type
2121 '_txt' => 'Testo', // name of the text type
 22+ '_cod' => 'Code', // name of the (source) code type //TODO: translate
2223 '_boo' => 'Booleano', // name of the boolean type
2324 '_num' => 'Numero', // name for the datatype of numbers
2425 '_geo' => 'Coordinate geografiche', // name of the geocoord type
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageSk.php
@@ -18,6 +18,7 @@
1919 '_wpg' => 'Page', // name of page datatype //TODO translate
2020 '_str' => 'Reťazec', // name of the string type
2121 '_txt' => 'Text', // name of the text type (very long strings) //TODO: translate
 22+ '_cod' => 'Code', // name of the (source) code type //TODO: translate
2223 '_boo' => 'Boolean', // name of the boolean type // TODO: translate
2324 '_num' => 'Číslo', // name for the datatype of numbers // TODO: check translation (done by pattern matching; mak)
2425 '_geo' => 'Zemepisné súradnice', // name of the geocoord type
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageRu.php
@@ -19,6 +19,7 @@
2020 '_wpg' => 'Страница', // name of page datatype
2121 '_str' => 'Строка', // name of the string type
2222 '_txt' => 'Текст', // name of the text type (very long strings)
 23+ '_cod' => 'Code', // name of the (source) code type //TODO: translate
2324 '_boo' => 'Булево', // name of the boolean type
2425 '_num' => 'Число', // name for the datatype of numbers
2526 '_geo' => 'Географическая координата', // name of the geocoord type
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageDe.php
@@ -26,6 +26,7 @@
2727 '_wpg' => 'Seite', // name of page datatype
2828 '_str' => 'Zeichenkette', // name of the string type
2929 '_txt' => 'Text', // name of the text type
 30+ '_cod' => 'Quellcode', // name of the (source) code type
3031 '_boo' => 'Wahrheitswert', // name of the boolean type
3132 '_num' => 'Zahl', // name for the datatype of numbers
3233 '_geo' => 'Geografische Koordinaten', // name of the geocoord type
@@ -45,6 +46,7 @@
4647 'Page' => '_wpg',
4748 'String' => '_str',
4849 'Text' => '_txt',
 50+ 'Code' => '_cod',
4951 'Boolean' => '_boo',
5052 'Number' => '_num',
5153 'Geographic coordinate' => '_geo',
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageZh_tw.php
@@ -18,6 +18,7 @@
1919 '_wpg' => '頁面', //'Page', // name of page datatype
2020 '_str' => '字串', //'String', // name of the string type
2121 '_txt' => '文字', //'Text', // name of the text type
 22+ '_cod' => 'Code', // name of the (source) code type //TODO: translate
2223 '_boo' => '布林', //'Boolean', // name of the boolean type
2324 '_num' => '數字', //'Number', // name for the datatype of numbers
2425 '_geo' => '地理學的座標', //'Geographic coordinate', // name of the geocoord type
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageHe.php
@@ -18,6 +18,7 @@
1919 '_wpg' => 'Page', // name of page datatype //TODO translate
2020 '_str' => 'מחרוזת', // name of the string type
2121 '_txt' => 'Text', // name of the text type (very long strings) //TODO: translate
 22+ '_cod' => 'Code', // name of the (source) code type //TODO: translate
2223 '_boo' => 'נכוןלאנכון', // name of the boolean type
2324 '_num' => 'Number', // name for the datatype of numbers //TODO: translate
2425 '_geo' => 'קורדינטות גיאוגרפיות', // name of the geocoord type
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageArz.php
@@ -18,6 +18,7 @@
1919 '_wpg' => 'الصفحة', // name of page datatype
2020 '_str' => 'سلسلة حروف', // name of the string type
2121 '_txt' => 'نص', // name of the text type
 22+ '_cod' => 'Code', // name of the (source) code type //TODO: translate
2223 '_boo' => 'منطقى', // name of the boolean type
2324 '_num' => 'عدد', // name for the datatype of numbers
2425 '_geo' => 'الإحداثيات', // name of the geocoord type

Follow-up revisions

RevisionCommit summaryAuthorDate
r38645Localisation updates. Processed consequences of r36808, 38610, r38614, r38615...siebrand17:17, 5 August 2008

Status & tagging log