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

Merge pull request #349 from infograf768/weblinks_assoc

Implementing full associations for single weblink
This commit is contained in:
Astrid 2017-11-03 21:46:26 +01:00 committed by GitHub
commit d0ff882375
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
52 changed files with 1232 additions and 124 deletions

View File

@ -36,7 +36,7 @@ class WeblinksAssociationsHelper extends JAssociationExtensionHelper
* *
* @since __DEPLOY_VERSION__ * @since __DEPLOY_VERSION__
*/ */
protected $itemTypes = array('category'); protected $itemTypes = array('weblink', 'category');
/** /**
* Has the extension association support * Has the extension association support
@ -105,6 +105,10 @@ class WeblinksAssociationsHelper extends JAssociationExtensionHelper
switch ($typeName) switch ($typeName)
{ {
case 'weblink':
$table = JTable::getInstance('Weblink', 'WeblinksTable');
break;
case 'category': case 'category':
$table = JTable::getInstance('Category'); $table = JTable::getInstance('Category');
break; break;
@ -141,6 +145,21 @@ class WeblinksAssociationsHelper extends JAssociationExtensionHelper
{ {
switch ($typeName) 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': case 'category':
$fields['created_user_id'] = 'a.created_user_id'; $fields['created_user_id'] = 'a.created_user_id';
$fields['ordering'] = 'a.lft'; $fields['ordering'] = 'a.lft';

View File

@ -0,0 +1,94 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
JLoader::register('WeblinksHelper', JPATH_ADMINISTRATOR . '/components/com_weblinks/helpers/weblinks.php');
/**
* Weblink HTML helper class.
*
* @since __DELPOY_VERSION__
*/
abstract class JHtmlWeblink
{
/**
* Get the associated language flags
*
* @param integer $weblinkid The item id to search associations
*
* @return string The language HTML
*
* @throws Exception
*
* @since ___DEPLOY_VERSION__
*/
public static function association($weblinkid)
{
// Defaults
$html = '';
$associations = JLanguageAssociations::getAssociations('com_weblinks', '#__weblinks', 'com_weblinks.item', $weblinkid);
// Get the associations
if ($associations)
{
foreach ($associations as $tag => $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') . '<br />' . JText::sprintf('JCATEGORY_SPRINTF', $item->category_title);
$classes = 'hasPopover label label-association label-' . $item->lang_sef;
$item->link = '<a href="' . $url . '" title="' . $item->language_title . '" class="' . $classes
. '" data-content="' . $tooltip . '" data-placement="top">'
. $text . '</a>';
}
}
JHtml::_('bootstrap.popover');
$html = JLayoutHelper::render('joomla.content.associations', $items);
}
return $html;
}
}

View File

@ -0,0 +1,257 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_BASE') or die;
/**
* Supports a modal weblink picker.
*
* @since __DEPLOY_VERSION__
*/
class JFormFieldModal_Weblink extends JFormField
{
/**
* The form field type.
*
* @var string
* @since __DEPLOY_VERSION__
*/
protected $type = 'Modal_Weblink';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since __DEPLOY_VERSION__
*/
protected function getInput()
{
$allowNew = ((string) $this->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&amp;view=weblinks&amp;layout=modal&amp;tmpl=component&amp;' . JSession::getFormToken() . '=1';
$linkWeblink = 'index.php?option=com_weblinks&amp;view=weblink&amp;layout=modal&amp;tmpl=component&amp;' . JSession::getFormToken() . '=1';
$modalTitle = JText::_('COM_WEBLINKS_CHANGE_WEBLINK');
if (isset($this->element['language']))
{
$linkWeblinks .= '&amp;forcedLanguage=' . $this->element['language'];
$linkWeblink .= '&amp;forcedLanguage=' . $this->element['language'];
$modalTitle .= ' &#8212; ' . $this->element['label'];
}
$urlSelect = $linkWeblinks . '&amp;function=jSelectWeblink_' . $this->id;
$urlEdit = $linkWeblink . '&amp;task=weblink.edit&amp;id=\' + document.getElementById("' . $this->id . '_id").value + \'';
$urlNew = $linkWeblink . '&amp;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 = '<span class="input-append">';
$html .= '<input class="input-medium" id="' . $this->id . '_name" type="text" value="' . $title . '" disabled="disabled" size="35" />';
// Select weblink button
if ($allowSelect)
{
$html .= '<a'
. ' class="btn hasTooltip' . ($value ? ' hidden' : '') . '"'
. ' id="' . $this->id . '_select"'
. ' data-toggle="modal"'
. ' role="button"'
. ' href="#ModalSelect' . $modalId . '"'
. ' title="' . JHtml::tooltipText('COM_WEBLINKS_CHANGE_WEBLINK') . '">'
. '<span class="icon-file" aria-hidden="true"></span> ' . JText::_('JSELECT')
. '</a>';
}
// New weblink button
if ($allowNew)
{
$html .= '<a'
. ' class="btn hasTooltip' . ($value ? ' hidden' : '') . '"'
. ' id="' . $this->id . '_new"'
. ' data-toggle="modal"'
. ' role="button"'
. ' href="#ModalNew' . $modalId . '"'
. ' title="' . JHtml::tooltipText('COM_WEBLINKS_NEW_WEBLINK') . '">'
. '<span class="icon-new" aria-hidden="true"></span> ' . JText::_('JACTION_CREATE')
. '</a>';
}
// Edit weblink button
if ($allowEdit)
{
$html .= '<a'
. ' class="btn hasTooltip' . ($value ? '' : ' hidden') . '"'
. ' id="' . $this->id . '_edit"'
. ' data-toggle="modal"'
. ' role="button"'
. ' href="#ModalEdit' . $modalId . '"'
. ' title="' . JHtml::tooltipText('COM_WEBLINKS_EDIT_WEBLINK') . '">'
. '<span class="icon-edit" aria-hidden="true"></span> ' . JText::_('JACTION_EDIT')
. '</a>';
}
// Clear weblink button
if ($allowClear)
{
$html .= '<a'
. ' class="btn' . ($value ? '' : ' hidden') . '"'
. ' id="' . $this->id . '_clear"'
. ' href="#"'
. ' onclick="window.processModalParent(\'' . $this->id . '\'); return false;">'
. '<span class="icon-remove" aria-hidden="true"></span>' . JText::_('JCLEAR')
. '</a>';
}
$html .= '</span>';
// 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' => '<a role="button" class="btn" data-dismiss="modal" aria-hidden="true">' . JText::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</a>',
)
);
}
// 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' => '<a role="button" class="btn" aria-hidden="true"'
. ' onclick="window.processModalEdit(this, \'' . $this->id . '\', \'add\', \'weblink\', \'cancel\', \'weblink-form\'); return false;">'
. JText::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</a>'
. '<a role="button" class="btn btn-primary" aria-hidden="true"'
. ' onclick="window.processModalEdit(this, \'' . $this->id . '\', \'add\', \'weblink\', \'save\', \'weblink-form\'); return false;">'
. JText::_('JSAVE') . '</a>'
. '<a role="button" class="btn btn-success" aria-hidden="true"'
. ' onclick="window.processModalEdit(this, \'' . $this->id . '\', \'add\', \'weblink\', \'apply\', \'weblink-form\'); return false;">'
. JText::_('JAPPLY') . '</a>',
)
);
}
// 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' => '<a role="button" class="btn" aria-hidden="true"'
. ' onclick="window.processModalEdit(this, \'' . $this->id . '\', \'edit\', \'weblink\', \'cancel\', \'weblink-form\'); return false;">'
. JText::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</a>'
. '<a role="button" class="btn btn-primary" aria-hidden="true"'
. ' onclick="window.processModalEdit(this, \'' . $this->id . '\', \'edit\', \'weblink\', \'save\', \'weblink-form\'); return false;">'
. JText::_('JSAVE') . '</a>'
. '<a role="button" class="btn btn-success" aria-hidden="true"'
. ' onclick="window.processModalEdit(this, \'' . $this->id . '\', \'edit\', \'weblink\', \'apply\', \'weblink-form\'); return false;">'
. JText::_('JAPPLY') . '</a>',
)
);
}
// Note: class='required' for client side validation.
$class = $this->required ? ' class="required modal-value"' : '';
$html .= '<input type="hidden" id="' . $this->id . '_id" ' . $class . ' data-required="' . (int) $this->required . '" name="' . $this->name
. '" data-text="' . htmlspecialchars(JText::_('COM_WEBLINKS_SELECT_A_WEBLINK', true), ENT_COMPAT, 'UTF-8') . '" value="' . $value . '" />';
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());
}
}

