Rename 'ajax' to 'json' because we don't use XML

We use json as response
This commit is contained in:
djmaze 2020-12-30 15:50:47 +01:00
parent 76cf24f426
commit 950579c7f5
18 changed files with 83 additions and 91 deletions

View file

@ -411,10 +411,10 @@ export const Notification = {
ClientViewError: 902, ClientViewError: 902,
InvalidInputArgument: 903, InvalidInputArgument: 903,
AjaxFalse: 950, JsonFalse: 950,
AjaxAbort: 951, JsonAbort: 951,
AjaxParse: 952, JsonParse: 952,
AjaxTimeout: 953, // JsonTimeout: 953,
UnknownNotification: 999, UnknownNotification: 999,
UnknownError: 999 UnknownError: 999

View file

@ -87,7 +87,7 @@ export function settingsSaveHelperSimpleFunction(koTrigger, context) {
} }
let __themeTimer = 0, let __themeTimer = 0,
__themeAjax = null; __themeJson = null;
/** /**
* @param {string} value * @param {string} value
@ -98,7 +98,7 @@ export function changeTheme(value, themeTrigger = ()=>{}) {
const themeLink = doc.getElementById('app-theme-link'), const themeLink = doc.getElementById('app-theme-link'),
clearTimer = () => { clearTimer = () => {
__themeTimer = setTimeout(() => themeTrigger(SaveSettingsStep.Idle), 1000); __themeTimer = setTimeout(() => themeTrigger(SaveSettingsStep.Idle), 1000);
__themeAjax = null; __themeJson = null;
}; };
let themeStyle = doc.getElementById('app-theme-style'), let themeStyle = doc.getElementById('app-theme-style'),
@ -118,13 +118,13 @@ export function changeTheme(value, themeTrigger = ()=>{}) {
themeTrigger(SaveSettingsStep.Animate); themeTrigger(SaveSettingsStep.Animate);
if (__themeAjax) { if (__themeJson) {
__themeAjax.abort(); __themeJson.abort();
} }
let init = {}; let init = {};
if (window.AbortController) { if (window.AbortController) {
__themeAjax = new AbortController(); __themeJson = new AbortController();
init.signal = __themeAjax.signal; init.signal = __themeJson.signal;
} }
rl.fetchJSON(url, init) rl.fetchJSON(url, init)
.then(data => { .then(data => {

View file

@ -2,11 +2,11 @@ import { StorageResultType, Notification } from 'Common/Enums';
import { pInt, pString } from 'Common/Utils'; import { pInt, pString } from 'Common/Utils';
import { serverRequest } from 'Common/Links'; import { serverRequest } from 'Common/Links';
let iAjaxErrorCount = 0, let iJsonErrorCount = 0,
iTokenErrorCount = 0, iTokenErrorCount = 0,
bUnload = false; bUnload = false;
const getURL = (add = '') => serverRequest('Ajax') + add, const getURL = (add = '') => serverRequest('Json') + add,
updateToken = data => { updateToken = data => {
if (data.UpdateToken) { if (data.UpdateToken) {
@ -28,7 +28,7 @@ checkResponseError = data => {
Notification.UnknownError Notification.UnknownError
].includes(err) ].includes(err)
) { ) {
++iAjaxErrorCount; ++iJsonErrorCount;
} }
if (Notification.InvalidToken === err) { if (Notification.InvalidToken === err) {
@ -39,7 +39,7 @@ checkResponseError = data => {
rl.logoutReload(); rl.logoutReload();
} }
if (window.rl && (data.ClearAuth || data.Logout || 7 < iAjaxErrorCount)) { if (window.rl && (data.ClearAuth || data.Logout || 7 < iJsonErrorCount)) {
rl.hash.clear(); rl.hash.clear();
if (!data.ClearAuth) { if (!data.ClearAuth) {
@ -118,7 +118,7 @@ class AbstractFetchRemote
if (StorageResultType.Success === sType && data && !data.Result) { if (StorageResultType.Success === sType && data && !data.Result) {
checkResponseError(data); checkResponseError(data);
} else if (StorageResultType.Success === sType && data && data.Result) { } else if (StorageResultType.Success === sType && data && data.Result) {
iAjaxErrorCount = iTokenErrorCount = 0; iJsonErrorCount = iTokenErrorCount = 0;
} }
if (fCallback) { if (fCallback) {
@ -152,7 +152,7 @@ class AbstractFetchRemote
}).catch(err => { }).catch(err => {
if (err.name == 'AbortError') { // handle abort() if (err.name == 'AbortError') { // handle abort()
err = Notification.AjaxAbort; err = Notification.JsonAbort;
} }
return Promise.reject(err); return Promise.reject(err);
}); });
@ -222,7 +222,7 @@ class AbstractFetchRemote
this.abort(action, true); this.abort(action, true);
if (!data) { if (!data) {
return Promise.reject(Notification.AjaxParse); return Promise.reject(Notification.JsonParse);
} }
updateToken(data); updateToken(data);
@ -249,13 +249,13 @@ class AbstractFetchRemote
if (!data.Result || action !== data.Action) { if (!data.Result || action !== data.Action) {
checkResponseError(data); checkResponseError(data);
const err = data ? data.ErrorCode : null; const err = data ? data.ErrorCode : null;
return Promise.reject(err || Notification.AjaxFalse); return Promise.reject(err || Notification.JsonFalse);
} }
return data; return data;
}).catch(err => { }).catch(err => {
if (err.name == 'AbortError') { // handle abort() if (err.name == 'AbortError') { // handle abort()
return Promise.reject(Notification.AjaxAbort); return Promise.reject(Notification.JsonAbort);
} }
return Promise.reject(err); return Promise.reject(err);
}); });

View file

@ -11,7 +11,7 @@ class CustomAdminSettingsTabPlugin extends \RainLoop\Plugins\AbstractPlugin
$this->addJs('js/CustomAdminSettings.js', true); // add js file $this->addJs('js/CustomAdminSettings.js', true); // add js file
$this->addAjaxHook('AjaxAdminGetData', 'AjaxAdminGetData'); $this->addJsonHook('JsonAdminGetData', 'JsonAdminGetData');
$this->addTemplate('templates/PluginCustomAdminSettingsTab.html', true); $this->addTemplate('templates/PluginCustomAdminSettingsTab.html', true);
} }
@ -19,9 +19,9 @@ class CustomAdminSettingsTabPlugin extends \RainLoop\Plugins\AbstractPlugin
/** /**
* @return array * @return array
*/ */
public function AjaxAdminGetData() public function JsonAdminGetData()
{ {
return $this->ajaxResponse(__FUNCTION__, array( return $this->jsonResponse(__FUNCTION__, array(
'PHP' => phpversion() 'PHP' => phpversion()
)); ));
} }

