Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php |
— | — | @@ -153,7 +153,7 @@ |
154 | 154 | break; |
155 | 155 | case SMW_SQL2_CONC2: |
156 | 156 | $from = 'smw_conc2'; |
157 | | - $select = 'concept_txt as value'; |
| 157 | + $select = 'concept_txt as concept, concept_docu as docu'; |
158 | 158 | $where = 's_id=' . $db->addQuotes($sid); |
159 | 159 | break; |
160 | 160 | } |
— | — | @@ -194,7 +194,7 @@ |
195 | 195 | $this->m_semdata[$sid]->addSpecialValue(SMW_SP_INSTANCE_OF, $dv); |
196 | 196 | } elseif ($task == SMW_SQL2_CONC2) { |
197 | 197 | $dv = SMWDataValueFactory::newSpecialValue(SMW_SP_CONCEPT_DESC); |
198 | | - $dv->setXSDValue($row->value, ''); |
| 198 | + $dv->setValues($row->concept, $row->docu); |
199 | 199 | $this->m_semdata[$sid]->addSpecialValue(SMW_SP_CONCEPT_DESC, $dv); |
200 | 200 | } |
201 | 201 | } |
— | — | @@ -784,7 +784,9 @@ |
785 | 785 | } |
786 | 786 | $value = end($propertyValueArray); // only one value per page! |
787 | 787 | if ( ($value->isValid()) ) { |
788 | | - $up_conc2[] = array('s_id' => $sid, 'concept_txt' => $value->getXSDValue()); |
| 788 | + $up_conc2[] = array('s_id' => $sid, |
| 789 | + 'concept_txt' => $value->getXSDValue(), |
| 790 | + 'concept_docu' => $value->getDocu()); |
789 | 791 | } |
790 | 792 | break; |
791 | 793 | default: // normal special value |
— | — | @@ -1097,7 +1099,8 @@ |
1098 | 1100 | |
1099 | 1101 | $this->setupTable($smw_conc2, // concept descriptions |
1100 | 1102 | array('s_id' => 'INT(8) UNSIGNED NOT NULL KEY', |
1101 | | - 'concept_txt' => 'MEDIUMBLOB'), $db, $verbose); |
| 1103 | + 'concept_txt' => 'MEDIUMBLOB', |
| 1104 | + 'concept_docu'=> 'MEDIUMBLOB'), $db, $verbose); |
1102 | 1105 | $this->setupIndex($smw_conc2, array('s_id'), $db); |
1103 | 1106 | |
1104 | 1107 | $this->reportProgress("Database initialised successfully.\n",$verbose); |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DataValueFactory.php |
— | — | @@ -115,7 +115,7 @@ |
116 | 116 | $result = SMWDataValueFactory::newTypeIDValue('_wpg', $value, $caption); |
117 | 117 | break; |
118 | 118 | case SMW_SP_CONCEPT_DESC: |
119 | | - $result = SMWDataValueFactory::newTypeIDValue('_txt', $value, $caption); |
| 119 | + $result = SMWDataValueFactory::newTypeIDValue('__con', $value, $caption); |
120 | 120 | break; |
121 | 121 | default: |
122 | 122 | /// NOTE: unstable hook, future versions might have better ways of enabling extensions to add properties |
— | — | @@ -252,6 +252,7 @@ |
253 | 253 | $wgAutoloadClasses['SMWTimeValue'] = $smwgIP . '/includes/SMW_DV_Time.php'; |
254 | 254 | $wgAutoloadClasses['SMWGeoCoordsValue'] = $smwgIP . '/includes/SMW_DV_GeoCoords.php'; |
255 | 255 | $wgAutoloadClasses['SMWBoolValue'] = $smwgIP . '/includes/SMW_DV_Bool.php'; |
| 256 | + $wgAutoloadClasses['SMWConceptValue'] = $smwgIP . '/includes/SMW_DV_Concept.php'; |
256 | 257 | SMWDataValueFactory::$m_typeclasses = array( |
257 | 258 | '_txt' => 'SMWStringValue', |
258 | 259 | '_cod' => 'SMWStringValue', |
— | — | @@ -268,7 +269,8 @@ |
269 | 270 | '__typ' => 'SMWTypesValue', |
270 | 271 | '__lin' => 'SMWLinearValue', |
271 | 272 | '__nry' => 'SMWNAryValue', |
272 | | - '__err' => 'SMWErrorValue' |
| 273 | + '__err' => 'SMWErrorValue', |
| 274 | + '__con' => 'SMWConceptValue' |
273 | 275 | ); |
274 | 276 | |
275 | 277 | wfRunHooks( 'smwInitDatatypes' ); |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Concept.php |
— | — | @@ -0,0 +1,94 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * This datavalue is used as a container for concept descriptions as used |
| 6 | + * on Concept pages with the #concept parserfunction. It has a somewhat |
| 7 | + * non-standard interface as compared to other datavalues, but this is not |
| 8 | + * an issue. |
| 9 | + * |
| 10 | + * @author Markus Krötzsch |
| 11 | + * @note AUTOLOADED |
| 12 | + */ |
| 13 | +class SMWConceptValue extends SMWDataValue { |
| 14 | + |
| 15 | + protected $m_concept = ''; // XML-safe, HTML-safe, Wiki-compatible concept expression (query string) |
| 16 | + protected $m_docu = ''; // text description of concept, can only be set by special function "setvalues" |
| 17 | + |
| 18 | + protected function parseUserValue($value) { |
| 19 | + // this function is normally not used for this class, not created from user input directly |
| 20 | + $this->m_concept = smwfXMLContentEncode($value); |
| 21 | + if ($this->m_caption === false) { |
| 22 | + $this->m_caption = $value; |
| 23 | + } |
| 24 | + return true; |
| 25 | + } |
| 26 | + |
| 27 | + protected function parseXSDValue($value, $unit) { |
| 28 | + // normally not used, store should use setValues |
| 29 | + $this->m_concept = $value; |
| 30 | + $this->m_caption = $this->m_concept; // this is our output text |
| 31 | + } |
| 32 | + |
| 33 | + public function getShortWikiText($linked = NULL) { |
| 34 | + return $this->m_caption; |
| 35 | + } |
| 36 | + |
| 37 | + public function getShortHTMLText($linker = NULL) { |
| 38 | + return $this->getShortWikiText($linker); // should be save (based on xsdvalue) |
| 39 | + } |
| 40 | + |
| 41 | + public function getLongWikiText($linked = NULL) { |
| 42 | + if (!$this->isValid()) { |
| 43 | + return $this->getErrorText(); |
| 44 | + } else { |
| 45 | + return $this->m_caption; |
| 46 | + } |
| 47 | + } |
| 48 | + |
| 49 | + public function getLongHTMLText($linker = NULL) { |
| 50 | + if (!$this->isValid()) { |
| 51 | + return $this->getErrorText(); |
| 52 | + } else { |
| 53 | + return $this->m_caption; // should be save (based on xsdvalue) |
| 54 | + } |
| 55 | + } |
| 56 | + |
| 57 | + public function getXSDValue() { |
| 58 | + return $this->m_concept; |
| 59 | + } |
| 60 | + |
| 61 | + public function getWikiValue(){ |
| 62 | + return $this->m_concept; |
| 63 | + } |
| 64 | + |
| 65 | + public function getExportData() { |
| 66 | + if ($this->isValid()) { |
| 67 | +// $lit = new SMWExpLiteral(smwfHTMLtoUTF8($this->m_value), $this, 'http://www.w3.org/2001/XMLSchema#string'); |
| 68 | +// return new SMWExpData($lit); |
| 69 | + return NULL; /// TODO |
| 70 | + } else { |
| 71 | + return NULL; |
| 72 | + } |
| 73 | + } |
| 74 | + |
| 75 | + /** |
| 76 | + * Special features for Type:Code formating. |
| 77 | + */ |
| 78 | + protected function getCodeDisplay($value, $scroll = false) { |
| 79 | + $result = str_replace( array('<', '>', ' ', '://', '=', "'"), array('<', '>', ' ', '<!-- -->://<!-- -->', '=', '''), $value); |
| 80 | + if ($scroll) { |
| 81 | + $result = "<div style=\"height:5em; overflow:auto;\">$result</div>"; |
| 82 | + } |
| 83 | + return "<pre>$result</pre>"; |
| 84 | + } |
| 85 | + |
| 86 | + public function setValues($concept, $docu) { |
| 87 | + $this->setUserValue($concept); // must be called to make object valid (parent implementation) |
| 88 | + $this->m_docu = $docu?smwfXMLContentEncode($docu):''; |
| 89 | + } |
| 90 | + |
| 91 | + public function getDocu() { |
| 92 | + return $this->m_docu; |
| 93 | + } |
| 94 | + |
| 95 | +} |
Property changes on: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Concept.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 96 | + native |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php |
— | — | @@ -320,10 +320,13 @@ |
321 | 321 | // process input: |
322 | 322 | $params = func_get_args(); |
323 | 323 | array_shift( $params ); // we already know the $parser ... |
324 | | - $concept_input = array_shift( $params ); // use only first parameter, ignore rest (may get meaning later) |
| 324 | + $concept_input = array_shift( $params ); // use first parameter as concept (query) string |
325 | 325 | $query = SMWQueryProcessor::createQuery($concept_input, array('limit' => -1), SMWQueryProcessor::CONCEPT_DESC); |
326 | | - $conceptText = $query->getDescription()->getQueryString(); |
327 | | - $dv = SMWDataValueFactory::newSpecialValue(SMW_SP_CONCEPT_DESC, $conceptText); |
| 326 | + $concept_text = $query->getDescription()->getQueryString(); |
| 327 | + $concept_docu = array_shift( $params ); // second parameter, if any, might be a description |
| 328 | + |
| 329 | + $dv = SMWDataValueFactory::newSpecialValue(SMW_SP_CONCEPT_DESC); |
| 330 | + $dv->setValues($concept_text, $concept_docu); |
328 | 331 | SMWFactbox::$semdata->addSpecialValue(SMW_SP_CONCEPT_DESC,$dv); |
329 | 332 | |
330 | 333 | // display concept box: |
— | — | @@ -333,8 +336,9 @@ |
334 | 337 | smwfRequireHeadItem(SMW_HEADER_STYLE); |
335 | 338 | $result = '<div class="smwfact"><span class="smwfactboxhead">' . wfMsgForContent('smw_concept_description',$title->getText()) . |
336 | 339 | //(count($query->getErrors())>0?' ' . smwfEncodeMessages($query->getErrors()):'') . // errors are shown by $resultlink anyway |
337 | | - '</span> ' . $resultlink . '<br/>' . |
338 | | - '<pre>' . str_replace('[', '[', $conceptText) . '</pre></div>'; |
| 340 | + '</span> ' . $resultlink . '<br />' . |
| 341 | + ($concept_docu?"<p>$concept_docu</p>":'') . |
| 342 | + '<pre>' . str_replace('[', '[', $concept_text) . '</pre></div>'; |
339 | 343 | return $result; |
340 | 344 | } |
341 | 345 | |