public function handleGet($get, $post, $files, $cookies) { // todo, get PREV and NEXT links from photo and use meta prev/next in HTML theme header $this->htmlBareHeader($cookies); $view = new Views\BackgroundBlurView(); $view->imageURL = $this->model->getMediaURL('thumbnail'); $view->render(); $view = new Views\PhotoView(); $view->photo = $this->model; $view->currentUser = Models\User::currentUser($cookies); $view->openGraphObject = $this; if (isset($get['referrer'])) { $view->referrer = $get['referrer']; } elseif (isset($_SERVER['HTTP_REFERER'])) { $view->referrer = $_SERVER['HTTP_REFERER']; } if ($this->model->get('status') != 0) { if (Models\User::currentUser($cookies)->authorizationLevel < 5) { throw new \Exception('This file has been flagged or marked private'); } } $this->model->set('hits', $this->model->get('hits') + 1); $context = $this->model->getFolder(); $view->contextUrl = FolderController::getUrlForID($context->id); $view->render(); $photoNext = $this->model->getNext(); $photoPrev = $this->model->getPrevious(); $context = $this->model->getFolder(); /* Render footer */ $this->footerJavascript = "\noutUrl = '" . FolderController::getUrlForID($context->id) . "'\nfunction goOut() {\n\t\$('#mainPic').animate({\n opacity: 'hide'\n }, 'medium', 'easeOutQuad', function() {\n \$('#mainPic').remove();\n window.location.href = outUrl\n });\n}\t\t\t\n\n\$(document).keyup(function(e) {\n\tif (e.which == 27) goOut();\n});\n\nvar hammertime = new Hammer(\$('#mainPic')[0]);\n\$.easing.easeInQuad = function (x, t, b, c, d) {\n return c*(t/=d)*t + b;\n };\n\$.easing.easeOutQuad = function (x, t, b, c, d) {\n return -c *(t/=d)*(t-2) + b;\n};\n\t\t\nnextUrl = '" . ($photoNext ? self::getUrlForID($photoNext->id) : '') . "'\nfunction goNext() {\n\tif (nextUrl) {\t\t\n\t\t\$('#mainPic').animate({\n\t opacity: 'hide',\n\t left: '-200px'\n\t }, 'medium', 'easeOutQuad', function() {\n\t \$('#mainPic').remove();\n\t window.location.href = nextUrl\n\t });\n\t} else {\n\t\t\$('#mainPic').animate({\n\t left: '-200px'\n\t }, 'fast', 'easeOutQuad', function() {\n\t\t\t\$('#mainPic').animate({\n\t\t left: '0'\n\t\t }, 'fast', 'easeInQuad');\n\t });\t\t\n\t}\n}\t\t\t\nhammertime.on('swipeleft', goNext);\n\$(document).keyup(function(e) {\n\tif (e.which == 39) goNext();\n});\n\t\t\nprevUrl = '" . ($photoPrev ? self::getUrlForID($photoPrev->id) : '') . "'\nfunction goPrev() {\n\tif (prevUrl) {\t\t\n\t\t\$('#mainPic').animate({\n\t opacity: 'hide',\n\t left: '200px'\n\t }, 'medium', 'easeOutQuad', function() {\n\t \$('#mainPic').remove();\n\t window.location.href = prevUrl\n\t });\n\t} else {\n\t\t\$('#mainPic').animate({\n\t left: '200px'\n\t }, 'fast', 'easeOutQuad', function() {\n\t\t\t\$('#mainPic').animate({\n\t\t left: '0'\n\t\t }, 'fast', 'easeInQuad');\n\t });\t\t\n\t}\n}\t\t\t\nhammertime.on('swiperight', goPrev);\n\$(document).keyup(function(e) {\n\tif (e.which == 37) goPrev();\n});\n\t "; $this->htmlBareFooter(); }
public function handleGet($get, $post, $files, $cookies) { $start = isset($get['start']) ? $get['start'] : 0; $section = isset($get['section']) ? $get['section'] : null; $this->model->setPage($start); $photoCount = $this->model->getPhotoCount(); $folderCount = $this->model->getFolderCount(); $gridObjects = array(); if (!$photoCount || $section == 'folders') { foreach ($this->model->getFolders() as $folder) { $gridObjects[] = new FolderController($folder->id); } } else { foreach ($this->model->getPhotos() as $photo) { $gridObjects[] = new PhotoController($photo->id); } } $photos = $this->model->getPhotos(); $firstPhoto = NULL; if (count($photos) > 0) { $firstPhoto = $photos[0]; } /* Set up common page parts */ $this->htmlHeader($cookies); if ($firstPhoto) { $view = new Views\BackgroundBlurView(); $view->imageURL = $firstPhoto->getMediaURL('thumbnail'); $view->render(); } /* Set up breadcrumbs */ $breadcrumbs = new Views\BreadcrumbView(); foreach ($this->model->getAncestors() as $ancestor) { $openGraph = new FolderController($ancestor->path); $openGraph->title = basename($openGraph->title); $breadcrumbs->openGraphObjects[] = $openGraph; } $openGraph = clone $this; $openGraph->title = basename($openGraph->title); $breadcrumbs->openGraphObjects[] = $openGraph; $breadcrumbs->openGraphObjects[0]->title = '(All photos)'; $breadcrumbs->render(); /* Set up tabs */ $tabs = new Views\TabView(); if ($photoCount && $folderCount) { $tabs->openGraphObjects[0] = clone $this; $tabs->openGraphObjects[0]->title = "{$photoCount} photos"; $tabs->openGraphObjects[1] = clone $this; $tabs->openGraphObjects[1]->title = "{$folderCount} folders"; $tabs->render(); } /* Set up grid */ $grid = new Views\GridView(); $grid->openGraphObjects = $gridObjects; $grid->render(); /* Set up page selector */ $pageSelector = new Views\PageSelectorView(); $pageSelector->start = $start; $pageSelector->total = $photoCount; $pageSelector->url = $this->url; $pageSelector->render(); /* Render footer */ $this->htmlFooter(); }