Пример #1
0
 public function deleteCommentAction(Episodes $episode, Comments $comment)
 {
     if ($this->auth->has($comment)) {
         $comment->delete();
     }
     return $this->redirectByRoute(['for' => 'movies.showEpisode', 'movie' => $episode->getMovie()->id, 'episode' => $episode->id]);
 }
 /**
  * The add action
  */
 public function addAction()
 {
     $auth = $this->session->get('auth');
     if ($auth) {
         $this->_bc->add('Add', 'awards/add');
         $allEpisodes = Episodes::find(array('order' => 'air_date DESC'));
         $allUsers = Users::find(array('order' => 'username'));
         $allPlayers = Players::find(array('order' => 'active DESC, name'));
         $this->view->setVar('users', $allUsers);
         $this->view->setVar('episodes', $allEpisodes);
         $this->view->setVar('players', $allPlayers);
         if ($this->request->isPost()) {
             $datetime = date('Y-m-d H:i:s');
             $award = new Awards();
             $award->userId = $this->request->getPost('user_id', 'int');
             $award->episodeId = $this->request->getPost('episode_id', 'int');
             $award->playerId = $this->request->getPost('player_id', 'int');
             $award->award = $this->request->getPost('award', 'int');
             if (!$award->save()) {
                 foreach ($award->getMessages() as $message) {
                     $this->flash->error((string) $message);
                 }
             } else {
                 $this->view->disable();
                 $this->flash->success('Award created successfully');
                 $this->invalidateCache();
                 $this->response->redirect('awards/');
             }
         }
     }
 }
Пример #3
0
 public function getMyLastedEpisodes($days = 1)
 {
     if ([] == $this->myLatestEpisodes) {
         $this->myLatestEpisodes = Episodes::getLatest($days, $this);
     }
     return $this->myLatestEpisodes;
 }
Пример #4
0
 public function getLastWatchedEpisode()
 {
     if (null == $this->lastWatchedEpisode) {
         $this->lastWatchedEpisode = Episodes::findFirst('id = "' . $this->getWatchList()->currentEpisode_id . '"');
     }
     return $this->lastWatchedEpisode;
 }
 /**
  * The index action
  */
 public function indexAction()
 {
     $data[] = array('id' => '-1', 'number' => 'All');
     $episodes = Episodes::find(array('order' => 'airDate DESC'));
     foreach ($episodes as $episode) {
         $data[] = array('id' => $episode->id, 'number' => $episode->number);
     }
     $this->view->setVar('episodes', json_encode($data));
 }
Пример #6
0
 public function proses($opsi)
 {
     switch ($opsi) {
         case 'tambah':
             Episodes::tambah();
             break;
         case 'hapus':
             Episodes::hapus();
             break;
     }
 }
