The user was too lazy to give a description
<?php class NewsController extends AppController { var $name = 'News'; /* Hauptausgabe */ function index() { /* News aus der Datenbank raussuchen */ $news = $this -> News -> find('all', array( 'order' => 'id', 'direction' => 'desc', 'limit' => '10' )); /* Inhalt in die Templatevariable news übergeben */ $this -> set('news', $news); } /* Ausgabe der News nach ID sowie der Kommentare */ function comments($id) { /* News von der entsprechenden ID selecten */ $news = $this -> News -> read(null, $id); /* Ist der Newsartikel überhaupt vorhanden? Wenn nicht -> bam back zum index.. */ if (empty($news['news']['id'])) { $this->Session->setFlash('Der von dir angeforderte Newsartikel scheint nicht vorhanden zu sein.'); $this->redirect(array('action'=>'index')); } /* Kommentare zählen */ $cmtcount = $this -> News -> Comments -> find('count', array('conditions' => array('Comments.news_id' => ''.$id.''))); /* Kommentare auswählen */ $comments = $this -> News -> Comments -> find('all', array( 'order' => 'id', 'direction' => 'desc' 'conditions' => array('Comments.news_id' => ''.$id.'' ))); /* Sind überhaupt Kommentare vorhanden? */ if($cmtcount == "0") { $nocmt = true; } else { $nocmt = false; } /* Abgeschickten Kommentar in die Datenbank eintragen - und einige Checks bzw. Fehlermeldungen */ if(!empty($this -> data)) { if(empty($this->data['Comments']['content'])) { $this -> Session -> setFlash('Das Feld Kommentartext darf nicht leer sein.'); } else { $this -> data ['Comments']['content'] = Sanitize::html($this->data['Comments']['content']); $this->data = Sanitize::clean($this->data, array('encode' => false)); $this->data['Comments']['news_id'] = $id; $this -> News -> Comments -> create(); if($this -> News -> Comments -> save($this->data)) { $this -> Session -> setFlash('Dein Kommentar wurde eingetragen.'); $this -> redirect('/news/comments/'.$id.''); } else { $this -> Session -> setFlash('Leider ist beim eintragen ein Fehler aufgetreten. Bitte versuche es erneut.'); } } } } } ?>