Beispiel #1
0
 public function action_editsongs()
 {
     $link_id = $this->request->param('id');
     $this->template->show_logout = TRUE;
     $this->template->title = 'Song::Edit';
     $song = Model_Links::getLinkById($link_id);
     $view = $this->template->content = View::factory('dashboard/songs/edit')->set('song', $song);
     if ($this->request->method() == Request::POST) {
         if (isset($_FILES['image_name'])) {
             $folderName = $_POST['catalog_id'];
             $filename = $this->_save_image($_FILES['image_name'], $folderName);
         }
         //
         $linkArr = array('url' => $_POST['url'], 'title' => $_POST['title'], 'source_id' => $_POST['source_id'], 'catalog_id' => $_POST['catalog_id'], 'language_id' => $_POST['language_id'], 'user_id' => Auth::instance()->get_user()->id, 'agegroup_id' => $_POST['agegroup_id'], 'date_added' => time(), 'is_public' => $_POST['is_public']);
         //
         if (isset($_FILES['image_name']['name']) && !empty($_FILES['image_name']['name'])) {
             $linkArr['image_name'] = $_FILES['image_name']['name'];
         }
         //
         Model_Links::editLink($linkArr, $_POST['link_id']);
         if (!$filename) {
             $error_message = 'There was a problem while uploading the image.
                     Make sure it is uploaded and must be JPG/PNG/GIF file.';
         }
         if ($_POST['link_id']) {
             $this->redirect('dashboard/editsongs/' . $_POST['link_id']);
         }
     }
     $view->uploaded_file = isset($filename) ? $filename : $song[0]['image_name'];
     $view->error_message = isset($error_message) ? $error_message : '';
     $this->response->body($view);
 }