Пример #7
0
 /**
  * Validates the input and returns an error code
  *
  * @return int
  */
 private function _validate()
 {
     if (isset($this->_validator)) {
         $call_params = array(&$this->_value, $this->_range);
         return call_user_func_array($this->_validator, $call_params) ?? self::ERROR_NONE;
     }
     switch ($this->_type) {
         case "bool":
             if (!in_array($this->_value, array('1', '0', 'true', 'false'))) {
                 return self::ERROR_INVALID;
             }
             $this->_value = $this->_value == '1' || $this->_value == 'true';
             break;
         case "int":
         case "float":
             if (!is_numeric($this->_value)) {
                 return self::ERROR_INVALID;
             }
             $this->_value = $this->_type === 'int' ? intval($this->_value, 10) : floatval($this->_value, 10);
             if (self::checkNumberRange($this->_value, $this->_range, $code)) {
                 return $code;
             }
             break;
         case "text":
         case "string":
             if (!is_string($this->_value)) {
                 return self::ERROR_INVALID;
             }
             if (self::checkStringLength($this->_value, $this->_range, $code)) {
                 return $code;
             }
             break;
         case "uuid":
             if (!is_string($this->_value) || !preg_match(new RegExp('^[a-f0-9]{8}\\-[a-f0-9]{4}\\-4[a-f0-9]{3}\\-[89ab][a-f0-9]{3}\\-[a-f0-9]{12}$', 'i'), $this->_value)) {
                 return self::ERROR_INVALID;
             }
             $this->_value = strtolower($this->_value);
             break;
         case "username":
             global $USERNAME_REGEX;
             if (!is_string($this->_value) || !$USERNAME_REGEX->match($this->_value)) {
                 return self::ERROR_INVALID;
             }
             break;
         case "url":
             if (!is_string($this->_value)) {
                 return self::ERROR_INVALID;
             }
             global $REWRITE_REGEX;
             if (stripos($this->_value, ABSPATH) === 0) {
                 $this->_value = CoreUtils::substring($this->_value, CoreUtils::length(ABSPATH) - 1);
             }
             if (!preg_match($REWRITE_REGEX, $this->_value) && !preg_match(new RegExp('^#[a-z\\-]+$'), $this->_value)) {
                 if (self::checkStringLength($this->_value, $this->_range, $code)) {
                     return $code;
                 }
                 if (!preg_match(new RegExp('^https?://[a-z\\d/.-]+/[ -~]+$', 'i'), $this->_value)) {
                     Response::fail('Link URL does not appear to be a valid link');
                 }
             }
             break;
         case "int[]":
             if (!is_string($this->_value) || !preg_match(new RegExp('^\\d{1,12}(?:,\\d{1,12})*$'), $this->_value)) {
                 return self::ERROR_INVALID;
             }
             $this->_value = explode(',', $this->_value);
             break;
         case "json":
             try {
                 $this->_value = JSON::decode($this->_value);
                 if (empty($this->_value)) {
                     throw new \Exception(rtrim('Could not decode JSON; ' . json_last_error(), '; '));
                 }
             } catch (\Exception $e) {
                 error_log($e->getMessage() . "\n" . $e->getTraceAsString());
                 return self::ERROR_INVALID;
             }
             break;
         case "timestamp":
             $this->_value = strtotime($this->_value);
             if ($this->_value === false) {
                 return self::ERROR_INVALID;
             }
             if (self::checkNumberRange($this->_value, $this->_range, $code)) {
                 return $code;
             }
             break;
         case "epid":
             $this->_value = Episodes::parseID($this->_value);
             if (empty($this->_value)) {
                 return self::ERROR_INVALID;
             }
             break;
     }
     return self::ERROR_NONE;
 }
Пример #8
0
 private function saveEpisode($source, Episodes $to, $serial)
 {
     $to->num = $source['num'];
     $to->date = (new Carbon())->createFromTimestamp(strtotime($source['date']))->toDateTimeString();
     $to->title = $source['title'];
     $to->serial_id = $serial->id;
     $to->save();
 }
 public function deleteAction($id)
 {
     $auth = $this->session->get('auth');
     if ($auth) {
         $id = $this->filter->sanitize($id, array('int'));
         $episode = Episodes::findFirst('id=' . $id);
         if (!$episode) {
             $this->flash->error('Episode not found');
             return $this->response->redirect('episodes/');
         }
         if (!$episode->delete()) {
             foreach ($episode->getMessages() as $message) {
                 $this->flash->error((string) $message);
             }
             return $this->response->redirect('episodes/');
         } else {
             $this->flash->success('Episode deleted successfully');
             return $this->response->redirect('episodes/');
         }
     }
 }
Пример #10
0
 public function getLastUpdatedEpisode()
 {
     if (null == $this->lastEpisode) {
         $this->lastEpisode = Episodes::getLastUpdatedEpisodeFor($this);
     }
     return $this->lastEpisode;
 }
Пример #11
0
 public function latestAction()
 {
     $this->view->episodes = Episodes::getLatest(7);
     //        dd($this->view->episodes);
     //        (new \Carbon\Carbon())->now()->format('l')
 }
Пример #12
0
 public function addLinkToEpisodeAction($movie, Episodes $episode)
 {
     $episode->addLinkBy($this->auth, $this->request->getPost()['url']);
     return $this->redirectByRoute(['for' => 'movies.showEpisode', 'movie' => $movie, 'episode' => $episode->id]);
 }