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
|
|
|
*
|
2016-11-28 22:13:39 +00:00
|
|
|
* @copyright Copyright (C) 2005 - 2016 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 Article 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 WeblinksViewForm extends JViewLegacy
|
|
|
|
{
|
|
|
|
protected $form;
|
|
|
|
|
|
|
|
protected $item;
|
|
|
|
|
|
|
|
protected $return_page;
|
|
|
|
|
|
|
|
protected $state;
|
|
|
|
|
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)
|
|
|
|
{
|
2014-09-01 14:48:14 +00:00
|
|
|
$user = JFactory::getUser();
|
2014-04-08 12:32:59 +00:00
|
|
|
|
|
|
|
// Get model data.
|
2014-09-01 14:48:14 +00:00
|
|
|
$this->state = $this->get('State');
|
|
|
|
$this->item = $this->get('Item');
|
|
|
|
$this->form = $this->get('Form');
|
|
|
|
$this->return_page = $this->get('ReturnPage');
|
2014-04-08 12:32:59 +00:00
|
|
|
|
|
|
|
if (empty($this->item->id))
|
|
|
|
{
|
|
|
|
$authorised = ($user->authorise('core.create', 'com_weblinks') || (count($user->getAuthorisedCategories('com_weblinks', 'core.create'))));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-07-03 10:07:25 +00:00
|
|
|
$authorised = $user->authorise('core.edit', 'com_weblinks.category.' . $this->item->catid);
|
2014-04-08 12:32:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($authorised !== true)
|
|
|
|
{
|
|
|
|
JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR'));
|
2014-12-04 19:43:05 +00:00
|
|
|
|
2014-04-08 12:32:59 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($this->item))
|
|
|
|
{
|
2016-07-04 21:32:27 +00:00
|
|
|
// Override the base weblink data with any data in the session.
|
2016-08-01 17:47:09 +00:00
|
|
|
$temp = (array) JFactory::getApplication()->getUserState('com_weblinks.edit.weblink.data', array());
|
|
|
|
|
2016-07-04 21:32:27 +00:00
|
|
|
foreach ($temp as $k => $v)
|
|
|
|
{
|
|
|
|
$this->item->$k = $v;
|
|
|
|
}
|
2016-08-01 17:47:09 +00:00
|
|
|
|
2014-04-08 12:32:59 +00:00
|
|
|
$this->form->bind($this->item);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check for errors.
|
|
|
|
if (count($errors = $this->get('Errors')))
|
|
|
|
{
|
|
|
|
JError::raiseWarning(500, implode("\n", $errors));
|
2014-09-01 14:48:14 +00:00
|
|
|
|
2014-04-08 12:32:59 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a shortcut to the parameters.
|
2014-09-01 14:48:14 +00:00
|
|
|
$params = &$this->state->params;
|
2014-04-08 12:32:59 +00:00
|
|
|
|
2016-07-03 10:07:25 +00:00
|
|
|
// Escape strings for HTML output
|
2014-04-08 12:32:59 +00:00
|
|
|
$this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
|
|
|
|
|
2014-09-01 14:48:14 +00:00
|
|
|
$this->params = $params;
|
|
|
|
$this->user = $user;
|
2014-04-08 12:32:59 +00:00
|
|
|
|
|
|
|
$this->_prepareDocument();
|
|
|
|
parent::display($tpl);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Prepares the document
|
2016-07-03 10:07:25 +00:00
|
|
|
*
|
|
|
|
* @return void
|
2014-04-08 12:32:59 +00:00
|
|
|
*/
|
|
|
|
protected function _prepareDocument()
|
|
|
|
{
|
2016-08-01 17:47:09 +00:00
|
|
|
$app = JFactory::getApplication();
|
|
|
|
$menus = $app->getMenu();
|
|
|
|
$title = null;
|
2014-04-08 12:32:59 +00:00
|
|
|
|
|
|
|
// Because the application sets a default page title,
|
|
|
|
// we need to get it from the menu item itself
|
|
|
|
$menu = $menus->getActive();
|
|
|
|
|
|
|
|
if (empty($this->item->id))
|
2014-09-01 14:48:14 +00:00
|
|
|
{
|
|
|
|
$head = JText::_('COM_WEBLINKS_FORM_SUBMIT_WEBLINK');
|
2014-04-08 12:32:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-09-01 14:48:14 +00:00
|
|
|
$head = JText::_('COM_WEBLINKS_FORM_EDIT_WEBLINK');
|
2014-04-08 12:32:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($menu)
|
|
|
|
{
|
|
|
|
$this->params->def('page_heading', $this->params->get('page_title', $menu->title));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->params->def('page_heading', $head);
|
|
|
|
}
|
|
|
|
|
|
|
|
$title = $this->params->def('page_title', $head);
|
2014-09-01 14:48:14 +00:00
|
|
|
|
|
|
|
if ($app->get('sitename_pagetitles', 0) == 1)
|
2014-04-08 12:32:59 +00:00
|
|
|
{
|
2014-09-01 14:48:14 +00:00
|
|
|
$title = JText::sprintf('JPAGETITLE', $app->get('sitename'), $title);
|
2014-04-08 12:32:59 +00:00
|
|
|
}
|
2014-09-01 14:48:14 +00:00
|
|
|
elseif ($app->get('sitename_pagetitles', 0) == 2)
|
2014-04-08 12:32:59 +00:00
|
|
|
{
|
2014-09-01 14:48:14 +00:00
|
|
|
$title = JText::sprintf('JPAGETITLE', $title, $app->get('sitename'));
|
2014-04-08 12:32:59 +00:00
|
|
|
}
|
2014-09-01 14:48:14 +00:00
|
|
|
|
2014-04-08 12:32:59 +00:00
|
|
|
$this->document->setTitle($title);
|
|
|
|
|
|
|
|
if ($this->params->get('menu-meta_description'))
|
|
|
|
{
|
|
|
|
$this->document->setDescription($this->params->get('menu-meta_description'));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->params->get('menu-meta_keywords'))
|
|
|
|
{
|
|
|
|
$this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
|
|
|
|
}
|
|
|
|
|
2014-12-04 19:43:05 +00:00
|
|
|
if ($this->params->get('robots'))
|
2014-04-08 12:32:59 +00:00
|
|
|
{
|
|
|
|
$this->document->setMetadata('robots', $this->params->get('robots'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|