Skip to content

Commit 2642ceb

Browse files
authored
[6.0] No htmlhelper for js (#45925)
* Remove `HTMLHelper::_('behavior..xxx);` * Update Grid.php * don’t use deprecated fn * order * z
1 parent cc988a4 commit 2642ceb

File tree

6 files changed

+24
-23
lines changed

6 files changed

+24
-23
lines changed

administrator/components/com_modules/tmpl/module/edit.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818

1919
/** @var \Joomla\Component\Modules\Administrator\View\Module\HtmlView $this */
2020

21-
HTMLHelper::_('behavior.combobox');
22-
2321
$hasContent = isset($this->item->xml->customContent);
2422
$hasContentFieldName = 'content';
2523

@@ -39,10 +37,10 @@
3937

4038
$this->getDocument()->addScriptOptions('module-edit', ['itemId' => $this->item->id, 'state' => (int) $this->item->id == 0 ? 'Add' : 'Edit']);
4139

42-
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
43-
$wa = $this->getDocument()->getWebAssetManager();
44-
$wa->useScript('keepalive')
45-
->useScript('form.validate');
40+
$this->getDocument()->getWebAssetManager()
41+
->useScript('keepalive')
42+
->useScript('form.validate')
43+
->useScript('awesomplete');
4644

4745
$input = Factory::getApplication()->getInput();
4846

administrator/components/com_templates/tmpl/template/default.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,21 @@
2121

2222
/** @var \Joomla\Component\Templates\Administrator\View\Template\HtmlView $this */
2323

24-
HTMLHelper::_('behavior.multiselect', 'updateForm');
25-
HTMLHelper::_('bootstrap.modal');
24+
$app = Factory::getApplication();
25+
$doc = $app->getDocument();
26+
27+
// Pass the required options to the javascript
28+
$doc->addScriptOptions('js-multiselect', ['formName' => 'updateForm']);
2629

2730
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
28-
$wa = $this->getDocument()->getWebAssetManager();
29-
$input = Factory::getApplication()->getInput();
31+
$wa = $doc->getWebAssetManager();
32+
$input = $app->getInput();
3033

3134
// Enable assets
3235
$wa->useScript('form.validate')
3336
->useScript('keepalive')
37+
->useScript('bootstrap.modal')
38+
->useScript('multiselect')
3439
->useScript('com_templates.admin-template-toggle-switch')
3540
->useScript('com_templates.admin-templates')
3641
->useStyle('com_templates.admin-templates');

components/com_config/tmpl/modules/default.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,17 @@
1010

1111
defined('_JEXEC') or die;
1212

13-
use Joomla\CMS\HTML\HTMLHelper;
1413
use Joomla\CMS\Language\Multilanguage;
1514
use Joomla\CMS\Language\Text;
1615
use Joomla\CMS\Router\Route;
1716

18-
HTMLHelper::_('behavior.combobox');
19-
2017
/** @var \Joomla\Component\Config\Site\View\Modules\HtmlView $this */
21-
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
22-
$wa = $this->getDocument()->getWebAssetManager();
23-
$wa->useScript('keepalive')
18+
19+
$this->getDocument()->getWebAssetManager()
20+
->useScript('keepalive')
2421
->useScript('form.validate')
25-
->useScript('com_config.modules');
22+
->useScript('com_config.modules')
23+
->useScript('awesomplete');
2624

2725
$editorText = false;
2826
$moduleXml = JPATH_SITE . '/modules/' . $this->item['module'] . '/' . $this->item['module'] . '.xml';

layouts/joomla/form/field/combo.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
extract($displayData);
1414

15-
use Joomla\CMS\HTML\HTMLHelper;
15+
use Joomla\CMS\Factory;
1616

1717
/**
1818
* Layout variables
@@ -45,7 +45,7 @@
4545
* @var array $dataAttributes Miscellaneous data attribute for eg, data-*.
4646
*/
4747

48-
HTMLHelper::_('behavior.combobox');
48+
Factory::getApplication()->getDocument()->getWebAssetManager()->usePreset('awesomplete');
4949

5050
$attr = '';
5151

libraries/src/HTML/Helpers/Grid.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public static function sort($title, $order, $direction = 'asc', $selected = '',
8989
*/
9090
public static function checkall($name = 'checkall-toggle', $action = 'Joomla.checkAll(this)')
9191
{
92-
HTMLHelper::_('behavior.core');
92+
Factory::getApplication()->getDocument()->getWebAssetManager()->useScript('core');
9393

9494
return '<input class="form-check-input" autocomplete="off" type="checkbox" name="' . $name . '" value="" title="' . Text::_('JGLOBAL_CHECK_ALL') . '" onclick="' . $action . '">';
9595
}

libraries/src/Language/Text.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
namespace Joomla\CMS\Language;
1111

1212
use Joomla\CMS\Factory;
13-
use Joomla\CMS\HTML\HTMLHelper;
1413

1514
// phpcs:disable PSR1.Files.SideEffects
1615
\defined('_JEXEC') or die;
@@ -351,7 +350,8 @@ public static function script($string = null, $jsSafe = false, $interpretBackSla
351350

352351
// Add the string to the array if not null.
353352
if ($string !== null) {
354-
$doc = Factory::getDocument();
353+
$app = Factory::getApplication();
354+
$doc = $app->getDocument();
355355

356356
// Get previously added strings
357357
$strings = $doc->getScriptOptions('joomla.jtext');
@@ -362,7 +362,7 @@ public static function script($string = null, $jsSafe = false, $interpretBackSla
362362
static::$strings[$key] = $strings[$key];
363363

364364
// Load core.js dependency
365-
HTMLHelper::_('behavior.core');
365+
$doc->getWebAssetManager()->useScript('core');
366366

367367
// Update Joomla.Text script options
368368
$doc->addScriptOptions('joomla.jtext', $strings, false);

0 commit comments

Comments
 (0)