30
1
mirror of https://github.com/joomla-extensions/weblinks.git synced 2024-06-16 21:12:22 +00:00

Merge remote-tracking branch 'upstream/master' into phpcs

This commit is contained in:
Yves Hoppe 2016-08-01 19:50:42 +02:00
commit b97d472f8f
8 changed files with 152 additions and 166 deletions

View File

@ -19,9 +19,9 @@ class WeblinksController extends JControllerLegacy
/** /**
* Method to display a view. * Method to display a view.
* *
* @param boolean $cacheable If true, the view output will be cached * @param boolean $cacheable If true, the view output will be cached
* @param array $urlparams An array of safe url parameters and their variable types, * @param array $urlparams An array of safe url parameters and their variable types,
* for valid values see {@link JFilterInput::clean()}. * for valid values see {@link JFilterInput::clean()}.
* *
* @return JControllerLegacy This object to support chaining. * @return JControllerLegacy This object to support chaining.
* *

View File

@ -21,6 +21,7 @@ $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';
if ($saveOrder) if ($saveOrder)
{ {
$saveOrderingUrl = 'index.php?option=com_weblinks&task=weblinks.saveOrderAjax&tmpl=component'; $saveOrderingUrl = 'index.php?option=com_weblinks&task=weblinks.saveOrderAjax&tmpl=component';
@ -80,27 +81,21 @@ if ($saveOrder)
</tr> </tr>
</tfoot> </tfoot>
<tbody> <tbody>
<?php foreach ($this->items as $i => $item) : <?php foreach ($this->items as $i => $item) : ?>
$ordering = ($listOrder == 'a.ordering'); <?php $ordering = ($listOrder == 'a.ordering'); ?>
$item->cat_link = JRoute::_('index.php?option=com_categories&extension=com_weblinks&task=edit&type=other&cid[]='. $item->catid); <?php $item->cat_link = JRoute::_('index.php?option=com_categories&extension=com_weblinks&task=edit&type=other&cid[]=' . $item->catid); ?>
$canCreate = $user->authorise('core.create', 'com_weblinks.category.' . $item->catid); <?php $canCreate = $user->authorise('core.create', 'com_weblinks.category.' . $item->catid); ?>
$canEdit = $user->authorise('core.edit', 'com_weblinks.category.' . $item->catid); <?php $canEdit = $user->authorise('core.edit', 'com_weblinks.category.' . $item->catid); ?>
$canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $user->get('id') || $item->checked_out == 0; <?php $canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $user->get('id') || $item->checked_out == 0; ?>
$canChange = $user->authorise('core.edit.state', 'com_weblinks.category.' . $item->catid) && $canCheckin; <?php $canChange = $user->authorise('core.edit.state', 'com_weblinks.category.' . $item->catid) && $canCheckin; ?>
?>
<tr class="row<?php echo $i % 2; ?>" sortable-group-id="<?php echo $item->catid; ?>"> <tr class="row<?php echo $i % 2; ?>" sortable-group-id="<?php echo $item->catid; ?>">
<td class="order nowrap center hidden-phone"> <td class="order nowrap center hidden-phone">
<?php <?php $iconClass = ''; ?>
$iconClass = ''; <?php if (!$canChange) : ?>
if (!$canChange) <?php $iconClass = ' inactive'; ?>
{ <?php elseif (!$saveOrder) : ?>
$iconClass = ' inactive'; <?php $iconClass = ' inactive tip-top hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); ?>
} <?php endif; ?>
elseif (!$saveOrder)
{
$iconClass = ' inactive tip-top hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED');
}
?>
<span class="sortable-handler<?php echo $iconClass ?>"> <span class="sortable-handler<?php echo $iconClass ?>">
<i class="icon-menu"></i> <i class="icon-menu"></i>
</span> </span>
@ -114,14 +109,12 @@ if ($saveOrder)
<td class="center"> <td class="center">
<div class="btn-group"> <div class="btn-group">
<?php echo JHtml::_('jgrid.published', $item->state, $i, 'weblinks.', $canChange, 'cb', $item->publish_up, $item->publish_down); ?> <?php echo JHtml::_('jgrid.published', $item->state, $i, 'weblinks.', $canChange, 'cb', $item->publish_up, $item->publish_down); ?>
<?php // Create dropdown items and render the dropdown list. <?php // Create dropdown items and render the dropdown list. ?>
if ($canChange) <?php if ($canChange) : ?>
{ <?php JHtml::_('actionsdropdown.' . ((int) $item->state === 2 ? 'un' : '') . 'archive', 'cb' . $i, 'weblinks'); ?>
JHtml::_('actionsdropdown.' . ((int) $item->state === 2 ? 'un' : '') . 'archive', 'cb' . $i, 'weblinks'); <?php JHtml::_('actionsdropdown.' . ((int) $item->state === -2 ? 'un' : '') . 'trash', 'cb' . $i, 'weblinks'); ?>
JHtml::_('actionsdropdown.' . ((int) $item->state === -2 ? 'un' : '') . 'trash', 'cb' . $i, 'weblinks'); <?php echo JHtml::_('actionsdropdown.render', $this->escape($item->title)); ?>
echo JHtml::_('actionsdropdown.render', $this->escape($item->title)); <?php endif; ?>
}
?>
</div> </div>
</td> </td>
<td class="nowrap has-context"> <td class="nowrap has-context">

View File

@ -19,9 +19,9 @@ class WeblinksController extends JControllerLegacy
/** /**
* Method to display a view. * Method to display a view.
* *
* @param boolean $cacheable If true, the view output will be cached * @param boolean $cacheable If true, the view output will be cached
* @param array $urlparams An array of safe url parameters and their variable types, * @param array $urlparams An array of safe url parameters and their variable types,
* for valid values see {@link JFilterInput::clean()}. * for valid values see {@link JFilterInput::clean()}.
* *
* @return WeblinksController This object to support chaining. * @return WeblinksController This object to support chaining.
* *
@ -32,9 +32,11 @@ class WeblinksController extends JControllerLegacy
// Huh? Why not just put that in the constructor? // Huh? Why not just put that in the constructor?
$cacheable = true; $cacheable = true;
// Set the default view name and format from the Request. /**
// Note we are using w_id to avoid collisions with the router and the return page. * Set the default view name and format from the Request.
// Frontend is a bit messier than the backend. * Note we are using w_id to avoid collisions with the router and the return page.
* Frontend is a bit messier than the backend.
*/
$id = $this->input->getInt('w_id'); $id = $this->input->getInt('w_id');
$vName = $this->input->get('view', 'categories'); $vName = $this->input->get('view', 'categories');
$this->input->set('view', $vName); $this->input->set('view', $vName);

