Skip to content

Commit

Permalink
Rather annoying commit that needs to be made because it won't let me …
Browse files Browse the repository at this point in the history
…update!
  • Loading branch information
flikQ committed Apr 15, 2013
1 parent bca800d commit ef5ba09
Show file tree
Hide file tree
Showing 77 changed files with 24,244 additions and 51 deletions.
19 changes: 0 additions & 19 deletions README.markdown

This file was deleted.

2 changes: 0 additions & 2 deletions README.md

This file was deleted.

13 changes: 13 additions & 0 deletions application/config/new_routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@
// Pages
'page' => array(':page', 'pages/show/title/$1'),
'sub_page' => array(':page/:sub_page', 'pages/show/title/$2'),

// Forums
'forums' => array('forums', 'forums/index'),
'forum_threads' => array('forums/:name/page/:page', 'forums/show_threads/name/$1/page/$2'),
'new_forum_thread' => array('forums/:name/new', 'forums/new_thread/name/$1'),
'create_forum_thread' => array('forums/:name/create', 'forums/create_thread/name/$1'),
'forum_thread' => array('forums/:name/:id/:title/page/:page', 'forums/show_thread/name/$1/title/$3/id/$2/page/$4'),
'edit_forum_thread' => array('forums/:name/:id/:title/edit', 'forums/edit_thread/name/$1/title/$3/id/$2'),
'update_forum_thread' => array('forums/:name/:id/:title/update', 'forums/update_thread/name/$1/title/$3/id/$2'),
'new_forum_post' => array('forums/:name/:id/:title/new', 'forums/new_post/name/$1/title/$3/id/$2'),
'create_forum_post' => array('forums/:name/:id/:title/create', 'forums/create_post/name/$1/title/$3/id/$2'),
'edit_forum_post' => array('forums/:name/:id/:title/:post_id/edit', 'forums/edit_post/name/$1/title/$2/id/$3/post_id/$4'),
'update_forum_post' => array('forums/:name/:id/:title/:post_id/update', 'forums/update_post/name/$1/title/$2/id/$3/post_id/$4'),

);

Expand Down
82 changes: 82 additions & 0 deletions application/controllers/admin/forum_posts.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php

class Forum_Posts extends Admin_Controller {

public function __construct() {
parent::__construct();
}

public function index() {
$post = new Forum_Post;
$base_url = '/admin/forum_posts/index/';
$total_rows = $post->count();
$this->load->library('pagination');
$this->pagination->initialize(array(
'total_rows' => $total_rows,
'base_url' => $base_url.'page/',
'per_page' => 20,
'uri_segment' => 'page',
'full_tag_open' => '<ul>',
'full_tag_close' => '</ul>',
'first_link' => '',
'last_link' => '',
'previous_link' => '',
'next_link' => '',
'cur_tag_open' => '<li class="active">',
'cur_tag_close' => '</li>',
'num_tag_open' => '<li>',
'num_tag_close' => '</li>'
));
$this->load->view('forum_posts/index', array(
'posts' => $post->limit(20)->offset((int) param('page'))->get(),
'pagination' => $this->pagination->create_links()
));
}

public function remove() {
$id = param('id');
if(! $id) {
show_404();
}
$post = new Forum_Post($id);
if(! $post->exists()) {
show_404();
}
$post->remove();
redirect('admin/forum_posts/index');
}

public function edit() {
$id = param('id');
if(! $id) {
show_404();
}
$post = new Forum_Post($id);
if(! $post->exists()) {
show_404();
}
$this->layout->js = array('jquery-1.5.1.min', 'tiny_mce/jquery.tinymce', 'init-tinymce');
$this->load->view('forum_posts/edit', array(
'post' => $post
));
}

public function update() {
$id = $this->input->post('id');
if(! $id) {
show_error('Undefined Post ID');
}
$post = new Forum_Post($id);
if(! $post->exists()) {
show_404();
}
$post->content = $this->input->post('content');
if($post->save() == FALSE) {
flash('errors', $post->errors);
redirect('admin/forum_posts/edit/id/'.$post->id);
return;
}
redirect('admin/forum_posts/index');
}

}
125 changes: 125 additions & 0 deletions application/controllers/admin/forum_sections.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<?php

