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

1
site/forms/index.html Normal file
View File

@ -0,0 +1 @@
<html><body></body></html>

View File

@ -0,0 +1,43 @@
COM_CIRCOLARI = "Circolari"
COM_CIRCOLARI_ITEM_SAVED_SUCCESSFULLY = "Item saved successfully"
COM_CIRCOLARI_ITEM_DELETED_SUCCESSFULLY = "Item deleted successfully"
COM_CIRCOLARI_ITEM_DELETED_UNSUCCESSFULLY = "Could not delete item"
COM_CIRCOLARI_ITEM_DOESNT_EXIST = "Item does not exist"
COM_CIRCOLARI_ITEM_NOT_LOADED = "Could not load the item"
COM_CIRCOLARI_VIEW_FILE = "[View File]"
COM_CIRCOLARI_ADD_ITEM = "Add"
COM_CIRCOLARI_EDIT_ITEM = "Edit"
COM_CIRCOLARI_DELETE_ITEM = "Delete"
COM_CIRCOLARI_DELETE_MESSAGE = "Are you sure that you want delete this item?"
COM_CIRCOLARI_DELETE_CONFIRM = "You're about to delete the item <strong>#%s</strong>. Are you sure?"
COM_CIRCOLARI_PUBLISH_ITEM = "Publish"
COM_CIRCOLARI_UNPUBLISH_ITEM = "Unpublish"
COM_CIRCOLARI_NO_ITEMS = "There are no items in the list"
COM_CIRCOLARI_SEARCH_TOOLS = "Search Tools"
COM_CIRCOLARI_SEARCH_TOOLS_DESC = ""
COM_CIRCOLARI_SEARCH_FILTER_SUBMIT = "Search"
COM_CIRCOLARI_SEARCH_FILTER_CLEAR = "Clear"
COM_CIRCOLARI_SEARCH_FILTER_DATE_FORMAT = "Dates should be in this format: \"YYYY-MM-DD\". Some filter fields have been ignored."
COM_CIRCOLARI_ERROR_MESSAGE_NOT_AUTHORISED = "You don't have permission to access this. Please contact a website administrator if this is incorrect."
COM_CIRCOLARI_ADD_ITEM_TITLE = "Add"
COM_CIRCOLARI_EDIT_ITEM_TITLE = "Edit %s"
COM_CIRCOLARI_ACTION_PERMISSIONS_LABEL = "Permissions"
COM_CIRCOLARI_VALIDATION_FORM_FAILED = "Invalid form"
COM_CIRCOLARI_CHECKEDIN_SUCCESSFULLY = "Item successfully checked in"
COM_CIRCOLARI_FORM_LBL_CIRCOLARE_ID="ID"
COM_CIRCOLARI_FORM_LBL_CIRCOLARE_STATE="State"
COM_CIRCOLARI_FORM_LBL_CIRCOLARE_ORDERING="Order"
COM_CIRCOLARI_FORM_LBL_CIRCOLARE_CHECKED_OUT="N/A"
COM_CIRCOLARI_FORM_LBL_CIRCOLARE_CHECKED_OUT_TIME="N/A"
COM_CIRCOLARI_FORM_LBL_CIRCOLARE_CREATED_BY="Created by"
COM_CIRCOLARI_FORM_LBL_CIRCOLARE_MODIFIED_BY="Modified by"
COM_CIRCOLARI_FORM_LBL_CIRCOLARE_TITLE="Title"
COM_CIRCOLARI_FORM_LBL_CIRCOLARE_DESCRIPTION="Description"
COM_CIRCOLARI_FORM_LBL_CIRCOLARE_ATTACHMENT="Attachment"
COM_CIRCOLARI_FORM_LBL_CIRCOLARE_IMAGE="Image"

View File

