public function getLengthOrSizeAsText() { $length = $this->articles[$article_id]['length']; if (self::isUsingSizeInsteadOfLength($this->category_id)) { $length = translateLength2Size($length); } else { if (self::isUsingLengthInMilimeter($this->category_id)) { $length = round($length * 10); } if ($length > 0) { $length = number_format($length, 0); } else { $length = ''; } } return $length; }
function textLength($length, $show_unit = true) { if (!function_exists('is_decimal')) { function is_decimal($var) { return $var - intval($var) > 0; } } $length_decimal = is_decimal($length); if ($length == 0) { $result = ''; } elseif ($length < 1) { $result = translateLength2Size($length); } elseif ($length < 10) { $result = $length * 10 . ($show_unit ? ' mm' : ''); } else { $length_value = !$length_decimal ? intval($length) : $length; $result = $length_value . ($show_unit ? ' cm' : ''); } return $result; }