Exemplo n.º 1
0
 /**
  * @return Template
  */
 public function createTemplate(UI\Control $control = NULL)
 {
     $latte = $this->latteFactory->create();
     $template = new Template($latte);
     $presenter = $control ? $control->getPresenter(FALSE) : NULL;
     if ($control instanceof UI\Presenter) {
         $latte->setLoader(new Loader($control));
     }
     if ($latte->onCompile instanceof \Traversable) {
         $latte->onCompile = iterator_to_array($latte->onCompile);
     }
     array_unshift($latte->onCompile, function ($latte) use($control, $template) {
         $latte->getCompiler()->addMacro('cache', new Nette\Bridges\CacheLatte\CacheMacro($latte->getCompiler()));
         UIMacros::install($latte->getCompiler());
         if (class_exists(Nette\Bridges\FormsLatte\FormMacros::class)) {
             Nette\Bridges\FormsLatte\FormMacros::install($latte->getCompiler());
         }
         if ($control) {
             $control->templatePrepareFilters($template);
         }
     });
     $latte->addFilter('url', 'rawurlencode');
     // back compatiblity
     foreach (['normalize', 'toAscii', 'webalize', 'padLeft', 'padRight', 'reverse'] as $name) {
         $latte->addFilter($name, 'Nette\\Utils\\Strings::' . $name);
     }
     $latte->addFilter('null', function () {
     });
     $latte->addFilter('modifyDate', function ($time, $delta, $unit = NULL) {
         return $time == NULL ? NULL : Nette\Utils\DateTime::from($time)->modify($delta . $unit);
         // intentionally ==
     });
     if (!isset($latte->getFilters()['translate'])) {
         $latte->addFilter('translate', function (Latte\Runtime\FilterInfo $fi) {
             throw new Nette\InvalidStateException('Translator has not been set. Set translator using $template->setTranslator().');
         });
     }
     // default parameters
     $template->user = $this->user;
     $template->baseUri = $template->baseUrl = $this->httpRequest ? rtrim($this->httpRequest->getUrl()->getBaseUrl(), '/') : NULL;
     $template->basePath = preg_replace('#https?://[^/]+#A', '', $template->baseUrl);
     $template->flashes = [];
     if ($control) {
         $template->control = $control;
         $template->presenter = $presenter;
         $latte->addProvider('uiControl', $control);
         $latte->addProvider('uiPresenter', $presenter);
         $latte->addProvider('snippetBridge', new Nette\Bridges\ApplicationLatte\SnippetBridge($control));
     }
     $latte->addProvider('cacheStorage', $this->cacheStorage);
     // back compatibility
     $template->_control = $control;
     $template->_presenter = $presenter;
     $template->netteCacheStorage = $this->cacheStorage;
     if ($presenter instanceof UI\Presenter && $presenter->hasFlashSession()) {
         $id = $control->getParameterId('flash');
         $template->flashes = (array) $presenter->getFlashSession()->{$id};
     }
     return $template;
 }
Exemplo n.º 2
0
 public function addSnippet($name, $content)
 {
     if ($this->payload === NULL) {
         $this->payload = $this->control->getPresenter()->getPayload();
     }
     $this->payload->snippets[$this->control->getSnippetId($name)] = $content;
 }
Exemplo n.º 3
0
 /**
  * Checks whether an item is current.
  *
  * If the voter is not able to determine a result,
  * it should return null to let other voters do the job.
  *
  * @param ItemInterface $item
  *
  * @return boolean|null
  */
 public function matchItem(ItemInterface $item)
 {
     if ($item->getExtra('link', false) && $this->parentControl) {
         $presenter = $this->parentControl->getPresenter(true);
         $item->setCurrent(call_user_func_array(array($presenter, 'isLinkCurrent'), $item->getExtra('link')));
         return $item->isCurrent();
     }
     return null;
 }
