32
1
mirror of https://github.com/joomla-extensions/weblinks.git synced 2024-12-26 01:57:30 +00:00

Make weblink editor-xtd works

This commit is contained in:
Tuan Pham Ngoc 2021-06-25 23:56:03 +07:00
parent 1a415435af
commit 6c68bcad5d
2 changed files with 27 additions and 31 deletions

View File

@ -8,27 +8,29 @@
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Multilanguage;
use Joomla\CMS\Language\Text;
use Joomla\Component\Weblinks\Site\Helper\RouteHelper;
$app = JFactory::getApplication();
$app = Factory::getApplication();
if ($app->isClient('site'))
{
JSession::checkToken('get') or die(JText::_('JINVALID_TOKEN'));
JSession::checkToken('get') or die(Text::_('JINVALID_TOKEN'));
}
// Include the component HTML helpers.
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
JHtml::_('behavior.core');
JHtml::_('behavior.polyfill', array('event'), 'lt IE 9');
JHtml::_('script', 'com_weblinks/admin-weblinks-modal.js', array('version' => 'auto', 'relative' => true));
JHtml::_('bootstrap.tooltip', '.hasTooltip', array('placement' => 'bottom'));
JHtml::_('formbehavior.chosen', 'select');
HTMLHelper::_('behavior.core');
HTMLHelper::_('script', 'com_weblinks/admin-weblinks-modal.js', array('version' => 'auto', 'relative' => true));
HTMLHelper::_('bootstrap.tooltip', '.hasTooltip', array('placement' => 'bottom'));
HTMLHelper::_('formbehavior.chosen', 'select');
// Special case for the search field tooltip.
$searchFilterDesc = $this->filterForm->getFieldAttribute('search', 'description', null, 'filter');
JHtml::_('bootstrap.tooltip', '#filter_search', array('title' => JText::_($searchFilterDesc), 'placement' => 'bottom'));
HTMLHelper::_('bootstrap.tooltip', '#filter_search', array('title' => Text::_($searchFilterDesc), 'placement' => 'bottom'));
$function = $app->input->getCmd('function', 'jSelectWeblink');
$editor = $app->input->getCmd('editor', '');
@ -39,7 +41,7 @@ $onclick = $this->escape($function);
if (!empty($editor))
{
// This view is used also in com_menus. Load the xtd script only if the editor is set!
JFactory::getDocument()->addScriptOptions('xtd-weblinks', array('editor' => $editor));
$app->getDocument()->addScriptOptions('xtd-weblinks', array('editor' => $editor));
$onclick = "jSelectWeblink";
}
@ -58,29 +60,29 @@ $iconStates = array(
<div class="clearfix"></div>
<?php if (empty($this->items)) : ?>
<div class="alert alert-no-items">
<?php echo JText::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
<?php echo Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
</div>
<?php else : ?>
<table class="table table-striped table-condensed">
<thead>
<tr>
<th width="1%" class="center nowrap">
<?php echo JHtml::_('searchtools.sort', 'JSTATUS', 'a.state', $listDirn, $listOrder); ?>
<?php echo HTMLHelper::_('searchtools.sort', 'JSTATUS', 'a.state', $listDirn, $listOrder); ?>
</th>
<th class="title">
<?php echo JHtml::_('searchtools.sort', 'JGLOBAL_TITLE', 'a.title', $listDirn, $listOrder); ?>
<?php echo HTMLHelper::_('searchtools.sort', 'JGLOBAL_TITLE', 'a.title', $listDirn, $listOrder); ?>
</th>
<th width="10%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_ACCESS', 'a.access', $listDirn, $listOrder); ?>
<?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_ACCESS', 'a.access', $listDirn, $listOrder); ?>
</th>
<th width="15%" class="nowrap">
<?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_LANGUAGE', 'language', $listDirn, $listOrder); ?>
<?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_LANGUAGE', 'language', $listDirn, $listOrder); ?>
</th>
<th width="5%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'JDATE', 'a.created', $listDirn, $listOrder); ?>
<?php echo HTMLHelper::_('searchtools.sort', 'JDATE', 'a.created', $listDirn, $listOrder); ?>
</th>
<th width="1%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
<?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
</th>
</tr>
</thead>
@ -94,7 +96,7 @@ $iconStates = array(
<tbody>
<?php foreach ($this->items as $i => $item) : ?>
<?php $lang = ''; ?>
<?php if ($item->language && JLanguageMultilang::isEnabled()) : ?>
<?php if ($item->language && Multilanguage::isEnabled()) : ?>
<?php $tag = strlen($item->language); ?>
<?php if ($tag == 5) : ?>
<?php $lang = substr($item->language, 0, 2); ?>
@ -118,7 +120,7 @@ $iconStates = array(
<?php echo $this->escape($item->title); ?>
</a>
<div class="small">
<?php echo JText::_('JCATEGORY') . ': ' . $this->escape($item->category_title); ?>
<?php echo Text::_('JCATEGORY') . ': ' . $this->escape($item->category_title); ?>
</div>
</td>
<td class="small hidden-phone">
@ -128,7 +130,7 @@ $iconStates = array(
<?php echo JLayoutHelper::render('joomla.content.language', $item); ?>
</td>
<td class="nowrap small hidden-phone">
<?php echo JHtml::_('date', $item->created, JText::_('DATE_FORMAT_LC4')); ?>
<?php echo HTMLHelper::_('date', $item->created, Text::_('DATE_FORMAT_LC4')); ?>
</td>
<td class="nowrap small hidden-phone">
<?php echo (int) $item->id; ?>
@ -142,7 +144,7 @@ $iconStates = array(
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="forcedLanguage" value="<?php echo $app->input->get('forcedLanguage', '', 'CMD'); ?>" />
<?php echo JHtml::_('form.token'); ?>
<?php echo HTMLHelper::_('form.token'); ?>
</form>
</div>

View File

@ -14,8 +14,8 @@
var hreflang = '', editor, tag;
if (!Joomla.getOptions('xtd-weblinks')) {
// Something went wrong!
window.parent.jModalClose();
// Something went wrong
window.parent.Joomla.Modal.getCurrent().close();
return false;
}
@ -28,14 +28,8 @@
tag = '<a' + hreflang + ' href="' + link + '">' + title + '</a>';
/** Use the API, if editor supports it **/
if (window.Joomla && window.Joomla.editors && Joomla.editors.instances && Joomla.editors.instances.hasOwnProperty(editor)) {
Joomla.editors.instances[editor].replaceSelection(tag)
} else {
window.parent.jInsertEditorText(tag, editor);
}
window.parent.jModalClose();
window.parent.Joomla.editors.instances[editor].replaceSelection(tag);
window.parent.Joomla.Modal.getCurrent().close();
};
document.addEventListener('DOMContentLoaded', function(){