1 <?php
defined('IN_CMS') or die('No direct access allowed.');
3 class Pages_controller
{
5 public function __construct() {
6 $this->admin_url
= Config
::get('application.admin_folder');
9 public function index() {
10 $pages = Pages
::list_all();
11 Template
::render('pages/index', array('pages' => $pages));
14 public function add() {
15 if(Input
::method() == 'POST') {
17 return Response
::redirect($this->admin_url
. '/pages/edit/' . Db
::insert_id());
20 Template
::render('pages/add');
23 public function edit($id) {
25 if(($page = Pages
::find(array('id' => $id))) === false) {
26 return Response
::redirect($this->admin_url
. '/pages');
29 // process post request
30 if(Input
::method() == 'POST') {
31 if(Pages
::update($id)) {
33 return Response
::redirect($this->admin_url
. '/pages/edit/' . $id);
37 Template
::render('pages/edit', array('page' => $page));