Example #1
0
 public function save(Nette\Application\UI\Form $form)
 {
     $flag = $this->context->createServiceFlags();
     try {
         $vars = $form->getValues();
         if ($vars['www'] !== '') {
             $form->addError('Are you a spam robot, right?');
             throw new AuthorizationException('Are you a spam robot, right?');
         }
         unset($vars['www']);
         $flag->flag = $vars;
         $flag->save();
         $cache = new Nette\Caching\Cache($this->context->cacheStorage);
         $cache->clean(array('flags', 'flag'));
         $this->flashMessage('Děkujeme! Váš podnět k aktualizaci zpracujeme. Peknyden.cz.', 'success');
         $this->hide = true;
     } catch (AuthorizationException $e) {
         $this->flashMessage($e->getMessage(), 'error');
     } catch (Exception $e) {
         $this->flashMessage('There is error during saving flag! We know about this. Try it later, please.', 'error');
     }
     if ($this->parent->isAjax()) {
         $this->redrawControl('form');
     }
 }
Example #2
0
 public function render($args = NULL)
 {
     parent::render($args);
     $this->template->files = $this->context->createServiceFiles()->where('isImage', '1')->where('imageSizeX > 150')->where('imageSizeY > 150')->where('delete', '0')->limit(10)->order('first DESC, file.created DESC')->group(':subject_x_file.subject_id');
     //$this->template->subjects = $this->context->createServicePlaces()->fetchVisible();
     $this->template->setFile(__DIR__ . "/PhotoStream.latte");
     //		$this->template->setTranslator($this->context->translator);
     $this->template->render();
 }
Example #3
0
 /**
  * (non-phpDoc)
  *
  * @see Nette\Application\Control#render()
  */
 public function render($args = NULL)
 {
     parent::render($args);
     $tmp = $this->context->createServiceTimes()->fetchPublic()->where('DATEDIFF(event_time.date_from, CURDATE()) >= 0')->where('prefered', 1)->order('event_time.date_from ')->group('event_time.event_id')->limit(4);
     if ($tmp->count() == 0) {
         $tmp = $this->context->createServiceTimes()->fetchPublic()->where('DATEDIFF(event_time.date_from, CURDATE()) >= 0')->order('event_time.date_from ')->group('event_time.event_id')->limit(4);
     }
     $this->template->events = $tmp;
     $this->template->setFile(__DIR__ . "/HomepageCalendarControl.latte");
     $this->template->setTranslator($this->translator);
     $this->template->render();
 }
Example #4
0
 public function render()
 {
     $cache = new Cache($this->context->getService('cacheStorage'));
     $key = $this->type;
     $categories = $cache->load($key);
     if ($categories === NULL) {
         $categories = $this->context->database->table('category')->where($this->type, '1')->where('visible', '1')->group('category.id')->having('COUNT(:' . $this->type . '_x_category.category_id) > 0')->order('category.shift, category.name')->fetchPairs('code', 'name');
         $cache->save($key, $categories, array(Cache::EXPIRE => "24 hours", Cache::SLIDING => true, Cache::TAGS => array('category', 'categories')));
     }
     $this->template->categories = $categories;
     $this->template->type = $this->type;
     $this->template->setFile(__DIR__ . "/CategoriesControl." . $this->type . ".latte");
     //		$this->template->setTranslator($this->context->translator);
     $this->template->render();
 }
Example #5
0
 public function __construct(\Nette\DI\Container $context)
 {
     $this->context = $context;
     $this->subjects = $this->context->createServicePlaces()->fetchVisible()->limit(7)->order('RAND()');
 }
