Annotation of /branches/mambo5/app/controllers/content_controller.php
Parent Directory
|
Revision Log
Revision 2 - (view) (download)
| 1 : | enjoyman | 2 | <?php |
| 2 : | /** | ||
| 3 : | * @package Mambo | ||
| 4 : | * @author Mambo Foundation Inc see README.php | ||
| 5 : | * @copyright (C) 2000 - 2009 Mambo Foundation Inc. | ||
| 6 : | * See COPYRIGHT.php for copyright notices and details. | ||
| 7 : | * @license GNU/GPL Version 2, see http://www.opensource.org/licenses/gpl-2.0.php | ||
| 8 : | * | ||
| 9 : | * Redistributions of files must retain the above copyright notice. | ||
| 10 : | * | ||
| 11 : | * Mambo is free software; you can redistribute it and/or | ||
| 12 : | * modify it under the terms of the GNU General Public License | ||
| 13 : | * as published by the Free Software Foundation; version 2 of the License. | ||
| 14 : | */ | ||
| 15 : | |||
| 16 : | /** | ||
| 17 : | * Handles content item management. Loads more to come... | ||
| 18 : | * | ||
| 19 : | */ | ||
| 20 : | |||
| 21 : | class ContentController extends AppController { | ||
| 22 : | |||
| 23 : | public $name = 'Content'; | ||
| 24 : | public $uses = array('Content', 'ContentTemplate'); | ||
| 25 : | public $components = array('Mostlyce'); | ||
| 26 : | public $helpers = array('Html', 'Form', 'Javascript', 'MamboHtml'); | ||
| 27 : | public $paginate = array('limit' => 5, 'page' => 1, 'order'=>array('created'=>'DESC')); | ||
| 28 : | |||
| 29 : | /** | ||
| 30 : | * Displays a list of content items that can be viewed | ||
| 31 : | * | ||
| 32 : | */ | ||
| 33 : | public function index() { | ||
| 34 : | $this->set('content_items', $this->paginate('Content')); | ||
| 35 : | $this->pageTitle = 'List of Content Items'; | ||
| 36 : | } | ||
| 37 : | |||
| 38 : | /** | ||
| 39 : | * Displays a list of content items that can be edited or removed | ||
| 40 : | * | ||
| 41 : | */ | ||
| 42 : | public function administrator_index() { | ||
| 43 : | $this->set('content_items', $this->paginate('Content')); | ||
| 44 : | $this->pageTitle = 'List of Content Items'; | ||
| 45 : | } | ||
| 46 : | |||
| 47 : | /** | ||
| 48 : | * Displays the title, intro text, and main body of the content item it was passed | ||
| 49 : | * @param int $id | ||
| 50 : | */ | ||
| 51 : | public function view($id = null) { | ||
| 52 : | |||
| 53 : | $requestedItem = $this->Content->read(null, $id); | ||
| 54 : | |||
| 55 : | //Include the data sanitation code | ||
| 56 : | uses('Sanitize'); | ||
| 57 : | $mrClean = new Sanitize(); | ||
| 58 : | //Scrub on the way out as well to prevent xss hacks | ||
| 59 : | $mrClean->clean($requestedItem); | ||
| 60 : | |||
| 61 : | $this->set('requested_item', $requestedItem); | ||
| 62 : | $this->pageTitle = $requestedItem['Content']['title']; | ||
| 63 : | |||
| 64 : | } | ||
| 65 : | |||
| 66 : | /** | ||
| 67 : | * Loads the selected content item for editing. Also builds a list of html templates for MOStlyCE. | ||
| 68 : | * @param int $id | ||
| 69 : | */ | ||
| 70 : | public function administrator_edit($id = null) { | ||
| 71 : | if(empty($this->data)) { | ||
| 72 : | if(!$id) { | ||
| 73 : | $this->Session->setFlash('Invalid content id'); | ||
| 74 : | $this->redirect('/content/index'); | ||
| 75 : | } | ||
| 76 : | $this->data = $this->Content->read(null, $id); | ||
| 77 : | //Build a list of html templates for MOStlyCE | ||
| 78 : | $this->set('tinymce_template_code', $this->Mostlyce->setContentTemplates()); | ||
| 79 : | } else { | ||
| 80 : | //Cleans up the date fields of the current model | ||
| 81 : | $this->cleanUpFields(); | ||
| 82 : | |||
| 83 : | //Include the data sanitation code | ||
| 84 : | uses('Sanitize'); | ||
| 85 : | $mrClean = new Sanitize(); | ||
| 86 : | $mrClean->clean($this->data); | ||
| 87 : | |||
| 88 : | if($this->Content->save($this->data)) { | ||
| 89 : | $this->Session->setFlash('The content item has been saved'); | ||
| 90 : | $this->redirect('/administrator/content/index'); | ||
| 91 : | } else { | ||
| 92 : | $this->Session->setFlash('Please correct errors below.'); | ||
| 93 : | } | ||
| 94 : | } | ||
| 95 : | } | ||
| 96 : | |||
| 97 : | /** | ||
| 98 : | * Deletes the passed content item | ||
| 99 : | * @param int $id | ||
| 100 : | */ | ||
| 101 : | public function administrator_delete($id = null) { | ||
| 102 : | if(!$id) { | ||
| 103 : | $this->Session->setFlash('Invalid content item!'); | ||
| 104 : | $this->redirect('/administrator/content/index'); | ||
| 105 : | } | ||
| 106 : | if($this->Content->del($id)) { | ||
| 107 : | $this->Session->setFlash('The content item deleted: id '.$id.''); | ||
| 108 : | $this->redirect('/administrator/content/index'); | ||
| 109 : | } | ||
| 110 : | } | ||
| 111 : | |||
| 112 : | } | ||
| 113 : | ?> |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |
Web Hosting provided by Network Redux.

