r90597 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90596‎ | r90597 | r90598 >
Date:19:41, 22 June 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
style tweaks
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_Record.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_Record.php
@@ -27,6 +27,7 @@
2828 if ( $value == '' ) {
2929 smwfLoadExtensionMessages( 'SemanticMediaWiki' );
3030 $this->addError( wfMsg( 'smw_novalues' ) );
 31+
3132 if ( $queryMode ) {
3233 return new SMWThingDescription();
3334 } else {
@@ -44,8 +45,11 @@
4546 $valueIndex = 0; // index in value array
4647 $propertyIndex = 0; // index in property list
4748 $empty = true;
 49+
4850 foreach ( $this->getPropertyDataItems() as $diProperty ) {
49 - if ( !array_key_exists( $valueIndex, $values ) ) break; // stop if there are no values left
 51+ if ( !array_key_exists( $valueIndex, $values ) ) {
 52+ break; // stop if there are no values left
 53+ }
5054
5155 if ( $queryMode ) { // special handling for supporting query parsing
5256 $comparator = SMW_CMP_EQ;
@@ -57,12 +61,14 @@
5862 $valueIndex++;
5963 } else {
6064 $dataValue = SMWDataValueFactory::newPropertyObjectValue( $diProperty, $values[$valueIndex] );
 65+
6166 if ( $dataValue->isValid() ) { // valid DV: keep
6267 if ( $queryMode ) {
6368 $subdescriptions[] = new SMWSomeProperty( $diProperty, new SMWValueDescription( $dataValue->getDataItem(), $comparator ) );
6469 } else {
6570 $semanticData->addPropertyObjectValue( $diProperty, $dataValue->getDataItem() );
6671 }
 72+
6773 $valueIndex++;
6874 $empty = false;
6975 } elseif ( ( count( $values ) - $valueIndex ) == ( count( $this->m_diProperties ) - $propertyIndex ) ) {
@@ -70,6 +76,7 @@
7177 if ( !$queryMode ) {
7278 $semanticData->addPropertyObjectValue( $diProperty, $dataValue->getDataItem() );
7379 }
 80+
7481 $this->addError( $dataValue->getErrors() );
7582 $valueIndex++;
7683 }
@@ -160,34 +167,43 @@
161168 * and minimize the below special code.
162169 */
163170 public function getExportData() {
164 - if ( !$this->isValid() ) return null;
 171+ if ( !$this->isValid() ) {
 172+ return null;
 173+ }
165174
166175 $result = new SMWExpData( new SMWExpResource( '', $this ) ); // bnode
167176 $ed = new SMWExpData( SMWExporter::getSpecialNsResource( 'swivt', 'Container' ) );
168177 $result->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'rdf', 'type' ), $ed );
169178 $count = 0;
 179+
 180+ // FIXME: obtain DVs or build them from DIs
170181 foreach ( $this->getDVs() as $dataValue ) {
171182 $count++;
 183+
172184 if ( ( $dataValue === null ) || ( !$dataValue->isValid() ) ) {
173185 continue;
174186 }
175 - if ( ( $dataValue->getTypeID() == '_wpg' ) || ( $dataValue->getTypeID() == '_uri' ) || ( $dataValue->getTypeID() == '_ema' ) ) {
 187+
 188+ if ( in_array( $dataValue->getTypeID(), array( '_wpg', '_uri', '_ema' ) ) ) {
176189 $result->addPropertyObjectValue(
177 - SMWExporter::getSpecialNsResource( 'swivt', 'object' . $count ),
178 - $dataValue->getExportData() );
 190+ SMWExporter::getSpecialNsResource( 'swivt', 'object' . $count ),
 191+ $dataValue->getExportData()
 192+ );
179193 } else {
180194 $result->addPropertyObjectValue(
181 - SMWExporter::getSpecialNsResource( 'swivt', 'value' . $count ),
182 - $dataValue->getExportData() );
 195+ SMWExporter::getSpecialNsResource( 'swivt', 'value' . $count ),
 196+ $dataValue->getExportData()
 197+ );
183198 }
184199 }
 200+
185201 return $result;
186202 }
187203
188204 ////// Additional API for value lists
189205
190206 /**
191 - * @deprecated as of 1.0, use getDataItems instead
 207+ * @deprecated as of 1.6, use getDataItems instead
192208 *
193209 * @return array of SMWDataItem
194210 */
@@ -213,7 +229,10 @@
214230 * Return the array (list) of properties that the individual entries of
215231 * this datatype consist of.
216232 *
 233+ * @since 1.6
 234+ *
217235 * @todo I18N for error message.
 236+ *
218237 * @return array of SMWDIProperty
219238 */
220239 public function getPropertyDataItems() {
@@ -231,7 +250,10 @@
232251 * Return the array (list) of properties that the individual entries of
233252 * this datatype consist of.
234253 *
 254+ * @since 1.6
 255+ *
235256 * @param $diProperty mixed null or SMWDIProperty object for which to retrieve the types
 257+ *
236258 * @return array of SMWDIProperty
237259 */
238260 public static function findPropertyDataItems( $diProperty ) {
@@ -244,6 +266,7 @@
245267 } else {
246268 $listDiProperty = new SMWDIProperty( '_LIST' );
247269 $dataitems = smwfGetStore()->getPropertyValues( $propertyDiWikiPage, $listDiProperty );
 270+
248271 if ( count( $dataitems ) == 1 ) {
249272 $propertyListValue = new SMWPropertyListValue( '__pls' );
250273 $propertyListValue->setDataItem( reset( $dataitems ) );