1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
<?php
/**
* @ingroup SMWDataValues
*/
/**
* This datavalue is used as a container for concept descriptions as used
* on Concept pages with the #concept parserfunction. It has a somewhat
* non-standard interface as compared to other datavalues, but this is not
* an issue.
*
* @author Markus Krötzsch
* @ingroup SMWDataValues
*/
class SMWConceptValue extends SMWDataValue {
protected function parseUserValue( $value ) {
throw new Exception( 'Concepts cannot be initialized from user-provided strings. This should not happen.' );
}
/**
* @see SMWDataValue::loadDataItem()
* @param $dataItem SMWDataItem
* @return boolean
*/
protected function loadDataItem( SMWDataItem $dataItem ) {
if ( $dataItem->getDIType() !== SMWDataItem::TYPE_CONCEPT ) {
return false;
}
$this->m_dataitem = $dataItem;
$this->m_caption = $dataItem->getConceptQuery(); // probably useless
return true;
}
protected function clear() {
$this->m_dataitem = new \SMW\DIConcept( '', '', 0, -1, -1, $this->m_typeid );
}
public function getShortWikiText( $linked = null ) {
return $this->m_caption;
}
public function getShortHTMLText( $linker = null ) {
return $this->getShortWikiText( $linker ); // should be save (based on xsdvalue)
}
public function getLongWikiText( $linked = null ) {
if ( !$this->isValid() ) {
return $this->getErrorText();
} else {
return $this->m_caption;
}
}
public function getLongHTMLText( $linker = null ) {
if ( !$this->isValid() ) {
return $this->getErrorText();
} else {
return $this->m_caption; // should be save (based on xsdvalue)
}
}
public function getWikiValue() {
/// This should not be used for anything. This class does not support wiki values.
return str_replace( [ '<', '>', '&' ], [ '<', '>', '&' ], $this->m_dataitem->getConceptQuery() );
}
/// Return the concept's defining text (in SMW query syntax)
public function getConceptText() {
return $this->m_dataitem->getConceptQuery();
}
/// Return the optional concept documentation.
public function getDocu() {
return $this->m_dataitem->getDocumentation();
}
/// Return the concept's size (a metric used to estimate computation complexity).
public function getSize() {
return $this->m_dataitem->getSize();
}
/// Return the concept's depth (a metric used to estimate computation complexity).
public function getDepth() {
return $this->m_dataitem->getDepth();
}
/// Return the concept's query feature bit field (a metric used to estimate computation complexity).
public function getQueryFeatures() {
return $this->m_dataitem->getQueryFeatures();
}
}
|