Index: . =================================================================== --- . (revision 19692) +++ . (working copy) @@ -117,7 +117,7 @@ * static methods provided below. * @access private */ - function SMWDataValue($type = NULL, $desiredUnits = array()) { + function SMWDataValue($type = NULL, $desiredUnits = false) { $this->clear(); $this->type_handler = $type; @@ -124,8 +124,8 @@ $this->skin = NULL; $this->attribute = false; $this->desiredUnits = $desiredUnits; - $this->possibleValues = array(); - $this->serviceLinks = array(); + $this->possibleValues = false; + $this->serviceLinks = false; } /*********************************************************************/ @@ -143,11 +143,9 @@ $result = new SMWDataValue($type); $result->setSkin($skin); $result->attribute = $attribute; - $result->desiredUnits = SMWTypeHandlerFactory::getUnitsList($attribute); // TODO: Maybe only get this for attributes types that can support it, or only get if requested? - $result->possibleValues = SMWTypeHandlerFactory::getPossibleValues($attribute); - $result->serviceLinks = SMWTypeHandlerFactory::getServiceLinks($attribute); - if ($value !== false) $result->setUserValue($value); + if ($value !== false) + $result->setUserValue($value); return $result; } @@ -162,7 +160,8 @@ $type = SMWTypeHandlerFactory::getSpecialTypeHandler($specialprop); $result = new SMWDataValue($type); $result->setSkin($skin); - if ($value !== false) $result->setUserValue($value); + if ($value !== false) + $result->setUserValue($value); return $result; } @@ -275,8 +274,9 @@ function addServiceLinks() { $args = func_get_args(); array_unshift($args, ''); // add a 0 element as placeholder + $serviceLinks = $this->getServiceLinks(); - foreach ($this->serviceLinks as $sid) { + foreach ($serviceLinks as $sid) { $args[0] = "smw_service_$sid"; $text = call_user_func_array('wfMsgForContent', $args); $links = preg_split("([\n][\s]?)", $text); @@ -325,8 +325,9 @@ $this->desiredUnits = $desiredUnits; } + /** - * Specify an array of service links. See SMWDatavalue::serviceLinks for details. + * Specify an array of service links. See SMWDataValue::serviceLinks for details. */ function setServiceLinks($serviceLinks) { $this->serviceLinks = $serviceLinks; @@ -500,14 +501,45 @@ * Return the array of desired units (possibly empty if not given). */ function getDesiredUnits() { - return $this->desiredUnits; + // If we don't have a value for this, get it from the attribute. + if ($this->desiredUnits === false && $this->attribute != false) { + $this->desiredUnits = SMWTypeHandlerFactory::getUnitsList($this->attribute); + } + if ($this->desiredUnits === false) { + return Array(); + } else { + return $this->desiredUnits; + } + } + + /** + * Return the array of service links (possibly empty if not given). + */ + function getServiceLinks() { + // If we don't have a value for this, get it from the attribute. + if ($this->serviceLinks === false && $this->attribute != false) { + $this->serviceLinks = SMWTypeHandlerFactory::getServiceLinks($this->attribute); + } + if ($this->serviceLinks === false) { + return Array(); + } else { + return $this->serviceLinks; + } } /** - * Return the possible values (possibly empty if not given). + * Return the array of possible values (possibly empty if not given). */ function getPossibleValues() { - return $this->possibleValues; + // If we don't have a value for this, get it from the attribute. + if ($this->possibleValues === false && $this->attribute != false) { + $this->possibleValues = SMWTypeHandlerFactory::getPossibleValues($this->attribute); + } + if ($this->possibleValues === false) { + return Array(); + } else { + return $this->possibleValues; + } } /**