View File

@ -8,7 +8,6 @@
description="COM_WEBLINKS_FILTER_SEARCH_DESC" description="COM_WEBLINKS_FILTER_SEARCH_DESC"
hint="JSEARCH_FILTER" hint="JSEARCH_FILTER"
/> />
<field <field
name="published" name="published"
type="status" type="status"
@ -18,7 +17,6 @@
> >
<option value="">JOPTION_SELECT_PUBLISHED</option> <option value="">JOPTION_SELECT_PUBLISHED</option>
</field> </field>
<field <field
name="category_id" name="category_id"
type="category" type="category"
@ -29,7 +27,6 @@
> >
<option value="">JOPTION_SELECT_CATEGORY</option> <option value="">JOPTION_SELECT_CATEGORY</option>
</field> </field>
<field <field
name="access" name="access"
type="accesslevel" type="accesslevel"
@ -39,7 +36,6 @@
> >
<option value="">JOPTION_SELECT_ACCESS</option> <option value="">JOPTION_SELECT_ACCESS</option>
</field> </field>
<field <field
name="language" name="language"
type="contentlanguage" type="contentlanguage"
@ -50,7 +46,6 @@
<option value="">JOPTION_SELECT_LANGUAGE</option> <option value="">JOPTION_SELECT_LANGUAGE</option>
<option value="*">JALL</option> <option value="*">JALL</option>
</field> </field>
<field <field
name="tag" name="tag"
type="tag" type="tag"
@ -61,7 +56,6 @@
> >
<option value="">JOPTION_SELECT_TAG</option> <option value="">JOPTION_SELECT_TAG</option>
</field> </field>
<field <field
name="level" name="level"
type="integer" type="integer"
@ -76,7 +70,6 @@
<option value="">JOPTION_SELECT_MAX_LEVELS</option> <option value="">JOPTION_SELECT_MAX_LEVELS</option>
</field> </field>
</fields> </fields>
<fields name="list"> <fields name="list">
<field <field
name="fullordering" name="fullordering"
@ -97,12 +90,13 @@
<option value="access_level DESC">JGRID_HEADING_ACCESS_DESC</option> <option value="access_level DESC">JGRID_HEADING_ACCESS_DESC</option>
<option value="a.hits ASC">JGLOBAL_HITS_ASC</option> <option value="a.hits ASC">JGLOBAL_HITS_ASC</option>
<option value="a.hits DESC">JGLOBAL_HITS_DESC</option> <option value="a.hits DESC">JGLOBAL_HITS_DESC</option>
<option value="association ASC" requires="associations">JASSOCIATIONS_ASC</option>
<option value="association DESC" requires="associations">JASSOCIATIONS_DESC</option>
<option value="language_title ASC">JGRID_HEADING_LANGUAGE_ASC</option> <option value="language_title ASC">JGRID_HEADING_LANGUAGE_ASC</option>
<option value="language_title DESC">JGRID_HEADING_LANGUAGE_DESC</option> <option value="language_title DESC">JGRID_HEADING_LANGUAGE_DESC</option>
<option value="a.id ASC">JGRID_HEADING_ID_ASC</option> <option value="a.id ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id DESC">JGRID_HEADING_ID_DESC</option> <option value="a.id DESC">JGRID_HEADING_ID_DESC</option>
</field> </field>
<field <field
name="limit" name="limit"
type="limitbox" type="limitbox"

