/**
  * @param \Nette\Templating\FileTemplate $template
  */
 public function __construct(FileTemplate $template = NULL)
 {
     if ($template === NULL) {
         $template = new FileTemplate();
         $template->registerFilter(new \Nette\Latte\Engine());
     }
     $template->setFile(__DIR__ . '/@form.latte');
     $this->template = $template;
 }
Ejemplo n.º 2
0
 public function createNewTemplate($fileName = NULL)
 {
     $template = NULL;
     if ($fileName !== NULL) {
         $template = new \Nette\Templating\FileTemplate();
         $template->setFile($fileName);
     } else {
         $template = new Nette\Templating\Template();
     }
     $template->setTranslator($this->getPresenter()->context->translator);
     $template->registerFilter(new \Nette\Latte\Engine());
     $template->registerHelperLoader('Nette\\Templating\\Helpers::loader');
     //$baseUrl = rtrim($this->presenter->context->httpRequest->getUrl()->getBaseUrl(), '/');
     $template->basePath = $this->getBasePath();
     $template->themePath = $template->basePath . '/' . strtolower($this->presenter->pageManagerService->getCurrentModule());
     $template->_presenter = $this->presenter;
     $template->_control = $this;
     return $template;
 }
Ejemplo n.º 3
0
 /**
  * Returns the code for the panel itself.
  *
  * @return string
  */
 public function getPanel()
 {
     $template = new FileTemplate();
     $template->setFile(__DIR__ . "/panel.latte");
     $template->onPrepareFilters[] = function ($template) {
         $template->registerFilter(new Engine());
     };
     $template->registerHelperLoader("\\Nette\\Templating\\Helpers::loader");
     $template->setCacheStorage(new PhpFileStorage($this->container->parameters["tempDir"] . "/cache"));
     if ($this->container->application->presenter) {
         $file = $this->container->application->presenter->template->getFile();
         if (!empty($file)) {
             $template->templatePath = $file;
             $template->templateCode = $this->printCode($file);
             $template->presenterLink = $this->container->application->getPresenter()->link("this");
             $template->xhr_header = self::XHR_HEADER;
         }
     }
     ob_start();
     echo $template->render();
     return ob_get_clean();
 }
Ejemplo n.º 4
0
 /** @return Nette\Templating\FileTemplate */
 public function getTemplate()
 {
     $template = new Nette\Templating\FileTemplate();
     $template->registerFilter(new Nette\Latte\Engine());
     $template->registerHelper('json', function ($array) {
         return json_encode($array);
     });
     $template->registerHelper('toArray', function ($array) {
         if ($array instanceof \Traversable) {
             $array = iterator_to_array($array);
         }
         return array_map(function ($object) {
             return $object->toArray();
         }, $array);
     });
     $template->setFile(__DIR__ . '/template.latte');
     $template->basePath = Nette\Environment::getHttpRequest()->getUrl()->basePath;
     return $template;
 }
 /**
  * Renders HTML code for custom panel.
  * @return string
  * @see IDebugPanel::getPanel()
  */
 public function getPanel()
 {
     if ($this->response instanceof \Nette\Application\Responses\ForwardResponse || $this->response instanceof \Nette\Application\Responses\RedirectResponse) {
         return '';
     }
     /** @var Template */
     $template = new FileTemplate();
     $template->setFile(dirname(__FILE__) . "/bar.latte");
     $template->registerFilter(new Engine());
     $template->presenter = $template->control = $template->rootComponent = Environment::getApplication()->getPresenter();
     if ($template->presenter === NULL) {
         return NULL;
     }
     $template->wrap = static::$wrap;
     $template->cache = static::$cache ? Environment::getCache('Debugger.Panels.ComponentTree') : NULL;
     $template->dumps = static::$dumps;
     $template->parametersOpen = static::$parametersOpen;
     $template->presenterOpen = static::$presenterOpen;
     $template->showSources = static::$showSources;
     $template->omittedVariables = static::$omittedTemplateVariables;
     $template->registerHelper('parametersInfo', callback($this, 'getParametersInfo'));
     $template->registerHelper('editlink', callback($this, 'buildEditorLink'));
     $template->registerHelper('highlight', callback($this, 'highlight'));
     $template->registerHelper('filterMethods', callback($this, 'filterMethods'));
     $template->registerHelper('renderedTemplates', callback($this, 'getRenderedTemplates'));
     $template->registerHelper('isPersistent', callback($this, 'isPersistent'));
     $template->registerHelperLoader('Nette\\Templating\\Helpers::loader');
     ob_start();
     $template->render();
     return ob_get_clean();
 }