class Forum_Sections extends Admin_Controller {

public function __construct() {
parent::__construct();
}

public function index()
{
// Handle saving a new order
if($this->input->is_ajax_request())
{
$order = $this->input->post('order');
$order = explode('&', $order);
$new_order = array();

foreach($order as $item)
{
$item = explode('=', $item);
$new_order[] = (int)$item[1];
}

// Now update the forum table
foreach($new_order as $order => $id)
{
$this->db->where('id', $id);
$this->db->update('forum_sections', array(
'order' => ($order+1)
));
}

// Output JSON
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Content-type: application/json');
echo json_encode(array('success' => true));
// echo json_encode(array('error' => 'There was a problem saving the order'));
exit;
}

// Forum sections
$section = new Forum_Section;

// Load assets
$this->layout->js = array('jquery-ui-1.8.min');

// Load view
$this->load->view('forum_sections/index', array(
'sections' => $section->order_by('order', 'asc')->get()
));
}

public function add() {
$section = new Forum_Section;
$sections = array();
foreach($section->get() as $item) {
$sections[$item->id] = $item->name;
}
$this->layout->js = array('jquery-1.5.1.min', 'tiny_mce/jquery.tinymce', 'init-tinymce');
$this->load->view('forum_sections/add', array(
'sections' => $sections
));
}

public function create() {
$section = new Forum_Section;
$section->name = $this->input->post('name');
$section->description = $this->input->post('description');
$section->private = $this->input->post('private');
if($section->save() == FALSE) {
flash('errors', $section->errors);
redirect('admin/forum_sections/add');
return;
}
redirect('admin/forum_sections/index');
}

public function edit() {
$id = param('id');
if(! $id) {
show_404();
}
$section = new Forum_Section($id);
if(! $section->exists()) {
show_404();
}
$this->layout->js = array('jquery-1.5.1.min', 'tiny_mce/jquery.tinymce', 'init-tinymce');
$this->load->view('forum_sections/edit', array(
'section' => $section,
));
}

public function update() {
$id = $this->input->post('id');
if(! $id) {
show_error('Unknown Forum_Section Section ID');
}
$section = new Forum_Section($id);
if(! $section->exists()) {
show_404();
}
$section->name = $this->input->post('name');
$section->description = $this->input->post('description');
$section->private = $this->input->post('private');
if($section->save() == FALSE) {
flash('errors', $section->errors);
}
redirect('admin/forum_sections/index');
}

public function remove() {
$id = param('id');
if(! $id) {
show_404();
}
$section = new Forum_Section($id);
if(! $section->exists()) {
show_404();
}
$section->remove();
redirect('admin/forum_sections/index');
}

}
94 changes: 94 additions & 0 deletions application/controllers/admin/forum_threads.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php

class Forum_Threads extends Admin_Controller {

public function __construct() {
parent::__construct();
}

public function index() {
$thread = new Forum_Thread;
$base_url = '/admin/forum_threads/index/';
$total_rows = $thread->count();
$this->load->library('pagination');
$this->pagination->initialize(array(
'total_rows' => $total_rows,
'base_url' => $base_url.'page/',
'per_page' => 20,
'uri_segment' => 'page',
'full_tag_open' => '<ul>',
'full_tag_close' => '</ul>',
'first_link' => '',
'last_link' => '',
'previous_link' => '',
'next_link' => '',
'cur_tag_open' => '<li class="active">',
'cur_tag_close' => '</li>',
'num_tag_open' => '<li>',
'num_tag_close' => '</li>'
));
$this->load->view('forum_threads/index', array(
'threads' => $thread->limit(20)->offset((int) param('page'))->get(),
'pagination' => $this->pagination->create_links()
));
}

public function remove() {
$id = param('id');
if(! $id) {
show_404();
}
$thread = new Forum_Thread($id);
if(! $thread->exists()) {
show_404();
}
$thread->remove();

$this->db->where('thread_id', $thread->id);
$this->db->delete('forum_posts');

redirect('admin/forum_threads/index');
}

public function edit() {
$id = param('id');
if(! $id) {
show_404();
}
$thread = new Forum_Thread($id);
if(! $thread->exists()) {
show_404();
}

$post = new Forum_Post();
$post->where('thread_id', $thread->id)->order_by('created_at', 'asc');
$posts = $post->get();

$this->layout->js = array('jquery-1.5.1.min', 'tiny_mce/jquery.tinymce', 'init-tinymce');
$this->load->view('forum_threads/edit', array(
'thread' => $thread,
'posts' => $posts
));
}

public function update() {
$id = $this->input->post('id');
if(! $id) {
show_error('Undefined Thread ID');
}
$thread = new Forum_Thread($id);
if(! $thread->exists()) {
show_404();
}

$thread->title = $this->input->post('title');

if($thread->save() == FALSE) {
flash('errors', $thread->errors);
redirect('admin/forum_threads/edit/id/'.$thread->id);
return;
}
redirect('admin/forum_threads/index');
}

}
Loading

0 comments on commit ef5ba09

Please sign in to comment.