View File

@ -11,6 +11,8 @@ defined('_JEXEC') or die;
use Joomla\Registry\Registry; use Joomla\Registry\Registry;
JLoader::register('WeblinksHelper', JPATH_ADMINISTRATOR . '/components/com_weblinks/helpers/weblinks.php');
/** /**
* Weblinks model. * Weblinks model.
* *
@ -26,6 +28,14 @@ class WeblinksModelWeblink extends JModelAdmin
*/ */
public $typeAlias = 'com_weblinks.weblink'; public $typeAlias = 'com_weblinks.weblink';
/**
* The context used for the associations table
*
* @var string
* @since __DEPLOY_VERSION__
*/
protected $associationsContext = 'com_weblinks.item';
/** /**
* The prefix to use with controller messages. * The prefix to use with controller messages.
* *
@ -200,6 +210,24 @@ class WeblinksModelWeblink extends JModelAdmin
$registry->loadString($item->images); $registry->loadString($item->images);
$item->images = $registry->toArray(); $item->images = $registry->toArray();
// Load associated web links items
$assoc = JLanguageAssociations::isEnabled();
if ($assoc)
{
$item->associations = array();
if ($item->id != null)
{
$associations = JLanguageAssociations::getAssociations('com_weblinks', '#__weblinks', 'com_weblinks.item', $item->id);
foreach ($associations as $tag => $association)
{
$item->associations[$tag] = $association->id;
}
}
}
if (!empty($item->id)) if (!empty($item->id))
{ {
$item->tags = new JHelperTags; $item->tags = new JHelperTags;
@ -296,7 +324,7 @@ class WeblinksModelWeblink extends JModelAdmin
// Cast catid to integer for comparison // Cast catid to integer for comparison
$catid = (int) $data['catid']; $catid = (int) $data['catid'];
// Check if New Category exists // Check if New Category exists
if ($catid > 0) if ($catid > 0)
{ {
@ -376,6 +404,37 @@ class WeblinksModelWeblink extends JModelAdmin
$form->setFieldAttribute('catid', 'allowAdd', 'true'); $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('<form />');
$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); parent::preprocessForm($form, $data, $group);
} }

View File

@ -52,6 +52,13 @@ class WeblinksModelWeblinks extends JModelList
'tag', 'tag',
'level', 'c.level', 'level', 'c.level',
); );
$assoc = JLanguageAssociations::isEnabled();
if ($assoc)
{
$config['filter_fields'][] = 'association';
}
} }
parent::__construct($config); parent::__construct($config);
@ -70,6 +77,22 @@ class WeblinksModelWeblinks extends JModelList
*/ */
protected function populateState($ordering = 'a.title', $direction = 'asc') 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. // Load the filter state.
$this->setState('filter.search', $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', '', 'string')); $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')); $this->setState('filter.access', $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', '', 'cmd'));
@ -83,6 +106,12 @@ class WeblinksModelWeblinks extends JModelList
$params = JComponentHelper::getParams('com_weblinks'); $params = JComponentHelper::getParams('com_weblinks');
$this->setState('params', $params); $this->setState('params', $params);
// Force a language.
if (!empty($forcedLanguage))
{
$this->setState('filter.language', $forcedLanguage);
}
// List state information. // List state information.
parent::populateState($ordering, $direction); parent::populateState($ordering, $direction);
} }
@ -132,7 +161,7 @@ class WeblinksModelWeblinks extends JModelList
$query->select( $query->select(
$this->getState( $this->getState(
'list.select', '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' 'a.hits, a.state, a.access, a.ordering, a.language, a.publish_up, a.publish_down'
) )
); );
@ -155,6 +184,17 @@ class WeblinksModelWeblinks extends JModelList
$query->select('c.title AS category_title') $query->select('c.title AS category_title')
->join('LEFT', $db->quoteName('#__categories', 'c') . ' ON ' . $db->qn('c.id') . ' = ' . $db->qn('a.catid')); ->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. // Filter by access level.
if ($access = $this->getState('filter.access')) if ($access = $this->getState('filter.access'))
{ {

View File

@ -153,7 +153,7 @@ class WeblinksTableWeblink extends JTable
$this->alias = $this->title; $this->alias = $this->title;
} }
$this->alias = JApplicationHelper::stringURLSafe($this->alias); $this->alias = JApplicationHelper::stringURLSafe($this->alias, $this->language);
if (trim(str_replace('-', '', $this->alias)) == '') if (trim(str_replace('-', '', $this->alias)) == '')
{ {

View File

@ -14,8 +14,13 @@ JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
JHtml::_('behavior.formvalidator'); JHtml::_('behavior.formvalidator');
JHtml::_('formbehavior.chosen', 'select', null, array('disable_search_threshold' => 0 )); JHtml::_('formbehavior.chosen', 'select', null, array('disable_search_threshold' => 0 ));
// Ignore Image fieldset for the layouts as we render it manually $app = JFactory::getApplication();
$this->ignore_fieldsets = array('images'); $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(" JFactory::getDocument()->addScriptDeclaration("
Joomla.submitbutton = function(task) 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' : '';
?> ?>
<form action="<?php echo JRoute::_('index.php?option=com_weblinks&layout=edit&id=' . (int) $this->item->id); ?>" method="post" name="adminForm" id="weblink-form" class="form-validate"> <form action="<?php echo JRoute::_('index.php?option=com_weblinks&layout=' . $layout . $tmpl . '&id=' . (int) $this->item->id); ?>" method="post" name="adminForm" id="weblink-form" class="form-validate">
<?php echo JLayoutHelper::render('joomla.edit.title_alias', $this); ?> <?php echo JLayoutHelper::render('joomla.edit.title_alias', $this); ?>
@ -73,11 +83,20 @@ JFactory::getDocument()->addScriptDeclaration("
<?php echo JHtml::_('bootstrap.endTab'); ?> <?php echo JHtml::_('bootstrap.endTab'); ?>
<?php echo JLayoutHelper::render('joomla.edit.params', $this); ?> <?php echo JLayoutHelper::render('joomla.edit.params', $this); ?>
<?php if (!$isModal && $assoc) : ?>
<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'associations', JText::_('JGLOBAL_FIELDSET_ASSOCIATIONS')); ?>
<?php echo $this->loadTemplate('associations'); ?>
<?php echo JHtml::_('bootstrap.endTab'); ?>
<?php elseif ($isModal && $assoc) : ?>
<div class="hidden"><?php echo $this->loadTemplate('associations'); ?></div>
<?php endif; ?>
<?php echo JHtml::_('bootstrap.endTabSet'); ?> <?php echo JHtml::_('bootstrap.endTabSet'); ?>
</div> </div>
<input type="hidden" name="task" value="" /> <input type="hidden" name="task" value="" />
<input type="hidden" name="forcedLanguage" value="<?php echo $input->get('forcedLanguage', '', 'cmd'); ?>" />
<?php echo JHtml::_('form.token'); ?> <?php echo JHtml::_('form.token'); ?>
</form> </form>

View File

@ -0,0 +1,12 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
echo JLayoutHelper::render('joomla.edit.associations', $this);

View File

@ -0,0 +1,31 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::_('bootstrap.tooltip', '.hasTooltip', array('placement' => '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);
}
}
');
?>
<button id="applyBtn" type="button" class="hidden" onclick="Joomla.submitbutton('weblink.apply'); jEditWeblinkModal();"></button>
<button id="saveBtn" type="button" class="hidden" onclick="Joomla.submitbutton('weblink.save'); jEditWeblinkModal();"></button>
<button id="closeBtn" type="button" class="hidden" onclick="Joomla.submitbutton('weblink.cancel');"></button>
<div class="container-popup">
<?php $this->setLayout('edit'); ?>
<?php echo $this->loadTemplate(); ?>
</div>

View File

@ -0,0 +1,12 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
echo JLayoutHelper::render('joomla.edit.associations', $this);

View File

@ -0,0 +1,12 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
echo JLayoutHelper::render('joomla.edit.metadata', $this);

View File

@ -0,0 +1,25 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
$fieldSets = $this->form->getFieldsets('params'); ?>
<?php foreach ($fieldSets as $name => $fieldSet) : ?>
<div class="tab-pane" id="params-<?php echo $name; ?>">
<?php if (isset($fieldSet->description) && trim($fieldSet->description)) : ?>
<?php echo '<p class="alert alert-info">' . $this->escape(JText::_($fieldSet->description)) . '</p>'; ?>
<?php endif; ?>
<?php foreach ($this->form->getFieldset($name) as $field) : ?>
<div class="control-group">
<div class="control-label"><?php echo $field->label; ?></div>
<div class="controls"><?php echo $field->input; ?></div>
</div>
<?php endforeach; ?>
</div>
<?php endforeach; ?>

View File

@ -42,6 +42,20 @@ class WeblinksViewWeblink extends JViewLegacy
return false; 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(); $this->addToolbar();

View File

@ -15,12 +15,13 @@ JHtml::_('bootstrap.tooltip');
JHtml::_('behavior.multiselect'); JHtml::_('behavior.multiselect');
JHtml::_('formbehavior.chosen', 'select'); JHtml::_('formbehavior.chosen', 'select');
$user = JFactory::getUser(); $user = JFactory::getUser();
$userId = $user->get('id'); $userId = $user->get('id');
$listOrder = $this->escape($this->state->get('list.ordering')); $listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction')); $listDirn = $this->escape($this->state->get('list.direction'));
$canOrder = $user->authorise('core.edit.state', 'com_weblinks.category'); $canOrder = $user->authorise('core.edit.state', 'com_weblinks.category');
$saveOrder = $listOrder == 'a.ordering'; $saveOrder = $listOrder == 'a.ordering';
$assoc = JLanguageAssociations::isEnabled();
if ($saveOrder) if ($saveOrder)
{ {
@ -65,6 +66,11 @@ if ($saveOrder)
<th width="5%" class="nowrap center hidden-phone"> <th width="5%" class="nowrap center hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'JGLOBAL_HITS', 'a.hits', $listDirn, $listOrder); ?> <?php echo JHtml::_('searchtools.sort', 'JGLOBAL_HITS', 'a.hits', $listDirn, $listOrder); ?>
</th> </th>
<?php if ($assoc) : ?>
<th width="5%" class="nowrap hidden-phone hidden-tablet">
<?php echo JHtml::_('searchtools.sort', 'COM_WEBLINKS_HEADING_ASSOCIATION', 'association', $listDirn, $listOrder); ?>
</th>
<?php endif; ?>
<th width="10%" class="nowrap hidden-phone"> <th width="10%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_LANGUAGE', 'language_title', $listDirn, $listOrder); ?> <?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_LANGUAGE', 'language_title', $listDirn, $listOrder); ?>
</th> </th>
@ -98,7 +104,7 @@ if ($saveOrder)
<?php $iconClass = ' inactive tip-top hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); ?> <?php $iconClass = ' inactive tip-top hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); ?>
<?php endif; ?> <?php endif; ?>
<span class="sortable-handler<?php echo $iconClass ?>"> <span class="sortable-handler<?php echo $iconClass ?>">
<i class="icon-menu"></i> <i class="icon-menu" aria-hidden="true"></i>
</span> </span>
<?php if ($canChange && $saveOrder) : ?> <?php if ($canChange && $saveOrder) : ?>
<input type="text" style="display:none" name="order[]" size="5" value="<?php echo $item->ordering; ?>" class="width-20 text-area-order " /> <input type="text" style="display:none" name="order[]" size="5" value="<?php echo $item->ordering; ?>" class="width-20 text-area-order " />
@ -141,7 +147,14 @@ if ($saveOrder)
<td class="center hidden-phone"> <td class="center hidden-phone">
<?php echo $item->hits; ?> <?php echo $item->hits; ?>
</td> </td>
<td class="small nowrap hidden-phone"> <?php if ($assoc) : ?>
<td class="hidden-phone hidden-tablet">
<?php if ($item->association) : ?>
<?php echo JHtml::_('weblink.association', $item->id); ?>
<?php endif; ?>
</td>
<?php endif; ?>
<td class="small hidden-phone">
<?php echo JLayoutHelper::render('joomla.content.language', $item); ?> <?php echo JLayoutHelper::render('joomla.content.language', $item); ?>
</td> </td>
<td class="center hidden-phone"> <td class="center hidden-phone">

View File

@ -0,0 +1,147 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @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'));
}
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',
);
?>
<div class="container-popup">
<form action="<?php echo JRoute::_('index.php?option=com_weblinks&view=weblinks&layout=modal&tmpl=component&function=' . $function . '&' . JSession::getFormToken() . '=1&editor=' . $editor); ?>" method="post" name="adminForm" id="adminForm" class="form-inline">
<?php echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this)); ?>
<div class="clearfix"></div>
<?php if (empty($this->items)) : ?>
<div class="alert alert-no-items">
<?php echo JText::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
</div>
<?php else : ?>
<table class="table table-striped table-condensed">
<thead>
<tr>
<th width="1%" class="center nowrap">
<?php echo JHtml::_('searchtools.sort', 'JSTATUS', 'a.state', $listDirn, $listOrder); ?>
</th>
<th class="title">
<?php echo JHtml::_('searchtools.sort', 'JGLOBAL_TITLE', 'a.title', $listDirn, $listOrder); ?>
</th>
<th width="10%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_ACCESS', 'a.access', $listDirn, $listOrder); ?>
</th>
<th width="15%" class="nowrap">
<?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_LANGUAGE', 'language', $listDirn, $listOrder); ?>
</th>
<th width="5%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'JDATE', 'a.created', $listDirn, $listOrder); ?>
</th>
<th width="1%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="6">
<?php echo $this->pagination->getListFooter(); ?>
</td>
</tr>
</tfoot>
<tbody>
<?php foreach ($this->items as $i => $item) : ?>
<?php $lang = ''; ?>
<?php if ($item->language && JLanguageMultilang::isEnabled()) : ?>
<?php $tag = strlen($item->language); ?>
<?php if ($tag == 5) : ?>
<?php $lang = substr($item->language, 0, 2); ?>
<?php elseif ($tag == 6) : ?>
<?php $lang = substr($item->language, 0, 3); ?>
<?php endif; ?>
<?php endif; ?>
<tr class="row<?php echo $i % 2; ?>">
<td class="center">
<span class="<?php echo $iconStates[$this->escape($item->state)]; ?>"></span>
</td>
<td>
<?php $attribs = 'data-function="' . $this->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) . '"';
?>
<a class="select-link" href="javascript:void(0)" <?php echo $attribs; ?>>
<?php echo $this->escape($item->title); ?>
</a>
<div class="small">
<?php echo JText::_('JCATEGORY') . ': ' . $this->escape($item->category_title); ?>
</div>
</td>
<td class="small hidden-phone">
<?php echo $this->escape($item->access_level); ?>
</td>
<td class="small">
<?php echo JLayoutHelper::render('joomla.content.language', $item); ?>
</td>
<td class="nowrap small hidden-phone">
<?php echo JHtml::_('date', $item->created, JText::_('DATE_FORMAT_LC4')); ?>
</td>
<td class="nowrap small hidden-phone">
<?php echo (int) $item->id; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="forcedLanguage" value="<?php echo $app->input->get('forcedLanguage', '', 'CMD'); ?>" />
<?php echo JHtml::_('form.token'); ?>
</form>
</div>

