primo commit

This commit is contained in:
2024-12-17 17:34:10 +01:00
commit e650f8df99
16435 changed files with 2451012 additions and 0 deletions

View File

@ -0,0 +1,50 @@
<?php
/**
* @package AllediaFramework
* @contact www.joomlashack.com, help@joomlashack.com
* @copyright 2016-2023 Joomlashack.com. All rights reserved
* @license https://www.gnu.org/licenses/gpl.html GNU/GPL
*
* This file is part of AllediaFramework.
*
* AllediaFramework is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* AllediaFramework is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AllediaFramework. If not, see <https://www.gnu.org/licenses/>.
*/
namespace Alledia\Framework\Joomla\Controller;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\MVC\Controller\AdminController;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\Input\Input;
defined('_JEXEC') or die();
class Admin extends AdminController
{
use TraitController;
/**
* @inheritDoc
*/
public function __construct(
$config = [],
MVCFactoryInterface $factory = null,
?CMSApplication $app = null,
?Input $input = null
) {
parent::__construct($config, $factory, $app, $input);
$this->customInit();
}
}

View File

@ -0,0 +1,44 @@
<?php
/**
* @package AllediaFramework
* @contact www.joomlashack.com, help@joomlashack.com
* @copyright 2016-2023 Joomlashack.com. All rights reserved
* @license https://www.gnu.org/licenses/gpl.html GNU/GPL
*
* This file is part of AllediaFramework.
*
* AllediaFramework is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* AllediaFramework is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AllediaFramework. If not, see <https://www.gnu.org/licenses/>.
*/
namespace Alledia\Framework\Joomla\Controller;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
defined('_JEXEC') or die();
class Base extends BaseController
{
use TraitController;
/**
* @inheritDoc
*/
public function __construct($config = [], MVCFactoryInterface $factory = null)
{
parent::__construct($config, $factory);
$this->customInit();
}
}

View File

@ -0,0 +1,80 @@
<?php
/**
* @package AllediaFramework
* @contact www.joomlashack.com, help@joomlashack.com
* @copyright 2016-2023 Joomlashack.com. All rights reserved
* @license https://www.gnu.org/licenses/gpl.html GNU/GPL
*
* This file is part of AllediaFramework.
*
* AllediaFramework is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* AllediaFramework is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AllediaFramework. If not, see <https://www.gnu.org/licenses/>.
*/
namespace Alledia\Framework\Joomla\Controller;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\MVC\Controller\FormController;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\CMS\Router\Route;
use Joomla\Input\Input;
defined('_JEXEC') or die();
class Form extends FormController
{
use TraitController;
/**
* @inheritDoc
*/
public function __construct(
$config = [],
MVCFactoryInterface $factory = null,
?CMSApplication $app = null,
?Input $input = null
) {
parent::__construct($config, $factory, $app, $input);
$this->customInit();
}
/**
* @inheritDoc
* @throws \Exception
*/
public function batch($model = null)
{
$this->checkToken();
$inflector = $this->getStringInflector();
$view = $this->app->input->getCmd('view', $this->default_view);
if ($inflector->isPlural($view)) {
$modelName = $inflector->toSingular($view);
$model = $this->getModel($modelName, '', []);
$linkQuery = http_build_query([
'option' => $this->app->input->getCmd('option'),
'view' => $view
]);
$this->setRedirect(Route::_('index.php?' . $linkQuery . $this->getRedirectToListAppend(), false));
return parent::batch($model);
}
return null;
}
}

View File

@ -0,0 +1,79 @@
<?php
/**
* @package OSCampus
* @contact www.joomlashack.com, help@joomlashack.com
* @copyright 2015-2023 Joomlashack.com. All rights reserved
* @license http://www.gnu.org/licenses/gpl.html GNU/GPL
*
* This file is part of OSCampus.
*
* OSCampus is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* OSCampus is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OSCampus. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Alledia\Framework\Joomla\Controller;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Response\JsonResponse;
defined('_JEXEC') or die();
abstract class Json extends Base
{
/**
* @inheritDoc
* @throws \Exception`
*/
public function checkToken($method = 'post', $redirect = false)
{
$valid = parent::checkToken($method, $redirect);
if (!$valid) {
throw new \Exception(Text::_('JINVALID_TOKEN'), 403);
}
return true;
}
/**
* Sends a json package to output. All php processing ended to prevent any
* plugin processing that might slow things down or waste memory.
*
* @param ?string|\Throwable $message
*
* @return void
*/
protected function returnJson($message = null)
{
$result = new JsonResponse();
if ($message) {
if ($message instanceof \Throwable) {
$result->success = false;
$result->message = $message->getMessage();
$result->data = [
'file' => $message->getFile(),
'line' => $message->getLine()
];
} else {
$result->message = $message;
}
}
header('Content-Type: application/json');
echo $result;
jexit();
}
}

View File

@ -0,0 +1,128 @@
<?php
/**
* @package OSCampus
* @contact www.joomlashack.com, help@joomlashack.com
* @copyright 2021-2023 Joomlashack.com. All rights reserved
* @license https://www.gnu.org/licenses/gpl.html GNU/GPL
*
* This file is part of OSCampus.
*
* OSCampus is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* OSCampus is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OSCampus. If not, see <https://www.gnu.org/licenses/>.
*/
namespace Alledia\Framework\Joomla\Controller;
use Alledia\Framework\Factory;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Uri\Uri;
use Joomla\String\Inflector;
defined('_JEXEC') or die();
trait TraitController
{
/**
* For consistency between Joomla 3 & 4
*
* @var CMSApplication
* @since Joomla v4
*/
protected $app = null;
/**
* Standard return to calling url. In order:
* - Looks for base64 encoded 'return' URL variable
* - Uses current 'Itemid' URL variable
* - Uses current 'option', 'view', 'layout' URL variables
* - Goes to site default page
*
* @param ?array|string $message The message to queue up
* @param ?string $type message|notice|error
* @param ?string $return (optional) base64 encoded url for redirect
*
* @return void
*/
protected function callerReturn($message = null, ?string $type = null, ?string $return = null)
{
$url = $return ?: $this->app->input->getBase64('return');
if ($url) {
$url = base64_decode($url);
} else {
$url = new Uri('index.php');
if ($itemId = $this->app->input->getInt('Itemid')) {
$url->setVar('Itemid', $itemId);
} elseif ($option = $this->app->input->getCmd('option')) {
$url->setVar('option', $option);
}
if ($view = $this->app->input->getCmd('view')) {
$url->setVar('view', $view);
if ($layout = $this->app->input->getCmd('layout')) {
$url->setVar('layout', $layout);
}
}
}
if (is_array($message)) {
$message = join('<br>', $message);
}
$this->setRedirect(Route::_((string)$url), $message, $type);
}
/**
* Return to referrer if internal, home page if external
*
* @param string $message
* @param string $type
*
* @return void
*/
protected function errorReturn(string $message, string $type = 'error')
{
$referrer = $this->input->server->getString('HTTP_REFERER');
if (Uri::isInternal($referrer) == false) {
$referrer = 'index.php';
}
$this->app->enqueueMessage($message, $type);
$this->app->redirect($referrer);
}
/**
* Provide consistency between Joomla 3/Joomla 4 among other possibilities
*
* @return void
*/
protected function customInit()
{
if (empty($this->app)) {
$this->app = Factory::getApplication();
}
}
/**
* @return Inflector
*/
protected function getStringInflector(): Inflector
{
return Inflector::getInstance();
}
}