@ -0,0 +1,43 @@
COM_CIRCOLARI = "Circolari"
COM_CIRCOLARI_ITEM_SAVED_SUCCESSFULLY = "Item saved successfully"
COM_CIRCOLARI_ITEM_DELETED_SUCCESSFULLY = "Item deleted successfully"
COM_CIRCOLARI_ITEM_DELETED_UNSUCCESSFULLY = "Could not delete item"
COM_CIRCOLARI_ITEM_DOESNT_EXIST = "Item does not exist"
COM_CIRCOLARI_ITEM_NOT_LOADED = "Could not load the item"
COM_CIRCOLARI_VIEW_FILE = "[View File]"
COM_CIRCOLARI_ADD_ITEM = "Add"
COM_CIRCOLARI_EDIT_ITEM = "Edit"
COM_CIRCOLARI_DELETE_ITEM = "Delete"
COM_CIRCOLARI_DELETE_MESSAGE = "Are you sure that you want delete this item?"
COM_CIRCOLARI_DELETE_CONFIRM = "You're about to delete the item <strong>#%s</strong>. Are you sure?"
COM_CIRCOLARI_PUBLISH_ITEM = "Publish"
COM_CIRCOLARI_UNPUBLISH_ITEM = "Unpublish"
COM_CIRCOLARI_NO_ITEMS = "There are no items in the list"
COM_CIRCOLARI_SEARCH_TOOLS = "Search Tools"
COM_CIRCOLARI_SEARCH_TOOLS_DESC = ""
COM_CIRCOLARI_SEARCH_FILTER_SUBMIT = "Search"
COM_CIRCOLARI_SEARCH_FILTER_CLEAR = "Clear"
COM_CIRCOLARI_SEARCH_FILTER_DATE_FORMAT = "Dates should be in this format: \"YYYY-MM-DD\". Some filter fields have been ignored."
COM_CIRCOLARI_ERROR_MESSAGE_NOT_AUTHORISED = "You don't have permission to access this. Please contact a website administrator if this is incorrect."
COM_CIRCOLARI_ADD_ITEM_TITLE = "Add"
COM_CIRCOLARI_EDIT_ITEM_TITLE = "Edit %s"
COM_CIRCOLARI_ACTION_PERMISSIONS_LABEL = "Permissions"
COM_CIRCOLARI_VALIDATION_FORM_FAILED = "Invalid form"
COM_CIRCOLARI_CHECKEDIN_SUCCESSFULLY = "Item successfully checked in"
COM_CIRCOLARI_FORM_LBL_CIRCOLARE_ID="ID"
COM_CIRCOLARI_FORM_LBL_CIRCOLARE_STATE="State"
COM_CIRCOLARI_FORM_LBL_CIRCOLARE_ORDERING="Order"
COM_CIRCOLARI_FORM_LBL_CIRCOLARE_CHECKED_OUT="N/A"
COM_CIRCOLARI_FORM_LBL_CIRCOLARE_CHECKED_OUT_TIME="N/A"
COM_CIRCOLARI_FORM_LBL_CIRCOLARE_CREATED_BY="Created by"
COM_CIRCOLARI_FORM_LBL_CIRCOLARE_MODIFIED_BY="Modified by"
COM_CIRCOLARI_FORM_LBL_CIRCOLARE_TITLE="Title"
COM_CIRCOLARI_FORM_LBL_CIRCOLARE_DESCRIPTION="Description"
COM_CIRCOLARI_FORM_LBL_CIRCOLARE_ATTACHMENT="Attachment"
COM_CIRCOLARI_FORM_LBL_CIRCOLARE_IMAGE="Image"

View File

@ -0,0 +1,64 @@
<?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\Site\Controller;
\defined('_JEXEC') or die;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
/**
* Display Component Controller
*
* @since 1.0.0
*/
class DisplayController extends \Joomla\CMS\MVC\Controller\BaseController
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration settings.
* Recognized key values include 'name', 'default_task', 'model_path', and
* 'view_path' (this list is not meant to be comprehensive).
* @param MVCFactoryInterface $factory The factory.
* @param CMSApplication $app The JApplication for the dispatcher
* @param Input $input Input
*
* @since 1.0.0
*/
public function __construct($config = array(), ?MVCFactoryInterface $factory = null, $app = null, $input = null)
{
parent::__construct($config, $factory, $app, $input);
}
/**
* Method to display a view.
*
* @param boolean $cachable If true, the view output will be cached.
* @param boolean $urlparams An array of safe URL parameters and their variable types, for valid values see {@link InputFilter::clean()}.
*
* @return \Joomla\CMS\MVC\Controller\BaseController This object to support chaining.
*
* @since 1.0.0
*/
public function display($cachable = false, $urlparams = false)
{
$view = $this->input->getCmd('view', 'circolares');
$view = $view == "featured" ? 'circolares' : $view;
$this->input->set('view', $view);
parent::display($cachable, $urlparams);
return $this;
}
}