View File

@ -37,7 +37,11 @@ class WeblinksViewWeblinks extends JViewLegacy
$this->filterForm = $this->get('FilterForm'); $this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters'); $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. // Check for errors.
if (count($errors = $this->get('Errors'))) if (count($errors = $this->get('Errors')))
@ -46,8 +50,30 @@ class WeblinksViewWeblinks extends JViewLegacy
return false; return false;
} }
$this->addToolbar(); // We don't need toolbar in the modal layout.
$this->sidebar = JHtmlSidebar::render(); 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('<field name="language" type="hidden" default="' . $forcedLanguage . '" />');
$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); parent::display($tpl);
} }

View File

@ -33,6 +33,10 @@
</schemas> </schemas>
</update> </update>
<media folder="media" destination="com_weblinks">
<folder>js</folder>
</media>
<files folder="components/com_weblinks"> <files folder="components/com_weblinks">
##FRONTEND_COMPONENT_FILES## ##FRONTEND_COMPONENT_FILES##
</files> </files>

View File

@ -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_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_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_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_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_COMPONENT_LABEL="Web Link"
COM_WEBLINKS_CONFIG_INTEGRATION_SETTINGS_DESC="These settings determine how the Web Links Component will integrate with other extensions." 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_FILTER_STATE="Filter State"
COM_WEBLINKS_FLOAT_DESC="Controls placement of the image." COM_WEBLINKS_FLOAT_DESC="Controls placement of the image."
COM_WEBLINKS_FLOAT_LABEL="Image Float" COM_WEBLINKS_FLOAT_LABEL="Image Float"
COM_WEBLINKS_HEADING_ASSOCIATION="Association"
COM_WEBLINKS_HITS_DESC="Number of hits for this web link." COM_WEBLINKS_HITS_DESC="Number of hits for this web link."
COM_WEBLINKS_LEFT="Left" 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." 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_RIGHT="Right"
COM_WEBLINKS_SAVE_SUCCESS="Web link successfully saved" COM_WEBLINKS_SAVE_SUCCESS="Web link successfully saved"
COM_WEBLINKS_SEARCH_IN_TITLE="Search in title" COM_WEBLINKS_SEARCH_IN_TITLE="Search in title"
COM_WEBLINKS_SELECT_A_WEBLINK="Select Web Link"
COM_WEBLINKS_SHOW_EMPTY_CATEGORIES_DESC="If Show, empty categories will display. A category is only empty - if it has no Web links or subcategories." COM_WEBLINKS_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_CATEGORIES="Categories"
COM_WEBLINKS_SUBMENU_WEBLINKS="Web Links" COM_WEBLINKS_SUBMENU_WEBLINKS="Web Links"
COM_WEBLINKS_WEBLINKS="Web Links"
COM_WEBLINKS_XML_DESCRIPTION="Component for web links management" COM_WEBLINKS_XML_DESCRIPTION="Component for web links management"
JGLOBAL_NO_ITEM_SELECTED="No web links selected" 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." JGLOBAL_NEWITEMSLAST_DESC="New Web links default to the last position. Ordering can be changed after this Web link is saved."

