Exemple #1
0
 public function sendMail($formValues)
 {
     //        dump($formValues);
     //        die();
     //
     $template = new Nette\Templating\FileTemplate(__DIR__ . '/emailTemplates/' . $this->templateFilename);
     $template->registerFilter(new Nette\Latte\Engine());
     $template->registerHelperLoader('Nette\\Templating\\Helpers::loader');
     $attachments = array();
     if (isset($formValues['cv']) && $formValues['cv'] instanceof Nette\Http\FileUpload) {
         if ($formValues['cv']->isOk()) {
             $attachments[$formValues['cv']->getName()] = $formValues['cv']->getContents();
         }
     }
     unset($formValues['cv']);
     $template->values = $formValues;
     //        echo $template;
     //        die();
     $mail = new \Nette\Mail\Message();
     $mail->setFrom($this->from)->setSubject($this->subject)->addTo($this->to)->setHtmlBody($template);
     if ($attachments) {
         foreach ($attachments as $name => $content) {
             $mail->addAttachment($name, $content);
         }
     }
     //        foreach ($tos as $to) {
     //            $mail->addTo($to);
     //        }
     $mail->send();
 }
Exemple #2
0
 /**
  *
  * @param Presenter $presenter
  * @return FileTemplate 
  */
 private function createTemplate(Presenter $presenter)
 {
     $template = new FileTemplate();
     $latte = new Engine();
     $template->registerFilter($latte);
     $set = MacroSet::install($latte->getCompiler());
     $template->control = $template->presenter = $presenter;
     return $template;
 }
Exemple #3
0
 public static function getCustomTemplateFile($customTemplate, Nette\Templating\FileTemplate $currentTemplate)
 {
     if (substr($customTemplate, 0, 1) !== '/' && substr($customTemplate, 1, 1) !== ':') {
         $customTemplate = dirname($currentTemplate->getFile()) . '/' . $customTemplate;
     }
     $tpl = clone $currentTemplate;
     $tpl->setFile($customTemplate);
     return $tpl;
 }
 /**
  * @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;
 }
 /**
  * Renders HTML code for custom panel
  * IDebugPanel
  * @return void
  */
 function getPanel()
 {
     ob_start();
     $template = new FileTemplate(dirname(__FILE__) . '/bar.navigation.panel.latte');
     $template->registerFilter(new Engine());
     $template->tree = $this->getPresenters();
     $template->render();
     return $cache['output'] = ob_get_clean();
 }
Exemple #6
0
 /**
  *
  * @param Presenter $presenter
  * @return FileTemplate 
  */
 private function createTemplate(Presenter $presenter)
 {
     $template = new FileTemplate();
     $latte = new Engine();
     $template->registerFilter($latte);
     $set = MacroSet::install($latte->parser);
     $template->control = $template->presenter = $presenter;
     $template->setTranslator($presenter->context->translator);
     return $template;
 }
 /**
  * Redirects using JavaScript.
  * @param string $url 
  * @return void
  */
 public static function redirectUrl($url)
 {
     if (FALSE === Validators::isUrl($url)) {
         throw new \Nette\InvalidArgumentException($url . " is not valid URL.");
     }
     $template = new FileTemplate(dirname(__FILE__) . '/' . self::$TEMPLATE_DIR . '/iframeRedirect.latte');
     $template->registerHelperLoader('Nette\\Templating\\Helpers::loader');
     $template->registerFilter(new \Nette\Latte\Engine());
     $template->url = $url;
     $template->render();
     exit;
 }
 /**
  * Renders HTML code for custom panel.
  * @return string
  * @see IDebugPanel::getPanel()
  */
 public function getPanel()
 {
     $session = Environment::getSession('debug/RequestsPanel');
     $logs = $session->logs;
     if ($this->response instanceof TextResponse) {
         unset($session->logs);
         $template = new FileTemplate(dirname(__FILE__) . '/bar.requests.panel.latte');
         $template->registerFilter(new LatteFilter());
         $template->registerHelper('plural', 'Helpers::plural');
         $template->logs = $logs;
         $template->numberOfLogs = count($logs);
         return $template->__toString();
     }
 }
 /**
  * Renders HTML code for custom panel
  * IDebugPanel
  *
  * @return void
  */
 function getPanel()
 {
     ob_start();
     $template = new FileTemplate(dirname(__FILE__) . '/configurator.panel.latte');
     $template->registerFilter(new Engine());
     $template->parameters = $this->context->params;
     unset($template->parameters['nette']);
     // ??!
     $template->factories = $this->getFactories();
     $template->netteFactories = $this->getNetteFactories();
     $template->services = $this->getServices();
     $template->netteServices = $this->getNetteFactories();
     $template->render();
     return $cache['output'] = ob_get_clean();
 }
