Inheritance: use trait Nette\SmartObject
Exemple #1
0
 /**
  * Sets debug mode.
  * @param boolean $debugMode
  */
 public function setDebugMode($debugMode)
 {
     $this->debugMode = $debugMode;
     if ($debugMode === true) {
         $this->sessionStorage = $this->session->getSection(Gettext::$namespace);
     }
 }
 /**
  * @return AjaxFileUploaderControl
  */
 public function invoke($basePath)
 {
     $control = new AjaxFileUploaderControl($this->ajaxDir, $basePath . $this->getRelativeAjaxPath(), $this->session->getSection('ajaxFileUploader'));
     $control->onFileUpload[] = $this->handleFileUpload;
     $control->onAfterFileUpload[] = $this->handleFileUploadUnlink;
     return $control;
 }
 protected function _before()
 {
     $this->session = new \Nette\Http\Session(new \Nette\Http\Request(new \Nette\Http\UrlScript()), new \Nette\Http\Response());
     $this->session = new \Kdyby\FakeSession\Session($this->session);
     $this->session->start();
     $this->wizard = new Wizard($this->session);
 }
Exemple #4
0
 public function actionImage()
 {
     if (substr($this->url, 0, 7) === self::DIRECTORY_CACHE . '/') {
         $this->cached = true;
         $this->url = substr($this->url, 7);
     }
     if (($entity = $this->fileRepository->findOneBy(array('path' => $this->url))) === null) {
         throw new \Nette\Application\BadRequestException(sprintf('File \'%s\' does not exist.', $this->url));
     }
     $image = Image::fromFile($entity->getFilePath());
     $this->session->close();
     // resize
     if ($this->size && $this->size !== 'default') {
         if (strpos($this->size, 'x') !== false) {
             $format = explode('x', $this->size);
             $width = $format[0] !== '?' ? $format[0] : null;
             $height = $format[1] !== '?' ? $format[1] : null;
             $image->resize($width, $height, $this->format !== 'default' ? $this->format : Image::FIT);
         }
     }
     if (!$this->type) {
         $this->type = substr($entity->getName(), strrpos($entity->getName(), '.'));
     }
     $type = $this->type === 'jpg' ? Image::JPEG : $this->type === 'gif' ? Image::GIF : Image::PNG;
     $file = sprintf('%s/%s/%s/%s/%s/%s', $this->cacheDir, self::DIRECTORY_CACHE, $this->size, $this->format, $this->type, $entity->getPath());
     $dir = dirname($file);
     umask(00);
     @mkdir($dir, 0777, true);
     $image->save($file, 90, $type);
     $image->send($type, 90);
 }
 /**
  * @param \Nette\ComponentModel\IContainer $ajaxDir
  * @param string $ajaxPath
  * @param \Nette\Http\Session $session
  */
 public function __construct($ajaxDir, $ajaxPath, Session $session)
 {
     parent::__construct();
     $this->ajaxDir = $ajaxDir;
     $this->ajaxPath = $ajaxPath;
     $this->sessionSection = $session->getSection('ajaxUploader-' . $this->getName());
 }
Exemple #6
0
 /**
  * @param PresenterFactory $presenterFactory
  * @param BaseRepository $roleRepository
  * @param Session $session
  */
 public function __construct(PresenterFactory $presenterFactory, BaseRepository $roleRepository, Session $session, Callback $checkConnection)
 {
     $this->presenterFactory = $presenterFactory;
     $this->roleRepository = $roleRepository;
     $this->session = $session->getSection(self::SESSION_SECTION);
     $this->checkConnection = $checkConnection;
 }
Exemple #7
0
 public function __construct(EntityManager $entityManager, Session $session, AdministrationManager $administrationManager)
 {
     $this->roleRepository = $entityManager->getRepository(Role::class);
     $this->permissionRepository = $entityManager->getRepository(Permission::class);
     $this->session = $session->getSection(self::SESSION_SECTION);
     $this->administrationManager = $administrationManager;
 }
