/**
  * Renders the css for our frontend.
  *
  * Sets etags to avoid sending not needed data
  */
 public function render_css()
 {
     header('HTTP/1.1 200 OK');
     header('Content-Type: text/css', true, 200);
     // Aggressive caching to save future requests from the same client.
     $etag = '"' . md5(__FILE__ . $_GET[self::GET_VARIBALE_NAME]) . '"';
     header('ETag: ' . $etag);
     $max_age = 31536000;
     header('Expires: ' . gmdate('D, d M Y H:i:s', Ai1ec_Time_Utility::current_time() + $max_age) . ' GMT');
     header('Cache-Control: public, max-age=' . $max_age);
     if (empty($_SERVER['HTTP_IF_NONE_MATCH']) || $etag !== stripslashes($_SERVER['HTTP_IF_NONE_MATCH'])) {
         // compress data if possible
         if (Ai1ec_Http_Utility::client_use_gzip()) {
             ob_start('ob_gzhandler');
             header('Content-Encoding: gzip');
         } else {
             ob_start();
         }
         $content = $this->get_compiled_css();
         echo $content;
         ob_end_flush();
     } else {
         // Not modified!
         status_header(304);
     }
     // We're done!
     ai1ec_stop(0);
 }
 /**
  * Render the javascript for the appropriate page
  * 
  */
 public function render_js()
 {
     header('HTTP/1.1 200 OK');
     header('Content-Type: application/javascript; charset=utf-8', true, 200);
     // Aggressive caching to save future requests from the same client.
     $etag = '"' . md5(__FILE__ . $_GET[self::LOAD_JS_PARAMETER]) . '"';
     header('ETag: ' . $etag);
     $max_age = 31536000;
     // One Year
     header('Expires: ' . gmdate('D, d M Y H:i:s', Ai1ec_Time_Utility::current_time() + $max_age) . ' GMT');
     header('Cache-Control: public, max-age=' . $max_age);
     if (empty($_SERVER['HTTP_IF_NONE_MATCH']) || $etag !== stripslashes($_SERVER['HTTP_IF_NONE_MATCH'])) {
         // compress data if possible
         if (Ai1ec_Http_Utility::client_use_gzip()) {
             ob_start('ob_gzhandler');
             header('Content-Encoding: gzip');
         } else {
             ob_start();
         }
         $js_path = AI1EC_ADMIN_THEME_JS_PATH . DIRECTORY_SEPARATOR;
         $common_js = '';
         $page_to_load = $_GET[self::LOAD_JS_PARAMETER];
         if ($_GET[self::IS_BACKEND_PARAMETER] === self::TRUE_PARAM) {
             $common_js = file_get_contents($js_path . 'pages/common_backend.js');
         } else {
             if ($page_to_load === self::EVENT_PAGE_JS || $page_to_load === self::CALENDAR_PAGE_JS || $page_to_load === self::LOAD_ONLY_FRONTEND_SCRIPTS) {
                 if ($page_to_load === self::LOAD_ONLY_FRONTEND_SCRIPTS && true === self::$frontend_scripts_loaded) {
                     return;
                 }
                 if (false === self::$frontend_scripts_loaded) {
                     $common_js = file_get_contents($js_path . 'pages/common_frontend.js');
                     self::$frontend_scripts_loaded = true;
                 }
             }
         }
         // create the config object for require js
         $require_config = $this->create_require_js_config_object();
         // load require
         $require = file_get_contents($js_path . 'require.js');
         // get jquery
         $jquery = $this->get_jquery_version_based_on_browser($_SERVER['HTTP_USER_AGENT']);
         // load the script for the page
         $page_js = '';
         if ($page_to_load !== self::LOAD_ONLY_BACKEND_SCRIPTS && $page_to_load !== self::LOAD_ONLY_FRONTEND_SCRIPTS) {
             $page_js = file_get_contents($js_path . 'pages/' . $page_to_load);
         }
         $translation = $this->get_frontend_translation_data();
         $permalink = get_permalink($this->settings->calendar_page_id);
         $translation['calendar_url'] = $permalink;
         $tranlsation_module = $this->create_require_js_module(self::FRONTEND_CONFIG_MODULE, $translation);
         $config = $this->create_require_js_module('ai1ec_config', $this->get_translation_data());
         echo $require . $require_config . $tranlsation_module . $config . $jquery . $page_js . $common_js;
         ob_end_flush();
     } else {
         // Not modified!
         status_header(304);
     }
     // We're done!
     ai1ec_stop(0);
 }