Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore.php |
— | — | @@ -79,7 +79,7 @@ |
80 | 80 | case '_wpg': |
81 | 81 | $do_rels = true; |
82 | 82 | break; |
83 | | - case '_txt': |
| 83 | + case '_txt': case '_cod': |
84 | 84 | $do_text = true; |
85 | 85 | break; |
86 | 86 | case '__nry': |
— | — | @@ -442,7 +442,7 @@ |
443 | 443 | $result = array(); |
444 | 444 | $id = SMWDataValueFactory::getPropertyObjectTypeID($property); |
445 | 445 | switch ($id) { |
446 | | - case '_txt': |
| 446 | + case '_txt': case '_cod': |
447 | 447 | $res = $db->select( $db->tableName('smw_longstrings'), |
448 | 448 | 'value_blob', |
449 | 449 | $subjectcond . |
— | — | @@ -568,7 +568,7 @@ |
569 | 569 | $db =& wfGetDB( DB_SLAVE ); |
570 | 570 | |
571 | 571 | switch ($value->getTypeID()) { |
572 | | - case '_txt': // not supported |
| 572 | + case '_txt': case '_cod': // not supported |
573 | 573 | wfProfileOut("SMWSQLStore::getPropertySubjects (SMW)"); |
574 | 574 | return array(); |
575 | 575 | break; |
— | — | @@ -595,7 +595,7 @@ |
596 | 596 | continue; |
597 | 597 | } |
598 | 598 | switch ($dv->getTypeID()) { |
599 | | - case '_txt': // not supported |
| 599 | + case '_txt': case '_cod': // not supported |
600 | 600 | break; |
601 | 601 | case '_wpg': |
602 | 602 | $from .= ' INNER JOIN ' . $db->tableName('smw_nary_relations') . ' AS nary' . $count . |
— | — | @@ -643,7 +643,7 @@ |
644 | 644 | $db =& wfGetDB( DB_SLAVE ); |
645 | 645 | $id = SMWDataValueFactory::getPropertyObjectTypeID($property); |
646 | 646 | switch ($id) { |
647 | | - case '_txt': |
| 647 | + case '_txt': case '_cod': |
648 | 648 | $tablename = 'smw_longstrings'; |
649 | 649 | $pcolumn = 'attribute_title'; |
650 | 650 | $extraconds = ''; |
— | — | @@ -797,7 +797,7 @@ |
798 | 798 | if ($property instanceof Title) { // normal property |
799 | 799 | foreach($propertyValueArray as $value) { |
800 | 800 | if ($value->isValid()) { |
801 | | - if ($value->getTypeID() == '_txt') { |
| 801 | + if ( ($value->getTypeID() == '_txt') || ($value->getTypeID() == '_cod') ){ |
802 | 802 | $up_longstrings[] = |
803 | 803 | array( 'subject_id' => $subject->getArticleID(), |
804 | 804 | 'subject_namespace' => $subject->getNamespace(), |
— | — | @@ -837,7 +837,7 @@ |
838 | 838 | 'object_title' => $dv->getDBkey(), |
839 | 839 | 'object_id' => $oid ); |
840 | 840 | break; |
841 | | - case '_txt': |
| 841 | + case '_txt': case '_cod': |
842 | 842 | $up_nary_longstrings[] = |
843 | 843 | array( 'subject_id' => $subject->getArticleID(), |
844 | 844 | 'nary_key' => $nkey, |
— | — | @@ -1924,7 +1924,7 @@ |
1925 | 1925 | } |
1926 | 1926 | } elseif ($description instanceof SMWValueDescription) { |
1927 | 1927 | 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) |
1929 | 1929 | $this->addJoin('pTEXT', $from, $db, $curtables, $nary_pos); |
1930 | 1930 | break; |
1931 | 1931 | case '_wpg': |
— | — | @@ -2045,7 +2045,7 @@ |
2046 | 2046 | $sortfield = 'object_title'; |
2047 | 2047 | } |
2048 | 2048 | break; |
2049 | | - case '_txt': |
| 2049 | + case '_txt': case '_cod': |
2050 | 2050 | $tablename = 'TEXT'; |
2051 | 2051 | $pcolumn = 'attribute_title'; |
2052 | 2052 | $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 @@ |
68 | 68 | foreach ($filter as $value) { |
69 | 69 | switch ($value) { |
70 | 70 | 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; |
72 | 73 | case '__nry': $tasks = $tasks | SMW_SQL2_NARY2; break; |
73 | 74 | case SMW_SP_INSTANCE_OF: $tasks = $tasks | SMW_SQL2_INST2; break; |
74 | 75 | case SMW_SP_REDIRECTS_TO: $tasks = $tasks | SMW_SQL2_REDI2; break; |
— | — | @@ -387,7 +388,7 @@ |
388 | 389 | } |
389 | 390 | |
390 | 391 | switch ($typeid) { |
391 | | - case '_txt': break; // not supported |
| 392 | + case '_txt': case '_cod': break; // not supported |
392 | 393 | case '_wpg': // wikipage |
393 | 394 | if ($value !== NULL) { |
394 | 395 | $oid = $this->getSMWPageID($value->getDBkey(),$value->getNamespace(),$value->getInterwiki()); |
— | — | @@ -416,7 +417,7 @@ |
417 | 418 | } |
418 | 419 | $npid = $this->makeSMWPageID(strval($count),SMW_NS_PROPERTY,SMW_SQL2_SMWIW); // might be cached |
419 | 420 | switch ($dv->getTypeID()) { |
420 | | - case '_txt': break; // not supported |
| 421 | + case '_txt': case '_cod': break; // not supported |
421 | 422 | case '_wpg': |
422 | 423 | $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"; |
423 | 424 | $where .= " AND t$count.p_id=" . $db->addQuotes($npid) . |
— | — | @@ -560,7 +561,7 @@ |
561 | 562 | if ($property instanceof Title) { // normal property |
562 | 563 | foreach($propertyValueArray as $value) { |
563 | 564 | if ($value->isValid()) { |
564 | | - if ($value->getTypeID() == '_txt') { |
| 565 | + if ( ($value->getTypeID() == '_txt') || ($value->getTypeID() == '_cod') ){ |
565 | 566 | $up_text2[] = |
566 | 567 | array( 's_id' => $sid, |
567 | 568 | 'p_id' => $this->makeSMWPageID($property->getDBkey(),SMW_NS_PROPERTY,''), |
— | — | @@ -587,7 +588,7 @@ |
588 | 589 | 'p_id' => $pid, |
589 | 590 | 'o_id' => $this->makeSMWPageID($dv->getDBkey(),$dv->getNamespace(),$dv->getInterwiki()) ); |
590 | 591 | break; |
591 | | - case '_txt': |
| 592 | + case '_txt': case '_cod': |
592 | 593 | $up_text2[] = |
593 | 594 | array( 's_id' => $bnode, |
594 | 595 | 'p_id' => $pid, |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DataValueFactory.php |
— | — | @@ -248,9 +248,10 @@ |
249 | 249 | $wgAutoloadClasses['SMWLinearValue'] = $smwgIP . '/includes/SMW_DV_Linear.php'; |
250 | 250 | $wgAutoloadClasses['SMWTimeValue'] = $smwgIP . '/includes/SMW_DV_Time.php'; |
251 | 251 | $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'; |
253 | 253 | SMWDataValueFactory::$m_typeclasses = array( |
254 | 254 | '_txt' => 'SMWStringValue', |
| 255 | + '_cod' => 'SMWStringValue', |
255 | 256 | '_str' => 'SMWStringValue', |
256 | 257 | '_ema' => 'SMWURIValue', |
257 | 258 | '_uri' => 'SMWURIValue', |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_String.php |
— | — | @@ -16,14 +16,14 @@ |
17 | 17 | protected function parseUserValue($value) { |
18 | 18 | if ($value!='') { |
19 | 19 | $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) |
21 | 21 | $this->addError(wfMsgForContent('smw_maxstring', mb_substr($value, 0, 42) . ' <span class="smwwarning">[…]</span> ' . mb_substr($value, mb_strlen($this->m_value) - 42))); |
22 | 22 | } |
23 | 23 | } else { |
24 | 24 | $this->addError(wfMsgForContent('smw_emptystring')); |
25 | 25 | } |
26 | 26 | if ($this->m_caption === false) { |
27 | | - $this->m_caption = $value; |
| 27 | + $this->m_caption = ($this->m_typeid=='_cod')?$this->getCodeDisplay($value):$value; |
28 | 28 | } |
29 | 29 | return true; |
30 | 30 | } |
— | — | @@ -67,7 +67,7 @@ |
68 | 68 | } |
69 | 69 | |
70 | 70 | public function getInfolinks() { |
71 | | - if ($this->m_typeid !== '_txt') { |
| 71 | + if ($this->m_typeid == '_str') { |
72 | 72 | return SMWDataValue::getInfolinks(); |
73 | 73 | } |
74 | 74 | return $this->m_infolinks; |
— | — | @@ -77,7 +77,7 @@ |
78 | 78 | // Create links to mapping services based on a wiki-editable message. The parameters |
79 | 79 | // available to the message are: |
80 | 80 | // $1: urlencoded string |
81 | | - if ($this->m_typeid === '_txt') { |
| 81 | + if ($this->m_typeid == '_str') { |
82 | 82 | return false; // no services for Type:Text |
83 | 83 | } else { |
84 | 84 | return array(rawurlencode($this->m_value)); |
— | — | @@ -98,17 +98,31 @@ |
99 | 99 | */ |
100 | 100 | protected function getAbbValue($linked) { |
101 | 101 | $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') ) { |
103 | 105 | if ( ($linked === NULL)||($linked === false) ) { |
104 | 106 | return mb_substr($this->m_value, 0, 42) . ' <span class="smwwarning">…</span> ' . mb_substr($this->m_value, $len - 42); |
105 | 107 | } else { |
106 | 108 | smwfRequireHeadItem(SMW_HEADER_TOOLTIP); |
107 | 109 | return mb_substr($this->m_value, 0, 42) . ' <span class="smwttpersist"> … <span class="smwttcontent">' . $this->m_value . '</span></span> ' . mb_substr($this->m_value, $len - 42); |
108 | 110 | } |
| 111 | + } elseif ($len > 255) { |
| 112 | + return $this->getCodeDisplay($this->m_value,true); |
109 | 113 | } else { |
110 | 114 | return $this->m_value; |
111 | 115 | } |
112 | 116 | } |
113 | 117 | |
| 118 | + /** |
| 119 | + * Special features for Type:Code formating. |
| 120 | + */ |
| 121 | + protected function getCodeDisplay($value, $scroll = false) { |
| 122 | + $result = str_replace( array('<', '>', ' ','://'), array('<', '>', ' ', '<!-- -->://<!-- -->'), $value); |
| 123 | + if ($scroll) { |
| 124 | + $result = "<div style=\"height:5em; overflow:auto;\">$result</div>"; |
| 125 | + } |
| 126 | + return "<pre>$result</pre>"; |
| 127 | + } |
114 | 128 | |
115 | 129 | } |
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageZh_cn.php |
— | — | @@ -18,6 +18,7 @@ |
19 | 19 | '_wpg' => '页面', //'Page', // name of page datatype |
20 | 20 | '_str' => '字串', //'String', // name of the string type |
21 | 21 | '_txt' => '文字', //'Text', // name of the text type |
| 22 | + '_cod' => 'Code', // name of the (source) code type //TODO: translate |
22 | 23 | '_boo' => '布林', //'Boolean', // name of the boolean type |
23 | 24 | '_num' => '数字', //'Number', // name for the datatype of numbers |
24 | 25 | '_geo' => '地理学的座标', //'Geographic coordinate', // name of the geocoord type |
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageAr.php |
— | — | @@ -19,6 +19,7 @@ |
20 | 20 | '_wpg' => 'الصفحة', // name of page datatype |
21 | 21 | '_str' => 'سلسلة أحرف', // name of the string type |
22 | 22 | '_txt' => 'نص', // name of the text type |
| 23 | + '_cod' => 'Code', // name of the (source) code type //TODO: translate |
23 | 24 | '_boo' => 'منطقي', // name of the boolean type |
24 | 25 | '_num' => 'عدد', // name for the datatype of numbers |
25 | 26 | '_geo' => 'الإحداثيات', // name of the geocoord type |
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageEn.php |
— | — | @@ -18,6 +18,7 @@ |
19 | 19 | '_wpg' => 'Page', // name of page datatype |
20 | 20 | '_str' => 'String', // name of the string type |
21 | 21 | '_txt' => 'Text', // name of the text type |
| 22 | + '_cod' => 'Code', // name of the (source) code type |
22 | 23 | '_boo' => 'Boolean', // name of the boolean type |
23 | 24 | '_num' => 'Number', // name for the datatype of numbers |
24 | 25 | '_geo' => 'Geographic coordinate', // name of the geocoord type |
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageEs.php |
— | — | @@ -18,6 +18,7 @@ |
19 | 19 | '_wpg' => 'Page', // name of page datatype //TODO translate |
20 | 20 | '_str' => 'Cadena de caracteres', // name of the string type |
21 | 21 | '_txt' => 'Texto', // name of the text type (very long strings) |
| 22 | + '_cod' => 'Code', // name of the (source) code type //TODO: translate |
22 | 23 | '_boo' => 'Booleano', // name of the boolean type |
23 | 24 | '_num' => 'Número', // name for the datatype of numbers |
24 | 25 | '_geo' => 'Coordenadas geográficas', // name of the geocoord type |
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageFr.php |
— | — | @@ -18,6 +18,7 @@ |
19 | 19 | '_wpg' => 'Page', // name of page datatype |
20 | 20 | '_str' => 'Chaîne de caractères', // name of the string type |
21 | 21 | '_txt' => 'Texte', // name of the text type (very long strings) |
| 22 | + '_cod' => 'Code', // name of the (source) code type //TODO: translate |
22 | 23 | '_boo' => 'Booléen', // name of the boolean type |
23 | 24 | '_num' => 'Nombre', // name for the datatype of numbers |
24 | 25 | '_geo' => 'Coordonnées géographiques', // name of the geocoord type |
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageKo.php |
— | — | @@ -21,6 +21,7 @@ |
22 | 22 | '_wpg' => '인공', // name of page datatype |
23 | 23 | '_str' => '배열의 문자', // name of the string type |
24 | 24 | '_txt' => '텍스트', // name of the text type |
| 25 | + '_cod' => 'Code', // name of the (source) code type //TODO: translate |
25 | 26 | '_boo' => '부울', // name of the boolean type |
26 | 27 | '_num' => '번호', // name for the datatype of numbers |
27 | 28 | '_geo' => '지리적 좌표', // name of the geocoord type |
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageNl.php |
— | — | @@ -18,6 +18,7 @@ |
19 | 19 | '_wpg' => 'Pagina', // name of page datatype |
20 | 20 | '_str' => 'String', // name of the string type |
21 | 21 | '_txt' => 'Tekst', // name of the text type |
| 22 | + '_cod' => 'Code', // name of the (source) code type //TODO: translate |
22 | 23 | '_boo' => 'Booleans', // name of the boolean type |
23 | 24 | '_num' => 'Number', // name for the datatype of numbers // TODO: translate |
24 | 25 | '_geo' => 'Geographische coordinaat', // name of the geocoord type |
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguagePl.php |
— | — | @@ -38,6 +38,7 @@ |
39 | 39 | '_wpg' => 'Page', // name of page datatype //TODO translate |
40 | 40 | '_str' => 'Łańcuch znaków', // name of the string type |
41 | 41 | '_txt' => 'Text', // name of the text type (very long strings) //TODO: translate |
| 42 | + '_cod' => 'Code', // name of the (source) code type //TODO: translate |
42 | 43 | '_boo' => 'Wartość logiczna', // name of the boolean type |
43 | 44 | '_num' => 'Liczba', // name for the datatype of numbers // TODO: check translation (done by pattern matching. mak) |
44 | 45 | '_geo' => 'Współrzędne geograficzne', // name of the geocoord type |
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageIt.php |
— | — | @@ -18,6 +18,7 @@ |
19 | 19 | '_wpg' => 'Pagina', // name of page datatypee |
20 | 20 | '_str' => 'Stringa', //name of the string type |
21 | 21 | '_txt' => 'Testo', // name of the text type |
| 22 | + '_cod' => 'Code', // name of the (source) code type //TODO: translate |
22 | 23 | '_boo' => 'Booleano', // name of the boolean type |
23 | 24 | '_num' => 'Numero', // name for the datatype of numbers |
24 | 25 | '_geo' => 'Coordinate geografiche', // name of the geocoord type |
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageSk.php |
— | — | @@ -18,6 +18,7 @@ |
19 | 19 | '_wpg' => 'Page', // name of page datatype //TODO translate |
20 | 20 | '_str' => 'Reťazec', // name of the string type |
21 | 21 | '_txt' => 'Text', // name of the text type (very long strings) //TODO: translate |
| 22 | + '_cod' => 'Code', // name of the (source) code type //TODO: translate |
22 | 23 | '_boo' => 'Boolean', // name of the boolean type // TODO: translate |
23 | 24 | '_num' => 'Číslo', // name for the datatype of numbers // TODO: check translation (done by pattern matching; mak) |
24 | 25 | '_geo' => 'Zemepisné súradnice', // name of the geocoord type |
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageRu.php |
— | — | @@ -19,6 +19,7 @@ |
20 | 20 | '_wpg' => 'Страница', // name of page datatype |
21 | 21 | '_str' => 'Строка', // name of the string type |
22 | 22 | '_txt' => 'Текст', // name of the text type (very long strings) |
| 23 | + '_cod' => 'Code', // name of the (source) code type //TODO: translate |
23 | 24 | '_boo' => 'Булево', // name of the boolean type |
24 | 25 | '_num' => 'Число', // name for the datatype of numbers |
25 | 26 | '_geo' => 'Географическая координата', // name of the geocoord type |
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageDe.php |
— | — | @@ -26,6 +26,7 @@ |
27 | 27 | '_wpg' => 'Seite', // name of page datatype |
28 | 28 | '_str' => 'Zeichenkette', // name of the string type |
29 | 29 | '_txt' => 'Text', // name of the text type |
| 30 | + '_cod' => 'Quellcode', // name of the (source) code type |
30 | 31 | '_boo' => 'Wahrheitswert', // name of the boolean type |
31 | 32 | '_num' => 'Zahl', // name for the datatype of numbers |
32 | 33 | '_geo' => 'Geografische Koordinaten', // name of the geocoord type |
— | — | @@ -45,6 +46,7 @@ |
46 | 47 | 'Page' => '_wpg', |
47 | 48 | 'String' => '_str', |
48 | 49 | 'Text' => '_txt', |
| 50 | + 'Code' => '_cod', |
49 | 51 | 'Boolean' => '_boo', |
50 | 52 | 'Number' => '_num', |
51 | 53 | 'Geographic coordinate' => '_geo', |
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageZh_tw.php |
— | — | @@ -18,6 +18,7 @@ |
19 | 19 | '_wpg' => '頁面', //'Page', // name of page datatype |
20 | 20 | '_str' => '字串', //'String', // name of the string type |
21 | 21 | '_txt' => '文字', //'Text', // name of the text type |
| 22 | + '_cod' => 'Code', // name of the (source) code type //TODO: translate |
22 | 23 | '_boo' => '布林', //'Boolean', // name of the boolean type |
23 | 24 | '_num' => '數字', //'Number', // name for the datatype of numbers |
24 | 25 | '_geo' => '地理學的座標', //'Geographic coordinate', // name of the geocoord type |
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageHe.php |
— | — | @@ -18,6 +18,7 @@ |
19 | 19 | '_wpg' => 'Page', // name of page datatype //TODO translate |
20 | 20 | '_str' => 'מחרוזת', // name of the string type |
21 | 21 | '_txt' => 'Text', // name of the text type (very long strings) //TODO: translate |
| 22 | + '_cod' => 'Code', // name of the (source) code type //TODO: translate |
22 | 23 | '_boo' => 'נכוןלאנכון', // name of the boolean type |
23 | 24 | '_num' => 'Number', // name for the datatype of numbers //TODO: translate |
24 | 25 | '_geo' => 'קורדינטות גיאוגרפיות', // name of the geocoord type |
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageArz.php |
— | — | @@ -18,6 +18,7 @@ |
19 | 19 | '_wpg' => 'الصفحة', // name of page datatype |
20 | 20 | '_str' => 'سلسلة حروف', // name of the string type |
21 | 21 | '_txt' => 'نص', // name of the text type |
| 22 | + '_cod' => 'Code', // name of the (source) code type //TODO: translate |
22 | 23 | '_boo' => 'منطقى', // name of the boolean type |
23 | 24 | '_num' => 'عدد', // name for the datatype of numbers |
24 | 25 | '_geo' => 'الإحداثيات', // name of the geocoord type |