Exemple #8
0
 public function __construct(Kdyby\Doctrine\EntityManager $em, Zax\Utils\AppDir $appDir, Nette\Http\Session $session)
 {
     $this->em = $em;
     $this->schemaTool = new Doctrine\ORM\Tools\SchemaTool($this->em);
     $cacheStorage = new Nette\Caching\Storages\FileStorage($appDir . '/modules/Install/components/Install/installSchema');
     $this->cache = new Nette\Caching\Cache($cacheStorage);
     $this->sessionSection = $session->getSection('ZaxCMS.DatabaseGenerator');
 }
Exemple #9
0
 public function __construct(\Nette\Http\Session $session, \Fabian\Linkedin\Configuration $config)
 {
     $this->session = $session->getSection('linkedin');
     if (isset($this->session->access_token)) {
         $this->accessToken = $this->session->access_token;
     }
     $this->config = $config;
 }
 /**
  * @param string  $defaultLang
  * @param ITranslatorStorage $translatorStorage
  * @param Nette\Http\Session $session
  * @param Nette\Application\Application $application
  */
 public function __construct($defaultLang, ITranslatorStorage $translatorStorage, Nette\Http\Session $session, Nette\Application\Application $application)
 {
     $this->setDefaultLang($defaultLang);
     $this->translatorStorage = $translatorStorage;
     $session->start();
     $this->session = $session;
     $this->application = $application;
 }
 /**
  * Html code for DebugerBar Panel
  * @author Pavel Železný <*****@*****.**>
  * @return string
  */
 public function getPanel()
 {
     $template = $this->getFileTemplate(__DIR__ . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'panel.latte');
     $template->session = $this->session->isStarted() ? $this->session : FALSE;
     $template->sessionMetaStore = isset($_SESSION['__NF']['META']) ? $_SESSION['__NF']['META'] : array();
     $template->sessionMaxTime = ini_get('session.gc_maxlifetime');
     $template->hiddenSections = $this->hiddenSections;
     return $template;
 }
Exemple #12
0
 public function __construct(EntityManager $entityManager, Session $session, IBrowserControlFactory $browserFactory)
 {
     parent::__construct();
     $this->entityManager = $entityManager;
     $this->fileRepository = $entityManager->getRepository(File::class);
     $this->dirRepository = $entityManager->getRepository(Dir::class);
     $this->session = $session->getSection('Venne.Content.filesSide');
     $this->browserFactory = $browserFactory;
 }
Exemple #13
0
 public function __construct(Nette\Http\Session $session, Nette\Caching\IStorage $cacheStorage, Nette\Http\Response $httpResponse)
 {
     $this->sessionStorage = $sessionStorage = $session->getSection(self::$namespace);
     $this->cache = new Nette\Caching\Cache($cacheStorage, self::$namespace);
     $this->httpResponse = $httpResponse;
     if (!isset($sessionStorage->newStrings) || !is_array($sessionStorage->newStrings)) {
         $sessionStorage->newStrings = array();
     }
 }
Exemple #14
0
 /**
  * @param PayPal $payPal
  * @param Session $session
  */
 public function __construct(PayPal $payPal, Session $session)
 {
     parent::__construct();
     $this->payPal = $payPal;
     $this->session = $session->getSection('PayPalExpress');
     $this->session->setExpiration('+10 minutes');
     if (empty($this->session->token)) {
         $this->session->token = $this->_ec = Strings::random(6);
     }
 }
Exemple #15
0
 /**
  * @param Article $article Clanek, ktery se komentuje
  * @param \Nette\Http\Session $session Session pro ulozeni hodnot pri nahledu komentare
  * @param \Kdyby\Translation\Translator $translator Prekladac
  * @param \App\Model\Repository\ArticleRepository $repository 
  */
 public function __construct(Article $article, \Nette\Http\Session $session, \Kdyby\Translation\Translator $translator, \App\Model\Repository\ArticleRepository $repository)
 {
     $this->article = $article;
     $this->commentSession = $session->getSection('comments');
     $this->translator = $translator;
     $this->articleRepository = $repository;
     $this->paginator = new \Nette\Utils\Paginator();
     $this->paginator->setItemsPerPage(self::COMMENT_PER_PAGE);
     $this->paginator->setPage(1);
 }