Exemplo n.º 4
0
	/**
	 * @return Template
	 */
	public function createTemplate(UI\Control $control)
	{
		$latte = $this->latteFactory->create();
		$template = new Template($latte);
		$presenter = $control->getPresenter(FALSE);

		if ($control instanceof UI\Presenter) {
			$latte->setLoader(new Loader($control));
		}

		if ($latte->onCompile instanceof \Traversable) {
			$latte->onCompile = iterator_to_array($latte->onCompile);
		}

		array_unshift($latte->onCompile, function ($latte) use ($control, $template) {
			$latte->getParser()->shortNoEscape = TRUE;
			$latte->getCompiler()->addMacro('cache', new Nette\Bridges\CacheLatte\CacheMacro($latte->getCompiler()));
			UIMacros::install($latte->getCompiler());
			if (class_exists('Nette\Bridges\FormsLatte\FormMacros')) {
				Nette\Bridges\FormsLatte\FormMacros::install($latte->getCompiler());
			}
			$control->templatePrepareFilters($template);
		});

		$latte->addFilter('url', 'rawurlencode'); // back compatiblity
		foreach (array('normalize', 'toAscii', 'webalize', 'padLeft', 'padRight', 'reverse') as $name) {
			$latte->addFilter($name, 'Nette\Utils\Strings::' . $name);
		}
		$latte->addFilter('null', function () {});
		$latte->addFilter('length', function ($var) {
			return is_string($var) ? Nette\Utils\Strings::length($var) : count($var);
		});
		$latte->addFilter('modifyDate', function ($time, $delta, $unit = NULL) {
			return $time == NULL ? NULL : Nette\Utils\DateTime::from($time)->modify($delta . $unit); // intentionally ==
		});

		// default parameters
		$template->control = $template->_control = $control;
		$template->presenter = $template->_presenter = $presenter;
		$template->user = $this->user;
		$template->netteHttpResponse = $this->httpResponse;
		$template->netteCacheStorage = $this->cacheStorage;
		$template->baseUri = $template->baseUrl = $this->httpRequest ? rtrim($this->httpRequest->getUrl()->getBaseUrl(), '/') : NULL;
		$template->basePath = preg_replace('#https?://[^/]+#A', '', $template->baseUrl);
		$template->flashes = array();

		if ($presenter instanceof UI\Presenter && $presenter->hasFlashSession()) {
			$id = $control->getParameterId('flash');
			$template->flashes = (array) $presenter->getFlashSession()->$id;
		}

		return $template;
	}
Exemplo n.º 5
0
 public function __construct(User $user, CustomerService $cus, CountriesService $cs)
 {
     parent::__construct();
     $this->user = $user;
     $this->cus = $cus;
     $this->cs = $cs;
 }
Exemplo n.º 6
0
 /**
  * @param \Nette\ComponentModel\Container $obj
  */
 protected function attached($obj)
 {
     parent::attached($obj);
     if ($obj instanceof Nette\Application\UI\Presenter) {
         $this->payPal->setReturnAddress($this->link('//return!'), $this->link('//cancel!'));
     }
 }
Exemplo n.º 7
0
	/**
	 * Automatically registers template file.
	 *
	 * @author   Jan Tvrdík
	 * @param    string
	 * @return   Nette\Templating\FileTemplate
	 */
	protected function createTemplate($class = NULL)
	{
		$template = parent::createTemplate($class);
		if ($this->autoSetupTemplateFile) $template->setFile($this->getTemplateFilePath());

		return $template;
	}
Exemplo n.º 8
0
 /**
  * Editrouble constructor.
  * @param IContainer $parent
  * @param string $name
  * @param Connector $connector
  */
 public function __construct(IContainer $parent, $name, Connector $connector, Request $request)
 {
     parent::__construct($parent, $name);
     $this->connector = $connector;
     $this->storage = $connector->getStorage();
     $this->request = $request;
 }
Exemplo n.º 9
0
 public function __construct(States $states, Colors $colors)
 {
     parent::__construct();
     $this->states = $states;
     $this->ordered = $this->states->findBy([], ['sequence' => 'ASC']);
     $this->colors = $colors;
 }
Exemplo n.º 10
0
 public function __construct($default_render = self::TYPE_MINI, IPictureViewFactory $picture_view_factory, IGlobalSettings $settings)
 {
     parent::__construct();
     $this->default_render = $default_render;
     $this->picture_view_factory = $picture_view_factory;
     $this->settings = $settings;
 }
Exemplo n.º 11
0
 public function __construct($parent, $name)
 {
     parent::__construct($parent, $name);
     $this->templatesDir = __DIR__ . "/templates/";
     $this->templateFile = $this->templatesDir . "default.latte";
     $this->homepageTemplateFile = $this->templatesDir . "homepage.latte";
 }
 /**
  * @return ITemplate
  */
 public function createTemplate()
 {
     $template = parent::createTemplate();
     /** @noinspection PhpUndefinedMethodInspection */
     $template->setTranslator($this->translator);
     return $template;
 }
Exemplo n.º 13
0
 protected function createTemplate($class = NULL)
 {
     if (!is_null($this->templateFactory)) {
         return $this->templateFactory->createTemplate($this->getPresenter());
     }
     return parent::createTemplate($class);
 }