View file

@ -31,7 +31,7 @@
self.php(oData.Result.PHP || ''); self.php(oData.Result.PHP || '');
} }
}, 'AjaxAdminGetData'); }, 'JsonAdminGetData');
}; };

View file

@ -11,8 +11,8 @@ class CustomSettingsTabPlugin extends \RainLoop\Plugins\AbstractPlugin
$this->addJs('js/CustomUserSettings.js'); // add js file $this->addJs('js/CustomUserSettings.js'); // add js file
$this->addAjaxHook('AjaxGetCustomUserData', 'AjaxGetCustomUserData'); $this->addJsonHook('JsonGetCustomUserData', 'JsonGetCustomUserData');
$this->addAjaxHook('AjaxSaveCustomUserData', 'AjaxSaveCustomUserData'); $this->addJsonHook('JsonSaveCustomUserData', 'JsonSaveCustomUserData');
$this->addTemplate('templates/PluginCustomSettingsTab.html'); $this->addTemplate('templates/PluginCustomSettingsTab.html');
} }
@ -20,7 +20,7 @@ class CustomSettingsTabPlugin extends \RainLoop\Plugins\AbstractPlugin
/** /**
* @return array * @return array
*/ */
public function AjaxGetCustomUserData() public function JsonGetCustomUserData()
{ {
$aSettings = $this->getUserSettings(); $aSettings = $this->getUserSettings();
@ -30,7 +30,7 @@ class CustomSettingsTabPlugin extends \RainLoop\Plugins\AbstractPlugin
// or get user's data from your custom storage ( DB / LDAP / ... ). // or get user's data from your custom storage ( DB / LDAP / ... ).
\sleep(1); \sleep(1);
return $this->ajaxResponse(__FUNCTION__, array( return $this->jsonResponse(__FUNCTION__, array(
'UserFacebook' => $sUserFacebook, 'UserFacebook' => $sUserFacebook,
'UserSkype' => $sUserSkype 'UserSkype' => $sUserSkype
)); ));
@ -39,15 +39,15 @@ class CustomSettingsTabPlugin extends \RainLoop\Plugins\AbstractPlugin
/** /**
* @return array * @return array
*/ */
public function AjaxSaveCustomUserData() public function JsonSaveCustomUserData()
{ {
$sUserFacebook = $this->ajaxParam('UserFacebook'); $sUserFacebook = $this->jsonParam('UserFacebook');
$sUserSkype = $this->ajaxParam('UserSkype'); $sUserSkype = $this->jsonParam('UserSkype');
// or put user's data to your custom storage ( DB / LDAP / ... ). // or put user's data to your custom storage ( DB / LDAP / ... ).
\sleep(1); \sleep(1);
return $this->ajaxResponse(__FUNCTION__, $this->saveUserSettings(array( return $this->jsonResponse(__FUNCTION__, $this->saveUserSettings(array(
'UserFacebook' => $sUserFacebook, 'UserFacebook' => $sUserFacebook,
'UserSkype' => $sUserSkype 'UserSkype' => $sUserSkype
))); )));

View file

@ -22,7 +22,7 @@
}, this); }, this);
} }
CustomUserSettings.prototype.customAjaxSaveData = function () CustomUserSettings.prototype.customJsonSaveData = function ()
{ {
var self = this; var self = this;
@ -46,7 +46,7 @@
// false // false
} }
}, 'AjaxSaveCustomUserData', { }, 'JsonSaveCustomUserData', {
'UserSkype': this.userSkype(), 'UserSkype': this.userSkype(),
'UserFacebook': this.userFacebook() 'UserFacebook': this.userFacebook()
}); });
@ -68,7 +68,7 @@
self.userFacebook(oData.Result.UserFacebook || ''); self.userFacebook(oData.Result.UserFacebook || '');
} }
}, 'AjaxGetCustomUserData'); }, 'JsonGetCustomUserData');
}; };

