Beispiel #1
0
 public function render($templateName, variable_space $data)
 {
     $templateFile = $this->getTemplate($templateName);
     extract($data->asArray());
     $LOCALDATA = $data;
     ob_start();
     try {
         // @todo evaluate performance improvements by caching used templates in closures on frequent use
         include $templateFile;
         $code = ob_get_clean();
     } catch (\Exception $e) {
         ob_end_clean();
         $code = manager::simpleRenderException($e);
     }
     return $code;
 }
Beispiel #2
0
 /**
  * Retrieves HTML code of relating elements of initially related or
  * explicitly selected element.
  *
  * @param array $data custom data to be passed to template on rendering
  * @param string $template name of custom template to use instead of default one on rendering
  * @param int $listNodeAtIndex index of node to list properties of
  *        (default: node at opposite end of relation)
  * @return string rendering result
  */
 public function render($data = array(), $template = null, $listNodeAtIndex = -1)
 {
     $query = $this->query();
     // extend query to fetch all properties of selected node's model
     $query->addProperty($this->datasource->qualifyDatasetName($this->nodeAtIndex($listNodeAtIndex)->getName()) . '.*');
     // process query
     $matches = $query->execute()->all();
     // start variable space initialized using provided set of custom data
     $data = variable_space::fromArray($data);
     // add fetched relation instances to variable space
     $data->update('matches', $matches);
     // add reference on current relation manager instance
     $data->update('relation', $this);
     // render variable space using selected or default template
     return view::render($template ? $template : 'model/relation/generic', $data);
 }
Beispiel #3
0
 /**
  * Returns rendered code of whole current page.
  *
  * @return string code of page
  */
 public function renderPage()
 {
     // ensure to provide output document once, only
     if ($this->renderedBefore) {
         return '';
     }
     $this->renderedBefore = true;
     $this->processConfiguredWidgets("render");
     try {
         // ensure to compile all currently declared flash messages
         static::renderFlashes();
         // prepare content of all used viewports
         $viewports = array();
         foreach ($this->viewports as $key => $vp) {
             $viewports[$key] = $vp->wrap($key == 'main' ? $this->getRawOutput() : '');
         }
         // ensure to have any raw output of scripts (bypassing view manager)
         // to be embedded in viewport main
         if (!\array_key_exists('main', $viewports)) {
             $viewports['main'] = $this->getRawOutput();
         }
         // compile set of viewports into set of regions
         $regions = $this->collectRegions($viewports);
         // use page template to compile set of regions into single output document
         $data = variable_space::create('variables', $this->variables, 'regions', variable_space::fromArray($regions), 'view', $this, 'clientData', $this->compileClientVariables());
         $code = $this->engine->render('page', $data);
     } catch (\Exception $e) {
         $code = self::simpleRenderException($e);
     }
     return $code;
 }