first commit

This commit is contained in:
2025-07-22 15:41:16 +02:00
commit 2a40a54622
81 changed files with 5614 additions and 0 deletions

View File

@ -0,0 +1,114 @@
<?php
/**
* @version CVS: 1.0.0
* @package Com_Circolari
* @author Tommaso Cippitelli <tommaso.cippitelli@protocollicreativi.it>
* @copyright 2025 Tommaso Cippitelli
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Pcrt\Component\Circolari\Administrator\View\Circolare;
// No direct access
defined('_JEXEC') or die;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use \Joomla\CMS\Toolbar\ToolbarHelper;
use \Joomla\CMS\Factory;
use \Pcrt\Component\Circolari\Administrator\Helper\CircolariHelper;
use \Joomla\CMS\Language\Text;
/**
* View class for a single Circolare.
*
* @since 1.0.0
*/
class HtmlView extends BaseHtmlView
{
protected $state;
protected $item;
protected $form;
/**
* Display the view
*
* @param string $tpl Template name
*
* @return void
*
* @throws Exception
*/
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')))
{
throw new \Exception(implode("\n", $errors));
}
$this->addToolbar();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @return void
*
* @throws Exception
*/
protected function addToolbar()
{
Factory::getApplication()->input->set('hidemainmenu', true);
$user = Factory::getApplication()->getIdentity();
$isNew = ($this->item->id == 0);
if (isset($this->item->checked_out))
{
$checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id'));
}
else
{
$checkedOut = false;
}
$canDo = CircolariHelper::getActions();
ToolbarHelper::title(Text::_('COM_CIRCOLARI_TITLE_CIRCOLARE'), "generic");
// If not checked out, can save the item.
if (!$checkedOut && ($canDo->get('core.edit') || ($canDo->get('core.create'))))
{
ToolbarHelper::apply('circolare.apply', 'JTOOLBAR_APPLY');
ToolbarHelper::save('circolare.save', 'JTOOLBAR_SAVE');
}
if (!$checkedOut && ($canDo->get('core.create')))
{
ToolbarHelper::custom('circolare.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false);
}
// If an existing item, can save to a copy.
if (!$isNew && $canDo->get('core.create'))
{
ToolbarHelper::custom('circolare.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false);
}
if (empty($this->item->id))
{
ToolbarHelper::cancel('circolare.cancel', 'JTOOLBAR_CANCEL');
}
else
{
ToolbarHelper::cancel('circolare.cancel', 'JTOOLBAR_CLOSE');
}
}
}

View File

@ -0,0 +1,183 @@
<?php
/**
* @version CVS: 1.0.0
* @package Com_Circolari
* @author Tommaso Cippitelli <tommaso.cippitelli@protocollicreativi.it>
* @copyright 2025 Tommaso Cippitelli
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Pcrt\Component\Circolari\Administrator\View\Circolares;
// No direct access
defined('_JEXEC') or die;
use \Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use \Pcrt\Component\Circolari\Administrator\Helper\CircolariHelper;
use \Joomla\CMS\Toolbar\Toolbar;
use \Joomla\CMS\Toolbar\ToolbarHelper;
use \Joomla\CMS\Language\Text;
use \Joomla\Component\Content\Administrator\Extension\ContentComponent;
use \Joomla\CMS\Form\Form;
use \Joomla\CMS\HTML\Helpers\Sidebar;
/**
* View class for a list of Circolares.
*
* @since 1.0.0
*/
class HtmlView extends BaseHtmlView
{
protected $items;
protected $pagination;
protected $state;
/**
* Display the view
*
* @param string $tpl Template name
*
* @return void
*
* @throws Exception
*/
public function display($tpl = null)
{
$this->state = $this->get('State');
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
throw new \Exception(implode("\n", $errors));
}
$this->addToolbar();
$this->sidebar = Sidebar::render();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @return void
*
* @since 1.0.0
*/
protected function addToolbar()
{
$state = $this->get('State');
$canDo = CircolariHelper::getActions();
ToolbarHelper::title(Text::_('COM_CIRCOLARI_TITLE_CIRCOLARES'), "generic");
$toolbar = Toolbar::getInstance('toolbar');
// Check if the form exists before showing the add/edit buttons
$formPath = JPATH_COMPONENT_ADMINISTRATOR . '/src/View/Circolares';
if (file_exists($formPath))
{
if ($canDo->get('core.create'))
{
$toolbar->addNew('circolare.add');
}
}
if ($canDo->get('core.edit.state'))
{
$dropdown = $toolbar->dropdownButton('status-group')
->text('JTOOLBAR_CHANGE_STATUS')
->toggleSplit(false)
->icon('fas fa-ellipsis-h')
->buttonClass('btn btn-action')
->listCheck(true);
$childBar = $dropdown->getChildToolbar();
if (isset($this->items[0]->state))
{
$childBar->publish('circolares.publish')->listCheck(true);
$childBar->unpublish('circolares.unpublish')->listCheck(true);
$childBar->archive('circolares.archive')->listCheck(true);
}
elseif (isset($this->items[0]))
{
// If this component does not use state then show a direct delete button as we can not trash
$toolbar->delete('circolares.delete')
->text('JTOOLBAR_EMPTY_TRASH')
->message('JGLOBAL_CONFIRM_DELETE')
->listCheck(true);
}
$childBar->standardButton('duplicate')
->text('JTOOLBAR_DUPLICATE')
->icon('fas fa-copy')
->task('circolares.duplicate')
->listCheck(true);
if (isset($this->items[0]->checked_out))
{
$childBar->checkin('circolares.checkin')->listCheck(true);
}
if (isset($this->items[0]->state))
{
$childBar->trash('circolares.trash')->listCheck(true);
}
}
// Show trash and delete for components that uses the state field
if (isset($this->items[0]->state))
{
if ($this->state->get('filter.state') == ContentComponent::CONDITION_TRASHED && $canDo->get('core.delete'))
{
$toolbar->delete('circolares.delete')
->text('JTOOLBAR_EMPTY_TRASH')
->message('JGLOBAL_CONFIRM_DELETE')
->listCheck(true);
}
}
if ($canDo->get('core.admin'))
{
$toolbar->preferences('com_circolari');
}
// Set sidebar action
Sidebar::setAction('index.php?option=com_circolari&view=circolares');
}
/**
* Method to order fields
*
* @return void
*/
protected function getSortFields()
{
return array(
'a.`id`' => Text::_('JGRID_HEADING_ID'),
'a.`state`' => Text::_('JSTATUS'),
'a.`ordering`' => Text::_('JGRID_HEADING_ORDERING'),
);
}
/**
* Check if state is set
*
* @param mixed $state State
*
* @return bool
*/
public function getState($state)
{
return isset($this->state->{$state}) ? $this->state->{$state} : false;
}
}

View File

@ -0,0 +1,114 @@
<?php
/**
* @version CVS: 1.0.0
* @package Com_Circolari
* @author Eddy Prosperi <eddy.prosperi@protocollicreativi.it>
* @copyright 2024 Eddy Prosperi
* @license GNU General Public License versione 2 o successiva; vedi LICENSE.txt
*/
namespace Pcrt\Component\Circolari\Administrator\View\Firmatipo;
// No direct access
defined('_JEXEC') or die;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use \Joomla\CMS\Toolbar\ToolbarHelper;
use \Joomla\CMS\Factory;
use \Pcrt\Component\Circolari\Administrator\Helper\CircolariHelper;
use \Joomla\CMS\Language\Text;
/**
* View class HtmlView a single Firmatipo.
*
* @since 1.0.0
*/
class HtmlView extends BaseHtmlView
{
protected $state;
protected $item;
protected $form;
/**
* Display the view
*
* @param string $tpl Template name
*
* @return void
*
* @throws Exception
*/
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')))
{
throw new \Exception(implode("\n", $errors));
}
$this->addToolbar();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @return void
*
* @throws Exception
*/
protected function addToolbar()
{
Factory::getApplication()->input->set('hidemainmenu', true);
$user = Factory::getApplication()->getIdentity();
$isNew = ($this->item->id == 0);
if (isset($this->item->checked_out))
{
$checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id'));
}
else
{
$checkedOut = false;
}
$canDo = CircolariHelper::getActions();
ToolbarHelper::title(Text::_('Firma'), "generic");
// If not checked out, can save the item.
if (!$checkedOut && ($canDo->get('core.edit') || ($canDo->get('core.create'))))
{
ToolbarHelper::apply('firmatipo.apply', 'JTOOLBAR_APPLY');
ToolbarHelper::save('firmatipo.save', 'JTOOLBAR_SAVE');
}
if (!$checkedOut && ($canDo->get('core.create')))
{
ToolbarHelper::custom('firmatipo.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false);
}
// If an existing item, can save to a copy.
if (!$isNew && $canDo->get('core.create'))
{
ToolbarHelper::custom('firmatipo.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false);
}
if (empty($this->item->id))
{
ToolbarHelper::cancel('firmatipo.cancel', 'JTOOLBAR_CANCEL');
}
else
{
ToolbarHelper::cancel('firmatipo.cancel', 'JTOOLBAR_CLOSE');
}
}
}

View File

@ -0,0 +1,177 @@
<?php
/**
* @version CVS: 1.0.0
* @package Com_Circolari
* @author Eddy Prosperi <eddy.prosperi@protocollicreativi.it>
* @copyright 2024 Eddy Prosperi
* @license GNU General Public License versione 2 o successiva; vedi LICENSE.txt
*/
namespace Pcrt\Component\Circolari\Administrator\View\Firmetipi;
// No direct access
defined('_JEXEC') or die;
use \Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use \Pcrt\Component\Circolari\Administrator\Helper\CircolariHelper;
use \Joomla\CMS\Toolbar\Toolbar;
use \Joomla\CMS\Toolbar\ToolbarHelper;
use \Joomla\CMS\Language\Text;
use \Joomla\Component\Content\Administrator\Extension\ContentComponent;
use \Joomla\CMS\Form\Form;
use \Joomla\CMS\HTML\Helpers\Sidebar;
/**
* View class HtmlView a list of Firmetipi.
*
* @since 1.0.0
*/
class HtmlView extends BaseHtmlView
{
protected $items;
protected $pagination;
protected $state;
/**
* Display the view
*
* @param string $tpl Template name
*
* @return void
*
* @throws Exception
*/
public function display($tpl = null)
{
$this->state = $this->get('State');
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
throw new \Exception(implode("\n", $errors));
}
$this->addToolbar();
$this->sidebar = Sidebar::render();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @return void
*
* @since 1.0.0
*/
protected function addToolbar()
{
$state = $this->get('State');
$canDo = CircolariHelper::getActions();
ToolbarHelper::title(Text::_('Firme'), "generic");
$toolbar = Toolbar::getInstance('toolbar');
// Check if the form exists before showing the add/edit buttons
$formPath = JPATH_COMPONENT_ADMINISTRATOR . '/src/View/Firmetipi';
if (file_exists($formPath))
{
if ($canDo->get('core.create'))
{
$toolbar->addNew('firmatipo.add');
}
}
if ($canDo->get('core.edit.state'))
{
$dropdown = $toolbar->dropdownButton('status-group')
->text('JTOOLBAR_CHANGE_STATUS')
->toggleSplit(false)
->icon('fas fa-ellipsis-h')
->buttonClass('btn btn-action')
->listCheck(true);
$childBar = $dropdown->getChildToolbar();
if (isset($this->items[0]->state))
{
$childBar->publish('firmetipi.publish')->listCheck(true);
$childBar->unpublish('firmetipi.unpublish')->listCheck(true);
$childBar->archive('firmetipi.archive')->listCheck(true);
}
$childBar->standardButton('duplicate')
->text('JTOOLBAR_DUPLICATE')
->icon('fas fa-copy')
->task('firmetipi.duplicate')
->listCheck(true);
if (isset($this->items[0]->checked_out))
{
$childBar->checkin('firmetipi.checkin')->listCheck(true);
}
if (isset($this->items[0]->state))
{
$childBar->trash('firmetipi.trash')->listCheck(true);
}
}
// Show trash and delete for components that uses the state field
if (isset($this->items[0]->state))
{
if ($this->state->get('filter.state') == ContentComponent::CONDITION_TRASHED && $canDo->get('core.delete'))
{
$toolbar->delete('firmetipi.delete')
->text('JTOOLBAR_EMPTY_TRASH')
->message('JGLOBAL_CONFIRM_DELETE')
->listCheck(true);
}
}
if ($canDo->get('core.admin'))
{
$toolbar->preferences('com_circolari');
}
// Set sidebar action
Sidebar::setAction('index.php?option=com_circolari&view=firmetipi');
}
/**
* Method to order fields
*
* @return void
*/
protected function getSortFields()
{
return array(
'a.`id`' => Text::_('JGRID_HEADING_ID'),
'a.`state`' => Text::_('JSTATUS'),
'a.`ordering`' => Text::_('JGRID_HEADING_ORDERING'),
'a.`nome`' => Text::_('COM_HIGHLIGHTS_ETICHETTE_NOME'),
'a.`lingua`' => Text::_('COM_HIGHLIGHTS_ETICHETTE_LINGUA'),
);
}
/**
* Check if state is set
*
* @param mixed $state State
*
* @return bool
*/
public function getState($state)
{
return isset($this->state->{$state}) ? $this->state->{$state} : false;
}
}