/** * Bootstrap for comments * * */ public static function initComments($app) { // Sets context (should only be set here, globals can be dangerous) $app->session->set('context', $app->request->getCurrentUrl()); // Activate controller to show comments $app->dispatcher->forward(['controller' => 'comment', 'action' => 'view']); // Create HTML form that lets the user create comments $form = new CommentForm(); $form->setDI($app); $form->createForm(); $form->check(); $app->views->add('me/page', ['content' => $form->getHTML()]); /* // Adds comment form view $app->views->add('comment/form', [ 'mail' => null, 'web' => null, 'name' => null, 'content' => null, 'output' => null, 'fieldlabel'=> 'Kommentera', 'update' => false ]); */ // Adds comment styling $app->theme->addStylesheet('css/comments.css'); }
/** * Display comment info for editing * * @return void */ public function editAction($commentId) { // Retrieve data from the model as an array $comment = $this->commentModel->find($commentId); $this->theme->setTitle('Uppdatera kommentar'); // Add view with the fetched information /* $this->di->views->add('comment/form', [ 'mail' => $comment['email'], 'web' => $comment['website'], 'name' => $comment['creator'], 'content' => $comment['content'], 'output' => null, 'fieldlabel'=> 'Kommentera', 'update' => true, 'id' => $commentId ]); */ $form = new CommentForm(); $form->setDI($this); $form->createForm('update', $this->translate($comment)); $form->check(); $this->views->add('me/page', ['content' => $form->getHTML()]); $this->theme->setVariable('bodyClasses', 'page-container'); }