Exemple #10
0
 public function sendEmail($form)
 {
     $form = $form->getForm();
     $values = $form->getValues();
     $template = new Nette\Templating\FileTemplate(__DIR__ . '/message.latte');
     $template->registerFilter(new Nette\Latte\Engine());
     $template->registerHelperLoader('Nette\\Templating\\Helpers::loader');
     $template->mailfrom = $values->mailfrom;
     $mail = new Message();
     $mail->setFrom($values->mailfrom)->addTo($values->mailto)->setSubject('Upozornění na stránky www.automarkyzy.cz')->setHtmlBody($template);
     $mailer = new SendmailMailer();
     $mailer->send($mail);
     $this->redrawControl('tellafriend');
     $this->send = TRUE;
 }
Exemple #11
0
 private function saveSitemapIndex()
 {
     $sitemapIndexTemplate = new FileTemplate(__DIR__ . '/sitemapIndex.latte');
     $sitemapIndexTemplate->registerFilter(new Engine());
     $sitemapIndexTemplate->registerHelperLoader('\\Nette\\Templating\\Helpers::loader');
     $sitemapIndexTemplate->sitemapForSitemapIndex = $this->sitemapForSitemapIndex;
     $xmlToSave = $sitemapIndexTemplate->__toString();
     if ($this->subdomain !== NULL) {
         $filename = 'sitemapIndex-' . $this->subdomain . '.xml';
     } else {
         $filename = 'sitemapIndex.xml';
     }
     if (file_exists($filename)) {
         unlink($filename);
     }
     file_put_contents($this->sitemapDir . $filename, $xmlToSave);
 }
 public function getPanel()
 {
     $template = new FileTemplate(dirname(__FILE__) . '/template.latte');
     $template->registerFilter(new LatteFilter());
     $template->registerHelper("editorLink", callback(__CLASS__, "getEditorLink"));
     $template->registerHelper("substr", "substr");
     $template->presenterClass = $this->getPresenter()->getReflection();
     $template->actionName = $this->getPresenter()->getAction(true);
     $template->templateFileName = $this->getTemplateFileName();
     $template->layoutFileName = $this->getLayoutFileName();
     $template->appDirPathLength = strlen(realpath($this->getAppDir()));
     $template->interestedMethods = $this->getInterestedMethodReflections();
     $template->parentClasses = $this->getParentClasses();
     $template->usedComponentMethods = $this->getUsedComponentMethods();
     $template->unusedComponentMethods = $this->getUnusedComponentMethods();
     return $template->__toString();
 }
Exemple #13
0
 /**
  * Returns the code for the panel itself
  * @return string
  */
 public function getPanel()
 {
     $files = array_keys($this->translator->getFiles());
     $strings = $this->translator->getStrings();
     $untranslatedStack = isset($this->sessionStorage['stack']) ? $this->sessionStorage['stack'] : array();
     foreach ($strings as $string => $data) {
         if (!$data) {
             $untranslatedStack[$string] = FALSE;
         }
     }
     $this->sessionStorage['stack'] = $untranslatedStack;
     foreach ($untranslatedStack as $string => $value) {
         if (!isset($strings[$string])) {
             $strings[$string] = FALSE;
         }
     }
     $template = new Nette\Templating\FileTemplate(__DIR__ . '/panel.latte');
     $template->registerFilter(new \Nette\Latte\Engine());
     $template->registerHelperLoader('Nette\\Templating\\Helpers::loader');
     $template->translator = $this->translator;
     $template->ordinalSuffix = function ($count) {
         switch (substr($count, -1)) {
             case '1':
                 return 'st';
                 break;
             case '2':
                 return 'nd';
                 break;
             case '3':
                 return 'rd';
                 break;
             default:
                 return 'th';
                 break;
         }
     };
     $template->application = $this->application;
     $template->strings = $strings;
     $template->height = $this->height;
     $template->layout = $this->layout;
     $template->files = $files;
     $template->xhrHeader = $this->xhrHeader;
     $template->activeFile = $this->getActiveFile($files);
     return $template;
 }
Exemple #14
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;
 }