View File

@ -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_CATEGORY_VIEW_DEFAULT_TITLE="List Web Links in a Category"
COM_WEBLINKS_CONTENT_TYPE_WEBLINK="Web Link" COM_WEBLINKS_CONTENT_TYPE_WEBLINK="Web Link"
COM_WEBLINKS_CONTENT_TYPE_CATEGORY="Web Links Category" 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_DESC="Display a form to submit a web link in the Frontend."
COM_WEBLINKS_FORM_VIEW_DEFAULT_OPTION="Default" COM_WEBLINKS_FORM_VIEW_DEFAULT_OPTION="Default"
COM_WEBLINKS_FORM_VIEW_DEFAULT_TITLE="Submit a Web Link" COM_WEBLINKS_FORM_VIEW_DEFAULT_TITLE="Submit a Web Link"
COM_WEBLINKS_LINKS="Links" COM_WEBLINKS_LINKS="Links"
COM_WEBLINKS_TAGS_WEBLINK="Web Link" COM_WEBLINKS_TAGS_WEBLINK="Web Link"
COM_WEBLINKS_TAGS_CATEGORY="Web Link Category" 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." COM_WEBLINKS_XML_DESCRIPTION="Component for web links management."

View File

@ -21,6 +21,7 @@
<file type="plugin" id="weblinks" group="finder">plg_finder_weblinks.zip</file> <file type="plugin" id="weblinks" group="finder">plg_finder_weblinks.zip</file>
<file type="plugin" id="weblinks" group="search">plg_search_weblinks.zip</file> <file type="plugin" id="weblinks" group="search">plg_search_weblinks.zip</file>
<file type="plugin" id="weblinks" group="system">plg_system_weblinks.zip</file> <file type="plugin" id="weblinks" group="system">plg_system_weblinks.zip</file>
<file type="plugin" id="weblinks" group="editors-xtd">plg_editors-xtd_weblink.zip</file>
</files> </files>
<languages folder="language"> <languages folder="language">
<language tag="en-GB">en-GB/en-GB.pkg_weblinks.sys.ini</language> <language tag="en-GB">en-GB/en-GB.pkg_weblinks.sys.ini</language>

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* @package Joomla.Administrator * @package Joomla.Site
* @subpackage Weblinks * @subpackage com_weblinks
* *
* @copyright Copyright (C) 2005 - 2017 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 * @license GNU General Public License version 2 or later; see LICENSE.txt

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* @package Joomla.Administrator * @package Joomla.Site
* @subpackage Weblinks * @subpackage com_weblinks
* *
* @copyright Copyright (C) 2005 - 2017 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 * @license GNU General Public License version 2 or later; see LICENSE.txt

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* @package Joomla.Administrator * @package Joomla.Site
* @subpackage Weblinks * @subpackage com_weblinks
* *
* @copyright Copyright (C) 2005 - 2017 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 * @license GNU General Public License version 2 or later; see LICENSE.txt
@ -36,6 +36,23 @@ abstract class WeblinksHelperAssociation extends CategoryHelperAssociation
$view = is_null($view) ? $jinput->get('view') : $view; $view = is_null($view) ? $jinput->get('view') : $view;
$id = empty($id) ? $jinput->getInt('id') : $id; $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') if ($view == 'category' || $view == 'categories')
{ {
return self::getCategoryAssociations($id, 'com_weblinks'); return self::getCategoryAssociations($id, 'com_weblinks');

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* @package Joomla.Administrator * @package Joomla.Site
* @subpackage Weblinks * @subpackage com_weblinks
* *
* @copyright Copyright (C) 2005 - 2017 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 * @license GNU General Public License version 2 or later; see LICENSE.txt

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* @package Joomla.Administrator * @package Joomla.Site
* @subpackage Weblinks * @subpackage com_weblinks
* *
* @copyright Copyright (C) 2005 - 2017 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 * @license GNU General Public License version 2 or later; see LICENSE.txt

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* @package Joomla.Administrator * @package Joomla.Site
* @subpackage Weblinks * @subpackage com_weblinks
* *
* @copyright Copyright (C) 2005 - 2017 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 * @license GNU General Public License version 2 or later; see LICENSE.txt

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* @package Joomla.Administrator * @package Joomla.Site
* @subpackage Weblinks * @subpackage com_weblinks
* *
* @copyright Copyright (C) 2005 - 2017 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 * @license GNU General Public License version 2 or later; see LICENSE.txt

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* @package Joomla.Administrator * @package Joomla.Site
* @subpackage Weblinks * @subpackage com_weblinks
* *
* @copyright Copyright (C) 2005 - 2017 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 * @license GNU General Public License version 2 or later; see LICENSE.txt

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* @package Joomla.Administrator * @package Joomla.Site
* @subpackage Weblinks * @subpackage com_weblinks
* *
* @copyright Copyright (C) 2005 - 2017 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 * @license GNU General Public License version 2 or later; see LICENSE.txt

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* @package Joomla.Administrator * @package Joomla.Site
* @subpackage Weblinks * @subpackage com_weblinks
* *
* @copyright Copyright (C) 2005 - 2017 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 * @license GNU General Public License version 2 or later; see LICENSE.txt
@ -10,6 +10,7 @@
defined('_JEXEC') or die; defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper; use Joomla\Utilities\ArrayHelper;
use Joomla\Registry\Registry;
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . '/tables'); JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . '/tables');
@ -38,15 +39,25 @@ class WeblinksModelWeblink extends JModelItem
*/ */
protected function populateState() protected function populateState()
{ {
$app = JFactory::getApplication(); $app = JFactory::getApplication('site');
$params = $app->getParams();
// Load the object state. // Load the object state.
$id = $app->input->getInt('id'); $pk = $app->input->getInt('id');
$this->setState('weblink.id', $id); $this->setState('weblink.id', $pk);
// Load the parameters. // Load the parameters.
$params = $app->getParams();
$this->setState('params', $params); $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. * @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) 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. // Join on category table.
$table = JTable::getInstance('Weblink', 'WeblinksTable'); $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. // Join on user table.
if ($table->load($id)) $query->select('u.name AS author')
{ ->join('LEFT', '#__users AS u on u.id = a.created_by');
// Check published state.
if ($published = $this->getState('filter.published')) // Filter by language
if ($this->getState('filter.language'))
{ {
if ($table->state != $published) $query->where('a.language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')');
{
return $this->_item;
}
} }
// Convert the JTable to a clean JObject. // Join over the categories to get parent category titles
$properties = $table->getProperties(1); $query->select('parent.title as parent_title, parent.id as parent_id, parent.path as parent_route, parent.alias as parent_alias')
$this->_item = ArrayHelper::toObject($properties, 'JObject'); ->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 * @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);
} }
} }

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* @package Joomla.Administrator * @package Joomla.Site
* @subpackage Weblinks * @subpackage com_weblinks
* *
* @copyright Copyright (C) 2005 - 2017 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 * @license GNU General Public License version 2 or later; see LICENSE.txt

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* @package Joomla.Administrator * @package Joomla.Site
* @subpackage Weblinks * @subpackage com_weblinks
* *
* @copyright Copyright (C) 2005 - 2017 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 * @license GNU General Public License version 2 or later; see LICENSE.txt

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* @package Joomla.Administrator * @package Joomla.Site
* @subpackage Weblinks * @subpackage com_weblinks
* *
* @copyright Copyright (C) 2005 - 2017 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 * @license GNU General Public License version 2 or later; see LICENSE.txt

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* @package Joomla.Administrator * @package Joomla.Site
* @subpackage Weblinks * @subpackage com_weblinks
* *
* @copyright Copyright (C) 2005 - 2017 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 * @license GNU General Public License version 2 or later; see LICENSE.txt

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* @package Joomla.Administrator * @package Joomla.Site
* @subpackage Weblinks * @subpackage com_weblinks
* *
* @copyright Copyright (C) 2005 - 2017 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 * @license GNU General Public License version 2 or later; see LICENSE.txt

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* @package Joomla.Administrator * @package Joomla.Site
* @subpackage Weblinks * @subpackage com_weblinks
* *
* @copyright Copyright (C) 2005 - 2017 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 * @license GNU General Public License version 2 or later; see LICENSE.txt

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* @package Joomla.Administrator * @package Joomla.Site
* @subpackage Weblinks * @subpackage com_weblinks
* *
* @copyright Copyright (C) 2005 - 2017 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 * @license GNU General Public License version 2 or later; see LICENSE.txt

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* @package Joomla.Administrator * @package Joomla.Site
* @subpackage Weblinks * @subpackage com_weblinks
* *
* @copyright Copyright (C) 2005 - 2017 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 * @license GNU General Public License version 2 or later; see LICENSE.txt

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* @package Joomla.Administrator * @package Joomla.Site
* @subpackage Weblinks * @subpackage com_weblinks
* *
* @copyright Copyright (C) 2005 - 2017 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 * @license GNU General Public License version 2 or later; see LICENSE.txt

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* @package Joomla.Administrator * @package Joomla.Site
* @subpackage Weblinks * @subpackage com_weblinks
* *
* @copyright Copyright (C) 2005 - 2017 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 * @license GNU General Public License version 2 or later; see LICENSE.txt

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* @package Joomla.Administrator * @package Joomla.Site
* @subpackage Weblinks * @subpackage com_weblinks
* *
* @copyright Copyright (C) 2005 - 2017 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 * @license GNU General Public License version 2 or later; see LICENSE.txt

