getPresenter() публичный Метод

Returns current presenter.
public getPresenter ( ) : Nette\Application\IPresenter
Результат Nette\Application\IPresenter
Пример #1
0
 /**
  * @return \Nette\Application\IPresenter|\Nette\Application\UI\Presenter
  * @throws \Kdyby\Console\InvalidStateException
  */
 public function getPresenter()
 {
     if (!($presenter = $this->app->getPresenter())) {
         throw new Kdyby\Console\InvalidStateException("There is currently no presenter");
     }
     return $presenter;
 }
Пример #2
0
 /**
  * @param IRedirect $event
  */
 public function handle(IEvent $event)
 {
     Helper::assertRedirectInterface($event);
     if ($event->hasRedirect()) {
         $event->performRedirect($this->application->getPresenter());
     }
 }
Пример #3
0
 /**
  * Format link to format array('module:submodule:presenter', 'action')
  *
  * @param string $destination
  *
  * @return array(presenter, action)
  */
 public function formatLink($destination)
 {
     if ($destination == 'this') {
         return array($this->application->getPresenter()->getName(), $this->application->getPresenter()->getAction());
     }
     $parts = explode(':', $destination);
     if ($destination[0] != ':') {
         $current = explode(':', $this->application->getPresenter()->getName());
         if (strpos($destination, ':') !== FALSE) {
             // Remove presenter
             array_pop($current);
         }
         $parts = array_merge($current, $parts);
     } else {
         // Remove empty
         array_shift($parts);
     }
     if ($destination[strlen($destination) - 1] == ':') {
         // Remove empty
         array_pop($parts);
         $action = UI\Presenter::DEFAULT_ACTION;
     } else {
         $action = array_pop($parts);
     }
     return array(implode(':', $parts), $action);
 }
Пример #4
0
    /**
     * Whole panel after hover or click on tab
     * @return string
     */
    public function getPanel()
    {
        $presenter = $this->app->getPresenter();
        $linkRun = !$presenter ? "" : $presenter->link("Yadup:Update:Run");
        $linkCreate = !$presenter ? "" : $presenter->link("Yadup:Update:Create");
        $linkShowSettings = !$presenter ? "" : $presenter->link("Yadup:Update:ShowSettings");
        return $this->renderStyles() . $this->renderJavascript() . '
			<div class="js-yadupPanel">
				<div class="yadup-heading">
					<h1>DB updates</h1> 
					<input name="show_all" type="checkbox" title="Show all updates / Only from last full" data-link="' . $linkShowSettings . '" />
				</div>
				<div class="yadup-controls">
					<div class="yadup-controls-header">
						<table>
							<thead>
								<tr>
									<th>timestamp</th>
									<th>in DB</th>
									<th>on disk</th>
									<th>is full</th>
									<th title="Toggle selected">run</th>
								</tr>
							</thead>
						</table>
					</div>
					<div class="yadup-controls-inner">' . $this->updatorRenderService->renderTable() . '
					</div>
					<div class="yadup-controls-buttons">
						<input type="button" name="createUpdate" value="Create new" />
						<input type="button" name="runUpdates" value="Run selected" data-link="' . $linkRun . '" />
						<input type="button" name="cancel" value="Cancel" />
						<input type="button" name="saveFile" value="Save file" data-link="' . $linkCreate . '" />
					</div>
				</div>
				<div class="yadup-sqlPanel">
					<div class="yadup-sqlPanel-heading">
						<p class="yadup-sqlPanel-heading-run">
							<span></span>
							<span title="in DB"></span>
							<span title="on disk"></span>
							<span title="is full"></span>
						</p>
						<p class="yadup-sqlPanel-heading-create">
							<span title="If SQL is full database dump">
								<input id="yadup-sqlPanel-heading-create_is-full" name="is_full" type="checkbox" value="" />
								<label for="yadup-sqlPanel-heading-create_is-full">is full</label>
							</span>
						</p>
					</div>
					<div class="yadup-sqlPanel-query">
						<div class="yadup-sqlPanel-query-inner">
							<code class="jush-sql"></code>
							<textarea class="jush-sql" name="newSql" placeholder="Paste here your query"></textarea>
						</div>
					</div>
				</div>
			</div>';
    }
