Skip to content

Commit 17e4afc

Browse files
committed
use own class, use toggler
1 parent 62e9189 commit 17e4afc

File tree

4 files changed

+68
-29
lines changed

4 files changed

+68
-29
lines changed

administrator/language/en-GB/plg_behaviour_compat.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ PLG_COMPAT_FIELD_ES5_ASSETS_LABEL="ES5 Assets"
1111
PLG_COMPAT_FIELD_REMOVED_ASSETS_DESCRIPTION="Activate this option if your extension requires removed assets which has resulted in an exception. The assets provided are empty but prevent the exception."
1212
PLG_COMPAT_FIELD_REMOVED_ASSETS_LABEL="Removed Assets"
1313
PLG_COMPAT_XML_DESCRIPTION="If you use extensions which are not using the current Joomla Coding standards then this plugin, when enabled, will provide backward compatibility to the prior major version."
14+
PLG_COMPAT_FIELD_HTML_HELPERS_LABEL="HTMLHelper classes/functions"
15+
PLG_COMPAT_FIELD_HTML_HELPERS_DESCRIPTION="Activate this option if your extension requires deprecated HTMLHelper classes or functions. When enabled, will provide backward compatibility to the prior major version."

plugins/behaviour/compat/compat.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@
3333
<option value="0">JNO</option>
3434
<option value="1">JYES</option>
3535
</field>
36+
<field
37+
name="html_helpers"
38+
type="radio"
39+
label="PLG_COMPAT_FIELD_HTML_HELPERS_LABEL"
40+
description="PLG_COMPAT_FIELD_HTML_HELPERS_DESCRIPTION"
41+
layout="joomla.form.field.radio.switcher"
42+
default="1"
43+
filter="integer"
44+
>
45+
<option value="0">JNO</option>
46+
<option value="1">JYES</option>
47+
</field>
3648
<field
3749
name="es5_assets"
3850
type="radio"

plugins/behaviour/compat/src/Extension/Compat.php

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@
1111
namespace Joomla\Plugin\Behaviour\Compat\Extension;
1212

1313
use Joomla\CMS\Event\Application\AfterInitialiseDocumentEvent;
14-
use Joomla\CMS\Factory;
15-
use Joomla\CMS\HTML\HTMLHelper;
1614
use Joomla\CMS\Plugin\CMSPlugin;
1715
use Joomla\Event\DispatcherInterface;
1816
use Joomla\Event\Priority;
1917
use Joomla\Event\SubscriberInterface;
18+
use Joomla\Plugin\Behaviour\Compat\HTMLHelper\Bootstrap;
2019

2120
// phpcs:disable PSR1.Files.SideEffects
2221
\defined('_JEXEC') or die;
@@ -94,8 +93,13 @@ public function __construct(DispatcherInterface $dispatcher, array $config = [])
9493
*/
9594
public function onAfterInitialiseDocument(AfterInitialiseDocumentEvent $event)
9695
{
97-
if (!HTMLHelper::isRegistered('bootstrap.framework')) {
98-
HTMLHelper::register('bootstrap.framework', 'Joomla\Plugin\Behaviour\Compat\Extension\Compat::framework');
96+
/**
97+
* Load the deprecated HTMLHelper classes/functions
98+
* likely be removed in Joomla 7.0
99+
*/
100+
if ($this->params->get('html_helpers', '1')) {
101+
// Restore HTMLHelper::Bootstrap('framework')
102+
new Bootstrap();
99103
}
100104

101105
/**
@@ -121,29 +125,4 @@ public function onAfterInitialiseDocument(AfterInitialiseDocumentEvent $event)
121125
->addRegistryFile('media/plg_behaviour_compat/removed.asset.json');
122126
}
123127
}
124-
125-
/**
126-
* Method to load the ALL the Bootstrap Components
127-
*
128-
* If debugging mode is on an uncompressed version of Bootstrap is included for easier debugging.
129-
*
130-
* @param mixed $debug Is debugging mode on? [optional]
131-
*
132-
* @return void
133-
*
134-
* @deprecated 4.0 will be removed in 6.0
135-
* Will be removed without replacement
136-
* Load the different scripts with their individual method calls
137-
*/
138-
public static function framework($debug = null): void
139-
{
140-
$wa = Factory::getApplication()->getDocument()->getWebAssetManager();
141-
142-
array_map(
143-
function ($script) use ($wa) {
144-
$wa->useScript('bootstrap.' . $script);
145-
},
146-
['alert', 'button', 'carousel', 'collapse', 'dropdown', 'modal', 'offcanvas', 'popover', 'scrollspy', 'tab', 'toast']
147-
);
148-
}
149128
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
/**
4+
* @copyright (C) 2025 Open Source Matters, Inc. <https://www.joomla.org>
5+
* @license GNU General Public License version 2 or later; see LICENSE.txt
6+
*/
7+
8+
namespace Joomla\Plugin\Behaviour\Compat\HTMLHelper;
9+
10+
use Joomla\CMS\Factory;
11+
use Joomla\CMS\HTML\HTMLHelper;
12+
13+
Class Bootstrap
14+
{
15+
public function __construct()
16+
{
17+
if (!HTMLHelper::isRegistered('bootstrap.framework')) {
18+
HTMLHelper::register('bootstrap.framework', 'Joomla\Plugin\Behaviour\Compat\HTMLHelper\Bootstrap::framework');
19+
}
20+
}
21+
22+
/**
23+
* Method to load the ALL the Bootstrap Components
24+
*
25+
* If debugging mode is on an uncompressed version of Bootstrap is included for easier debugging.
26+
*
27+
* @param mixed $debug Is debugging mode on? [optional]
28+
*
29+
* @return void
30+
*
31+
* @deprecated 4.0 will be removed in 6.0
32+
* Will be removed without replacement
33+
* Load the different scripts with their individual method calls
34+
*/
35+
public static function framework($debug = null): void
36+
{
37+
$wa = Factory::getApplication()->getDocument()->getWebAssetManager();
38+
39+
array_map(
40+
function ($script) use ($wa) {
41+
$wa->useScript('bootstrap.' . $script);
42+
},
43+
['alert', 'button', 'carousel', 'collapse', 'dropdown', 'modal', 'offcanvas', 'popover', 'scrollspy', 'tab', 'toast']
44+
);
45+
}
46+
}

0 commit comments

Comments
 (0)