Exemplo n.º 14
0
 function __construct($templateFile = NULL, IFilterFactory $filterFactory, Trejjam\Utils\Helpers\IBaseList $list = NULL)
 {
     parent::__construct();
     $this->setTemplate($templateFile);
     $this->filterFactory = $filterFactory;
     $this->list = $list;
 }
Exemplo n.º 15
0
 /**
  * Constructor
  *
  * @param \Nette\Http\Request     $request      HTTP request
  * @param \Nette\Http\Session     $session      Session
  * @param \Nette\Caching\IStorage $cacheStorage Cache storage
  */
 public function __construct(Http\Request $request, Http\Session $session, \Nette\Caching\IStorage $cacheStorage)
 {
     parent::__construct();
     $this->httpRequest = $request;
     $this->session = $session;
     $this->cacheStorage = $cacheStorage;
 }
Exemplo n.º 16
0
 /**
  * @param string $class
  * @return \Nette\Templating\FileTemplate
  * @internal
  */
 public function createTemplate($class = NULL)
 {
     $template = parent::createTemplate($class);
     $template->setFile(__DIR__ . '/DateRangePicker.latte');
     //$template->registerHelper('translate', callback($this->getTranslator(), 'translate'));
     return $template;
 }
Exemplo n.º 17
0
 public function attached($presenter)
 {
     parent::attached($presenter);
     $this->wdata = $this->WDataModel->get($this->presenter->getParameter('destination'));
     $this->template->village = $this->village = $this->villageService->getVillage($this->presenter->getParameter('id'));
     $this->units = $this->unitService->getUnits($this->village);
     $this->template->units = $this->units;
     $this->template->names = $this->unitService->getNames();
     $unitData = [];
     switch ($this->village->getOwner()->tribe) {
         case App\FrontModule\Model\User\UserService::TRIBE_ROMANS:
             foreach (App\GameModule\Model\Units\UnitService::ROMANS as $unit) {
                 $unitData[] = $this->unitFactory->getUnit($unit);
             }
             break;
         case App\FrontModule\Model\User\UserService::TRIBE_TEUTONS:
             foreach (App\GameModule\Model\Units\UnitService::TEUTONS as $unit) {
                 $unitData[] = $this->unitFactory->getUnit($unit);
             }
             break;
         case App\FrontModule\Model\User\UserService::TRIBE_GAULS:
             foreach (App\GameModule\Model\Units\UnitService::GAULS as $unit) {
                 $unitData[] = $this->unitFactory->getUnit($unit);
             }
             break;
     }
     $this->template->unitData = $unitData;
     $this->template->setFile(__DIR__ . '/SendUnitsControl.latte');
 }
Exemplo n.º 18
0
 public function __construct(IContainer $parent = NULL, $name = NULL)
 {
     parent::__construct($parent, $name);
     $this->templatesDir = __DIR__ . "/templates/";
     $this->templateMain = $this->templatesDir . "default.latte";
     $this->templateForm = $this->templatesDir . "defaultForm.latte";
 }
Exemplo n.º 19
0
 protected function createTemplate($class = NULL)
 {
     $template = parent::createTemplate($class);
     $texy = new \Texy();
     $texy->encoding = 'utf-8';
     $texy->setOutputMode(\Texy::HTML5);
     // config as in \TexyConfigurator::safeMode($texy);
     $safeTags = array('a' => array('href', 'title'), 'acronym' => array('title'), 'b' => array(), 'br' => array(), 'cite' => array(), 'code' => array(), 'em' => array(), 'i' => array(), 'strong' => array(), 'sub' => array(), 'sup' => array(), 'q' => array(), 'small' => array());
     $texy->allowedClasses = \Texy::NONE;
     // no class or ID are allowed
     $texy->allowedStyles = \Texy::NONE;
     // style modifiers are disabled
     $texy->allowedTags = $safeTags;
     // only some "safe" HTML tags and attributes are allowed
     $texy->urlSchemeFilters[\Texy::FILTER_ANCHOR] = '#https?:|ftp:|mailto:#A';
     $texy->urlSchemeFilters[\Texy::FILTER_IMAGE] = '#https?:#A';
     $texy->allowed['image'] = FALSE;
     // disable images
     $texy->allowed['link/definition'] = FALSE;
     // disable [ref]: URL  reference definitions
     $texy->allowed['html/comment'] = FALSE;
     // disable HTML comments
     # zakázaní nadpisů
     $texy->allowed['heading/surrounded'] = FALSE;
     $texy->allowed['heading/underlined'] = FALSE;
     # zalamování textu v odstavcích po enteru
     # false => nebude spojovat řádky, vloží místo enteru <br>
     # true => řádky po jednom enteru spojí
     $texy->mergeLines = false;
     $texy->linkModule->forceNoFollow = TRUE;
     // force rel="nofollow"
     $template->registerHelper('texy', callback($texy, 'process'));
     return $template;
 }
