diff --git a/src/administrator/components/com_weblinks/helpers/associations.php b/src/administrator/components/com_weblinks/helpers/associations.php index a5e2cdb..5f64ba8 100644 --- a/src/administrator/components/com_weblinks/helpers/associations.php +++ b/src/administrator/components/com_weblinks/helpers/associations.php @@ -36,7 +36,7 @@ class WeblinksAssociationsHelper extends JAssociationExtensionHelper * * @since __DEPLOY_VERSION__ */ - protected $itemTypes = array('category'); + protected $itemTypes = array('weblink', 'category'); /** * Has the extension association support @@ -105,6 +105,10 @@ class WeblinksAssociationsHelper extends JAssociationExtensionHelper switch ($typeName) { + case 'weblink': + $table = JTable::getInstance('Weblink', 'WeblinksTable'); + break; + case 'category': $table = JTable::getInstance('Category'); break; @@ -141,6 +145,21 @@ class WeblinksAssociationsHelper extends JAssociationExtensionHelper { switch ($typeName) { + case 'weblink': + + $support['state'] = true; + $support['acl'] = true; + $support['checkout'] = true; + $support['category'] = true; + $support['save2copy'] = true; + + $tables = array( + 'a' => '#__weblinks' + ); + + $title = 'weblink'; + break; + case 'category': $fields['created_user_id'] = 'a.created_user_id'; $fields['ordering'] = 'a.lft'; diff --git a/src/administrator/components/com_weblinks/helpers/html/weblink.php b/src/administrator/components/com_weblinks/helpers/html/weblink.php new file mode 100644 index 0000000..4a7a18d --- /dev/null +++ b/src/administrator/components/com_weblinks/helpers/html/weblink.php @@ -0,0 +1,91 @@ + $associated) + { + $associations[$tag] = (int) $associated->id; + } + + // Get the associated weblinks items + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select('c.id, c.title as title') + ->select('l.sef as lang_sef, lang_code') + ->from('#__weblinks as c') + ->select('cat.title as category_title') + ->join('LEFT', '#__categories as cat ON cat.id=c.catid') + ->where('c.id IN (' . implode(',', array_values($associations)) . ')') + ->join('LEFT', '#__languages as l ON c.language=l.lang_code') + ->select('l.image') + ->select('l.title as language_title'); + $db->setQuery($query); + + try + { + $items = $db->loadObjectList('id'); + } + catch (RuntimeException $e) + { + throw new Exception($e->getMessage(), 500, $e); + } + + if ($items) + { + foreach ($items as &$item) + { + $text = strtoupper($item->lang_sef); + $url = JRoute::_('index.php?option=com_weblinks&task=weblink.edit&id=' . (int) $item->id); + + $tooltip = htmlspecialchars($item->title, ENT_QUOTES, 'UTF-8') . '
' . JText::sprintf('JCATEGORY_SPRINTF', $item->category_title); + $classes = 'hasPopover label label-association label-' . $item->lang_sef; + + $item->link = '' + . $text . ''; + } + } + + JHtml::_('bootstrap.popover'); + + $html = JLayoutHelper::render('joomla.content.associations', $items); + } + + return $html; + } +} diff --git a/src/administrator/components/com_weblinks/models/fields/modal/weblink.php b/src/administrator/components/com_weblinks/models/fields/modal/weblink.php new file mode 100644 index 0000000..f3d5397 --- /dev/null +++ b/src/administrator/components/com_weblinks/models/fields/modal/weblink.php @@ -0,0 +1,256 @@ +element['new'] == 'true'); + $allowEdit = ((string) $this->element['edit'] == 'true'); + $allowClear = ((string) $this->element['clear'] != 'false'); + $allowSelect = ((string) $this->element['select'] != 'false'); + + // Load language + JFactory::getLanguage()->load('com_weblinks', JPATH_ADMINISTRATOR); + + // The active weblink id field. + $value = (int) $this->value > 0 ? (int) $this->value : ''; + + // Create the modal id. + $modalId = 'Weblink_' . $this->id; + + // Add the modal field script to the document head. + JHtml::_('jquery.framework'); + JHtml::_('script', 'system/modal-fields.js', array('version' => 'auto', 'relative' => true)); + + // Script to proxy the select modal function to the modal-fields.js file. + if ($allowSelect) + { + static $scriptSelect = null; + + if (is_null($scriptSelect)) + { + $scriptSelect = array(); + } + + 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); + } + "); + $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'); + + if (isset($this->element['language'])) + { + $linkWeblinks .= '&forcedLanguage=' . $this->element['language']; + $linkWeblink .= '&forcedLanguage=' . $this->element['language']; + $modalTitle .= ' — ' . $this->element['label']; + } + + $urlSelect = $linkWeblinks . '&function=jSelectWeblink_' . $this->id; + $urlEdit = $linkWeblink . '&task=weblink.edit&id=\' + document.getElementById("' . $this->id . '_id").value + \''; + $urlNew = $linkWeblink . '&task=weblink.add'; + + if ($value) + { + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select($db->quoteName('title')) + ->from($db->quoteName('#__weblinks')) + ->where($db->quoteName('id') . ' = ' . (int) $value); + $db->setQuery($query); + try + { + $title = $db->loadResult(); + } + catch (RuntimeException $e) + { + JError::raiseWarning(500, $e->getMessage()); + } + } + $title = empty($title) ? JText::_('COM_WEBLINKS_SELECT_A_WEBLINK') : htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); + + // The current weblink display field. + $html = ''; + $html .= ''; + + // Select weblink button + if ($allowSelect) + { + $html .= '' + . ' ' . JText::_('JSELECT') + . ''; + } + // New weblink button + if ($allowNew) + { + $html .= '' + . ' ' . JText::_('JACTION_CREATE') + . ''; + } + // Edit weblink button + if ($allowEdit) + { + $html .= '' + . ' ' . JText::_('JACTION_EDIT') + . ''; + } + // Clear weblink button + if ($allowClear) + { + $html .= '' + . '' . JText::_('JCLEAR') + . ''; + } + $html .= ''; + + // Select weblink modal + if ($allowSelect) + { + $html .= JHtml::_( + 'bootstrap.renderModal', + 'ModalSelect' . $modalId, + array( + 'title' => $modalTitle, + 'url' => $urlSelect, + 'height' => '400px', + 'width' => '800px', + 'bodyHeight' => '70', + 'modalWidth' => '80', + 'footer' => '', + ) + ); + } + + // New weblink modal + if ($allowNew) + { + $html .= JHtml::_( + 'bootstrap.renderModal', + 'ModalNew' . $modalId, + array( + 'title' => JText::_('COM_WEBLINKS_NEW_WEBLINK'), + 'backdrop' => 'static', + 'keyboard' => false, + 'closeButton' => false, + 'url' => $urlNew, + 'height' => '400px', + 'width' => '800px', + 'bodyHeight' => '70', + 'modalWidth' => '80', + 'footer' => '' + . '' + . '', + ) + ); + } + + // Edit weblink modal + if ($allowEdit) + { + $html .= JHtml::_( + 'bootstrap.renderModal', + 'ModalEdit' . $modalId, + array( + 'title' => JText::_('COM_WEBLINKS_EDIT_WEBLINK'), + 'backdrop' => 'static', + 'keyboard' => false, + 'closeButton' => false, + 'url' => $urlEdit, + 'height' => '400px', + 'width' => '800px', + 'bodyHeight' => '70', + 'modalWidth' => '80', + 'footer' => '' + . '' + . '', + ) + ); + } + // Note: class='required' for client side validation. + $class = $this->required ? ' class="required modal-value"' : ''; + $html .= ''; + return $html; + } + + /** + * Method to get the field label markup. + * + * @return string The field label markup. + * + * @since __DEPLOY_VERSION__ + */ + protected function getLabel() + { + return str_replace($this->id, $this->id . '_id', parent::getLabel()); + } +} diff --git a/src/administrator/components/com_weblinks/models/forms/filter_weblinks.xml b/src/administrator/components/com_weblinks/models/forms/filter_weblinks.xml index c06a48f..3746583 100644 --- a/src/administrator/components/com_weblinks/models/forms/filter_weblinks.xml +++ b/src/administrator/components/com_weblinks/models/forms/filter_weblinks.xml @@ -8,7 +8,6 @@ description="COM_WEBLINKS_FILTER_SEARCH_DESC" hint="JSEARCH_FILTER" /> - - - - JOPTION_SELECT_LANGUAGE - - JOPTION_SELECT_MAX_LEVELS - JGRID_HEADING_ACCESS_DESC + + - loadString($item->images); $item->images = $registry->toArray(); + // Load associated newsfeeds items + $app = JFactory::getApplication(); + $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; @@ -376,6 +405,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..808d919 100644 --- a/src/administrator/components/com_weblinks/models/weblinks.php +++ b/src/administrator/components/com_weblinks/models/weblinks.php @@ -52,6 +52,12 @@ class WeblinksModelWeblinks extends JModelList 'tag', 'level', 'c.level', ); + + $assoc = JLanguageAssociations::isEnabled(); + if ($assoc) + { + $config['filter_fields'][] = 'association'; + } } parent::__construct($config); @@ -70,6 +76,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 +105,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 +160,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 +183,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..ce9b6e1 100644 --- a/src/administrator/components/com_weblinks/tables/weblink.php +++ b/src/administrator/components/com_weblinks/tables/weblink.php @@ -153,7 +153,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..7765b32 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' : ''; ?> - + @@ -73,11 +83,20 @@ JFactory::getDocument()->addScriptDeclaration(" + + + + loadTemplate('associations'); ?> + + + + +
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); + } + } +'); +?> + + + + +
+ setLayout('edit'); ?> + loadTemplate(); ?> +
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..75fee92 100644 --- a/src/administrator/components/com_weblinks/views/weblinks/tmpl/default.php +++ b/src/administrator/components/com_weblinks/views/weblinks/tmpl/default.php @@ -21,6 +21,7 @@ $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..34893af --- /dev/null +++ b/src/administrator/components/com_weblinks/views/weblinks/tmpl/modal.php @@ -0,0 +1,141 @@ +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', +); +?> +
+ +
+ $this)); ?> +
+ items)) : ?> +
+ +
+ + + + + + + + + + + + + + + + + + + items as $i => $item) : ?> + + language && JLanguageMultilang::isEnabled()) : ?> + language); ?> + + language, 0, 2); ?> + + language, 0, 3); ?> + + + + + + + + + + + + +
+ + + + + + + + + + + +
+ pagination->getListFooter(); ?> +
+ + + escape($onclick) . '"' + . ' 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-language="' . $this->escape($lang) . '"'; + ?> + > + escape($item->title); ?> + +
+ escape($item->category_title); ?> +
+
+ escape($item->access_level); ?> + + + + created, JText::_('DATE_FORMAT_LC4')); ?> + + id; ?> +
+ + + + + + + +
+
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/language/en-GB/en-GB.com_weblinks.ini b/src/administrator/language/en-GB/en-GB.com_weblinks.ini index 1ceff68..63195ff 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." @@ -86,6 +87,7 @@ 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_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 +118,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 Weblink" 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/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 @@ 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..56a35e2 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 @@ ' + 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_contacts + 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..e29bde7 --- /dev/null +++ b/src/media/com_weblinks/js/admin-weblinks-modal.min.js @@ -0,0 +1,61 @@ +/** + * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +(function() { + "use strict"; + /** + * Javascript to insert the link + * View element calls jSelectWeblink when an weblink is clicked + * jSelectWeblink creates the link tag, sends it to the editor, + * and closes the select frame. + **/ + window.jSelectWeblink = function (id, title, catid, object, link, lang) { + var hreflang = '', editor, tag; + + if (!Joomla.getOptions('xtd-weblinks')) { + // Something went wrong! + window.parent.jModalClose(); + return false; + } + + editor = Joomla.getOptions('xtd-weblinks').editor; + + if (lang !== '') + { + hreflang = ' hreflang="' + lang + '"'; + } + + tag = '' + 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_contacts + 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)); + } + }) + } + }); +})();