View File

@ -0,0 +1,67 @@
<?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\Site\Field;
defined('JPATH_BASE') or die;
use \Joomla\CMS\Factory;
use \Joomla\CMS\Form\FormField;
use \Joomla\CMS\User\UserFactoryInterface;
/**
* Supports an HTML select list of categories
*
* @since 1.0.0
*/
class CreatedbyField extends FormField
{
/**
* The form field type.
*
* @var string
* @since 1.0.0
*/
protected $type = 'createdby';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 1.0.0
*/
protected function getInput()
{
// Initialize variables.
$html = array();
// Load user
$user_id = $this->value;
if ($user_id)
{
$container = \Joomla\CMS\Factory::getContainer();
$userFactory = $container->get(UserFactoryInterface::class);
$user = $userFactory->loadUserById($user_id);
}
else
{
$user = Factory::getApplication()->getIdentity();
$html[] = '<input type="hidden" name="' . $this->name . '" value="' . $user->id . '" />';
}
if (!$this->hidden)
{
$html[] = "<div>" . $user->name . " (" . $user->username . ")</div>";
}
return implode($html);
}
}

View File

@ -0,0 +1,296 @@
<?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\Site\Field;
defined('JPATH_BASE') or die;
use \Joomla\CMS\Factory;
use \Joomla\CMS\HTML\HTMLHelper;
use \Joomla\CMS\Language\Text;
use \Joomla\CMS\Form\Field\ListField;
/**
* Supports a value from an external table
*
* @since 1.0.0
*/
class ForeignKeyField extends ListField
{
/**
* The form field type.
*
* @var string
* @since 1.0.0
*/
protected $type = 'foreignkey';
protected $layout = 'joomla.form.field.list-fancy-select';
/**
* The translate.
*
* @var boolean
* @since 1.0.0
*/
protected $translate = true;
protected $header = false;
private $input_type;
private $table;
private $key_field;
private $value_field;
private $option_key_field;
private $option_value_field;
private $condition;
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 1.0.0
*/
protected function processQuery()
{
// Type of input the field shows
$this->input_type = $this->getAttribute('input_type');
// Database Table
$this->table = $this->getAttribute('table');
// The field that the field will save on the database
$this->key_field = (string) $this->getAttribute('key_field');
// The column that the field shows in the input
$this->value_field = (string) $this->getAttribute('value_field');
// The option field that the field will save on the database
$this->option_key_field = (string) $this->getAttribute('option_key_field');
// The option value that the field shows in the input
$this->option_value_field = (string) $this->getAttribute('option_value_field');
// Flag to identify if the fk_value is multiple
$this->value_multiple = (int) $this->getAttribute('value_multiple', 0);
$this->required = (string) $this->getAttribute('required', 0);
// Flag to identify if the fk_value hides the trashed items
$this->hideTrashed = (int) $this->getAttribute('hide_trashed', 0);
// Flag to identify if the fk_value hides the unpublished items
$this->hideUnpublished = (int) $this->getAttribute('hide_unpublished', 0);
// Flag to identify if the fk_value hides the published items
$this->hidePublished = (int) $this->getAttribute('hide_published', 0);
// Flag to identify if the fk_value hides the archived items
$this->hideArchived = (int) $this->getAttribute('hide_archived', 0);
// Flag to identify if the fk has default order
$this->fk_ordering = (string) $this->getAttribute('fk_ordering');
// The where SQL for foreignkey
$this->condition = (string) $this->getAttribute('condition');
// Flag for translate options
$this->translate = (bool) $this->getAttribute('translate');
// Initialize variables.
$html = '';
$fk_value = '';
// Load all the field options
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
// Support for multiple fields on fk_values
if ($this->value_multiple == 1)
{
// Get the fields for multiple value
$this->value_fields = (string) $this->getAttribute('value_field_multiple');
$this->value_fields = explode(',', $this->value_fields);
$this->separator = (string) $this->getAttribute('separator');
$fk_value = ' CONCAT(';
foreach ($this->value_fields as $field)
{
$fk_value .= $db->quoteName($field) . ', \'' . $this->separator . '\', ';
}
$fk_value = substr($fk_value, 0, -(strlen($this->separator) + 6));
$fk_value .= ') AS ' . $db->quoteName($this->value_field);
}
else
{
$fk_value = $db->quoteName($this->value_field);
}
$query
->select(
array(
$db->quoteName($this->key_field),
$fk_value
)
)
->from($this->table);
if ($this->hideTrashed)
{
$query->where($db->quoteName('state') . ' != -2');
}
if ($this->hideUnpublished)
{
$query->where($db->quoteName('state') . ' != 0');
}
if ($this->hidePublished)
{
$query->where($db->quoteName('state') . ' != 1');
}
if ($this->hideArchived)
{
$query->where($db->quoteName('state') . ' != 2');
}
if ($this->fk_ordering)
{
$query->order($this->fk_ordering);
}
if($this->condition)
{
$query->where($this->condition);
}
return $query;
}
/**
* Method to get the field input for a foreignkey field.
*
* @return string The field input.
*
* @since 1.0.0
*/
protected function getInput()
{
$data = $this->getLayoutData();
if (!\is_array($this->value) && !empty($this->value))
{
if (\is_object($this->value))
{
$this->value = get_object_vars($this->value);
}
// String in format 2,5,4
if (\is_string($this->value))
{
$this->value = explode(',', $this->value);
}
// Integer is given
if (\is_int($this->value))
{
$this->value = array($this->value);
}
$data['value'] = $this->value;
}
$data['options'] = $this->getOptions();
return $this->getRenderer($this->layout)->render($data);
}
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 1.0.0
*/
protected function getOptions()
{
$options = array();
$db = Factory::getContainer()->get('DatabaseDriver');
try
{
$db->setQuery($this->processQuery());
$results = $db->loadObjectList();
}
catch (ExecutionFailureException $e)
{
Factory::getApplication()->enqueueMessage(Text::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error');
}
// Add header.
if (!empty($this->header))
{
$options[] = (object) ["value" => '', "text" => Text::_($this->header)];
}
if(!empty($this->option_value_field) || !empty($this->option_key_field))
{
$options[] = (object) ["value" => $this->option_key_field, "text" => Text::_($this->option_value_field)];
}
// Build the field options.
if (!empty($results))
{
foreach ($results as $item)
{
$options[] = (object) [
"value" => $item->{$this->key_field},
"text" => $this->translate == true ? Text::_($item->{$this->value_field}) : $item->{$this->value_field}
];
}
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
/**
* Wrapper method for getting attributes from the form element
*
* @param string $attr_name Attribute name
* @param mixed $default Optional value to return if attribute not found
*
* @return mixed The value of the attribute if it exists, null otherwise
*/
public function getAttribute($attr_name, $default = null)
{
if (!empty($this->element[$attr_name]))
{
return $this->element[$attr_name];
}
else
{
return $default;
}
}
}

View File

@ -0,0 +1,53 @@
<?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\Site\Field;
defined('JPATH_BASE') or die;
use \Joomla\CMS\Factory;
use \Joomla\CMS\Form\FormField;
/**
* Supports an HTML select list of categories
*
* @since 1.0.0
*/
class ModifiedbyField extends FormField
{
/**
* The form field type.
*
* @var string
* @since 1.0.0
*/
protected $type = 'modifiedby';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 1.0.0
*/
protected function getInput()
{
// Initialize variables.
$html = array();
$user = Factory::getApplication()->getIdentity();
$html[] = '<input type="hidden" name="' . $this->name . '" value="' . $user->id . '" />';
if (!$this->hidden)
{
$html[] = "<div>" . $user->name . " (" . $user->username . ")</div>";
}
return implode($html);
}
}

View File

@ -0,0 +1,83 @@
<?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\Site\Field;
defined('JPATH_BASE') or die;
use Joomla\CMS\Helper\UserGroupsHelper;
use \Joomla\CMS\Factory;
use Joomla\CMS\Form\Field\ListField;
/**
* Supports an HTML select list of categories
*
* @since 1.0.0
*/
class NestedparentField extends ListField
{
/**
* The form field type.
*
* @var string
* @since 1.0.0
*/
protected $type = 'nestedparent';
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 1.0.0
*/
protected function getOptions()
{
$options = array();
$table = $this->getAttribute('table');
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true)
->select('DISTINCT(a.id) AS value, a.title AS text, a.level, a.lft')
->from($table . ' AS a');
// Prevent parenting to children of this item.
if ($id = $this->form->getValue('id'))
{
$query->join('LEFT', $db->quoteName($table) . ' AS p ON p.id = ' . (int) $id)
->where('NOT(a.lft >= p.lft AND a.rgt <= p.rgt)');
}
$query->order('a.lft ASC');
// Get the options.
$db->setQuery($query);
try
{
$options = $db->loadObjectList();
}
catch (\RuntimeException $e)
{
\JError::raiseWarning(500, $e->getMessage());
}
// Pad the option text with spaces using depth level as a multiplier.
for ($i = 0, $n = count($options); $i < $n; $i++)
{
$options[$i]->text = str_repeat('- ', $options[$i]->level) . $options[$i]->text;
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
}

View File

@ -0,0 +1,49 @@
<?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\Site\Field;
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
use \Joomla\CMS\Language\Text;
use \Joomla\CMS\Form\FormField;
/**
* Class SubmitField
*
* @since 1.0.0
*/
class SubmitField extends FormField
{
protected $type = 'submit';
protected $value;
protected $for;
/**
* Get a form field markup for the input
*
* @return string
*/
public function getInput()
{
$this->value = $this->getAttribute('value');
return '<button id="' . $this->id . '"'
. ' name="submit_' . $this->for . '"'
. ' value="' . $this->value . '"'
. ' title="' . Text::_('JSEARCH_FILTER_SUBMIT') . '"'
. ' class="btn" style="margin-top: -10px;">'
. Text::_('JSEARCH_FILTER_SUBMIT')
. ' </button>';
}
}

View File

@ -0,0 +1,65 @@
<?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\Site\Field;
defined('JPATH_BASE') or die;
use \Joomla\CMS\Factory;
use \Joomla\CMS\Language\Text;
use \Joomla\CMS\Form\FormField;
use \Joomla\CMS\Date\Date;
use Joomla\CMS\HTML\HTMLHelper;
/**
* Supports an HTML select list of categories
*
* @since 1.0.0
*/
class TimecreatedField extends FormField
{
/**
* The form field type.
*
* @var string
* @since 1.0.0
*/
protected $type = 'timecreated';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 1.0.0
*/
protected function getInput()
{
// Initialize variables.
$html = array();
$time_created = $this->value;
if (!strtotime($time_created))
{
$time_created = Factory::getDate()->toSql();
$html[] = '<input type="hidden" name="' . $this->name . '" value="' . $time_created . '" />';
}
$hidden = (boolean) $this->element['hidden'];
if ($hidden == null || !$hidden)
{
$pretty_date = HTMLHelper::_('date', $time_created, Text::_('DATE_FORMAT_LC2'), true);
$html[] = "<div>" . $pretty_date . "</div>";
}
return implode($html);
}
}

View File

@ -0,0 +1,68 @@
<?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\Site\Field;
defined('JPATH_BASE') or die;
use \Joomla\CMS\Factory;
use \Joomla\CMS\Language\Text;
use \Joomla\CMS\Form\FormField;
use \Joomla\CMS\Date\Date;
use Joomla\CMS\HTML\HTMLHelper;
/**
* Supports an HTML select list of categories
*
* @since 1.0.0
*/
class TimeupdatedField extends FormField
{
/**
* The form field type.
*
* @var string
* @since 1.0.0
*/
protected $type = 'timeupdated';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 1.0.0
*/
protected function getInput()
{
// Initialize variables.
$html = array();
$old_time_updated = $this->value;
$hidden = (boolean) $this->element['hidden'];
if ($hidden == null || !$hidden)
{
if (!strtotime($old_time_updated))
{
$html[] = '-';
}
else
{
$pretty_date = HTMLHelper::_('date', $old_time_updated, Text::_('DATE_FORMAT_LC2'), true);
$html[] = "<div>" . $pretty_date . "</div>";
}
}
$time_updated = Factory::getDate()->toSql();
$html[] = '<input type="hidden" name="' . $this->name . '" value="' . $time_updated . '" />';
return implode($html);
}
}

View File

@ -0,0 +1 @@
<html><body></body></html>

View File

@ -0,0 +1,71 @@
<?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\Site\Helper;
defined('_JEXEC') or die;
use \Joomla\CMS\Factory;
use \Joomla\CMS\MVC\Model\BaseDatabaseModel;
/**
* Class CircolariFrontendHelper
*
* @since 1.0.0
*/
class CircolariHelper
{
/**
* Gets the files attached to an item
*
* @param int $pk The item's id
*
* @param string $table The table's name
*
* @param string $field The field's name
*
* @return array The files
*/
public static function getFiles($pk, $table, $field)
{
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
$query
->select($field)
->from($table)
->where('id = ' . (int) $pk);
$db->setQuery($query);
return explode(',', $db->loadResult());
}
/**
* Gets the edit permission for an user
*
* @param mixed $item The item
*
* @return bool
*/
public static function canUserEdit($item)
{
$permission = false;
$user = Factory::getApplication()->getIdentity();
if ($user->authorise('core.edit', 'com_circolari') || (isset($item->created_by) && $user->authorise('core.edit.own', 'com_circolari') && $item->created_by == $user->id) || $user->authorise('core.create', 'com_circolari'))
{
$permission = true;
}
return $permission;
}
}

View File

@ -0,0 +1 @@
<html><body></body></html>

View File

@ -0,0 +1,21 @@
<?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\Site\Service;
// No direct access
defined('_JEXEC') or die;
use \Joomla\CMS\Categories\Categories;
/**
* Content Component Category Tree
*
* @since 1.0.0
*/

View File

@ -0,0 +1,95 @@
<?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\Site\Service;
// No direct access
defined('_JEXEC') or die;
use Joomla\CMS\Component\Router\RouterViewConfiguration;
use Joomla\CMS\Component\Router\RouterView;
use Joomla\CMS\Component\Router\Rules\StandardRules;
use Joomla\CMS\Component\Router\Rules\NomenuRules;
use Joomla\CMS\Component\Router\Rules\MenuRules;
use Joomla\CMS\Factory;
use Joomla\CMS\Categories\Categories;
use Joomla\CMS\Application\SiteApplication;
use Joomla\CMS\Categories\CategoryFactoryInterface;
use Joomla\CMS\Categories\CategoryInterface;
use Joomla\Database\DatabaseInterface;
use Joomla\CMS\Menu\AbstractMenu;
use Joomla\CMS\Component\ComponentHelper;
/**
* Class CircolariRouter
*
*/
class Router extends RouterView
{
private $noIDs;
/**
* The category factory
*
* @var CategoryFactoryInterface
*
* @since 1.0.0
*/
private $categoryFactory;
/**
* The category cache
*
* @var array
*
* @since 1.0.0
*/
private $categoryCache = [];
public function __construct(SiteApplication $app, AbstractMenu $menu, CategoryFactoryInterface $categoryFactory, DatabaseInterface $db)
{
$params = ComponentHelper::getParams('com_circolari');
$this->noIDs = (bool) $params->get('sef_ids');
$this->categoryFactory = $categoryFactory;
parent::__construct($app, $menu);
$this->attachRule(new MenuRules($this));
$this->attachRule(new StandardRules($this));
$this->attachRule(new NomenuRules($this));
}
/**
* Method to get categories from cache
*
* @param array $options The options for retrieving categories
*
* @return CategoryInterface The object containing categories
*
* @since 1.0.0
*/
private function getCategories(array $options = []): CategoryInterface
{
$key = serialize($options);
if (!isset($this->categoryCache[$key]))
{
$this->categoryCache[$key] = $this->categoryFactory->createCategory($options);
}
return $this->categoryCache[$key];
}
}

1
site/tmpl/index.html Normal file
View File

@ -0,0 +1 @@
<html><body></body></html>