2014-04-08 12:32:59 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2016-12-01 07:21:47 +00:00
|
|
|
* @package Joomla.Administrator
|
|
|
|
* @subpackage Weblinks
|
2014-04-08 12:32:59 +00:00
|
|
|
*
|
2017-02-13 16:20:35 +00:00
|
|
|
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
|
2014-04-08 12:32:59 +00:00
|
|
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
defined('_JEXEC') or die;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* HTML View class for the WebLinks component
|
|
|
|
*
|
2014-12-04 19:43:05 +00:00
|
|
|
* @since 1.5
|
2014-04-08 12:32:59 +00:00
|
|
|
*/
|
|
|
|
class WeblinksViewWeblink extends JViewLegacy
|
|
|
|
{
|
|
|
|
protected $state;
|
|
|
|
|
|
|
|
protected $item;
|
|
|
|
|
2016-07-03 10:07:25 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2014-04-08 12:32:59 +00:00
|
|
|
public function display($tpl = null)
|
|
|
|
{
|
|
|
|
// Get some data from the models
|
2016-07-03 10:07:25 +00:00
|
|
|
$item = $this->get('Item');
|
2014-04-08 12:32:59 +00:00
|
|
|
|
|
|
|
if ($this->getLayout() == 'edit')
|
|
|
|
{
|
|
|
|
$this->_displayEdit($tpl);
|
2016-07-03 10:07:25 +00:00
|
|
|
|
2014-04-08 12:32:59 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($item->url)
|
|
|
|
{
|
2016-07-03 10:07:25 +00:00
|
|
|
// Redirects to url if matching id found
|
2014-04-08 12:32:59 +00:00
|
|
|
JFactory::getApplication()->redirect($item->url);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-07-03 10:07:25 +00:00
|
|
|
// @TODO create proper error handling
|
2014-04-08 12:32:59 +00:00
|
|
|
JFactory::getApplication()->redirect(JRoute::_('index.php'), JText::_('COM_WEBLINKS_ERROR_WEBLINK_NOT_FOUND'), 'notice');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|