• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP UI\Presenter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Nette\Application\UI\Presenter的典型用法代码示例。如果您正苦于以下问题:PHP Presenter类的具体用法?PHP Presenter怎么用?PHP Presenter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Presenter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: create

 /**
  * @param string $name
  * @param Selection $selection
  * @return Grid
  * @throws GridNotExistsException
  */
 public function create($name, Selection $selection)
 {
     $className = '\\App\\AdminModule\\Grid\\' . $name;
     if (!class_exists($className)) {
         throw new GridNotExistsException("Grid class {$className} does not exist!");
     }
     if ($this->presenter === NULL) {
         throw new InvalidArgumentException('Presenter must be set!');
     }
     /** @var Grid $grid */
     $grid = new $className($this->db, $selection);
     $grid->setDefaultPerPage(100);
     $grid->setModel($selection)->setTranslator(new FileTranslator('cs'));
     $grid->addActionHref('edit', '')->setIcon('pencil');
     $grid->addActionHref('hide', 'Skrýt')->setCustomRender(function ($row) {
         $icon = Html::el('i');
         $button = Html::el('a')->href($this->presenter->link('hide!', $row->id))->title('Skrýt');
         if (isset($row->visible)) {
             $icon->class('fa fa-eye');
             if ($row->visible) {
                 $button->class('btn btn-default btn-xs btn-mini');
             } else {
                 $button->class('btn btn-danger btn-xs btn-mini');
             }
             $button->setHtml($icon);
         } else {
             $button->style('display: none');
         }
         return $button;
     });
     $grid->addActionHref('delete', '', 'delete!')->setIcon('times')->setConfirm('Opravdu smazat?');
     return $grid;
 }
开发者ID:ondrs,项目名称:nette-bootstrap,代码行数:39,代码来源:GridFactory.php


示例2: registerComponents

 public function registerComponents(Nette\Application\UI\Presenter $presenter)
 {
     if (!$this->getConfigurations()['labels']['enable']) {
         return;
     }
     $presenter->addComponent($this->labels->create(), $this->getConfigurations()['labels']['componentName']);
 }
开发者ID:trejjam,项目名称:utils,代码行数:7,代码来源:BaseLayout.php


示例3: formatTemplateFiles

 public function formatTemplateFiles(Presenter $presenter)
 {
     $name = $presenter->getName();
     $view = $presenter->view;
     $_presenter = substr($name, strrpos(':' . $name, ':'));
     $dir = dirname($presenter->getReflection()->getFileName());
     $dir = is_dir("{$dir}/templates") ? $dir : dirname($dir);
     return array("{$dir}/templates/{$_presenter}/{$view}.latte", "{$dir}/templates/{$_presenter}.{$view}.latte", "{$dir}/templates/{$_presenter}/{$view}.phtml", "{$dir}/templates/{$_presenter}.{$view}.phtml");
 }
开发者ID:rixxi,项目名称:template-locator,代码行数:9,代码来源:ConventionalTemplateLocator.php


示例4: runPresenterAction

 /**
  * @param $action
  * @param string $method
  * @param array $params
  * @param array $post
  * @return Nette\Application\IResponse
  */
 protected function runPresenterAction($action, $method = 'GET', $params = [], $post = [])
 {
     /** @var IntegrationTestCase|PresenterRunner $this */
     if (!$this->presenter) {
         throw new \LogicException("You have to open the presenter using \$this->openPresenter(\$name); before calling actions");
     }
     $request = new Nette\Application\Request($this->presenter->getName(), $method, ['action' => $action] + $params, $post);
     return $this->presenter->run($request);
 }
开发者ID:kdyby,项目名称:tester-extras,代码行数:16,代码来源:PresenterRunner.php


示例5: updateModal

 /**
  * @param Presenter $presenter
  */
 public function updateModal(Presenter $presenter)
 {
     $presenter->getTemplate()->modal = $activeModal = Modal::getActiveModal();
     if ($presenter->isAjax()) {
         // close the previous modal
         if (Modal::isCloseRequired()) {
             $presenter->getPayload()->closeModal = TRUE;
         }
         $redrawModal = $activeModal && $activeModal->isOpenRequired() || Modal::isCloseRequired();
         $presenter->redrawControl('modal', $redrawModal);
     }
 }
开发者ID:brosland,项目名称:modals,代码行数:15,代码来源:ModalTrait.php


示例6: tryJsonResponse

 public static function tryJsonResponse(Presenter $presenter)
 {
     if (empty(self::$jsonResoponseItems)) {
         return;
     }
     $payload = array("type" => "JsonDependentSelectBoxResponse", "items" => array());
     foreach (self::$jsonResoponseItems as $item) {
         $payload["items"][$item->getHtmlId()] = array("selected" => $item->getValue(), "items" => $item->getItems());
     }
     $response = new JsonResponse($payload);
     $presenter->sendResponse($response);
 }
开发者ID:foowie,项目名称:dependentselectbox,代码行数:12,代码来源:JsonDependentSelectBox.php


