예제 #1
0
function smarty_function_modules($params, &$smarty)
{
    $mod_con = new Controller_Module($params, RoutingEngine::getSmarty());
    $mod_names = array_safe($params, "list");
    $mod_list = explode(",", $mod_names);
    $modules = array();
    $unplaced_modules = array();
    $counts = array("3" => 0, "4" => 0, "5" => 0);
    foreach ($mod_list as $mod_code) {
        $mod_name = Module::$hash[$mod_code];
        if (!method_exists($mod_con, $mod_name)) {
            continue;
        }
        $module = $mod_con->{$mod_name}();
        if ($module->size) {
            $modules[$module->size][] = $module;
            $counts[$module->size]++;
        } else {
            $unplaced_modules[] = $module;
        }
    }
    foreach ($unplaced_modules as $module) {
        asort($counts);
        current($counts);
        $modules[key($counts)][] = $module;
        $counts[key($counts)]++;
    }
    RoutingEngine::getSmarty()->assign("modules", $modules);
    return RoutingEngine::getSmarty()->fetch("modules/module_master.tpl");
}
예제 #2
0
파일: rss.php 프로젝트: byronwall/runnDAILY
 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;
 }
예제 #3
0
 /**
  * 
  * @return unknown_type
  */
 public function index()
 {
     RoutingEngine::setPage("runnDAILY Requests", "PV__300");
     $confirm_to = Confirmation::fetchForUser(User::$current_user->uid, true);
     $confirm_from = Confirmation::fetchForUser(User::$current_user->uid, false);
     RoutingEngine::getSmarty()->assign("confirm_to", $confirm_to);
     RoutingEngine::getSmarty()->assign("confirm_from", $confirm_from);
 }
예제 #4
0
 public function elevation()
 {
     RoutingEngine::setPage("runnDAILY Elevation Admin", "PV__100");
     $query = Database::getDB()->query("\r\n\t\t\tSELECT * FROM elevation_regions\r\n\t\t");
     $elev = array();
     while ($row = $query->fetch_assoc()) {
         $elev[$row["id"]] = $row;
     }
     RoutingEngine::getSmarty()->assign("elevation", json_encode($elev));
 }
예제 #5
0
 public function view($id)
 {
     if (!isset($id)) {
         Page::redirect("/goals");
     }
     RoutingEngine::setPage("runnDAILY View Goal", "PV__300");
     $goal = Goal::getGoalById($id);
     $training_items = TrainingLog::getItemsForUserForGoalView(User::$current_user->uid, $goal->start, $goal->end);
     $goal->buildGoalDataUsingTrainingItems($training_items);
     RoutingEngine::getSmarty()->assign("goal", $goal);
     RoutingEngine::getSmarty()->assign("training_items", $training_items);
 }
예제 #6
0
 function create()
 {
     $types = Event::getTypes();
     RoutingEngine::getSmarty()->assign("event_types", $types);
     if (isset($_GET["eid"])) {
         $eid = $_GET["eid"];
         $event = Event::find($eid);
         if ($event->uid == User::$current_user->uid) {
             RoutingEngine::getSmarty()->assign("event", $event);
         }
     }
 }
예제 #7
0
파일: log.php 프로젝트: byronwall/runnDAILY
 public function browse()
 {
     $format = isset($_GET["format"]) ? $_GET["format"] : "html";
     if ($format == "ajax") {
         $uid = $_GET["uid"];
         $page_no = $_GET["page"];
         $logs = Log::getAllActivityForUserPaged($uid, 5, $page_no);
         RoutingEngine::getSmarty()->assign("logs", $logs);
         RoutingEngine::getSmarty()->assign("uid", $uid);
         RoutingEngine::getSmarty()->assign("page_no", $page_no + 1);
         exit(RoutingEngine::getSmarty()->fetch("log/log_list.tpl"));
     }
 }
예제 #8
0
 public function view()
 {
     if (!isset($_GET["gid"])) {
         Page::redirect("/community/");
     }
     $gid = $_GET["gid"];
     $group = Group::fromGroupID($gid);
     RoutingEngine::getSmarty()->assign("group_view", $group);
     RoutingEngine::getSmarty()->assign("user_is_member", Group::userIsMember($gid));
     RoutingEngine::getSmarty()->assign("user_can_edit", Group::userCanEdit($gid));
     RoutingEngine::getSmarty()->assign("group_view_anoun", Group::getAnnouncement($gid));
     RoutingEngine::getSmarty()->assign("group_view_member_list", Group::getMembers($gid));
     RoutingEngine::getSmarty()->assign("group_view_activity", Log::getActivityByAid(null, $gid, array(500)));
 }
