CoreFiles by mySites.guru
number.php32 lines, 933 bytes, from Joomla_6.0.0-Stable-Full_Package.zip
Raw History Compare with 5.4.10
md5
bc09a32c2cb067602281b35b21e4090b
sha1
f19d95c90b4492c4533acd08b306124275d17d71
sha256
3ae9fa67d6a0854c895cdb1309689269dbc443b47c7fec551e70a117709d3ebd
<?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', 2);
$position = $field->fieldparams->get('position', 2);

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 8 releases, Joomla 6.0.0-beta1 to 6.0.0. See them all, or every version of this file.