示例7: formatTemplateFiles

 public function formatTemplateFiles(Presenter $presenter)
 {
     $name = $presenter->getName();
     $view = $presenter->view;
     $_presenter = substr($name, strrpos(':' . $name, ':'));
     $directories = $this->getAdjustedDirectories($presenter);
     $list = array();
     foreach ($directories as $dir) {
         $list[] = $this->getTemplateFiles("{$dir}/presenters", $_presenter, $view);
         $list[] = $this->getTemplateFiles($dir, $_presenter, $view);
     }
     return Arrays::flatten($list);
 }
开发者ID:rixxi,项目名称:template-locator,代码行数:13,代码来源:PriorityTemplateLocator.php


示例8: handleSave

 public function handleSave()
 {
     $this->presenter = $this->getPresenter();
     if ($this->presenter->isAjax()) {
         $request = $this->presenter->getRequest();
         $result = $request->getPost();
         foreach ($this->onSave as $call) {
             $call($result);
         }
         $this->presenter->payload->neco = $result;
         $this->presenter->sendPayload();
     }
 }
开发者ID:DIPcms,项目名称:AceEditor,代码行数:13,代码来源:Editor.php


示例9: formatTemplateFiles

 public function formatTemplateFiles(Presenter $presenter)
 {
     if (NULL === $this->filesCache[$name = $presenter->getName()]) {
         $templateLocator = $this->templateLocator;
         $onlyExistingFiles = $this->onlyExistingFiles;
         return $this->filesCache->save($name, function () use($presenter, $templateLocator, $onlyExistingFiles) {
             $list = $templateLocator->formatTemplateFiles($presenter);
             if ($onlyExistingFiles) {
                 $list = array_filter($list, 'is_file');
             }
             return $list;
         });
     }
     return $this->filesCache[$name];
 }
开发者ID:rixxi,项目名称:template-locator,代码行数:15,代码来源:CachedTemplateLocator.php


示例10: isAllowed

 /**
  * {@inheritdoc}
  */
 public function isAllowed($role, $resource, $privilege)
 {
     if ($role instanceof IRole) {
         $role = $role->getRoleId();
     }
     if (!$resource instanceof PresenterResource) {
         throw new \Ark8\Security\Exceptions\SkipException(sprintf('Resource must be instance of %s, %s given.', PresenterResource::class, gettype($resource)));
     }
     $request = $resource->getRequest();
     $presenterName = $request->getPresenterName();
     list($signal, $signalReceiver) = $this->getSignal($request);
     if (!$signal) {
         throw new \Ark8\Security\Exceptions\SkipException(sprintf('No signal sent.'));
     }
     $refClass = new PresenterComponentReflection($class = $this->presenterFactory->getPresenterClass($presenterName));
     while ($name = array_shift($signalReceiver)) {
         $name = 'createComponent' . ucfirst($name);
         if (!$refClass->hasMethod($name)) {
             throw new \Nette\InvalidStateException(sprintf('Method %s::%s is not implemented.', $refClass->getName(), $name));
         }
         $refMethod = $refClass->getMethod($name);
         if (!$refMethod->hasAnnotation('return')) {
             throw new \Nette\InvalidStateException(sprintf('Method %s::%s must have fully qualified return annotation.', $refClass->getName(), $name));
         }
         $refClass = new ClassType($refMethod->getAnnotation('return'));
     }
     if (!$refClass->hasMethod($name = Presenter::formatSignalMethod($signal))) {
         throw new \Ark8\Security\Exceptions\SkipException(sprintf('Method %s::%s is not implemented.', $refClass->getName(), $name));
     }
     $refMethod = $refClass->getMethod($name);
     if (!$refMethod->hasAnnotation($privilege)) {
         throw new \Ark8\Security\Exceptions\SkipException(sprintf('Method %s::%s does not have annotation %s.', $refClass->getName(), $name, $privilege));
     }
     return in_array($role, preg_split('#\\s+#', trim((string) $refMethod->getAnnotation($privilege))));
 }
开发者ID:ark8,项目名称:security,代码行数:38,代码来源:SignalAuthorizator.php


示例11: link

 /**
  * Generates URL to presenter.
  * @param  string   destination in format "[[[module:]presenter:]action] [#fragment]"
  * @return string
  * @throws UI\InvalidLinkException
  */
 public function link($dest, array $params = array())
 {
     if (!preg_match('~^([\\w:]+):(\\w*+)(#.*)?()\\z~', $dest, $m)) {
         throw new UI\InvalidLinkException("Invalid link destination '{$dest}'.");
     }
     list(, $presenter, $action, $frag) = $m;
     try {
         $class = $this->presenterFactory ? $this->presenterFactory->getPresenterClass($presenter) : NULL;
     } catch (InvalidPresenterException $e) {
         throw new UI\InvalidLinkException($e->getMessage(), NULL, $e);
     }
     if (is_subclass_of($class, 'Nette\\Application\\UI\\Presenter')) {
         if ($action === '') {
             $action = UI\Presenter::DEFAULT_ACTION;
         }
         if (method_exists($class, $method = $class::formatActionMethod($action)) || method_exists($class, $method = $class::formatRenderMethod($action))) {
             UI\Presenter::argsToParams($class, $method, $params);
         }
     }
     if ($action !== '') {
         $params[UI\Presenter::ACTION_KEY] = $action;
     }
     $url = $this->router->constructUrl(new Request($presenter, NULL, $params), $this->refUrl);
     if ($url === NULL) {
         unset($params[UI\Presenter::ACTION_KEY]);
         $params = urldecode(http_build_query($params, NULL, ', '));
         throw new UI\InvalidLinkException("No route for {$dest}({$params})");
     }
     return $url . $frag;
 }
