diff --git a/src/administrator/components/com_weblinks/models/weblink.php b/src/administrator/components/com_weblinks/models/weblink.php
index 1195092..cb238fb 100644
--- a/src/administrator/components/com_weblinks/models/weblink.php
+++ b/src/administrator/components/com_weblinks/models/weblink.php
@@ -11,6 +11,8 @@ defined('_JEXEC') or die;
use Joomla\Registry\Registry;
+JLoader::register('WeblinksHelper', JPATH_ADMINISTRATOR . '/components/com_weblinks/helpers/weblinks.php');
+
/**
* Weblinks model.
*
@@ -26,6 +28,14 @@ class WeblinksModelWeblink extends JModelAdmin
*/
public $typeAlias = 'com_weblinks.weblink';
+ /**
+ * The context used for the associations table
+ *
+ * @var string
+ * @since __DEPLOY_VERSION__
+ */
+ protected $associationsContext = 'com_weblinks.item';
+
/**
* The prefix to use with controller messages.
*
@@ -200,6 +210,24 @@ class WeblinksModelWeblink extends JModelAdmin
$registry->loadString($item->images);
$item->images = $registry->toArray();
+ // Load associated web links items
+ $assoc = JLanguageAssociations::isEnabled();
+
+ if ($assoc)
+ {
+ $item->associations = array();
+
+ if ($item->id != null)
+ {
+ $associations = JLanguageAssociations::getAssociations('com_weblinks', '#__weblinks', 'com_weblinks.item', $item->id);
+
+ foreach ($associations as $tag => $association)
+ {
+ $item->associations[$tag] = $association->id;
+ }
+ }
+ }
+
if (!empty($item->id))
{
$item->tags = new JHelperTags;
@@ -296,7 +324,7 @@ class WeblinksModelWeblink extends JModelAdmin
// Cast catid to integer for comparison
$catid = (int) $data['catid'];
-
+
// Check if New Category exists
if ($catid > 0)
{
@@ -376,6 +404,37 @@ class WeblinksModelWeblink extends JModelAdmin
$form->setFieldAttribute('catid', 'allowAdd', 'true');
}
+ // Association weblinks items
+ if (JLanguageAssociations::isEnabled())
+ {
+ $languages = JLanguageHelper::getContentLanguages(false, true, null, 'ordering', 'asc');
+
+ if (count($languages) > 1)
+ {
+ $addform = new SimpleXMLElement('');
+ $fields = $addform->addChild('fields');
+ $fields->addAttribute('name', 'associations');
+ $fieldset = $fields->addChild('fieldset');
+ $fieldset->addAttribute('name', 'item_associations');
+
+ foreach ($languages as $language)
+ {
+ $field = $fieldset->addChild('field');
+ $field->addAttribute('name', $language->lang_code);
+ $field->addAttribute('type', 'modal_weblink');
+ $field->addAttribute('language', $language->lang_code);
+ $field->addAttribute('label', $language->title);
+ $field->addAttribute('translate_label', 'false');
+ $field->addAttribute('select', 'true');
+ $field->addAttribute('new', 'true');
+ $field->addAttribute('edit', 'true');
+ $field->addAttribute('clear', 'true');
+ }
+
+ $form->load($addform, false);
+ }
+ }
+
parent::preprocessForm($form, $data, $group);
}
diff --git a/src/administrator/components/com_weblinks/models/weblinks.php b/src/administrator/components/com_weblinks/models/weblinks.php
index 50f96f6..9e5b4c5 100644
--- a/src/administrator/components/com_weblinks/models/weblinks.php
+++ b/src/administrator/components/com_weblinks/models/weblinks.php
@@ -52,6 +52,13 @@ class WeblinksModelWeblinks extends JModelList
'tag',
'level', 'c.level',
);
+
+ $assoc = JLanguageAssociations::isEnabled();
+
+ if ($assoc)
+ {
+ $config['filter_fields'][] = 'association';
+ }
}
parent::__construct($config);
@@ -70,6 +77,22 @@ class WeblinksModelWeblinks extends JModelList
*/
protected function populateState($ordering = 'a.title', $direction = 'asc')
{
+ $app = JFactory::getApplication();
+
+ $forcedLanguage = $app->input->get('forcedLanguage', '', 'cmd');
+
+ // Adjust the context to support modal layouts.
+ if ($layout = $app->input->get('layout'))
+ {
+ $this->context .= '.' . $layout;
+ }
+
+ // Adjust the context to support forced languages.
+ if ($forcedLanguage)
+ {
+ $this->context .= '.' . $forcedLanguage;
+ }
+
// Load the filter state.
$this->setState('filter.search', $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', '', 'string'));
$this->setState('filter.access', $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', '', 'cmd'));
@@ -83,6 +106,12 @@ class WeblinksModelWeblinks extends JModelList
$params = JComponentHelper::getParams('com_weblinks');
$this->setState('params', $params);
+ // Force a language.
+ if (!empty($forcedLanguage))
+ {
+ $this->setState('filter.language', $forcedLanguage);
+ }
+
// List state information.
parent::populateState($ordering, $direction);
}
@@ -132,7 +161,7 @@ class WeblinksModelWeblinks extends JModelList
$query->select(
$this->getState(
'list.select',
- 'a.id, a.title, a.alias, a.checked_out, a.checked_out_time, a.catid, a.created_by, ' .
+ 'a.id, a.title, a.alias, a.checked_out, a.checked_out_time, a.catid, a.created, a.created_by, ' .
'a.hits, a.state, a.access, a.ordering, a.language, a.publish_up, a.publish_down'
)
);
@@ -155,6 +184,17 @@ class WeblinksModelWeblinks extends JModelList
$query->select('c.title AS category_title')
->join('LEFT', $db->quoteName('#__categories', 'c') . ' ON ' . $db->qn('c.id') . ' = ' . $db->qn('a.catid'));
+ // Join over the associations.
+ $assoc = JLanguageAssociations::isEnabled();
+
+ if ($assoc)
+ {
+ $query->select('COUNT(asso2.id)>1 AS association')
+ ->join('LEFT', $db->quoteName('#__associations', 'asso') . ' ON asso.id = a.id AND asso.context = ' . $db->quote('com_weblinks.item'))
+ ->join('LEFT', $db->quoteName('#__associations', 'asso2') . ' ON asso2.key = asso.key')
+ ->group('a.id, l.title, l.image, uc.name, ag.title, c.title');
+ }
+
// Filter by access level.
if ($access = $this->getState('filter.access'))
{
diff --git a/src/administrator/components/com_weblinks/tables/weblink.php b/src/administrator/components/com_weblinks/tables/weblink.php
index ea8e5f8..a7910ec 100644
--- a/src/administrator/components/com_weblinks/tables/weblink.php
+++ b/src/administrator/components/com_weblinks/tables/weblink.php
@@ -93,7 +93,7 @@ class WeblinksTableWeblink extends JTable
// Verify that the alias is unique
$table = JTable::getInstance('Weblink', 'WeblinksTable');
- if ($table->load(array('alias' => $this->alias, 'catid' => $this->catid)) && ($table->id != $this->id || $this->id == 0))
+ if ($table->load(array('language' => $this->language, 'alias' => $this->alias, 'catid' => $this->catid)) && ($table->id != $this->id || $this->id == 0))
{
$this->setError(JText::_('COM_WEBLINKS_ERROR_UNIQUE_ALIAS'));
@@ -136,6 +136,7 @@ class WeblinksTableWeblink extends JTable
->select($db->quoteName('id'))
->from($db->quoteName('#__weblinks'))
->where($db->quoteName('title') . ' = ' . $db->quote($this->title))
+ ->where($db->quoteName('language') . ' = ' . $db->quote($this->language))
->where($db->quoteName('catid') . ' = ' . (int) $this->catid);
$db->setQuery($query);
@@ -153,7 +154,7 @@ class WeblinksTableWeblink extends JTable
$this->alias = $this->title;
}
- $this->alias = JApplicationHelper::stringURLSafe($this->alias);
+ $this->alias = JApplicationHelper::stringURLSafe($this->alias, $this->language);
if (trim(str_replace('-', '', $this->alias)) == '')
{
diff --git a/src/administrator/components/com_weblinks/views/weblink/tmpl/edit.php b/src/administrator/components/com_weblinks/views/weblink/tmpl/edit.php
index 382fd48..998ad90 100644
--- a/src/administrator/components/com_weblinks/views/weblink/tmpl/edit.php
+++ b/src/administrator/components/com_weblinks/views/weblink/tmpl/edit.php
@@ -14,8 +14,13 @@ JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
JHtml::_('behavior.formvalidator');
JHtml::_('formbehavior.chosen', 'select', null, array('disable_search_threshold' => 0 ));
-// Ignore Image fieldset for the layouts as we render it manually
-$this->ignore_fieldsets = array('images');
+$app = JFactory::getApplication();
+$input = $app->input;
+
+$assoc = JLanguageAssociations::isEnabled();
+
+// Fieldsets to not automatically render by /layouts/joomla/edit/params.php
+$this->ignore_fieldsets = array('details', 'images', 'item_associations', 'jmetadata');
JFactory::getDocument()->addScriptDeclaration("
Joomla.submitbutton = function(task)
@@ -26,9 +31,14 @@ JFactory::getDocument()->addScriptDeclaration("
}
};
");
+
+// In case of modal
+$isModal = $input->get('layout') == 'modal' ? true : false;
+$layout = $isModal ? 'modal' : 'edit';
+$tmpl = $isModal || $input->get('tmpl', '', 'cmd') === 'component' ? '&tmpl=component' : '';
?>
-
diff --git a/src/administrator/components/com_weblinks/views/weblink/tmpl/edit_associations.php b/src/administrator/components/com_weblinks/views/weblink/tmpl/edit_associations.php
new file mode 100644
index 0000000..286ec63
--- /dev/null
+++ b/src/administrator/components/com_weblinks/views/weblink/tmpl/edit_associations.php
@@ -0,0 +1,12 @@
+ 'bottom'));
+
+// @deprecated 4.0 the function parameter, the inline js and the buttons are not needed since 3.7.0.
+$function = JFactory::getApplication()->input->getCmd('function', 'jEditWeblink_' . (int) $this->item->id);
+
+// Function to update input title when changed
+JFactory::getDocument()->addScriptDeclaration('
+ function jEditWeblinkModal() {
+ if (window.parent && document.formvalidator.isValid(document.getElementById("weblink-form"))) {
+ return window.parent.' . $this->escape($function) . '(document.getElementById("jform_title").value);
+ }
+ }
+');
+?>
+
+
+
+
+
diff --git a/src/administrator/components/com_weblinks/views/weblink/tmpl/modal_associations.php b/src/administrator/components/com_weblinks/views/weblink/tmpl/modal_associations.php
new file mode 100644
index 0000000..286ec63
--- /dev/null
+++ b/src/administrator/components/com_weblinks/views/weblink/tmpl/modal_associations.php
@@ -0,0 +1,12 @@
+form->getFieldsets('params'); ?>
+ $fieldSet) : ?>
+
+ description) && trim($fieldSet->description)) : ?>
+ ' . $this->escape(JText::_($fieldSet->description)) . ''; ?>
+
+ form->getFieldset($name) as $field) : ?>
+
+
label; ?>
+
input; ?>
+
+
+
+
diff --git a/src/administrator/components/com_weblinks/views/weblink/view.html.php b/src/administrator/components/com_weblinks/views/weblink/view.html.php
index ec21d41..e670e92 100644
--- a/src/administrator/components/com_weblinks/views/weblink/view.html.php
+++ b/src/administrator/components/com_weblinks/views/weblink/view.html.php
@@ -42,6 +42,20 @@ class WeblinksViewWeblink extends JViewLegacy
return false;
}
+
+ // If we are forcing a language in modal (used for associations).
+ if ($this->getLayout() === 'modal' && $forcedLanguage = JFactory::getApplication()->input->get('forcedLanguage', '', 'cmd'))
+ {
+ // Set the language field to the forcedLanguage and disable changing it.
+ $this->form->setValue('language', null, $forcedLanguage);
+ $this->form->setFieldAttribute('language', 'readonly', 'true');
+
+ // Only allow to select categories with All language or with the forced language.
+ $this->form->setFieldAttribute('catid', 'language', '*,' . $forcedLanguage);
+
+ // Only allow to select tags with All language or with the forced language.
+ $this->form->setFieldAttribute('tags', 'language', '*,' . $forcedLanguage);
+ }
$this->addToolbar();
diff --git a/src/administrator/components/com_weblinks/views/weblinks/tmpl/default.php b/src/administrator/components/com_weblinks/views/weblinks/tmpl/default.php
index 27682cb..69b0840 100644
--- a/src/administrator/components/com_weblinks/views/weblinks/tmpl/default.php
+++ b/src/administrator/components/com_weblinks/views/weblinks/tmpl/default.php
@@ -15,12 +15,13 @@ JHtml::_('bootstrap.tooltip');
JHtml::_('behavior.multiselect');
JHtml::_('formbehavior.chosen', 'select');
-$user = JFactory::getUser();
-$userId = $user->get('id');
-$listOrder = $this->escape($this->state->get('list.ordering'));
-$listDirn = $this->escape($this->state->get('list.direction'));
-$canOrder = $user->authorise('core.edit.state', 'com_weblinks.category');
-$saveOrder = $listOrder == 'a.ordering';
+$user = JFactory::getUser();
+$userId = $user->get('id');
+$listOrder = $this->escape($this->state->get('list.ordering'));
+$listDirn = $this->escape($this->state->get('list.direction'));
+$canOrder = $user->authorise('core.edit.state', 'com_weblinks.category');
+$saveOrder = $listOrder == 'a.ordering';
+$assoc = JLanguageAssociations::isEnabled();
if ($saveOrder)
{
@@ -65,6 +66,11 @@ if ($saveOrder)
|
+
+
+
+ |
+
|
@@ -98,7 +104,7 @@ if ($saveOrder)
-
+
@@ -141,7 +147,14 @@ if ($saveOrder)
hits; ?>
|
-
+
+ |
+ association) : ?>
+ id); ?>
+
+ |
+
+
|
diff --git a/src/administrator/components/com_weblinks/views/weblinks/tmpl/modal.php b/src/administrator/components/com_weblinks/views/weblinks/tmpl/modal.php
new file mode 100644
index 0000000..aa5527b
--- /dev/null
+++ b/src/administrator/components/com_weblinks/views/weblinks/tmpl/modal.php
@@ -0,0 +1,147 @@
+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.
+
+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');
+
+// 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'));
+
+$function = $app->input->getCmd('function', 'jSelectWeblink');
+$editor = $app->input->getCmd('editor', '');
+$listOrder = $this->escape($this->state->get('list.ordering'));
+$listDirn = $this->escape($this->state->get('list.direction'));
+$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));
+ $onclick = "jSelectWeblink";
+}
+
+$iconStates = array(
+ -2 => 'icon-trash',
+ 0 => 'icon-unpublish',
+ 1 => 'icon-publish',
+ 2 => 'icon-archive',
+);
+
+?>
+
diff --git a/src/administrator/components/com_weblinks/views/weblinks/view.html.php b/src/administrator/components/com_weblinks/views/weblinks/view.html.php
index a722a91..cc37c83 100644
--- a/src/administrator/components/com_weblinks/views/weblinks/view.html.php
+++ b/src/administrator/components/com_weblinks/views/weblinks/view.html.php
@@ -37,7 +37,11 @@ class WeblinksViewWeblinks extends JViewLegacy
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
- WeblinksHelper::addSubmenu('weblinks');
+ // Modal layout doesn't need the submenu.
+ if ($this->getLayout() !== 'modal')
+ {
+ WeblinksHelper::addSubmenu('weblinks');
+ }
// Check for errors.
if (count($errors = $this->get('Errors')))
@@ -46,8 +50,30 @@ class WeblinksViewWeblinks extends JViewLegacy
return false;
}
- $this->addToolbar();
- $this->sidebar = JHtmlSidebar::render();
+ // We don't need toolbar in the modal layout.
+ if ($this->getLayout() !== 'modal')
+ {
+ $this->addToolbar();
+ $this->sidebar = JHtmlSidebar::render();
+ }
+ else
+ {
+ // In article associations modal we need to remove language filter if forcing a language.
+ // We also need to change the category filter to show show categories with All or the forced language.
+ if ($forcedLanguage = JFactory::getApplication()->input->get('forcedLanguage', '', 'CMD'))
+ {
+ // If the language is forced we can't allow to select the language, so transform the language selector filter into an hidden field.
+ $languageXml = new SimpleXMLElement('');
+ $this->filterForm->setField($languageXml, 'filter', true);
+
+ // Also, unset the active language filter so the search tools is not open by default with this filter.
+ unset($this->activeFilters['language']);
+
+ // One last changes needed is to change the category filter to just show categories with All language or with the forced language.
+ $this->filterForm->setFieldAttribute('category_id', 'language', '*,' . $forcedLanguage, 'filter');
+ }
+ }
+
parent::display($tpl);
}
diff --git a/src/administrator/components/com_weblinks/weblinks.xml b/src/administrator/components/com_weblinks/weblinks.xml
index 524d131..dec3e4c 100644
--- a/src/administrator/components/com_weblinks/weblinks.xml
+++ b/src/administrator/components/com_weblinks/weblinks.xml
@@ -33,6 +33,10 @@
+
+ ##MEDIA_FILES##
+
+
##FRONTEND_COMPONENT_FILES##
diff --git a/src/administrator/language/en-GB/en-GB.com_weblinks.ini b/src/administrator/language/en-GB/en-GB.com_weblinks.ini
index 5f8d45e..5c0d9ae 100644
--- a/src/administrator/language/en-GB/en-GB.com_weblinks.ini
+++ b/src/administrator/language/en-GB/en-GB.com_weblinks.ini
@@ -9,6 +9,7 @@ COM_WEBLINKS_BATCH_OPTIONS="Batch process the selected links"
COM_WEBLINKS_BATCH_TIP="If a category is selected for move/copy, any actions selected will be applied to the copied or moved links. Otherwise, all actions are applied to the selected links."
COM_WEBLINKS_CATEGORIES_DESC="These settings apply for Web Links Categories Options unless they are changed for a specific menu item."
COM_WEBLINKS_CATEGORY_DESC="These settings apply for Web Links Category Options unless they are changed for a specific menu item."
+COM_WEBLINKS_CHANGE_WEBLINK="Select or Change Web Link"
COM_WEBLINKS_COMPONENT_DESC="These settings apply for Web Links unless they are changed for a specific menu item or web link."
COM_WEBLINKS_COMPONENT_LABEL="Web Link"
COM_WEBLINKS_CONFIG_INTEGRATION_SETTINGS_DESC="These settings determine how the Web Links Component will integrate with other extensions."
@@ -84,8 +85,11 @@ COM_WEBLINKS_FILTER_CATEGORY="Filter Category"
COM_WEBLINKS_FILTER_SEARCH_DESC="Search in web link title and alias. Prefix with ID: to search for a web link ID."
COM_WEBLINKS_FILTER_SEARCH_LABEL="Search Web Links"
COM_WEBLINKS_FILTER_STATE="Filter State"
-COM_WEBLINKS_FLOAT_DESC="Controls placement of the image."
-COM_WEBLINKS_FLOAT_LABEL="Image Float"
+COM_WEBLINKS_FLOAT_FIRST_DESC="Controls placement of the first image."
+COM_WEBLINKS_FLOAT_FIRST_LABEL="First Image Float"
+COM_WEBLINKS_FLOAT_SECOND_DESC="Controls placement of the second image."
+COM_WEBLINKS_FLOAT_SECOND_LABEL="Second Image Float"
+COM_WEBLINKS_HEADING_ASSOCIATION="Association"
COM_WEBLINKS_HITS_DESC="Number of hits for this web link."
COM_WEBLINKS_LEFT="Left"
COM_WEBLINKS_LIST_LAYOUT_DESC="These settings apply for Web Links List Layout Options unless they are changed for a specific menu item."
@@ -116,9 +120,11 @@ COM_WEBLINKS_ORDER_HEADING="Order"
COM_WEBLINKS_RIGHT="Right"
COM_WEBLINKS_SAVE_SUCCESS="Web link successfully saved"
COM_WEBLINKS_SEARCH_IN_TITLE="Search in title"
+COM_WEBLINKS_SELECT_A_WEBLINK="Select Web Link"
COM_WEBLINKS_SHOW_EMPTY_CATEGORIES_DESC="If Show, empty categories will display. A category is only empty - if it has no Web links or subcategories."
COM_WEBLINKS_SUBMENU_CATEGORIES="Categories"
COM_WEBLINKS_SUBMENU_WEBLINKS="Web Links"
+COM_WEBLINKS_WEBLINKS="Web Links"
COM_WEBLINKS_XML_DESCRIPTION="Component for web links management"
JGLOBAL_NO_ITEM_SELECTED="No web links selected"
JGLOBAL_NEWITEMSLAST_DESC="New Web links default to the last position. Ordering can be changed after this Web link is saved."
diff --git a/src/administrator/language/en-GB/en-GB.com_weblinks.sys.ini b/src/administrator/language/en-GB/en-GB.com_weblinks.sys.ini
index bbc0da1..7375e2e 100644
--- a/src/administrator/language/en-GB/en-GB.com_weblinks.sys.ini
+++ b/src/administrator/language/en-GB/en-GB.com_weblinks.sys.ini
@@ -15,11 +15,15 @@ COM_WEBLINKS_CATEGORY_VIEW_DEFAULT_OPTION="Default"
COM_WEBLINKS_CATEGORY_VIEW_DEFAULT_TITLE="List Web Links in a Category"
COM_WEBLINKS_CONTENT_TYPE_WEBLINK="Web Link"
COM_WEBLINKS_CONTENT_TYPE_CATEGORY="Web Links Category"
+COM_WEBLINKS_FIELD_SELECT_WEBLINK_DESC="Select the desired Web link from the list."
+COM_WEBLINKS_FIELD_SELECT_WEBLINK_LABEL="Select Weblink"
COM_WEBLINKS_FORM_VIEW_DEFAULT_DESC="Display a form to submit a web link in the Frontend."
COM_WEBLINKS_FORM_VIEW_DEFAULT_OPTION="Default"
COM_WEBLINKS_FORM_VIEW_DEFAULT_TITLE="Submit a Web Link"
COM_WEBLINKS_LINKS="Links"
COM_WEBLINKS_TAGS_WEBLINK="Web Link"
COM_WEBLINKS_TAGS_CATEGORY="Web Link Category"
+COM_WEBLINKS_WEBLINK_VIEW_DEFAULT_DESC="Display a single Web link"
+COM_WEBLINKS_WEBLINK_VIEW_DEFAULT_TITLE="Single Weblink"
COM_WEBLINKS_XML_DESCRIPTION="Component for web links management."
diff --git a/src/administrator/manifests/packages/pkg_weblinks.xml b/src/administrator/manifests/packages/pkg_weblinks.xml
index 7fcc815..35dc053 100644
--- a/src/administrator/manifests/packages/pkg_weblinks.xml
+++ b/src/administrator/manifests/packages/pkg_weblinks.xml
@@ -21,6 +21,7 @@
plg_finder_weblinks.zip
plg_search_weblinks.zip
plg_system_weblinks.zip
+ plg_editors-xtd_weblink.zip
en-GB/en-GB.pkg_weblinks.sys.ini
diff --git a/src/components/com_weblinks/controller.php b/src/components/com_weblinks/controller.php
index 860ab38..7516e40 100644
--- a/src/components/com_weblinks/controller.php
+++ b/src/components/com_weblinks/controller.php
@@ -1,7 +1,7 @@
get('view') : $view;
$id = empty($id) ? $jinput->getInt('id') : $id;
+ if ($view === 'weblink')
+ {
+ if ($id)
+ {
+ $associations = JLanguageAssociations::getAssociations('com_weblinks', '#__weblinks', 'com_weblinks.item', $id);
+
+ $return = array();
+
+ foreach ($associations as $tag => $item)
+ {
+ $return[$tag] = WeblinksHelperRoute::getWeblinkRoute($item->id, (int) $item->catid, $item->language);
+ }
+
+ return $return;
+ }
+ }
+
if ($view == 'category' || $view == 'categories')
{
return self::getCategoryAssociations($id, 'com_weblinks');
diff --git a/src/components/com_weblinks/helpers/category.php b/src/components/com_weblinks/helpers/category.php
index 3928ea4..e2a27e4 100644
--- a/src/components/com_weblinks/helpers/category.php
+++ b/src/components/com_weblinks/helpers/category.php
@@ -1,7 +1,7 @@
@@ -31,8 +31,8 @@
@@ -40,20 +40,20 @@
@@ -63,18 +63,18 @@
@@ -126,9 +126,9 @@
@@ -141,9 +141,9 @@
@@ -152,8 +152,8 @@
name="rights"
type="hidden"
label="JFIELD_META_RIGHTS_LABEL"
- filter="unset"
description="JFIELD_META_RIGHTS_DESC"
+ filter="unset"
required="false"
labelclass="control-label"
/>
@@ -161,9 +161,9 @@
getParams();
+ $app = JFactory::getApplication('site');
// Load the object state.
- $id = $app->input->getInt('id');
- $this->setState('weblink.id', $id);
+ $pk = $app->input->getInt('id');
+ $this->setState('weblink.id', $pk);
// Load the parameters.
+ $params = $app->getParams();
$this->setState('params', $params);
+
+ $user = JFactory::getUser();
+
+ if ((!$user->authorise('core.edit.state', 'com_weblinks')) && (!$user->authorise('core.edit', 'com_weblinks')))
+ {
+ $this->setState('filter.published', 1);
+ $this->setState('filter.archived', 2);
+ }
+
+ $this->setState('filter.language', JLanguageMultilang::isEnabled());
}
/**
@@ -56,43 +67,109 @@ class WeblinksModelWeblink extends JModelItem
*
* @return mixed Object on success, false on failure.
*/
- public function getItem($id = null)
+ public function getItem($pk = null)
{
+ $user = JFactory::getUser();
+
+ $pk = (!empty($pk)) ? $pk : (int) $this->getState('weblink.id');
+
if ($this->_item === null)
{
- $this->_item = false;
+ $this->_item = array();
+ }
- if (empty($id))
+ if (!isset($this->_item[$pk]))
+ {
+ try
{
- $id = $this->getState('weblink.id');
- }
+ $db = $this->getDbo();
+ $query = $db->getQuery(true)
+ ->select($this->getState('item.select', 'a.*'))
+ ->from('#__weblinks AS a')
+ ->where('a.id = ' . (int) $pk);
- // Get a level row instance.
- $table = JTable::getInstance('Weblink', 'WeblinksTable');
+ // Join on category table.
+ $query->select('c.title AS category_title, c.alias AS category_alias, c.access AS category_access')
+ ->innerJoin('#__categories AS c on c.id = a.catid')
+ ->where('c.published > 0');
- // Attempt to load the row.
- if ($table->load($id))
- {
- // Check published state.
- if ($published = $this->getState('filter.published'))
+ // Join on user table.
+ $query->select('u.name AS author')
+ ->join('LEFT', '#__users AS u on u.id = a.created_by');
+
+ // Filter by language
+ if ($this->getState('filter.language'))
{
- if ($table->state != $published)
- {
- return $this->_item;
- }
+ $query->where('a.language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')');
}
- // Convert the JTable to a clean JObject.
- $properties = $table->getProperties(1);
- $this->_item = ArrayHelper::toObject($properties, 'JObject');
+ // Join over the categories to get parent category titles
+ $query->select('parent.title as parent_title, parent.id as parent_id, parent.path as parent_route, parent.alias as parent_alias')
+ ->join('LEFT', '#__categories as parent ON parent.id = c.parent_id');
+
+ if ((!$user->authorise('core.edit.state', 'com_weblinks')) && (!$user->authorise('core.edit', 'com_weblinks')))
+ {
+ // Filter by start and end dates.
+ $nullDate = $db->quote($db->getNullDate());
+ $date = JFactory::getDate();
+
+ $nowDate = $db->quote($date->toSql());
+
+ $query->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')')
+ ->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')');
+ }
+
+ // Filter by published state.
+ $published = $this->getState('filter.published');
+ $archived = $this->getState('filter.archived');
+
+ if (is_numeric($published))
+ {
+ $query->where('(a.state = ' . (int) $published . ' OR a.state =' . (int) $archived . ')');
+ }
+
+ $db->setQuery($query);
+
+ $data = $db->loadObject();
+
+ if (empty($data))
+ {
+ JError::raiseError(404, JText::_('COM_WEBLINKS_ERROR_WEBLINK_NOT_FOUND'));
+ }
+
+ // Check for published state if filter set.
+ if ((is_numeric($published) || is_numeric($archived)) && (($data->state != $published) && ($data->state != $archived)))
+ {
+ JError::raiseError(404, JText::_('COM_WEBLINKS_ERROR_WEBLINK_NOT_FOUND'));
+ }
+
+ // Convert parameter fields to objects.
+ $data->params = new Registry($data->params);
+ $data->metadata = new Registry($data->metadata);
+
+ // Compute access permissions.
+ if ($access = $this->getState('filter.access'))
+ {
+ // If the access filter has been set, we already know this user can view.
+ $data->params->set('access-view', true);
+ }
+ else
+ {
+ // If no access filter is set, the layout takes some responsibility for display of limited information.
+ $groups = $user->getAuthorisedViewLevels();
+ $data->params->set('access-view', in_array($data->access, $groups) && in_array($data->category_access, $groups));
+ }
+
+ $this->_item[$pk] = $data;
}
- elseif ($error = $table->getError())
+ catch (Exception $e)
{
- $this->setError($error);
+ $this->setError($e);
+ $this->_item[$pk] = false;
}
}
- return $this->_item;
+ return $this->_item[$pk];
}
/**
@@ -118,13 +195,13 @@ class WeblinksModelWeblink extends JModelItem
*
* @return boolean True on success
*/
- public function hit($id = null)
+ public function hit($pk = null)
{
- if (empty($id))
+ if (empty($pk))
{
- $id = $this->getState('weblink.id');
+ $pk = $this->getState('weblink.id');
}
- return $this->getTable('Weblink', 'WeblinksTable')->hit($id);
+ return $this->getTable('Weblink', 'WeblinksTable')->hit($pk);
}
}
diff --git a/src/components/com_weblinks/router.php b/src/components/com_weblinks/router.php
index 23c3248..ee5253d 100644
--- a/src/components/com_weblinks/router.php
+++ b/src/components/com_weblinks/router.php
@@ -1,7 +1,7 @@
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/components/com_weblinks/views/categories/tmpl/default_items.php b/src/components/com_weblinks/views/categories/tmpl/default_items.php
index b588ef7..a702eca 100644
--- a/src/components/com_weblinks/views/categories/tmpl/default_items.php
+++ b/src/components/com_weblinks/views/categories/tmpl/default_items.php
@@ -1,7 +1,7 @@
-
-
-
-
-
+
+
-
+ >
-
+ >
-
+ >
-
+ >
@@ -72,124 +84,140 @@
-
+ >
-
-
-
-
+ >
+
+
+
-
-
-
-
+ >
+
+
+
-
+
-
-
+
+ >
-
+ >
-
+ >
-
-
-
-
+ >
+
+
+
-
+
+
+
- description="COM_WEBLINKS_FIELD_CONFIG_HITS_DESC"
- label="JGLOBAL_HITS"
- useglobal="true"
- >
-
-
-
-
-
-
+ >
-
-
-
-
-
-
-
-
-
+ >
-
-
+
+
+
+
+
+
+
+
diff --git a/src/components/com_weblinks/views/category/tmpl/default_children.php b/src/components/com_weblinks/views/category/tmpl/default_children.php
index 1379329..efac70a 100644
--- a/src/components/com_weblinks/views/category/tmpl/default_children.php
+++ b/src/components/com_weblinks/views/category/tmpl/default_children.php
@@ -1,7 +1,7 @@
escape($this->state->get('list.direction'));
images); ?>
image_first) and !empty($images->image_first)) : ?>
float_first)) ? $this->params->get('float_first') : $images->float_first; ?>
- image_first_caption) : ?>
image_first_caption) . '"'; ?>
@@ -143,7 +143,7 @@ $listDirn = $this->escape($this->state->get('list.direction'));
image_second) and !empty($images->image_second)) : ?>
float_second)) ? $this->params->get('float_second') : $images->float_second; ?>
- image_second_caption) : ?>
image_second_caption) . '"'; ?>
diff --git a/src/components/com_weblinks/views/category/view.feed.php b/src/components/com_weblinks/views/category/view.feed.php
index 1617cd3..56bfb38 100644
--- a/src/components/com_weblinks/views/category/view.feed.php
+++ b/src/components/com_weblinks/views/category/view.feed.php
@@ -1,7 +1,7 @@
item->url);
+
+?>
+
+
+
+
+ item->event->afterDisplayTitle; ?>
+
+ item->event->beforeDisplayContent; ?>
+
+
+
+
+ item->description; ?>
+
+
+ item->event->afterDisplayContent; ?>
+
diff --git a/src/components/com_weblinks/views/weblink/tmpl/default.xml b/src/components/com_weblinks/views/weblink/tmpl/default.xml
new file mode 100644
index 0000000..a22e772
--- /dev/null
+++ b/src/components/com_weblinks/views/weblink/tmpl/default.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/components/com_weblinks/views/weblink/view.html.php b/src/components/com_weblinks/views/weblink/view.html.php
index ea1d1fd..045e31d 100644
--- a/src/components/com_weblinks/views/weblink/view.html.php
+++ b/src/components/com_weblinks/views/weblink/view.html.php
@@ -1,7 +1,7 @@
get('Item');
+ $dispatcher = JEventDispatcher::getInstance();
- if ($this->getLayout() == 'edit')
- {
- $this->_displayEdit($tpl);
+ $this->item = $this->get('Item');
+ $this->state = $this->get('State');
+ $this->params = $this->state->get('params');
- return;
- }
+ // Create a shortcut for $item.
+ $item = $this->item;
- if ($item->url)
- {
- // Redirects to url if matching id found
- JFactory::getApplication()->redirect($item->url);
- }
- else
- {
- // @TODO create proper error handling
- JFactory::getApplication()->redirect(JRoute::_('index.php'), JText::_('COM_WEBLINKS_ERROR_WEBLINK_NOT_FOUND'), 'notice');
- }
+ $offset = $this->state->get('list.offset');
+
+ $dispatcher->trigger('onContentPrepare', array ('com_weblinks.weblink', &$item, &$item->params, $offset));
+
+ $item->event = new stdClass;
+
+ $results = $dispatcher->trigger('onContentAfterTitle', array('com_weblinks.weblink', &$item, &$item->params, $offset));
+ $item->event->afterDisplayTitle = trim(implode("\n", $results));
+
+ $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_weblinks.weblink', &$item, &$item->params, $offset));
+ $item->event->beforeDisplayContent = trim(implode("\n", $results));
+
+ $results = $dispatcher->trigger('onContentAfterDisplay', array('com_weblinks.weblink', &$item, &$item->params, $offset));
+ $item->event->afterDisplayContent = trim(implode("\n", $results));
+
+ parent::display($tpl);
}
}
diff --git a/src/components/com_weblinks/weblinks.php b/src/components/com_weblinks/weblinks.php
index d1fa171..e025468 100644
--- a/src/components/com_weblinks/weblinks.php
+++ b/src/components/com_weblinks/weblinks.php
@@ -1,7 +1,7 @@
' + title + '';
+
+ /** 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();
+ };
+
+ document.addEventListener('DOMContentLoaded', function(){
+ // Get the elements
+ var elements = document.querySelectorAll('.select-link');
+
+ for(var i = 0, l = elements.length; l>i; i++) {
+ // Listen for click event
+ elements[i].addEventListener('click', function (event) {
+ event.preventDefault();
+ var functionName = event.target.getAttribute('data-function');
+
+ if (functionName === 'jSelectWeblink') {
+ // Used in xtd_weblinks
+ window[functionName](event.target.getAttribute('data-id'), event.target.getAttribute('data-title'), event.target.getAttribute('data-cat-id'), null, event.target.getAttribute('data-uri'), event.target.getAttribute('data-language', null));
+ } else {
+ // Used in com_menus
+ window.parent[functionName](event.target.getAttribute('data-id'), event.target.getAttribute('data-title'), event.target.getAttribute('data-cat-id'), null, event.target.getAttribute('data-uri'), event.target.getAttribute('data-language', null));
+ }
+ })
+ }
+ });
+})();
diff --git a/src/media/com_weblinks/js/admin-weblinks-modal.min.js b/src/media/com_weblinks/js/admin-weblinks-modal.min.js
new file mode 100644
index 0000000..dcc3689
--- /dev/null
+++ b/src/media/com_weblinks/js/admin-weblinks-modal.min.js
@@ -0,0 +1 @@
+!function(){"use strict";window.jSelectWeblink=function(a,b,c,d,e,f){var h,i,g="";if(!Joomla.getOptions("xtd-weblinks"))return window.parent.jModalClose(),!1;h=Joomla.getOptions("xtd-weblinks").editor,""!==f&&(g=' hreflang="'+f+'"'),i=" '+b+"",window.Joomla&&window.Joomla.editors&&Joomla.editors.instances&&Joomla.editors.instances.hasOwnProperty(h)?Joomla.editors.instances[h].replaceSelection(i):window.parent.jInsertEditorText(i,h),window.parent.jModalClose()},document.addEventListener("DOMContentLoaded",function(){for(var a=document.querySelectorAll(".select-link"),b=0,c=a.length;c>b;b++)a[b].addEventListener("click",function(a){a.preventDefault();var b=a.target.getAttribute("data-function");"jSelectWeblink"===b?window[b](a.target.getAttribute("data-id"),a.target.getAttribute("data-title"),a.target.getAttribute("data-cat-id"),null,a.target.getAttribute("data-uri"),a.target.getAttribute("data-language",null)):window.parent[b](a.target.getAttribute("data-id"),a.target.getAttribute("data-title"),a.target.getAttribute("data-cat-id"),null,a.target.getAttribute("data-uri"),a.target.getAttribute("data-language",null))})})}();
\ No newline at end of file
diff --git a/src/modules/mod_weblinks/mod_weblinks.xml b/src/modules/mod_weblinks/mod_weblinks.xml
index c096e13..4cffd6b 100644
--- a/src/modules/mod_weblinks/mod_weblinks.xml
+++ b/src/modules/mod_weblinks/mod_weblinks.xml
@@ -11,6 +11,7 @@
MOD_WEBLINKS_XML_DESCRIPTION
##MODULE_FILES##
+ mod_weblinks.php
##LANGUAGE_FILES##
@@ -22,20 +23,20 @@
+ class="btn-group btn-group-yesno"
+ default="0"
+ >
@@ -43,12 +44,12 @@
+ >
@@ -56,11 +57,11 @@
+ >
@@ -68,11 +69,11 @@
+ >
@@ -80,12 +81,12 @@
+ default="3"
+ >
-
+
@@ -94,18 +95,18 @@
+ default="title"
+ >
@@ -114,10 +115,10 @@
+ default="asc"
+ >
@@ -125,10 +126,10 @@
+ default="0"
+ >
@@ -136,11 +137,11 @@
+ class="btn-group btn-group-yesno"
+ default="0"
+ >
@@ -148,11 +149,11 @@
+ class="btn-group btn-group-yesno"
+ default="0"
+ >
@@ -160,16 +161,17 @@
+ class="chzn-color"
+ default="0"
+ >
+
+ default="1"
+ >
@@ -200,9 +202,9 @@
authorise('core.create', 'com_weblinks')
+ || $user->authorise('core.edit', 'com_weblinks')
+ || $user->authorise('core.edit.own', 'com_weblinks'))
+ {
+ // The URL for the weblinks list
+ $link = 'index.php?option=com_weblinks&view=weblinks&layout=modal&tmpl=component&'
+ . JSession::getFormToken() . '=1&editor=' . $name;
+
+ $button = new JObject;
+ $button->modal = true;
+ $button->class = 'btn';
+ $button->link = $link;
+ $button->text = JText::_('PLG_EDITORS-XTD_WEBLINK_BUTTON_WEBLINK');
+ $button->name = 'link';
+ $button->options = "{handler: 'iframe', size: {x: 800, y: 500}}";
+
+ return $button;
+ }
+ }
+}
diff --git a/src/plugins/editors-xtd/weblink/weblink.xml b/src/plugins/editors-xtd/weblink/weblink.xml
new file mode 100644
index 0000000..29c425a
--- /dev/null
+++ b/src/plugins/editors-xtd/weblink/weblink.xml
@@ -0,0 +1,18 @@
+
+
+ plg_editors-xtd_weblink
+ Joomla! Project
+ ##DATE##
+ Copyright (C) 2005 - 2017 Open Source Matters. All rights reserved.
+ GNU General Public License version 2 or later; see LICENSE.txt
+ admin@joomla.org
+ www.joomla.org
+ 3.7.0
+ PLG_EDITORS-XTD_WEBLINK_XML_DESCRIPTION
+
+ ##FILES##
+
+
+ ##LANGUAGE_FILES##
+
+
diff --git a/src/plugins/search/weblinks/weblinks.xml b/src/plugins/search/weblinks/weblinks.xml
index 51066a8..47a3cc7 100644
--- a/src/plugins/search/weblinks/weblinks.xml
+++ b/src/plugins/search/weblinks/weblinks.xml
@@ -21,20 +21,20 @@
+ >
@@ -42,11 +42,11 @@
+ >
|