Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit 823be4e28eb3797481c36b7d1a4692590bc6f400 @neilcrookes committed May 17, 2011
@@ -0,0 +1,105 @@
+<?php
+/**
+ * BlogPostCategories Controller
+ *
+ * Pretty much just baked admin actions except add/edit use generateTreeList()
+ * for finding the parents so you see the hierarchy.
+ *
+ * @author Neil Crookes <neil@crook.es>
+ * @link http://www.neilcrookes.com http://neil.crook.es
+ * @copyright (c) 2011 Neil Crookes
+ * @license MIT License - http://www.opensource.org/licenses/mit-license.php *
+ */
+class BlogPostCategoriesController extends AppController {
+
+
+/**
+ * index method
+ *
+ * @return void
+ */
+ public function admin_index() {
+ $this->BlogPostCategory->recursive = 0;
+ $this->set('blogPostCategories', $this->paginate());
+ }
+
+/**
+ * view method
+ *
+ * @param string $id
+ * @return void
+ */
+ public function admin_view($id = null) {
+ $this->BlogPostCategory->id = $id;
+ if (!$this->BlogPostCategory->exists()) {
+ throw new NotFoundException(__('Invalid blog post category'));
+ }
+ $this->set('blogPostCategory', $this->BlogPostCategory->read(null, $id));
+ }
+
+/**
+ * add method
+ *
+ * @return void
+ */
+ public function admin_add() {
+ if ($this->request->is('post')) {
+ $this->BlogPostCategory->create();
+ if ($this->BlogPostCategory->save($this->request->data)) {
+ $this->Session->setFlash(__('The blog post category has been saved'));
+ $this->redirect(array('action' => 'index'));
+ } else {
+ $this->Session->setFlash(__('The blog post category could not be saved. Please, try again.'));
+ }
+ }
+ $parents = $this->BlogPostCategory->generateTreeList();
+ $this->set(compact('parents'));
+ }
+
+/**
+ * edit method
+ *
+ * @param string $id
+ * @return void
+ */
+ public function admin_edit($id = null) {
+ $this->BlogPostCategory->id = $id;
+ if (!$this->BlogPostCategory->exists()) {
+ throw new NotFoundException(__('Invalid blog post category'));
+ }
+ if ($this->request->is('post') || $this->request->is('put')) {
+ if ($this->BlogPostCategory->save($this->request->data)) {
+ $this->Session->setFlash(__('The blog post category has been saved'));
+ $this->redirect(array('action' => 'index'));
+ } else {
+ $this->Session->setFlash(__('The blog post category could not be saved. Please, try again.'));
+ }
+ } else {
+ $this->request->data = $this->BlogPostCategory->read(null, $id);
+ }
+ $parents = $this->BlogPostCategory->generateTreeList();
+ $this->set(compact('parents'));
+ }
+
+/**
+ * delete method
+ *
+ * @param string $id
+ * @return void
+ */
+ public function admin_delete($id = null) {
+ if (!$this->request->is('post')) {
+ throw new MethodNotAllowedException();
+ }
+ $this->BlogPostCategory->id = $id;
+ if (!$this->BlogPostCategory->exists()) {
+ throw new NotFoundException(__('Invalid blog post category'));
+ }
+ if ($this->BlogPostCategory->delete()) {
+ $this->Session->setFlash(__('Blog post category deleted'));
+ $this->redirect(array('action'=>'index'));
+ }
+ $this->Session->setFlash(__('Blog post category was not deleted'));
+ $this->redirect(array('action' => 'index'));
+ }
+}
@@ -0,0 +1,100 @@
+<?php
+/**
+ * BlogPostTags Controller
+ *
+ * Just contains baked admin actions
+ *
+ * @author Neil Crookes <neil@crook.es>
+ * @link http://www.neilcrookes.com http://neil.crook.es
+ * @copyright (c) 2011 Neil Crookes
+ * @license MIT License - http://www.opensource.org/licenses/mit-license.php
+ */
+class BlogPostTagsController extends AppController {
+
+
+/**
+ * index method
+ *
+ * @return void
+ */
+ public function admin_index() {
+ $this->BlogPostTag->recursive = 0;
+ $this->set('blogPostTags', $this->paginate());
+ }
+
+/**
+ * view method
+ *
+ * @param string $id
+ * @return void
+ */
+ public function admin_view($id = null) {
+ $this->BlogPostTag->id = $id;
+ if (!$this->BlogPostTag->exists()) {
+ throw new NotFoundException(__('Invalid blog post tag'));
+ }
+ $this->set('blogPostTag', $this->BlogPostTag->read(null, $id));
+ }
+
+/**
+ * add method
+ *
+ * @return void
+ */
+ public function admin_add() {
+ if ($this->request->is('post')) {
+ $this->BlogPostTag->create();
+ if ($this->BlogPostTag->save($this->request->data)) {
+ $this->Session->setFlash(__('The blog post tag has been saved'));
+ $this->redirect(array('action' => 'index'));
+ } else {
+ $this->Session->setFlash(__('The blog post tag could not be saved. Please, try again.'));
+ }
+ }
+ }
+
+/**
+ * edit method
+ *
+ * @param string $id
+ * @return void
+ */
+ public function admin_edit($id = null) {
+ $this->BlogPostTag->id = $id;
+ if (!$this->BlogPostTag->exists()) {
+ throw new NotFoundException(__('Invalid blog post tag'));
+ }
+ if ($this->request->is('post') || $this->request->is('put')) {
+ if ($this->BlogPostTag->save($this->request->data)) {
+ $this->Session->setFlash(__('The blog post tag has been saved'));
+ $this->redirect(array('action' => 'index'));
+ } else {
+ $this->Session->setFlash(__('The blog post tag could not be saved. Please, try again.'));
+ }
+ } else {
+ $this->request->data = $this->BlogPostTag->read(null, $id);
+ }
+ }
+
+/**
+ * delete method
+ *
+ * @param string $id
+ * @return void
+ */
+ public function admin_delete($id = null) {
+ if (!$this->request->is('post')) {
+ throw new MethodNotAllowedException();
+ }
+ $this->BlogPostTag->id = $id;
+ if (!$this->BlogPostTag->exists()) {
+ throw new NotFoundException(__('Invalid blog post tag'));
+ }
+ if ($this->BlogPostTag->delete()) {
+ $this->Session->setFlash(__('Blog post tag deleted'));
+ $this->redirect(array('action'=>'index'));
+ }
+ $this->Session->setFlash(__('Blog post tag was not deleted'));
+ $this->redirect(array('action' => 'index'));
+ }
+}
Oops, something went wrong.

0 comments on commit 823be4e

Please sign in to comment.