开发者ID:knedle,项目名称:twitter-nette-skeleton,代码行数:36,代码来源:LinkGenerator.php


示例12: getText

 public function getText($params, \Nette\Application\UI\Presenter $presenter, $default_text = null)
 {
     if (!isset($params[0])) {
         throw new \Exception("gettext macro must define 1 parameter {getText 'textName'}");
     }
     $name = $params[0];
     $default_text = htmlspecialchars_decode($default_text);
     $text = $this->textManager->getText($name);
     $texy = new \Texy\Texy();
     if (!$text) {
         $this->textManager->addText($name, $presenter->name . ':' . $presenter->getAction(), $default_text);
         return $texy->process($default_text);
     } else {
         return $texy->process($text->text);
     }
 }
开发者ID:chomenko,项目名称:cemvin,代码行数:16,代码来源:Macros.php


示例13: startup

 public function startup()
 {
     parent::startup();
     if (!$this->user->isLoggedIn() && !$this->presenter instanceof SignPresenter) {
         $this->redirect('Sign:in');
     }
 }
开发者ID:ParalelniPolis,项目名称:bitcoinJukebox,代码行数:7,代码来源:BasePresenter.php


示例14: startup

 public function startup()
 {
     parent::startup();
     $this->template->max_rating = $this->global_settings->getMaxRating();
     $this->template->image_dir = __DIR__ . '/../../www/images/games/';
     $this->template->title = '';
 }
开发者ID:Thoronir42,项目名称:G-archive,代码行数:7,代码来源:BasePresenter.php


示例15: addLinkAttr

 public function addLinkAttr(&$button, $attr_name, Link $link)
 {
     $href = $link->create($this->data);
     if (!$link->hasUseNetteLink()) {
         $button->addAttributes(array($attr_name => reset($href)));
     } else {
         if ($href === FALSE) {
             return FALSE;
         }
         list($to_href, $params) = $href;
         $used_component = $link->getUsedComponent();
         if (!is_null($used_component)) {
             if (is_string($used_component)) {
                 $href_attribute = $this->presenter[$used_component]->link($to_href, $params);
             } elseif (is_array($used_component)) {
                 $component = $this->presenter;
                 foreach ($used_component as $component_name) {
                     $component = $component[$component_name];
                 }
                 $href_attribute = $component->link($to_href, $params);
             } else {
                 throw new Grid_Exception('Link::COMPONENT must be string or array, ' . gettype($used_component) . ' given.');
             }
             $button->addAttributes(array($attr_name => $href_attribute));
         } else {
             $button->addAttributes(array($attr_name => $this->presenter->link($to_href, $params)));
         }
     }
     return TRUE;
 }
开发者ID:Aearsis,项目名称:DataGrid,代码行数:30,代码来源:Button.php


示例16: startup

 public function startup()
 {
     parent::startup();
     if (!$this->getRequest()->isMethod(Nette\Application\Request::FORWARD)) {
         $this->error();
     }
 }
开发者ID:fuchcz,项目名称:generator-myproject,代码行数:7,代码来源:Error4xxPresenter.php


示例17: beforeRender

 protected function beforeRender()
 {
     parent::beforeRender();
     if ($this->isAjax() && $this->hasFlashSession()) {
         $this->redrawControl('flash');
     }
 }
开发者ID:jedenweb,项目名称:framework,代码行数:7,代码来源:Presenter.php


示例18: createTemplate

 /**
  * @return \Nette\Bridges\ApplicationLatte\Template
  */
 protected function createTemplate()
 {
     /** @var \Nette\Bridges\ApplicationLatte\Template $template */
     $template = parent::createTemplate();
     $this->latteFilters->install($template->getLatte());
     return $template;
 }
开发者ID:milo,项目名称:web-project,代码行数:10,代码来源:BasePresenter.php


示例19: beforeRender

 /**
  * Common template method
  */
 protected function beforeRender()
 {
     parent::beforeRender();
     $this->template->portal = $this->portal;
     $this->template->rev = $this->portal->expand('build.rev');
     $this->template->debug = $this->portal->isDebug();
 }
开发者ID:milo,项目名称:componette.com,代码行数:10,代码来源:BasePresenter.php


示例20: startup

 protected function startup()
 {
     parent::startup();
     if (!$this->user->isLoggedIn() && $this->name != "Sign") {
         $this->redirect("Sign:in");
     }
 }
开发者ID:batko,项目名称:batkovi.com,代码行数:7,代码来源:BasePresenter.php



注:本文中的Nette\Application\UI\Presenter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP UI\PresenterComponentReflection类代码示例发布时间:2022-05-23
下一篇:
PHP UI\Form类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap