public function init()
 {
     parent::init();
     (int) ($this->id = (int) Controller::curr()->getRequest()->param('ID'));
     //grab ID from URL query string
     $this->keywords = Catalogue::get()->where(array('id =' . $this->id))->column($colName = "keywords");
     //get keywords
     $this->keywordsArr = parent::__convertAndCleanList($this->keywords, ',');
     // creates array into pieces
     $this->video = Catalogue::get()->where(array('id =' . $this->id))->setQueriedColumns(array("Video_title", "trilogy"));
     //get title
 }
示例#2
0
 /**
  * gets genres as a separate query sorts and removes duplicates
  * 
  * @return string
  */
 public function getGenres()
 {
     $result = Catalogue::get()->sort('Genre')->where('Genre is not null')->column($colName = "Genre");
     if ($result != null) {
         /** clean up keywords from DB **/
         $_list = array(parent::__convertAndCleanList($result, '|'));
         $genreList = "";
         foreach ($_list as $list) {
             foreach ($list as $value) {
                 $genreList .= "<li><span data-path=\"." . str_replace(' ', '', $value) . "\">" . $value . "</span></li>";
             }
         }
         return $genreList;
     }
 }
示例#3
0
 public function Form()
 {
     $genres = $this->__getGenres();
     $clean = parent::__convertAndCleanList($genres, $pipe = '|');
     $genres != null ? $genresJson = json_encode($clean) : json_encode(array("Comedy", "Drama", "Horror", "Science Fiction", "Comic/Super Heroes", "Action", "Thriller", "Crime", "Documentary", "Family", "Animated", "Romance", "Adventure", "War", "Sitcom"));
     Requirements::customScript('
             $("#Form_Form_Seasons").tagit({
                 singleFieldDelimiter: " | ",    
                 allowSpaces: true,
                 availableTags: ["Season 1", "Season 2", "Season 3", "Season 4", "Season 5", "Season 6", "Season 7", "Season 8", "Season 9" , "Season 10", "Season 11", "Season 12", "Season 13", "Season 14", "Season 15", "Season 16"]
             });
             
             $("#Form_Form_Genre").tagit({
                 singleFieldDelimiter: " | ",    
                 availableTags: ' . $genresJson . '
             });
                                  
         ');
     //create source arrays to swap out on form load
     $filmarr = array('Bluray' => 'BD/BRRip', 'DVD' => 'DVD-R', 'screener' => 'SCR/SCREENER/DVDSCR/DVDSCREENER/BDSCR', 'cam' => 'CAMRip/CAM/TS/TELESYNC', 'vod' => 'VODRip/VODR', 'web' => 'WEB-Rip/WEBRIP/WEB Rip/WEB-DL');
     $tvarr = array('Bluray' => 'BD/BRRip', 'DVD' => 'DVD-R', 'HDTV' => 'HD TV', 'SDTV' => 'SD TV', 'web' => 'WEB-Rip/WEBRIP/WEB Rip/WEB-DL');
     //include js
     $keywords = $this->__getKeywords();
     if ($keywords != null) {
         $clean = parent::__convertAndCleanList($keywords, $pipe = ',');
         $json = json_encode($clean);
         // turn into json array for jquery library
         Requirements::customScript('
           $("#Form_Form_keywords").tagit({
                 singleFieldDelimiter: " , ",
                 allowSpaces: true,
                 fieldName: "keywordsField",
                 availableTags: ' . $json . '
             });
         ');
     } else {
         Requirements::customScript('
           $("#Form_Form_keywords").tagit({
                 singleFieldDelimiter: " , ",
                 allowSpaces: true,
             });
         ');
     }
     $action = Controller::curr()->getRequest()->param('Action');
     $id = (int) Controller::curr()->getRequest()->param('ID');
     $automap = $id ? $automap = Catalogue::get()->byID($id) : false;
     $submitCaption = $automap ? 'Edit' : 'Add';
     $sourceArr = $filmarr;
     if (isset($automap->Video_type)) {
         $automap->Video_type == 'film' ? $sourceArr = $filmarr : ($sourceArr = $tvarr);
     }
     // Create fields
     $fields = FieldList::create(TextField::create('Video_title', 'Video Title'), DropDownField::create('Video_type', 'Type of Video', array('series' => 'Series (TV)', 'film' => 'Film'))->setEmptyString('Select type of media'), TextField::create('Genre', 'Genre')->setDescription('Select a genre by typing a keyword e.g. Comedy'), TextField::create('keywords', 'Keywords')->setDescription('Add a keyword/tag to the title e.g. Marvel'), TextField::create('trilogy', 'Is this a Trilogy?')->setDescription('Add a trilogy name e.g. "X-Men" or "Wolverine"'), TextField::create('Seasons', 'Seasons')->setDescription('Select a Season or type Seasons owned e.g. Season 1'), DropDownField::create('Status', 'Current Status of download', array('Downloaded' => 'Downloaded - file complete', 'Downloading' => 'Dowloading - in progress', 'Wanted' => 'Wanted - need a copy of', 'No Torrents' => 'No Torrents - cannot find video'))->setEmptyString('Select status'), DropDownField::create('Source', 'Source of download', $sourceArr)->setEmptyString('Select source'), DropDownField::create('Quality', 'Resolution of download (quality)', array('4k' => '4k', '1440p' => '1440p', '1080p' => '1080p', '720p' => '720p', '420p' => '420p', '320p' => '320p'))->setEmptyString('Select quality'), HiddenField::create('Owner', '', Member::currentUserID()), HiddenField::create('Comments'), HiddenField::create('imdbID'), HiddenField::create('Year'), TextareaField::create('CommentsEnter', 'Enter new comments on new line'), HiddenField::create('Poster'), HiddenField::create('ID', 'ID')->setValue($id));
     $actions = FieldList::create(FormAction::create('submit', $submitCaption));
     $validator = RequiredFields::create('Video_title');
     $form = Form::create($this, 'Form', $fields, $actions, $validator);
     $form->type = $submitCaption;
     //are we in edit or add mode, pass it to view
     if ($automap) {
         $form->loadDataFrom($automap);
     }
     return $form;
 }