Exemplo n.º 1
0
 /**
  * @return Season
  */
 public static function getInstance()
 {
     if (!self::$instance) {
         if (isset($_GET['year']) && is_numeric($_GET['year']) && strlen($_GET['year']) == 4) {
             $year = $_GET['year'];
         } else {
             // assume new season starts in august
             if (date('n') >= 8) {
                 // assume it' not updated before the 25th (random guess) of august
                 $year = date('Y');
                 if (date('n') == 8 && date('j') < 25) {
                     $year--;
                 }
             } else {
                 // from jan to aug, use season that started last year
                 $year = date('Y') - 1;
             }
         }
         self::$instance = self::getSingle(array('nefub_id' => $year));
         if (!self::$instance) {
             self::$instance = new Season();
             self::$instance->nefub_id = $year;
             self::$instance->save();
         }
     }
     return self::$instance;
     $this->instance = $oSeason;
 }
Exemplo n.º 2
0
 public function load()
 {
     $this->clear();
     // Alfredo Rodriguez (Maryland)
     $season = new Season();
     $season->setYear(2012);
     $season->save();
     print_r(sprintf("Created Season: %s, %s (%s)\n", $player->getName(), $season->getYear(), $player->getId()));
 }
Exemplo n.º 3
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Season();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Season'])) {
         $model->attributes = $_POST['Season'];
         if ($model->save()) {
             $this->redirect(array('admin'));
         }
     }
     $this->render('create', array('model' => $model));
 }
Exemplo n.º 4
0
 public function editElementProcces()
 {
     if (!$this->session->userdata('logged_in')) {
         redirect('user/login');
     }
     print "<pre>";
     print_r($_POST);
     print "</pre>";
     $element_id = $_POST['element_id'];
     // change main name
     $element = new SimpleElement($this->oh, $element_id);
     $element->main_name = $_POST['main_name'];
     $element->save();
     print_query($this->db);
     unset($_POST['main_name']);
     //new name and season
     if ($_POST['newName']) {
         $season = -1;
         if ($_POST['newNameSeason'] && $_POST['newNameSeason'] != -1) {
             $season = $_POST['newNameSeason'];
         }
         $newSeason = new Season($this->db);
         $newSeason->element_id = $element_id;
         $newSeason->season = $season;
         $newSeason->save();
         $newName = new Name($this->db);
         $newName->element_id = $element_id;
         $newName->name = $_POST['newName'];
         $newName->season = $newSeason;
         $newName->save();
         unset($_POST['newName']);
         unset($_POST['newNameSeason']);
     }
     foreach ($_POST as $key => $value) {
         if (strpos($key, "elementLocationNew_") !== false) {
             $key = explode("_", $key);
             $location_id = $key[1];
             $season = -1;
             if ($_POST["elementLocationSeasonNew_" . $location_id] && $_POST["elementLocationSeasonNew_" . $location_id] != "all") {
                 $season = $_POST["elementLocationSeasonNew_" . $location_id];
             }
             $seasonSize = -1;
             if ($_POST["elementLocationSeasonNew_" . $location_id] && $_POST["elementLocationSeasonNew_" . $location_id] != "infinite") {
                 $seasonSize = $_POST["elementLocationSeasonNew_" . $location_id];
             }
             $newSeason = new Season($this->db);
             $newSeason->element_id = $element_id;
             $newSeason->season = $season;
             $newSeason->save();
             $newElementLocation = new ElementLocation($this->db);
             $newElementLocation->location = new Location($this->db, $location_id);
             $newElementLocation->element = new Element($this->db, $element_id);
             $newElementLocation->season = $newSeason;
             $newElementLocation->identifier = $value;
             $newElementLocation->seasonsize = $seasonSize;
             $newElementLocation->save();
             unset($_POST[$key]);
             unset($_POST["elementLocationSeasonNew_" . $location_id]);
             continue;
         }
         if (strpos($key, "location_") !== false) {
             print "----------------<br>";
             $key = explode("_", $key);
             $elementLocation_id = $key[1];
             $oldSeason = $key[2];
             if ($value || $_POST["locationSize_" . $elementLocation_id] && $_POST["locationSeason_" . $elementLocation_id]) {
                 $season = -1;
                 if ($_POST["locationSeason_" . $elementLocation_id] && $_POST["locationSeason_" . $elementLocation_id] != "all") {
                     $season = $_POST["locationSeason_" . $elementLocation_id];
                 }
                 $seasonSize = -1;
                 if ($_POST["locationSize_" . $elementLocation_id] && $_POST["locationSize_" . $elementLocation_id] != "infinite") {
                     $seasonSize = $_POST["locationSize_" . $elementLocation_id];
                 }
                 $newSeason = new Season($this->db);
                 $newSeason->element_id = $element_id;
                 $newSeason->season = $season;
                 $newSeason->save();
                 $newElementLocation = new ElementLocation($this->db, $elementLocation_id);
                 print $newElementLocation->location->name . ": " . $newElementLocation->identifier . "<br>";
                 $newElementLocation->season = $newSeason;
                 $newElementLocation->identifier = $value;
                 $newElementLocation->seasonsize = $seasonSize;
                 $newElementLocation->save();
             } else {
                 $newElementLocation = new ElementLocation($this->db, $elementLocation_id);
                 $newElementLocation->delete();
             }
             continue;
         }
         if (strpos($key, "name_") !== false) {
             print "----------------<br>";
             $key = explode("_", $key);
             $name_id = $key[1];
             if ($value) {
                 $season = -1;
                 if ($_POST["nameSeason_" . $name_id] && $_POST["nameSeason_" . $name_id] != "all") {
                     $season = $_POST["nameSeason_" . $name_id];
                 }
                 $newSeason = new Season($this->db);
                 $newSeason->element_id = $element_id;
                 $newSeason->season = $season;
                 $newSeason->save();
                 $newName = new Name($this->db, $name_id);
                 $newName->name = $value;
                 $newName->season = $newSeason;
                 $newName->save();
             } else {
                 $newName = new Name($this->db, $name_id);
                 $newName->delete();
             }
             continue;
         }
     }
     if (!isset($_POST['debug'])) {
         redirect('xem/editElement/' . $element_id);
     }
 }
