Beispiel #1
0
 /**
  * Ask the AetherSection to render itself,
  * or if a service is requested it will try to load that service
  *
  * @access public
  * @return string
  */
 public function render()
 {
     $config = $this->sl->get('aetherConfig');
     $options = $config->getOptions();
     /**
      * If a service is requested simply render the service
      */
     if (isset($_GET['module']) && isset($_GET['service'])) {
         $response = $this->section->service($_GET['module'], $_GET['service']);
         if (!is_object($response) || !$response instanceof AetherResponse) {
             trigger_error("Expected " . preg_replace("/[^A-z0-9]+/", "", $_GET['module']) . "::service() to return an AetherResponse object", E_USER_WARNING);
         } else {
             $response->draw($this->sl);
         }
     } else {
         if (isset($_GET['_esi'])) {
             /**
              * ESI support and rendering of only one module by provider name
              * # _esi to list
              * # _esi=<providerName> to render one module with settings of the url path
              */
             if (strlen($_GET['_esi']) > 0) {
                 $this->section->renderProviderWithCacheHeaders($_GET['_esi']);
             } else {
                 $modules = $config->getModules();
                 $providers = array();
                 foreach ($modules as $m) {
                     $providers[] = array('provides' => $m['provides'], 'cache' => isset($m['cache']) ? $m['cache'] : false);
                 }
                 $response = new AetherJSONResponse(array('providers' => $providers));
                 $response->draw($this->sl);
             }
         } else {
             /**
              * Start session if session switch is turned on in 
              * configuration file
              */
             if (array_key_exists('session', $options) and $options['session'] == 'on') {
                 session_start();
             }
             $response = $this->section->response();
             $response->draw($this->sl);
         }
     }
 }
Beispiel #2
0
 /**
  * Ask the AetherSection to render itself,
  * or if a service is requested it will try to load that service
  *
  * @access public
  * @return string
  */
 public function render()
 {
     $config = $this->sl->get('aetherConfig');
     $options = $config->getOptions();
     /**
      * If a service is requested simply render the service
      */
     if (isset($_GET['module']) && isset($_GET['service'])) {
         $response = $this->section->service($_GET['module'], $_GET['service']);
         if (!is_object($response) || !$response instanceof AetherResponse) {
             trigger_error("Expected " . preg_replace("/[^A-z0-9]+/", "", $_GET['module']) . "::service() to return an AetherResponse object." . (isset($_SERVER['HTTP_REFERER']) ? " Referer: " . $_SERVER['HTTP_REFERER'] : ""), E_USER_WARNING);
         } else {
             $response->draw($this->sl);
         }
     } else {
         if (isset($_GET['fragment']) && isset($_GET['service'])) {
             $response = $this->section->service($_GET['fragment'], $_GET['service'] !== "_esi" ? $_GET['service'] : null, 'fragment');
             $response->draw($this->sl);
         } else {
             if (isset($_GET['_esi'])) {
                 /**
                  * ESI support and rendering of only one module by provider name
                  * # _esi to list
                  * # _esi=<providerName> to render one module with settings of the url path
                  */
                 if (strlen($_GET['_esi']) > 0) {
                     $locale = isset($options['locale']) ? $options['locale'] : "nb_NO.UTF-8";
                     setlocale(LC_ALL, $locale);
                     $lc_numeric = isset($options['lc_numeric']) ? $options['lc_numeric'] : 'C';
                     setlocale(LC_NUMERIC, $lc_numeric);
                     if (isset($options['lc_messages'])) {
                         $localeDomain = "messages";
                         setlocale(LC_MESSAGES, $options['lc_messages']);
                         bindtextdomain($localeDomain, self::$aetherPath . "/locales");
                         bind_textdomain_codeset($localeDomain, 'UTF-8');
                         textdomain($localeDomain);
                     }
                     $this->section->renderProviderWithCacheHeaders($_GET['_esi']);
                 } else {
                     $modules = $config->getModules();
                     $fragments = $config->getFragments();
                     $providers = array();
                     foreach ($modules + $fragments as $m) {
                         $provider = ['provides' => isset($m['provides']) ? $m['provides'] : null, 'cache' => isset($m['cache']) ? $m['cache'] : false];
                         if (isset($m['module'])) {
                             $provider['providers'] = array_map(function ($m) {
                                 return ['provides' => $m['provides'], 'cache' => isset($m['cache']) ? $m['cache'] : false];
                             }, array_values($m['module']));
                         }
                         $providers[] = $provider;
                     }
                     $response = new AetherJSONResponse(array('providers' => $providers));
                     $response->draw($this->sl);
                 }
             } else {
                 /**
                  * Start session if session switch is turned on in 
                  * configuration file
                  */
                 if (array_key_exists('session', $options) and $options['session'] == 'on') {
                     session_start();
                 }
                 $response = $this->section->response();
                 $response->draw($this->sl);
             }
         }
     }
 }