public function view()
 {
     $this->guardMustBeAuthenticatedOtherwiseRedirectToIndex();
     $dropboxPath = @strval($this->getQueryArray()["path"]) ?: "/";
     $dropboxClient = $this->getDropboxClient();
     $entry = $dropboxClient->getMetadataWithChildren($dropboxPath);
     if (!$entry) {
         $errorMsg = htmlentities(sprintf("File or folder on path \"%s\" does not exist!", $dropboxPath));
         $this->respondWithError(404, "Not Found", $errorMsg);
     }
     $view = new ViewModel();
     $view->entry = $entry;
     $view->pathView = $this->getPath();
     $view->pathOneLevelUp = dirname($dropboxPath);
     $view->urlOneLevelUp = $this->getBaseURL() . "/view?path=" . htmlentities($view->pathOneLevelUp);
     if ($entry["is_dir"]) {
         $view->setTemplateFilePath(ROOT_PATH . "/application/MVC/View/application/folder.phtml");
         $view->uploadUrl = $this->getBaseURL() . "/upload";
         $view->uploadFolderPath = $entry["path"];
         $view->uploadMaxFilesize = Uploader::getUploadMaxFilesize();
     } else {
         $view->setTemplateFilePath(ROOT_PATH . "/application/MVC/View/application/file.phtml");
         $view->pathDownload = "/dropbox-integration/download";
     }
     $layout = new ViewModel();
     $layout->setTemplateFilePath(ROOT_PATH . "/application/MVC/View/layout/default.phtml");
     $layout->title = $entry["path"];
     $layout->content = $view->render();
     header("Content-Type: text/html; charset=utf-8", true);
     die($layout->render());
 }
 public function respondWithError($statusCode, $statusMessage, $body = "")
 {
     $title = sprintf("%s %s", $statusCode, $statusMessage);
     $view = new ViewModel();
     $view->setTemplateFilePath(ROOT_PATH . "/application/MVC/View/error/500.phtml");
     $view->title = $title;
     $view->content = $body;
     $layout = new ViewModel();
     $layout->setTemplateFilePath(ROOT_PATH . "/application/MVC/View/layout/default.phtml");
     $layout->title = $title;
     $layout->content = $view->render();
     $proto = $this->server['SERVER_PROTOCOL'];
     header("{$proto} {$statusCode} {$statusMessage}", true, $statusCode);
     header("Content-Type: text/html; charset=utf-8", true);
     die($layout->render());
 }