/** * Render Template * * This method will output the rendered template content * * @param string $template The path to the template, relative to the templates directory. * @param null $data * @return string */ public function render($template, $data = null) { $themetemplates = $this->getTemplatesDirectory(); if (!class_exists('\\_ets')) { if (!is_dir($this->parserDirectory)) { throw new \RuntimeException('Cannot set the Ets lib directory : ' . $this->parserDirectory . '. Directory does not exist.'); } require_once $this->parserDirectory . '/src/ets.php'; } $this->header = $this->inject_variables($this->header, $this->user_vars['header']); $this->header = $this->inject_variables($this->header, $this->user_vars['loops']); $this->footer = $this->inject_variables($this->footer, $this->user_vars['footer']); $this->footer = $this->inject_variables($this->footer, $this->user_vars['loops']); $this->menu = $this->inject_variables($this->menu, $this->user_vars['menu']); $this->menu = $this->inject_variables($this->menu, $this->user_vars['loops']); $this->content->content = $this->data->content; $this->content = $this->inject_variables($this->content, $this->user_vars['main']); $this->content = $this->inject_variables($this->content, $this->user_vars['loops']); if ($this->data->nav && $this->data->nav->total > 0) { $nav = $this->data->nav; $array['pages'] = $nav; $array['pages']->next = $nav->next('<li><a href="{path}/page/{nr}" class="next">»</a></li>', '<li class="disabled"><a href="{path}/page/{nr}">»</a></li>'); $array['pages']->prev = $nav->previous('<li><a href="{path}/page/{nr}" class="prev">«</a></li>', '<li class="disabled"><a href="{path}/page/{nr}">«</a></li>'); $array['pages']->numbers = $nav->numbers('<li><a href="{path}/page/{nr}" class="number">{nr}</a></li>', '<li class="disabled"><a href="{path}/page/{nr}">{nr}</a></li>'); $array['pages']->first = $nav->first('<a href="{path}/page/{nr}" class="first">First</a>'); $array['pages']->last = $nav->last('<a href="{path}/page/{nr}" class="last">Last</a>'); $array['pages']->info = $nav->info(' Page {page} of {pages} '); $this->content = $this->inject_variables($this->content, $array); } if (!is_array($template)) { return \_ets::sprintt($this->header, "{$themetemplates}/@header.tpl.html") . \_ets::sprintt($this->menu, "{$themetemplates}/@menu.tpl.html") . \_ets::sprintt($this->content, "{$themetemplates}/@{$template}") . \_ets::sprintt($this->footer, "{$themetemplates}/@footer.tpl.html"); } else { $template = $template[0]; return \_ets::sprintt($this->content, "{$themetemplates}/@{$template}"); } }
/** * Print out a built template */ function printt($datatree, $containers, $entry = 'main', $hsr = _ETS_SOURCE_READ, $hcr = _ETS_CACHE_READ, $hcw = _ETS_CACHE_WRITE) { $ets = new _ets($containers, $hsr, $hcr, $hcw); echo $ets->build_all($datatree, $entry); }
/** * Print out a built template */ function printt($datatree, $containers, $entry = 'main') { $ets = new _ets($containers); echo $ets->build_all($datatree, $entry); }