|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Maps\SemanticMW\DataValues; |
|
4
|
|
|
|
|
5
|
|
|
use PolygonHandler; |
|
6
|
|
|
use SMWDataItem; |
|
7
|
|
|
use SMWDataValue; |
|
8
|
|
|
use SMWDIBlob; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Implementation of datavalues that are geographic shapes. |
|
12
|
|
|
* |
|
13
|
|
|
* @author Nischay Nahata |
|
14
|
|
|
*/ |
|
15
|
|
|
class GeoPolygonValue extends SMWDataValue { |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @see SMWDataValue::getShortHTMLText |
|
19
|
|
|
* |
|
20
|
|
|
* @since 2.0 |
|
21
|
|
|
*/ |
|
22
|
|
|
public function getShortHTMLText( $linker = null ) { |
|
23
|
|
|
return $this->getShortWikiText( $linker ); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @see SMWDataValue::getShortWikiText |
|
28
|
|
|
* |
|
29
|
|
|
* @since 2.0 |
|
30
|
|
|
*/ |
|
31
|
|
|
public function getShortWikiText( $linked = null ) { |
|
32
|
|
|
if ( $this->isValid() ) { |
|
33
|
|
|
return $this->m_dataitem->getString(); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
return $this->getErrorText(); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @see SMWDataValue::getLongHTMLText |
|
41
|
|
|
* |
|
42
|
|
|
* @since 2.0 |
|
43
|
|
|
*/ |
|
44
|
|
|
public function getLongHTMLText( $linker = null ) { |
|
45
|
|
|
return $this->getLongWikiText( $linker ); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @see SMWDataValue::getLongWikiText |
|
50
|
|
|
* |
|
51
|
|
|
* @since 2.0 |
|
52
|
|
|
*/ |
|
53
|
|
|
public function getLongWikiText( $linker = null ) { |
|
54
|
|
|
return $this->getShortWikiText( $linker ); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @see SMWDataValue::getWikiValue |
|
59
|
|
|
* |
|
60
|
|
|
* @since 2.0 |
|
61
|
|
|
*/ |
|
62
|
|
|
public function getWikiValue() { |
|
63
|
|
|
return $this->m_dataitem->getString(); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @see SMWDataValue::getExportData |
|
68
|
|
|
* |
|
69
|
|
|
* @since 2.0 |
|
70
|
|
|
*/ |
|
71
|
|
|
public function getExportData() { |
|
72
|
|
|
return null; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @see SMWDataValue::setDataItem() |
|
77
|
|
|
* |
|
78
|
|
|
* @param $dataitem SMWDataItem |
|
79
|
|
|
* |
|
80
|
|
|
* @return boolean |
|
81
|
|
|
*/ |
|
82
|
|
|
protected function loadDataItem( SMWDataItem $dataItem ) { |
|
83
|
|
|
if ( $dataItem instanceof SMWDIBlob ) { |
|
|
|
|
|
|
84
|
|
|
$this->m_dataitem = $dataItem; |
|
85
|
|
|
return true; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
return false; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* NOTE: Do param validation. |
|
93
|
|
|
* TODO: Stores as a Blob, use better data structure |
|
94
|
|
|
* |
|
95
|
|
|
* @see SMWDataValue::parseUserValue |
|
96
|
|
|
* |
|
97
|
|
|
* @since 2.0 |
|
98
|
|
|
*/ |
|
99
|
|
|
protected function parseUserValue( $value ) { |
|
100
|
|
|
if ( $value === '' ) { |
|
101
|
|
|
$this->addError( wfMessage( 'smw_emptystring' )->inContentLanguage()->text() ); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
foreach ( ( new PolygonHandler( $value ) )->getValidationErrors() as $errMsg ) { |
|
105
|
|
|
$this->addError( $errMsg ); |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
$this->m_dataitem = new SMWDIBlob( $value, $this->m_typeid ); |
|
109
|
|
|
} |
|
110
|
|
|
} |
|
111
|
|
|
|