Exemple #16
0
 /**
  * @param Nette\Application\Application
  * @param Gettext\Translator\Gettext 
  * @param Nette\Http\Session
  * @param Nette\Http\Request
  * @param string
  * @param int
  */
 public function __construct(Nette\Application\Application $application, Gettext $translator, Nette\Http\Session $session, Nette\Http\Request $httpRequest, $layout, $height)
 {
     $this->application = $application;
     $this->translator = $translator;
     $this->sessionStorage = $session->getSection(Gettext::$namespace);
     $this->httpRequest = $httpRequest;
     $this->height = $height;
     $this->layout = $layout;
     $this->processRequest();
 }
 public function __construct(Nette\Http\Session $session, Nette\Caching\IStorage $cacheStorage, Nette\Http\Response $httpResponse, FileManager $fileManager)
 {
     $this->sessionStorage = $sessionStorage = $session->getSection(self::$namespace);
     $this->cache = new Nette\Caching\Cache(new Nette\Caching\Storages\DevNullStorage(), self::$namespace);
     $this->httpResponse = $httpResponse;
     $this->fileManager = $fileManager;
     /*
     if (!isset($sessionStorage->newStrings) || !is_array($sessionStorage->newStrings)) {
     	$sessionStorage->newStrings = array();
     }
     */
 }
Exemple #18
0
 /**
  * Check if answer is corect
  * @param string $answer
  * @throws CookieException
  * @return bool
  */
 public function checkCaptcha($answer)
 {
     if (!$this->session->isStarted()) {
         throw new \Exception('Povolte cookies ve vašem prohlížeči');
     }
     if ($this->cutAnswer($answer) != $this->cutAnswer($this->sessSect->answer)) {
         $this->sessSect->status = 'answBad';
         throw new \Exception('Špatná odpověď na otázku, možná pouze špatně zapsaná');
     }
     $this->sessSect->status = 'answOk';
     return true;
 }
Exemple #19
0
 public function __construct(Messages $messages, Nette\Http\Session $session, Github\Api $api, User $user = NULL)
 {
     $this->session = $session->getSection('milo.github.nette-extension');
     $this->api = $api;
     $this->user = $user;
     foreach ($messages->getAll() as $message) {
         $this->onMessage($message);
     }
     # Change handler
     $api->getClient()->onRequest([$this, 'onMessage']);
     $api->getClient()->onResponse([$this, 'onMessage']);
 }
Exemple #20
0
 public function success(Form $form)
 {
     $values = $form->getValues();
     if ($values['section'] === 'all') {
         $this->cacheStorage->clean(array(Cache::ALL => true));
         $this->session->destroy();
     } elseif ($values['section'] === 'cache') {
         $this->cacheStorage->clean(array(array(Cache::ALL => true)));
     } elseif ($values['section'] === 'sessions') {
         $this->session->destroy();
     }
 }
Exemple #21
0
 public function __construct(EntityManagerInterface $entityManager, Session $session, $cashPaymentAvailable, $bankPaymentAvailable, $cardPaymentAvailable)
 {
     parent::__construct($entityManager);
     $this->repository = $entityManager->getRepository(Order::class);
     $this->entityManager = $entityManager;
     $orderSession = $session->getSection('order');
     $orderSession->setExpiration('+ 30 minutes');
     $this->orderSession = $orderSession;
     $this->cashPaymentAvailable = (bool) $cashPaymentAvailable;
     $this->bankPaymentAvailable = (bool) $bankPaymentAvailable;
     $this->cardPaymentAvailable = (bool) $cardPaymentAvailable;
 }
