diff --git a/src/administrator/components/com_weblinks/src/Field/Modal/WeblinkField.php b/src/administrator/components/com_weblinks/src/Field/Modal/WeblinkField.php
index f0d1df3..5638e38 100644
--- a/src/administrator/components/com_weblinks/src/Field/Modal/WeblinkField.php
+++ b/src/administrator/components/com_weblinks/src/Field/Modal/WeblinkField.php
@@ -9,6 +9,12 @@
namespace Joomla\Component\Weblinks\Administrator\Field\Modal;
+use Joomla\CMS\Factory;
+use Joomla\CMS\Form\FormField;
+use Joomla\CMS\HTML\HTMLHelper;
+use Joomla\CMS\Language\Text;
+use Joomla\CMS\Session\Session;
+
defined('JPATH_BASE') or die;
/**
@@ -16,7 +22,7 @@ defined('JPATH_BASE') or die;
*
* @since __DEPLOY_VERSION__
*/
-class WeblinkField extends \JFormField
+class WeblinkField extends FormField
{
/**
* The form field type.
@@ -41,7 +47,7 @@ class WeblinkField extends \JFormField
$allowSelect = ((string) $this->element['select'] != 'false');
// Load language
- \JFactory::getLanguage()->load('com_weblinks', JPATH_ADMINISTRATOR);
+ Factory::getLanguage()->load('com_weblinks', JPATH_ADMINISTRATOR);
// The active weblink id field.
$value = (int) $this->value > 0 ? (int) $this->value : '';
@@ -49,9 +55,11 @@ class WeblinkField extends \JFormField
// Create the modal id.
$modalId = 'Weblink_' . $this->id;
+ /** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */
+ $wa = Factory::getApplication()->getDocument()->getWebAssetManager();
+
// Add the modal field script to the document head.
- \JHtml::_('jquery.framework');
- \JHtml::_('script', 'system/modal-fields.js', array('version' => 'auto', 'relative' => true));
+ $wa->useScript('field.modal-fields');
// Script to proxy the select modal function to the modal-fields.js file.
if ($allowSelect)
@@ -65,19 +73,24 @@ class WeblinkField extends \JFormField
if (!isset($scriptSelect[$this->id]))
{
- \JFactory::getDocument()->addScriptDeclaration("
- function jSelectWeblink_" . $this->id . "(id, title, catid, object, url, language) {
- window.processModalSelect('Weblink', '" . $this->id . "', id, title, catid, object, url, language);
- }
- ");
+ $wa->addInlineScript("
+ window.jSelectWeblink_" . $this->id . " = function (id, title, catid, object, url, language) {
+ window.processModalSelect('Article', '" . $this->id . "', id, title, catid, object, url, language);
+ }",
+ [],
+ ['type' => 'module']
+ );
+
+ Text::script('JGLOBAL_ASSOCIATIONS_PROPAGATE_FAILED');
+
$scriptSelect[$this->id] = true;
}
}
// Setup variables for display.
- $linkWeblinks = 'index.php?option=com_weblinks&view=weblinks&layout=modal&tmpl=component&' . \JSession::getFormToken() . '=1';
- $linkWeblink = 'index.php?option=com_weblinks&view=weblink&layout=modal&tmpl=component&' . \JSession::getFormToken() . '=1';
- $modalTitle = \JText::_('COM_WEBLINKS_CHANGE_WEBLINK');
+ $linkWeblinks = 'index.php?option=com_weblinks&view=weblinks&layout=modal&tmpl=component&' . Session::getFormToken() . '=1';
+ $linkWeblink = 'index.php?option=com_weblinks&view=weblink&layout=modal&tmpl=component&' . Session::getFormToken() . '=1';
+ $modalTitle = Text::_('COM_WEBLINKS_CHANGE_WEBLINK');
if (isset($this->element['language']))
{
@@ -92,7 +105,7 @@ class WeblinkField extends \JFormField
if ($value)
{
- $db = \JFactory::getDbo();
+ $db = Factory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('title'))
->from($db->quoteName('#__weblinks'))
@@ -104,81 +117,93 @@ class WeblinkField extends \JFormField
}
catch (\RuntimeException $e)
{
- \JError::raiseWarning(500, $e->getMessage());
+ Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');
}
}
- $title = empty($title) ? \JText::_('COM_WEBLINKS_SELECT_A_WEBLINK') : htmlspecialchars($title, ENT_QUOTES, 'UTF-8');
+
+ $title = empty($title) ? Text::_('COM_WEBLINKS_SELECT_A_WEBLINK') : htmlspecialchars($title, ENT_QUOTES, 'UTF-8');
// The current weblink display field.
- $html = '';
- $html .= '';
+ $html = '';
+
+ if ($allowSelect || $allowNew || $allowEdit || $allowClear)
+ {
+ $html .= '';
+ }
+
+ $html .= '';
// Select weblink button
if ($allowSelect)
{
- $html .= ''
- . ' ' . \JText::_('JSELECT')
- . '';
+ . ' data-bs-toggle="modal"'
+ . ' type="button"'
+ . ' data-bs-target="#ModalSelect' . $modalId . '">'
+ . ' ' . Text::_('JSELECT')
+ . '';
}
+
// New weblink button
if ($allowNew)
{
- $html .= ''
- . ' ' . \JText::_('JACTION_CREATE')
- . '';
+ . ' data-bs-toggle="modal"'
+ . ' type="button"'
+ . ' data-bs-target="#ModalNew' . $modalId . '">'
+ . ' ' . Text::_('JACTION_CREATE')
+ . '';
}
+
// Edit weblink button
if ($allowEdit)
{
- $html .= ''
- . ' ' . \JText::_('JACTION_EDIT')
- . '';
+ . ' data-bs-toggle="modal"'
+ . ' type="button"'
+ . ' data-bs-target="#ModalEdit' . $modalId . '">'
+ . ' ' . Text::_('JACTION_EDIT')
+ . '';
}
+
// Clear weblink button
if ($allowClear)
{
- $html .= ''
- . '' . \JText::_('JCLEAR')
- . '';
+ . ' ' . Text::_('JCLEAR')
+ . '';
+ }
+
+ if ($allowSelect || $allowNew || $allowEdit || $allowClear)
+ {
+ $html .= '';
}
- $html .= '';
// Select weblink modal
if ($allowSelect)
{
- $html .= \JHtml::_(
+ $html .= HTMLHelper::_(
'bootstrap.renderModal',
'ModalSelect' . $modalId,
array(
- 'title' => $modalTitle,
- 'url' => $urlSelect,
- 'height' => '400px',
- 'width' => '800px',
- 'bodyHeight' => '70',
- 'modalWidth' => '80',
- 'footer' => '' . \JText::_('JLIB_HTML_BEHAVIOR_CLOSE') . '',
+ 'title' => $modalTitle,
+ 'url' => $urlSelect,
+ 'height' => '400px',
+ 'width' => '800px',
+ 'bodyHeight' => 70,
+ 'modalWidth' => 80,
+ 'footer' => '',
)
);
}
@@ -190,7 +215,7 @@ class WeblinkField extends \JFormField
'bootstrap.renderModal',
'ModalNew' . $modalId,
array(
- 'title' => JText::_('COM_WEBLINKS_NEW_WEBLINK'),
+ 'title' => Text::_('COM_WEBLINKS_NEW_WEBLINK'),
'backdrop' => 'static',
'keyboard' => false,
'closeButton' => false,
@@ -200,14 +225,14 @@ class WeblinkField extends \JFormField
'bodyHeight' => '70',
'modalWidth' => '80',
'footer' => ''
- . \JText::_('JLIB_HTML_BEHAVIOR_CLOSE') . ''
- . ''
- . \JText::_('JSAVE') . ''
- . ''
- . \JText::_('JAPPLY') . '',
+ . ' onclick="window.processModalEdit(this, \'' . $this->id . '\', \'add\', \'weblink\', \'cancel\', \'weblink-form\'); return false;">'
+ . Text::_('JLIB_HTML_BEHAVIOR_CLOSE') . ''
+ . ''
+ . Text::_('JSAVE') . ''
+ . ''
+ . Text::_('JAPPLY') . '',
)
);
}
@@ -215,11 +240,11 @@ class WeblinkField extends \JFormField
// Edit weblink modal
if ($allowEdit)
{
- $html .= \JHtml::_(
+ $html .= HTMLHelper::_(
'bootstrap.renderModal',
'ModalEdit' . $modalId,
array(
- 'title' => \JText::_('COM_WEBLINKS_EDIT_WEBLINK'),
+ 'title' => Text::_('COM_WEBLINKS_EDIT_WEBLINK'),
'backdrop' => 'static',
'keyboard' => false,
'closeButton' => false,
@@ -229,21 +254,22 @@ class WeblinkField extends \JFormField
'bodyHeight' => '70',
'modalWidth' => '80',
'footer' => ''
- . \JText::_('JLIB_HTML_BEHAVIOR_CLOSE') . ''
- . ''
- . \JText::_('JSAVE') . ''
- . ''
- . \JText::_('JAPPLY') . '',
+ . ' onclick="window.processModalEdit(this, \'' . $this->id . '\', \'edit\', \'weblink\', \'cancel\', \'weblink-form\'); return false;">'
+ . Text::_('JLIB_HTML_BEHAVIOR_CLOSE') . ''
+ . ''
+ . Text::_('JSAVE') . ''
+ . ''
+ . Text::_('JAPPLY') . '',
)
);
}
// Note: class='required' for client side validation.
$class = $this->required ? ' class="required modal-value"' : '';
- $html .= '';
+ $html .= '';
+
return $html;
}
diff --git a/src/administrator/components/com_weblinks/tmpl/weblinks/modal.php b/src/administrator/components/com_weblinks/tmpl/weblinks/modal.php
index aa5527b..a4d52fd 100644
--- a/src/administrator/components/com_weblinks/tmpl/weblinks/modal.php
+++ b/src/administrator/components/com_weblinks/tmpl/weblinks/modal.php
@@ -8,13 +8,14 @@
*/
defined('_JEXEC') or die;
+use Joomla\Component\Weblinks\Site\Helper\RouteHelper;
+
$app = JFactory::getApplication();
if ($app->isClient('site'))
{
JSession::checkToken('get') or die(JText::_('JINVALID_TOKEN'));
}
-JLoader::register('WeblinksHelperRoute', JPATH_ROOT . '/components/com_weblinks/helpers/route.php');
// Include the component HTML helpers.
@@ -110,7 +111,7 @@ $iconStates = array(
. ' data-id="' . $item->id . '"'
. ' data-title="' . $this->escape(addslashes($item->title)) . '"'
. ' data-cat-id="' . $this->escape($item->catid) . '"'
- . ' data-uri="' . $this->escape(WeblinksHelperRoute::getWeblinkRoute($item->id, $item->catid, $item->language)) . '"'
+ . ' data-uri="' . $this->escape(RouteHelper::getWeblinkRoute($item->id, $item->catid, $item->language)) . '"'
. ' data-language="' . $this->escape($lang) . '"';
?>
>
diff --git a/src/components/com_weblinks/tmpl/weblink/default.xml b/src/components/com_weblinks/tmpl/weblink/default.xml
index a22e772..d7dd54b 100644
--- a/src/components/com_weblinks/tmpl/weblink/default.xml
+++ b/src/components/com_weblinks/tmpl/weblink/default.xml
@@ -12,7 +12,7 @@