作者:hrac
项目:nette-applicatio
/**
* @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;
}
作者:TomasVotrub
项目:SmfMen
/**
* 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;
}
作者:nakouka
项目:fakturac
/**
* @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;
}
作者:Spamer
项目:Travian
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');
}
作者:hrac
项目:nette-applicatio
public function addSnippet($name, $content)
{
if ($this->payload === NULL) {
$this->payload = $this->control->getPresenter()->getPayload();
}
$this->payload->snippets[$this->control->getSnippetId($name)] = $content;
}
作者:bagr00
项目:NAV_Sho
public function __construct(User $user, CustomerService $cus, CountriesService $cs)
{
parent::__construct();
$this->user = $user;
$this->cus = $cus;
$this->cs = $cs;
}
作者:Hajnee
项目:PayPalExpres
/**
* @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!'));
}
}
作者:JanTvrdi
项目:NetteExtra
/**
* 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;
}
作者:FreezyBe
项目:Editroubl
/**
* 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;
}
作者:Thoronir4
项目:G-archiv
public function __construct(States $states, Colors $colors)
{
parent::__construct();
$this->states = $states;
$this->ordered = $this->states->findBy([], ['sequence' => 'ASC']);
$this->colors = $colors;
}
作者:Thoronir4
项目:G-archiv
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;
}
作者:fuc
项目:sportsclu
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";
}
作者:kiz
项目:easyminer-easyminercente
/**
* @return ITemplate
*/
public function createTemplate()
{
$template = parent::createTemplate();
/** @noinspection PhpUndefinedMethodInspection */
$template->setTranslator($this->translator);
return $template;
}
作者:RiKa
项目:ErrorMonitorin
protected function createTemplate($class = NULL)
{
if (!is_null($this->templateFactory)) {
return $this->templateFactory->createTemplate($this->getPresenter());
}
return parent::createTemplate($class);
}
作者:trejja
项目:util
function __construct($templateFile = NULL, IFilterFactory $filterFactory, Trejjam\Utils\Helpers\IBaseList $list = NULL)
{
parent::__construct();
$this->setTemplate($templateFile);
$this->filterFactory = $filterFactory;
$this->list = $list;
}
作者:ixtru
项目:file-manage
/**
* 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;
}
作者:mepate
项目:daterangepicke
/**
* @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;
}
作者:fuc
项目:secondHan
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";
}
作者:BroukPytli
项目:agilit
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;
}
作者:baz
项目:Tatam
protected function createTemplate($class = NULL)
{
$template = parent::createTemplate($class);
$translator = $this->getPresenter()->getService('translator');
$template->setTranslator($translator);
return $template;
}