TopicController.inc 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. class TopicController implements IController {
  3. private $view;
  4. private $topicModel;
  5. private $form;
  6. private $postRenderer;
  7. private $loginViewDecider;
  8. private $permissionDecider;
  9. private $headRenderer;
  10. public function __construct() {
  11. $this->view = new View();
  12. $this->topicModel = new TopicModel();
  13. $this->form = new Form();
  14. $this->postRenderer = new PostRenderer();
  15. $this->loginViewDecider = new LoginViewDecider();
  16. $this->permissionDecider = new PermissionDecider();
  17. $this->headRenderer = new HeadRenderer();
  18. }
  19. public function execute() {
  20. $topicId = $this->form->getCleanDefaulted("id", 0);
  21. $page = $this->form->getCleanDefaulted("c", 0);
  22. $currentTopic = $this->topicModel->getCurrentTopic($topicId);
  23. $defaultTopics = $this->topicModel->getUserTopics();
  24. $topicAccess = $this->permissionDecider->hasTopicAccess($topicId);
  25. $topicViewData = array(
  26. "header" => $this->headRenderer->render(),
  27. "title" => $currentTopic['display_name'],
  28. "topicData" => $currentTopic,
  29. "postView" => $this->postRenderer->getPostsInTopic($topicId, $page),
  30. 'topicAccess' => $topicAccess
  31. );
  32. return $this->view->render("topicView.inc", $topicViewData);
  33. }
  34. }