Load long texts for inline-edit by AJAX

Display link to current page only under AJAX
This commit is contained in:
Jakub Vrana
2010-10-18 13:57:22 +02:00
parent 78adfc2e3a
commit 390e38b8f5
22 changed files with 68 additions and 48 deletions

View File

@@ -335,6 +335,13 @@ function auth_url($driver, $server, $username) {
;
}
/** Find whether it is an AJAX request
* @return bool
*/
function is_ajax() {
return ($_SERVER["HTTP_X_REQUESTED_WITH"] == "XMLHttpRequest");
}
/** Send Location header and exit
* @param string null to only set a message
* @param string
@@ -346,7 +353,7 @@ function redirect($location, $message = null) {
$_SESSION["messages"][] = $message;
}
if (isset($location)) {
if ($_SERVER["HTTP_X_REQUESTED_WITH"] != "XMLHttpRequest") {
if (!is_ajax()) {
header("Location: " . ($location != "" ? $location : "."));
exit;
}