Ejemplo n.º 1
0
 /**
  * @param $id
  * @param $status
  * @throws \Nette\Application\BadRequestException
  */
 public function actionView($id, $status = null)
 {
     $interpret = $this->interpreti->find($id);
     if ($status) {
         $this->template->status = $status;
     }
     if (!$interpret) {
         throw new Nette\Application\BadRequestException("Interpret does not exists!", 404);
     }
     if ($interpret->interpret_id) {
         $msg = $this->flashMessage("Přesměrováno z '{$interpret->nazev}'");
         $msg->title = "Alias";
         $this->redirect("this", array("id" => $interpret->interpret_id));
         //If is alias => redirect to real
     }
     $this->template->interpret = $interpret;
     //Register helper fot fetching song form last.fm
     $this->template->registerhelper('songImage', function ($song, $img = 0) {
         try {
             return $this->lastfm->call('Track.getInfo', ['track' => $song->name, 'artist' => $song->interpret_name])->track->album->image[$img]->{'#text'};
         } catch (Model\Lastfm\LastfmException $e) {
             return null;
         }
     });
     //Last.fm Interpret info (images)
     try {
         $this->template->lastfm = $this->lastfm->call('Artist.getInfo', ['artist' => $interpret->nazev])->artist;
     } catch (Model\Lastfm\LastfmException $e) {
         if ($this->settings->get('lastfm_enabled', false)) {
             Debugger::log($e);
         }
     }
 }
Ejemplo n.º 2
0
 public function handleDelete($id)
 {
     try {
         $interpret = $this->interpreti->find($id);
         if (!$interpret) {
             throw new \PDOException("Row #{$id} not exists!");
         }
         $name = $interpret->nazev;
         $interpret->delete();
         $this->logger->log('Interpret', 'delete', "%user% smazala(a) interpreta {$name}");
         $msg = $this->flashMessage("Interpret '{$name}' smazán", 'success');
         $msg->title = 'A je venku!';
         $msg->icon = 'trash-o';
     } catch (\PDOException $e) {
         $msg = $this->flashMessage("Interpreta se nepodařilo odstranit", 'danger');
         $msg->title = 'Oh shit!';
         $msg->icon = 'exclamation-triangle';
         \Nette\Diagnostics\Debugger::log($e, \Nette\Diagnostics\Debugger::ERROR);
     }
     $this->redirect('this');
 }