Fix a problem with PHP embedded server. $_SERVER['QUERY_STRING'] is not set if it's empty.

This commit is contained in:
Sébastien Lucas 2013-11-29 09:34:32 +01:00
parent ef4cbb79cd
commit 13d0b4c471
2 changed files with 12 additions and 5 deletions

View file

@ -16,6 +16,13 @@ function useServerSideRendering () {
return preg_match("/" . $config['cops_server_side_render'] . "/", $_SERVER['HTTP_USER_AGENT']);
}
function getQueryString () {
if ( isset($_SERVER['QUERY_STRING']) ) {
return $_SERVER['QUERY_STRING'];
}
return "";
}
function getURLParam ($name, $default = NULL) {
if (!empty ($_GET) && isset($_GET[$name]) && $_GET[$name] != "") {
return $_GET[$name];
@ -481,8 +488,8 @@ class Page
public function getNextLink ()
{
$currentUrl = $_SERVER['QUERY_STRING'];
$currentUrl = preg_replace ("/\&n=.*?$/", "", "?" . $_SERVER['QUERY_STRING']);
$currentUrl = getQueryString ();
$currentUrl = preg_replace ("/\&n=.*?$/", "", "?" . getQueryString ());
if (($this->n) * getCurrentOption ("max_item_per_page") < $this->totalNumber) {
return new LinkNavigation ($currentUrl . "&n=" . ($this->n + 1), "next", localize ("paging.next.alternate"));
}
@ -491,8 +498,8 @@ class Page
public function getPrevLink ()
{
$currentUrl = $_SERVER['QUERY_STRING'];
$currentUrl = preg_replace ("/\&n=.*?$/", "", "?" . $_SERVER['QUERY_STRING']);
$currentUrl = getQueryString ();
$currentUrl = preg_replace ("/\&n=.*?$/", "", "?" . getQueryString ());
if ($this->n > 1) {
return new LinkNavigation ($currentUrl . "&n=" . ($this->n - 1), "previous", localize ("paging.previous.alternate"));
}

View file

@ -80,7 +80,7 @@
$(document).ready(function() {
// Handler for .ready() called.
var url = "<?php echo "getJSON.php?" . addURLParameter ($_SERVER["QUERY_STRING"], "complete", 1); ?>";
var url = "<?php echo "getJSON.php?" . addURLParameter (getQueryString (), "complete", 1); ?>";
$.when($.get('templates/default/header.html'),
$.get('templates/default/footer.html'),