Example #1
0
 public function action_preview($id)
 {
     $id = filter_var($id, FILTER_SANITIZE_NUMBER_INT);
     $homeSpot = ORM::factory("homespot", $id);
     if (!$homeSpot->loaded()) {
         Message::set(Message::ERROR, "Sorry, that could not be found.");
         $this->request->redirect("admin/home/create");
         return;
     }
     $this->template->title = 'Share Your Photos - National Geographic Kids My Shot Community';
     $this->template->scripts = array('public/js/vendor/jquery.jcarousel.js', 'public/js/categories/slideshow.js', 'public/js/home/home.js');
     $awards = array();
     $badges = array();
     $events = ORM::factory('game_EventLog')->where('event_id', '=', Helper_Game::getSite()->getEvent(Model_Game_Site::HONOR_GIVEN))->order_by('time_stamp', 'DESC')->limit($this->sampleSize)->find_all();
     foreach ($events as $event) {
         $eventUser = ORM::factory('user', $event->user->user_id);
         if ($eventUser->id) {
             if ($event->data->type == "game_Badge") {
                 $obj = new stdClass();
                 $obj->data = $event->data;
                 $obj->honor = ORM::factory($event->data->type, $event->data->honor_id);
                 $obj->user = ORM::factory('user', $event->user->user_id);
                 $badges[] = $obj;
             }
         }
         if (count($badges) >= $this->maxBadges) {
             break;
         }
     }
     if (count($awards) < $this->maxAwards) {
         $aevents = ORM::factory('game_EventLog')->where('event_id', '=', Helper_Game::getSite()->getEvent(Helper_Game::AWARD_GIVEN)->id)->order_by('time_stamp', 'DESC')->limit($this->sampleSize)->find_all();
         foreach ($aevents as $event) {
             $obj = new stdClass();
             $obj->data = $event->data;
             $obj->honor = ORM::factory($event->data->type, $event->data->honor_id);
             $obj->user = ORM::factory('user', $event->user->user_id);
             $obj->photo = ORM::factory('photo', $event->item->item_id);
             $awards[] = $obj;
             if (count($awards) >= $this->maxAwards) {
                 break;
             }
         }
     }
     $honors = array_merge($awards, $badges);
     if (count($honors) == 0) {
         $honors = false;
     }
     $slider = Model_DLSliderGroup::getCurrentSlider();
     if ($slider) {
         $this->template->top = View::factory("home/slider");
         $this->template->top->slider = $slider;
     }
     $this->template->content = View::factory('home/index');
     $this->template->content->set(array('user' => $this->user, 'recently_added' => Reel_More::factory(ORM::factory('photo')->order_by('created', 'desc')), 'top_rated' => Reel_More::factory(Helper_Photos::get_top_rated()), 'honors' => $honors, 'potd' => Model_DailyPhoto::todaysPhoto(), 'homeSpot' => $homeSpot, 'homeSpotEditLink' => HTML::anchor("admin/home/edit/{$homeSpot->id}", "Edit")));
     $this->template->sidebar = Widget::factory()->add(Helper_Default::sidebar());
 }
Example #2
0
 /**
  * View the homepage.
  *
  * @return void
  * @author Merrick Christensen
  */
 public function action_index()
 {
     $this->template->title = 'Share Your Photos - National Geographic Kids My Shot Community';
     $this->template->scripts = array('public/js/vendor/jquery.jcarousel.js', 'public/js/categories/slideshow.js', 'public/js/home/home.js');
     $awards = array();
     $badges = array();
     $events = ORM::factory('game_EventLog')->where('event_id', '=', Helper_Game::getSite()->getEvent(Model_Game_Site::HONOR_GIVEN))->order_by('time_stamp', 'DESC')->limit($this->sampleSize)->find_all();
     foreach ($events as $event) {
         $eventUser = ORM::factory('user', $event->user->user_id);
         if ($eventUser->id) {
             if ($event->data->type == "game_Badge") {
                 $obj = new stdClass();
                 $obj->data = $event->data;
                 $obj->honor = ORM::factory($event->data->type, $event->data->honor_id);
                 $obj->user = ORM::factory('user', $event->user->user_id);
                 $badges[] = $obj;
             }
         }
         if (count($badges) >= $this->maxBadges) {
             break;
         }
     }
     if (count($awards) < $this->maxAwards) {
         $aevents = ORM::factory('game_EventLog')->where('event_id', '=', Helper_Game::getSite()->getEvent(Helper_Game::AWARD_GIVEN)->id)->order_by('time_stamp', 'DESC')->limit($this->sampleSize)->find_all();
         foreach ($aevents as $event) {
             $obj = new stdClass();
             $obj->data = $event->data;
             $obj->honor = ORM::factory($event->data->type, $event->data->honor_id);
             $obj->user = ORM::factory('user', $event->user->user_id);
             $obj->photo = ORM::factory('photo', $event->item->item_id);
             $awards[] = $obj;
             if (count($awards) >= $this->maxAwards) {
                 break;
             }
         }
     }
     $honors = array_merge($awards, $badges);
     if (count($honors) == 0) {
         $honors = false;
     }
     $slider = Model_DLSliderGroup::getCurrentSlider();
     if ($slider) {
         $this->template->top = View::factory("home/slider");
         $this->template->top->slider = $slider;
     }
     $this->template->content = View::factory('home/index');
     $this->template->content->set(array('user' => $this->user, 'recently_added' => Reel_More::factory(ORM::factory('photo')->order_by('created', 'desc')), 'top_rated' => Reel_More::factory(Helper_Photos::get_top_rated()), 'honors' => $honors, 'potd' => Model_DailyPhoto::todaysPhoto(), 'homeSpot' => Model_Homespot::getCurrent()));
     $this->template->sidebar = Widget::factory()->add(Helper_Default::sidebar());
 }
Example #3
0
 public function action_archive()
 {
     $this->template->content = View::factory('admin/dlslider/archive');
     $this->template->content->sliders = Model_DLSliderGroup::getArchivedSliders();
 }