View file

@ -23,7 +23,7 @@
</div> </div>
<div class="control-group"> <div class="control-group">
<div class="controls"> <div class="controls">
<button class="btn" data-bind="click: customAjaxSaveData, enable: !savingOrLoading()"> <button class="btn" data-bind="click: customJsonSaveData, enable: !savingOrLoading()">
<i data-bind="css: {'icon-floppy': !saving(), 'icon-spinner animated': saving()}" class="icon-floppy"></i> <i data-bind="css: {'icon-floppy': !saving(), 'icon-spinner animated': saving()}" class="icon-floppy"></i>
&nbsp;&nbsp; &nbsp;&nbsp;
<span class="i18n" data-i18n="SETTINGS_CUSTOM_PLUGIN/BUTTON_SAVE"></span> <span class="i18n" data-i18n="SETTINGS_CUSTOM_PLUGIN/BUTTON_SAVE"></span>

View file

@ -9,7 +9,7 @@ class DemoAccountPlugin extends \RainLoop\Plugins\AbstractPlugin
{ {
$this->addHook('filter.app-data', 'FilterAppData'); $this->addHook('filter.app-data', 'FilterAppData');
$this->addHook('filter.action-params', 'FilterActionParams'); $this->addHook('filter.action-params', 'FilterActionParams');
$this->addHook('ajax.action-pre-call', 'AjaxActionPreCall'); $this->addHook('json.action-pre-call', 'JsonActionPreCall');
$this->addHook('filter.send-message', 'FilterSendMessage'); $this->addHook('filter.send-message', 'FilterSendMessage');
$this->addHook('main.fabrica', 'MainFabrica'); $this->addHook('main.fabrica', 'MainFabrica');
} }
@ -63,7 +63,7 @@ class DemoAccountPlugin extends \RainLoop\Plugins\AbstractPlugin
return ($oAccount && $oAccount->Email() === $this->Config()->Get('plugin', 'email')); return ($oAccount && $oAccount->Email() === $this->Config()->Get('plugin', 'email'));
} }
public function AjaxActionPreCall($sAction) public function JsonActionPreCall($sAction)
{ {
if ('AccountSetup' === $sAction && if ('AccountSetup' === $sAction &&
$this->isDemoAccount($this->Manager()->Actions()->GetAccount())) $this->isDemoAccount($this->Manager()->Actions()->GetAccount()))

View file

@ -141,7 +141,7 @@ class Actions
$this->sSpecAuthToken = ''; $this->sSpecAuthToken = '';
$this->sUpdateAuthToken = ''; $this->sUpdateAuthToken = '';
$this->bIsAjax = false; $this->bIsJson = false;
$oConfig = $this->Config(); $oConfig = $this->Config();
$this->Plugins()->RunHook('filter.application-config', array($oConfig)); $this->Plugins()->RunHook('filter.application-config', array($oConfig));
@ -163,9 +163,9 @@ class Actions
return $this; return $this;
} }
public function SetIsAjax(bool $bIsAjax): self public function SetIsJson(bool $bIsJson): self
{ {
$this->bIsAjax = $bIsAjax; $this->bIsJson = $bIsJson;
return $this; return $this;
} }
@ -180,9 +180,9 @@ class Actions
return $this->sUpdateAuthToken; return $this->sUpdateAuthToken;
} }
public function GetIsAjax(): bool public function GetIsJson(): bool
{ {
return $this->bIsAjax; return $this->bIsJson;
} }
public function GetShortLifeSpecAuthToken(int $iLife = 60): string public function GetShortLifeSpecAuthToken(int $iLife = 60): string

