Improved the ajax controller.

This commit is contained in:
Llewellyn van der Merwe 2021-08-31 16:00:12 +02:00
parent 1651d4358c
commit 5651d3dca8
Signed by untrusted user: Llewellyn
GPG Key ID: EFC0C720A240551C
15 changed files with 307 additions and 153 deletions

View File

@ -143,11 +143,11 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder)
+ *First Build*: 30th April, 2015
+ *Last Build*: 27th August, 2021
+ *Last Build*: 31st August, 2021
+ *Version*: 2.12.11
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **292163**
+ *Line count*: **292284**
+ *Field count*: **1630**
+ *File count*: **1936**
+ *Folder count*: **322**

View File

@ -143,11 +143,11 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder)
+ *First Build*: 30th April, 2015
+ *Last Build*: 27th August, 2021
+ *Last Build*: 31st August, 2021
+ *Version*: 2.12.11
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **292163**
+ *Line count*: **292284**
+ *Field count*: **1630**
+ *File count*: **1936**
+ *Folder count*: **322**

View File

@ -274,7 +274,6 @@
<action name="field.access" title="COM_COMPONENTBUILDER_FIELDS_ACCESS" description="COM_COMPONENTBUILDER_FIELDS_ACCESS_DESC" />
<action name="field.batch" title="COM_COMPONENTBUILDER_FIELDS_BATCH_USE" description="COM_COMPONENTBUILDER_FIELDS_BATCH_USE_DESC" />
<action name="field.create" title="COM_COMPONENTBUILDER_FIELDS_CREATE" description="COM_COMPONENTBUILDER_FIELDS_CREATE_DESC" />
<action name="field.dashboard_add" title="COM_COMPONENTBUILDER_FIELDS_DASHBOARD_ADD" description="COM_COMPONENTBUILDER_FIELDS_DASHBOARD_ADD_DESC" />
<action name="field.dashboard_list" title="COM_COMPONENTBUILDER_FIELDS_DASHBOARD_LIST" description="COM_COMPONENTBUILDER_FIELDS_DASHBOARD_LIST_DESC" />
<action name="field.delete" title="COM_COMPONENTBUILDER_FIELDS_DELETE" description="COM_COMPONENTBUILDER_FIELDS_DELETE_DESC" />
<action name="field.edit" title="COM_COMPONENTBUILDER_FIELDS_EDIT" description="COM_COMPONENTBUILDER_FIELDS_EDIT_DESC" />

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

View File

