2021-03-05 03:08:47 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @package Joomla.Component.Builder
|
|
|
|
*
|
|
|
|
* @created 30th April, 2015
|
2024-03-09 19:47:28 +00:00
|
|
|
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
|
|
|
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
2021-03-05 03:08:47 +00:00
|
|
|
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
|
|
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
// No direct access to this file
|
|
|
|
defined('_JEXEC') or die('Restricted access');
|
|
|
|
?>
|
|
|
|
###BOM###
|
|
|
|
|
|
|
|
// No direct access to this file
|
|
|
|
defined('_JEXEC') or die('Restricted access');
|
|
|
|
|
2024-03-09 19:47:28 +00:00
|
|
|
use Joomla\CMS\Factory;
|
2022-05-25 08:30:55 +00:00
|
|
|
use Joomla\CMS\MVC\Controller\BaseController;
|
2024-03-09 19:47:28 +00:00
|
|
|
use Joomla\CMS\Session\Session;
|
2021-03-05 03:08:47 +00:00
|
|
|
use Joomla\Utilities\ArrayHelper;
|
|
|
|
|
|
|
|
/**
|
2022-05-25 08:30:55 +00:00
|
|
|
* ###Component### Ajax Base Controller
|
2021-03-05 03:08:47 +00:00
|
|
|
*/
|
2022-05-25 08:30:55 +00:00
|
|
|
class ###Component###ControllerAjax extends BaseController
|
2021-03-05 03:08:47 +00:00
|
|
|
{
|
|
|
|
public function __construct($config)
|
|
|
|
{
|
|
|
|
parent::__construct($config);
|
|
|
|
// make sure all json stuff are set
|
2024-03-09 19:47:28 +00:00
|
|
|
Factory::getDocument()->setMimeEncoding( 'application/json' );
|
2021-08-31 14:00:12 +00:00
|
|
|
// get the application
|
2024-03-09 19:47:28 +00:00
|
|
|
$app = Factory::getApplication();
|
2021-08-31 14:00:12 +00:00
|
|
|
$app->setHeader('Content-Disposition','attachment;filename="getajax.json"');
|
|
|
|
$app->setHeader('Access-Control-Allow-Origin', '*');
|
2021-03-05 03:08:47 +00:00
|
|
|
// load the tasks ###REGISTER_SITE_AJAX_TASK###
|
|
|
|
}
|
|
|
|
|
|
|
|
public function ajax()
|
|
|
|
{
|
2021-08-31 14:00:12 +00:00
|
|
|
// get the user for later use
|
2024-03-09 19:47:28 +00:00
|
|
|
$user = Factory::getUser();
|
2021-08-31 14:00:12 +00:00
|
|
|
// get the input values
|
2024-03-09 19:47:28 +00:00
|
|
|
$jinput = Factory::getApplication()->input;
|
2021-08-31 14:00:12 +00:00
|
|
|
// check if we should return raw
|
2024-03-09 19:47:28 +00:00
|
|
|
$returnRaw = $jinput->get('raw', false, 'BOOLEAN');
|
2021-08-31 14:00:12 +00:00
|
|
|
// return to a callback function
|
2024-03-09 19:47:28 +00:00
|
|
|
$callback = $jinput->get('callback', null, 'CMD');
|
2021-03-05 03:08:47 +00:00
|
|
|
// Check Token!
|
2024-03-09 19:47:28 +00:00
|
|
|
$token = Session::getFormToken();
|
|
|
|
$call_token = $jinput->get('token', 0, 'ALNUM');
|
2021-03-05 03:08:47 +00:00
|
|
|
if($jinput->get($token, 0, 'ALNUM') || $token === $call_token)
|
|
|
|
{
|
2021-08-31 14:00:12 +00:00
|
|
|
// get the task
|
2021-03-05 03:08:47 +00:00
|
|
|
$task = $this->getTask();
|
|
|
|
switch($task)
|
|
|
|
{###AJAX_SITE_INPUT_RETURN###
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-08-31 14:00:12 +00:00
|
|
|
// return to a callback function
|
|
|
|
if($callback)
|
2021-03-05 03:08:47 +00:00
|
|
|
{
|
|
|
|
echo $callback."(".json_encode(false).");";
|
|
|
|
}
|
2021-08-31 14:00:12 +00:00
|
|
|
// return raw
|
|
|
|
elseif($returnRaw)
|
|
|
|
{
|
|
|
|
echo json_encode(false);
|
|
|
|
}
|
2021-03-05 03:08:47 +00:00
|
|
|
else
|
2024-03-09 19:47:28 +00:00
|
|
|
{
|
2021-03-05 03:08:47 +00:00
|
|
|
echo "(".json_encode(false).");";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|