Esempio n. 1
0
 public function action_set($id)
 {
     $photo = ORM::factory("photo", filter_var($id, FILTER_SANITIZE_NUMBER_INT));
     if ($photo->loaded() && !empty($_POST['day'])) {
         Model_DailyPhoto::setPhoto($photo, $_POST['day']);
         Message::set(Message::SUCCESS, "Photo set as photo of the day!");
     }
     $this->request->redirect("photos/view/{$photo->id}");
 }
Esempio n. 2
0
 /**
  * Ajax endpoint for gathering all photos of the day by timestamp.
  *
  * @return void
  * @author Stevie McComb
  */
 public function action_getpotds()
 {
     $photos = Model_DailyPhoto::allPhotos($_POST['olderThan'], $_POST['newerThan']);
     $ret = array();
     foreach ($photos as $photo) {
         $ret[] = (object) array("id" => $photo->id, "name" => $photo->name, "created" => $photo->created, "timestamp" => $photo->creationDate(), "url" => Helper_Photos::get_photo_url($photo), "imageSource" => addcslashes(Helper_Photos::get($photo, "medium"), "'"));
     }
     echo json_encode($ret);
     exit;
 }
Esempio n. 3
0
 public function action_index()
 {
     $this->auto_render = false;
     $limit = filter_var(Arr::get($_GET, 'past', 30), FILTER_SANITIZE_NUMBER_INT);
     $offset = filter_var(Arr::get($_GET, 'offset', 0), FILTER_SANITIZE_NUMBER_INT);
     if ($past = Arr::get($_GET, "past")) {
         $this->resource = ORM::factory("DailyPhoto")->where("day", "<", date("Y-m-d"))->order_by("day", "desc")->limit($limit)->offset($offset);
     } else {
         $this->resource = Model_DailyPhoto::todaysPhoto();
     }
     $this->render($this->resource, $offset, $limit);
 }
Esempio n. 4
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());
 }
Esempio n. 5
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());
 }