View File

@ -0,0 +1,34 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
$weblinkUrl = JStringPunycode::urlToUTF8($this->item->url);
?>
<div class="item-page">
<meta itemprop="inLanguage" content="<?php echo ($this->item->language === '*') ? JFactory::getConfig()->get('language') : $this->item->language; ?>" />
<div class="page-header">
<h2 itemprop="headline">
<?php echo $this->escape($this->item->title); ?>
</h2>
</div>
<?php // Content is generated by content plugin event "onContentAfterTitle" ?>
<?php echo $this->item->event->afterDisplayTitle; ?>
<?php // Content is generated by content plugin event "onContentBeforeDisplay" ?>
<?php echo $this->item->event->beforeDisplayContent; ?>
<div itemprop="articleBody">
<a href="<?php echo $weblinkUrl; ?>" target="_blank" itemprop="url">
<?php echo $weblinkUrl; ?>
</a>
<?php echo $this->item->description; ?>
</div>
<?php // Content is generated by content plugin event "onContentAfterDisplay" ?>
<?php echo $this->item->event->afterDisplayContent; ?>
</div>

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout title="COM_WEBLINKS_WEBLINK_VIEW_DEFAULT_TITLE" option="COM_WEBLINKS_WEBLINK_VIEW_DEFAULT_OPTION">
<help
key = "JHELP_MENUS_MENU_ITEM_WEBLINK_SINGLE_WEBLINK"
/>
<message>
<![CDATA[COM_WEBLINKS_WEBLINK_VIEW_DEFAULT_DESC]]>
</message>
</layout>
<fields name="request">
<fieldset
name="request"
addfieldpath="/administrator/components/com_weblinks/models/fields"
>
<field name="id"
type="modal_weblink"
label="COM_WEBLINKS_FIELD_SELECT_WEBLINK_LABEL"
required="true"
select="true"
new="true"
edit="true"
clear="true"
description="COM_WEBLINKS_FIELD_SELECT_WEBLINK_DESC"
/>
</fieldset>
</fields>
</metadata>

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* @package Joomla.Administrator * @package Joomla.Site
* @subpackage Weblinks * @subpackage com_weblinks
* *
* @copyright Copyright (C) 2005 - 2017 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 * @license GNU General Public License version 2 or later; see LICENSE.txt
@ -10,44 +10,53 @@
defined('_JEXEC') or die; 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 class WeblinksViewWeblink extends JViewLegacy
{ {
protected $state;
protected $item; 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. * @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. * @return mixed A string if successful, otherwise an Error object.
*
* @since __DEPLOY_VERSION__
*/ */
public function display($tpl = null) public function display($tpl = null)
{ {
// Get some data from the models $dispatcher = JEventDispatcher::getInstance();
$item = $this->get('Item');
if ($this->getLayout() == 'edit') $this->item = $this->get('Item');
{ $this->state = $this->get('State');
$this->_displayEdit($tpl); $this->params = $this->state->get('params');
return; // Create a shortcut for $item.
} $item = $this->item;
if ($item->url) $offset = $this->state->get('list.offset');
{
// Redirects to url if matching id found $dispatcher->trigger('onContentPrepare', array ('com_weblinks.weblink', &$item, &$item->params, $offset));
JFactory::getApplication()->redirect($item->url);
} $item->event = new stdClass;
else
{ $results = $dispatcher->trigger('onContentAfterTitle', array('com_weblinks.weblink', &$item, &$item->params, $offset));
// @TODO create proper error handling $item->event->afterDisplayTitle = trim(implode("\n", $results));
JFactory::getApplication()->redirect(JRoute::_('index.php'), JText::_('COM_WEBLINKS_ERROR_WEBLINK_NOT_FOUND'), 'notice');
} $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);
} }
} }

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* @package Joomla.Administrator * @package Joomla.Site
* @subpackage Weblinks * @subpackage com_weblinks
* *
* @copyright Copyright (C) 2005 - 2017 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 * @license GNU General Public License version 2 or later; see LICENSE.txt