View file

@ -387,7 +387,7 @@ trait User
$aResult = array(); $aResult = array();
$this->Plugins()->RunHook('ajax.suggestions-input-parameters', array(&$sQuery, &$iLimit, $oAccount)); $this->Plugins()->RunHook('json.suggestions-input-parameters', array(&$sQuery, &$iLimit, $oAccount));
$iLimit = (int) $iLimit; $iLimit = (int) $iLimit;
if (5 > $iLimit) if (5 > $iLimit)
@ -395,7 +395,7 @@ trait User
$iLimit = 5; $iLimit = 5;
} }
$this->Plugins()->RunHook('ajax.suggestions-pre', array(&$aResult, $sQuery, $oAccount, $iLimit)); $this->Plugins()->RunHook('json.suggestions-pre', array(&$aResult, $sQuery, $oAccount, $iLimit));
if ($iLimit > \count($aResult) && 0 < \strlen($sQuery)) if ($iLimit > \count($aResult) && 0 < \strlen($sQuery))
{ {
@ -442,7 +442,7 @@ trait User
$aResult = \array_slice($aResult, 0, $iLimit); $aResult = \array_slice($aResult, 0, $iLimit);
} }
$this->Plugins()->RunHook('ajax.suggestions-post', array(&$aResult, $sQuery, $oAccount, $iLimit)); $this->Plugins()->RunHook('json.suggestions-post', array(&$aResult, $sQuery, $oAccount, $iLimit));
$aResult = Utils::RemoveSuggestionDuplicates($aResult); $aResult = Utils::RemoveSuggestionDuplicates($aResult);
if ($iLimit < \count($aResult)) if ($iLimit < \count($aResult))

View file

