<?php
/*
 * Software Name: Eorisis Pixels
 * Software URI: https://eorisis.com/shop/software/joomla/pixels
 * Author: Eorisis
 * Author URI: https://eorisis.com
 * Copyright: Copyright (C) 2011-2025 EORISIS. All Rights Reserved.
 * License: GNU General Public License version 2; See https://eorisis.com/gpl
 * Terms of Service: https://eorisis.com/tos
 */
defined('_JEXEC') or die;

if (version_compare(JVERSION, '3.8', '>='))
{
	JLoader::registerAlias('EorisisText', '\\Joomla\\CMS\\Language\\Text');
	JLoader::registerAlias('EorisisFactory', '\\Joomla\\CMS\\Factory');
	JLoader::registerAlias('EorisisBaseController', '\\Joomla\\CMS\\MVC\\Controller\\BaseController');
	JLoader::registerAlias('EorisisNotAllowed', '\\Joomla\\CMS\\Access\\Exception\\NotAllowed');
}
else
{
	JLoader::registerAlias('EorisisText', 'JText');
	JLoader::registerAlias('EorisisFactory', 'JFactory');
	JLoader::registerAlias('EorisisBaseController', 'JControllerLegacy');
	JLoader::registerAlias('EorisisNotAllowed', 'JAccessExceptionNotallowed');
}

if (!EorisisFactory::getUser()->authorise('core.manage', 'com_eorisis_pixels'))
{
	throw new EorisisNotAllowed(EorisisText::_('JERROR_ALERTNOAUTHOR'), 403);
}

// When the system plugin is disabled
if (!class_exists('com_eorisis_pixels\framework\lib\eorisis', false))
{
	$namespace_path = JPATH_COMPONENT_ADMINISTRATOR.'/framework/lib';
	require_once $namespace_path.'/eorisis.php';
	$eorisis = new \com_eorisis_pixels\framework\lib\eorisis($namespace_path);
	$eorisis->register();
}

use com_eorisis_pixels\framework\lib\core\app\config as app_config;
use com_eorisis_pixels\framework\lib\core\cms\input as cms_input;
use com_eorisis_pixels\framework\lib\core\model\document as document_model;

document_model::set_component_layout();

// Not used
//$path = JPATH_COMPONENT_ADMINISTRATOR.'/helpers/'.app_config::EXTENSION.'.php';
//com_eorisis_pixels\framework\lib\core\cms\application::register_class('Eorisis_pixelsHelper', $path);

$controller = EorisisBaseController::getInstance(app_config::EXTENSION);

// Must get the $task AFTER getting the instance of the controller
$task = cms_input::get('task');

$controller->execute($task);
$controller->redirect();
