2016-01-30 20:28:43 +00:00
|
|
|
<?php
|
|
|
|
/*--------------------------------------------------------------------------------------------------------| www.vdm.io |------/
|
|
|
|
__ __ _ _____ _ _ __ __ _ _ _
|
|
|
|
\ \ / / | | | __ \ | | | | | \/ | | | | | | |
|
|
|
|
\ \ / /_ _ ___| |_ | | | | _____ _____| | ___ _ __ _ __ ___ ___ _ __ | |_ | \ / | ___| |_| |__ ___ __| |
|
|
|
|
\ \/ / _` / __| __| | | | |/ _ \ \ / / _ \ |/ _ \| '_ \| '_ ` _ \ / _ \ '_ \| __| | |\/| |/ _ \ __| '_ \ / _ \ / _` |
|
|
|
|
\ / (_| \__ \ |_ | |__| | __/\ V / __/ | (_) | |_) | | | | | | __/ | | | |_ | | | | __/ |_| | | | (_) | (_| |
|
|
|
|
\/ \__,_|___/\__| |_____/ \___| \_/ \___|_|\___/| .__/|_| |_| |_|\___|_| |_|\__| |_| |_|\___|\__|_| |_|\___/ \__,_|
|
|
|
|
| |
|
|
|
|
|_|
|
|
|
|
/-------------------------------------------------------------------------------------------------------------------------------/
|
|
|
|
|
2016-11-25 02:56:16 +00:00
|
|
|
@version 2.2.4
|
|
|
|
@build 25th November, 2016
|
2016-01-30 20:28:43 +00:00
|
|
|
@created 30th April, 2015
|
|
|
|
@package Component Builder
|
|
|
|
@subpackage ajax.json.php
|
2016-10-23 22:48:26 +00:00
|
|
|
@author Llewellyn van der Merwe <https://www.vdm.io/joomla-component-builder>
|
2016-01-30 20:28:43 +00:00
|
|
|
@copyright Copyright (C) 2015. All Rights Reserved
|
|
|
|
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
|
|
|
|
|
|
|
|
Builds Complex Joomla Components
|
|
|
|
|
|
|
|
/-----------------------------------------------------------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
// No direct access to this file
|
|
|
|
defined('_JEXEC') or die('Restricted access');
|
|
|
|
|
|
|
|
// import Joomla controllerform library
|
|
|
|
jimport('joomla.application.component.controller');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Componentbuilder Ajax Controller
|
|
|
|
*/
|
|
|
|
class ComponentbuilderControllerAjax extends JControllerLegacy
|
|
|
|
{
|
|
|
|
public function __construct($config)
|
|
|
|
{
|
|
|
|
parent::__construct($config);
|
|
|
|
// make sure all json stuff are set
|
|
|
|
JFactory::getDocument()->setMimeEncoding( 'application/json' );
|
|
|
|
JResponse::setHeader('Content-Disposition','attachment;filename="getajax.json"');
|
|
|
|
JResponse::setHeader("Access-Control-Allow-Origin", "*");
|
|
|
|
// load the tasks
|
2016-10-31 21:47:21 +00:00
|
|
|
$this->registerTask('isNew', 'ajax');
|
|
|
|
$this->registerTask('isRead', 'ajax');
|
2016-01-30 20:28:43 +00:00
|
|
|
$this->registerTask('tableColumns', 'ajax');
|
|
|
|
$this->registerTask('fieldSelectOptions', 'ajax');
|
2016-05-04 04:53:33 +00:00
|
|
|
$this->registerTask('getImportScripts', 'ajax');
|
2016-01-30 20:28:43 +00:00
|
|
|
$this->registerTask('layoutDetails', 'ajax');
|
|
|
|
$this->registerTask('templateDetails', 'ajax');
|
|
|
|
$this->registerTask('snippetDetails', 'ajax');
|
|
|
|
$this->registerTask('dynamicValues', 'ajax');
|
|
|
|
$this->registerTask('dynamicFormDetails', 'ajax');
|
|
|
|
$this->registerTask('dbTableColumns', 'ajax');
|
|
|
|
$this->registerTask('viewTableColumns', 'ajax');
|
|
|
|
$this->registerTask('fieldOptions', 'ajax');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function ajax()
|
|
|
|
{
|
|
|
|
$user = JFactory::getUser();
|
|
|
|
$jinput = JFactory::getApplication()->input;
|
|
|
|
// Check Token!
|
|
|
|
$token = JSession::getFormToken();
|
|
|
|
$call_token = $jinput->get('token', 0, 'ALNUM');
|
|
|
|
if($token == $call_token)
|
|
|
|
{
|
|
|
|
$task = $this->getTask();
|
|
|
|
switch($task)
|
|
|
|
{
|
2016-10-31 21:47:21 +00:00
|
|
|
case 'isNew':
|
|
|
|
try
|
|
|
|
{
|
|
|
|
$returnRaw = $jinput->get('raw', false, 'BOOLEAN');
|
|
|
|
$noticeValue = $jinput->get('notice', NULL, 'STRING');
|
|
|
|
if($noticeValue && $user->id != 0)
|
|
|
|
{
|
|
|
|
$result = $this->getModel('ajax')->isNew($noticeValue);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$result = false;
|
|
|
|
}
|
|
|
|
if($callback = $jinput->get('callback', null, 'CMD'))
|
|
|
|
{
|
|
|
|
echo $callback . "(".json_encode($result).");";
|
|
|
|
}
|
|
|
|
elseif($returnRaw)
|
|
|
|
{
|
|
|
|
echo json_encode($result);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "(".json_encode($result).");";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(Exception $e)
|
|
|
|
{
|
|
|
|
if($callback = $jinput->get('callback', null, 'CMD'))
|
|
|
|
{
|
|
|
|
echo $callback."(".json_encode($e).");";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "(".json_encode($e).");";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'isRead':
|
|
|
|
try
|
|
|
|
{
|
|
|
|
$returnRaw = $jinput->get('raw', false, 'BOOLEAN');
|
|
|
|
$noticeValue = $jinput->get('notice', NULL, 'STRING');
|
|
|
|
if($noticeValue && $user->id != 0)
|
|
|
|
{
|
|
|
|
$result = $this->getModel('ajax')->isRead($noticeValue);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$result = false;
|
|
|
|
}
|
|
|
|
if($callback = $jinput->get('callback', null, 'CMD'))
|
|
|
|
{
|
|
|
|
echo $callback . "(".json_encode($result).");";
|
|
|
|
}
|
|
|
|
elseif($returnRaw)
|
|
|
|
{
|
|
|
|
echo json_encode($result);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "(".json_encode($result).");";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(Exception $e)
|
|
|
|
{
|
|
|
|
if($callback = $jinput->get('callback', null, 'CMD'))
|
|
|
|
{
|
|
|
|
echo $callback."(".json_encode($e).");";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "(".json_encode($e).");";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2016-01-30 20:28:43 +00:00
|
|
|
case 'tableColumns':
|
|
|
|
try
|
|
|
|
{
|
2016-04-22 12:03:43 +00:00
|
|
|
$returnRaw = $jinput->get('raw', false, 'BOOLEAN');
|
2016-01-30 20:28:43 +00:00
|
|
|
$tableValue = $jinput->get('table', NULL, 'WORD');
|
|
|
|
if($tableValue && $user->id != 0)
|
|
|
|
{
|
|
|
|
$result = $this->getModel('ajax')->getTableColumns($tableValue);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$result = false;
|
|
|
|
}
|
2016-06-24 14:23:01 +00:00
|
|
|
if($callback = $jinput->get('callback', null, 'CMD'))
|
2016-01-30 20:28:43 +00:00
|
|
|
{
|
2016-06-24 14:23:01 +00:00
|
|
|
echo $callback . "(".json_encode($result).");";
|
2016-01-30 20:28:43 +00:00
|
|
|
}
|
2016-04-22 12:03:43 +00:00
|
|
|
elseif($returnRaw)
|
|
|
|
{
|
|
|
|
echo json_encode($result);
|
|
|
|
}
|
2016-01-30 20:28:43 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "(".json_encode($result).");";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(Exception $e)
|
|
|
|
{
|
2016-06-24 14:23:01 +00:00
|
|
|
if($callback = $jinput->get('callback', null, 'CMD'))
|
2016-01-30 20:28:43 +00:00
|
|
|
{
|
2016-06-24 14:23:01 +00:00
|
|
|
echo $callback."(".json_encode($e).");";
|
2016-01-30 20:28:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "(".json_encode($e).");";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'fieldSelectOptions':
|
|
|
|
try
|
|
|
|
{
|
2016-04-22 12:03:43 +00:00
|
|
|
$returnRaw = $jinput->get('raw', false, 'BOOLEAN');
|
2016-01-30 20:28:43 +00:00
|
|
|
$idValue = $jinput->get('id', NULL, 'INT');
|
|
|
|
if($idValue && $user->id != 0)
|
|
|
|
{
|
|
|
|
$result = $this->getModel('ajax')->getFieldSelectOptions($idValue);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$result = false;
|
|
|
|
}
|
2016-06-24 14:23:01 +00:00
|
|
|
if($callback = $jinput->get('callback', null, 'CMD'))
|
2016-01-30 20:28:43 +00:00
|
|
|
{
|
2016-06-24 14:23:01 +00:00
|
|
|
echo $callback . "(".json_encode($result).");";
|
2016-01-30 20:28:43 +00:00
|
|
|
}
|
2016-04-22 12:03:43 +00:00
|
|
|
elseif($returnRaw)
|
|
|
|
{
|
|
|
|
echo json_encode($result);
|
|
|
|
}
|
2016-01-30 20:28:43 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "(".json_encode($result).");";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(Exception $e)
|
|
|
|
{
|
2016-06-24 14:23:01 +00:00
|
|
|
if($callback = $jinput->get('callback', null, 'CMD'))
|
2016-01-30 20:28:43 +00:00
|
|
|
{
|
2016-06-24 14:23:01 +00:00
|
|
|
echo $callback."(".json_encode($e).");";
|
2016-01-30 20:28:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "(".json_encode($e).");";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2016-05-04 04:53:33 +00:00
|
|
|
case 'getImportScripts':
|
|
|
|
try
|
|
|
|
{
|
|
|
|
$returnRaw = $jinput->get('raw', false, 'BOOLEAN');
|
|
|
|
$typeValue = $jinput->get('type', NULL, 'WORD');
|
|
|
|
if($typeValue && $user->id != 0)
|
|
|
|
{
|
|
|
|
$result = $this->getModel('ajax')->getImportScripts($typeValue);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$result = false;
|
|
|
|
}
|
2016-06-24 14:23:01 +00:00
|
|
|
if($callback = $jinput->get('callback', null, 'CMD'))
|
2016-05-04 04:53:33 +00:00
|
|
|
{
|
2016-06-24 14:23:01 +00:00
|
|
|
echo $callback . "(".json_encode($result).");";
|
2016-05-04 04:53:33 +00:00
|
|
|
}
|
|
|
|
elseif($returnRaw)
|
|
|
|
{
|
|
|
|
echo json_encode($result);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "(".json_encode($result).");";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(Exception $e)
|
|
|
|
{
|
2016-06-24 14:23:01 +00:00
|
|
|
if($callback = $jinput->get('callback', null, 'CMD'))
|
2016-05-04 04:53:33 +00:00
|
|
|
{
|
2016-06-24 14:23:01 +00:00
|
|
|
echo $callback."(".json_encode($e).");";
|
2016-05-04 04:53:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "(".json_encode($e).");";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2016-01-30 20:28:43 +00:00
|
|
|
case 'layoutDetails':
|
|
|
|
try
|
|
|
|
{
|
2016-04-22 12:03:43 +00:00
|
|
|
$returnRaw = $jinput->get('raw', false, 'BOOLEAN');
|
2016-01-30 20:28:43 +00:00
|
|
|
$idValue = $jinput->get('id', null, 'INT');
|
|
|
|
if($idValue && $user->id != 0)
|
|
|
|
{
|
|
|
|
$result = $this->getModel('ajax')->getLayoutDetails($idValue);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$result = false;
|
|
|
|
}
|
2016-06-24 14:23:01 +00:00
|
|
|
if($callback = $jinput->get('callback', null, 'CMD'))
|
2016-01-30 20:28:43 +00:00
|
|
|
{
|
2016-06-24 14:23:01 +00:00
|
|
|
echo $callback . "(".json_encode($result).");";
|
2016-01-30 20:28:43 +00:00
|
|
|
}
|
2016-04-22 12:03:43 +00:00
|
|
|
elseif($returnRaw)
|
|
|
|
{
|
|
|
|
echo json_encode($result);
|
|
|
|
}
|
2016-01-30 20:28:43 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "(".json_encode($result).");";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(Exception $e)
|
|
|
|
{
|
2016-06-24 14:23:01 +00:00
|
|
|
if($callback = $jinput->get('callback', null, 'CMD'))
|
2016-01-30 20:28:43 +00:00
|
|
|
{
|
2016-06-24 14:23:01 +00:00
|
|
|
echo $callback."(".json_encode($e).");";
|
2016-01-30 20:28:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "(".json_encode($e).");";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'templateDetails':
|
|
|
|
try
|
|
|
|
{
|
2016-04-22 12:03:43 +00:00
|
|
|
$returnRaw = $jinput->get('raw', false, 'BOOLEAN');
|
2016-01-30 20:28:43 +00:00
|
|
|
$idValue = $jinput->get('id', null, 'INT');
|
|
|
|
if($idValue && $user->id != 0)
|
|
|
|
{
|
|
|
|
$result = $this->getModel('ajax')->getTemplateDetails($idValue);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$result = false;
|
|
|
|
}
|
2016-06-24 14:23:01 +00:00
|
|
|
if($callback = $jinput->get('callback', null, 'CMD'))
|
2016-01-30 20:28:43 +00:00
|
|
|
{
|
2016-06-24 14:23:01 +00:00
|
|
|
echo $callback . "(".json_encode($result).");";
|
2016-01-30 20:28:43 +00:00
|
|
|
}
|
2016-04-22 12:03:43 +00:00
|
|
|
elseif($returnRaw)
|
|
|
|
{
|
|
|
|
echo json_encode($result);
|
|
|
|
}
|
2016-01-30 20:28:43 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "(".json_encode($result).");";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(Exception $e)
|
|
|
|
{
|
2016-06-24 14:23:01 +00:00
|
|
|
if($callback = $jinput->get('callback', null, 'CMD'))
|
2016-01-30 20:28:43 +00:00
|
|
|
{
|
2016-06-24 14:23:01 +00:00
|
|
|
echo $callback."(".json_encode($e).");";
|
2016-01-30 20:28:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "(".json_encode($e).");";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'snippetDetails':
|
|
|
|
try
|
|
|
|
{
|
2016-04-22 12:03:43 +00:00
|
|
|
$returnRaw = $jinput->get('raw', false, 'BOOLEAN');
|
2016-01-30 20:28:43 +00:00
|
|
|
$idValue = $jinput->get('id', NULL, 'INT');
|
|
|
|
if($idValue && $user->id != 0)
|
|
|
|
{
|
|
|
|
$result = $this->getModel('ajax')->getSnippetDetails($idValue);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$result = false;
|
|
|
|
}
|
2016-06-24 14:23:01 +00:00
|
|
|
if($callback = $jinput->get('callback', null, 'CMD'))
|
2016-01-30 20:28:43 +00:00
|
|
|
{
|
2016-06-24 14:23:01 +00:00
|
|
|
echo $callback . "(".json_encode($result).");";
|
2016-01-30 20:28:43 +00:00
|
|
|
}
|
2016-04-22 12:03:43 +00:00
|
|
|
elseif($returnRaw)
|
|
|
|
{
|
|
|
|
echo json_encode($result);
|
|
|
|
}
|
2016-01-30 20:28:43 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "(".json_encode($result).");";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(Exception $e)
|
|
|
|
{
|
2016-06-24 14:23:01 +00:00
|
|
|
if($callback = $jinput->get('callback', null, 'CMD'))
|
2016-01-30 20:28:43 +00:00
|
|
|
{
|
2016-06-24 14:23:01 +00:00
|
|
|
echo $callback."(".json_encode($e).");";
|
2016-01-30 20:28:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "(".json_encode($e).");";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'dynamicValues':
|
|
|
|
try
|
|
|
|
{
|
2016-04-22 12:03:43 +00:00
|
|
|
$returnRaw = $jinput->get('raw', false, 'BOOLEAN');
|
2016-01-30 20:28:43 +00:00
|
|
|
$idValue = $jinput->get('id', NULL, 'INT');
|
|
|
|
$viewValue = $jinput->get('view', NULL, 'WORD');
|
|
|
|
if($idValue && $viewValue && $user->id != 0)
|
|
|
|
{
|
|
|
|
$result = $this->getModel('ajax')->getDynamicValues($idValue, $viewValue);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$result = false;
|
|
|
|
}
|
2016-06-24 14:23:01 +00:00
|
|
|
if($callback = $jinput->get('callback', null, 'CMD'))
|
2016-01-30 20:28:43 +00:00
|
|
|
{
|
2016-06-24 14:23:01 +00:00
|
|
|
echo $callback . "(".json_encode($result).");";
|
2016-01-30 20:28:43 +00:00
|
|
|
}
|
2016-04-22 12:03:43 +00:00
|
|
|
elseif($returnRaw)
|
|
|
|
{
|
|
|
|
echo json_encode($result);
|
|
|
|
}
|
2016-01-30 20:28:43 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "(".json_encode($result).");";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(Exception $e)
|
|
|
|
{
|
2016-06-24 14:23:01 +00:00
|
|
|
if($callback = $jinput->get('callback', null, 'CMD'))
|
2016-01-30 20:28:43 +00:00
|
|
|
{
|
2016-06-24 14:23:01 +00:00
|
|
|
echo $callback."(".json_encode($e).");";
|
2016-01-30 20:28:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "(".json_encode($e).");";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'dynamicFormDetails':
|
|
|
|
try
|
|
|
|
{
|
2016-04-22 12:03:43 +00:00
|
|
|
$returnRaw = $jinput->get('raw', false, 'BOOLEAN');
|
2016-01-30 20:28:43 +00:00
|
|
|
$idValue = $jinput->get('id', NULL, 'INT');
|
|
|
|
if($idValue && $user->id != 0)
|
|
|
|
{
|
|
|
|
$result = $this->getModel('ajax')->getDynamicFormDetails($idValue);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$result = false;
|
|
|
|
}
|
2016-06-24 14:23:01 +00:00
|
|
|
if($callback = $jinput->get('callback', null, 'CMD'))
|
2016-01-30 20:28:43 +00:00
|
|
|
{
|
2016-06-24 14:23:01 +00:00
|
|
|
echo $callback . "(".json_encode($result).");";
|
2016-01-30 20:28:43 +00:00
|
|
|
}
|
2016-04-22 12:03:43 +00:00
|
|
|
elseif($returnRaw)
|
|
|
|
{
|
|
|
|
echo json_encode($result);
|
|
|
|
}
|
2016-01-30 20:28:43 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "(".json_encode($result).");";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(Exception $e)
|
|
|
|
{
|
2016-06-24 14:23:01 +00:00
|
|
|
if($callback = $jinput->get('callback', null, 'CMD'))
|
2016-01-30 20:28:43 +00:00
|
|
|
{
|
2016-06-24 14:23:01 +00:00
|
|
|
echo $callback."(".json_encode($e).");";
|
2016-01-30 20:28:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "(".json_encode($e).");";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'dbTableColumns':
|
|
|
|
try
|
|
|
|
{
|
2016-04-22 12:03:43 +00:00
|
|
|
$returnRaw = $jinput->get('raw', false, 'BOOLEAN');
|
2016-01-30 20:28:43 +00:00
|
|
|
$nameValue = $jinput->get('name', NULL, 'WORD');
|
|
|
|
$asValue = $jinput->get('as', NULL, 'WORD');
|
|
|
|
$typeValue = $jinput->get('type', NULL, 'INT');
|
|
|
|
if($nameValue && $asValue && $typeValue && $user->id != 0)
|
|
|
|
{
|
|
|
|
$result = $this->getModel('ajax')->getDbTableColumns($nameValue, $asValue, $typeValue);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$result = false;
|
|
|
|
}
|
2016-06-24 14:23:01 +00:00
|
|
|
if($callback = $jinput->get('callback', null, 'CMD'))
|
2016-01-30 20:28:43 +00:00
|
|
|
{
|
2016-06-24 14:23:01 +00:00
|
|
|
echo $callback . "(".json_encode($result).");";
|
2016-01-30 20:28:43 +00:00
|
|
|
}
|
2016-04-22 12:03:43 +00:00
|
|
|
elseif($returnRaw)
|
|
|
|
{
|
|
|
|
echo json_encode($result);
|
|
|
|
}
|
2016-01-30 20:28:43 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "(".json_encode($result).");";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(Exception $e)
|
|
|
|
{
|
2016-06-24 14:23:01 +00:00
|
|
|
if($callback = $jinput->get('callback', null, 'CMD'))
|
2016-01-30 20:28:43 +00:00
|
|
|
{
|
2016-06-24 14:23:01 +00:00
|
|
|
echo $callback."(".json_encode($e).");";
|
2016-01-30 20:28:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "(".json_encode($e).");";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'viewTableColumns':
|
|
|
|
try
|
|
|
|
{
|
2016-04-22 12:03:43 +00:00
|
|
|
$returnRaw = $jinput->get('raw', false, 'BOOLEAN');
|
2016-01-30 20:28:43 +00:00
|
|
|
$idValue = $jinput->get('id', NULL, 'INT');
|
|
|
|
$asValue = $jinput->get('as', NULL, 'WORD');
|
|
|
|
$typeValue = $jinput->get('type', NULL, 'INT');
|
|
|
|
if($idValue && $asValue && $typeValue && $user->id != 0)
|
|
|
|
{
|
|
|
|
$result = $this->getModel('ajax')->getViewTableColumns($idValue, $asValue, $typeValue);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$result = false;
|
|
|
|
}
|
2016-06-24 14:23:01 +00:00
|
|
|
if($callback = $jinput->get('callback', null, 'CMD'))
|
2016-01-30 20:28:43 +00:00
|
|
|
{
|
2016-06-24 14:23:01 +00:00
|
|
|
echo $callback . "(".json_encode($result).");";
|
2016-01-30 20:28:43 +00:00
|
|
|
}
|
2016-04-22 12:03:43 +00:00
|
|
|
elseif($returnRaw)
|
|
|
|
{
|
|
|
|
echo json_encode($result);
|
|
|
|
}
|
2016-01-30 20:28:43 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "(".json_encode($result).");";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(Exception $e)
|
|
|
|
{
|
2016-06-24 14:23:01 +00:00
|
|
|
if($callback = $jinput->get('callback', null, 'CMD'))
|
2016-01-30 20:28:43 +00:00
|
|
|
{
|
2016-06-24 14:23:01 +00:00
|
|
|
echo $callback."(".json_encode($e).");";
|
2016-01-30 20:28:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "(".json_encode($e).");";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'fieldOptions':
|
|
|
|
try
|
|
|
|
{
|
2016-04-22 12:03:43 +00:00
|
|
|
$returnRaw = $jinput->get('raw', false, 'BOOLEAN');
|
2016-01-30 20:28:43 +00:00
|
|
|
$idValue = $jinput->get('id', NULL, 'INT');
|
|
|
|
if($idValue && $user->id != 0)
|
|
|
|
{
|
|
|
|
$result = $this->getModel('ajax')->getFieldOptions($idValue);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$result = false;
|
|
|
|
}
|
2016-06-24 14:23:01 +00:00
|
|
|
if($callback = $jinput->get('callback', null, 'CMD'))
|
2016-01-30 20:28:43 +00:00
|
|
|
{
|
2016-06-24 14:23:01 +00:00
|
|
|
echo $callback . "(".json_encode($result).");";
|
2016-01-30 20:28:43 +00:00
|
|
|
}
|
2016-04-22 12:03:43 +00:00
|
|
|
elseif($returnRaw)
|
|
|
|
{
|
|
|
|
echo json_encode($result);
|
|
|
|
}
|
2016-01-30 20:28:43 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "(".json_encode($result).");";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(Exception $e)
|
|
|
|
{
|
2016-06-24 14:23:01 +00:00
|
|
|
if($callback = $jinput->get('callback', null, 'CMD'))
|
2016-01-30 20:28:43 +00:00
|
|
|
{
|
2016-06-24 14:23:01 +00:00
|
|
|
echo $callback."(".json_encode($e).");";
|
2016-01-30 20:28:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "(".json_encode($e).");";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-06-24 14:23:01 +00:00
|
|
|
if($callback = $jinput->get('callback', null, 'CMD'))
|
2016-01-30 20:28:43 +00:00
|
|
|
{
|
2016-06-24 14:23:01 +00:00
|
|
|
echo $callback."(".json_encode(false).");";
|
2016-01-30 20:28:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "(".json_encode(false).");";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|