30
1
mirror of https://github.com/joomla-extensions/weblinks.git synced 2024-05-29 04:30:46 +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; 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; use Joomla\Component\Weblinks\Site\Helper\RouteHelper;
$app = JFactory::getApplication(); $app = Factory::getApplication();
if ($app->isClient('site')) 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. // Include the component HTML helpers.
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html'); HTMLHelper::_('behavior.core');
JHtml::_('behavior.core'); HTMLHelper::_('script', 'com_weblinks/admin-weblinks-modal.js', array('version' => 'auto', 'relative' => true));
JHtml::_('behavior.polyfill', array('event'), 'lt IE 9'); HTMLHelper::_('bootstrap.tooltip', '.hasTooltip', array('placement' => 'bottom'));
JHtml::_('script', 'com_weblinks/admin-weblinks-modal.js', array('version' => 'auto', 'relative' => true)); HTMLHelper::_('formbehavior.chosen', 'select');
JHtml::_('bootstrap.tooltip', '.hasTooltip', array('placement' => 'bottom'));
JHtml::_('formbehavior.chosen', 'select');
// Special case for the search field tooltip. // Special case for the search field tooltip.
$searchFilterDesc = $this->filterForm->getFieldAttribute('search', 'description', null, 'filter'); $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'); $function = $app->input->getCmd('function', 'jSelectWeblink');
$editor = $app->input->getCmd('editor', ''); $editor = $app->input->getCmd('editor', '');
@ -39,7 +41,7 @@ $onclick = $this->escape($function);
if (!empty($editor)) if (!empty($editor))
{ {
// This view is used also in com_menus. Load the xtd script only if the editor is set! // 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"; $onclick = "jSelectWeblink";
} }
@ -58,29 +60,29 @@ $iconStates = array(
<div class="clearfix"></div> <div class="clearfix"></div>
<?php if (empty($this->items)) : ?> <?php if (empty($this->items)) : ?>
<div class="alert alert-no-items"> <div class="alert alert-no-items">
<?php echo JText::_('JGLOBAL_NO_MATCHING_RESULTS'); ?> <?php echo Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
</div> </div>
<?php else : ?> <?php else : ?>
<table class="table table-striped table-condensed"> <table class="table table-striped table-condensed">
<thead> <thead>
<tr> <tr>
<th width="1%" class="center nowrap"> <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>
<th class="title"> <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>
<th width="10%" class="nowrap hidden-phone"> <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>
<th width="15%" class="nowrap"> <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>
<th width="5%" class="nowrap hidden-phone"> <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>
<th width="1%" class="nowrap hidden-phone"> <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> </th>
</tr> </tr>
</thead> </thead>
@ -94,7 +96,7 @@ $iconStates = array(
<tbody> <tbody>
<?php foreach ($this->items as $i => $item) : ?> <?php foreach ($this->items as $i => $item) : ?>
<?php $lang = ''; ?> <?php $lang = ''; ?>
<?php if ($item->language && JLanguageMultilang::isEnabled()) : ?> <?php if ($item->language && Multilanguage::isEnabled()) : ?>
<?php $tag = strlen($item->language); ?> <?php $tag = strlen($item->language); ?>
<?php if ($tag == 5) : ?> <?php if ($tag == 5) : ?>
<?php $lang = substr($item->language, 0, 2); ?> <?php $lang = substr($item->language, 0, 2); ?>
@ -118,7 +120,7 @@ $iconStates = array(
<?php echo $this->escape($item->title); ?> <?php echo $this->escape($item->title); ?>
</a> </a>
<div class="small"> <div class="small">
<?php echo JText::_('JCATEGORY') . ': ' . $this->escape($item->category_title); ?> <?php echo Text::_('JCATEGORY') . ': ' . $this->escape($item->category_title); ?>
</div> </div>
</td> </td>
<td class="small hidden-phone"> <td class="small hidden-phone">
@ -128,7 +130,7 @@ $iconStates = array(
<?php echo JLayoutHelper::render('joomla.content.language', $item); ?> <?php echo JLayoutHelper::render('joomla.content.language', $item); ?>
</td> </td>
<td class="nowrap small hidden-phone"> <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>
<td class="nowrap small hidden-phone"> <td class="nowrap small hidden-phone">
<?php echo (int) $item->id; ?> <?php echo (int) $item->id; ?>
@ -142,7 +144,7 @@ $iconStates = array(
<input type="hidden" name="task" value="" /> <input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" /> <input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="forcedLanguage" value="<?php echo $app->input->get('forcedLanguage', '', 'CMD'); ?>" /> <input type="hidden" name="forcedLanguage" value="<?php echo $app->input->get('forcedLanguage', '', 'CMD'); ?>" />
<?php echo JHtml::_('form.token'); ?> <?php echo HTMLHelper::_('form.token'); ?>
</form> </form>
</div> </div>

View File

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