示例#1
0
 public function register()
 {
     Event::register('app_init', 'empire\\framework\\app\\App', $this, 'test');
 }
示例#2
0
 public function render()
 {
     Event::fire('document_rendered', array(&$this->content));
     header("Content-Type: application/json");
     echo $this->content;
 }
示例#3
0
 public function register()
 {
     Event::register('print', 'empire\\framework\\app\\App', $this, 'prints');
 }
示例#4
0
 /**
  * Render this HTML document.
  *
  * This method adds the template assets and processes all assets added by the mod or components.
  * It then fills the data array
  * and calls the {@link \empire\framework\template\TemplateRenderer::render}
  *
  * @see empire\framework\document.Document::render()
  */
 public function render()
 {
     $template = $this->app->getPage()->getTemplate();
     // add template common files
     $templateAssets = $this->app->getFileSystem()->getFileList($this->app->getTemplateDirectory() . DIRECTORY_SEPARATOR . $template . DIRECTORY_SEPARATOR . 'pub' . DIRECTORY_SEPARATOR . 'common');
     if (!empty($templateAssets)) {
         foreach ($templateAssets as $index => $asset) {
             $path = $this->app->getPath();
             $templateAssets[$index] = array('path' => $path->pathToRelativeURL($asset));
         }
         $this->addAssets($templateAssets);
     }
     // process the assets
     $this->processAssets();
     $data = array();
     $data['css'] = $this->css;
     $data['scripts'] = $this->scripts;
     $data['meta'] = $this->meta;
     $htmlFormatter = $this->app->getFormatterFactory()->getFormatter('html');
     $data['title'] = $htmlFormatter->format($this->app->getPage()->getTitle());
     $data['siteTitle'] = $htmlFormatter->format($this->app->getConfigurationManager()->getAppConfiguration()->title);
     $data['remoteDir'] = $this->app->getRemoteDir();
     $data['startPage'] = $this->app->getGenericURL($this->app->getID(), $this->app->getStartPageID(), $this->app->getPage()->getDefaultTask());
     // add module
     $data['main'] = $this->content;
     // TODO choose template language
     $templateLanguage = $this->app->getTemplateLanguageFactory()->getLanguage($this->app->getConfigurationManager()->getFlavorsConfiguration()->defaultTemplateLanguage);
     $rendered = $this->app->getTemplateRenderer()->render($data, $this->app->getTemplateDirectory() . DIRECTORY_SEPARATOR . $template . DIRECTORY_SEPARATOR . 'main.html', $templateLanguage);
     Event::fire('document_rendered', array(&$rendered));
     header('Content-type: text/html; charset=utf-8');
     header('X-Frame-Options: DENY');
     echo $rendered;
 }