Example #6
0
 /**
  * (non-phpDoc)
  *
  * @see Nette\Application\Control#render()
  */
 public function render($args = NULL)
 {
     parent::render($args);
     $httpRequest = $this->context->getService('httpRequest');
     $this->template->hash = $httpRequest->getUrl()->path;
     if ($this->presenter->name == 'Calendar') {
         $this->template->type = 'event';
     } else {
         $this->template->type = 'place';
     }
     if ($this->tab == '') {
         $this->handleEvents();
     }
     $cache = new Cache($this->context->getService('cacheStorage'), 'tabs');
     // akce na miste
     $key = "subject_id/" . $this->subject->id;
     if (in_array('events', $this->tabs) && $this->subject->id != 1) {
         $events = $this->context->createServiceTimes()->where('event_time.event.subject_id', $this->subject->id)->fetchVisibleEvent()->fetchCurrent()->group('event_time.event_id')->limit(5);
         if ($this->excludeEvent) {
             $events->where('event_time.event_id != ' . $this->excludeEvent);
         }
     } else {
         $events = new \Nette\ArrayHash();
         //workaround pro prazdny eventy a nasledujici IF
     }
     $eventsCount = $cache->load($key);
     if ($eventsCount === NULL) {
         $eventsCount = $events->count();
         $cache->save($key, $eventsCount, array(Cache::EXPIRE => "8 hours", Cache::SLIDING => true, Cache::TAGS => array('events', 'event')));
     }
     $this->template->events = $events;
     $this->template->eventsCount = $eventsCount;
     if ($this->tab == 'events' && $eventsCount == 0) {
         if ($this->template->type == 'event') {
             $this->tab = "nearEvents";
         } else {
             $this->tab = "nearPlaces";
         }
     }
     if ($this->lat == "") {
         $this->lat = $this->subject->lat;
     }
     if ($this->lon == "") {
         $this->lon = $this->subject->lon;
     }
     // akce v okoli
     try {
         /* @var $nearEvents \EventsTimes */
         $nearEvents = in_array('nearEvents', $this->tabs) ? $this->context->createServiceTimes()->nearEvent($this->lat, $this->lon, $this->distance, $this->excludeEvent, $this->excludePlace)->fetchCurrent()->fetchVisibleEvent()->limit(5)->group('event_time.event_id') : NULL;
         if ($this->tab == 'nearEvents' && $nearEvents->count() == 0) {
             if ($this->template->type == 'event') {
                 $this->tab = "nearPlaces";
             } else {
                 $this->tab = "events";
             }
         }
         $distances = array();
         foreach ($nearEvents as $key => $time) {
             $gps = Geolocation::getCoordsFromText($time->event_time->event->subject_gps);
             $distances[$time->id] = Geolocation::getDistance($this->lat, $this->lon, $gps[0], $gps[1]);
         }
         $this->template->nearEvents = $nearEvents;
         $this->template->nearEventsDistances = $distances;
     } catch (DibiException $e) {
         if ($e->getCode() == 1) {
             // no near events
             $this->tab = "nearPlaces";
         } else {
             $this->flashMessage($e->getMessage(), 'warning');
         }
     }
     // mista v okoli
     try {
         $places = in_array('nearPlaces', $this->tabs) ? $this->context->createServicePlaces()->near($this->lat, $this->lon, $this->distance)->fetchVisible()->fetchUnDeleted()->limit(5)->fetchVisible() : NULL;
         if ($this->subject) {
             $places->where('subject.id != ', $this->subject->id);
         }
         if ($this->excludePlace) {
             $places->where('subject.id != ' . $this->excludePlace);
         }
         $distances = array();
         foreach ($places as $key => $place) {
             $distances[$place->id] = Geolocation::getDistance($this->lat, $this->lon, $place->lat, $place->lon);
         }
         $this->template->nearPlaces = $places;
         $this->template->nearPlacesDistances = $distances;
         if ($this->tab == 'nearPlaces' && $this->template->nearPlaces->count() == 0) {
             if ($this->template->type == 'event') {
                 $this->tab = "events";
             } else {
                 $this->tab = "nearEvents";
             }
         }
         $this->template->subject = $this->subject;
     } catch (DibiException $e) {
         if ($e->getCode() == 1) {
             $this->tab = "events";
         } else {
             $this->flashMessage($e->getMessage(), 'warning');
         }
     }
     $this->template->distance = $this->distance / 1000;
     $this->template->active = $this->tab;
     $this->template->tabs = $this->tabs;
     $texy = new Texy();
     $this->template->registerHelper('texy', callback($texy, 'process'));
     $helpers = $this->context->myTemplateHelpers;
     $this->template->registerHelperLoader(array($helpers, 'loader'));
     $this->template->setFile(__DIR__ . "/Tabs.latte");
     $this->template->render();
 }
Example #7
0
 public function __construct(\Nette\DI\Container $context)
 {
     $this->context = $context;
     $this->events = $this->context->createServiceTimes()->fetchPublic()->limit(6);
     $this->subjects = $this->context->createServicePlaces()->fetchVisible()->limit(6);
 }