/** * Generates control's HTML element. */ public function getControl() { $input = parent::getControl(); if ($this->path) { $this->template->pathName = $this->getHtmlName() . "-path"; $this->template->path = $this->path; $this->template->setFile(__DIR__ . "/templates/edit.latte"); } else { $this->template->setFile(__DIR__ . "/templates/add.latte"); } $this->template->removedName = $this->getHtmlName() . "-removed"; $this->template->input = $input; $this->template->_form = $this->getForm(); return Html::el()->add((string) $this->template); }
/** * attaches helpers, translator and other useful variables into template * called also from BaseControl::createTemplate() * * @param ITemplate * @return ITemplate */ public function getEnrichedTemplate(ITemplate $tpl) { $tpl->setTranslator($this->getTranslator()); $tpl->registerHelper('html', array('Helpers', 'html')); $tpl->registerHelper('emailSafe', array('Helpers', 'emailSafe')); $tpl->registerHelper('latte', array('Helpers', 'latte')); $tpl->registerHelperLoader('Helpers::functionLoader'); $this->registerUser($tpl); $tpl->model = $this->model; $tpl->httpHost = $this->getHttpRequest()->getUri()->getHost(); return $tpl; }
/** * Includes subtemplate. * @param mixed included file name or template * @param array parameters * @param ITemplate current template * @return NTemplate */ public static function includeTemplate($destination, array $params, ITemplate $template) { if ($destination instanceof ITemplate) { $tpl = $destination; } elseif ($destination == NULL) { // intentionally == throw new InvalidArgumentException("Template file name was not specified."); } elseif ($template instanceof IFileTemplate) { if (substr($destination, 0, 1) !== '/' && substr($destination, 1, 1) !== ':') { $destination = dirname($template->getFile()) . '/' . $destination; } $tpl = clone $template; $tpl->setFile($destination); } else { throw new NotSupportedException('Macro {include "filename"} is supported only with IFileTemplate.'); } $tpl->setParameters($params); // interface? return $tpl; }