public function add($parameter) { $category_slug = $parameter[0]; $this->data['title'] = 'Add Post'; $category_model = new Category(); $post_model = new \Models\Post(); $album_model = new Album(); $this->data['album_group'] = $album_model->all(); $this->data['post_category'] = $category_model->getCol('category_slug', $category_slug); // var_dump(count($this->data['post_category'])); if (isset($_POST) && !empty($_POST)) { $post_user_id = Session::get('user_id'); $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_created = time(); $post_array = array('post_user_id' => $post_user_id, '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_created' => $post_created); // $insert_array = Gump::xss_clean($insert_array); // $insert_array = Gump::sanitize($insert_array); $post_id = $post_model->create($post_array); //UPLOAD IMAGE if ($_FILES["image"]["tmp_name"] != '') { Upload::setName(uniqid()); Upload::upload_file($_FILES["image"], UPLOAD_PATH); $update_data = array('post_image' => Upload::getFileName('images')); $update = $post_model->updateId($update_data, $post_id); } if ($insert_post_id > 0) { Session::set('success', 'post added'); 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); }