/** * @since 2.4 * * @param DIProperty $property */ public function fetchConversionData(DIProperty $property) { $this->unitIds = array(); $this->unitFactors = array(); $this->mainUnit = false; $this->prefixalUnitPreference = array(); $this->errors = array(); $factors = $this->cachedPropertyValuesPrefetcher->getPropertyValues($property->getDiWikiPage(), new DIProperty('_CONV')); $this->numberValue->setContextPage($property->getDiWikiPage()); if ($factors === null || $factors === array()) { // no custom type return $this->errors[] = 'smw_nounitsdeclared'; } $number = ''; $unit = ''; foreach ($factors as $di) { // ignore corrupted data and bogus inputs if (!$di instanceof DIBlob || $this->numberValue->parseNumberValue($di->getString(), $number, $unit, $asPrefix) != 0 || $number == 0) { continue; } $this->matchUnitAliases($number, $asPrefix, preg_split('/\\s*,\\s*/u', $unit)); } // No unit with factor 1? Make empty string the main unit. if ($this->mainUnit === false) { $this->mainUnit = ''; } // Always add an extra empty unit; not as a synonym for the main unit // but as a new unit with ID '' so if users do not give any unit, the // conversion tooltip will still display the main unit for clarity // (the empty unit is never displayed; we filter it when making // conversion values) $this->unitFactors = array('' => 1) + $this->unitFactors; $this->unitIds[''] = ''; }