-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[6.0] Numbers custom fields plugin #43974
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
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 b1afbe2
Apply suggestions from code review
TLWebdesign 3ec13f1
Apply suggestions from code review
TLWebdesign 3d8f2bc
added install sql and removed unused field param
TLWebdesign 9a70c69
Merge branch '6.0-dev' into 5.2-dev
TLWebdesign b9d3036
updated copyright year
TLWebdesign 570a0a5
Update plugins/fields/number/tmpl/number.php
TLWebdesign fdced95
Added update sql and currency formatting option
TLWebdesign c65fbdc
cleaned up language strings
TLWebdesign 1810ba0
Fixed years to 2025 and version number to be in line with joomla version
TLWebdesign e249175
Alpha sorted the strings
TLWebdesign 0f8274d
fixed stupid mistake.
TLWebdesign 6bdf7e1
updated sql files to include all the default params settings
TLWebdesign 9d148c4
changed indentation
TLWebdesign 7d38756
fix sorting of field params
TLWebdesign d0665b0
Update administrator/language/en-GB/plg_fields_number.ini
TLWebdesign acca4e7
Update administrator/language/en-GB/plg_fields_number.ini
TLWebdesign d86943a
removed unnecessary description
TLWebdesign c7ac6ff
Changed update SQL file to own file and reverted changes to other file
TLWebdesign ead2fcb
Update administrator/language/en-GB/plg_fields_number.ini
TLWebdesign 47cef73
Merge branch '6.0-dev' into 5.2-dev
TLWebdesign c6f6b64
Merge branch '6.0-dev' into 5.2-dev
TLWebdesign e720107
Merge branch '6.0-dev' into 5.2-dev
TLWebdesign 730bd3a
Merge branch '6.0-dev' into 5.2-dev
Bodge-IT 2661516
removed unnecessary descriptions
TLWebdesign b89199b
removed unneccessary descriptions
TLWebdesign 8e8f3e2
removed more unnecessary descriptions and added default in the params…
TLWebdesign 72ea857
Update administrator/components/com_admin/sql/updates/postgresql/6.0.…
TLWebdesign 61fc118
changed sql name
TLWebdesign 8b59343
Merge branch '5.2-dev' of https://github.com/TLWebdesign/joomla-cms i…
TLWebdesign 3044c15
Update 6.0.0-2024-08-24.sql
TLWebdesign 6851218
Rename 6.0.0-2024-08-24.sql to 6.0.0-2025-08-17.sql
Bodge-IT 6372998
Rename 6.0.0-2024-08-24.sql to 6.0.0-2025-08-17.sql
Bodge-IT 42a494c
Merge branch '5.2-dev' of https://github.com/TLWebdesign/joomla-cms i…
TLWebdesign add1023
Merge branch '6.0-dev' into 5.2-dev
richard67 494ee13
Merge branch '6.0-dev' into 5.2-dev
richard67 dcafe21
Merge branch '6.0-dev' into 5.2-dev
Bodge-IT File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
administrator/components/com_admin/sql/updates/mysql/6.0.0-2025-08-17.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
2 changes: 2 additions & 0 deletions
2
administrator/components/com_admin/sql/updates/postgresql/6.0.0-2025-08-17.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | ||
| /> | ||
|
|
||
TLWebdesign marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <field | ||
| name="max" | ||
| type="number" | ||
| label="PLG_FIELDS_NUMBER_PARAMS_MAX_LABEL" | ||
| description="PLG_FIELDS_NUMBER_PARAMS_MAX_DESC" | ||
| default="100.0" | ||
| filter="float" | ||
| /> | ||
|
|
||
TLWebdesign marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <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> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | ||
TLWebdesign marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| type="int" | ||
| label="PLG_FIELDS_NUMBER_PARAMS_DECIMALS_LABEL" | ||
| default="2" | ||
| filter="integer" | ||
| showon="currency:1" | ||
| min="0" | ||
| max="10" | ||
| /> | ||
| </fieldset> | ||
| </fields> | ||
| </form> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
| ); | ||
| } | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| { | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.