Exemple #22
0
 /**
  * Returns and initializes $this->sessionSection.
  * @return Nette\Http\SessionSection
  */
 protected function getSessionSection($need)
 {
     $ret = parent::getSessionSection($need);
     if (!is_null($ret)) {
         if ($ret->authenticated && $ret->identity->browser !== $this->browser->getName() && $ret->identity->browserVersion !== $this->browser->getVersion()) {
             $ret->authenticated = FALSE;
             $this->sessionHandler->regenerateId();
             $ret->reason = static::MANUAL;
             $ret->authTime = NULL;
         }
     }
     return $ret;
 }
 /**
  * Get web passage uri from session if any
  * @return mixed
  */
 public function getPassage($size = NULL, $include_host = TRUE)
 {
     $url = $this->request->url->scheme . '://' . $this->request->url->host;
     $passage = $this->session->getSection('web_passage')->web_passage ?: [];
     if ($size) {
         $passage = array_slice($passage, 0, $size);
     }
     if (!$include_host) {
         $passage = array_map(function ($item) use($url) {
             return str_replace($url, '', $item);
         }, $passage);
     }
     return $passage;
 }
Exemple #24
0
 /**
  * @param int $id
  */
 public function handleCheck($id)
 {
     $this->session->close();
     $this->redrawControl('check');
     $this->template->last = $newerThan = $this->commentDao->find($id);
     for ($x = 0; $x < 100; $x++) {
         if ($this->countNewComments($newerThan)) {
             $this->template->new = $this->getNewComments($newerThan);
             $this->template->last = end($this->template->new);
             $this->redrawControl('new');
             break;
         }
         sleep(1);
     }
 }
 /**
  * @return \Nette\Http\SessionSection
  */
 protected function getStateSession()
 {
     if (is_null($this->session)) {
         throw new \Nette\InvalidStateException('Session is not set! Use \'setSession\' to set session!');
     }
     return $this->session->getSection('VisualPaginator/' . $this->lookupPath('Nette\\ComponentModel\\IComponent', FALSE) ?: $this->getName() . '/states');
 }
Exemple #26
0
 /**
  * Returns session namespace provided to pass temporary data between redirects.
  * @return Nette\Http\SessionSection
  */
 public function getFlashSession()
 {
     if (empty($this->params[self::FLASH_KEY])) {
         $this->params[self::FLASH_KEY] = Nette\Utils\Strings::random(4);
     }
     return $this->session->getSection('Nette.Application.Flash/' . $this->params[self::FLASH_KEY]);
 }
Exemple #27
0
 /**
  * Determines whether a variable in this session section is set.
  * @param  string    name
  * @return bool
  */
 public function __isset($name)
 {
     if ($this->session->exists()) {
         $this->start();
     }
     return isset($this->data[$name]);
 }
Exemple #28
0
 /**
  * @param  string
  * @return Nette\Http\Session|Nette\Http\SessionSection
  */
 public function getSession($namespace = NULL)
 {
     if (!$this->session) {
         throw new Nette\InvalidStateException('Service Session has not been set.');
     }
     return $namespace === NULL ? $this->session : $this->session->getSection($namespace);
 }
 /**
  * @throws AuthenticationException
  * @param array $credentials
  * @return Identity
  */
 public function authenticate(array $credentials)
 {
     list($code, $state) = $credentials;
     $session = $this->session->getSection(AuthPresenterTrait::$OAUTH_SESSION);
     if (empty($session->state) || $session->state !== $state) {
         throw new AuthenticationException('Invalid state.');
     }
     try {
         $accessToken = $this->provider->getAccessToken('authorization_code', ['code' => $code]);
         /* @var $data AngelcamUser */
         $data = $this->provider->getResourceOwner($accessToken);
     } catch (\Exception $e) {
         $invalidToken = $e instanceof ClientException && $e->getResponse()->getStatusCode() === 401;
         throw new AuthenticationException($invalidToken ? 'Invalid token' : 'Authentication failed', 0, $e);
     }
     return new Identity($data->getId(), $data, $accessToken);
 }
 /**
  * @param string
  * @param string
  * @return void
  * @throws \Nette\InvalidStateException
  */
 private function setSession($uid, $word)
 {
     if (!self::$session) {
         throw new \Nette\InvalidStateException(__CLASS__ . ' session not found');
     }
     self::$session->{$uid} = $word;
     self::$session->setExpiration($this->getExpire(), $uid);
 }