CoreFiles by mySites.guru
number.php32 lines, 934 bytes, from Joomla_6.2.0-Stable-Full_Package.zip
Raw History Compare with 6.1.4
md5
b3528eda2bc46c48bda7f3b5c005987f
sha1
4733d546747119a5b18c8cf9fc3478b956bb4fe1
sha256
da4f7823d41d14533b734d68e686949c459032efb72c0f4211291e61f42a4c8d
<?php

/**
 * @package     Joomla.Plugin
 * @subpackage  Fields.Number
 *
 * @copyright   (C) 2025 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

use Joomla\CMS\Language\Text;

$value    = $field->value;
$min      = $field->fieldparams->get('min', null);
$currency = $field->fieldparams->get('currency', 0);
$decimals = $field->fieldparams->get('decimals', 2);
$symbol   = $field->fieldparams->get('symbol', '');
$position = $field->fieldparams->get('position', 0);

if (is_numeric($value)) {
    $value = (float)$value;
    if ($currency) {
        $formattedCurrency = number_format($value, $decimals, Text::_('DECIMALS_SEPARATOR'), Text::_('THOUSANDS_SEPARATOR'));
        $value = $position ? ($formattedCurrency . $symbol) : ($symbol . $formattedCurrency) ;
    }
} else {
    $value = $min ?? '';
}

echo $value;

The same content is in 39 releases, Joomla 6.0.1-rc1 to 6.2.1-rc1. See them all, or every version of this file.