Ejemplo n.º 1
0
 public function beforeRender()
 {
     $stats = $this->songy->findAll()->select("status, COUNT(id) AS score")->group("status")->fetchPairs("status", "score");
     $stats["all"] = count($this->songy->findAll());
     $this->template->navigation = $this->navigation;
     $this->template->songy = $this->songy;
     $this->template->songStats = $stats;
     $this->template->songGraph = $this->songy->findAll()->select("DATE(datum) AS datum, COUNT(datum) AS score")->group("DATE(datum)")->order("datum DESC");
 }
Ejemplo n.º 2
0
 public function renderDefault($filter)
 {
     //If filter is empty => redirect to default filter
     if (!$filter) {
         $this->redirect('this', ['filter' => 'last-month']);
     }
     $this->template->filter = $filter;
     //Filter mapping
     switch ($filter) {
         case 'last-month':
             $filter = '1 month';
             break;
         case 'last-week':
             $filter = '1 week';
             break;
         case 'last-day':
             $filter = '24 hour';
             break;
         default:
             $filter = null;
     }
     $this->template->songs = $this->songList->getTopSongs(10, $filter);
     $this->template->newest = $this->songList->findAll()->order("datum DESC")->limit(5);
 }
Ejemplo n.º 3
0
 public function handleLike($id)
 {
     if (!$this->checkPermissions("song", "like")) {
         $this->flashMessage("Pro lajkování songu se musíte přihlásit", "warning");
     } else {
         try {
             $this->songList->like($id, $this->user->id);
             $msg = $this->flashMessage("Hlasovat můžeš každých 24 hodin", "success");
             $msg->title = "Tvůj hlas byl zaznamenán!";
         } catch (\Nette\InvalidStateException $e) {
             $msg = $this->flashMessage("Hlasovat lze jen jednou za 24 hodin", "warning");
             $msg->title = "Pro tento song jsi již hlasoval(a)!";
         }
     }
     $this->redirect("this");
 }