Index: trunk/extensions/WikiObjectModel/includes/models/WOM_OM_Property.php |
— | — | @@ -10,9 +10,10 @@ |
11 | 11 | |
12 | 12 | class WOMPropertyModel extends WikiObjectModel { |
13 | 13 | protected $m_property; // name |
14 | | - protected $m_smwdatavalue; // value, caption, type |
15 | 14 | protected $m_value; |
16 | 15 | protected $m_caption; |
| 16 | + protected $m_user_property; // name |
| 17 | + protected $m_smwdatavalue; // value, caption, type |
17 | 18 | protected $m_visible; |
18 | 19 | |
19 | 20 | public function __construct( $property, $value, $caption = '' ) { |
— | — | @@ -23,7 +24,12 @@ |
24 | 25 | throw new MWException( __METHOD__ . ": Property model is invalid. Please install 'SemanticMediaWiki extension' first." ); |
25 | 26 | } |
26 | 27 | |
27 | | - $property = SMWPropertyValue::makeUserProperty( $property ); |
| 28 | + $user_property = SMWPropertyValue::makeUserProperty( $property ); |
| 29 | + if ( count ( $user_property->getErrors() ) > 0 ) { |
| 30 | + $user_property = SMWPropertyValue::makeUserProperty( '///NA///' ); |
| 31 | + } else { |
| 32 | + $property = ''; |
| 33 | + } |
28 | 34 | $smwdatavalue = null; |
29 | 35 | // FIXME: property should be collection object according to templates |
30 | 36 | // if template/field used |
— | — | @@ -31,22 +37,23 @@ |
32 | 38 | $value = "{$value}|{$caption}"; |
33 | 39 | $caption = ''; |
34 | 40 | } else { |
35 | | - $smwdatavalue = SMWDataValueFactory::newPropertyObjectValue( $property, $value, $caption ); |
| 41 | + $smwdatavalue = SMWDataValueFactory::newPropertyObjectValue( $user_property, $value, $caption ); |
36 | 42 | } |
37 | 43 | |
| 44 | + $this->m_user_property = $user_property; |
| 45 | + $this->m_smwdatavalue = $smwdatavalue; |
38 | 46 | $this->m_property = $property; |
39 | | - $this->m_smwdatavalue = $smwdatavalue; |
40 | 47 | $this->m_value = $value; |
41 | 48 | $this->m_caption = $caption; |
42 | | - $this->m_visible = !preg_match( '/\s+/', $caption ); |
| 49 | + $this->m_visible = !preg_match( '/^\s+$/', $caption ); |
43 | 50 | } |
44 | 51 | |
45 | 52 | public function getProperty() { |
46 | | - return $this->m_property; |
| 53 | + return $this->m_user_property; |
47 | 54 | } |
48 | 55 | |
49 | 56 | public function setProperty( $property ) { |
50 | | - $this->m_property = $property; |
| 57 | + $this->m_user_property = $property; |
51 | 58 | } |
52 | 59 | |
53 | 60 | public function getSMWDataValue() { |
— | — | @@ -71,7 +78,7 @@ |
72 | 79 | } |
73 | 80 | |
74 | 81 | public function getPropertyName() { |
75 | | - return $this->m_property->getWikiValue(); |
| 82 | + return ( $this->m_property ) ? $this->m_property : $this->m_user_property->getWikiValue(); |
76 | 83 | } |
77 | 84 | |
78 | 85 | public function getPropertyValue() { |
Index: trunk/extensions/WikiObjectModel/includes/apis/WOM_OutputObjectModel.php |
— | — | @@ -78,9 +78,9 @@ |
79 | 79 | header ( "Content-Type: application/rdf+xml" );
|
80 | 80 | echo <<<OUTPUT
|
81 | 81 | <?xml version="1.0" encoding="UTF-8" ?>
|
82 | | -<api><womget result="Success"><return>
|
| 82 | +<api><womoutput result="Success"><return>
|
83 | 83 | {$xml}
|
84 | | -</return></womget></api>
|
| 84 | +</return></womoutput></api>
|
85 | 85 | OUTPUT;
|
86 | 86 | exit( 1 );
|
87 | 87 | }
|
— | — | @@ -129,7 +129,7 @@ |
130 | 130 |
|
131 | 131 | protected function getExamples() {
|
132 | 132 | return array (
|
133 | | - 'api.php?action=womget&page=Somepage&xpath=//template[@name=SomeTempate]/template_field[@key=templateparam]'
|
| 133 | + 'api.php?action=womoutput&page=Somepage&xpath=//template[@name=SomeTempate]/template_field[@key=templateparam]'
|
134 | 134 | );
|
135 | 135 | }
|
136 | 136 |
|
Index: trunk/extensions/WikiObjectModel/includes/apis/WOM_OutputProcessor.php |
— | — | @@ -134,10 +134,10 @@ |
135 | 135 | static function smwgWTregisterParserFunctions( &$parser ) {
|
136 | 136 | global $wgWOMOutputHooked;
|
137 | 137 | if ( $wgWOMOutputHooked === true ) {
|
138 | | - if ( defined( SMW_VERSION ) ) {
|
| 138 | + if ( defined( 'SMW_VERSION' ) ) {
|
139 | 139 | $parser->setFunctionHook( 'ask', 'WOMOutputProcessor::smwfProcessInlineQueryParserFunctionGTP' );
|
140 | 140 | }
|
141 | | - if ( defined( SMW_HALO_VERSION ) ) {
|
| 141 | + if ( defined( 'SMW_HALO_VERSION' ) ) {
|
142 | 142 | $parser->setFunctionHook( 'sparql', 'WOMOutputProcessor::smwfProcessSPARQLQueryParserFunctionGTP' );
|
143 | 143 | }
|
144 | 144 | }
|
Index: trunk/extensions/WikiObjectModel/includes/apis/WOM_Query.php |
— | — | @@ -94,9 +94,9 @@ |
95 | 95 | header ( "Content-Type: application/rdf+xml" );
|
96 | 96 | echo <<<OUTPUT
|
97 | 97 | <?xml version="1.0" encoding="UTF-8" ?>
|
98 | | -<api><womget result="Success"><return>
|
| 98 | +<api><womquery result="Success"><return>
|
99 | 99 | {$xml}
|
100 | | -</return></womget></api>
|
| 100 | +</return></womquery></api>
|
101 | 101 | OUTPUT;
|
102 | 102 | exit( 1 );
|
103 | 103 | }
|