Exemplo n.º 20
0
 protected function createTemplate($class = NULL)
 {
     $template = parent::createTemplate($class);
     $translator = $this->getPresenter()->getService('translator');
     $template->setTranslator($translator);
     return $template;
 }
Exemplo n.º 21
0
 public function __construct(User $user, ItemCardService $ics, $item_no)
 {
     parent::__construct();
     $this->user = $user;
     $this->ics = $ics;
     $this->item_no = $item_no;
 }
Exemplo n.º 22
0
 public function __construct(UserFacade $userFacade, MailSender $mailSender, RoleFacade $roleFacade)
 {
     parent::__construct();
     $this->userFacade = $userFacade;
     $this->mailSender = $mailSender;
     $this->roleFacade = $roleFacade;
 }
Exemplo n.º 23
0
 public function __construct(Nette\Database\Connection $database, UserManager $userManager, FormRenderer $render)
 {
     parent::__construct();
     $this->database = $database;
     $this->userManager = $userManager;
     $this->renderer = $render;
 }
Exemplo n.º 24
0
 public function __construct($formObject, $formModels)
 {
     $this->formObject = $formObject;
     $this->formModels = $formModels;
     $this->formFields = array();
     parent::__construct(NULL, NULL);
 }
Exemplo n.º 25
0
 /**
  * @param Nette\ComponentModel\Container $obj
  */
 protected function attached($obj)
 {
     parent::attached($obj);
     if ($obj instanceof Nette\Application\IPresenter) {
         $this->client->getConsumer()->setCallbackUrl(new Http\UrlScript($this->link('//response!')));
     }
 }
Exemplo n.º 26
0
 /**
  * @param \Nette\ComponentModel\Container $obj
  */
 protected function attached($obj)
 {
     parent::attached($obj);
     if ($obj instanceof Nette\Application\IPresenter) {
         $this->currentUrl = new UrlScript($this->link('//response!'));
     }
 }
Exemplo n.º 27
0
 protected function createTemplate($class = NULL)
 {
     $servise = $this;
     $template = parent::createTemplate($class);
     $template->addFilter('obr_v_txt', function ($text) use($servise) {
         $rozloz = explode("#", $text);
         $serv = $servise->presenter;
         $vysledok = '';
         $cesta = 'http://' . $serv->nazov_stranky . "/";
         foreach ($rozloz as $k => $cast) {
             if (substr($cast, 0, 2) == "I-") {
                 $obr = $serv->dokumenty->find((int) substr($cast, 2));
                 if ($obr !== FALSE) {
                     $cast = \Nette\Utils\Html::el('a class="fotky" rel="fotky"')->href($cesta . $obr->subor)->title($obr->nazov)->setHtml(\Nette\Utils\Html::el('img')->src($cesta . $obr->thumb)->alt($obr->nazov));
                 }
             }
             $vysledok .= $cast;
         }
         return $vysledok;
     });
     $template->addFilter('koncova_znacka', function ($text) use($servise) {
         $rozloz = explode("{end}", $text);
         $vysledok = $text;
         if (count($rozloz) > 1) {
             //Ak som nasiel znacku
             $vysledok = $rozloz[0] . \Nette\Utils\Html::el('a class="cely_clanok"')->href($servise->link("this"))->title($servise->texty["title"])->setHtml('&gt;&gt;&gt; ' . $servise->texty["viac"]) . '<div class="ostatok">' . $rozloz[1] . '</div>';
         }
         return $vysledok;
     });
     return $template;
 }
Exemplo n.º 28
0
 public function __construct(StatisticFacade $statisticFacade, SystemSettingsFacade $systemSettingsFacade, MailSender $mailSender)
 {
     parent::__construct();
     $this->statisticFacade = $statisticFacade;
     $this->mailSender = $mailSender;
     $this->setEmailOwner($systemSettingsFacade);
 }
Exemplo n.º 29
0
 /**
  * Class constructor
  * @param IContainer $parent
  * @param string $name
  */
 public function __construct(IContainer $parent, $name)
 {
     parent::__construct($parent, $name);
     $this->templatesDir = __DIR__ . "/templates/";
     $this->templateFile = $this->templatesDir . "default.latte";
     $this->data = [];
 }
Exemplo n.º 30
0
 public function __construct(Games $games, ImageManager $imageManager)
 {
     parent::__construct();
     $this->file_limit = 2;
     $this->games = $games;
     $this->imageManager = $imageManager;
 }