X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fajax-functions.php;h=f64f59ea4878adff97c92eb64915ddf12f171c34;hb=987bf5583fce2696a1c6b2b72b123747b4cd4536;hp=47db96ca0bfdf4bf6d6992bc06064cee0e2fd1a7;hpb=2df8c1757b41f35e7c5b6a92c52ca96ab1b0bcb8;p=mailer.git diff --git a/inc/ajax-functions.php b/inc/ajax-functions.php index 47db96ca0b..f64f59ea48 100644 --- a/inc/ajax-functions.php +++ b/inc/ajax-functions.php @@ -10,13 +10,8 @@ * -------------------------------------------------------------------- * * Kurzbeschreibung : AJAX-bezogene Funktionen * * -------------------------------------------------------------------- * - * $Revision:: $ * - * $Date:: $ * - * $Tag:: 0.2.1-FINAL $ * - * $Author:: $ * - * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * - * Copyright (c) 2009 - 2012 by Mailer Developer Team * + * Copyright (c) 2009 - 2015 by Mailer Developer Team * * For more information visit: http://mxchange.org * * * * This program is free software; you can redistribute it and/or modify * @@ -48,6 +43,9 @@ function initAjax () { 'reply_content' => NULL, ); + // Init call-back debug information + $GLOBALS['ajax_callback_function'] = NULL; + // Set content type (mostly JSON) setContentType('application/json'); @@ -58,7 +56,7 @@ function initAjax () { setUsername('{--USERNAME_AJAX--}'); // In installation phase load ajax_installer.php - if (isInstallationPhase()) { + if (isInstaller()) { // Load it loadIncludeOnce('inc/ajax/ajax_installer.php'); } // END - if @@ -66,23 +64,27 @@ function initAjax () { // Setter for AJAX reply content function setAjaxReplyContent ($content) { + // Log message + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'content()=' . strlen($content)); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'content[]=' . gettype($content)); + // Set it, but with URL encoding - $GLOBALS['ajax_reply']['reply_content'] = urlencode(doFinalCompilation($content, false)); + $GLOBALS['ajax_reply']['reply_content'] = urlencode(doFinalCompilation($content, FALSE)); } /** * Checks whether the AJAX access level was valid. This function doesn't need * caching in $GLOBALS[__FUNCTION__] because it will be called only once. */ -function isAjaxRequestLevelValid () { +function isValidAjaxRequestLevel () { // By default nothing is valid - $isValid = false; + $isValid = FALSE; // Switch on the 'level' value switch (postRequestElement('level')) { case 'install': // Installation phase level // Simply check for it - $isValid = isInstallationPhase(); + $isValid = isInstaller(); break; case 'admin': // Admin area @@ -125,13 +127,22 @@ function processAjaxRequest () { } // Send AJAX content -function sendAjaxContent () { +function sendAjaxContent ($forceOutput = FALSE) { // Is the status fine or template not found (404)? - if ((getHttpStatus() == '200 OK') || (getHttpStatus() == '404 NOT FOUND')) { + if ((isAjaxHttpStatusAccepted()) || ($forceOutput === TRUE)) { // Then output the JSON - outputHtml(json_encode($GLOBALS['ajax_reply'], JSON_FORCE_OBJECT)); + outputHtml(encodeJson($GLOBALS['ajax_reply'])); } // END - if } +// Checks whether the HTTP status is accepted +function isAjaxHttpStatusAccepted () { + // Is it accepted? + $isAccepted = in_array(strtoupper(getHttpStatus()), array('200 OK', '404 NOT FOUND')); + + // Return it + return $isAccepted; +} + // [EOF] ?>