コード例 #1
0
 public function handleGet($get, $post, $files, $cookies)
 {
     $this->htmlHeader($cookies);
     /* Set up the page view */
     $view = new Views\MainPageView();
     $view->adminUrl = AdminController::getUrl();
     $search = new Models\Search();
     $search->setPage(0, 11);
     $search->sort = 'rand';
     $view->openGraphsForTop = array();
     $view->activeSection = isset($get['section']) ? $get['section'] : 'rand';
     switch ($view->activeSection) {
         case 'newest-folders':
             $search->sort = 'newest';
             foreach ($search->getFolders() as $folder) {
                 $view->openGraphsForTop[] = new FolderController($folder->id);
             }
             break;
         case 'rand':
         case 'popular':
         case 'unpopular':
         case 'newest':
             $search->sort = $view->activeSection;
             foreach ($search->getPhotos() as $photo) {
                 $view->openGraphsForTop[] = new PhotoController($photo->id);
             }
             break;
         default:
             $search->sort = 'rand';
             foreach ($search->getPhotos() as $photo) {
                 $view->openGraphsForTop[] = new PhotoController($photo->id);
             }
     }
     $root = Models\Folder::getRootFolder();
     $root->sort = 'newest';
     $root->setPage(0, 6);
     $view->folderAndPhotoOGs = array();
     foreach ($root->getDescendants() as $descendant) {
         $folderController = new FolderController($descendant->id);
         $folderAndPhotoOG = array($folderController);
         $photoOpenGraphs = array();
         $descendant->sort = 'rand';
         $descendant->setPage(0, 11);
         foreach ($descendant->getPhotos() as $photo) {
             $photoController = new PhotoController($photo->id);
             $photoOpenGraphs[] = $photoController;
         }
         $folderAndPhotoOG[] = $photoOpenGraphs;
         $view->folderAndPhotoOGs[] = $folderAndPhotoOG;
     }
     $view->rootOpenGraph = new FolderController('/');
     $view->mainPageOpenGraph = $this;
     $view->tagCollections = Models\TagCollection::getCollections();
     $view->render();
     $this->renderBottomNavbar();
     $this->htmlFooter();
 }
コード例 #2
0
 protected function renderNavbar($cookies = array())
 {
     $navbarView = new Views\NavbarView();
     $navbarView->openGraphObject = $this;
     $navbarView->currentUser = Models\User::currentUser($cookies);
     $navbarView->searchUrl = SearchController::getUrl();
     $navbarView->adminUrl = AdminController::getUrl();
     $navbarView->logoutUrl = LogoutController::getUrl();
     $navbarView->favoritesUrl = FavoritesController::getUrl();
     $navbarView->loginUrl = LoginController::getUrl();
     $navbarView->numFavorites = Models\Favorites::favoritesForCurrentUser($cookies)->getPhotoCount();
     $navbarView->ownerEmail = Models\Preferences::valueForModuleWithKey('CameraLife', 'owner_email');
     $navbarView->render();
 }