public function edit($param) { $song_id = $param[0]; $songModel = new \Models\Song(); $this->data['title'] = 'Edit Song'; $this->data['albums'] = $this->albumModel->all(); $this->data['artist'] = User::artist(); $this->data['genre'] = $this->categoryModel->get(array('category_slug' => 'genre')); $this->data['tags'] = $this->categoryModel->get(array('category_slug' => 'tag')); $this->data['status'] = $this->status_model->get(array('status_slug' => 'album')); if (isset($_POST) && !empty($_POST)) { $songArray = array('song_album_id' => $_POST['album_id'], 'song_user_id' => Session::get('user_id'), 'song_artist_id' => $_POST['artist_id'], 'song_genre_id' => $_POST['genre_id'], 'song_status_id' => $_POST['status_id'], 'song_title' => $_POST['title'], 'song_description' => $_POST['description'], 'song_modified' => time(), 'song_slug' => Url::generateSafeSlug($_POST['title'])); $songArray = Gump::xss_clean($songArray); $songArray = Gump::sanitize($songArray); $update = $songModel->updateId($songArray, $song_id); if ($update > 0) { $message = 'ok'; } else { $message = 'no'; } if ($_FILES["mp3"]["tmp_name"] != '') { //resize youtube image into uploads folder Upload::setName(time()); Upload::upload_file($_FILES["mp3"], UPLOAD_PATH); $filepath = UPLOAD_PATH . Upload::getName(); $outputMp3 = UPLOAD_PATH . 'encoded_' . Upload::getName(); //check bitrate $bitRate = Audio::bitRateSampleRate($filepath, 'bitrate'); $duration = Audio::duration($filepath); if ($bitRate > 128) { $convertMp3 = Audio::convertMp3($filepath, 128, $outputMp3); } if (is_file($outputMp3)) { $updateArray = array('song_file' => 'images/encoded_' . Upload::getName(), 'song_duration' => $duration); unlink($filepath); } else { $updateArray = array('song_file' => Upload::getFileName('images'), 'song_duration' => $duration); } $saveMp3 = $songModel->updateId($updateArray, $song_id); } //UPLOAD SONG COVER if ($_FILES["image"]["tmp_name"] != '') { //upload file into uploads folder Upload::setName(time()); Upload::resizeUpload($_FILES["image"], UPLOAD_PATH, '450px'); $update_data = array('song_image' => Upload::getFileName('images')); $songModel->updateId($update_data, $song_id); } } if ($message == 'ok') { Session::set('success', 'record edited'); Url::redirect('song/item/' . $_POST['album_id']); } else { if ($message == 'no') { $this->data['error'] = 'Operation Fails!'; } } $this->data['song'] = \Models\Song::item($song_id); View::rendertemplate('header', $this->data); View::rendertemplate('sidebar', $this->data); View::render('song/song.edit', $this->data); View::rendertemplate('footer', $this->data); }
public function edit($param) { $edit_id = $param[0]; $user_model = new User(); if (isset($_POST) && !empty($_POST)) { $artistArray = array('user_firstname' => $_POST['firstname'], 'user_stagename' => $_POST['stagename'], 'user_bio' => $_POST['bio'], 'twitter_handle' => $_POST['twitter_handle'], 'user_modified' => time()); $artistArray = Gump::xss_clean($artistArray); $artistArray = Gump::sanitize($artistArray); $update_id = $user_model->updateId($artistArray, $edit_id); //UPLOAD ATTACHMENT if ($_FILES["image"]["tmp_name"] != '') { //upload image into uploads folder Upload::setName($slug . time()); Upload::resizeUpload($_FILES["image"], UPLOAD_PATH, '450px'); $update_data = array('user_image' => Upload::getFileName('images')); if ($this->user_model->updateId($update_data, $edit_id)) { Session::set('success', 'Artist record edited'); } else { Session::set('error', 'operation fails'); } } if ($update_id > 0) { Session::set('success', 'Artist record edited'); Url::redirect('artist'); } else { Session::set('error', 'operation fails'); } } $this->data['user_data'] = $user_model->find($edit_id); View::rendertemplate('header', $this->data); View::rendertemplate('sidebar', $this->data); View::render('artist/artist.add', $this->data); View::rendertemplate('footer', $this->data); }
public function edit($param) { $media_id = $param[0]; //get album detail $albumitem_detail = $this->mediaModel->find($media_id); $this->data['title'] = 'Edit Item'; $this->data['album_categories'] = $this->categoryModel->get(array('category_slug' => 'album')); $this->data['status'] = $this->status_model->get(array('status_slug' => 'album')); if (isset($_POST) && !empty($_POST)) { $slug = Url::generateSafeSlug($_POST['title']); $mediaArray = array('media_category_id' => $_POST['category'], 'media_user_id' => Session::get('user_id'), 'media_title' => $_POST['title'], 'media_description' => $_POST['description'], 'media_youtubelink' => $_POST['youtubelink'], 'media_slug' => $slug, 'media_modified' => time()); $update = $this->mediaModel->updateId($mediaArray, $media_id); if ($update > 0) { $message = 'ok'; } else { $message = 'no'; } //check if item is a video $category_type = $this->categoryModel->find($_POST['category']); if ($category_type->category_title == 'video' && isset($_POST['youtubelink']) && $_POST['youtubelink'] != '') { //item is a video $youtube_url = "https://i.ytimg.com/vi/" . $_POST['youtubelink'] . "/maxresdefault.jpg"; if (!file_exists($youtube_url)) { $youtube_url = "https://i.ytimg.com/vi/" . $_POST['youtubelink'] . "/hqdefault.jpg"; } //resize youtube image into uploads folder Upload::setName(time()); Upload::resizeUrl($youtube_url, UPLOAD_PATH, '480px'); $update_data = array('media_file' => Upload::getFileName('images')); $this->mediaModel->updateId($update_data, $media_id); } if ($_FILES["image"]["tmp_name"] != '' && $category_type->category_title == 'audio') { //resize youtube image into uploads folder Upload::setName(time()); Upload::upload_file($_FILES["image"], UPLOAD_PATH); $filepath = UPLOAD_PATH . Upload::getName(); $outputMp3 = UPLOAD_PATH . 'encoded_' . Upload::getName(); //check bitrate $bitRate = Audio::bitRateSampleRate($filepath, 'bitrate'); if ($bitRate > 128) { $convertMp3 = Audio::convertMp3($filepath, 128, $outputMp3); } if (is_file($outputMp3)) { $updateArray = array('media_file' => 'images/encoded_' . Upload::getName()); unlink($filepath); } else { $updateArray = array('media_file' => Upload::getFileName('images')); } $saveMp3 = $this->mediaModel->updateId($updateArray, $media_id); } //UPLOAD ATTACHMENT if ($_FILES["image"]["tmp_name"] != '' && $category_type->category_title == 'image') { //upload image into uploads folder Upload::setName(time()); Upload::resizeUpload($_FILES["image"], UPLOAD_PATH, '480px'); $update_data = array('media_file' => Upload::getFileName('images')); $update_img = $this->mediaModel->updateId($update_data, $media_id); if ($update_img > 0) { Session::set('success', 'record edited'); Url::redirect('album/media/' . $albumitem_detail->media_album_id); } else { if ($message == 'no') { $this->data['error'] = 'Operation Fails!'; } } } } if ($message == 'ok') { Session::set('success', 'record edited'); Url::redirect('album/media/' . $albumitem_detail->media_album_id); } else { if ($message == 'no') { $this->data['error'] = 'Operation Fails!'; } } $this->data['media'] = Media::row('media_id', $media_id); View::rendertemplate('header', $this->data); View::rendertemplate('sidebar', $this->data); View::render('album/album.edit_item', $this->data); View::rendertemplate('footer', $this->data); }