@ -131,17 +131,17 @@ class Identity implements JsonSerializable
return $this; return $this;
} }
public function FromJSON(array $aData, bool $bAjax = false): bool public function FromJSON(array $aData, bool $bJson = false): bool
{ {
if (!empty($aData['Email'])) { if (!empty($aData['Email'])) {
$this->sId = !empty($aData['Id']) ? $aData['Id'] : ''; $this->sId = !empty($aData['Id']) ? $aData['Id'] : '';
$this->sEmail = $bAjax ? Utils::IdnToAscii($aData['Email'], true) : $aData['Email']; $this->sEmail = $bJson ? Utils::IdnToAscii($aData['Email'], true) : $aData['Email'];
$this->sName = isset($aData['Name']) ? $aData['Name'] : ''; $this->sName = isset($aData['Name']) ? $aData['Name'] : '';
$this->sReplyTo = !empty($aData['ReplyTo']) ? $aData['ReplyTo'] : ''; $this->sReplyTo = !empty($aData['ReplyTo']) ? $aData['ReplyTo'] : '';
$this->sBcc = !empty($aData['Bcc']) ? $aData['Bcc'] : ''; $this->sBcc = !empty($aData['Bcc']) ? $aData['Bcc'] : '';
$this->sSignature = !empty($aData['Signature']) ? $aData['Signature'] : ''; $this->sSignature = !empty($aData['Signature']) ? $aData['Signature'] : '';
$this->bSignatureInsertBefore = isset($aData['SignatureInsertBefore']) ? $this->bSignatureInsertBefore = isset($aData['SignatureInsertBefore']) ?
($bAjax ? '1' === $aData['SignatureInsertBefore'] : !!$aData['SignatureInsertBefore']) : true; ($bJson ? '1' === $aData['SignatureInsertBefore'] : !!$aData['SignatureInsertBefore']) : true;
return true; return true;
} }

View file

@ -52,7 +52,7 @@ class Template implements \JsonSerializable
$this->bPopulateAlways = $bPopulateAlways; $this->bPopulateAlways = $bPopulateAlways;
} }
public function FromJSON(array $aData, bool $bAjax = false) : bool public function FromJSON(array $aData, bool $bJson = false) : bool
{ {
if (isset($aData['ID'], $aData['Name'], $aData['Body'])) if (isset($aData['ID'], $aData['Name'], $aData['Body']))
{ {

View file

@ -232,11 +232,11 @@ abstract class AbstractPlugin
return $this; return $this;
} }
protected function addAjaxHook(string $sActionName, string $sFunctionName) : self protected function addJsonHook(string $sActionName, string $sFunctionName) : self
{ {
if ($this->oPluginManager) if ($this->oPluginManager)
{ {
$this->oPluginManager->AddAdditionalAjaxAction($sActionName, array(&$this, $sFunctionName)); $this->oPluginManager->AddAdditionalJsonAction($sActionName, array(&$this, $sFunctionName));
} }
return $this; return $this;
@ -253,11 +253,11 @@ abstract class AbstractPlugin
return $this; return $this;
} }
protected function ajaxResponse(string $sFunctionName, array $aData) : self protected function jsonResponse(string $sFunctionName, array $aData) : self
{ {
if ($this->oPluginManager) if ($this->oPluginManager)
{ {
return $this->oPluginManager->AjaxResponseHelper( return $this->oPluginManager->JsonResponseHelper(
$this->oPluginManager->convertPluginFolderNameToClassName($this->Name()).'::'.$sFunctionName, $aData); $this->oPluginManager->convertPluginFolderNameToClassName($this->Name()).'::'.$sFunctionName, $aData);
} }
@ -269,7 +269,7 @@ abstract class AbstractPlugin
* *
* @return mixed * @return mixed
*/ */
public function ajaxParam(string $sKey, $mDefault = null) public function jsonParam(string $sKey, $mDefault = null)
{ {
if ($this->oPluginManager) if ($this->oPluginManager)
{ {

View file

@ -47,7 +47,7 @@ class Manager
/** /**
* @var array * @var array
*/ */
private $aAdditionalAjax; private $aAdditionalJson;
/** /**
* @var array * @var array
@ -76,8 +76,8 @@ class Manager
$this->aTemplates = array(); $this->aTemplates = array();
$this->aAdminTemplates = array(); $this->aAdminTemplates = array();
$this->aAjaxFilters = array(); $this->aJsonFilters = array();
$this->aAdditionalAjax = array(); $this->aAdditionalJson = array();
$this->aProcessTemplate = array(); $this->aProcessTemplate = array();
$this->bIsEnabled = (bool) $this->oActions->Config()->Get('plugins', 'enable', false); $this->bIsEnabled = (bool) $this->oActions->Config()->Get('plugins', 'enable', false);
@ -438,36 +438,36 @@ class Manager
/** /**
* @param mixed $mCallback * @param mixed $mCallback
*/ */
public function AddAdditionalAjaxAction(string $sActionName, $mCallback) : self public function AddAdditionalJsonAction(string $sActionName, $mCallback) : self
{ {
if ($this->bIsEnabled && \is_callable($mCallback) && 0 < \strlen($sActionName)) if ($this->bIsEnabled && \is_callable($mCallback) && 0 < \strlen($sActionName))
{ {
$sActionName = 'DoPlugin'.$sActionName; $sActionName = 'DoPlugin'.$sActionName;
if (!isset($this->aAdditionalAjax[$sActionName])) if (!isset($this->aAdditionalJson[$sActionName]))
{ {
$this->aAdditionalAjax[$sActionName] = $mCallback; $this->aAdditionalJson[$sActionName] = $mCallback;
} }
} }
return $this; return $this;
} }
public function HasAdditionalAjax(string $sActionName) : bool public function HasAdditionalJson(string $sActionName) : bool
{ {
return $this->bIsEnabled && isset($this->aAdditionalAjax[$sActionName]); return $this->bIsEnabled && isset($this->aAdditionalJson[$sActionName]);
} }
/** /**
* @return mixed * @return mixed
*/ */
public function RunAdditionalAjax(string $sActionName) public function RunAdditionalJson(string $sActionName)
{ {
if ($this->bIsEnabled) if ($this->bIsEnabled)
{ {
if (isset($this->aAdditionalAjax[$sActionName])) if (isset($this->aAdditionalJson[$sActionName]))
{ {
return \call_user_func($this->aAdditionalAjax[$sActionName]); return \call_user_func($this->aAdditionalJson[$sActionName]);
} }
} }
@ -479,7 +479,7 @@ class Manager
* *
* @return mixed * @return mixed
*/ */
public function AjaxResponseHelper(string $sFunctionName, $mData) public function JsonResponseHelper(string $sFunctionName, $mData)
{ {
return $this->oActions->DefaultResponse($sFunctionName, $mData); return $this->oActions->DefaultResponse($sFunctionName, $mData);
} }

View file

@ -74,7 +74,7 @@ class ServiceActions
return $this; return $this;
} }
public function ServiceAjax() : string public function ServiceJson() : string
{ {
\ob_start(); \ob_start();
@ -87,7 +87,7 @@ class ServiceActions
$sAction = $this->aPaths[2]; $sAction = $this->aPaths[2];
} }
$this->oActions->SetIsAjax(true); $this->oActions->SetIsJson(true);
try try
{ {
@ -105,7 +105,7 @@ class ServiceActions
$sMethodName = 'Do'.$sAction; $sMethodName = 'Do'.$sAction;
$this->Logger()->Write('Action: '.$sMethodName, \MailSo\Log\Enumerations\Type::NOTE, 'AJAX'); $this->Logger()->Write('Action: '.$sMethodName, \MailSo\Log\Enumerations\Type::NOTE, 'JSON');
$aPost = $this->oHttp->GetPostAsArray(); $aPost = $this->oHttp->GetPostAsArray();
if ($aPost) if ($aPost)
@ -133,15 +133,15 @@ class ServiceActions
if (\method_exists($this->oActions, $sMethodName) && if (\method_exists($this->oActions, $sMethodName) &&
\is_callable(array($this->oActions, $sMethodName))) \is_callable(array($this->oActions, $sMethodName)))
{ {
$this->Plugins()->RunHook('ajax.action-pre-call', array($sAction)); $this->Plugins()->RunHook('json.action-pre-call', array($sAction));
$aResponseItem = \call_user_func(array($this->oActions, $sMethodName)); $aResponseItem = \call_user_func(array($this->oActions, $sMethodName));
$this->Plugins()->RunHook('ajax.action-post-call', array($sAction, &$aResponseItem)); $this->Plugins()->RunHook('json.action-post-call', array($sAction, &$aResponseItem));
} }
else if ($this->Plugins()->HasAdditionalAjax($sMethodName)) else if ($this->Plugins()->HasAdditionalJson($sMethodName))
{ {
$this->Plugins()->RunHook('ajax.action-pre-call', array($sAction)); $this->Plugins()->RunHook('json.action-pre-call', array($sAction));
$aResponseItem = $this->Plugins()->RunAdditionalAjax($sMethodName); $aResponseItem = $this->Plugins()->RunAdditionalJson($sMethodName);
$this->Plugins()->RunHook('ajax.action-post-call', array($sAction, &$aResponseItem)); $this->Plugins()->RunHook('json.action-post-call', array($sAction, &$aResponseItem));
} }
} }
@ -189,7 +189,7 @@ class ServiceActions
} }
} }
$this->Plugins()->RunHook('filter.ajax-response', array($sAction, &$aResponseItem)); $this->Plugins()->RunHook('filter.json-response', array($sAction, &$aResponseItem));
\header('Content-Type: application/json; charset=utf-8'); \header('Content-Type: application/json; charset=utf-8');
@ -211,7 +211,7 @@ class ServiceActions
$iLimit = (int) $this->Config()->Get('labs', 'log_ajax_response_write_limit', 0); $iLimit = (int) $this->Config()->Get('labs', 'log_ajax_response_write_limit', 0);
$this->Logger()->Write(0 < $iLimit && $iLimit < \strlen($sResult) $this->Logger()->Write(0 < $iLimit && $iLimit < \strlen($sResult)
? \substr($sResult, 0, $iLimit).'...' : $sResult, \MailSo\Log\Enumerations\Type::INFO, 'AJAX'); ? \substr($sResult, 0, $iLimit).'...' : $sResult, \MailSo\Log\Enumerations\Type::INFO, 'JSON');
} }
return $sResult; return $sResult;
@ -316,14 +316,7 @@ class ServiceActions
$aResponseItem = $this->oActions->ExceptionResponse($sAction, $oException); $aResponseItem = $this->oActions->ExceptionResponse($sAction, $oException);
} }
if ('iframe' === $this->oHttp->GetPost('jua-post-type', ''))
{
\header('Content-Type: text/html; charset=utf-8');
}
else
{
\header('Content-Type: application/json; charset=utf-8'); \header('Content-Type: application/json; charset=utf-8');
}
$this->Plugins()->RunHook('filter.upload-response', array(&$aResponseItem)); $this->Plugins()->RunHook('filter.upload-response', array(&$aResponseItem));
$sResult = \MailSo\Base\Utils::Php2js($aResponseItem, $this->Logger()); $sResult = \MailSo\Base\Utils::Php2js($aResponseItem, $this->Logger());