@ -29,20 +29,29 @@ class ###Component###ControllerAjax extends JControllerLegacy
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", "*");
// get the application
$app = JFactory::getApplication();
$app->setHeader('Content-Disposition','attachment;filename="getajax.json"');
$app->setHeader('Access-Control-Allow-Origin', '*');
// load the tasks ###REGISTER_AJAX_TASK###
}
public function ajax()
{
// get the user for later use
$user = JFactory::getUser();
// get the input values
$jinput = JFactory::getApplication()->input;
// check if we should return raw
$returnRaw = $jinput->get('raw', false, 'BOOLEAN');
// return to a callback function
$callback = $jinput->get('callback', null, 'CMD');
// Check Token!
$token = JSession::getFormToken();
$call_token = $jinput->get('token', 0, 'ALNUM');
if($jinput->get($token, 0, 'ALNUM') || $token === $call_token)
{
// get the task
$task = $this->getTask();
switch($task)
{###AJAX_INPUT_RETURN###
@ -50,10 +59,15 @@ class ###Component###ControllerAjax extends JControllerLegacy
}
else
{
if($callback = $jinput->get('callback', null, 'CMD'))
// return to a callback function
if($callback)
{
echo $callback."(".json_encode(false).");";
}
elseif($returnRaw)
{
echo json_encode(false);
}
else
{
echo "(".json_encode(false).");";

View File

@ -29,20 +29,29 @@ class ###Component###ControllerAjax extends JControllerLegacy
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", "*");
// get the application
$app = JFactory::getApplication();
$app->setHeader('Content-Disposition','attachment;filename="getajax.json"');
$app->setHeader('Access-Control-Allow-Origin', '*');
// load the tasks ###REGISTER_SITE_AJAX_TASK###
}
public function ajax()
{
// get the user for later use
$user = JFactory::getUser();
// get the input values
$jinput = JFactory::getApplication()->input;
// check if we should return raw
$returnRaw = $jinput->get('raw', false, 'BOOLEAN');
// return to a callback function
$callback = $jinput->get('callback', null, 'CMD');
// Check Token!
$token = JSession::getFormToken();
$call_token = $jinput->get('token', 0, 'ALNUM');
if($jinput->get($token, 0, 'ALNUM') || $token === $call_token)
{
// get the task
$task = $this->getTask();
switch($task)
{###AJAX_SITE_INPUT_RETURN###
@ -50,10 +59,16 @@ class ###Component###ControllerAjax extends JControllerLegacy
}
else
{
if($callback = $jinput->get('callback', null, 'CMD'))
// return to a callback function
if($callback)
{
echo $callback."(".json_encode(false).");";
}
// return raw
elseif($returnRaw)
{
echo json_encode(false);
}
else
{
echo "(".json_encode(false).");";

View File

@ -27,8 +27,8 @@ class ###Component###ControllerAjax extends JControllerLegacy
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", "*");
JFactory::getApplication()->setHeader('Content-Disposition','attachment;filename="getajax.json"');
JFactory::getApplication()->setHeader("Access-Control-Allow-Origin", "*");
// load the tasks
$this->registerTask('fieldRequired', 'ajax');
}

View File

@ -60,7 +60,7 @@ class ###Component###ModelAjax extends JModelList
$fields = array($name);
}
}
// load the remaining values to seesion
// load the remaining values to session
if(###Component###Helper::checkArray($fields))
{
$session->set($form.'_requiredFieldFix', $fields);

File diff suppressed because it is too large Load Diff

View File

@ -17900,8 +17900,6 @@ class Interpretation extends Fields
$cases .= PHP_EOL . $this->_t(4) . "case '" . $task . "':";
$cases .= PHP_EOL . $this->_t(5) . "try";
$cases .= PHP_EOL . $this->_t(5) . "{";
$cases .= PHP_EOL . $this->_t(6)
. "\$returnRaw = \$jinput->get('raw', false, 'BOOLEAN');";
foreach ($input[$task] as $string)
{
$cases .= PHP_EOL . $this->_t(6) . $string;
@ -17936,7 +17934,7 @@ class Interpretation extends Fields
}
// continue the build
$cases .= PHP_EOL . $this->_t(6)
. "if(\$callback = \$jinput->get('callback', null, 'CMD'))";
. "if(\$callback)";
$cases .= PHP_EOL . $this->_t(6) . "{";
$cases .= PHP_EOL . $this->_t(7)
. "echo \$callback . \"(\".json_encode(\$result).\");\";";
@ -17955,11 +17953,17 @@ class Interpretation extends Fields
$cases .= PHP_EOL . $this->_t(5) . "catch(Exception \$e)";
$cases .= PHP_EOL . $this->_t(5) . "{";
$cases .= PHP_EOL . $this->_t(6)
. "if(\$callback = \$jinput->get('callback', null, 'CMD'))";
. "if(\$callback)";
$cases .= PHP_EOL . $this->_t(6) . "{";
$cases .= PHP_EOL . $this->_t(7)
. "echo \$callback.\"(\".json_encode(\$e).\");\";";
$cases .= PHP_EOL . $this->_t(6) . "}";
$cases .= PHP_EOL . $this->_t(6)
. "elseif(\$returnRaw)";
$cases .= PHP_EOL . $this->_t(6) . "{";
$cases .= PHP_EOL . $this->_t(7)
. "echo json_encode(\$e);";
$cases .= PHP_EOL . $this->_t(6) . "}";
$cases .= PHP_EOL . $this->_t(6) . "else";
$cases .= PHP_EOL . $this->_t(6) . "{";
$cases .= PHP_EOL . $this->_t(7)

View File

@ -864,13 +864,13 @@ COM_COMPONENTBUILDER_ADMIN_VIEW_NAME_LABEL="Name"
COM_COMPONENTBUILDER_ADMIN_VIEW_NAME_LIST_DESCRIPTION="The name of the list of records in this view"
COM_COMPONENTBUILDER_ADMIN_VIEW_NAME_LIST_HINT="List of Records Name Here"
COM_COMPONENTBUILDER_ADMIN_VIEW_NAME_LIST_LABEL="Name (list of records)<br />
<small><a href=&quot;https://docs.joomla.org/J3.x:File_Structure_and_Naming_Conventions&quot; target=&quot;_blank&quot;>Naming Conventions</a></small>"
<small><a href='https://docs.joomla.org/J3.x:File_Structure_and_Naming_Conventions' target='_blank'>Naming Conventions</a></small>"
COM_COMPONENTBUILDER_ADMIN_VIEW_NAME_LIST_MESSAGE="Error! Please add list of records name here."
COM_COMPONENTBUILDER_ADMIN_VIEW_NAME_MESSAGE="Error! Please add name here."
COM_COMPONENTBUILDER_ADMIN_VIEW_NAME_SINGLE_DESCRIPTION="Type null if single record view is not to be set"
COM_COMPONENTBUILDER_ADMIN_VIEW_NAME_SINGLE_HINT="Single Record Name Here"
COM_COMPONENTBUILDER_ADMIN_VIEW_NAME_SINGLE_LABEL="Name (single record)<br />
<small><a href=&quot;https://docs.joomla.org/J3.x:File_Structure_and_Naming_Conventions&quot; target=&quot;_blank&quot;>Naming Conventions</a></small>"
<small><a href='https://docs.joomla.org/J3.x:File_Structure_and_Naming_Conventions' target='_blank'>Naming Conventions</a></small>"
COM_COMPONENTBUILDER_ADMIN_VIEW_NAME_SINGLE_MESSAGE="Error! Please add single record name here."
COM_COMPONENTBUILDER_ADMIN_VIEW_NEW="A New Admin View"
COM_COMPONENTBUILDER_ADMIN_VIEW_NEW_TAB="New Tab"
@ -4278,7 +4278,6 @@ COM_COMPONENTBUILDER_DASHBOARD_FIELDS="Fields<br /><br />"
COM_COMPONENTBUILDER_DASHBOARD_FIELDS_CATID="Categories&nbsp;For<br />Fields"
COM_COMPONENTBUILDER_DASHBOARD_FIELDTYPES="Fieldtypes<br /><br />"
COM_COMPONENTBUILDER_DASHBOARD_FIELDTYPES_CATID="Categories&nbsp;For<br />Fieldtypes"
COM_COMPONENTBUILDER_DASHBOARD_FIELD_ADD="Add&nbsp;Field<br /><br />"
COM_COMPONENTBUILDER_DASHBOARD_GET_SNIPPETS="Get Snippets<br /><br />"
COM_COMPONENTBUILDER_DASHBOARD_HELP_DOCUMENTS="Help Documents<br /><br />"
COM_COMPONENTBUILDER_DASHBOARD_IMPORTJCBPACKAGES="Import JCB Packages<br /><br />"
@ -4663,8 +4662,6 @@ COM_COMPONENTBUILDER_FIELDS_BATCH_USE="Fields Batch Use"
COM_COMPONENTBUILDER_FIELDS_BATCH_USE_DESC="Allows users in this group to use batch copy/update method of batch fields"
COM_COMPONENTBUILDER_FIELDS_CREATE="Fields Create"
COM_COMPONENTBUILDER_FIELDS_CREATE_DESC="Allows the users in this group to create create fields"
COM_COMPONENTBUILDER_FIELDS_DASHBOARD_ADD="Fields Dashboard Add"
COM_COMPONENTBUILDER_FIELDS_DASHBOARD_ADD_DESC="Allows the users in this group to dashboard add of field"
COM_COMPONENTBUILDER_FIELDS_DASHBOARD_LIST="Fields Dashboard List"
COM_COMPONENTBUILDER_FIELDS_DASHBOARD_LIST_DESC="Allows the users in this group to dashboard list of field"
COM_COMPONENTBUILDER_FIELDS_DELETE="Fields Delete"

View File

@ -534,8 +534,6 @@ COM_COMPONENTBUILDER_FIELDS_BATCH_USE="Fields Batch Use"
COM_COMPONENTBUILDER_FIELDS_BATCH_USE_DESC="Allows users in this group to use batch copy/update method of batch fields"
COM_COMPONENTBUILDER_FIELDS_CREATE="Fields Create"
COM_COMPONENTBUILDER_FIELDS_CREATE_DESC="Allows the users in this group to create create fields"
COM_COMPONENTBUILDER_FIELDS_DASHBOARD_ADD="Fields Dashboard Add"
COM_COMPONENTBUILDER_FIELDS_DASHBOARD_ADD_DESC="Allows the users in this group to dashboard add of field"
COM_COMPONENTBUILDER_FIELDS_DASHBOARD_LIST="Fields Dashboard List"
COM_COMPONENTBUILDER_FIELDS_DASHBOARD_LIST_DESC="Allows the users in this group to dashboard list of field"
COM_COMPONENTBUILDER_FIELDS_DELETE="Fields Delete"

View File

@ -25,7 +25,7 @@ class ComponentbuilderModelComponentbuilder extends JModelList
$icons = array();
// view groups array
$viewGroups = array(
'main' => array('png.compiler', 'png.joomla_components', 'png.joomla_modules', 'png.joomla_plugins', 'png||importjcbpackages||index.php?option=com_componentbuilder&view=joomla_components&task=joomla_components.smartImport', 'png.admin_view.add', 'png.admin_views', 'png.custom_admin_view.add', 'png.custom_admin_views', 'png.site_view.add', 'png.site_views', 'png.template.add', 'png.templates', 'png.layouts', 'png.dynamic_get.add', 'png.dynamic_gets', 'png.custom_codes', 'png.placeholders', 'png.libraries', 'png.snippets', 'png.get_snippets', 'png.validation_rules', 'png.field.add', 'png.fields', 'png.fields.catid_qpo0O0oqp_com_componentbuilder_po0O0oq_field', 'png.fieldtypes', 'png.fieldtypes.catid_qpo0O0oqp_com_componentbuilder_po0O0oq_fieldtype', 'png.language_translations', 'png.servers', 'png.help_documents')
'main' => array('png.compiler', 'png.joomla_components', 'png.joomla_modules', 'png.joomla_plugins', 'png||importjcbpackages||index.php?option=com_componentbuilder&view=joomla_components&task=joomla_components.smartImport', 'png.admin_view.add', 'png.admin_views', 'png.custom_admin_view.add', 'png.custom_admin_views', 'png.site_view.add', 'png.site_views', 'png.template.add', 'png.templates', 'png.layouts', 'png.dynamic_get.add', 'png.dynamic_gets', 'png.custom_codes', 'png.placeholders', 'png.libraries', 'png.snippets', 'png.get_snippets', 'png.validation_rules', 'png.fields', 'png.fields.catid_qpo0O0oqp_com_componentbuilder_po0O0oq_field', 'png.fieldtypes', 'png.fieldtypes.catid_qpo0O0oqp_com_componentbuilder_po0O0oq_fieldtype', 'png.language_translations', 'png.servers', 'png.help_documents')
);
// view access array
$viewAccess = array(
@ -114,7 +114,6 @@ class ComponentbuilderModelComponentbuilder extends JModelList
'field.access' => 'field.access',
'fields.submenu' => 'field.submenu',
'fields.dashboard_list' => 'field.dashboard_list',
'field.dashboard_add' => 'field.dashboard_add',
'fieldtype.create' => 'fieldtype.create',
'fieldtypes.access' => 'fieldtype.access',
'fieldtype.access' => 'fieldtype.access',

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.2" method="upgrade">
<name>COM_COMPONENTBUILDER</name>
<creationDate>27th August, 2021</creationDate>
<creationDate>31st August, 2021</creationDate>
<author>Llewellyn van der Merwe</author>
<authorEmail>llewellyn@joomlacomponentbuilder.com</authorEmail>
<authorUrl>http://www.joomlacomponentbuilder.com</authorUrl>

View File

@ -6631,7 +6631,7 @@ class com_componentbuilderInstallerScript
{
$rule_length = $db->loadResult();
// Check the size of the rules column
if ($rule_length <= 94400)
if ($rule_length <= 94240)
{
// Fix the assets table rules column size
$fix_rules_size = "ALTER TABLE `#__assets` CHANGE `rules` `rules` MEDIUMTEXT NOT NULL COMMENT 'JSON encoded access control. Enlarged to MEDIUMTEXT by JCB';";