Exemplo n.º 5
0
 /**
  * Creates or updates the episode in database getting data from file.
  * Used in /tvshow/actions/executeRefreshTVShow
  *
  * @param Season $season_object ex: Season(1)
  * @param Array $episode_info[] ex: [12, Getting in troubles, 1080p, 25 fps, 2300 kbps, 1920x800, [Spa,Eng], [Spa]]
  * @return Episode
  */
 public static function createEpisode($season_object, $episode_info)
 {
     //looking for this episode in db
     $episode_object = NULL;
     foreach ($season_object['Episodes'] as $episode) {
         if ($episode->title == $episode_info['title']) {
             $episode_object = $episode;
         }
     }
     //if there is no episode
     if ($episode_object == NULL) {
         $episode_object = new Episode();
         $episode_object->title = $episode_info['title'];
         $episode_object->num_episode = $episode_info['num_episode'];
     }
     $episode_object->duration = $episode_info['duration'];
     $episode_object->framerate = $episode_info['framerate'];
     $episode_object->bitrate = $episode_info['bitrate'];
     $episode_object->filesize = $episode_info['filesize'];
     $episode_object->dimensions = $episode_info['dimensions'];
     $episode_object->file_abs = $episode_info['file_abs'];
     $episode_object->file_rel = $episode_info['file_rel'];
     /***********************************   FORMAT   ***********************************/
     if ($episode_info['format'] != NULL) {
         $format_object = Doctrine::getTable('Format')->findOneByName($episode_info['format']);
         if ($format_object == NULL) {
             $format_object = Util::createFormat($episode_info['format']);
         }
         $episode_object->Format = $format_object;
     }
     /**********************************   LANGUAGES   **********************************/
     //First remove previous audio tracks
     foreach ($episode_object['AudioTracks'] as $track) {
         $q = Doctrine_Query::create()->delete('AudioTrack')->where('id = ?', $track['id'])->execute();
     }
     //Adding the new ones
     foreach ($episode_info['audio_tracks'] as $track) {
         $audio_track = Util::createAudioTrack($track['codec'], $track['code']);
         $episode_object->AudioTracks[] = $audio_track;
     }
     /**********************************   SUBTITLES   **********************************/
     //First remove previous sub tracks
     foreach ($episode_object['SubTracks'] as $track) {
         $q = Doctrine_Query::create()->delete('SubTrack')->where('id = ?', $track['id'])->execute();
     }
     //Adding the new ones
     foreach ($episode_info['sub_tracks'] as $track) {
         $sub_track = Util::createSubTrack($track['label'], $track['code']);
         $episode_object->SubTracks[] = $sub_track;
     }
     $episode_object->save();
     $season_object->Episodes[] = $episode_object;
     $season_object->save();
     return $episode_object;
 }