5
vendors/jua/jua.js vendored
View file

@ -88,7 +88,7 @@
* @param {Jua} oJua * @param {Jua} oJua
* @param {Object} oOptions * @param {Object} oOptions
*/ */
class AjaxDriver class XHRDriver
{ {
constructor(oJua, oOptions) constructor(oJua, oOptions)
{ {
@ -170,7 +170,6 @@
fStartFunction && fStartFunction(sUid); fStartFunction && fStartFunction(sUid);
oFormData.append('jua-post-type', 'ajax');
oFormData.append(this.oOptions.name, oFileInfo['File']); oFormData.append(this.oOptions.name, oFileInfo['File']);
Object.entries(aHidden).forEach(([key, value]) => Object.entries(aHidden).forEach(([key, value]) =>
oFormData.append(key, (typeof value === "function" ? value(oFileInfo) : value).toString()) oFormData.append(key, (typeof value === "function" ? value(oFileInfo) : value).toString())
@ -305,7 +304,7 @@
self.oQueue = new Queue(oOptions.queueSize); self.oQueue = new Queue(oOptions.queueSize);
self.oDriver = new AjaxDriver(self, oOptions); self.oDriver = new XHRDriver(self, oOptions);
let el = oOptions.clickElement; let el = oOptions.clickElement;
if (el) { if (el) {

File diff suppressed because one or more lines are too long