Inherits SMWNumberValue.
Public Member Functions | |
| getUnitList () | |
| Return an array of major unit strings (ids only recommended) supported by this datavalue. | |
| getUnit () | |
| Return the unit in which the returned value is to be interpreted. | |
Protected Member Functions | |
| convertToMainUnit ($number, $unit) | |
| Compute the value based on the given input number and unit string. | |
| makeConversionValues () | |
| This method creates an array of unit-value-pairs that should be printed. | |
| makeUserValue () | |
| This method is used when no user input was given to find the best values for m_unitin and m_caption. | |
| initConversionData () | |
| The remaining functions are relatively "private" but are kept protected since subclasses might exploit this to, e.g., "fake" conversion factors instead of getting them from the database. | |
| initDisplayData () | |
| This method initializes $m_displayunits. | |
Protected Attributes | |
| $m_unitfactors = false | |
| Array with format (canonical unit ID string) => (conversion factor). | |
| $m_unitids = false | |
| Array with format (normalised unit string) => (canonical unit ID string). | |
| $m_displayunits = false | |
| Ordered array of (normalized) units that should be displayed in tooltips, etc. | |
| $m_mainunit = false | |
| Main unit in canonical form (recognised by the conversion factor 1). | |
Those user settings are retrieved from a type page, the DB key of which is the type id of this object.
Definition at line 16 of file SMW_DV_Linear.php.
| SMWLinearValue::convertToMainUnit | ( | $ | number, | |
| $ | unit | |||
| ) | [protected] |
Compute the value based on the given input number and unit string.
If the unit is not supported, return false, otherwise return true. This is called when parsing user input, where the given unit value has already been normalized.
This class does not support any (non-empty) units, but subclasses may overwrite this behavior.
| $number | float value obtained by parsing user input | |
| $unit | string after the numericla user input |
Reimplemented from SMWNumberValue.
Definition at line 27 of file SMW_DV_Linear.php.
References initConversionData().
| SMWLinearValue::makeConversionValues | ( | ) | [protected] |
This method creates an array of unit-value-pairs that should be printed.
Units are the keys and should be canonical unit IDs. The result is stored in $this->m_unitvalues. Again, any class that requires effort for doing this should first check whether the array is already set (i.e. not false) before doing any work. Note that the values should be plain numbers. Output formatting is done later when needed. Also, it should be checked if the value is valid before trying to calculate with its contents. This method also must call or implement convertToMainUnit().
Overwritten by subclasses that support units.
Reimplemented from SMWNumberValue.
Definition at line 38 of file SMW_DV_Linear.php.
References initDisplayData(), and SMWDataValue::isValid().
| SMWLinearValue::makeUserValue | ( | ) | [protected] |
This method is used when no user input was given to find the best values for m_unitin and m_caption.
After conversion, these fields will look as if they were generated from user input, and convertToMainUnit() will have been called (if not, it would be blocked by the presence of m_unitin).
Overwritten by subclasses that support units.
Reimplemented from SMWNumberValue.
Definition at line 60 of file SMW_DV_Linear.php.
References getUnit(), initDisplayData(), SMWNumberValue::normalizeUnit(), and smwfNumberFormat().
| SMWLinearValue::getUnitList | ( | ) |
Return an array of major unit strings (ids only recommended) supported by this datavalue.
Overwritten by subclasses that support units.
Reimplemented from SMWNumberValue.
Definition at line 98 of file SMW_DV_Linear.php.
References initConversionData().
| SMWLinearValue::getUnit | ( | ) |
Return the unit in which the returned value is to be interpreted.
This string is a plain UTF-8 string without wiki or html markup. The returned value is a canonical ID for the main unit. Returns the empty string if no unit is given for the value. Overwritten by subclasses that support units.
Reimplemented from SMWNumberValue.
Definition at line 103 of file SMW_DV_Linear.php.
References initConversionData().
Referenced by makeUserValue().
| SMWLinearValue::initConversionData | ( | ) | [protected] |
The remaining functions are relatively "private" but are kept protected since subclasses might exploit this to, e.g., "fake" conversion factors instead of getting them from the database.
A cheap way of making built-in types. This method initializes $m_unitfactors, $m_unitids, and $m_mainunit.
Definition at line 115 of file SMW_DV_Linear.php.
References SMWDataValue::addError(), SMWDataValueFactory::findTypeLabel(), SMWDataValue::getTypeID(), SMWNumberValue::normalizeUnit(), SMWNumberValue::parseNumberValue(), smwfGetStore(), smwfLoadExtensionMessages(), and SMWDataItem::TYPE_STRING.
Referenced by convertToMainUnit(), getUnit(), getUnitList(), and initDisplayData().
| SMWLinearValue::initDisplayData | ( | ) | [protected] |
This method initializes $m_displayunits.
Definition at line 171 of file SMW_DV_Linear.php.
References initConversionData(), SMWNumberValue::normalizeUnit(), smwfGetStore(), and SMWDataItem::TYPE_STRING.
Referenced by makeConversionValues(), and makeUserValue().
SMWLinearValue::$m_unitfactors = false [protected] |
Array with format (canonical unit ID string) => (conversion factor).
Definition at line 19 of file SMW_DV_Linear.php.
SMWLinearValue::$m_unitids = false [protected] |
Array with format (normalised unit string) => (canonical unit ID string).
Definition at line 21 of file SMW_DV_Linear.php.
SMWLinearValue::$m_displayunits = false [protected] |
Ordered array of (normalized) units that should be displayed in tooltips, etc.
Definition at line 23 of file SMW_DV_Linear.php.
SMWLinearValue::$m_mainunit = false [protected] |
Main unit in canonical form (recognised by the conversion factor 1).
Definition at line 25 of file SMW_DV_Linear.php.
1.5.6