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;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* View to edit a weblink.
|
|
|
|
*
|
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;
|
|
|
|
|
|
|
|
protected $form;
|
|
|
|
|
|
|
|
/**
|
2016-07-03 10:04:21 +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)
|
|
|
|
{
|
2016-07-03 10:04:21 +00:00
|
|
|
$this->state = $this->get('State');
|
|
|
|
$this->item = $this->get('Item');
|
|
|
|
$this->form = $this->get('Form');
|
2014-04-08 12:32:59 +00:00
|
|
|
|
|
|
|
// Check for errors.
|
|
|
|
if (count($errors = $this->get('Errors')))
|
|
|
|
{
|
|
|
|
JError::raiseError(500, implode("\n", $errors));
|
2016-07-03 10:04:21 +00:00
|
|
|
|
2014-04-08 12:32:59 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->addToolbar();
|
2016-07-03 10:04:21 +00:00
|
|
|
|
2014-04-08 12:32:59 +00:00
|
|
|
parent::display($tpl);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add the page title and toolbar.
|
|
|
|
*
|
2016-07-03 10:04:21 +00:00
|
|
|
* @return void
|
|
|
|
*
|
2014-04-08 12:32:59 +00:00
|
|
|
* @since 1.6
|
|
|
|
*/
|
|
|
|
protected function addToolbar()
|
|
|
|
{
|
|
|
|
JFactory::getApplication()->input->set('hidemainmenu', true);
|
|
|
|
|
2016-07-03 10:04:21 +00:00
|
|
|
$user = JFactory::getUser();
|
|
|
|
$isNew = ($this->item->id == 0);
|
|
|
|
$checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id'));
|
2014-04-08 12:32:59 +00:00
|
|
|
|
|
|
|
// Since we don't track these assets at the item level, use the category id.
|
2016-07-03 10:04:21 +00:00
|
|
|
$canDo = JHelperContent::getActions('com_weblinks', 'category', $this->item->catid);
|
2014-04-08 12:32:59 +00:00
|
|
|
|
2015-07-22 11:41:52 +00:00
|
|
|
JToolbarHelper::title($isNew ? JText::_('COM_WEBLINKS_MANAGER_WEBLINK_NEW') : JText::_('COM_WEBLINKS_MANAGER_WEBLINK_EDIT'), 'link weblinks');
|
2014-04-08 12:32:59 +00:00
|
|
|
|
|
|
|
// If not checked out, can save the item.
|
|
|
|
if (!$checkedOut && ($canDo->get('core.edit')||(count($user->getAuthorisedCategories('com_weblinks', 'core.create')))))
|
|
|
|
{
|
|
|
|
JToolbarHelper::apply('weblink.apply');
|
|
|
|
JToolbarHelper::save('weblink.save');
|
|
|
|
}
|
|
|
|
if (!$checkedOut && (count($user->getAuthorisedCategories('com_weblinks', 'core.create'))))
|
|
|
|
{
|
|
|
|
JToolbarHelper::save2new('weblink.save2new');
|
|
|
|
}
|
|
|
|
// If an existing item, can save to a copy.
|
|
|
|
if (!$isNew && (count($user->getAuthorisedCategories('com_weblinks', 'core.create')) > 0))
|
|
|
|
{
|
|
|
|
JToolbarHelper::save2copy('weblink.save2copy');
|
|
|
|
}
|
|
|
|
if (empty($this->item->id))
|
|
|
|
{
|
|
|
|
JToolbarHelper::cancel('weblink.cancel');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ($this->state->params->get('save_history', 0) && $user->authorise('core.edit'))
|
|
|
|
{
|
|
|
|
JToolbarHelper::versions('com_weblinks.weblink', $this->item->id);
|
|
|
|
}
|
|
|
|
|
|
|
|
JToolbarHelper::cancel('weblink.cancel', 'JTOOLBAR_CLOSE');
|
|
|
|
}
|
|
|
|
|
|
|
|
JToolbarHelper::divider();
|
|
|
|
JToolbarHelper::help('JHELP_COMPONENTS_WEBLINKS_LINKS_EDIT');
|
|
|
|
}
|
|
|
|
}
|