public function edit($id) { self::auth(); $page = WY_Db::row('SELECT * FROM wy_pages WHERE page_id = :id', array(':id' => (int) $id)); if (!$page) { $view = new WY_View('404'); $view->render(); exit; } $isParent = WY_Db::all('SELECT * FROM wy_pages WHERE is_parent = 0 AND page_id <> :id', array(':id' => (int) $id)); $plugins = WY_Db::all("SELECT * FROM `wy_plugins` WHERE `is_active` = 1 ORDER BY plugin_name ASC"); if (WY_Request::isPost()) { $title = $_POST['title']; if (isset($_POST['published'])) { $published = 1; } else { $published = 0; } if (isset($_POST['a_comment'])) { $comment = 1; } else { $comment = 0; } $isParent = $_POST['isParent']; $content = $_POST['content']; $tags = $_POST['tags']; $permalink = strtolower(str_replace(' ', '-', $title)); WY_Db::execute('UPDATE wy_pages SET title = :title, date_modified = NOW(), content = :content, published = :published, is_parent= :is_parent, permalink = :permalink, comment_open = :comment_open, tag = :taglist WHERE page_id = :id', array(':title' => $title, ':published' => $published, ':content' => $content, ':is_parent' => $isParent, ':comment_open' => $comment, ':permalink' => $permalink, ':taglist' => $tags, ':id' => (int) $id)); WY_Response::redirect('admin/pages/all'); } $this->layout->pageTitle = 'Wayang CMS - Pages Edit'; $this->layout->content = WY_View::fetch('admin/pages/edit', array('page' => $page, 'isParent' => $isParent, 'plugins' => $plugins)); }
public function edit($id) { self::auth(); $user = WY_Db::row('SELECT * FROM `wy_users` WHERE `user_id` = :id', array(':id' => (int) $id)); if (!$user) { $view = new WY_View('404'); $view->render(); exit; } if (WY_Request::isPost()) { $username = $_POST['username']; $email = $_POST['email']; $display = $_POST['display']; $url = $_POST['url']; $level = $_POST['level']; if (isset($_POST['password']) && $_POST['password'] === "") { $sql = "UPDATE `wy_users` SET `username`=:username,`email`=:email,`display_name`=:display,`url`=:url,`status`=:level WHERE `user_id`=:id"; WY_Db::execute($sql, array(':username' => $username, ':email' => $email, ':display' => $display, ':url' => $url, ':level' => $level, ':id' => (int) $id)); } else { $password = $_POST['password']; $sql = "UPDATE `wy_users` SET `username`=:username,`pass`=:password,`email`=:email,`display_name`=:display,`url`=:url,`status`=:level WHERE `user_id`=:id"; WY_Db::execute($sql, array(':username' => $username, ':password' => sha1($password . WY_Config::get('salt')), ':email' => $email, ':display' => $display, ':url' => $url, ':level' => $level, ':id' => (int) $id)); } WY_Response::redirect('admin/users/all'); } $this->layout->pageTitle = 'Wayang CMS - Edit User'; $this->layout->content = WY_View::fetch('admin/users/edit', array('user' => $user)); }
public function edit($id) { self::auth(); $category = WY_Db::row('SELECT * FROM wy_categories WHERE cat_id = :id', array(':id' => (int) $id)); if (!$category) { $view = new WY_View('404'); $view->render(); exit; } if (WY_Request::isPost()) { $title = $_POST['title']; $published = $_POST['published']; $permalink = strtolower(str_replace(' ', '-', $title)); WY_Db::execute('UPDATE wy_categories SET title = :title, date_modified = NOW(), published = :published, permalink = :permalink WHERE cat_id = :id', array(':title' => $title, ':published' => $published, ':permalink' => $permalink, ':id' => (int) $id)); WY_Response::redirect('admin/categories/all'); } $this->layout->pageTitle = 'Wayang CMS - Edit Category'; $this->layout->content = WY_View::fetch('admin/categories/edit', array('category' => $category)); }
public function edit($id) { self::auth(); $comment = WY_Db::row('SELECT * FROM wy_comments WHERE c_id = :id', array(':id' => (int) $id)); if (!$comment) { $view = new WY_View('404'); $view->render(); exit; } if (WY_Request::isPost()) { $name = $_POST['name']; $email = $_POST['email']; $url = $_POST['url']; $content = $_POST['content']; WY_Db::execute('UPDATE `wy_comments` SET `name`=:name,`email`=:email,`url`=:url,`content`=:content WHERE `c_id` = :id', array(':name' => $name, ':email' => $email, ':url' => $url, ':content' => $content, ':id' => (int) $id)); WY_Response::redirect('admin/comments/all'); } $this->layout->pageTitle = 'Wayang CMS - Edit Comment'; $this->layout->content = WY_View::fetch('admin/comments/edit', array('comment' => $comment)); }
public function edit($id) { self::auth(); $post = WY_Db::row('SELECT * FROM wy_posts WHERE post_id = :id', array(':id' => (int) $id)); if (!$post) { $view = new WY_View('404'); $view->render(); exit; } $cat = WY_Db::all('SELECT * FROM wy_categories'); if (WY_Request::isPost()) { $title = $_POST['title']; if (isset($_POST['published'])) { $published = 1; } else { $published = 0; } if (isset($_POST['a_comment'])) { $comment = 1; } else { $comment = 0; } if ($_POST['permalink'] === "") { $permalink = strtolower(str_replace(' ', '-', $_POST['title'])); } else { $permalink = strtolower(str_replace(' ', '-', $_POST['permalink'])); } $content = $_POST['content']; $tags = $_POST['tags']; $cat_id = $_POST['category']; WY_Db::execute('UPDATE `wy_posts` SET' . '`cat_id` = :cat_id, `title` = :title, `tag` = :tag, `content` = :content, `comment_open` = :comment_open, `permalink` = :permalink, `published` = :published, `date_modified` = NOW() WHERE post_id = :id', array(':cat_id' => $cat_id, ':title' => $title, ':tag' => $tags, ':content' => $content, ':comment_open' => $comment, ':permalink' => $permalink, ':published' => $published, ':id' => (int) $id)); WY_Response::redirect('admin/posts/all'); } $this->layout->pageTitle = 'Wayang CMS - Pages Edit'; $this->layout->content = WY_View::fetch('admin/posts/edit', array('post' => $post, 'cat' => $cat)); }