Exemple #15
0
 public function getControl()
 {
     $container = Nette\Utils\Html::el('span');
     $control = parent::getControl();
     $control->class[] = 'form-control integerPicker';
     /*$template = $this->getForm()->getPresenter()->createTemplate();
     		$template->setFile(__DIR__.'/Templates/control.latte');
     		$template->input = $control; */
     $context = $this->getForm()->getPresenter()->getContext();
     $template = new Nette\Templating\FileTemplate(__DIR__ . '/Templates/control.latte');
     $latte = $context->getService('nette.latte');
     $template->registerFilter($latte);
     vBuilder\Latte\Macros\SystemMacros::install($latte->compiler);
     $template->context = $context;
     $template->input = $control;
     $template->_control = $this->getForm()->lookup('Nette\\Application\\UI\\Control', true);
     $container->setHtml($template);
     return $container;
 }
 /**
  * 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();
 }
Exemple #17
0
 /**
  * @param array $report See ScreenshotMaker::$report
  */
 public function generate(array $report)
 {
     foreach (Finder::findFiles('*.png')->in($this->outDir) as $image) {
         /** @var \SplFileInfo $image */
         $blank = Image::fromBlank(120, 120, array('green' => 255, 'blue' => 255, 'red' => 255));
         $blank->place(Image::fromFile($image->getPathname())->resize(120, 120));
         $blank->save(dirname($image->getPathname()) . '/' . $image->getBasename('.png') . '.thumb.png');
     }
     $tpl = new Nette\Templating\FileTemplate(__DIR__ . '/../templates/report.latte');
     $tpl->registerFilter(new Nette\Latte\Engine());
     $tpl->registerHelperLoader('Nette\\Templating\\Helpers::loader');
     $tpl->registerHelper('resultName', function ($result) {
         static $names = array(StepEvent::PASSED => 'passed', StepEvent::SKIPPED => 'skipped', StepEvent::PENDING => 'pending', StepEvent::UNDEFINED => 'undefined', StepEvent::FAILED => 'failed');
         return isset($names[$result]) ? $names[$result] : '[unknown]';
     });
     $tpl->registerHelper('resultClass', function ($result) {
         static $names = array(StepEvent::PASSED => 'passed', StepEvent::SKIPPED => 'skipped', StepEvent::PENDING => 'pending', StepEvent::UNDEFINED => 'undefined', StepEvent::FAILED => 'failed');
         return isset($names[$result]) ? $names[$result] : '[unknown]';
     });
     // render
     $tpl->report = $report;
     file_put_contents($this->outDir . '/index.html', $tpl->__toString());
 }
 /**
  * Creates template instance
  * 
  * @return Nette\Templating\FileTemplate
  * 
  * @throws Nette\InvalidStateException if template file was not set
  * @throws Nette\InvalidArgumentException if template file does not exists
  */
 protected function createTemplate()
 {
     if (empty($this->templateFile)) {
         throw new Nette\InvalidStateException("Template file was not set. Forget to call " . get_called_class() . "::setTempplate()?");
     }
     if (!file_exists($this->templateFile)) {
         throw new Nette\InvalidArgumentException("Invoice template file '{$this->templateFile}' does not exist.");
     }
     $template = new Nette\Templating\FileTemplate($this->templateFile);
     $template->registerFilter(new Nette\Latte\Engine());
     $template->registerHelperLoader('Nette\\Templating\\DefaultHelpers::loader');
     $template->registerHelper('currency', 'vStore\\Latte\\Helpers\\Shop::currency');
     $template->baseUrl = rtrim($this->context->httpRequest->getUrl()->getBaseUrl(), '/');
     $template->renderer = $this;
     return $template;
 }
 /**
  * @return void
  */
 public static function initRuntime(Nette\Templating\FileTemplate $template, \stdClass $global)
 {
     if (!empty($global->caches)) {
         end($global->caches)->dependencies[Nette\Caching\Cache::FILES][] = $template->getFile();
     }
 }
Exemple #20
0
 /**
  * Template factory
  * @return Template
  */
 private function createTemplate()
 {
     $template = new FileTemplate();
     $template->registerFilter(new Engine());
     return $template;
 }
Exemple #21
0
 /**
  * Constructor
  *
  * @param $templateName
  */
 public function __construct($templateName)
 {
     $this->template = new \Nette\Templating\FileTemplate(SUBSCRIBE_TEMPLATES . $templateName);
     $this->template->registerFilter(new \Nette\Latte\Engine());
     $this->template->registerHelperLoader('\\Nette\\Templating\\Helpers::loader');
 }
 /**
  * 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();
 }
 public function __construct($file = NULL)
 {
     parent::__construct($file);
     $this->onPrepareFilters[] = callback($this, "registerFilters");
 }
Exemple #24
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;
 }
Exemple #25
0
 private function buildPDFApplication($id, $file = null)
 {
     $record = $this->model->get($id);
     if (!$record) {
         return;
     }
     $set = $this->setModel->get($record->wrk_set_id);
     $template = new \Nette\Templating\FileTemplate(__DIR__ . '/../../templates/pdf/workApplication-' . $set->template . '.latte');
     $template->registerFilter(new \Nette\Latte\Engine());
     $template->registerHelperLoader('\\Nette\\Templating\\Helpers::loader');
     $templateHeader = new \Nette\Templating\FileTemplate(__DIR__ . '/../../templates/pdf/generalHeader.latte');
     $templateHeader->registerFilter(new \Nette\Latte\Engine());
     $templateHeader->registerHelperLoader('\\Nette\\Templating\\Helpers::loader');
     $templateOddFooter = new \Nette\Templating\FileTemplate(__DIR__ . '/../../templates/pdf/generalOddFooter.latte');
     $templateOddFooter->registerFilter(new \Nette\Latte\Engine());
     $templateOddFooter->registerHelperLoader('\\Nette\\Templating\\Helpers::loader');
     $templateEvenFooter = new \Nette\Templating\FileTemplate(__DIR__ . '/../../templates/pdf/generalEvenFooter.latte');
     $templateEvenFooter->registerFilter(new \Nette\Latte\Engine());
     $templateEvenFooter->registerHelperLoader('\\Nette\\Templating\\Helpers::loader');
     $template->date = new \Nette\DateTime();
     $template->work = $record;
     $template->idea = $this->ideaModel->get($record->wrk_assignment_id);
     $template->goals = $this->ideaModel->getGoals($record->wrk_assignment_id);
     $template->outline = $this->ideaModel->getOutline($record->wrk_assignment_id);
     $template->roles = $this->model->getAssignedRolesForPrintApplication($id);
     require "../vendor/mpdf/mpdf/mpdf.php";
     $mpdf = new \mPDF('', 'A4', 10, 'arial');
     $mpdf->mirrorMargins = true;
     $mpdf->ignore_invalid_utf8 = true;
     $mpdf->WriteHTML(file_get_contents('css/pdf.css'), 1);
     $mpdf->SetHTMLHeader($templateHeader->__toString());
     $mpdf->SetHTMLFooter($templateEvenFooter->__toString(), "E");
     $mpdf->SetHTMLFooter($templateOddFooter->__toString(), "O");
     $mpdf->WriteHTML($template->__toString());
     if ($file) {
         $mpdf->Output($file, "F");
         return;
     }
     $mpdf->Output();
 }
Exemple #26
0
 public function __construct(\Latte\Engine $latte)
 {
     parent::__construct(null);
     $this->registerFilter($latte);
     $this->registerHelperLoader('Nette\\Templating\\Helpers::loader');
 }
Exemple #27
0
nodeClosed(Latte\MacroNode$node){$node->closingCode='<?php $_l->tmp = array_pop($_g->caches); if (!$_l->tmp instanceof stdClass) $_l->tmp->end(); } ?>';}static
function
initRuntime(Nette\Templating\FileTemplate$template,\stdClass$global){if(!empty($global->caches)){end($global->caches)->dependencies[Nette\Caching\Cache::FILES][]=$template->getFile();}}static
Exemple #28
0
 /**
  * Returns the code for the panel tab.
  * @return string
  */
 public function getTab()
 {
     $template = new Nette\Templating\FileTemplate(__DIR__ . '/tab.phtml');
     return $template->__toString();
 }
Exemple #29
0
 /**
  * @return Nette\Templating\ITemplate
  */
 protected function createTemplate()
 {
     $template = new Nette\Templating\FileTemplate();
     $presenter = $this->getPresenter(FALSE);
     $template->onPrepareFilters[] = callback($this, 'templatePrepareFilters');
     // default parameters
     $template->control = $this;
     $template->presenter = $presenter;
     if ($presenter instanceof Presenter) {
         $template->setCacheStorage($presenter->getContext()->templateCacheStorage);
         $template->user = $presenter->getUser();
         $template->netteHttpResponse = $presenter->getHttpResponse();
         $template->netteCacheStorage = $presenter->getContext()->cacheStorage;
         $template->baseUri = $template->baseUrl = rtrim($presenter->getHttpRequest()->getUrl()->getBaseUrl(), '/');
         $template->basePath = preg_replace('#https?://[^/]+#A', '', $template->baseUrl);
         // flash message
         if ($presenter->hasFlashSession()) {
             $id = $this->getParamId('flash');
             $template->flashes = $presenter->getFlashSession()->{$id};
         }
     }
     if (!isset($template->flashes) || !is_array($template->flashes)) {
         $template->flashes = array();
     }
     // default helpers
     $template->registerHelper('escape', 'Nette\\Templating\\DefaultHelpers::escapeHtml');
     $template->registerHelper('escapeUrl', 'rawurlencode');
     $template->registerHelper('stripTags', 'strip_tags');
     $template->registerHelper('nl2br', 'nl2br');
     $template->registerHelper('substr', 'iconv_substr');
     $template->registerHelper('repeat', 'str_repeat');
     $template->registerHelper('replaceRE', 'Nette\\Utils\\Strings::replace');
     $template->registerHelper('implode', 'implode');
     $template->registerHelper('number', 'number_format');
     $template->registerHelperLoader('Nette\\Templating\\DefaultHelpers::loader');
     return $template;
 }