http://www.mediawiki.org/wiki/Special:Code/MediaWiki/90600
Revision: 90600
Author: jeroendedauw
Date: 2011-06-22 20:24:25 +0000 (Wed, 22 Jun 2011)
Log Message:
-----------
some style tweaks and doc improvements
Modified Paths:
--------------
trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_PropertyList.php
trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_Record.php
trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DataValue.php
Modified:
trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_PropertyList.php
===================================================================
---
trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_PropertyList.php
2011-06-22 20:10:14 UTC (rev 90599)
+++
trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_PropertyList.php
2011-06-22 20:24:25 UTC (rev 90600)
@@ -64,15 +64,17 @@
/**
* @see SMWDataValue::loadDataItem()
+ *
* @param $dataitem SMWDataItem
+ *
* @return boolean
*/
protected function loadDataItem( SMWDataItem $dataItem ) {
if ( $dataItem->getDIType() == SMWDataItem::TYPE_STRING ) {
$this->m_dataitem = $dataItem;
$this->m_diProperties = array();
- $propertyKeys = explode( ';', $dataItem->getString() );
- foreach ( $propertyKeys as $propertyKey ) {
+
+ foreach ( explode( ';', $dataItem->getString() ) as
$propertyKey ) {
try {
$this->m_diProperties[] = new
SMWDIProperty( $propertyKey );
} catch ( SMWDataItemException $e ) {
@@ -81,7 +83,9 @@
$this->addError( wfMsgForContent(
'smw_parseerror' ) );
}
}
+
$this->m_caption = false;
+
return true;
} else {
return false;
Modified:
trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_Record.php
===================================================================
--- trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_Record.php
2011-06-22 20:10:14 UTC (rev 90599)
+++ trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_Record.php
2011-06-22 20:24:25 UTC (rev 90600)
@@ -257,24 +257,25 @@
* @return array of SMWDIProperty
*/
public static function findPropertyDataItems( $diProperty ) {
- if ( $diProperty !== null ) {
+ if ( !is_null( $diProperty ) ) {
$propertyDiWikiPage = $diProperty->getDiWikiPage();
- }
+
+ if ( !is_null( $propertyDiWikiPage ) ) {
+ $listDiProperty = new SMWDIProperty( '_LIST' );
+ $dataItems = smwfGetStore()->getPropertyValues(
$propertyDiWikiPage, $listDiProperty );
- if ( ( $diProperty === null ) || ( $propertyDiWikiPage === null
) ) {
- return array(); // no property known -> no types
- } else {
- $listDiProperty = new SMWDIProperty( '_LIST' );
- $dataitems = smwfGetStore()->getPropertyValues(
$propertyDiWikiPage, $listDiProperty );
-
- if ( count( $dataitems ) == 1 ) {
- $propertyListValue = new SMWPropertyListValue(
'__pls' );
- $propertyListValue->setDataItem( reset(
$dataitems ) );
- return $propertyListValue->isvalid() ?
$propertyListValue->getPropertyDataItems() : array();
- } else {
- return array();
+ if ( count( $dataItems ) == 1 ) {
+ $propertyListValue = new
SMWPropertyListValue( '__pls' );
+ $propertyListValue->setDataItem(
$dataItems[0] );
+
+ if ( $propertyListValue->isvalid() ) {
+ return
$propertyListValue->getPropertyDataItems();
+ }
+ }
}
}
+
+ return array();
}
////// Internal helper functions
Modified:
trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DataValue.php
===================================================================
--- trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DataValue.php
2011-06-22 20:10:14 UTC (rev 90599)
+++ trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DataValue.php
2011-06-22 20:24:25 UTC (rev 90600)
@@ -336,7 +336,10 @@
* in spite of it being of the right basic type. False is only returned
* if the data item is fundamentally incompatible with the data value.
*
+ * @since 1.6
+ *
* @param $dataitem SMWDataItem
+ *
* @return boolean
*/
abstract protected function loadDataItem( SMWDataItem $dataItem );
@@ -411,6 +414,8 @@
* accessing null. Hence, one must not assume that a non-null return
* value here implies that isValid() returns true.
*
+ * @since 1.6
+ *
* @return SMWDataItem
*/
public function getDataItem() {
@@ -508,6 +513,11 @@
/**
* Return text serialisation of info links. Ensures more uniform layout
* throughout wiki (Factbox, Property pages, ...).
+ *
+ * @param integer $outputformat Element of the SMW_OUTPUT_ enum
+ * @param $linker
+ *
+ * @return string
*/
public function getInfolinkText( $outputformat, $linker = null ) {
$result = '';
@@ -640,6 +650,8 @@
/**
* Return TRUE if a value was defined and understood by the given type,
* and false if parsing errors occured or no value was given.
+ *
+ * @return boolean
*/
public function isValid() {
$this->unstub();
@@ -649,6 +661,8 @@
/**
* Return a string that displays all error messages as a tooltip, or
* an empty string if no errors happened.
+ *
+ * @return string
*/
public function getErrorText() {
return smwfEncodeMessages( $this->mErrors );
@@ -657,6 +671,8 @@
/**
* Return an array of error messages, or an empty array
* if no errors occurred.
+ *
+ * @return array
*/
public function getErrors() {
return $this->mErrors;
@@ -667,6 +683,8 @@
* way. This representation is used by exporters, e.g. to be further
decomposed into
* RDF triples or to generate OWL/XML serialisations.
* If the value is empty or invalid, NULL is returned.
+ *
+ * @return SMWExpData or null
*/
public function getExportData() { // default implementation: encode
values as untyped string
if ( $this->isValid() ) {
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs