5, 'page' => 1, 'order'=>array('created'=>'DESC')); /** * Displays a list of content items that can be viewed * */ public function index() { $this->set('content_items', $this->paginate('Content')); $this->pageTitle = 'List of Content Items'; } /** * Displays a list of content items that can be edited or removed * */ public function administrator_index() { $this->set('content_items', $this->paginate('Content')); $this->pageTitle = 'List of Content Items'; } /** * Displays the title, intro text, and main body of the content item it was passed * @param int $id */ public function view($id = null) { $requestedItem = $this->Content->read(null, $id); //Include the data sanitation code uses('Sanitize'); $mrClean = new Sanitize(); //Scrub on the way out as well to prevent xss hacks $mrClean->clean($requestedItem); $this->set('requested_item', $requestedItem); $this->pageTitle = $requestedItem['Content']['title']; } /** * Loads the selected content item for editing. Also builds a list of html templates for MOStlyCE. * @param int $id */ public function administrator_edit($id = null) { if(empty($this->data)) { if(!$id) { $this->Session->setFlash('Invalid content id'); $this->redirect('/content/index'); } $this->data = $this->Content->read(null, $id); //Build a list of html templates for MOStlyCE $this->set('tinymce_template_code', $this->Mostlyce->setContentTemplates()); } else { //Cleans up the date fields of the current model $this->cleanUpFields(); //Include the data sanitation code uses('Sanitize'); $mrClean = new Sanitize(); $mrClean->clean($this->data); if($this->Content->save($this->data)) { $this->Session->setFlash('The content item has been saved'); $this->redirect('/administrator/content/index'); } else { $this->Session->setFlash('Please correct errors below.'); } } } /** * Deletes the passed content item * @param int $id */ public function administrator_delete($id = null) { if(!$id) { $this->Session->setFlash('Invalid content item!'); $this->redirect('/administrator/content/index'); } if($this->Content->del($id)) { $this->Session->setFlash('The content item deleted: id '.$id.''); $this->redirect('/administrator/content/index'); } } } ?>