Пример #5
0
 public function signIn(IUser $user)
 {
     $this->onSignIn($user);
     if ($this->expiration !== NULL) {
         $this->security->setExpiration($this->expiration);
     }
     if ($this->backlink !== NULL) {
         $presenter = $this->application->getPresenter();
         if (isset($presenter->{$this->backlink})) {
             $presenter->restoreRequest($presenter->{$this->backlink});
         }
     }
 }
Пример #6
0
 public function onResponse(NA\Application $application, NA\IResponse $response)
 {
     if ($this->config["panel"]["ajax"] && $application->getPresenter() instanceof \Nette\Application\UI\Presenter && $application->getPresenter()->isAjax()) {
         $debug = ["count" => count($this->_getElapsed())];
         if ($debug["count"]) {
             ob_start();
             include __DIR__ . "/panel/templates/results.phtml";
             $debug["template"] = ob_get_clean();
         }
         $data = base64_encode(json_encode($debug));
         // Workaround for Chrome header limit as https://github.com/Seldaek/monolog/issues/172
         if (strlen($data) > 240 * 1024) {
             $debug["template"] = "Incomplete logs, chrome header size limit reached!";
             $data = base64_encode(json_encode($debug));
         }
         $this->response->setHeader(self::HEADER_PREFIX, $data);
     }
 }
Пример #7
0
 public static function initialize(Nette\Application\Application $application, Nette\Http\IRequest $httpRequest)
 {
     Debugger::$bar->addPanel(new self($application->getRouter(), $httpRequest));
     Debugger::$blueScreen->addPanel(function ($e) use($application) {
         if ($e === NULL) {
             return array('tab' => 'Nette Application', 'panel' => '<h3>Requests</h3>' . Nette\Diagnostics\Helpers::clickableDump($application->getRequests()) . '<h3>Presenter</h3>' . Nette\Diagnostics\Helpers::clickableDump($application->getPresenter()));
         }
     });
 }
Пример #8
0
 /**
  * @param Application $sender
  * @param \Exception  $e
  */
 public static function sendExceptionLogFile(Nette\Application\Application $sender, \Exception $e)
 {
     /** @var $presenter Presenter */
     if (Debugger::isEnabled() && Debugger::getBar() && ($presenter = $sender->getPresenter()) && preg_match('/exceptionLogFile/', $e->getMessage())) {
         echo file_exists($filename = $presenter->getParameter('file')) ? $presenter->payload->dibiPanel = file_get_contents($filename) : '"' . $presenter->getParameter('file') . '" not found.';
         //Debugger::$bar = false;
         die;
     }
 }
Пример #9
0
	public static function initializePanel(Nette\Application\Application $application)
	{
		Tracy\Debugger::getBlueScreen()->addPanel(function ($e) use ($application) {
			return $e ? NULL : array(
				'tab' => 'Nette Application',
				'panel' => '<h3>Requests</h3>' . Tracy\Dumper::toHtml($application->getRequests())
					. '<h3>Presenter</h3>' . Tracy\Dumper::toHtml($application->getPresenter()),
			);
		});
	}
Пример #10
0
 /**
  * @param \Nette\Application\Application $application
  * @return \DK\Menu\Menu
  */
 public function init(Application $application)
 {
     if (($presenter = $application->getPresenter()) !== null) {
         /** @var $presenter \Nette\Application\UI\Presenter */
         $this->setPresenter($presenter);
     } else {
         $_this = $this;
         $application->onPresenter[] = function (Application $application, Presenter $presenter) use($_this) {
             $_this->setPresenter($presenter);
         };
     }
     return $this;
 }
