From f7691ed50d75b2a40c86e1e295acdb455ceaf73c Mon Sep 17 00:00:00 2001 From: zero-24 Date: Sat, 25 Feb 2017 11:42:25 +0100 Subject: [PATCH 01/27] first step for custom_fields --- .../components/com_weblinks/access.xml | 15 +++++++++++++++ .../components/com_weblinks/config.xml | 11 +++++++++++ .../components/com_weblinks/helpers/weblinks.php | 15 +++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/src/administrator/components/com_weblinks/access.xml b/src/administrator/components/com_weblinks/access.xml index 4cda7d9..1622da5 100644 --- a/src/administrator/components/com_weblinks/access.xml +++ b/src/administrator/components/com_weblinks/access.xml @@ -9,6 +9,7 @@ +
@@ -17,4 +18,18 @@
+
+ + + + + + +
+
+ + + + +
diff --git a/src/administrator/components/com_weblinks/config.xml b/src/administrator/components/com_weblinks/config.xml index 04e0079..924871d 100644 --- a/src/administrator/components/com_weblinks/config.xml +++ b/src/administrator/components/com_weblinks/config.xml @@ -363,6 +363,17 @@ + + + +
get('custom_fields_enable', '1')) + { + JHtmlSidebar::addEntry( + JText::_('JGLOBAL_FIELDS'), + 'index.php?option=com_fields&context=com_weblinks.weblink', + $vName == 'fields.fields' + ); + + JHtmlSidebar::addEntry( + JText::_('JGLOBAL_FIELD_GROUPS'), + 'index.php?option=com_fields&view=groups&context=com_weblinks.weblink', + $vName == 'fields.groups' + ); + } } /** From 95bd6c9c2e6b5e54ab12ea70b43807917e0e3210 Mon Sep 17 00:00:00 2001 From: zero-24 Date: Sat, 25 Feb 2017 11:52:36 +0100 Subject: [PATCH 02/27] cs --- src/administrator/components/com_weblinks/config.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/administrator/components/com_weblinks/config.xml b/src/administrator/components/com_weblinks/config.xml index 924871d..f11ad49 100644 --- a/src/administrator/components/com_weblinks/config.xml +++ b/src/administrator/components/com_weblinks/config.xml @@ -370,7 +370,7 @@ description="JGLOBAL_CUSTOM_FIELDS_ENABLE_DESC" default="1" class="btn-group btn-group-yesno" - > + > From d4a03c2d558b7883f09bc8c45155be0a97b7fa9e Mon Sep 17 00:00:00 2001 From: zero-24 Date: Sat, 25 Feb 2017 13:04:33 +0100 Subject: [PATCH 03/27] default should be off --- src/administrator/components/com_weblinks/config.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/administrator/components/com_weblinks/config.xml b/src/administrator/components/com_weblinks/config.xml index f11ad49..f3947cc 100644 --- a/src/administrator/components/com_weblinks/config.xml +++ b/src/administrator/components/com_weblinks/config.xml @@ -368,7 +368,7 @@ type="radio" label="JGLOBAL_CUSTOM_FIELDS_ENABLE_LABEL" description="JGLOBAL_CUSTOM_FIELDS_ENABLE_DESC" - default="1" + default="0" class="btn-group btn-group-yesno" > From 3389bf4902f68aa664740723dc78762ad89d2683 Mon Sep 17 00:00:00 2001 From: Jean-Marie Simonet Date: Tue, 16 May 2017 08:03:22 +0200 Subject: [PATCH 04/27] IMplementing full associations --- .../com_weblinks/helpers/associations.php | 21 +- .../com_weblinks/helpers/html/weblink.php | 91 +++++++ .../models/fields/modal/weblink.php | 256 ++++++++++++++++++ .../models/forms/filter_weblinks.xml | 20 +- .../com_weblinks/models/weblink.php | 60 ++++ .../com_weblinks/models/weblinks.php | 41 ++- .../com_weblinks/tables/weblink.php | 2 +- .../com_weblinks/views/weblink/tmpl/edit.php | 25 +- .../views/weblink/tmpl/edit_associations.php | 12 + .../com_weblinks/views/weblink/tmpl/modal.php | 31 +++ .../views/weblink/tmpl/modal_associations.php | 12 + .../views/weblink/tmpl/modal_metadata.php | 12 + .../views/weblink/tmpl/modal_params.php | 25 ++ .../com_weblinks/views/weblink/view.html.php | 14 + .../views/weblinks/tmpl/default.php | 17 +- .../views/weblinks/tmpl/modal.php | 141 ++++++++++ .../com_weblinks/views/weblinks/view.html.php | 32 ++- .../language/en-GB/en-GB.com_weblinks.ini | 4 + .../language/en-GB/en-GB.com_weblinks.sys.ini | 4 + src/components/com_weblinks/controller.php | 4 +- .../com_weblinks/controllers/weblink.php | 4 +- .../com_weblinks/helpers/association.php | 21 +- .../com_weblinks/helpers/category.php | 4 +- src/components/com_weblinks/helpers/icon.php | 4 +- src/components/com_weblinks/helpers/route.php | 4 +- .../com_weblinks/models/categories.php | 4 +- .../com_weblinks/models/category.php | 4 +- src/components/com_weblinks/models/form.php | 4 +- .../com_weblinks/models/weblink.php | 4 +- src/components/com_weblinks/router.php | 4 +- .../views/categories/tmpl/default.php | 4 +- .../views/categories/tmpl/default_items.php | 4 +- .../views/categories/view.html.php | 4 +- .../views/category/tmpl/default.php | 4 +- .../views/category/tmpl/default_children.php | 4 +- .../views/category/tmpl/default_items.php | 4 +- .../com_weblinks/views/category/view.feed.php | 4 +- .../com_weblinks/views/category/view.html.php | 4 +- .../com_weblinks/views/form/tmpl/edit.php | 4 +- .../com_weblinks/views/form/view.html.php | 4 +- .../views/weblink/tmpl/default.php | 34 +++ .../views/weblink/tmpl/default.xml | 30 ++ .../com_weblinks/views/weblink/view.html.php | 4 +- src/components/com_weblinks/weblinks.php | 4 +- .../com_weblinks/js/admin-weblinks-modal.js | 61 +++++ .../js/admin-weblinks-modal.min.js | 61 +++++ 46 files changed, 1050 insertions(+), 65 deletions(-) create mode 100644 src/administrator/components/com_weblinks/helpers/html/weblink.php create mode 100644 src/administrator/components/com_weblinks/models/fields/modal/weblink.php create mode 100644 src/administrator/components/com_weblinks/views/weblink/tmpl/edit_associations.php create mode 100644 src/administrator/components/com_weblinks/views/weblink/tmpl/modal.php create mode 100644 src/administrator/components/com_weblinks/views/weblink/tmpl/modal_associations.php create mode 100644 src/administrator/components/com_weblinks/views/weblink/tmpl/modal_metadata.php create mode 100644 src/administrator/components/com_weblinks/views/weblink/tmpl/modal_params.php create mode 100644 src/administrator/components/com_weblinks/views/weblinks/tmpl/modal.php create mode 100644 src/components/com_weblinks/views/weblink/tmpl/default.php create mode 100644 src/components/com_weblinks/views/weblink/tmpl/default.xml create mode 100644 src/media/com_weblinks/js/admin-weblinks-modal.js create mode 100644 src/media/com_weblinks/js/admin-weblinks-modal.min.js 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)); + } + }) + } + }); +})(); From 99f239c8a5f695367a78737dc13215128caba74c Mon Sep 17 00:00:00 2001 From: Jean-Marie Simonet Date: Tue, 16 May 2017 08:42:34 +0200 Subject: [PATCH 05/27] missing change --- .../com_weblinks/views/weblink/view.html.php | 53 +++++++++++-------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/src/components/com_weblinks/views/weblink/view.html.php b/src/components/com_weblinks/views/weblink/view.html.php index 56a35e2..045e31d 100644 --- a/src/components/com_weblinks/views/weblink/view.html.php +++ b/src/components/com_weblinks/views/weblink/view.html.php @@ -10,44 +10,53 @@ defined('_JEXEC') or die; /** - * HTML View class for the WebLinks component + * HTML Weblink View class for the Weblinks component * - * @since 1.5 + * @since __DEPLOY_VERSION__ */ class WeblinksViewWeblink extends JViewLegacy { - protected $state; - protected $item; + protected $params; + + protected $state; + /** - * Display the view. + * Execute and display a template script. * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * * @return mixed A string if successful, otherwise an Error object. + * + * @since __DEPLOY_VERSION__ */ public function display($tpl = null) { - // Get some data from the models - $item = $this->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); } } From 9b6e02a3840b283d27623b22bec86753d549f336 Mon Sep 17 00:00:00 2001 From: Jean-Marie Simonet Date: Tue, 16 May 2017 17:50:43 +0200 Subject: [PATCH 06/27] adding media in manifest --- src/administrator/components/com_weblinks/weblinks.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/administrator/components/com_weblinks/weblinks.xml b/src/administrator/components/com_weblinks/weblinks.xml index 524d131..bf39e54 100644 --- a/src/administrator/components/com_weblinks/weblinks.xml +++ b/src/administrator/components/com_weblinks/weblinks.xml @@ -33,6 +33,10 @@ + + js + + ##FRONTEND_COMPONENT_FILES## From 75684b9918eb5466a21792fa547218a33d5cb18b Mon Sep 17 00:00:00 2001 From: Jean-Marie Simonet Date: Tue, 16 May 2017 17:55:36 +0200 Subject: [PATCH 07/27] Changing comment --- .../components/com_weblinks/models/weblink.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/administrator/components/com_weblinks/models/weblink.php b/src/administrator/components/com_weblinks/models/weblink.php index fbe6892..d5b5455 100644 --- a/src/administrator/components/com_weblinks/models/weblink.php +++ b/src/administrator/components/com_weblinks/models/weblink.php @@ -27,7 +27,7 @@ class WeblinksModelWeblink extends JModelAdmin * @since 3.2 */ public $typeAlias = 'com_weblinks.weblink'; - + /** * The context used for the associations table * @@ -210,7 +210,7 @@ class WeblinksModelWeblink extends JModelAdmin $registry->loadString($item->images); $item->images = $registry->toArray(); - // Load associated newsfeeds items + // Load associated web links items $app = JFactory::getApplication(); $assoc = JLanguageAssociations::isEnabled(); @@ -325,7 +325,7 @@ class WeblinksModelWeblink extends JModelAdmin // Cast catid to integer for comparison $catid = (int) $data['catid']; - + // Check if New Category exists if ($catid > 0) { From 3151bf9c8f66ca93a37403017fd8a54eb360c355 Mon Sep 17 00:00:00 2001 From: Jean-Marie Simonet Date: Wed, 17 May 2017 09:06:21 +0200 Subject: [PATCH 08/27] Minifying js and adding xtd-editors web link --- .../manifests/packages/pkg_weblinks.xml | 1 + .../com_weblinks/js/admin-weblinks-modal.js | 4 +- .../js/admin-weblinks-modal.min.js | 62 +------------------ .../en-GB/en-GB.plg_editors-xtd_weblink.ini | 8 +++ .../en-GB.plg_editors-xtd_weblink.sys.ini | 7 +++ src/plugins/editors-xtd/weblink/weblink.php | 59 ++++++++++++++++++ src/plugins/editors-xtd/weblink/weblink.xml | 18 ++++++ 7 files changed, 96 insertions(+), 63 deletions(-) create mode 100644 src/plugins/editors-xtd/weblink/language/en-GB/en-GB.plg_editors-xtd_weblink.ini create mode 100644 src/plugins/editors-xtd/weblink/language/en-GB/en-GB.plg_editors-xtd_weblink.sys.ini create mode 100644 src/plugins/editors-xtd/weblink/weblink.php create mode 100644 src/plugins/editors-xtd/weblink/weblink.xml 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/media/com_weblinks/js/admin-weblinks-modal.js b/src/media/com_weblinks/js/admin-weblinks-modal.js index e29bde7..0ba5441 100644 --- a/src/media/com_weblinks/js/admin-weblinks-modal.js +++ b/src/media/com_weblinks/js/admin-weblinks-modal.js @@ -1,5 +1,5 @@ /** - * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved. + * @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ (function() { @@ -49,7 +49,7 @@ var functionName = event.target.getAttribute('data-function'); if (functionName === 'jSelectWeblink') { - // Used in xtd_contacts + // 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 diff --git a/src/media/com_weblinks/js/admin-weblinks-modal.min.js b/src/media/com_weblinks/js/admin-weblinks-modal.min.js index e29bde7..dcc3689 100644 --- a/src/media/com_weblinks/js/admin-weblinks-modal.min.js +++ b/src/media/com_weblinks/js/admin-weblinks-modal.min.js @@ -1,61 +1 @@ -/** - * @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)); - } - }) - } - }); -})(); +!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/plugins/editors-xtd/weblink/language/en-GB/en-GB.plg_editors-xtd_weblink.ini b/src/plugins/editors-xtd/weblink/language/en-GB/en-GB.plg_editors-xtd_weblink.ini new file mode 100644 index 0000000..471be69 --- /dev/null +++ b/src/plugins/editors-xtd/weblink/language/en-GB/en-GB.plg_editors-xtd_weblink.ini @@ -0,0 +1,8 @@ +; Joomla! Project +; Copyright (C) 2005 - 2017 Open Source Matters. All rights reserved. +; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php +; Note : All ini files need to be saved as UTF-8 + +PLG_EDITORS-XTD_WEBLINK="Button - Web Link" +PLG_EDITORS-XTD_WEBLINK_BUTTON_WEBLINK="Web Link" +PLG_EDITORS-XTD_WEBLINK_XML_DESCRIPTION="Displays a button to make it possible to insert web links into an Article. Displays a popup allowing you to choose the web link." diff --git a/src/plugins/editors-xtd/weblink/language/en-GB/en-GB.plg_editors-xtd_weblink.sys.ini b/src/plugins/editors-xtd/weblink/language/en-GB/en-GB.plg_editors-xtd_weblink.sys.ini new file mode 100644 index 0000000..c644667 --- /dev/null +++ b/src/plugins/editors-xtd/weblink/language/en-GB/en-GB.plg_editors-xtd_weblink.sys.ini @@ -0,0 +1,7 @@ +; Joomla! Project +; Copyright (C) 2005 - 2017 Open Source Matters. All rights reserved. +; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php +; Note : All ini files need to be saved as UTF-8 + +PLG_EDITORS-XTD_WEBLINK="Button - Web Link" +PLG_EDITORS-XTD_WEBLINK_XML_DESCRIPTION="Displays a button to make it possible to insert web links into an Article. Displays a popup allowing you to choose the web link." diff --git a/src/plugins/editors-xtd/weblink/weblink.php b/src/plugins/editors-xtd/weblink/weblink.php new file mode 100644 index 0000000..90ea9b4 --- /dev/null +++ b/src/plugins/editors-xtd/weblink/weblink.php @@ -0,0 +1,59 @@ +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## + + From 4f33935200939b2e1e891c002347f8232062f377 Mon Sep 17 00:00:00 2001 From: Jean-Marie Simonet Date: Wed, 17 May 2017 09:08:43 +0200 Subject: [PATCH 09/27] correcting date --- src/media/com_weblinks/js/admin-weblinks-modal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/media/com_weblinks/js/admin-weblinks-modal.js b/src/media/com_weblinks/js/admin-weblinks-modal.js index 0ba5441..35f7133 100644 --- a/src/media/com_weblinks/js/admin-weblinks-modal.js +++ b/src/media/com_weblinks/js/admin-weblinks-modal.js @@ -1,5 +1,5 @@ /** - * @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved. + * @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() { From db0bfa95b9609ac07ae78feef5349277c7ae1058 Mon Sep 17 00:00:00 2001 From: Jean-Marie Simonet Date: Sat, 20 May 2017 08:28:21 +0200 Subject: [PATCH 10/27] small corrections --- src/administrator/language/en-GB/en-GB.com_weblinks.ini | 4 ++-- src/plugins/editors-xtd/weblink/weblink.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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 63195ff..2862b4a 100644 --- a/src/administrator/language/en-GB/en-GB.com_weblinks.ini +++ b/src/administrator/language/en-GB/en-GB.com_weblinks.ini @@ -9,7 +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_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." @@ -118,7 +118,7 @@ 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_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" diff --git a/src/plugins/editors-xtd/weblink/weblink.php b/src/plugins/editors-xtd/weblink/weblink.php index 90ea9b4..235a531 100644 --- a/src/plugins/editors-xtd/weblink/weblink.php +++ b/src/plugins/editors-xtd/weblink/weblink.php @@ -10,7 +10,7 @@ defined('_JEXEC') or die; /** - * Editor WEb Link button + * Editor Web Link button * * @since __DEPLOY_VERSION__ */ From 9b30cedb4db9b3160263f9eee73e78aab91bad6a Mon Sep 17 00:00:00 2001 From: zero-24 Date: Sun, 21 May 2017 18:59:44 +0200 Subject: [PATCH 11/27] fix some smal things --- .../com_weblinks/helpers/html/weblink.php | 9 ++++++--- .../com_weblinks/models/forms/filter_weblinks.xml | 14 ++------------ .../components/com_weblinks/models/weblink.php | 5 ++--- .../components/com_weblinks/models/weblinks.php | 1 + .../com_weblinks/views/weblink/tmpl/edit.php | 2 +- .../com_weblinks/views/weblinks/tmpl/default.php | 14 +++++++------- .../com_weblinks/views/weblinks/tmpl/modal.php | 6 ++++++ src/plugins/editors-xtd/weblink/weblink.php | 2 +- 8 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/administrator/components/com_weblinks/helpers/html/weblink.php b/src/administrator/components/com_weblinks/helpers/html/weblink.php index 4a7a18d..7299f2a 100644 --- a/src/administrator/components/com_weblinks/helpers/html/weblink.php +++ b/src/administrator/components/com_weblinks/helpers/html/weblink.php @@ -16,7 +16,7 @@ JLoader::register('WeblinksHelper', JPATH_ADMINISTRATOR . '/components/com_webli /** * Weblink HTML helper class. * - * @since 1.6 + * @since __DELPOY_VERSION__ */ abstract class JHtmlWeblink { @@ -28,14 +28,17 @@ abstract class JHtmlWeblink * @return string The language HTML * * @throws Exception + * + * @since __DELPOY_VERSION__ */ public static function association($weblinkid) { // Defaults $html = ''; + $associations = JLanguageAssociations::getAssociations('com_weblinks', '#__weblinks', 'com_weblinks.item', $weblinkid); // Get the associations - if ($associations = JLanguageAssociations::getAssociations('com_weblinks', '#__weblinks', 'com_weblinks.item', $weblinkid)) + if ($associations) { foreach ($associations as $tag => $associated) { @@ -70,7 +73,7 @@ abstract class JHtmlWeblink foreach ($items as &$item) { $text = strtoupper($item->lang_sef); - $url = JRoute::_('index.php?option=com_weblinks&task=weblink.edit&id=' . (int) $item->id); + $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; 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 3746583..3862039 100644 --- a/src/administrator/components/com_weblinks/models/forms/filter_weblinks.xml +++ b/src/administrator/components/com_weblinks/models/forms/filter_weblinks.xml @@ -90,18 +90,8 @@ - - + + diff --git a/src/administrator/components/com_weblinks/models/weblink.php b/src/administrator/components/com_weblinks/models/weblink.php index d5b5455..cb238fb 100644 --- a/src/administrator/components/com_weblinks/models/weblink.php +++ b/src/administrator/components/com_weblinks/models/weblink.php @@ -31,8 +31,8 @@ class WeblinksModelWeblink extends JModelAdmin /** * The context used for the associations table * - * @var string - * @since 3.4.4 + * @var string + * @since __DEPLOY_VERSION__ */ protected $associationsContext = 'com_weblinks.item'; @@ -211,7 +211,6 @@ class WeblinksModelWeblink extends JModelAdmin $item->images = $registry->toArray(); // Load associated web links items - $app = JFactory::getApplication(); $assoc = JLanguageAssociations::isEnabled(); if ($assoc) diff --git a/src/administrator/components/com_weblinks/models/weblinks.php b/src/administrator/components/com_weblinks/models/weblinks.php index 808d919..9e5b4c5 100644 --- a/src/administrator/components/com_weblinks/models/weblinks.php +++ b/src/administrator/components/com_weblinks/models/weblinks.php @@ -54,6 +54,7 @@ class WeblinksModelWeblinks extends JModelList ); $assoc = JLanguageAssociations::isEnabled(); + if ($assoc) { $config['filter_fields'][] = 'association'; 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 7765b32..998ad90 100644 --- a/src/administrator/components/com_weblinks/views/weblink/tmpl/edit.php +++ b/src/administrator/components/com_weblinks/views/weblink/tmpl/edit.php @@ -84,7 +84,7 @@ $tmpl = $isModal || $input->get('tmpl', '', 'cmd') === 'component' ? '&tmpl=c - + loadTemplate('associations'); ?> 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 75fee92..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,13 +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'; -$assoc = JLanguageAssociations::isEnabled(); +$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) { diff --git a/src/administrator/components/com_weblinks/views/weblinks/tmpl/modal.php b/src/administrator/components/com_weblinks/views/weblinks/tmpl/modal.php index 34893af..56d1190 100644 --- a/src/administrator/components/com_weblinks/views/weblinks/tmpl/modal.php +++ b/src/administrator/components/com_weblinks/views/weblinks/tmpl/modal.php @@ -7,7 +7,9 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; + $app = JFactory::getApplication(); + if ($app->isClient('site')) { JSession::checkToken('get') or die(JText::_('JINVALID_TOKEN')); @@ -26,23 +28,27 @@ 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/plugins/editors-xtd/weblink/weblink.php b/src/plugins/editors-xtd/weblink/weblink.php index 235a531..67b6291 100644 --- a/src/plugins/editors-xtd/weblink/weblink.php +++ b/src/plugins/editors-xtd/weblink/weblink.php @@ -35,7 +35,7 @@ class PlgButtonWeblink extends JPlugin */ public function onDisplay($name) { - $user = JFactory::getUser(); + $user = JFactory::getUser(); if ($user->authorise('core.create', 'com_weblinks') || $user->authorise('core.edit', 'com_weblinks') From b6e084a8288b5a540585911a027919bbf09bfaa9 Mon Sep 17 00:00:00 2001 From: infograf768 Date: Mon, 22 May 2017 12:04:38 +0200 Subject: [PATCH 12/27] deploy --- .../components/com_weblinks/helpers/html/weblink.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/administrator/components/com_weblinks/helpers/html/weblink.php b/src/administrator/components/com_weblinks/helpers/html/weblink.php index 7299f2a..b976745 100644 --- a/src/administrator/components/com_weblinks/helpers/html/weblink.php +++ b/src/administrator/components/com_weblinks/helpers/html/weblink.php @@ -29,7 +29,7 @@ abstract class JHtmlWeblink * * @throws Exception * - * @since __DELPOY_VERSION__ + * @since ___DEPLOY_VERSION__ */ public static function association($weblinkid) { From 7e9269d993e3dd20d3d328cf7bd2dfe774d7c350 Mon Sep 17 00:00:00 2001 From: zero-24 Date: Mon, 22 May 2017 14:13:49 +0200 Subject: [PATCH 13/27] Update weblink.php --- .../components/com_weblinks/models/fields/modal/weblink.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/administrator/components/com_weblinks/models/fields/modal/weblink.php b/src/administrator/components/com_weblinks/models/fields/modal/weblink.php index f3d5397..1a94c60 100644 --- a/src/administrator/components/com_weblinks/models/fields/modal/weblink.php +++ b/src/administrator/components/com_weblinks/models/fields/modal/weblink.php @@ -21,6 +21,7 @@ class JFormFieldModal_Weblink extends JFormField * @since __DEPLOY_VERSION__ */ protected $type = 'Modal_Weblink'; + /** * Method to get the field input markup. * From 58fa74a1a29e9509d1043959f8ea5a34b6d2e7a3 Mon Sep 17 00:00:00 2001 From: zero-24 Date: Mon, 22 May 2017 14:14:50 +0200 Subject: [PATCH 14/27] Update modal.php --- .../components/com_weblinks/views/weblinks/tmpl/modal.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/administrator/components/com_weblinks/views/weblinks/tmpl/modal.php b/src/administrator/components/com_weblinks/views/weblinks/tmpl/modal.php index 56d1190..aa5527b 100644 --- a/src/administrator/components/com_weblinks/views/weblinks/tmpl/modal.php +++ b/src/administrator/components/com_weblinks/views/weblinks/tmpl/modal.php @@ -1,7 +1,7 @@ Date: Sat, 10 Jun 2017 08:33:20 +0200 Subject: [PATCH 15/27] Correcting weblink frontend model to adapt to the new display --- .../com_weblinks/models/weblink.php | 137 ++++++++++++++---- 1 file changed, 107 insertions(+), 30 deletions(-) diff --git a/src/components/com_weblinks/models/weblink.php b/src/components/com_weblinks/models/weblink.php index c1e8a45..688e303 100644 --- a/src/components/com_weblinks/models/weblink.php +++ b/src/components/com_weblinks/models/weblink.php @@ -10,6 +10,7 @@ defined('_JEXEC') or die; use Joomla\Utilities\ArrayHelper; +use Joomla\Registry\Registry; JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . '/tables'); @@ -38,15 +39,25 @@ class WeblinksModelWeblink extends JModelItem */ protected function populateState() { - $app = JFactory::getApplication(); - $params = $app->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); } } From 2ebe811b6046052f32d2f90e6239032da151dcf8 Mon Sep 17 00:00:00 2001 From: Brian Teeman Date: Thu, 31 Aug 2017 18:56:12 +0100 Subject: [PATCH 16/27] xml code-style (#363) * xml code-style * fixes * oops --- .../com_weblinks/models/forms/weblink.xml | 38 +- .../com_weblinks/models/forms/weblink.xml | 26 +- .../views/categories/tmpl/default.xml | 419 ++++++++++-------- .../views/category/tmpl/default.xml | 206 +++++---- src/modules/mod_weblinks/mod_weblinks.xml | 69 +-- src/plugins/search/weblinks/weblinks.xml | 14 +- 6 files changed, 422 insertions(+), 350 deletions(-) diff --git a/src/administrator/components/com_weblinks/models/forms/weblink.xml b/src/administrator/components/com_weblinks/models/forms/weblink.xml index 9acd378..b80840a 100644 --- a/src/administrator/components/com_weblinks/models/forms/weblink.xml +++ b/src/administrator/components/com_weblinks/models/forms/weblink.xml @@ -6,38 +6,38 @@ @@ -45,31 +45,31 @@ @@ -160,9 +160,9 @@ @@ -259,9 +259,9 @@ @@ -273,25 +273,25 @@ diff --git a/src/components/com_weblinks/models/forms/weblink.xml b/src/components/com_weblinks/models/forms/weblink.xml index 4145369..34478a3 100644 --- a/src/components/com_weblinks/models/forms/weblink.xml +++ b/src/components/com_weblinks/models/forms/weblink.xml @@ -22,8 +22,8 @@ @@ -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 @@
- @@ -25,136 +27,162 @@ -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -163,77 +191,90 @@
- - - - - + - - - - - - - - - - - - - - - - - + > + - - - - - - + + + - - - + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/components/com_weblinks/views/category/tmpl/default.xml b/src/components/com_weblinks/views/category/tmpl/default.xml index d54ab0b..e883551 100644 --- a/src/components/com_weblinks/views/category/tmpl/default.xml +++ b/src/components/com_weblinks/views/category/tmpl/default.xml @@ -13,55 +13,68 @@
-
- -
- +
+ - + > - + > - + > - + > @@ -72,124 +85,141 @@ - + > - - - - + > + + + - - - - + > + + + -
+
-
- + + > - + > - + > - - - - + > + + + - + + + - description="COM_WEBLINKS_FIELD_CONFIG_HITS_DESC" - label="JGLOBAL_HITS" - useglobal="true" - > - - - - - - + > - - - - -
- -
- - + > -
-
+ +
+ + + + + +
+
diff --git a/src/modules/mod_weblinks/mod_weblinks.xml b/src/modules/mod_weblinks/mod_weblinks.xml index c096e13..65b9398 100644 --- a/src/modules/mod_weblinks/mod_weblinks.xml +++ b/src/modules/mod_weblinks/mod_weblinks.xml @@ -22,20 +22,20 @@ + class="btn-group btn-group-yesno" + default="0" + > @@ -43,12 +43,12 @@ + > @@ -56,11 +56,11 @@ + > @@ -68,11 +68,11 @@ + > @@ -80,10 +80,10 @@ + default="3" + > @@ -94,18 +94,18 @@ + default="title" + > @@ -114,10 +114,10 @@ + default="asc" + > @@ -125,10 +125,10 @@ + default="0" + > @@ -136,11 +136,11 @@ + class="btn-group btn-group-yesno" + default="0" + > @@ -148,11 +148,11 @@ + class="btn-group btn-group-yesno" + default="0" + > @@ -160,16 +160,17 @@ + class="chzn-color" + default="0" + >
+
+ default="1" + > @@ -200,9 +201,9 @@ + > @@ -42,11 +42,11 @@ + > From 1ad63abd543f10df5f582f16f8a7d58d659ba633 Mon Sep 17 00:00:00 2001 From: zero-24 Date: Fri, 1 Sep 2017 01:28:39 +0200 Subject: [PATCH 17/27] thanks @quy --- src/components/com_weblinks/views/category/tmpl/default.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/com_weblinks/views/category/tmpl/default.xml b/src/components/com_weblinks/views/category/tmpl/default.xml index e883551..4014c51 100644 --- a/src/components/com_weblinks/views/category/tmpl/default.xml +++ b/src/components/com_weblinks/views/category/tmpl/default.xml @@ -12,7 +12,6 @@
- Date: Fri, 1 Sep 2017 01:29:16 +0200 Subject: [PATCH 18/27] thanks @quy --- src/components/com_weblinks/views/category/tmpl/default.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/com_weblinks/views/category/tmpl/default.xml b/src/components/com_weblinks/views/category/tmpl/default.xml index 4014c51..36c68f1 100644 --- a/src/components/com_weblinks/views/category/tmpl/default.xml +++ b/src/components/com_weblinks/views/category/tmpl/default.xml @@ -208,7 +208,6 @@
- Date: Fri, 1 Sep 2017 01:29:47 +0200 Subject: [PATCH 19/27] thanks @quy --- src/modules/mod_weblinks/mod_weblinks.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/mod_weblinks/mod_weblinks.xml b/src/modules/mod_weblinks/mod_weblinks.xml index 65b9398..028bcb5 100644 --- a/src/modules/mod_weblinks/mod_weblinks.xml +++ b/src/modules/mod_weblinks/mod_weblinks.xml @@ -85,7 +85,7 @@ default="3" > - + From e8a9d563afa331e4975832959b0f19826a66b793 Mon Sep 17 00:00:00 2001 From: zero-24 Date: Fri, 1 Sep 2017 01:30:47 +0200 Subject: [PATCH 20/27] thanks @quy --- src/plugins/search/weblinks/weblinks.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/search/weblinks/weblinks.xml b/src/plugins/search/weblinks/weblinks.xml index 0ae5306..47a3cc7 100644 --- a/src/plugins/search/weblinks/weblinks.xml +++ b/src/plugins/search/weblinks/weblinks.xml @@ -21,8 +21,8 @@ From e69347e2558f3887ad177ee8a60af304592e6757 Mon Sep 17 00:00:00 2001 From: Astrid Date: Sat, 16 Sep 2017 18:36:25 +0200 Subject: [PATCH 21/27] Update config.xml deleted merge conflict hints. --- src/administrator/components/com_weblinks/config.xml | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/administrator/components/com_weblinks/config.xml b/src/administrator/components/com_weblinks/config.xml index e1172ca..6452858 100644 --- a/src/administrator/components/com_weblinks/config.xml +++ b/src/administrator/components/com_weblinks/config.xml @@ -411,7 +411,6 @@ -<<<<<<< HEAD JYES -======= ->>>>>>> e8a9d563afa331e4975832959b0f19826a66b793
Date: Sun, 22 Oct 2017 12:18:58 +0200 Subject: [PATCH 22/27] Delete jed_update.xml --- jed_update.xml | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 jed_update.xml diff --git a/jed_update.xml b/jed_update.xml deleted file mode 100644 index 90d7bee..0000000 --- a/jed_update.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - The Web Links Manager allows you to add, edit and remove links to other web sites on your Joomla! web site, and organize them into categories. You can then display these links on your site, and optionally let visitors add new links. - - https://github.com/joomla-extensions/weblinks - https://github.com/joomla-extensions/weblinks/releases - https://docs.joomla.org/Help33:Components_Weblinks_Links - https://forum.joomla.org/ - http://opensourcematters.org/legal/license-copyright/gnu-general-public-license-v2.html - 3.6.0 - - 36 - 37 - - From c9d4f57cea4f6f10791d479271d906804ad008de Mon Sep 17 00:00:00 2001 From: Astrid Date: Mon, 6 Nov 2017 12:52:05 +0100 Subject: [PATCH 23/27] mapping of new media files was not correct (#372) --- src/administrator/components/com_weblinks/weblinks.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/administrator/components/com_weblinks/weblinks.xml b/src/administrator/components/com_weblinks/weblinks.xml index bf39e54..dec3e4c 100644 --- a/src/administrator/components/com_weblinks/weblinks.xml +++ b/src/administrator/components/com_weblinks/weblinks.xml @@ -33,8 +33,8 @@ - - js + + ##MEDIA_FILES## From 9bc1752ca57abf8714c1b4977552c0c112af87f3 Mon Sep 17 00:00:00 2001 From: Astrid Date: Mon, 6 Nov 2017 12:52:45 +0100 Subject: [PATCH 24/27] First imageignores image float setting366 (#378) * usethesameclassforfloatingtheimageslikecomcontent * addchangetosecondimage --- .../com_weblinks/views/category/tmpl/default_items.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/com_weblinks/views/category/tmpl/default_items.php b/src/components/com_weblinks/views/category/tmpl/default_items.php index 55099ee..c49b298 100644 --- a/src/components/com_weblinks/views/category/tmpl/default_items.php +++ b/src/components/com_weblinks/views/category/tmpl/default_items.php @@ -135,7 +135,7 @@ $listDirn = $this->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) . '"'; ?> From ffc012d56ad39378ca9a23f9f781a45f9c4c72c3 Mon Sep 17 00:00:00 2001 From: Astrid Date: Mon, 6 Nov 2017 12:54:06 +0100 Subject: [PATCH 25/27] changedlanguagestringssothatimagefloatismoreconcrete (#376) --- .../components/com_weblinks/config.xml | 27 ++++++++++++++++--- .../com_weblinks/models/forms/weblink.xml | 8 +++--- .../language/en-GB/en-GB.com_weblinks.ini | 6 +++-- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/src/administrator/components/com_weblinks/config.xml b/src/administrator/components/com_weblinks/config.xml index 6452858..53c689e 100644 --- a/src/administrator/components/com_weblinks/config.xml +++ b/src/administrator/components/com_weblinks/config.xml @@ -50,6 +50,7 @@ label="JGLOBAL_HISTORY_LIMIT_OPTIONS_LABEL" description="JGLOBAL_HISTORY_LIMIT_OPTIONS_DESC" default="5" + showon="save_history:1" /> JNO + + + + @@ -98,14 +111,20 @@ + + @@ -358,8 +358,8 @@ 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 571f7ee..5c0d9ae 100644 --- a/src/administrator/language/en-GB/en-GB.com_weblinks.ini +++ b/src/administrator/language/en-GB/en-GB.com_weblinks.ini @@ -85,8 +85,10 @@ 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" From 08e6da7006a1d53fee07a614e8a1253935020b7d Mon Sep 17 00:00:00 2001 From: Astrid Date: Mon, 6 Nov 2017 12:55:24 +0100 Subject: [PATCH 26/27] addJoroboMapTaskToRoboFile (#374) --- RoboFile.php | 14 ++++++++++++++ src/modules/mod_weblinks/mod_weblinks.xml | 1 + 2 files changed, 15 insertions(+) diff --git a/RoboFile.php b/RoboFile.php index 0bd8c45..b6249ba 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -693,4 +693,18 @@ class RoboFile extends \Robo\Tasks { (new \Joomla\Jorobo\Tasks\BumpVersion())->run(); } + + /** + * Map into Joomla installation. + * + * @param String $target The target joomla instance + * + * @since __DEPLOY_VERSION__ + * + * @return void + */ + public function map($target) + { + (new \Joomla\Jorobo\Tasks\Map($target))->run(); + } } diff --git a/src/modules/mod_weblinks/mod_weblinks.xml b/src/modules/mod_weblinks/mod_weblinks.xml index 028bcb5..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## From 84df5980155320a76a2771a5fe327d06d50bc107 Mon Sep 17 00:00:00 2001 From: Astrid Date: Mon, 6 Nov 2017 12:56:26 +0100 Subject: [PATCH 27/27] makeSameAliasPossibleForDifferentLanguages (#373) --- src/administrator/components/com_weblinks/tables/weblink.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/administrator/components/com_weblinks/tables/weblink.php b/src/administrator/components/com_weblinks/tables/weblink.php index ce9b6e1..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);