Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
90ee79e
First draft for numbers custom field plugin
TLWebdesign Aug 24, 2024
b1afbe2
Apply suggestions from code review
TLWebdesign Aug 24, 2024
3ec13f1
Apply suggestions from code review
TLWebdesign Aug 25, 2024
3d8f2bc
added install sql and removed unused field param
TLWebdesign Sep 2, 2024
9a70c69
Merge branch '6.0-dev' into 5.2-dev
TLWebdesign Mar 14, 2025
b9d3036
updated copyright year
TLWebdesign Mar 14, 2025
570a0a5
Update plugins/fields/number/tmpl/number.php
TLWebdesign Mar 14, 2025
fdced95
Added update sql and currency formatting option
TLWebdesign Mar 15, 2025
c65fbdc
cleaned up language strings
TLWebdesign Mar 24, 2025
1810ba0
Fixed years to 2025 and version number to be in line with joomla version
TLWebdesign Mar 24, 2025
e249175
Alpha sorted the strings
TLWebdesign Mar 24, 2025
0f8274d
fixed stupid mistake.
TLWebdesign Mar 24, 2025
6bdf7e1
updated sql files to include all the default params settings
TLWebdesign Mar 24, 2025
9d148c4
changed indentation
TLWebdesign Mar 24, 2025
7d38756
fix sorting of field params
TLWebdesign Mar 25, 2025
d0665b0
Update administrator/language/en-GB/plg_fields_number.ini
TLWebdesign Mar 25, 2025
acca4e7
Update administrator/language/en-GB/plg_fields_number.ini
TLWebdesign Mar 25, 2025
d86943a
removed unnecessary description
TLWebdesign Mar 25, 2025
c7ac6ff
Changed update SQL file to own file and reverted changes to other file
TLWebdesign Apr 1, 2025
ead2fcb
Update administrator/language/en-GB/plg_fields_number.ini
TLWebdesign Apr 10, 2025
47cef73
Merge branch '6.0-dev' into 5.2-dev
TLWebdesign Jun 2, 2025
c6f6b64
Merge branch '6.0-dev' into 5.2-dev
TLWebdesign Jun 12, 2025
e720107
Merge branch '6.0-dev' into 5.2-dev
TLWebdesign Aug 14, 2025
730bd3a
Merge branch '6.0-dev' into 5.2-dev
Bodge-IT Aug 15, 2025
2661516
removed unnecessary descriptions
TLWebdesign Aug 15, 2025
b89199b
removed unneccessary descriptions
TLWebdesign Aug 15, 2025
8e8f3e2
removed more unnecessary descriptions and added default in the params…
TLWebdesign Aug 16, 2025
72ea857
Update administrator/components/com_admin/sql/updates/postgresql/6.0.…
TLWebdesign Aug 16, 2025
61fc118
changed sql name
TLWebdesign Aug 16, 2025
8b59343
Merge branch '5.2-dev' of https://github.com/TLWebdesign/joomla-cms i…
TLWebdesign Aug 16, 2025
3044c15
Update 6.0.0-2024-08-24.sql
TLWebdesign Aug 16, 2025
6851218
Rename 6.0.0-2024-08-24.sql to 6.0.0-2025-08-17.sql
Bodge-IT Aug 16, 2025
6372998
Rename 6.0.0-2024-08-24.sql to 6.0.0-2025-08-17.sql
Bodge-IT Aug 16, 2025
42a494c
Merge branch '5.2-dev' of https://github.com/TLWebdesign/joomla-cms i…
TLWebdesign Aug 16, 2025
add1023
Merge branch '6.0-dev' into 5.2-dev
richard67 Aug 16, 2025
494ee13
Merge branch '6.0-dev' into 5.2-dev
richard67 Aug 16, 2025
dcafe21
Merge branch '6.0-dev' into 5.2-dev
Bodge-IT Aug 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
INSERT INTO `#__extensions` (`package_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `locked`, `manifest_cache`, `params`, `custom_data`, `ordering`, `state`) VALUES
(0, 'plg_fields_number', 'plugin', 'number', 'fields', 0, 1, 1, 0, 1, '', '{"min":"1.0","max":"100.0","step":"0.1","currency":"0","position":"0","decimals":"2"}', '', -1, 0);
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
INSERT INTO "#__extensions" ("package_id", "name", "type", "element", "folder", "client_id", "enabled", "access", "protected", "locked", "manifest_cache", "params", "custom_data", "ordering", "state") VALUES
(0, 'plg_fields_number', 'plugin', 'number', 'fields', 0, 1, 1, 0, 1, '', '{"min":"1.0","max":"100.0","step":"0.1","currency":"0","position":"0","decimals":"2"}', '', -1, 0);
19 changes: 19 additions & 0 deletions administrator/language/en-GB/plg_fields_number.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
; Joomla! Project
; (C) 2025 Open Source Matters, Inc. <https://www.joomla.org>
; License GNU General Public License version 2 or later; see LICENSE.txt
; Note : All ini files need to be saved as UTF-8

PLG_FIELDS_NUMBER="Fields - Number"
PLG_FIELDS_NUMBER_LABEL="Number (%s)"
PLG_FIELDS_NUMBER_PARAMS_CURRENCY_LABEL="Format as Currency"
PLG_FIELDS_NUMBER_PARAMS_DECIMALS_LABEL="Number of Decimals"
PLG_FIELDS_NUMBER_PARAMS_MAX_DESC="Maximum value that can be chosen (only limits the up/down arrows)."
PLG_FIELDS_NUMBER_PARAMS_MAX_LABEL="Maximum"
PLG_FIELDS_NUMBER_PARAMS_MIN_DESC="Minimum value that can be chosen (only limits the up/down arrows)."
PLG_FIELDS_NUMBER_PARAMS_MIN_LABEL="Minimum"
PLG_FIELDS_NUMBER_PARAMS_POSITION_LABEL="Symbol Position"
PLG_FIELDS_NUMBER_PARAMS_POSITION_OPTION_AFTER="After"
PLG_FIELDS_NUMBER_PARAMS_POSITION_OPTION_BEFORE="Before"
PLG_FIELDS_NUMBER_PARAMS_STEP_LABEL="Step Increment"
PLG_FIELDS_NUMBER_PARAMS_SYMBOL_LABEL="Currency Symbol"
PLG_FIELDS_NUMBER_XML_DESCRIPTION="This plugin lets you create new fields of type 'number' in any extensions where custom fields are supported."
7 changes: 7 additions & 0 deletions administrator/language/en-GB/plg_fields_number.sys.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
; Joomla! Project
; (C) 2025 Open Source Matters, Inc. <https://www.joomla.org>
; License GNU General Public License version 2 or later; see LICENSE.txt
; Note : All ini files need to be saved as UTF-8

PLG_FIELDS_NUMBER="Fields - Number"
PLG_FIELDS_NUMBER_XML_DESCRIPTION="This plugin lets you create new fields of type 'number' in any extensions where custom fields are supported."
17 changes: 9 additions & 8 deletions installation/sql/mysql/base.sql
Original file line number Diff line number Diff line change
Expand Up @@ -299,14 +299,15 @@ INSERT INTO `#__extensions` (`package_id`, `name`, `type`, `element`, `folder`,
(0, 'plg_fields_list', 'plugin', 'list', 'fields', 0, 1, 1, 0, 1, '', '', '', 7, 0),
(0, 'plg_fields_media', 'plugin', 'media', 'fields', 0, 1, 1, 0, 1, '', '', '', 8, 0),
(0, 'plg_fields_note', 'plugin', 'note', 'fields', 0, 1, 1, 0, 1, '', '{"class":"alert alert-info","heading":"h4"}', '', 9, 0),
(0, 'plg_fields_radio', 'plugin', 'radio', 'fields', 0, 1, 1, 0, 1, '', '', '', 10, 0),
(0, 'plg_fields_sql', 'plugin', 'sql', 'fields', 0, 1, 1, 0, 1, '', '', '', 11, 0),
(0, 'plg_fields_subform', 'plugin', 'subform', 'fields', 0, 1, 1, 0, 1, '', '', '', 12, 0),
(0, 'plg_fields_text', 'plugin', 'text', 'fields', 0, 1, 1, 0, 1, '', '', '', 13, 0),
(0, 'plg_fields_textarea', 'plugin', 'textarea', 'fields', 0, 1, 1, 0, 1, '', '{"rows":10,"cols":10,"maxlength":"","filter":"\\\\Joomla\\\\CMS\\\\Component\\\\ComponentHelper::filterText"}', '', 14, 0),
(0, 'plg_fields_url', 'plugin', 'url', 'fields', 0, 1, 1, 0, 1, '', '', '', 15, 0),
(0, 'plg_fields_user', 'plugin', 'user', 'fields', 0, 1, 1, 0, 1, '', '', '', 16, 0),
(0, 'plg_fields_usergrouplist', 'plugin', 'usergrouplist', 'fields', 0, 1, 1, 0, 1, '', '', '', 17, 0),
(0, 'plg_fields_number', 'plugin', 'number', 'fields', 0, 1, 1, 0, 1, '', '{"min":"1.0","max":"100.0","step":"0.1","currency":"0","position":"0","decimals":"2"}', '', 10, 0),
(0, 'plg_fields_radio', 'plugin', 'radio', 'fields', 0, 1, 1, 0, 1, '', '', '', 11, 0),
(0, 'plg_fields_sql', 'plugin', 'sql', 'fields', 0, 1, 1, 0, 1, '', '', '', 12, 0),
(0, 'plg_fields_subform', 'plugin', 'subform', 'fields', 0, 1, 1, 0, 1, '', '', '', 13, 0),
(0, 'plg_fields_text', 'plugin', 'text', 'fields', 0, 1, 1, 0, 1, '', '', '', 14, 0),
(0, 'plg_fields_textarea', 'plugin', 'textarea', 'fields', 0, 1, 1, 0, 1, '', '{"rows":10,"cols":10,"maxlength":"","filter":"\\\\Joomla\\\\CMS\\\\Component\\\\ComponentHelper::filterText"}', '', 15, 0),
(0, 'plg_fields_url', 'plugin', 'url', 'fields', 0, 1, 1, 0, 1, '', '', '', 16, 0),
(0, 'plg_fields_user', 'plugin', 'user', 'fields', 0, 1, 1, 0, 1, '', '', '', 17, 0),
(0, 'plg_fields_usergrouplist', 'plugin', 'usergrouplist', 'fields', 0, 1, 1, 0, 1, '', '', '', 18, 0),
(0, 'plg_filesystem_local', 'plugin', 'local', 'filesystem', 0, 1, 1, 0, 1, '', '{}', '', 1, 0),
(0, 'plg_finder_categories', 'plugin', 'categories', 'finder', 0, 1, 1, 0, 1, '', '', '', 1, 0),
(0, 'plg_finder_contacts', 'plugin', 'contacts', 'finder', 0, 1, 1, 0, 1, '', '', '', 2, 0),
Expand Down
17 changes: 9 additions & 8 deletions installation/sql/postgresql/base.sql
Original file line number Diff line number Diff line change
Expand Up @@ -305,14 +305,15 @@ INSERT INTO "#__extensions" ("package_id", "name", "type", "element", "folder",
(0, 'plg_fields_list', 'plugin', 'list', 'fields', 0, 1, 1, 0, 1, '', '', '', 7, 0),
(0, 'plg_fields_media', 'plugin', 'media', 'fields', 0, 1, 1, 0, 1, '', '', '', 8, 0),
(0, 'plg_fields_note', 'plugin', 'note', 'fields', 0, 1, 1, 0, 1, '', '{"class":"alert alert-info","heading":"h4"}', '', 9, 0),
(0, 'plg_fields_radio', 'plugin', 'radio', 'fields', 0, 1, 1, 0, 1, '', '', '', 10, 0),
(0, 'plg_fields_sql', 'plugin', 'sql', 'fields', 0, 1, 1, 0, 1, '', '', '', 11, 0),
(0, 'plg_fields_subform', 'plugin', 'subform', 'fields', 0, 1, 1, 0, 1, '', '', '', 12, 0),
(0, 'plg_fields_text', 'plugin', 'text', 'fields', 0, 1, 1, 0, 1, '', '', '', 13, 0),
(0, 'plg_fields_textarea', 'plugin', 'textarea', 'fields', 0, 1, 1, 0, 1, '', '{"rows":10,"cols":10,"maxlength":"","filter":"\\\\Joomla\\\\CMS\\\\Component\\\\ComponentHelper::filterText"}', '', 14, 0),
(0, 'plg_fields_url', 'plugin', 'url', 'fields', 0, 1, 1, 0, 1, '', '', '', 15, 0),
(0, 'plg_fields_user', 'plugin', 'user', 'fields', 0, 1, 1, 0, 1, '', '', '', 16, 0),
(0, 'plg_fields_usergrouplist', 'plugin', 'usergrouplist', 'fields', 0, 1, 1, 0, 1, '', '', '', 17, 0),
(0, 'plg_fields_number', 'plugin', 'number', 'fields', 0, 1, 1, 0, 1, '', '{"min":"1.0","max":"100.0","step":"0.1","currency":"0","position":"0","decimals":"2"}', '', 10, 0),
(0, 'plg_fields_radio', 'plugin', 'radio', 'fields', 0, 1, 1, 0, 1, '', '', '', 11, 0),
(0, 'plg_fields_sql', 'plugin', 'sql', 'fields', 0, 1, 1, 0, 1, '', '', '', 12, 0),
(0, 'plg_fields_subform', 'plugin', 'subform', 'fields', 0, 1, 1, 0, 1, '', '', '', 13, 0),
(0, 'plg_fields_text', 'plugin', 'text', 'fields', 0, 1, 1, 0, 1, '', '', '', 14, 0),
(0, 'plg_fields_textarea', 'plugin', 'textarea', 'fields', 0, 1, 1, 0, 1, '', '{"rows":10,"cols":10,"maxlength":"","filter":"\\\\Joomla\\\\CMS\\\\Component\\\\ComponentHelper::filterText"}', '', 15, 0),
(0, 'plg_fields_url', 'plugin', 'url', 'fields', 0, 1, 1, 0, 1, '', '', '', 16, 0),
(0, 'plg_fields_user', 'plugin', 'user', 'fields', 0, 1, 1, 0, 1, '', '', '', 17, 0),
(0, 'plg_fields_usergrouplist', 'plugin', 'usergrouplist', 'fields', 0, 1, 1, 0, 1, '', '', '', 18, 0),
(0, 'plg_filesystem_local', 'plugin', 'local', 'filesystem', 0, 1, 1, 0, 1, '', '{}', '', 1, 0),
(0, 'plg_finder_categories', 'plugin', 'categories', 'finder', 0, 1, 1, 0, 1, '', '', '', 1, 0),
(0, 'plg_finder_contacts', 'plugin', 'contacts', 'finder', 0, 1, 1, 0, 1, '', '', '', 2, 0),
Expand Down
97 changes: 97 additions & 0 deletions plugins/fields/number/number.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension type="plugin" group="fields" method="upgrade">
<name>plg_fields_number</name>
<author>Joomla! Project</author>
<creationDate>2025-03</creationDate>
<copyright>(C) 2025 Open Source Matters, Inc.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>6.0.0</version>
<description>PLG_FIELDS_NUMBER_XML_DESCRIPTION</description>
<namespace path="src">Joomla\Plugin\Fields\Number</namespace>
<files>
<folder>params</folder>
<folder plugin="number">services</folder>
<folder>src</folder>
<folder>tmpl</folder>
</files>
<languages>
<language tag="en-GB">language/en-GB/plg_fields_number.ini</language>
<language tag="en-GB">language/en-GB/plg_fields_number.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field
name="min"
type="number"
label="PLG_FIELDS_NUMBER_PARAMS_MIN_LABEL"
description="PLG_FIELDS_NUMBER_PARAMS_MIN_DESC"
default="1.0"
filter="float"
/>

<field
name="max"
type="number"
label="PLG_FIELDS_NUMBER_PARAMS_MAX_LABEL"
description="PLG_FIELDS_NUMBER_PARAMS_MAX_DESC"
default="100.0"
filter="float"
/>

<field
name="step"
type="number"
label="PLG_FIELDS_NUMBER_PARAMS_STEP_LABEL"
default="1.0"
filter="float"
/>

<field
name="currency"
type="radio"
label="PLG_FIELDS_NUMBER_PARAMS_CURRENCY_LABEL"
layout="joomla.form.field.radio.switcher"
default="0"
filter="integer"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>

<field
name="symbol"
type="text"
label="PLG_FIELDS_NUMBER_PARAMS_SYMBOL_LABEL"
filter="string"
showon="currency:1"
/>

<field
name="position"
type="list"
label="PLG_FIELDS_NUMBER_PARAMS_POSITION_LABEL"
default="0"
filter="integer"
showon="currency:1"
>
<option value="0">PLG_FIELDS_NUMBER_PARAMS_POSITION_OPTION_BEFORE</option>
<option value="1">PLG_FIELDS_NUMBER_PARAMS_POSITION_OPTION_AFTER</option>
</field>

<field
name="decimals"
type="int"
label="PLG_FIELDS_NUMBER_PARAMS_DECIMALS_LABEL"
min="0"
max="10"
default="2"
filter="int"
showon="currency:1"
/>
</fieldset>
</fields>
</config>
</extension>
73 changes: 73 additions & 0 deletions plugins/fields/number/params/number.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<form>
<fields name="fieldparams">
<fieldset name="fieldparams">
<field
name="min"
type="number"
label="PLG_FIELDS_NUMBER_PARAMS_MIN_LABEL"
description="PLG_FIELDS_NUMBER_PARAMS_MIN_DESC"
filter="float"
/>

<field
name="max"
type="number"
label="PLG_FIELDS_NUMBER_PARAMS_MAX_LABEL"
description="PLG_FIELDS_NUMBER_PARAMS_MAX_DESC"
filter="float"
/>

<field
name="step"
type="number"
label="PLG_FIELDS_NUMBER_PARAMS_STEP_LABEL"
default="1.0"
filter="float"
/>

<field
name="currency"
type="radio"
label="PLG_FIELDS_NUMBER_PARAMS_CURRENCY_LABEL"
layout="joomla.form.field.radio.switcher"
default="0"
filter="integer"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>

<field
name="symbol"
type="text"
label="PLG_FIELDS_NUMBER_PARAMS_SYMBOL_LABEL"
filter="string"
showon="currency:1"
/>

<field
name="position"
type="list"
label="PLG_FIELDS_NUMBER_PARAMS_POSITION_LABEL"
default="0"
filter="integer"
showon="currency:1"
>
<option value="0">PLG_FIELDS_NUMBER_PARAMS_POSITION_OPTION_BEFORE</option>
<option value="1">PLG_FIELDS_NUMBER_PARAMS_POSITION_OPTION_AFTER</option>
</field>

<field
name="decimals"
type="int"
label="PLG_FIELDS_NUMBER_PARAMS_DECIMALS_LABEL"
default="2"
filter="integer"
showon="currency:1"
min="0"
max="10"
/>
</fieldset>
</fields>
</form>
46 changes: 46 additions & 0 deletions plugins/fields/number/services/provider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?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\Extension\PluginInterface;
use Joomla\CMS\Factory;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Event\DispatcherInterface;
use Joomla\Plugin\Fields\Number\Extension\Number;

return new class () implements ServiceProviderInterface {
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public function register(Container $container)
{
$container->set(
PluginInterface::class,
function (Container $container) {
$plugin = new Number(
$container->get(DispatcherInterface::class),
(array) PluginHelper::getPlugin('fields', 'number')
);
$plugin->setApplication(Factory::getApplication());

return $plugin;
}
);
}
};
27 changes: 27 additions & 0 deletions plugins/fields/number/src/Extension/Number.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?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
*/

namespace Joomla\Plugin\Fields\Number\Extension;

use Joomla\Component\Fields\Administrator\Plugin\FieldsPlugin;
use Joomla\Event\SubscriberInterface;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
* Fields Number Plugin
*
* @since __DEPLOY_VERSION__
*/
final class Number extends FieldsPlugin implements SubscriberInterface
{
}
32 changes: 32 additions & 0 deletions plugins/fields/number/tmpl/number.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?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;
Loading