25 #require_once 'Zend/Measure/Abstract.php'; 26 #require_once 'Zend/Locale.php'; 62 'BINARY' => array(2,
'⑵'),
63 'TERNARY' => array(3,
'⑶'),
64 'QUATERNARY' => array(4,
'⑷'),
65 'QUINARY' => array(5,
'⑸'),
66 'SENARY' => array(6,
'⑹'),
67 'SEPTENARY' => array(7,
'⑺'),
68 'OCTAL' => array(8,
'⑻'),
69 'NONARY' => array(9,
'⑼'),
70 'DECIMAL' => array(10,
'⑽'),
71 'DUODECIMAL' => array(12,
'⑿'),
72 'HEXADECIMAL' => array(16,
'⒃'),
73 'ROMAN' => array(99,
''),
74 'STANDARD' =>
'DECIMAL' 82 private static $_roman = array(
115 private static $_romanconvert = array(
152 if ($locale ===
null) {
158 #require_once 'Zend/Measure/Exception.php'; 165 $this->_locale = (string) $locale;
167 if (
$type ===
null) {
168 $type = $this->_units[
'STANDARD'];
171 if (isset($this->_units[
$type]) ===
false) {
172 #require_once 'Zend/Measure/Exception.php'; 189 if (empty($locale)) {
193 if (empty($this->_units[
$type])) {
194 #require_once 'Zend/Measure/Exception.php'; 200 preg_match(
'/[01]+/',
$value, $ergebnis);
205 preg_match(
'/[012]+/',
$value, $ergebnis);
210 preg_match(
'/[0123]+/',
$value, $ergebnis);
215 preg_match(
'/[01234]+/',
$value, $ergebnis);
220 preg_match(
'/[012345]+/',
$value, $ergebnis);
225 preg_match(
'/[0123456]+/',
$value, $ergebnis);
230 preg_match(
'/[01234567]+/',
$value, $ergebnis);
235 preg_match(
'/[012345678]+/',
$value, $ergebnis);
240 preg_match(
'/[0123456789AB]+/', strtoupper(
$value), $ergebnis);
245 preg_match(
'/[0123456789ABCDEF]+/', strtoupper(
$value), $ergebnis);
250 preg_match(
'/[IVXLCDM_]+/', strtoupper(
$value), $ergebnis);
257 }
catch (Exception $e) {
258 #require_once 'Zend/Measure/Exception.php'; 268 $this->_type =
$type;
278 private function _toDecimal($input,
$type)
282 if ($this->_units[
$type][0] <= 16) {
283 $split = str_split($input);
284 $length = strlen($input);
285 for ($x = 0; $x < $length; ++$x) {
286 $split[$x] = hexdec($split[$x]);
294 if (
$type ===
'ROMAN') {
295 $input = strtoupper($input);
296 $input = preg_replace(array_keys(self::$_romanconvert), array_values(self::$_romanconvert), $input);
298 $split = preg_split(
'//', strrev($input), -1, PREG_SPLIT_NO_EMPTY);
300 for ($x =0; $x <
sizeof($split); $x++) {
301 if ($split[$x] ==
'/') {
305 $num = self::$_roman[$split[$x]];
306 if (($x > 0 and ($split[$x-1] !=
'/') and ($num < self::$_roman[$split[$x-1]]))) {
313 str_replace(
'/',
'',
$value);
330 if ($this->_units[
$type][0] <= 16) {
338 $newvalue = strtoupper(dechex(
$target)) . $newvalue;
345 #require_once 'Zend/Measure/Exception.php'; 346 throw new Zend_Measure_Exception(
"Your value '$tempvalue' cannot be processed because it extends 200 digits");
350 if ($newvalue ===
'') {
355 if (
$type ===
'ROMAN') {
358 $romanval = array_values(array_reverse(self::$_roman));
359 $romankey = array_keys(array_reverse(self::$_roman));
364 $newvalue .= $romankey[
$i];
372 #require_once 'Zend/Measure/Exception.php'; 373 throw new Zend_Measure_Exception(
"Your value '$tempvalue' cannot be processed because it extends 200 digits");
380 $newvalue = str_replace(
'/',
'', preg_replace(array_values(self::$_romanconvert), array_keys(self::$_romanconvert), $newvalue));
395 if (empty($this->_units[
$type]) ===
true) {
396 #require_once 'Zend/Measure/Exception.php'; 404 $this->_type =
$type;
420 if ($this->
getType() === self::ROMAN) {
424 return $this->
toString($round, $locale);
__construct($value, $type, $locale=null)
toString($round=-1, $locale=null)
call_user_func($callable, $param)
static isLocale($locale, $strict=false, $compatible=true)
getValue($round=-1, $locale=null)
setValue($value, $type=null, $locale=null)
convertTo($type, $round=0, $locale=null)