r90600 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90599‎ | r90600 | r90601 >
Date:20:24, 22 June 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
some style tweaks and doc improvements
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_PropertyList.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_Record.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DataValue.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DataValue.php
@@ -336,7 +336,10 @@
337337 * in spite of it being of the right basic type. False is only returned
338338 * if the data item is fundamentally incompatible with the data value.
339339 *
 340+ * @since 1.6
 341+ *
340342 * @param $dataitem SMWDataItem
 343+ *
341344 * @return boolean
342345 */
343346 abstract protected function loadDataItem( SMWDataItem $dataItem );
@@ -411,6 +414,8 @@
412415 * accessing null. Hence, one must not assume that a non-null return
413416 * value here implies that isValid() returns true.
414417 *
 418+ * @since 1.6
 419+ *
415420 * @return SMWDataItem
416421 */
417422 public function getDataItem() {
@@ -508,6 +513,11 @@
509514 /**
510515 * Return text serialisation of info links. Ensures more uniform layout
511516 * throughout wiki (Factbox, Property pages, ...).
 517+ *
 518+ * @param integer $outputformat Element of the SMW_OUTPUT_ enum
 519+ * @param $linker
 520+ *
 521+ * @return string
512522 */
513523 public function getInfolinkText( $outputformat, $linker = null ) {
514524 $result = '';
@@ -640,6 +650,8 @@
641651 /**
642652 * Return TRUE if a value was defined and understood by the given type,
643653 * and false if parsing errors occured or no value was given.
 654+ *
 655+ * @return boolean
644656 */
645657 public function isValid() {
646658 $this->unstub();
@@ -649,6 +661,8 @@
650662 /**
651663 * Return a string that displays all error messages as a tooltip, or
652664 * an empty string if no errors happened.
 665+ *
 666+ * @return string
653667 */
654668 public function getErrorText() {
655669 return smwfEncodeMessages( $this->mErrors );
@@ -657,6 +671,8 @@
658672 /**
659673 * Return an array of error messages, or an empty array
660674 * if no errors occurred.
 675+ *
 676+ * @return array
661677 */
662678 public function getErrors() {
663679 return $this->mErrors;
@@ -667,6 +683,8 @@
668684 * way. This representation is used by exporters, e.g. to be further decomposed into
669685 * RDF triples or to generate OWL/XML serialisations.
670686 * If the value is empty or invalid, NULL is returned.
 687+ *
 688+ * @return SMWExpData or null
671689 */
672690 public function getExportData() { // default implementation: encode values as untyped string
673691 if ( $this->isValid() ) {
Index: trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_Record.php
@@ -257,24 +257,25 @@
258258 * @return array of SMWDIProperty
259259 */
260260 public static function findPropertyDataItems( $diProperty ) {
261 - if ( $diProperty !== null ) {
 261+ if ( !is_null( $diProperty ) ) {
262262 $propertyDiWikiPage = $diProperty->getDiWikiPage();
263 - }
 263+
 264+ if ( !is_null( $propertyDiWikiPage ) ) {
 265+ $listDiProperty = new SMWDIProperty( '_LIST' );
 266+ $dataItems = smwfGetStore()->getPropertyValues( $propertyDiWikiPage, $listDiProperty );
264267
265 - if ( ( $diProperty === null ) || ( $propertyDiWikiPage === null ) ) {
266 - return array(); // no property known -> no types
267 - } else {
268 - $listDiProperty = new SMWDIProperty( '_LIST' );
269 - $dataitems = smwfGetStore()->getPropertyValues( $propertyDiWikiPage, $listDiProperty );
270 -
271 - if ( count( $dataitems ) == 1 ) {
272 - $propertyListValue = new SMWPropertyListValue( '__pls' );
273 - $propertyListValue->setDataItem( reset( $dataitems ) );
274 - return $propertyListValue->isvalid() ? $propertyListValue->getPropertyDataItems() : array();
275 - } else {
276 - return array();
 268+ if ( count( $dataItems ) == 1 ) {
 269+ $propertyListValue = new SMWPropertyListValue( '__pls' );
 270+ $propertyListValue->setDataItem( $dataItems[0] );
 271+
 272+ if ( $propertyListValue->isvalid() ) {
 273+ return $propertyListValue->getPropertyDataItems();
 274+ }
 275+ }
277276 }
278277 }
 278+
 279+ return array();
279280 }
280281
281282 ////// Internal helper functions
Index: trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_PropertyList.php
@@ -64,15 +64,17 @@
6565
6666 /**
6767 * @see SMWDataValue::loadDataItem()
 68+ *
6869 * @param $dataitem SMWDataItem
 70+ *
6971 * @return boolean
7072 */
7173 protected function loadDataItem( SMWDataItem $dataItem ) {
7274 if ( $dataItem->getDIType() == SMWDataItem::TYPE_STRING ) {
7375 $this->m_dataitem = $dataItem;
7476 $this->m_diProperties = array();
75 - $propertyKeys = explode( ';', $dataItem->getString() );
76 - foreach ( $propertyKeys as $propertyKey ) {
 77+
 78+ foreach ( explode( ';', $dataItem->getString() ) as $propertyKey ) {
7779 try {
7880 $this->m_diProperties[] = new SMWDIProperty( $propertyKey );
7981 } catch ( SMWDataItemException $e ) {
@@ -81,7 +83,9 @@
8284 $this->addError( wfMsgForContent( 'smw_parseerror' ) );
8385 }
8486 }
 87+
8588 $this->m_caption = false;
 89+
8690 return true;
8791 } else {
8892 return false;