本文整理汇总了PHP中Nette\Application\UI\Control类的典型用法代码示例。如果您正苦于以下问题:PHP Control类的具体用法?PHP Control怎么用?PHP Control使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Control类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: createTemplate
/**
* @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;
}
开发者ID:hrach,项目名称:nette-application,代码行数:63,代码来源:TemplateFactory.php
示例2: matchItem
/**
* 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;
}
开发者ID:TomasVotruba,项目名称:SmfMenu,代码行数:19,代码来源:PresenterVoter.php
示例3: createTemplate
/**
* @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;
}
开发者ID:nakoukal,项目名称:fakturace,代码行数:56,代码来源:TemplateFactory.php
示例4: attached
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');
}
开发者ID:Spameri,项目名称:TravianZ,代码行数:29,代码来源:SendUnitsControl.php
示例5: addSnippet
public function addSnippet($name, $content)
{
if ($this->payload === NULL) {
$this->payload = $this->control->getPresenter()->getPayload();
}
$this->payload->snippets[$this->control->getSnippetId($name)] = $content;
}
开发者ID:hrach,项目名称:nette-application,代码行数:7,代码来源:SnippetBridge.php
示例6: __construct
public function __construct(User $user, CustomerService $cus, CountriesService $cs)
{
parent::__construct();
$this->user = $user;
$this->cus = $cus;
$this->cs = $cs;
}
开发者ID:bagr001,项目名称:NAV_Shop,代码行数:7,代码来源:CustomerFormControl.php
示例7: attached
/**
* @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!'));
}
}
开发者ID:Hajneej,项目名称:PayPalExpress,代码行数:10,代码来源:PayControl.php
示例8: createTemplate
/**
* 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;
}
开发者ID:JanTvrdik,项目名称:NetteExtras,代码行数:14,代码来源:BaseControl.php
示例9: __construct
/**
* 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;
}
开发者ID:FreezyBee,项目名称:Editrouble,代码行数:13,代码来源:Editrouble.php
示例10: __construct
public function __construct(States $states, Colors $colors)
{
parent::__construct();
$this->states = $states;
$this->ordered = $this->states->findBy([], ['sequence' => 'ASC']);
$this->colors = $colors;
}
开发者ID:Thoronir42,项目名称:G-archive,代码行数:7,代码来源:StateView.php
示例11: __construct
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;
}
开发者ID:Thoronir42,项目名称:G-archive,代码行数:7,代码来源:GameView.php
示例12: __construct
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";
}
开发者ID:fuca,项目名称:sportsclub,代码行数:7,代码来源:ContactControl.php
示例13: createTemplate
/**
* @return ITemplate
*/
public function createTemplate()
{
$template = parent::createTemplate();
/** @noinspection PhpUndefinedMethodInspection */
$template->setTranslator($this->translator);
return $template;
}
开发者ID:kizi,项目名称:easyminer-easyminercenter,代码行数:10,代码来源:MailerControl.php
示例14: createTemplate
protected function createTemplate($class = NULL)
{
if (!is_null($this->templateFactory)) {
return $this->templateFactory->createTemplate($this->getPresenter());
}
return parent::createTemplate($class);
}
开发者ID:RiKap,项目名称:ErrorMonitoring,代码行数:7,代码来源:FactoryBaseControl.php
示例15:
function __construct($templateFile = NULL, IFilterFactory $filterFactory, Trejjam\Utils\Helpers\IBaseList $list = NULL)
{
parent::__construct();
$this->setTemplate($templateFile);
$this->filterFactory = $filterFactory;
$this->list = $list;
}
开发者ID:trejjam,项目名称:utils,代码行数:7,代码来源:ListingFactory.php
示例16: __construct
/**
* 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;
}
开发者ID:ixtrum,项目名称:file-manager,代码行数:14,代码来源:FileManager.php
示例17: createTemplate
/**
* @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;
}
开发者ID:mepatek,项目名称:daterangepicker,代码行数:12,代码来源:DateRangePicker.php
示例18: __construct
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";
}
开发者ID:fuca,项目名称:secondHand,代码行数:7,代码来源:LoginControl.php
示例19: createTemplate
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;
}
开发者ID:BroukPytlik,项目名称:agility,代码行数:34,代码来源:itemList.php
示例20: createTemplate
protected function createTemplate($class = NULL)
{
$template = parent::createTemplate($class);
$translator = $this->getPresenter()->getService('translator');
$template->setTranslator($translator);
return $template;
}
开发者ID:bazo,项目名称:Tatami,代码行数:7,代码来源:BaseControl.php
注:本文中的Nette\Application\UI\Control类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论