r101452 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101451‎ | r101452 | r101453 >
Date:07:01, 1 November 2011
Author:ning
Status:deferred
Tags:
Comment:
some bug fixing stuff
Modified paths:
  • /trunk/extensions/WikiObjectModel/includes/apis/WOM_OutputObjectModel.php (modified) (history)
  • /trunk/extensions/WikiObjectModel/includes/apis/WOM_OutputProcessor.php (modified) (history)
  • /trunk/extensions/WikiObjectModel/includes/apis/WOM_Query.php (modified) (history)
  • /trunk/extensions/WikiObjectModel/includes/models/WOM_OM_Property.php (modified) (history)

Diff [purge]

Index: trunk/extensions/WikiObjectModel/includes/models/WOM_OM_Property.php
@@ -10,9 +10,10 @@
1111
1212 class WOMPropertyModel extends WikiObjectModel {
1313 protected $m_property; // name
14 - protected $m_smwdatavalue; // value, caption, type
1514 protected $m_value;
1615 protected $m_caption;
 16+ protected $m_user_property; // name
 17+ protected $m_smwdatavalue; // value, caption, type
1718 protected $m_visible;
1819
1920 public function __construct( $property, $value, $caption = '' ) {
@@ -23,7 +24,12 @@
2425 throw new MWException( __METHOD__ . ": Property model is invalid. Please install 'SemanticMediaWiki extension' first." );
2526 }
2627
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+ }
2834 $smwdatavalue = null;
2935 // FIXME: property should be collection object according to templates
3036 // if template/field used
@@ -31,22 +37,23 @@
3238 $value = "{$value}|{$caption}";
3339 $caption = '';
3440 } else {
35 - $smwdatavalue = SMWDataValueFactory::newPropertyObjectValue( $property, $value, $caption );
 41+ $smwdatavalue = SMWDataValueFactory::newPropertyObjectValue( $user_property, $value, $caption );
3642 }
3743
 44+ $this->m_user_property = $user_property;
 45+ $this->m_smwdatavalue = $smwdatavalue;
3846 $this->m_property = $property;
39 - $this->m_smwdatavalue = $smwdatavalue;
4047 $this->m_value = $value;
4148 $this->m_caption = $caption;
42 - $this->m_visible = !preg_match( '/\s+/', $caption );
 49+ $this->m_visible = !preg_match( '/^\s+$/', $caption );
4350 }
4451
4552 public function getProperty() {
46 - return $this->m_property;
 53+ return $this->m_user_property;
4754 }
4855
4956 public function setProperty( $property ) {
50 - $this->m_property = $property;
 57+ $this->m_user_property = $property;
5158 }
5259
5360 public function getSMWDataValue() {
@@ -71,7 +78,7 @@
7279 }
7380
7481 public function getPropertyName() {
75 - return $this->m_property->getWikiValue();
 82+ return ( $this->m_property ) ? $this->m_property : $this->m_user_property->getWikiValue();
7683 }
7784
7885 public function getPropertyValue() {
Index: trunk/extensions/WikiObjectModel/includes/apis/WOM_OutputObjectModel.php
@@ -78,9 +78,9 @@
7979 header ( "Content-Type: application/rdf+xml" );
8080 echo <<<OUTPUT
8181 <?xml version="1.0" encoding="UTF-8" ?>
82 -<api><womget result="Success"><return>
 82+<api><womoutput result="Success"><return>
8383 {$xml}
84 -</return></womget></api>
 84+</return></womoutput></api>
8585 OUTPUT;
8686 exit( 1 );
8787 }
@@ -129,7 +129,7 @@
130130
131131 protected function getExamples() {
132132 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]'
134134 );
135135 }
136136
Index: trunk/extensions/WikiObjectModel/includes/apis/WOM_OutputProcessor.php
@@ -134,10 +134,10 @@
135135 static function smwgWTregisterParserFunctions( &$parser ) {
136136 global $wgWOMOutputHooked;
137137 if ( $wgWOMOutputHooked === true ) {
138 - if ( defined( SMW_VERSION ) ) {
 138+ if ( defined( 'SMW_VERSION' ) ) {
139139 $parser->setFunctionHook( 'ask', 'WOMOutputProcessor::smwfProcessInlineQueryParserFunctionGTP' );
140140 }
141 - if ( defined( SMW_HALO_VERSION ) ) {
 141+ if ( defined( 'SMW_HALO_VERSION' ) ) {
142142 $parser->setFunctionHook( 'sparql', 'WOMOutputProcessor::smwfProcessSPARQLQueryParserFunctionGTP' );
143143 }
144144 }
Index: trunk/extensions/WikiObjectModel/includes/apis/WOM_Query.php
@@ -94,9 +94,9 @@
9595 header ( "Content-Type: application/rdf+xml" );
9696 echo <<<OUTPUT
9797 <?xml version="1.0" encoding="UTF-8" ?>
98 -<api><womget result="Success"><return>
 98+<api><womquery result="Success"><return>
9999 {$xml}
100 -</return></womget></api>
 100+</return></womquery></api>
101101 OUTPUT;
102102 exit( 1 );
103103 }

Status & tagging log