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(); }
public function handleGet($get, $post, $files, $cookies) { $photoCount = $this->model->getPhotoCount(); $folderCount = $this->model->getFolderCount(); $albumCount = $this->model->getTagCount(); // Sometimes we're sure an album page is relevant - redirect there if (!$folderCount && $albumCount == 1) { /* TODO $count_term = $cameralife->database->SelectOne('albums', 'COUNT(*)', "term LIKE '" . $get['q'] . "'"); if ($count_term == 1) { $albumid = $cameralife->database->SelectOne('albums', 'id', "term LIKE '" . $get['q'] . "'"); header('Location: ' . $cameralife->baseURL . '/album.php?id=' . $albumid); echo 'redirecting... ' . $cameralife->baseURL . '/album.php?id=' . $albumid; exit(0); } */ } // Sometimes we're sure a folder page is relevant - redirect there if (!$albumCount && !$photoCount && $folderCount == 1) { /* TODO list($folder) = $search->getFolders(); $folderOpenGraph = $folder->GetOpenGraph(); header('Location: ' . $folderOpenGraph['op:url']); exit(0); */ } $start = isset($get['start']) ? $get['start'] : 0; $this->model->setPage($start); /* Set up common page parts */ $this->htmlHeader($cookies); /* 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(); } if ($photoCount) { /* Set up grid */ $start = isset($get['start']) ? $get['start'] : 0; $objects = array(); foreach ($this->model->getPhotos() as $photo) { $objects[] = new PhotoController($photo->id); } /* Set up grid */ $grid = new Views\GridView(); $grid->openGraphObjects = $objects; $grid->render(); /* Set up page selector */ $pageSelector = new Views\PageSelectorView(); $pageSelector->start = $start; $pageSelector->total = $this->model->getPhotoCount(); $pageSelector->render(); } else { /* Set up grid */ $start = isset($get['start']) ? $get['start'] : 0; $objects = array(); foreach ($this->model->getFolders() as $folder) { $objects[] = new FolderController($folder->id); } /* Set up grid */ $grid = new Views\GridView(); $grid->openGraphObjects = $objects; $grid->render(); /* Set up page selector */ $pageSelector = new Views\PageSelectorView(); $pageSelector->start = $start; $pageSelector->total = $this->model->getFolderCount(); $pageSelector->render(); } /* Render footer */ $this->htmlFooter(); }