public static function getInstance() { if (null === self::$instance) { self::$instance = new self(); } return self::$instance; }
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"); }
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; }
private function __construct() { $this->classloader = Classloader::getInstance(); $this->classloader->initLoadLib(); $this->dataConnector = DataConnector::getInstance(); $this->routingEngine = RoutingEngine::getInstance(); $this->templateEngine = TemplateEngine::getInstance(); }
function leave() { if (!isset($_POST["e_eid"])) { RoutingEngine::returnAjax("Error."); } $eid = $_POST["e_eid"]; $result = Event::removeAttendeeFromEvent($eid); RoutingEngine::returnAjax($result, true); }
public function action_delete() { RoutingEngine::setPage("runnDAILY", "PV__300"); if (!isset($_POST["go_id"])) { Page::redirect("/goals"); } Goal::deleteGoal($_POST["go_id"]); Page::redirect("/goals"); }
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")); } }
public function actionCancel() { RoutingEngine::setPage("runnDAILY Requests", "PV__300"); $cid = $_POST["cid"]; $confirmation = Confirmation::fetch($cid); $result = false; if ($confirmation->uid_from == User::$current_user->uid) { $result = $confirmation->delete(); } //Javascript is expecting an object with result and cid $output = array("cid" => $cid, "result" => $result); RoutingEngine::returnAjax($output, true); }
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))); }
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; }
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; }
/** * Normal render * @param string $view */ public function renderAsHTML($view = 'index') { $routingEngine = RoutingEngine::getInstance(); $templateEngine = TemplateEngine::getInstance(); $templateEngine->loadDesign(); $templateEngine->loadView($routingEngine->controller, $routingEngine->action); $templateEngine->setTitle($routingEngine->controller . ' > ' . $routingEngine->action); $templateEngine->render($this); }
<?php //phpinfo(); //die("Configuring the server."); $_SERVER["TIME_START"] = microtime(true); DEFINE("PUBLIC_ROOT", dirname(__FILE__)); DEFINE("ROOT", dirname(PUBLIC_ROOT)); DEFINE("SYSTEM_ROOT", ROOT . "/system"); DEFINE("CLASS_ROOT", SYSTEM_ROOT . "/class"); require SYSTEM_ROOT . "/config.php"; session_start(); RoutingEngine::getInstance()->authenticateUser(); $request = explode("?", $_SERVER["REQUEST_URI"]); $engine = RoutingEngine::getInstance()->initialize($request[0]); $engine->renderRequest(); RoutingEngine::getInstance()->persistUserData();
public function action_copy_view() { RoutingEngine::setPage("runnDAILY Routes", "PV__300"); $route = new Route($_POST); if ($route->copy()) { Notification::add("Your route - {$route->name} - was copied."); Page::redirect("/routes/view/{$route->id}"); } Notification::add("There was an error copying the route. Try again."); Page::redirect("/routes/view/{$route->id}"); }
public function ajax_elevation_update_all() { $result = Database::getDB()->query("\r\n\t\t\tSELECT r_id, r_name, r_points\r\n\t\t\tFROM routes\r\n\t\t\tWHERE\r\n\t\t\t\tr_elevation IS NULL\r\n\t\t\tLIMIT 10\r\n\t\t") or die(Database::getDB()->error); $routes = array(); while ($row = $result->fetch_assoc()) { $routes[] = new Route($row); } $result->close(); $results = array(); foreach ($routes as $route) { $result = $route->_updateElevationData(); if (!$result) { $result = $route->_setElevationToChecked(); } $results[] = $result; } RoutingEngine::returnAjaxForm(true, $results); }
public function logoff() { $_SESSION['login'] = false; session_destroy(); RoutingEngine::getInstance()->redirect('index.php'); }
public function credits() { RoutingEngine::setPage("runnDAILY About", "PV__400"); }
public function actionDelete() { RoutingEngine::setPage("Messages | runnDAILY", "PV__300"); if (!isset($_POST["msg_convo_id"])) { Page::redirect("/messages"); } $message = new Message($_POST); $read_count = Message::markConvoRead($message->convo_id); if ($read_count > 0) { Message::updateCount(User::$current_user->uid, -$read_count); User::$current_user->msg_new -= $read_count; RoutingEngine::getInstance()->persistUserData(); } $message->delete(); Page::redirect("/messages"); }
function ajax_remove_notification() { RoutingEngine::setPage("runnDAILY User Remove Notification", "PV__300"); if (!isset($_POST["id"])) { return false; } $id = $_POST["id"]; Notification::remove($id); RoutingEngine::getInstance()->persistUserData(); RoutingEngine::returnAjax(true); }
public function delete() { RoutingEngine::setPage("runnDAILY", "PV__100"); $message = new Message($_POST); exit(json_encode($message->deleteByType(2))); }
public function settings() { RoutingEngine::setPage("runnDAILY Settings", "PV__300"); }
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; }
public function userCanEdit($gid) { return RoutingEngine::getInstance()->requirePermission("GP__100", $gid); }
public static function setPage($title = "runnDAILY", $perm = "PV__100", $default = false) { if ($default && self::$_isPageSet) { return; } self::getInstance()->requirePermission($perm, null, true); self::getInstance()->page->title = $title; self::$_isPageSet = true; }
/** * @param $as_object * @param $arr_on_single * @param $arr_index * @return mixed */ function execute($as_object = false, $arr_on_single = false, $arr_index = null) { //set some defaults if needed if (!$this->_has_select) { $this->select("*"); } if (!$this->_has_limit) { $this->limit(100); } $sql = $this->_get_full_sql(); if (count($this->_bind_vals)) { $stmt = Database::getDB()->prepare($sql); $types = $this->_sql_all_bind_types(); call_user_func_array(array($stmt, "bind_param"), array_merge(array($types), $this->_bind_vals)); $stmt->execute() or RoutingEngine::throwException($stmt->error); $stmt->store_result(); } else { $stmt = Database::getDB()->query($sql); } $results = array(); while ($row = $stmt->fetch_assoc()) { if ($as_object) { $obj = new $this->_class($row); if (count($this->_left_joins)) { foreach ($this->_left_joins as $table) { $type = $this->_tables_classes[$table]; $obj->{$type} = new $type($row); } } $results[] = $obj; } else { if (isset($arr_index)) { $results[$row[$arr_index]] = $row; } else { $results[] = $row; } } } $stmt->close(); $return = !$arr_on_single && count($results) == 1 ? $results[0] : $results; if ($this->_has_debug) { var_dump($return); } return $return; }
public function index() { RoutingEngine::setPage("runnDAILY Guides", "PV__400"); }