inc_cal_js.phtml // // In order to integrate the calendar as a JavaScript, just do as follows: // // // // Put in the URL the parameters that you would like to pass to the function // Calendar(): ?PREFIX=...&CSS_PREFIX=&DATE_URL=...&URL_PARAMETER=... // &USE_SESSION=...&PRESERVE_URL=... // // Utilisation : // ------------- // Ce script doit se trouver a cote du script calendar.php. Si vous avez // renomme calendar.php, ce script doit s'appeler comme le nouveau nom, mais // avec _js en plus. Exemple : inc_cal.phtml => inc_cal_js.phtml // // Pour l'integration JavaScript, il suffit de faire : // // // // Passez dans l'URL les parametres que vous souhaitez passer a la fonction // Calendar() : ?PREFIX=...&CSS_PREFIX=&DATE_URL=...&URL_PARAMETER=... // &USE_SESSION=...&PRESERVE_URL=... // // Content-Type header("Content-Type: text/javascript"); // Shall we display the calendar or the JavaScript that retrieves the missing // parameters? if (isset($_GET["display_calendar"])) { // We display the calendar in the JavaScript format require_once($_SERVER["DOCUMENT_ROOT"].str_replace("_js.", ".", $_SERVER["PHP_SELF"])); // We get all the calendar parameters from the URL // We replace all "true"/"false" by real booleans foreach ($_GET as $key => $value) { if ($value == "true") { $params[$key] = true; } elseif ($value == "false") { $params[$key] = false; } else { $params[$key] = $value; } } $params["JS"] = true; calendar($params); } else { $prefix = (isset($_GET["PREFIX"]))?$_GET["PREFIX"]:"calendar_"; // If sessions are used, we do a session_start() in order to get the SID // if required if (isset($_GET["USE_SESSION"]) && $_GET["USE_SESSION"] = "true") { session_start(); $SID = "&".SID; } else { $SID = ""; } // URL to call the calendar $calendar_URL = str_replace("&", "&", $_SERVER["REQUEST_URI"]); $URL_items = parse_url($calendar_URL); if (isset($URL_items["query"])) { $calendar_URL .= "&"; } else { $calendar_URL .= "?"; } // We add the paremeter to say that the calendar must be display as a // JavaScript $calendar_URL .= "display_calendar=true"; ?> // URL of the current page var calendar_current_url = document.location; // We retrieve the date to display var calendar_month_date = ""; // We also retrieve the SID if it exists for the session var SID = ""; var query_string = this.location.search.substring(1); if (query_string.length > 0) { var params = query_string.split("&"); for (var i = 0; i < params.length; i++) { var pos = params[i].indexOf("="); if (params[i].substring(0, pos) == "date") { calendar_month_date = params[i].substring(pos + 1); } if (params[i].substring(0, pos) == "") { SID = "=" + params[i].substring(pos + 1); } } } // We display the calendar via a second JavaScript call document.write('');