Semantic MediaWiki and related extensions
|
Public Attributes | |
const | TYPE_ID = '_num' |
const | NO_DISP_PRECISION_LIMIT = 'num.no.displayprecision.limit' |
const | DECIMAL_SEPARATOR = 'decimal.separator' |
const | THOUSANDS_SEPARATOR = 'thousands.separator' |
Public Attributes inherited from SMWDataValue | |
const | OPT_USER_LANGUAGE = 'user.language' |
const | OPT_CONTENT_LANGUAGE = 'content.language' |
const | OPT_QUERY_CONTEXT = 'query.context' |
const | OPT_QUERY_COMP_CONTEXT = 'query.comparator.context' |
const | OPT_DISABLE_INFOLINKS = 'disable.infolinks' |
const | OPT_DISABLE_SERVICELINKS = 'disable.servicelinks' |
const | OPT_COMPACT_INFOLINKS = 'compact.infolinks' |
Protected Member Functions | |
parseUserValue ( $value) | |
loadDataItem (SMWDataItem $dataItem) | |
getServiceLinkParams () | |
convertToMainUnit ( $number, $unit) | |
makeConversionValues () | |
makeUserValue () | |
getPreferredDisplayPrecision () | |
Protected Member Functions inherited from SMWDataValue | |
getOptions () | |
parseUserValue ( $value) | |
loadDataItem (SMWDataItem $dataItem) | |
getServiceLinkParams () | |
checkAllowedValues () | |
Protected Attributes | |
$m_unitvalues | |
$prefixalUnitPreference = [] | |
$m_unitin | |
$precision = null | |
Protected Attributes inherited from SMWDataValue | |
$m_dataitem | |
$m_property = null | |
$m_contextPage = null | |
$m_caption | |
$m_typeid | |
$m_outformat = false | |
$restrictionError = false | |
$dataValueServiceFactory | |
Additional Inherited Members | |
Static Public Member Functions inherited from SMWDataValue | |
static | prepareValue (&$value, &$comparator) |
This datavalue implements numerical datavalues, and supports optional unit conversions. It parses and manages unit strings, since even plain numbers may have (not further specified) units that are stored. However, only subclasses implement full unit conversion by extending the methods convertToMainUnit() and makeConversionValues().
Units work as follows: a unit is a string, but many such strings might refer to the same unit of measurement. There is always one string, that canonically represents the unit, and we will call this version of writing the unit the /unit id/. IDs for units are needed for tasks like duplicate avoidance. If no conversion information is given, any unit is its own ID. In any case, units are /normalised/, i.e. given a more standardised meaning before being processed. All units, IDs or otherwise, should be suitable for printout in wikitext, and main IDs should moreover be suitable for printout in HTML.
Subclasses that support unit conversion may interpret the output format set via setOutputFormat() to allow a unit to be selected for display. Note that this setting does not affect the internal representation of the value though. So choosing a specific output format will change the behavior of output functions like getLongWikiText(), but not of functions that access the value itself, such as getUnit() or getDBKeys().
SMWNumberValue::__construct | ( | $typeid = '' | ) |
string | $typeid |
|
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 |
SMWNumberValue::getCanonicalMainUnit | ( | ) |
SMWNumberValue::getConvertedUnitValues | ( | ) |
Returns array of converted unit-value-pairs that can be printed.
SMWNumberValue::getInfolinks | ( | ) |
SMWNumberValue::getLocalizedFormattedNumber | ( | $value | ) |
SMWNumberValue::getLongHTMLText | ( | $linker = null | ) |
SMWNumberValue::getLongWikiText | ( | $linker = null | ) |
SMWNumberValue::getNormalizedFormattedNumber | ( | $value | ) |
SMWNumberValue::getNumber | ( | ) |
|
protected |
Create links to mapping services based on a wiki-editable message. The parameters available to the message are: $1: string of numerical value in English punctuation $2: string of integer version of value, in English punctuation
SMWNumberValue::getShortHTMLText | ( | $linker = null | ) |
SMWNumberValue::getShortWikiText | ( | $linker = null | ) |
SMWNumberValue::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.
SMWNumberValue::getUnitList | ( | ) |
Return an array of major unit strings (ids only recommended) supported by this datavalue.
Overwritten by subclasses that support units.
SMWNumberValue::getWikiValue | ( | ) |
SMWNumberValue::hasPrefixalUnitPreference | ( | $unit | ) |
string | $unit |
|
protected |
|
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.
|
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.
SMWNumberValue::normalizeUnit | ( | $unit | ) |
Transform a (typically unit-) string into a normalised form, so that, e.g., "km²" and "km<sup>2</sup>" do not need to be distinguished.
SMWNumberValue::parseNumberValue | ( | $value, | |
& | $number, | ||
& | $unit, | ||
& | $asPrefix = false |
||
) |
Parse a string of the form "number unit" where unit is optional. The results are stored in the $number and $unit parameters. Returns an error code.
$value | string to parse |
$number | call-by-ref parameter that will be set to the numerical value |
$unit | call-by-ref parameter that will be set to the "unit" string (after the number) |
|
protected |
SMWNumberValue::setOutputFormat | ( | $formatstring | ) |
$string | $formatstring |
const SMWNumberValue::DECIMAL_SEPARATOR = 'decimal.separator' |
Separator related constants
const SMWNumberValue::NO_DISP_PRECISION_LIMIT = 'num.no.displayprecision.limit' |
Internal state to ensure no precision limitation is applied to an output
const SMWNumberValue::TYPE_ID = '_num' |
DV identifier