PHP File Manager
Editing File: Content.php
<?php /* * Copyright (C) Wayne Purton-Smith - All Rights Reserved * Unauthorized copying of this file or removing this paragraph, via any medium is strictly prohibited * Proprietary and confidential * Written by Wayne Purton-Smith <waynepurtonsmith@hotmail.co.uk> February 2014 */ class Content extends CI_Controller { function __construct() { parent::__construct(); $this->load->model('pages'); $this->users->denyRestricted('content'); } public function index() { if($this->input->post('get_pages')) { if(($parent_id = (int) $this->input->post('parent_id')) > 0) { $pages = $this->pages->get(NULL, NULL, $parent_id, array('only_visible' => false), -1); foreach($pages as &$page_info) { $page_info->date_created_text = date('jS M Y - H:i', $page_info->date_created); $page_info->last_updated_text = ($page_info->last_updated) ? date('jS M Y - H:i', $page_info->last_updated) : NULL; $page_info->url_link = SYSTEM_DEFAULT_HOST . $page_info->url; $page_info->depth = $this->pages->getPageDepth($page_info->page_id); } exit_with_json(array('success' => !empty($pages), 'pages' => $pages)); } exit_with_json(array('success' => false)); } if($this->input->post('move_page')) { exit_with_json(array('success' => $this->pages->changePageOrder($this->input->post('page'), $this->input->post('dir')))); } $head_data['page_title'] = 'Pages'; $this->load->view('header', $head_data); $data['pages'] = $this->pages->get(NULL, NULL, NULL, array('only_visible' => false, 'only_top_level' => true), -1); $this->load->view('pages/overview', $data); $this->load->view('footer'); } public function edit($mode = NULL) { if(($page_id = (int) $mode) > 0 && !($page_info = $this->pages->get($page_id, NULL, NULL, array('only_visible' => false)))) { redirect('/pages'); exit; } if($this->input->post('save_page')) { if(!$this->pages->save($this->input->post(), $page_id)) { $this->common->keepPostData(); $this->common->keepResponseMessage(); redirect($this->agent->referrer()); exit; } else { $this->common->keepResponseMessage(); redirect('/pages'); exit; } } $this->common->getPostData(); $head_data['page_title'] = ((isset($page_info->title)) ? 'Edit ' . input_value('"' . $page_info->title . '"') : 'New page') . ' - Pages'; $this->load->view('header', $head_data); $data['page_info'] = (isset($page_info)) ? $page_info : NULL; $this->load->view('pages/edit', $data); $this->load->view('footer'); } public function blocks($mode = NULL, $sub_mode = NULL) { if($mode == 'edit') { if(is_numeric($sub_mode) && !(($block_id = (int) $sub_mode) > 0 && ($block_info = $this->pages->getContentBlocks($block_id)))) { redirect('/pages/blocks'); exit; } if($this->input->post('save_block')) { $save_response = $this->pages->saveContentBlock($this->input->post(), (isset($block_id)) ? $block_id : NULL); $this->common->keepResponseMessage(); if(!$save_response) { $this->common->keepPostData(); } redirect($this->agent->referrer()); exit; } $head_data['page_title'] = ((isset($block_info->block_id)) ? ' Edit ' . input_value($block_info->name) : ' Create new block'); $data['block_info'] = (isset($block_info)) ? $block_info : NULL; $template_name = 'edit-block'; } else { $head_data['page_title'] = 'Content blocks'; $data['all_blocks'] = $this->pages->getContentBlocks(); $template_name = 'overview-blocks'; } $this->load->view('header', $head_data); $this->load->view('pages/' . $template_name, $data); $this->load->view('footer'); } public function preview() { $head_data['page_title'] = input_value($this->input->post('page_title')); $this->load->view('website/header', $head_data); $data['page_content'] = $this->input->post('page_content'); $this->load->view('website/pages/content', $data); $this->load->view('website/footer'); } public function delete($mode = NULL) { $this->pages->delete($mode); redirect('/pages'); } }
Cancel