Example #1
0
 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);
 }
Example #2
0
 /**
  * @param text $statusName
  */
 public function getList($statusName)
 {
     if (!$this->application->request->isGet()) {
         throw new Exception('Method not allowed', 405);
     }
     $statuses = Status::find();
     $statusesArr = $statuses->toArray('name');
     if (!in_array($statusName, $statusesArr)) {
         throw new Exception('Invalid paremeter', 409);
     }
     $status = Status::findFirst(array('conditions' => 'name = :name:', 'bind' => array('name' => $statusName)));
     $songs = Song::find(array('conditions' => 'status_id = :id:', 'bind' => array('id' => $status->getId()), 'order' => 'number ASC', 'group' => 'production_id'));
     if (!$songs) {
         throw new Exception('Query not executed', 500);
     }
     if ($songs->count() == 0) {
         return array('code' => 204, 'content' => 'No matching Song instance found');
     }
     return array('code' => 200, 'content' => $songs->toArray());
 }
Example #3
0
    ?>
</td>
									<td class="center"><?php 
    echo $item->album_description;
    ?>
</td>
									<td class="center"><?php 
    echo Assets::image($item->album_image, '', 'width: 120px');
    ?>
</td>
									<td class="center"><?php 
    echo $item->album_slug;
    ?>
</td>
									<td class="center"><?php 
    echo Song::itemCount($item->album_id);
    ?>
</td>
									<td class="center"><?php 
    echo date('d/m/Y', $item->album_created);
    ?>
</td>
									<td class="center"><span class="label label-success">Active</span></td> 
									<td class="center">
									<div class="btn-group">
							<button class="btn btn-small">Option</button>
							<button class="btn btn-small dropdown-toggle" data-toggle="dropdown">
							<span class="caret"></span></button>
							<ul class="dropdown-menu">
								<li><a href="<?php 
    echo DIR . 'song/editalbum/' . $item->album_id;
 /**
  * @param integer $productionId
  */
 public function getSongs($productionId)
 {
     if (!$this->application->request->isGet()) {
         throw new Exception('Method not allowed', 405);
     }
     $production = Production::findFirst($productionId);
     if (!$production) {
         throw new Exception('Production instance not found', 404);
     }
     $songs = Song::find(array('conditions' => 'production_id = :pId:', 'bind' => array('pId' => $productionId), 'order' => 'number ASC'));
     if (!$songs) {
         throw new Exception('Query not executed', 500);
     }
     if ($songs->count() == 0) {
         return array('code' => 204, 'content' => 'No Song instance found for this Production instance');
     }
     return array('code' => 200, 'content' => $songs->toArray());
 }