View File

@ -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 = '<a' + hreflang + ' href="' + link + '">' + title + '</a>';
/** Use the API, if editor supports it **/
if (window.Joomla && window.Joomla.editors && Joomla.editors.instances && Joomla.editors.instances.hasOwnProperty(editor)) {
Joomla.editors.instances[editor].replaceSelection(tag)
} else {
window.parent.jInsertEditorText(tag, editor);
}
window.parent.jModalClose();
};
document.addEventListener('DOMContentLoaded', function(){
// Get the elements
var elements = document.querySelectorAll('.select-link');
for(var i = 0, l = elements.length; l>i; i++) {
// Listen for click event
elements[i].addEventListener('click', function (event) {
event.preventDefault();
var functionName = event.target.getAttribute('data-function');
if (functionName === 'jSelectWeblink') {
// Used in xtd_weblinks
window[functionName](event.target.getAttribute('data-id'), event.target.getAttribute('data-title'), event.target.getAttribute('data-cat-id'), null, event.target.getAttribute('data-uri'), event.target.getAttribute('data-language', null));
} else {
// Used in com_menus
window.parent[functionName](event.target.getAttribute('data-id'), event.target.getAttribute('data-title'), event.target.getAttribute('data-cat-id'), null, event.target.getAttribute('data-uri'), event.target.getAttribute('data-language', null));
}
})
}
});
})();