예제 #9
0
 public function delete()
 {
     RoutingEngine::setPage("Messages | runnDAILY", "PV__300");
     RoutingEngine::getInstance()->registerParams("convo_id");
     if (!isset($_GET["convo_id"])) {
         Page::redirect("/messages");
     }
     $convo_id = $_GET["convo_id"];
     RoutingEngine::getSmarty()->assign("convo_id", $convo_id);
     $output = RoutingEngine::getSmarty()->fetch("messages/_delete.tpl");
     echo $output;
     die;
     exit;
 }
예제 #10
0
 public function search()
 {
     RoutingEngine::setPage("runnDAILY", "PV__300");
     if (!isset($_POST["u_search"]) || $_POST["u_search"] == "") {
         echo "<p>Please enter a search term.</p>";
         exit;
     }
     //$user_list = User::searchForUser($_POST["u_search"]);
     $user = $_POST["u_search"];
     $user_list = User::sql()->select("u_uid, u_username")->where("u_username LIKE ? OR u_email LIKE ?", "%" . $user . "%", "%" . $user . "%")->limit(40)->execute(false, true);
     RoutingEngine::getSmarty()->assign("user_list", $user_list);
     $output = RoutingEngine::getSmarty()->fetch("community/_user_search_result.tpl");
     echo $output;
     exit;
 }
예제 #11
0
 public function view($common)
 {
     RoutingEngine::setPage("runnDAILY About", "PV__400");
     $pages = array("admin_elevation", "about_contact", "about_credits", "about_index", "community_index", "community_view_user", "confirmation_index", "goals_index", "goals_create", "home_index", "home_register", "messages_index", "routes_view", "routes_create", "routes_index", "training_create", "training_index");
     if (in_array($common, $pages)) {
         $output = RoutingEngine::getSmarty()->fetch("help/_pages/{$common}.tpl");
     } else {
         $feedback = new Message();
         $feedback->uid_from = User::$current_user->uid;
         $feedback->uid_to = null;
         $feedback->message = "Please create a help page for " . $_SERVER["HTTP_REFERER"];
         $feedback->subject = null;
         $feedback->type = 2;
         $feedback->create();
         $output = RoutingEngine::getSmarty()->fetch("help/_pages/none.tpl");
     }
     echo $output;
     die;
 }
예제 #12
0
 public function create()
 {
     RoutingEngine::setPage("runnDAILY Create Route", "PV__400");
     if (isset($_GET["rid"])) {
         $route = Route::fromRouteIdentifier($_GET["rid"]);
         if ($route->getTrainingCount() == 0) {
             RoutingEngine::getSmarty()->assign("route_edit", $route);
             RoutingEngine::getSmarty()->assign("is_edit", true);
         } else {
             Notification::add("The route you tried to edit needs to be copied first.");
         }
         if (isset($_GET["mode"])) {
             $isCopy = $_GET["mode"] == "copy";
             RoutingEngine::getSmarty()->assign("isCopy", $isCopy);
         }
     }
     RoutingEngine::getSmarty()->assign("body_id", "map_create");
 }
예제 #13
0
 public function summary()
 {
     RoutingEngine::setPage("runnDAILY Training Summary", "PV__300");
     $this_week = new DateRange();
     $this_week->getWeekRange();
     $data_this_week = TrainingLog::getItemsForUserForGoalPercent(User::$current_user->uid, $this_week->start, $this_week->end);
     $last_week = new DateRange();
     $last_week->getWeekRange("today", -1);
     $data_last_week = TrainingLog::getItemsForUserForGoalPercent(User::$current_user->uid, $last_week->start, $last_week->end);
     $overall = TrainingLog::getSummaryOverall(User::$current_user->uid);
     //var_dump($data_this_week, $data_last_week, $overall);
     RoutingEngine::getSmarty()->assign("this_week", $this_week);
     RoutingEngine::getSmarty()->assign("last_week", $last_week);
     RoutingEngine::getSmarty()->assign("overall", $overall);
     RoutingEngine::getSmarty()->assign("data_this_week", $data_this_week);
     RoutingEngine::getSmarty()->assign("data_last_week", $data_last_week);
     $output = RoutingEngine::getSmarty()->fetch("training/_summary.tpl");
     echo $output;
     die;
 }