public function edit($parameter) { $item_id = $parameter[0]; $this->data['title'] = 'Edit Post'; $category_model = new \Models\Category(); $post_model = new \Models\Post(); $album_model = new \models\album(); $this->data['post'] = $post_model->getItem($item_id); $this->data['album_group'] = $album_model->all(); $this->data['post_category_groups'] = $category_model->groupByCol('category_slug'); if (isset($_POST) && !empty($_POST)) { $post_category_id = $_POST['post_category_id']; $post_album_id = $_POST['post_album_id']; $post_title = $_POST['post_title']; $post_body = $_POST['post_body']; $post_link = $_POST['post_link']; $post_excerpt = $_POST['post_excerpt']; $post_slug = Url::generateSafeSlug($post_title); $post_modified = time(); $update_array = array('post_category_id' => $post_category_id, 'post_album_id' => $post_album_id, 'post_title' => $post_title, 'post_body' => $post_body, 'post_link' => $post_link, 'post_excerpt' => $post_excerpt, 'post_slug' => $post_slug, 'post_modified' => $post_modified); $update_array = Gump::xss_clean($update_array); $update_array = Gump::sanitize($update_array); $update_id = $post_model->updateId($update_array, $item_id); //UPLOAD IMAGE if ($_FILES["image"]["tmp_name"] != '') { Upload::setName(uniqid()); Upload::upload_file($_FILES["image"], UPLOAD_PATH); $image_name = Upload::getFileName('images'); $update_data = array('post_image' => $image_name); $update = $post_model->updateId($update_data, $update_id); } if ($update_id > 0) { Session::set('success', 'post edited'); Url::redirect('post'); } } View::rendertemplate('header', $this->data); View::rendertemplate('sidebar', $this->data); View::render('post/post.add', $this->data); View::rendertemplate('footer', $this->data); }