32
1
mirror of https://github.com/joomla-extensions/weblinks.git synced 2025-01-29 15:28:27 +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:
zero-24 2016-07-03 12:07:25 +02:00 committed by Chris Davenport
parent 8688bfd9cc
commit 77d2b1fbf9
6 changed files with 90 additions and 65 deletions

View File

@ -259,7 +259,11 @@ class WeblinksRouter extends JComponentRouterBase
/** /**
* Weblinks router functions * 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. * for old SEF extensions.
* *
* @deprecated 4.0 Use Class based routers instead * @deprecated 4.0 Use Class based routers instead
@ -271,6 +275,18 @@ function WeblinksBuildRoute(&$query)
return $router->build($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) function WeblinksParseRoute($segments)
{ {
$router = new WeblinksRouter; $router = new WeblinksRouter;

View File

@ -54,7 +54,6 @@ $listDirn = $this->escape($this->state->get('list.direction'));
</fieldset> </fieldset>
<?php endif; ?> <?php endif; ?>
<ul class="category list-striped list-condensed"> <ul class="category list-striped list-condensed">
<?php foreach ($this->items as $i => $item) : ?> <?php foreach ($this->items as $i => $item) : ?>
<?php if (in_array($item->access, $this->user->getAuthorisedViewLevels())) : ?> <?php if (in_array($item->access, $this->user->getAuthorisedViewLevels())) : ?>
<?php if ($this->items[$i]->state == 0) : ?> <?php if ($this->items[$i]->state == 0) : ?>
@ -84,22 +83,21 @@ $listDirn = $this->escape($this->state->get('list.direction'));
<?php echo '<img src="' . $this->params->get('link_icons') . '" alt="' . JText::_('COM_WEBLINKS_LINK') . '" />'; ?> <?php echo '<img src="' . $this->params->get('link_icons') . '" alt="' . JText::_('COM_WEBLINKS_LINK') . '" />'; ?>
<?php endif; ?> <?php endif; ?>
<?php endif; ?> <?php endif; ?>
<?php <?php // Compute the correct link ?>
// Compute the correct link <?php $menuclass = 'category' . $this->pageclass_sfx; ?>
$menuclass = 'category' . $this->pageclass_sfx; <?php $link = $item->link; ?>
$link = $item->link; <?php $width = $item->params->get('width'); ?>
$width = $item->params->get('width'); <?php $height = $item->params->get('height'); ?>
$height = $item->params->get('height'); <?php if ($width == null || $height == null) : ?>
if ($width == null || $height == null) <?php $width = 600; ?>
{ <?php $height = 500; ?>
$width = 600; <?php endif; ?>
$height = 500; <?php if ($this->items[$i]->state == 0) : ?>
}
if ($this->items[$i]->state == 0) : ?>
<span class="label label-warning"><?php echo JText::_('JUNPUBLISHED'); ?></span> <span class="label label-warning"><?php echo JText::_('JUNPUBLISHED'); ?></span>
<?php endif; ?> <?php endif; ?>
<?php switch ($item->params->get('target', $this->params->get('target'))) <?php
switch ($item->params->get('target', $this->params->get('target')))
{ {
case 1: case 1:
// Open in a new window // Open in a new window
@ -133,38 +131,32 @@ $listDirn = $this->escape($this->state->get('list.direction'));
<?php $this->item->tagLayout = new JLayoutFile('joomla.content.tags'); ?> <?php $this->item->tagLayout = new JLayoutFile('joomla.content.tags'); ?>
<?php echo $this->item->tagLayout->render($tagsData); ?> <?php echo $this->item->tagLayout->render($tagsData); ?>
<?php endif; ?> <?php endif; ?>
<?php if (($this->params->get('show_link_description')) and ($item->description != '')) : ?> <?php if (($this->params->get('show_link_description')) and ($item->description != '')) : ?>
<?php $images = json_decode($item->images); ?> <?php $images = json_decode($item->images); ?>
<?php if (isset($images->image_first) and !empty($images->image_first)) : ?> <?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; ?> <?php $imgfloat = (empty($images->float_first)) ? $this->params->get('float_first') : $images->float_first; ?>
<div class="img-intro-<?php echo htmlspecialchars($imgfloat); ?>"> <img <div class="img-intro-<?php echo htmlspecialchars($imgfloat); ?>"> <img
<?php if ($images->image_first_caption): <?php if ($images->image_first_caption) : ?>
echo 'class="caption"'.' title="' .htmlspecialchars($images->image_first_caption) .'"'; <?php echo 'class="caption" title="' . htmlspecialchars($images->image_first_caption) . '"'; ?>
endif; ?> <?php endif; ?>
src="<?php echo htmlspecialchars($images->image_first); ?>" alt="<?php echo htmlspecialchars($images->image_first_alt); ?>"/> </div> src="<?php echo htmlspecialchars($images->image_first); ?>" alt="<?php echo htmlspecialchars($images->image_first_alt); ?>"/> </div>
<?php endif; ?> <?php endif; ?>
<?php if (isset($images->image_second) and !empty($images->image_second)) : ?> <?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; ?> <?php $imgfloat = (empty($images->float_second)) ? $this->params->get('float_second') : $images->float_second; ?>
<div class="pull-<?php echo htmlspecialchars($imgfloat); ?> item-image"> <img <div class="pull-<?php echo htmlspecialchars($imgfloat); ?> item-image"> <img
<?php if ($images->image_second_caption): <?php if ($images->image_second_caption) : ?>
echo 'class="caption"'.' title="' .htmlspecialchars($images->image_second_caption) .'"'; <?php echo 'class="caption" title="' . htmlspecialchars($images->image_second_caption) . '"'; ?>
endif; ?> <?php endif; ?>
src="<?php echo htmlspecialchars($images->image_second); ?>" alt="<?php echo htmlspecialchars($images->image_second_alt); ?>"/> </div> src="<?php echo htmlspecialchars($images->image_second); ?>" alt="<?php echo htmlspecialchars($images->image_second_alt); ?>"/> </div>
<?php endif; ?> <?php endif; ?>
<?php echo $item->description; ?> <?php echo $item->description; ?>
<?php endif; ?> <?php endif; ?>
</li> </li>
<?php endif;?> <?php endif;?>
<?php endforeach; ?> <?php endforeach; ?>
</ul> </ul>
<?php // Code to add a link to submit a weblink. ?> <?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')) : ?> <?php if ($this->params->get('show_pagination')) : ?>
<div class="pagination"> <div class="pagination">
<?php if ($this->params->def('show_pagination_results', 1)) : ?> <?php if ($this->params->def('show_pagination_results', 1)) : ?>

View File

@ -24,6 +24,13 @@ class WeblinksViewForm extends JViewLegacy
protected $state; 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) public function display($tpl = null)
{ {
$user = JFactory::getUser(); $user = JFactory::getUser();
@ -78,6 +85,8 @@ class WeblinksViewForm extends JViewLegacy
/** /**
* Prepares the document * Prepares the document
*
* @return void
*/ */
protected function _prepareDocument() protected function _prepareDocument()
{ {

View File

@ -20,6 +20,13 @@ class WeblinksViewWeblink extends JViewLegacy
protected $item; 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) public function display($tpl = null)
{ {
// Get some data from the models // Get some data from the models
@ -28,17 +35,18 @@ class WeblinksViewWeblink extends JViewLegacy
if ($this->getLayout() == 'edit') if ($this->getLayout() == 'edit')
{ {
$this->_displayEdit($tpl); $this->_displayEdit($tpl);
return; return;
} }
if ($item->url) if ($item->url)
{ {
// redirects to url if matching id found // Redirects to url if matching id found
JFactory::getApplication()->redirect($item->url); JFactory::getApplication()->redirect($item->url);
} }
else 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'); JFactory::getApplication()->redirect(JRoute::_('index.php'), JText::_('COM_WEBLINKS_ERROR_WEBLINK_NOT_FOUND'), 'notice');
} }
} }