View File

@ -0,0 +1 @@
!function(){"use strict";window.jSelectWeblink=function(a,b,c,d,e,f){var h,i,g="";if(!Joomla.getOptions("xtd-weblinks"))return window.parent.jModalClose(),!1;h=Joomla.getOptions("xtd-weblinks").editor,""!==f&&(g=' hreflang="'+f+'"'),i="<a"+g+' href="'+e+'">'+b+"</a>",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))})})}();

View File

@ -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."

View File

@ -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."

View File

@ -0,0 +1,59 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Editors-xtd.weblink
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Editor Web Link button
*
* @since __DEPLOY_VERSION__
*/
class PlgButtonWeblink extends JPlugin
{
/**
* Load the language file on instantiation.
*
* @var boolean
* @since __DEPLOY_VERSION__
*/
protected $autoloadLanguage = true;
/**
* Display the button
*
* @param string $name The name of the button to add
*
* @return JObject The button options as JObject
*
* @since __DEPLOY_VERSION__
*/
public function onDisplay($name)
{
$user = JFactory::getUser();
if ($user->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&amp;view=weblinks&amp;layout=modal&amp;tmpl=component&amp;'
. JSession::getFormToken() . '=1&amp;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;
}
}
}

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.7" type="plugin" group="editors-xtd" method="upgrade">
<name>plg_editors-xtd_weblink</name>
<author>Joomla! Project</author>
<creationDate>##DATE##</creationDate>
<copyright>Copyright (C) 2005 - 2017 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.7.0</version>
<description>PLG_EDITORS-XTD_WEBLINK_XML_DESCRIPTION</description>
<files>
##FILES##
</files>
<languages folder="language">
##LANGUAGE_FILES##
</languages>
</extension>