CreatePostController.inc 681 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. class CreatePostController implements IController {
  3. public function execute() {
  4. $session = new Session();
  5. $view = new View();
  6. $form = new Form();
  7. $topicModel = new TopicModel();
  8. $headRenderer = new HeadRenderer();
  9. $userId = $session->getValue("logged_in");
  10. $topicId = $form->getDefaulted('t', 0);
  11. $currentTopic = $topicModel->getCurrentTopic($topicId);
  12. $viewData = array(
  13. "header" => $headRenderer->render(),
  14. "tag" => ! empty($currentTopic) ? $currentTopic['display_name'] : ""
  15. );
  16. if ($userId) {
  17. return $view->render("createPostView.inc", $viewData);
  18. } else {
  19. return $view->render("logInPromptView.inc", $viewData);
  20. }
  21. }
  22. }