Пример #11
0
 /**
  * @return string
  */
 public function getPanel()
 {
     $groups = array();
     $empty = true;
     $translated = $this->translator->getTranslated();
     foreach ($this->groups as $name => $pattern) {
         $group = array();
         $translated = array_filter($translated, function ($translation) use(&$group, $pattern) {
             if (preg_match('/' . $pattern . '/', $translation)) {
                 $group[] = $translation;
                 return false;
             } else {
                 return true;
             }
         });
         if ($empty && !empty($group)) {
             $empty = false;
         }
         $groups[$name] = array('collapsed' => true, 'data' => $group);
     }
     $groups['Untranslated'] = array('collapsed' => false, 'data' => $this->translator->getUntranslated());
     $groups['Translated'] = array('collapsed' => false, 'data' => $translated);
     if (count($groups['Untranslated']['data']) === 0 && count($groups['Translated']['data']) === 0 && $empty) {
         return null;
     }
     $translator = $this->translator;
     $link = $this->application->getPresenter()->link('this');
     $xhrHeader = self::XHR_HEADER;
     $ajaxActionKey = self::AJAX_ACTION_KEY;
     $ajaxMessageKey = self::AJAX_MESSAGE_KEY;
     $ajaxTranslationKey = self::AJAX_TRANSLATION_KEY;
     $ajaxActionLoad = self::AJAX_ACTION_LOAD;
     $ajaxActionEdit = self::AJAX_ACTION_EDIT;
     $cookieDebugKey = self::COOKIE_DEBUG_KEY;
     $checkMessage = function ($message) {
         return preg_match('/^[a-zA-Z0-9._]+$/', $message) > 0;
     };
     ob_start();
     require __DIR__ . '/panel.phtml';
     return ob_get_clean();
 }
 /**
  * Nastaví URL na kterou bude uživatel z Facebook.com přesměrován
  * Přijímá nette zápis odkazů (např.: Homepage:default) nebo absolutní URL
  * @param string $redirectUri
  * @throws \Nette\InvalidArgumentException
  * @return void
  */
 public function setRedirectUri($redirectUri)
 {
     /* @var $currentPresenter \Nette\Application\UI\Presenter */
     $currentPresenter = $this->application->getPresenter();
     $netteAbsoluteLinkPrexix = "//";
     try {
         if (\Nette\Utils\Strings::startsWith($redirectUri, "//")) {
             $netteAbsoluteLinkPrexix = "";
         }
         $absoluteUri = $currentPresenter->link($netteAbsoluteLinkPrexix . $redirectUri);
         if (\Nette\Utils\Strings::startsWith($absoluteUri, "error:")) {
             throw new \Nette\Application\UI\InvalidLinkException();
         }
     } catch (\Nette\Application\UI\InvalidLinkException $exc) {
         if (Validators::isUrl($redirectUri) === TRUE) {
             $absoluteUri = $redirectUri;
         } else {
             throw new Exceptions\InvalidRedirectUriException("Given \"" . $redirectUri . "\" is not valid absolute URL or nette link.");
         }
     }
     $this->redirectUri = $absoluteUri;
 }
Пример #13
0
 /**
  * @param AbstractDialog $dialog
  * @return Application\UI\Link|UrlScript
  */
 public function getReturnLink(AbstractDialog $dialog = NULL)
 {
     $destination = $this->config->getReturnDestination();
     if ($destination[0] instanceof Url) {
         return $destination[0];
     }
     $reset = array();
     /** @var Application\UI\Presenter $presenter */
     $presenter = $this->app->getPresenter();
     /** @var PresenterComponent $parent */
     $parent = $dialog ? $dialog->getParent() : $presenter;
     do {
         $prefix = $parent instanceof Application\IPresenter ? '' : $parent->lookupPath('Nette\\Application\\IPresenter');
         foreach ($parent->getReflection()->getPersistentParams() as $name => $meta) {
             $reset[($prefix ? $prefix . IComponent::NAME_SEPARATOR : '') . $name] = array_key_exists('def', $meta) ? $meta['def'] : NULL;
         }
     } while ($parent = $parent->getParent());
     $args = is_array($destination[1]) ? $destination[1] : array_slice($destination, 1);
     if ($dialog !== NULL) {
         $args['do'] = $dialog->lookupPath('Nette\\Application\\IPresenter') . IComponent::NAME_SEPARATOR . 'response';
     }
     return $presenter->lazyLink('//' . ltrim($destination[0], '/'), $args + $reset);
 }
Пример #14
0
 public static function onError(Nette\Application\Application $application)
 {
     self::$lastPresenter = $application->getPresenter();
 }
