Ejemplo n.º 1
0
	public function __construct($path)
	{
		$cacheFile = $path . '/routes.php';
		if (is_file($cacheFile = $path . '/routes.php')) {
			$routes = require $cacheFile;
		} else {
			$routes = array();
			foreach (Nette\Utils\Finder::findFiles('*.latte')->from($path) as $file) {
				$latte = new Latte\Engine;
				$macroSet = new Latte\Macros\MacroSet($latte->parser);
				$macroSet->addMacro('url', function($node) use (&$routes, $file) {
					$routes[$node->args] = (string) $file;
				});
				$latte->__invoke(file_get_contents($file));
			}
			file_put_contents($cacheFile, '<?php return ' . var_export($routes, TRUE) . ';');
		}

		foreach ($routes as $mask => $file) {
			$this[] = new Routers\Route($mask, function($presenter) use ($file) {
				return $presenter->createTemplate(NULL, function() {
					$latte = new Nette\Latte\Engine;
					$macroSet = new Latte\Macros\MacroSet($latte->parser);
					$macroSet->addMacro('url', '');
					return $latte;
				})->setFile($file);
			});
		}
	}
Ejemplo n.º 2
0
 public function prepareFilters(Template $template)
 {
     $this->latte = $this->latteFactory->invoke();
     foreach ($this->macroFactories as $factory) {
         $this->container->{Container::getMethodName($factory, FALSE)}($this->latte->getCompiler());
     }
     $template->registerFilter($this->latte);
 }
Ejemplo n.º 3
0
	public function __construct()
	{
		// Register Nette macros
		parent::__construct();

		// Register Nella macros
		Macros\UIMacros::install($this->parser);
	}
Ejemplo n.º 4
0
 /**
  * @param Engine $engine
  */
 public static function setup(Engine $engine)
 {
     self::install($engine->getCompiler());
 }
Ejemplo n.º 5
0
 public function prihozFormSucceeded($button)
 {
     $id = (int) $this->getParameter('id');
     $values = $button->getForm()->getValues(true);
     $values['datum_vkladu'] = date('Y-m-d H:i:s');
     if ($values['pocet'] == $this->database->findAll('drazba')->where('id_nemovitost', $values['id_nemovitost'])->count('*')) {
         // pokud se shoduji pocty prihozu pri nacteni a tesne pred prihozenim, pak vse ok
         unset($values['pocet']);
         // priprava promennych pro poslani emailu o prehozeni
         $nemovitost = $this->database->findById('nemovitost', $id);
         $prihozy = $this->database->findAll('drazba')->where('id_nemovitost', $id);
         $drazba = $this->drazba->vyhodnotDrazbu($id, $prihozy);
         if ($drazba["email"] != null || $drazba["email"] != "") {
             // nastaveni parametru pro latte emailu
             $latte = new Nette\Latte\Engine();
             $params = array('nemovitost' => $nemovitost, 'uzivatel' => $drazba["jmeno"], 'cena' => $drazba["cena"] + $values["vkladana_castka"]);
             // nastaveni mailu
             $mail = new Nette\Mail\Message();
             $mail->setFrom('*****@*****.**')->addTo($drazba["email"])->setHtmlBody($latte->renderToString(__DIR__ . '/../templates/Aukce/email.latte', $params));
             // poslani mailu
             $mailer = new Nette\Mail\SmtpMailer(array('host' => 'smtp.seznam.cz', 'username' => '*****@*****.**', 'password' => 'pps2015', 'secure' => 'ssl'));
             $mailer->send($mail);
         }
         // prihozeni
         $this->database->insert('drazba', $values);
         $this->flashMessage('Přihodil(a) jste ' . number_format($values['vkladana_castka']) . ' Kč.');
         $this->redirect('Nemovitosti:detailNemovitosti', $values['id_nemovitost']);
     } else {
         $this->flashMessage('Znovu zvažte přihození, někdo před Vámi ještě navýšil cenu.');
         $this->redirect('Aukce:prihodit', $values['id_nemovitost']);
     }
 }