View File

@ -45,7 +45,7 @@ abstract class WeblinksHelperRoute
{ {
$needles['category'] = array_reverse($category->getPath()); $needles['category'] = array_reverse($category->getPath());
$needles['categories'] = $needles['category']; $needles['categories'] = $needles['category'];
$link .= '&catid='.$catid; $link .= '&catid=' . $catid;
} }
} }
@ -62,7 +62,7 @@ abstract class WeblinksHelperRoute
if ($item = self::_findItem($needles)) if ($item = self::_findItem($needles))
{ {
$link .= '&Itemid='.$item; $link .= '&Itemid=' . $item;
} }
return $link; return $link;
@ -155,7 +155,7 @@ abstract class WeblinksHelperRoute
/** /**
* Do a language lookup * Do a language lookup
* *
* @return void * @return void
*/ */
protected static function buildLanguageLookup() protected static function buildLanguageLookup()
{ {
@ -180,9 +180,9 @@ abstract class WeblinksHelperRoute
/** /**
* Find items per given $needles * Find items per given $needles
* *
* @params array $needles * @param array $needles
* *
* @return void * @return void
*/ */
protected static function _findItem($needles = null) protected static function _findItem($needles = null)
{ {
@ -195,7 +195,7 @@ abstract class WeblinksHelperRoute
{ {
self::$lookup[$language] = array(); self::$lookup[$language] = array();
$component = JComponentHelper::getComponent('com_weblinks'); $component = JComponentHelper::getComponent('com_weblinks');
$attributes = array('component_id'); $attributes = array('component_id');
$values = array($component->id); $values = array($component->id);
@ -223,9 +223,11 @@ abstract class WeblinksHelperRoute
if (isset($item->query['id'])) if (isset($item->query['id']))
{ {
// Here it will become a bit tricky /**
// language != * can override existing entries * Here it will become a bit tricky
// language == * cannot override existing entries * language != * can override existing entries
* language == * cannot override existing entries
*/
if (!isset(self::$lookup[$language][$view][$item->query['id']]) || $item->language != '*') if (!isset(self::$lookup[$language][$view][$item->query['id']]) || $item->language != '*')
{ {
self::$lookup[$language][$view][$item->query['id']] = $item->id; self::$lookup[$language][$view][$item->query['id']] = $item->id;

View File

@ -70,7 +70,7 @@ class WeblinksModelCategories extends JModelList
* different modules that might need different sets of data or different * different modules that might need different sets of data or different
* ordering requirements. * ordering requirements.
* *
* @param string $id A prefix for the store id. * @param string $id A prefix for the store id.
* *
* @return string A store id. * @return string A store id.
*/ */

View File

@ -121,19 +121,19 @@ class WeblinksModelCategory extends JModelList
// Filter by category. // Filter by category.
if ($categoryId = $this->getState('category.id')) if ($categoryId = $this->getState('category.id'))
{ {
// Group by subcategory // Group by subcategory
if ($this->getState('category.group', 0)) if ($this->getState('category.group', 0))
{ {
$query->select('c.title AS category_title') $query->select('c.title AS category_title')
->where('c.parent_id = ' . (int) $categoryId) ->where('c.parent_id = ' . (int) $categoryId)
->join('LEFT', '#__categories AS c ON c.id = a.catid') ->join('LEFT', '#__categories AS c ON c.id = a.catid')
->where('c.access IN (' . $groups . ')'); ->where('c.access IN (' . $groups . ')');
} }
else else
{ {
$query->where('a.catid = ' . (int) $categoryId) $query->where('a.catid = ' . (int) $categoryId)
->join('LEFT', '#__categories AS c ON c.id = a.catid') ->join('LEFT', '#__categories AS c ON c.id = a.catid')
->where('c.access IN (' . $groups . ')'); ->where('c.access IN (' . $groups . ')');
} }
// Filter by published category // Filter by published category
@ -188,7 +188,7 @@ class WeblinksModelCategory extends JModelList
} }
// If grouping by subcategory, add the subcategory list ordering clause. // If grouping by subcategory, add the subcategory list ordering clause.
if($this->getState('category.group', 0)) if ($this->getState('category.group', 0))
{ {
$query->order( $query->order(
$db->escape($this->getState('category.ordering', 'c.lft')) . ' ' . $db->escape($this->getState('category.ordering', 'c.lft')) . ' ' .

View File

@ -34,8 +34,6 @@ class WeblinksViewForm extends JViewLegacy
public function display($tpl = null) public function display($tpl = null)
{ {
$user = JFactory::getUser(); $user = JFactory::getUser();
// Get the application
$app = JFactory::getApplication();
// Get model data. // Get model data.
$this->state = $this->get('State'); $this->state = $this->get('State');
@ -62,11 +60,13 @@ class WeblinksViewForm extends JViewLegacy
if (!empty($this->item)) if (!empty($this->item))
{ {
// Override the base weblink data with any data in the session. // Override the base weblink data with any data in the session.
$temp = (array) $app->getUserState('com_weblinks.edit.weblink.data', array()); $temp = (array) JFactory::getApplication()->getUserState('com_weblinks.edit.weblink.data', array());
foreach ($temp as $k => $v) foreach ($temp as $k => $v)
{ {
$this->item->$k = $v; $this->item->$k = $v;
} }
$this->form->bind($this->item); $this->form->bind($this->item);
} }
@ -98,9 +98,9 @@ class WeblinksViewForm extends JViewLegacy
*/ */
protected function _prepareDocument() protected function _prepareDocument()
{ {
$app = JFactory::getApplication(); $app = JFactory::getApplication();
$menus = $app->getMenu(); $menus = $app->getMenu();
$title = null; $title = null;
// Because the application sets a default page title, // Because the application sets a default page title,
// we need to get it from the menu item itself // we need to get it from the menu item itself

View File

@ -9,120 +9,109 @@
defined('_JEXEC') or die; defined('_JEXEC') or die;
?> ?>
<?php
if($params->get('groupby', 0)) :
$cats = array(); <?php if ($params->get('groupby', 0)) : ?>
$cols = $params->get('groupby_columns', 3); <?php $cats = array(); ?>
<?php $cols = $params->get('groupby_columns', 3); ?>
<?php foreach ($list as $l) : ?>
<?php $cats[] = array('catid' => $l->catid, 'title' => $l->category_title); ?>
<?php endforeach; ?>
<?php $cats = array_values(array_map('unserialize', array_unique(array_map('serialize', $cats)))); ?>
<?php foreach ($cats as $k => $cat) : ?>
<?php $items = array(); ?>
<?php foreach ($list as $item) : ?>
<?php if ($item->catid == $cat['catid']) : ?>
<?php $items[] = $item; ?>
<?php endif; ?>
<?php endforeach; ?>
<?php if ($cols > 1) : ?>
<?php if ($k % $cols == 0) : ?>
<div class="row row-fluid">
<?php endif; ?>
<div class="span<?php echo (12 / $cols); ?>">
<?php endif; ?>
<?php if ($params->get('groupby_showtitle', 1)) : ?>
<h4><?php echo htmlspecialchars($cat['title'], ENT_COMPAT, 'UTF-8')); ?></h4>
<?php endif; ?>
<ul class="weblinks<?php echo $moduleclass_sfx; ?>">
<?php foreach ($items as $item) : ?>
<li>
<?php $link = $item->link; ?>
<?php
switch ($item->params->get('target', 3))
{
case 1:
// Open in a new window
echo '<a href="' . $link . '" target="_blank" rel="' . $params->get('follow', 'nofollow') . '">' .
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break;
foreach ($list as $l) case 2:
$cats[] = array('catid' => $l->catid, 'title' => $l->category_title); // Open in a popup window
echo "<a href=\"#\" onclick=\"window.open('" . $link . "', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550'); return false\">" .
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break;
$cats = array_values(array_map('unserialize', array_unique(array_map('serialize', $cats)))); default:
// Open in parent window
echo '<a href="' . $link . '" rel="' . $params->get('follow', 'nofollow') . '">' .
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break;
}
?>
<?php if ($params->get('description', 0)) : ?>
<?php echo nl2br($item->description); ?>
<?php endif; ?>
foreach ($cats as $k => $cat) : <?php if ($params->get('hits', 0)) : ?>
<?php echo '(' . $item->hits . ' ' . JText::_('MOD_WEBLINKS_HITS') . ')'; ?>
$items = array(); <?php endif; ?>
</li>
foreach ($list as $item) <?php endforeach; ?>
if ($item->catid == $cat['catid']) </ul>
$items[] = $item; <?php if ($cols > 1) : ?>
?> </div>
<?php if($cols > 1) : ?> <?php if(($k + 1) % $cols == 0 || $k == count($cats) - 1) : ?>
<?php if($k % $cols == 0) : ?> </div>
<div class="row row-fluid"> <?php endif; ?>
<?php endif; ?> <?php endif; ?>
<div class="span<?php echo (12 / $cols); ?>"> <?php endforeach; ?>
<?php endif; ?>
<?php if($params->get('groupby_showtitle', 1)) : ?>
<h4><?php echo htmlspecialchars($cat['title']); ?></h4>
<?php endif; ?>
<ul class="weblinks<?php echo $moduleclass_sfx; ?>">
<?php foreach ($items as $item) : ?>
<li>
<?php
$link = $item->link;
switch ($item->params->get('target', 3))
{
case 1:
// Open in a new window
echo '<a href="' . $link . '" target="_blank" rel="' . $params->get('follow', 'nofollow') . '">' .
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break;
case 2:
// Open in a popup window
echo "<a href=\"#\" onclick=\"window.open('" . $link . "', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550'); return false\">" .
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break;
default:
// Open in parent window
echo '<a href="' . $link . '" rel="' . $params->get('follow', 'nofollow') . '">' .
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break;
}
if ($params->get('description', 0))
{
echo nl2br($item->description);
}
if ($params->get('hits', 0))
{
echo '(' . $item->hits . ' ' . JText::_('MOD_WEBLINKS_HITS') . ')';
}
?>
</li>
<?php endforeach; ?>
</ul>
<?php if($cols > 1) : ?>
</div>
<?php if(($k + 1) % $cols == 0 || $k == count($cats) - 1) : ?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php endforeach; ?>
<?php else : ?> <?php else : ?>
<ul class="weblinks<?php echo $moduleclass_sfx; ?>"> <ul class="weblinks<?php echo $moduleclass_sfx; ?>">
<?php foreach ($list as $item) : ?> <?php foreach ($list as $item) : ?>
<li> <li>
<?php <?php $link = $item->link; ?>
$link = $item->link; <?php
switch ($item->params->get('target', 3))
{
case 1:
// Open in a new window
echo '<a href="' . $link . '" target="_blank" rel="' . $params->get('follow', 'nofollow') . '">' .
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break;
switch ($item->params->get('target', 3)) case 2:
{ // Open in a popup window
case 1: echo "<a href=\"#\" onclick=\"window.open('" . $link . "', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550'); return false\">" .
// Open in a new window htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
echo '<a href="' . $link . '" target="_blank" rel="' . $params->get('follow', 'nofollow') . '">' . break;
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break;
case 2: default:
// Open in a popup window // Open in parent window
echo "<a href=\"#\" onclick=\"window.open('" . $link . "', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550'); return false\">" . echo '<a href="' . $link . '" rel="' . $params->get('follow', 'nofollow') . '">' .
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>'; htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break; break;
}
?>
default: <?php if ($params->get('description', 0)) : ?>
// Open in parent window <?php echo nl2br($item->description); ?>
echo '<a href="' . $link . '" rel="' . $params->get('follow', 'nofollow') . '">' . <?php endif; ?>
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break;
}
if ($params->get('description', 0)) <?php if ($params->get('hits', 0)) : ?>
{ <?php echo '(' . $item->hits . ' ' . JText::_('MOD_WEBLINKS_HITS') . ')'; ?>
echo nl2br($item->description); <?php endif; ?>
} </li>
<?php endforeach; ?>
if ($params->get('hits', 0)) </ul>
{
echo '(' . $item->hits . ' ' . JText::_('MOD_WEBLINKS_HITS') . ')';
}
?>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?> <?php endif; ?>