Example #1
0
 public function playlist()
 {
     $this->data['title'] = 'Song Playlists';
     if (isset($_POST) && !empty($_POST)) {
         //generate slug
         $slug = Url::generateSafeSlug($_POST['title']);
         $albumArray = array('album_name' => $_POST['title'], 'album_user_id' => Session::get('user_id'), 'album_category_id' => Category::id('category_title', 'playlist'), 'album_description' => $_POST['description'], 'album_slug' => $slug . 'pl', 'album_created' => time());
         $albumArray = Gump::xss_clean($albumArray);
         $albumArray = Gump::sanitize($albumArray);
         $album_id = $this->albumModel->create($albumArray);
         if ($album_id > 0) {
             $checkSlug = $this->albumModel->getColRow('album_slug', $slug);
             if (!is_bool($checkSlug)) {
                 $updateSlug = $this->albumModel->updateId(array('album_slug' => $slug . 'pl' . $album_id), $album_id);
             }
             //UPLOAD ALBUM COVER
             if ($_FILES["image"]["tmp_name"] != '') {
                 //upload file into uploads folder
                 Upload::setName(time());
                 Upload::resizeUpload($_FILES["image"], UPLOAD_PATH, 300);
                 $update_data = array('album_image' => Upload::getFileName('images'));
                 $this->albumModel->updateId($update_data, $album_id);
             }
             Session::set('success', 'Playlist Created');
         } else {
             Session::set('error', 'Operation Fails');
         }
     }
     $this->data['albums'] = $this->albumModel->allalbum();
     $total = count(Album::type('playlist'));
     $pages = new Paginator('5', 'p');
     $this->data['albums'] = Album::type('playlist', $pages->getLimit());
     $pages->setTotal($total);
     $path = DIR . 'song/playlist?';
     $this->data['pageLinks'] = $pages->pageLinks($path, null);
     View::rendertemplate('header', $this->data);
     View::rendertemplate('sidebar', $this->data);
     View::render('song/song.playlist', $this->data);
     View::rendertemplate('footer', $this->data);
 }