function list_action() { $postsModel = new PostsModel(); $posts = $postsModel->get_all_posts(); $html = render_template('view/template/list.php', array('posts' => $posts)); return $html; //require "view/template/list.php"; }
function delete_action($id) { $postsModel = new PostsModel(); $postsModel->delete_post($id); $posts = $postsModel->get_all_posts(); $html = render_template('view/template/admin.php', array('posts' => $posts)); return $html; }
function edit_action($id) { $model = new PostsModel(); /*$post = get_post($id);*/ $post = $model->get_post_by_id($id); $html = render_template('View/Templates/edit.php', array('post' => $post)); if (isset($_POST['edit_post'])) { $model->update($id); header("location: ../index.php/show?id=" . $id); } return $html; }
/** * @return object */ public function getAuthor() { if (!$this->checkProperty('author')) { if (!$this->getId_author()) { $Register = Register::getInstance(); $this->author = $Register['ModManager']->getEntityInstance('users'); } else { $Model = new PostsModel('posts'); $this->author = $Model->getById($this->getId_author()); // TODO (function is not exists) } } return $this->author; }
function delete_action($id) { $postsModel = new PostsModel(); $postsModel->delete_post($id); $posts = $postsModel->get_all_posts(); $html = render_template("View/Templates/admin.php", array('posts' => $posts)); return $html; /*function delete_action($id) { delete_post($id); $posts = get_all_posts(); $html=render_template("View/Templates/admin.php",array('posts'=>$posts)); return $html; }*/ }
public static function getList() { if (PostsModel::isModified()) { self::updateCounts(); } $col = Collection::Query(self::TABLE)->Select(self::SLUG, self::NAME, self::POST_COUNT)->orderBy(self::NAME)->limit(20); $list = array(); foreach ($col->getValues() as $row) { $list[] = $row; } return $list; }