mirror of
https://github.com/joomla-extensions/weblinks.git
synced 2025-01-27 06:18:29 +00:00
View and router frontend CS (#231)
* Update view.html.php * Update default_items.php * Update default.php * Update view.html.php * Update edit.php * Update router.php * Update router.php * Update default_items.php * Update view.html.php * Update view.html.php
This commit is contained in:
parent
8688bfd9cc
commit
77d2b1fbf9
@ -259,7 +259,11 @@ class WeblinksRouter extends JComponentRouterBase
|
||||
/**
|
||||
* Weblinks router functions
|
||||
*
|
||||
* These functions are proxys for the new router interface
|
||||
* @param array &$query An array of URL arguments
|
||||
*
|
||||
* @return array The URL arguments to use to assemble the subsequent URL.
|
||||
*
|
||||
* Note. These functions are proxies for the new router interface
|
||||
* for old SEF extensions.
|
||||
*
|
||||
* @deprecated 4.0 Use Class based routers instead
|
||||
@ -271,6 +275,18 @@ function WeblinksBuildRoute(&$query)
|
||||
return $router->build($query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Weblinks router functions
|
||||
*
|
||||
* @param array $segments The segments of the URL to parse.
|
||||
*
|
||||
* @return array The URL attributes to be used by the application.
|
||||
*
|
||||
* Note. These functions are proxies for the new router interface
|
||||
* for old SEF extensions.
|
||||
*
|
||||
* @deprecated 4.0 Use Class based routers instead
|
||||
*/
|
||||
function WeblinksParseRoute($segments)
|
||||
{
|
||||
$router = new WeblinksRouter;
|
||||
|
@ -9,6 +9,6 @@
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers');
|
||||
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers');
|
||||
$this->subtemplatename = 'items';
|
||||
echo JLayoutHelper::render('joomla.content.category_default', $this);
|
||||
|
@ -25,8 +25,8 @@ $canCreate = $user->authorise('core.create', 'com_weblinks');
|
||||
$canEditState = $user->authorise('core.edit.state', 'com_weblinks');
|
||||
|
||||
$n = count($this->items);
|
||||
$listOrder = $this->escape($this->state->get('list.ordering'));
|
||||
$listDirn = $this->escape($this->state->get('list.direction'));
|
||||
$listOrder = $this->escape($this->state->get('list.ordering'));
|
||||
$listDirn = $this->escape($this->state->get('list.direction'));
|
||||
?>
|
||||
|
||||
<?php if (empty($this->items)) : ?>
|
||||
@ -34,9 +34,9 @@ $listDirn = $this->escape($this->state->get('list.direction'));
|
||||
<?php else : ?>
|
||||
|
||||
<form action="<?php echo htmlspecialchars(JUri::getInstance()->toString()); ?>" method="post" name="adminForm" id="adminForm">
|
||||
<?php if ($this->params->get('filter_field') != 'hide' || $this->params->get('show_pagination_limit')) :?>
|
||||
<?php if ($this->params->get('filter_field') != 'hide' || $this->params->get('show_pagination_limit')) : ?>
|
||||
<fieldset class="filters btn-toolbar">
|
||||
<?php if ($this->params->get('filter_field') != 'hide') :?>
|
||||
<?php if ($this->params->get('filter_field') != 'hide') : ?>
|
||||
<div class="btn-group">
|
||||
<label class="filter-search-lbl element-invisible" for="filter-search"><?php echo JText::_('COM_WEBLINKS_FILTER_LABEL') . ' '; ?></label>
|
||||
<input type="text" name="filter-search" id="filter-search" value="<?php echo $this->escape($this->state->get('list.filter')); ?>" class="inputbox" onchange="document.adminForm.submit();" title="<?php echo JText::_('COM_WEBLINKS_FILTER_SEARCH_DESC'); ?>" placeholder="<?php echo JText::_('COM_WEBLINKS_FILTER_SEARCH_DESC'); ?>" />
|
||||
@ -54,12 +54,11 @@ $listDirn = $this->escape($this->state->get('list.direction'));
|
||||
</fieldset>
|
||||
<?php endif; ?>
|
||||
<ul class="category list-striped list-condensed">
|
||||
|
||||
<?php foreach ($this->items as $i => $item) : ?>
|
||||
<?php if (in_array($item->access, $this->user->getAuthorisedViewLevels())) : ?>
|
||||
<?php if ($this->items[$i]->state == 0) : ?>
|
||||
<li class="system-unpublished cat-list-row<?php echo $i % 2; ?>">
|
||||
<?php else: ?>
|
||||
<?php else : ?>
|
||||
<li class="cat-list-row<?php echo $i % 2; ?>" >
|
||||
<?php endif; ?>
|
||||
<?php if ($this->params->get('show_link_hits', 1)) : ?>
|
||||
@ -84,48 +83,47 @@ $listDirn = $this->escape($this->state->get('list.direction'));
|
||||
<?php echo '<img src="' . $this->params->get('link_icons') . '" alt="' . JText::_('COM_WEBLINKS_LINK') . '" />'; ?>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<?php // Compute the correct link ?>
|
||||
<?php $menuclass = 'category' . $this->pageclass_sfx; ?>
|
||||
<?php $link = $item->link; ?>
|
||||
<?php $width = $item->params->get('width'); ?>
|
||||
<?php $height = $item->params->get('height'); ?>
|
||||
<?php if ($width == null || $height == null) : ?>
|
||||
<?php $width = 600; ?>
|
||||
<?php $height = 500; ?>
|
||||
<?php endif; ?>
|
||||
<?php if ($this->items[$i]->state == 0) : ?>
|
||||
<span class="label label-warning"><?php echo JText::_('JUNPUBLISHED'); ?></span>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
// Compute the correct link
|
||||
$menuclass = 'category' . $this->pageclass_sfx;
|
||||
$link = $item->link;
|
||||
$width = $item->params->get('width');
|
||||
$height = $item->params->get('height');
|
||||
if ($width == null || $height == null)
|
||||
{
|
||||
$width = 600;
|
||||
$height = 500;
|
||||
}
|
||||
if ($this->items[$i]->state == 0) : ?>
|
||||
<span class="label label-warning"><?php echo JText::_('JUNPUBLISHED'); ?></span>
|
||||
<?php endif; ?>
|
||||
switch ($item->params->get('target', $this->params->get('target')))
|
||||
{
|
||||
case 1:
|
||||
// Open in a new window
|
||||
echo '<a href="' . $link . '" target="_blank" class="' . $menuclass . '" rel="nofollow">' .
|
||||
$this->escape($item->title) . '</a>';
|
||||
break;
|
||||
|
||||
<?php switch ($item->params->get('target', $this->params->get('target')))
|
||||
{
|
||||
case 1:
|
||||
// Open in a new window
|
||||
echo '<a href="' . $link . '" target="_blank" class="' . $menuclass . '" rel="nofollow">' .
|
||||
$this->escape($item->title) . '</a>';
|
||||
break;
|
||||
case 2:
|
||||
// Open in a popup window
|
||||
$attribs = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=' . $this->escape($width) . ',height=' . $this->escape($height) . '';
|
||||
echo "<a href=\"$link\" onclick=\"window.open(this.href, 'targetWindow', '" . $attribs . "'); return false;\">" .
|
||||
$this->escape($item->title) . '</a>';
|
||||
break;
|
||||
case 3:
|
||||
// Open in a modal window
|
||||
JHtml::_('behavior.modal', 'a.modal');
|
||||
echo '<a class="modal" href="' . $link . '" rel="{handler: \'iframe\', size: {x:' . $this->escape($width) . ', y:' . $this->escape($height) . '}}">' .
|
||||
$this->escape($item->title) . ' </a>';
|
||||
break;
|
||||
|
||||
case 2:
|
||||
// Open in a popup window
|
||||
$attribs = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=' . $this->escape($width) . ',height=' . $this->escape($height) . '';
|
||||
echo "<a href=\"$link\" onclick=\"window.open(this.href, 'targetWindow', '" . $attribs . "'); return false;\">" .
|
||||
$this->escape($item->title) . '</a>';
|
||||
break;
|
||||
case 3:
|
||||
// Open in a modal window
|
||||
JHtml::_('behavior.modal', 'a.modal');
|
||||
echo '<a class="modal" href="' . $link . '" rel="{handler: \'iframe\', size: {x:' . $this->escape($width) . ', y:' . $this->escape($height) . '}}">' .
|
||||
$this->escape($item->title) . ' </a>';
|
||||
break;
|
||||
|
||||
default:
|
||||
// Open in parent window
|
||||
echo '<a href="' . $link . '" class="' . $menuclass . '" rel="nofollow">' .
|
||||
$this->escape($item->title) . ' </a>';
|
||||
break;
|
||||
}
|
||||
default:
|
||||
// Open in parent window
|
||||
echo '<a href="' . $link . '" class="' . $menuclass . '" rel="nofollow">' .
|
||||
$this->escape($item->title) . ' </a>';
|
||||
break;
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php $tagsData = $item->tags->getItemTags('com_weblinks.weblink', $item->id); ?>
|
||||
@ -133,38 +131,32 @@ $listDirn = $this->escape($this->state->get('list.direction'));
|
||||
<?php $this->item->tagLayout = new JLayoutFile('joomla.content.tags'); ?>
|
||||
<?php echo $this->item->tagLayout->render($tagsData); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (($this->params->get('show_link_description')) and ($item->description != '')) : ?>
|
||||
<?php $images = json_decode($item->images); ?>
|
||||
<?php if (isset($images->image_first) and !empty($images->image_first)) : ?>
|
||||
<?php $imgfloat = (empty($images->float_first)) ? $this->params->get('float_first') : $images->float_first; ?>
|
||||
<div class="img-intro-<?php echo htmlspecialchars($imgfloat); ?>"> <img
|
||||
<?php if ($images->image_first_caption):
|
||||
echo 'class="caption"'.' title="' .htmlspecialchars($images->image_first_caption) .'"';
|
||||
endif; ?>
|
||||
<?php if ($images->image_first_caption) : ?>
|
||||
<?php echo 'class="caption" title="' . htmlspecialchars($images->image_first_caption) . '"'; ?>
|
||||
<?php endif; ?>
|
||||
src="<?php echo htmlspecialchars($images->image_first); ?>" alt="<?php echo htmlspecialchars($images->image_first_alt); ?>"/> </div>
|
||||
<?php endif; ?>
|
||||
<?php if (isset($images->image_second) and !empty($images->image_second)) : ?>
|
||||
<?php $imgfloat = (empty($images->float_second)) ? $this->params->get('float_second') : $images->float_second; ?>
|
||||
<div class="pull-<?php echo htmlspecialchars($imgfloat); ?> item-image"> <img
|
||||
<?php if ($images->image_second_caption):
|
||||
echo 'class="caption"'.' title="' .htmlspecialchars($images->image_second_caption) .'"';
|
||||
endif; ?>
|
||||
<?php if ($images->image_second_caption) : ?>
|
||||
<?php echo 'class="caption" title="' . htmlspecialchars($images->image_second_caption) . '"'; ?>
|
||||
<?php endif; ?>
|
||||
src="<?php echo htmlspecialchars($images->image_second); ?>" alt="<?php echo htmlspecialchars($images->image_second_alt); ?>"/> </div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php echo $item->description; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
</li>
|
||||
<?php endif;?>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
|
||||
<?php // Code to add a link to submit a weblink. ?>
|
||||
<?php /* if ($canCreate) : // TODO This is not working due to some problem in the router, I think. Ref issue #23685 ?>
|
||||
<?php echo JHtml::_('icon.create', $item, $item->params); ?>
|
||||
<?php endif; */ ?>
|
||||
<?php if ($this->params->get('show_pagination')) : ?>
|
||||
<div class="pagination">
|
||||
<?php if ($this->params->def('show_pagination_results', 1)) : ?>
|
||||
|
@ -34,7 +34,7 @@ $params = $this->state->get('params');
|
||||
<?php echo $this->escape($this->params->get('page_heading')); ?>
|
||||
</h1>
|
||||
<?php endif; ?>
|
||||
<form action="<?php echo JRoute::_('index.php?option=com_weblinks&view=form&w_id='.(int) $this->item->id); ?>" method="post" name="adminForm" id="adminForm" class="form-validate form-vertical">
|
||||
<form action="<?php echo JRoute::_('index.php?option=com_weblinks&view=form&w_id=' . (int) $this->item->id); ?>" method="post" name="adminForm" id="adminForm" class="form-validate form-vertical">
|
||||
<div class="btn-toolbar">
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-primary" onclick="Joomla.submitbutton('weblink.save')">
|
||||
|
@ -24,6 +24,13 @@ class WeblinksViewForm extends JViewLegacy
|
||||
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* Display the view.
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
$user = JFactory::getUser();
|
||||
@ -40,7 +47,7 @@ class WeblinksViewForm extends JViewLegacy
|
||||
}
|
||||
else
|
||||
{
|
||||
$authorised = $user->authorise('core.edit', 'com_weblinks.category.'.$this->item->catid);
|
||||
$authorised = $user->authorise('core.edit', 'com_weblinks.category.' . $this->item->catid);
|
||||
}
|
||||
|
||||
if ($authorised !== true)
|
||||
@ -66,7 +73,7 @@ class WeblinksViewForm extends JViewLegacy
|
||||
// Create a shortcut to the parameters.
|
||||
$params = &$this->state->params;
|
||||
|
||||
//Escape strings for HTML output
|
||||
// Escape strings for HTML output
|
||||
$this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
|
||||
|
||||
$this->params = $params;
|
||||
@ -78,6 +85,8 @@ class WeblinksViewForm extends JViewLegacy
|
||||
|
||||
/**
|
||||
* Prepares the document
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _prepareDocument()
|
||||
{
|
||||
|
@ -20,25 +20,33 @@ class WeblinksViewWeblink extends JViewLegacy
|
||||
|
||||
protected $item;
|
||||
|
||||
/**
|
||||
* Display the view.
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
// Get some data from the models
|
||||
$item = $this->get('Item');
|
||||
$item = $this->get('Item');
|
||||
|
||||
if ($this->getLayout() == 'edit')
|
||||
{
|
||||
$this->_displayEdit($tpl);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($item->url)
|
||||
{
|
||||
// redirects to url if matching id found
|
||||
// Redirects to url if matching id found
|
||||
JFactory::getApplication()->redirect($item->url);
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO create proper error handling
|
||||
// @TODO create proper error handling
|
||||
JFactory::getApplication()->redirect(JRoute::_('index.php'), JText::_('COM_WEBLINKS_ERROR_WEBLINK_NOT_FOUND'), 'notice');
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user