mirror of
https://github.com/joomla-extensions/weblinks.git
synced 2024-05-29 04:30:46 +00:00
2247d9ba4d
* Make it joomla 4 compatible * Joomla 4 compatibility * Move to dispatcher * Move controller.php to DisplayController * Define default view for DisplayController * Move the model weblinks.php to WeblinksModel * Move the view weblinks list view view.html.php to HtmlView.php * Move the view templates like default.php to the right position * Move the weblinks controller weblins.php to WeblinksController.php * Move the weblink model weblink.php to WeblinkModel.php * Remove the get table function in the WeblinkModel * Moved the table weblink.php to WeblinkTable.php * Moved the controller weblink.php to WeblinkController.php * Moved the web link form view view.html.php to HtmlView.php * Move the weblink layouts to the right folder * Convert list template to Bootstrap 4 * Convert form layout to Bootstrap 4 * Move forms to root folder * Namespace field * Calling the parent check function in the table * Adapt travis file * Pass factory to parent class
120 lines
3.5 KiB
PHP
120 lines
3.5 KiB
PHP
<?php
|
|
/**
|
|
* @package Joomla.Administrator
|
|
* @subpackage Weblinks
|
|
*
|
|
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
|
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
|
*/
|
|
|
|
namespace Joomla\Component\Weblinks\Administrator\View\Weblink;
|
|
|
|
defined('_JEXEC') or die;
|
|
|
|
/**
|
|
* View to edit a weblink.
|
|
*
|
|
* @since 1.5
|
|
*/
|
|
class HtmlView extends \Joomla\CMS\MVC\View\HtmlView
|
|
{
|
|
protected $state;
|
|
|
|
protected $item;
|
|
|
|
protected $form;
|
|
|
|
/**
|
|
* 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)
|
|
{
|
|
$this->state = $this->get('State');
|
|
$this->item = $this->get('Item');
|
|
$this->form = $this->get('Form');
|
|
|
|
// Check for errors.
|
|
if (count($errors = $this->get('Errors')))
|
|
{
|
|
\JError::raiseError(500, implode("\n", $errors));
|
|
|
|
return false;
|
|
}
|
|
|
|
// If we are forcing a language in modal (used for associations).
|
|
if ($this->getLayout() === 'modal' && $forcedLanguage = \JFactory::getApplication()->input->get('forcedLanguage', '', 'cmd'))
|
|
{
|
|
// Set the language field to the forcedLanguage and disable changing it.
|
|
$this->form->setValue('language', null, $forcedLanguage);
|
|
$this->form->setFieldAttribute('language', 'readonly', 'true');
|
|
|
|
// Only allow to select categories with All language or with the forced language.
|
|
$this->form->setFieldAttribute('catid', 'language', '*,' . $forcedLanguage);
|
|
|
|
// Only allow to select tags with All language or with the forced language.
|
|
$this->form->setFieldAttribute('tags', 'language', '*,' . $forcedLanguage);
|
|
}
|
|
|
|
$this->addToolbar();
|
|
|
|
parent::display($tpl);
|
|
}
|
|
|
|
/**
|
|
* Add the page title and toolbar.
|
|
*
|
|
* @return void
|
|
*
|
|
* @since 1.6
|
|
*/
|
|
protected function addToolbar()
|
|
{
|
|
\JFactory::getApplication()->input->set('hidemainmenu', true);
|
|
|
|
$user = \JFactory::getUser();
|
|
$isNew = ($this->item->id == 0);
|
|
$checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id'));
|
|
|
|
// Since we don't track these assets at the item level, use the category id.
|
|
$canDo = \JHelperContent::getActions('com_weblinks', 'category', $this->item->catid);
|
|
|
|
\JToolbarHelper::title($isNew ? \JText::_('COM_WEBLINKS_MANAGER_WEBLINK_NEW') : \JText::_('COM_WEBLINKS_MANAGER_WEBLINK_EDIT'), 'link weblinks');
|
|
|
|
// 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');
|
|
}
|
|
}
|