Ejemplo n.º 1
0
 private function _avelancheTransform($text, $filterParams = NULL, $templateParams = NULL)
 {
     //dump($filterParams);
     $_temp = $text;
     $hash = NULL;
     $oldHash = NULL;
     for ($i = 1; $i <= 50; $i++) {
         $template = new \Nette\Templating\Template();
         $template->setTranslator($this->presenter->context->translator);
         $template->setSource($_temp);
         $template->add('_presenter', $this->presenter);
         $template->add('_control', $this->presenter);
         $template->add('_page', $this);
         if ($templateParams !== NULL) {
             foreach ($templateParams as $k => $v) {
                 $template->add($k, $v);
             }
         }
         $template->onPrepareFilters[] = function ($template) use($filterParams) {
             $template->registerFilter(new Bubo\Filters\CMSFilter($filterParams));
         };
         $template->onPrepareFilters[] = function ($template) {
             $template->registerFilter(new \Nette\Latte\Engine());
         };
         //$template->setCacheStorage(new \Nette\Caching\Storages\PhpFileStorage(TEMP_DIR.'/cache'));
         $_temp = $template->__toString();
         if (($hash = sha1($_temp)) == $oldHash) {
             break;
         }
         $oldHash = $hash;
     }
     return $_temp;
 }