Ejemplo n.º 1
0
 public function training()
 {
     if (!isset($_GET["username"])) {
         exit;
     }
     $user = User::fromUsername($_GET["username"]);
     $t_items = TrainingLog::getItemsForUser($user->uid);
     $feed = new Rss_Feed("Training entries for {$user->username}", "http://{$_SERVER["SERVER_NAME"]}", "Includes the training data for a given user.");
     $feed->pubDate = date(DATE_RSS);
     $feed->defineImageForFeed(new Rss_Image("running logo", "http://byroni.us", "http://runndaily.com/img/logo.png"));
     foreach ($t_items as $item) {
         $rss_item = new Rss_Item();
         $rss_item->guid = "http://{$_SERVER["SERVER_NAME"]}/training/view/{$item->tid}";
         $rss_item->link = "http://{$_SERVER["SERVER_NAME"]}/training/view/{$item->tid}";
         $rss_item->description = "{$item->date} : {$item->distance} miles";
         $rss_item->pubDate = date(DATE_RSS, $item->date);
         $rss_item->title = "{$user->username} logged an entry on " . date("F j, Y, g:i a", $item->date);
         $feed->addItemToFeed($rss_item);
     }
     //die(var_dump($feed));
     RoutingEngine::getSmarty()->assign("RssFeed", $feed);
     $rss_out = RoutingEngine::getSmarty()->fetch("generic/rss.tpl");
     header("Content-Type: application/rss+xml");
     echo $rss_out;
 }
Ejemplo n.º 2
0
 public function view()
 {
     RoutingEngine::setPage("runnDAILY View Training", "PV__300");
     if (!isset($_GET["tid"])) {
         Page::redirect("/training/");
     }
     $tid = $_GET["tid"];
     $training_item = TrainingLog::getItem($tid);
     $cal_week = new Calendar($training_item->date, CAL_WEEK);
     $training_items = TrainingLog::getItemsForUser($training_item->uid, $cal_week->getFirstDayOnCalendar(), $cal_week->getLastDayOnCalendar());
     foreach ($training_items as $item) {
         $cal_week->addItemToDay($item->date, $item);
     }
     RoutingEngine::getSmarty()->assign("item", $training_item);
     RoutingEngine::getSmarty()->assign("calendar", $cal_week);
 }