/** * Handles input, by calling according controller, * an sets view depending on url. * @return void */ public function handleInput() { //Create database, get content catalog $db = new Database(); $contentDAL = new contentDAL($db); $Catalog = new contentCatalog(); $contentController = new ContentController($contentDAL, $Catalog); $contentCatalog = $contentController->getContent(); //Handle login if ($this->navigationView->wantsToLogin()) { $login = new LoginController($this->users, $this->navigationView); $this->IsLoggedIn = $login->doLogin(); if ($this->IsLoggedIn) { $this->navigationView->redirToAdmin(); } else { $this->view = $login->getOutPut(); } } else { if ($this->navigationView->wantsToUpload() && isset($_SESSION['user'])) { $this->view = new AdminView(); $uploadController = new uploadController($this->view, $contentDAL, $this->users); $uploadController->doUpload(); } else { if ($this->navigationView->wantsToReg()) { $model = new RegFacade($this->userDAL); $this->view = new RegView($this->navigationView); $regControl = new RegisterController($model, $this->view); $regControl->addUser(); $this->view = new RegView($this->navigationView); } else { if ($this->navigationView->wantsToViewImage()) { $this->view = new ImageView(); $imgController = new ImageController($this->view, $contentCatalog); $imgController->getImage(); } else { if ($this->navigationView->wantsToViewContent()) { $commentView = new commentView(); $this->view = new ContentView($commentView); $id = $this->view->getID(); $commentDAL = new commentDAL($db); $commentController = new CommentController($commentView, $commentDAL); $comments = $commentController->doComment($id); $content = $contentController->getContentByID($id); $this->view->createHTML($content, $comments); } else { $this->view = new galleryView(); $galController = new GalleryController($this->view); $galController->doGallery($contentCatalog); } } } } } }
public function view() { session_start(); include 'models/memberModel.php'; $username = $_SESSION['username']; $memberModel = new memberModel(); // check for form submission if (isset($_POST["submit"])) { $uploadManager = new uploadController(); $uploadManager->uploadDisplayPic($username); if (isset($_POST["email"])) { $memberModel->updateEmail($username, $_POST["email"]); } if (isset($_POST["user_info"])) { $memberModel->updateUserInfo($username, $_POST["user_info"]); } } // query database to retrieve user information $memberModel = new memberModel(); $queryResult = $memberModel->getUserByUsername($username); $resultCount = pg_num_rows($queryResult); // check if user exists if ($resultCount == 1) { // initialize data for profile page $queryData = pg_fetch_row($queryResult); $data['profileName'] = $queryData[0]; $data['email'] = $queryData[3]; $data['user_info'] = $queryData[4]; $data['display_pic'] = $queryData[5]; // lastly, run the profile view include 'views/settings.php'; } else { // no result, redirect to home $home = new homeController(); $home->view(); } }