Пример #15
0
 public static function initializePanel(Nette\Application\Application $application)
 {
     Debugger::$blueScreen->addPanel(function ($e) use($application) {
         return $e ? NULL : array('tab' => 'Nette Application', 'panel' => '<h3>Requests</h3>' . Nette\Diagnostics\Helpers::clickableDump($application->getRequests()) . '<h3>Presenter</h3>' . Nette\Diagnostics\Helpers::clickableDump($application->getPresenter()));
     });
 }
Пример #16
0
 /**
  * @return IPresenter|Presenter|null
  */
 protected function getPresenter()
 {
     if ($this->application) {
         return $this->application->getPresenter();
     }
 }
Пример #17
0
 /**
  * @param $text
  * @return string
  */
 public function run($text)
 {
     $template = $this->application->getPresenter()->createTemplate("\\Nette\\Templating\\Template");
     $template->setSource($text);
     return $template->__toString();
 }
Пример #18
0
 private function getPresenter()
 {
     return $this->application->getPresenter();
 }
 /**
  * @param Application $app
  * @param IResponse $response
  */
 public function onResponse(Application $app, IResponse $response)
 {
     $_ENV['APP_RESPONSE_TIME_FLOAT'] = microtime(TRUE);
     $this->client->customTimeMetric('Nette/ResponseTime', $_ENV['APP_RESPONSE_TIME_FLOAT'], $_ENV['APP_REQUEST_TIME_FLOAT']);
     if (($presenter = $app->getPresenter()) && $presenter instanceof Presenter) {
         $module = $this->getModule($presenter->getName());
         $this->client->customTimeMetric("Presenter/{$module}/Shutdown", $_ENV['APP_PRESENTER_LEAVE'], $_ENV['APP_PRESENTER_SEND_RESPONSE']);
         $this->client->customTimeMetric("Presenter/{$module}/InitGlobals", $_ENV['APP_PRESENTER_REQUIREMENTS_BEGIN'], $_ENV['APP_PRESENTER_BEFORE_INIT']);
         $this->client->customTimeMetric("Presenter/{$module}/Startup", $_ENV['APP_PRESENTER_STARTUP_END'], $_ENV['APP_PRESENTER_REQUIREMENTS_BEGIN']);
         $this->client->customTimeMetric("Presenter/{$module}/Action", $_ENV['APP_PRESENTER_ACTION_END'], $_ENV['APP_PRESENTER_ACTION_BEGIN']);
         $this->client->customTimeMetric("Presenter/{$module}/Render", $_ENV['APP_PRESENTER_RENDER_END'], $_ENV['APP_PRESENTER_RENDER_BEGIN']);
         $this->client->customTimeMetric("Presenter/{$module}/BeforeRender", $_ENV['APP_PRESENTER_RENDER_BEGIN'], $_ENV['APP_PRESENTER_ACTION_END']);
         $this->client->customTimeMetric("Presenter/{$module}/ProcessSignal", $_ENV['APP_PRESENTER_SIGNAL_END'], $_ENV['APP_PRESENTER_SIGNAL_BEGIN']);
         $this->client->customTimeMetric("Presenter/{$module}/AfterRender", $_ENV['APP_PRESENTER_AFTER_RENDER_END'], $_ENV['APP_PRESENTER_RENDER_END']);
         $this->client->customTimeMetric("Presenter/{$module}/SendTemplate", $_ENV['APP_PRESENTER_SEND_TEMPLATE_END'], $_ENV['APP_PRESENTER_SEND_TEMPLATE_BEGIN']);
     }
 }
 /**
  * Constructor
  * @author Pavel Železný <*****@*****.**>
  * @param \Nette\Application\Application $application
  * @param \Nette\Http\Session $session
  * @return void
  */
 public function __construct(\Nette\Application\Application $application, \Nette\Http\Session $session)
 {
     parent::__construct($application->getPresenter(), $this->getId());
     $this->session = $session;
 }
Пример #21
0
 /**
  * Constructor
  * @author Pavel Železný <*****@*****.**>
  * @param \Nette\Application\Application $application
  * @return void
  */
 public function __construct(\Nette\Application\Application $application)
 {
     parent::__construct($application->getPresenter(), $this->getId());
 }