function index() { $this->template->content = new View('admin/dashboard'); $this->template->content->title = 'Dashboard'; $this->template->this_page = 'dashboard'; // $this->template->header = new View('header'); // Retrieve Dashboard Count... // Total Reports $this->template->content->reports_total = ORM::factory('incident')->count_all(); // Total Unapproved Reports $this->template->content->reports_unapproved = ORM::factory('incident')->where('incident_active', '0')->count_all(); // Total Unverified Reports $this->template->content->reports_unverified = ORM::factory('incident')->where('incident_verified', '0')->count_all(); // Total Categories $this->template->content->categories = ORM::factory('category')->count_all(); // Total Locations $this->template->content->locations = ORM::factory('location')->count_all(); // Total Incoming Media $this->template->content->incoming_media = ORM::factory('feed_item')->count_all(); // Messages By Service $total_message_count = 0; $message_services = array(); $services = ORM::factory('service')->find_all(); foreach ($services as $service) { $message_count = ORM::factory('message')->join('reporter', 'message.reporter_id', 'reporter.id')->where('service_id', $service->id)->where('message_type', '1')->count_all(); $message_services[] = array('id' => $service->id, 'name' => $service->service_name, 'count' => $message_count); $total_message_count += $message_count; } $this->template->content->message_services = $message_services; // Total Messages $this->template->content->message_count = $total_message_count; // Get reports for display $incidents = ORM::factory('incident')->limit(5)->orderby('incident_dateadd', 'desc')->find_all(); $this->template->content->incidents = $incidents; // Get Incoming Media (We'll Use NewsFeeds for now) $this->template->content->feeds = ORM::factory('feed_item')->limit('3')->orderby('item_date', 'desc')->find_all(); // Javascript Header $this->template->flot_enabled = TRUE; $this->template->js = new View('admin/dashboard_js'); // Graph $this->template->js->all_graphs = Incident_Model::get_incidents_by_interval('ALL', NULL, NULL, 'all'); $this->template->js->current_date = date('Y') . '/' . date('m') . '/01'; }
function index() { $this->template->content = new View('admin/dashboard'); $this->template->content->title = 'Dashboard'; $this->template->this_page = 'dashboard'; // $this->template->header = new View('header'); // Retrieve Dashboard Count... // Total Reports $this->template->content->reports_total = ORM::factory('incident')->count_all(); // Total Unapproved Reports $this->template->content->reports_unapproved = ORM::factory('incident')->where('incident_active', '0')->count_all(); // Total Unverified Reports $this->template->content->reports_unverified = ORM::factory('incident')->where('incident_verified', '0')->count_all(); // Total Categories $this->template->content->categories = ORM::factory('category')->count_all(); // Total Locations $this->template->content->locations = ORM::factory('location')->count_all(); // Total Incoming Media $this->template->content->incoming_media = ORM::factory('feed_item')->count_all(); // Total SMS Messages $this->template->content->message_sms_count = ORM::factory('message')->count_all(); // Total Twitter Messages $this->template->content->message_twitter_count = ORM::factory('twitter')->where('hide', 0)->count_all(); // Total Message Count $this->template->content->message_count = $this->template->content->message_twitter_count + $this->template->content->message_sms_count; // Get reports for display $incidents = ORM::factory('incident')->limit(3)->orderby('incident_dateadd', 'desc')->find_all(); $this->template->content->incidents = $incidents; // Get Incoming Media (We'll Use NewsFeeds for now) $this->template->content->feeds = ORM::factory('feed_item')->limit('3')->orderby('item_date', 'desc')->find_all(); // Javascript Header $this->template->flot_enabled = TRUE; $this->template->js = new View('admin/dashboard_js'); // Graph $this->template->js->all_graphs = Incident_Model::get_incidents_by_interval('ALL', NULL, NULL, 'all'); $this->template->js->current_date = date('Y') . '/' . date('m') . '/01'; }
public function index() { $this->template->header->this_page = 'home'; $this->template->content = new View('main'); // Get all active categories $categories = array(); foreach (ORM::factory('category')->where('category_visible', '1')->find_all() as $category) { // Create a list of all categories $categories[$category->id] = array($category->category_title, $category->category_color); } $this->template->content->categories = $categories; // Get Reports // XXX: Might need to replace magic no. 8 with a constant $this->template->content->total_items = ORM::factory('incident')->where('incident_active', '1')->limit('8')->count_all(); $this->template->content->incidents = ORM::factory('incident')->where('incident_active', '1')->limit('10')->orderby('incident_dateadd', 'desc')->find_all(); // Get SMS Numbers $phone_array = array(); $sms_no1 = Kohana::config('settings.sms_no1'); $sms_no2 = Kohana::config('settings.sms_no2'); $sms_no3 = Kohana::config('settings.sms_no3'); if (!empty($sms_no1)) { $phone_array[] = $sms_no1; } if (!empty($sms_no2)) { $phone_array[] = $sms_no2; } if (!empty($sms_no3)) { $phone_array[] = $sms_no3; } $this->template->content->phone_array = $phone_array; // Get RSS News Feeds $this->template->content->feeds = ORM::factory('feed_item')->limit('10')->orderby('item_date', 'desc')->find_all(); // Get Slider Dates By Year $startDate = ""; $endDate = ""; // We need to use the DB builder for a custom query $db = new Database(); $query = $db->query('SELECT DATE_FORMAT(incident_dateadd, \'%Y\') AS incident_dateadd FROM incident WHERE incident_active = 1 GROUP BY DATE_FORMAT(incident_dateadd, \'%Y\') ORDER BY incident_dateadd'); foreach ($query as $slider_date) { $startDate .= "<optgroup label=\"" . $slider_date->incident_dateadd . "\">"; for ($i = 1; $i <= 12; $i++) { if ($i < 10) { $i = "0" . $i; } $startDate .= "<option value=\"" . strtotime($slider_date->incident_dateadd . "-" . $i . "-01") . "\">" . date('M', mktime(0, 0, 0, $i, 1)) . " " . $slider_date->incident_dateadd . "</option>"; } $startDate .= "</optgroup>"; $endDate .= "<optgroup label=\"" . $slider_date->incident_dateadd . "\">"; for ($i = 1; $i <= 12; $i++) { if ($i < 10) { $i = "0" . $i; } $endDate .= "<option value=\"" . strtotime($slider_date->incident_dateadd . "-" . $i . "-" . date('t', mktime(0, 0, 0, $i, 1))) . "\""; if ($i == 12) { $endDate .= " selected=\"selected\" "; } $endDate .= ">" . date('M', mktime(0, 0, 0, $i, 1)) . " " . $slider_date->incident_dateadd . "</option>"; } $endDate .= "</optgroup>"; } $this->template->content->startDate = $startDate; $this->template->content->endDate = $endDate; // get graph data // could not use DB query builder. It does not support parentheses yet $graph_data = array(); $all_graphs = Incident_Model::get_incidents_by_interval('month'); $this->template->content->all_graphs = $all_graphs; // Javascript Header $this->template->header->map_enabled = TRUE; $this->template->header->main_page = TRUE; // Cluster Reports on Map? $clustering = Kohana::config('settings.allow_clustering'); if ($clustering == 1) { $this->template->header->js = new View('main_cluster_js'); } else { $this->template->header->js = new View('main_js'); } $this->template->header->js->default_map = Kohana::config('settings.default_map'); $this->template->header->js->default_zoom = Kohana::config('settings.default_zoom'); $this->template->header->js->latitude = Kohana::config('settings.default_lat'); $this->template->header->js->longitude = Kohana::config('settings.default_lon'); $this->template->header->js->graph_data = $graph_data; $this->template->header->js->all_graphs = $all_graphs; $this->template->header->js->categories = $categories; // Pack the javascript using the javascriptpacker helper $myPacker = new javascriptpacker($this->template->header->js, 'Normal', false, false); $this->template->header->js = $myPacker->pack(); }
public function index() { $this->template->header->this_page = 'home'; $this->template->content = new View('main'); // Get all active top level categories $parent_categories = array(); foreach (ORM::factory('category')->where('category_visible', '1')->where('parent_id', '0')->find_all() as $category) { // Get The Children $children = array(); foreach ($category->children as $child) { $children[$child->id] = array($child->category_title, $child->category_color); } // Put it all together $parent_categories[$category->id] = array($category->category_title, $category->category_color, $children); } $this->template->content->categories = $parent_categories; // Get all active Layers (KMZ/KML) $layers = array(); $config_layers = Kohana::config('map.layers'); // use config/map layers if set if ($config_layers == $layers) { foreach (ORM::factory('layer')->where('layer_visible', 1)->find_all() as $layer) { $layers[$layer->id] = array($layer->layer_name, $layer->layer_color, $layer->layer_url, $layer->layer_file); } } else { $layers = $config_layers; } $this->template->content->layers = $layers; // Get all active Shares $shares = array(); foreach (ORM::factory('sharing')->where('sharing_active', 1)->where('sharing_type', 1)->find_all() as $share) { $shares[$share->id] = array($share->sharing_site_name, $share->sharing_color); } $this->template->content->shares = $shares; // Get Reports // XXX: Might need to replace magic no. 8 with a constant $this->template->content->total_items = ORM::factory('incident')->where('incident_active', '1')->limit('8')->count_all(); $this->template->content->incidents = ORM::factory('incident')->where('incident_active', '1')->limit('10')->orderby('incident_date', 'desc')->with('location')->find_all(); // Get Default Color $this->template->content->default_map_all = Kohana::config('settings.default_map_all'); // Get Twitter Hashtags $this->template->content->twitter_hashtag_array = array_filter(array_map('trim', explode(',', Kohana::config('settings.twitter_hashtags')))); // Get Report-To-Email $this->template->content->report_email = Kohana::config('settings.site_email'); // Get SMS Numbers $phone_array = array(); $sms_no1 = Kohana::config('settings.sms_no1'); $sms_no2 = Kohana::config('settings.sms_no2'); $sms_no3 = Kohana::config('settings.sms_no3'); if (!empty($sms_no1)) { $phone_array[] = $sms_no1; } if (!empty($sms_no2)) { $phone_array[] = $sms_no2; } if (!empty($sms_no3)) { $phone_array[] = $sms_no3; } $this->template->content->phone_array = $phone_array; // Get RSS News Feeds $this->template->content->feeds = ORM::factory('feed_item')->limit('10')->orderby('item_date', 'desc')->find_all(); // Get The START, END and most ACTIVE Incident Dates $startDate = ""; $endDate = ""; $active_month = 0; $active_startDate = 0; $active_endDate = 0; $db = new Database(); // First Get The Most Active Month $query = $db->query('SELECT incident_date, count(*) AS incident_count FROM ' . $this->table_prefix . 'incident WHERE incident_active = 1 GROUP BY DATE_FORMAT(incident_date, \'%Y-%m\') ORDER BY incident_count DESC LIMIT 1'); foreach ($query as $query_active) { $active_month = date('n', strtotime($query_active->incident_date)); $active_year = date('Y', strtotime($query_active->incident_date)); $active_startDate = strtotime($active_year . "-" . $active_month . "-01"); $active_endDate = strtotime($active_year . "-" . $active_month . "-" . date('t', mktime(0, 0, 0, $active_month, 1)) . " 23:59:59"); } // Next, Get the Range of Years $query = $db->query('SELECT DATE_FORMAT(incident_date, \'%Y\') AS incident_date FROM ' . $this->table_prefix . 'incident WHERE incident_active = 1 GROUP BY DATE_FORMAT(incident_date, \'%Y\') ORDER BY incident_date'); foreach ($query as $slider_date) { $years = $slider_date->incident_date; $startDate .= "<optgroup label=\"" . $years . "\">"; for ($i = 1; $i <= 12; $i++) { if ($i < 10) { $i = "0" . $i; } $startDate .= "<option value=\"" . strtotime($years . "-" . $i . "-01") . "\""; if ($active_month && (int) $i == $active_month - 1) { $startDate .= " selected=\"selected\" "; } $startDate .= ">" . date('M', mktime(0, 0, 0, $i, 1)) . " " . $years . "</option>"; } $startDate .= "</optgroup>"; $endDate .= "<optgroup label=\"" . $years . "\">"; for ($i = 1; $i <= 12; $i++) { if ($i < 10) { $i = "0" . $i; } $endDate .= "<option value=\"" . strtotime($years . "-" . $i . "-" . date('t', mktime(0, 0, 0, $i, 1)) . " 23:59:59") . "\""; // Focus on the most active month or set December as month of endDate if ($active_month && (int) $i == $active_month + 1 || $i == 12 && preg_match('/selected/', $endDate) == 0) { $endDate .= " selected=\"selected\" "; } $endDate .= ">" . date('M', mktime(0, 0, 0, $i, 1)) . " " . $years . "</option>"; } $endDate .= "</optgroup>"; } $this->template->content->startDate = $startDate; $this->template->content->endDate = $endDate; // get graph data // could not use DB query builder. It does not support parentheses yet $graph_data = array(); $all_graphs = Incident_Model::get_incidents_by_interval('month'); $daily_graphs = Incident_Model::get_incidents_by_interval('day'); $weekly_graphs = Incident_Model::get_incidents_by_interval('week'); $hourly_graphs = Incident_Model::get_incidents_by_interval('hour'); $this->template->content->all_graphs = $all_graphs; $this->template->content->daily_graphs = $daily_graphs; // If we are looking at the standard street map set by user if (!isset($_GET['3dmap'])) { //echo 'STREET MAP'; // Javascript Header $this->template->header->map_enabled = 'streetmap'; $this->template->content->map_enabled = 'streetmap'; $this->template->content->map_container = 'map'; $this->template->header->main_page = TRUE; $this->template->header->validator_enabled = TRUE; // Map Settings $clustering = Kohana::config('settings.allow_clustering'); $marker_radius = Kohana::config('map.marker_radius'); $marker_opacity = Kohana::config('map.marker_opacity'); $marker_stroke_width = Kohana::config('map.marker_stroke_width'); $marker_stroke_opacity = Kohana::config('map.marker_stroke_opacity'); // pdestefanis - allows to restrict the number of zoomlevels available $numZoomLevels = Kohana::config('map.numZoomLevels'); $minZoomLevel = Kohana::config('map.minZoomLevel'); $maxZoomLevel = Kohana::config('map.maxZoomLevel'); // pdestefanis - allows to limit the extents of the map $lonFrom = Kohana::config('map.lonFrom'); $latFrom = Kohana::config('map.latFrom'); $lonTo = Kohana::config('map.lonTo'); $latTo = Kohana::config('map.latTo'); $this->template->header->js = $clustering ? new View('main_cluster_js') : new View('main_cluster_js'); if ($clustering == 1) { //$this->template->header->js->cluster = "true"; // not used?? $this->template->header->js->default_json_url = "json_cluster"; } else { //$this->template->header->js->cluster = "false"; // not used?? $this->template->header->js->default_json_url = "json"; } $this->template->header->js->marker_radius = $marker_radius >= 1 && $marker_radius <= 10 ? $marker_radius : 5; $this->template->header->js->marker_opacity = $marker_opacity >= 1 && $marker_opacity <= 10 ? $marker_opacity * 0.1 : 0.9; $this->template->header->js->marker_stroke_width = $marker_stroke_width >= 1 && $marker_stroke_width <= 5 ? $marker_stroke_width : 2; $this->template->header->js->marker_stroke_opacity = $marker_stroke_opacity >= 1 && $marker_stroke_opacity <= 10 ? $marker_stroke_opacity * 0.1 : 0.9; // pdestefanis - allows to restrict the number of zoomlevels available $this->template->header->js->numZoomLevels = $numZoomLevels; $this->template->header->js->minZoomLevel = $minZoomLevel; $this->template->header->js->maxZoomLevel = $maxZoomLevel; // pdestefanis - allows to limit the extents of the map $this->template->header->js->lonFrom = $lonFrom; $this->template->header->js->latFrom = $latFrom; $this->template->header->js->lonTo = $lonTo; $this->template->header->js->latTo = $latTo; $this->template->header->js->default_map = Kohana::config('settings.default_map'); $this->template->header->js->default_zoom = Kohana::config('settings.default_zoom'); $this->template->header->js->latitude = Kohana::config('settings.default_lat'); $this->template->header->js->longitude = Kohana::config('settings.default_lon'); $this->template->header->js->graph_data = $graph_data; $this->template->header->js->all_graphs = $all_graphs; $this->template->header->js->daily_graphs = $daily_graphs; $this->template->header->js->hourly_graphs = $hourly_graphs; $this->template->header->js->weekly_graphs = $weekly_graphs; $this->template->header->js->default_map_all = Kohana::config('settings.default_map_all'); // $this->template->header->js->active_startDate = $active_startDate; $this->template->header->js->active_endDate = $active_endDate; // If we are viewing the 3D map } else { //echo '3D MAP'; // Javascript Header $this->template->header->map_enabled = '3dmap'; $this->template->content->map_enabled = '3dmap'; $this->template->content->map_container = 'map3d'; $this->template->header->main_page = FALSE; // Setting to false because we don't want all the external controls that the street map has $this->template->header->js = new View('main_3d_js'); $this->template->header->js->default_zoom = Kohana::config('settings.default_zoom'); $this->template->header->js->latitude = Kohana::config('settings.default_lat'); $this->template->header->js->longitude = Kohana::config('settings.default_lon'); // Override API URL $this->template->header->api_url = '<script src="http://www.google.com/jsapi?key=' . Kohana::config('settings.api_google') . '"> </script>'; } $myPacker = new javascriptpacker($this->template->header->js, 'Normal', false, false); $this->template->header->js = $myPacker->pack(); }
public function timeline() { $this->auto_render = FALSE; $this->template = new View('json/timeline'); //$this->template->content = new View('json/timeline'); $interval = 'day'; $start_date = NULL; $end_date = NULL; $active = 'true'; if (isset($_GET['i'])) { $interval = $_GET['i']; } if (isset($_GET['s'])) { $start_date = $_GET['s']; } if (isset($_GET['e'])) { $end_date = $_GET['e']; } if (isset($_GET['active'])) { $active = $_GET['active']; } // get graph data $graph_data = array(); $all_graphs = Incident_Model::get_incidents_by_interval($interval, $start_date, $end_date, $active); echo $all_graphs; }
public function index() { $this->template->header->this_page = 'home'; $this->template->content = new View('main'); //get images from flickr $flickr = new PhpFlickr('7ffd3c4b9d9f3a486b67124d5b530f11'); $haiti_photos = $flickr->photos_search(array('text' => 'earthquake in haiti', 'per_page' => 12)); $this->template->content->flickr = $flickr; $this->template->content->haiti_photos = $haiti_photos; // Get all active top level categories $parent_categories = array(); foreach (ORM::factory('category')->where('category_visible', '1')->where('parent_id', '0')->find_all() as $category) { // Get The Children $children = array(); foreach ($category->children as $child) { $children[$child->id] = array($child->category_title, $child->category_color, $child->category_image); } // Put it all together $parent_categories[$category->id] = array($category->category_title, $category->category_color, $category->category_image, $children); } $this->template->content->categories = $parent_categories; // Get all active Layers (KMZ/KML) $layers = array(); foreach (ORM::factory('layer')->where('layer_visible', 1)->find_all() as $layer) { $layers[$layer->id] = array($layer->layer_name, $layer->layer_color, $layer->layer_url, $layer->layer_file); } $this->template->content->layers = $layers; // Get all active Shares $shares = array(); foreach (ORM::factory('sharing')->where('sharing_active', 1)->where('sharing_type', 1)->find_all() as $share) { $shares[$share->id] = array($share->sharing_site_name, $share->sharing_color); } $this->template->content->shares = $shares; // Get Reports // XXX: Might need to replace magic no. 8 with a constant $this->template->content->total_items = ORM::factory('incident')->where('incident_active', '1')->limit('8')->count_all(); $this->template->content->incidents = ORM::factory('incident')->where('incident_active', '1')->limit('14')->orderby('incident_date', 'desc')->with('location')->find_all(); // Get quick stats for "Latest Activity" // note: Kohana ORM doesn't support these fancy date search features $this->template->content->latest_activity_today = count($this->db->query('SELECT id FROM incident WHERE incident_dateadd >= DATE_SUB(CURDATE(),INTERVAL 0 DAY);')); $this->template->content->latest_activity_yesterday = count($this->db->query('SELECT id FROM incident WHERE incident_dateadd >= DATE_SUB(CURDATE(),INTERVAL 1 DAY) AND incident_dateadd < DATE_SUB(CURDATE(),INTERVAL 0 DAY);')); $this->template->content->latest_activity_week = count($this->db->query('SELECT id FROM incident WHERE incident_dateadd >= DATE_SUB(CURDATE(),INTERVAL 1 WEEK);')); $this->template->content->latest_activity_total_from_sms = Incident_Model::num_incidents_by_sms(); // End getting of quick stats for "Latest Activity" // Get Default Color $this->template->content->default_map_all = Kohana::config('settings.default_map_all'); // Get Twitter Hashtags $this->template->content->twitter_hashtag_array = array_filter(array_map('trim', explode(',', Kohana::config('settings.twitter_hashtags')))); // Get Report-To-Email $this->template->content->report_email = Kohana::config('settings.site_email'); // Get SMS Numbers $phone_array = array(); $sms_no1 = Kohana::config('settings.sms_no1'); $sms_no2 = Kohana::config('settings.sms_no2'); $sms_no3 = Kohana::config('settings.sms_no3'); if (!empty($sms_no1)) { $phone_array[] = $sms_no1; } if (!empty($sms_no2)) { $phone_array[] = $sms_no2; } if (!empty($sms_no3)) { $phone_array[] = $sms_no3; } $this->template->content->phone_array = $phone_array; $this->template->header->phone_array = $phone_array; // Because we need some custom language around these numbers, // I'm just sending them straight to the template for "hardcoding" $this->template->content->sms_no1 = $sms_no1; $this->template->content->sms_no2 = $sms_no2; $this->template->header->sms_no1 = $sms_no1; $this->template->header->sms_no2 = $sms_no2; // Get RSS News Feeds but don't include Global Voices (8) $this->template->content->feeds = ORM::factory('feed_item')->limit('10')->where('feed_id !=', '8')->orderby('item_date', 'desc')->find_all(); // Get Global Voices Feed $this->template->content->gvfeeds = ORM::factory('feed_item')->limit('10')->where('feed_id', '8')->orderby('item_date', 'desc')->find_all(); // Get The START, END and most ACTIVE Incident Dates $startDate = ""; $endDate = ""; $active_month = 0; $active_startDate = 0; $active_endDate = 0; $db = new Database(); // First Get The Most Active Month $query = $db->query('SELECT incident_date, count(*) AS incident_count FROM incident WHERE incident_active = 1 GROUP BY DATE_FORMAT(incident_date, \'%Y-%m\') ORDER BY incident_count DESC LIMIT 1'); foreach ($query as $query_active) { $active_month = date('n', strtotime($query_active->incident_date)); $active_year = date('Y', strtotime($query_active->incident_date)); $active_startDate = strtotime($active_year . "-" . $active_month . "-01"); $active_endDate = strtotime($active_year . "-" . $active_month . "-" . date('t', mktime(0, 0, 0, $active_month, 1)) . " 23:59:59"); } /** HARDCODED SLIDER SET UP **/ // We'll Hardcode in the Start/End Dates $timeframe_start = strtotime("2010-01-12", 0); $timeframe_stop = strtotime(date("Y-m-d"), 0); $active_startDate = $timeframe_start; $active_endDate = $timeframe_stop + 86399; $days = floor(($timeframe_stop - $timeframe_start) / 86400); $startDate = "<optgroup label=\"2010\">"; $endDate = "<optgroup label=\"2010\">"; for ($i = 0; $i <= $days; $i++) { $startDate .= "<option value=\"" . $timeframe_start . "\""; if ($i == 0) { $startDate .= " selected=\"selected\" "; } $startDate .= ">" . date('M j', $timeframe_start) . " 2010</option>"; $timeframe_stop = $timeframe_start + 86399; $endDate .= "<option value=\"" . $timeframe_stop . "\""; if ($i == $days) { $endDate .= " selected=\"selected\" "; } $endDate .= ">" . date('M j', $timeframe_stop) . " 2010</option>"; $timeframe_start = $timeframe_start + 86400; } $startDate .= "</optgroup>"; $endDate .= "</optgroup>"; /** OLD SLIDER SET UP **/ // Next, Get the Range of Years // $query = $db->query('SELECT DATE_FORMAT(incident_date, \'%Y\') AS incident_date FROM incident WHERE incident_active = 1 GROUP BY DATE_FORMAT(incident_date, \'%Y\') ORDER BY incident_date'); $query = array(); foreach ($query as $slider_date) { $years = $slider_date->incident_date; $startDate .= "<optgroup label=\"" . $years . "\">"; for ($i = 1; $i <= 12; $i++) { if ($i < 10) { $i = "0" . $i; } $startDate .= "<option value=\"" . strtotime($years . "-" . $i . "-01") . "\""; if ($active_month && (int) $i == $active_month - 1) { $startDate .= " selected=\"selected\" "; } $startDate .= ">" . date('M', mktime(0, 0, 0, $i, 1)) . " " . $years . "</option>"; } $startDate .= "</optgroup>"; $endDate .= "<optgroup label=\"" . $years . "\">"; for ($i = 1; $i <= 12; $i++) { if ($i < 10) { $i = "0" . $i; } $endDate .= "<option value=\"" . strtotime($years . "-" . $i . "-" . date('t', mktime(0, 0, 0, $i, 1)) . " 23:59:59") . "\""; if ($active_month && (int) $i == $active_month + 1 || $i == 12) { $endDate .= " selected=\"selected\" "; } $endDate .= ">" . date('M', mktime(0, 0, 0, $i, 1)) . " " . $years . "</option>"; } $endDate .= "</optgroup>"; } $this->template->content->startDate = $startDate; $this->template->content->endDate = $endDate; //$this->template->content->startDate = '<select name="startDate" id="startDate"><optgroup label="2010"><option value="1262325600">Jan 2010</option></optgroup></select>'; //$this->template->content->endDate = '<select name="endDate" id="endDate"><optgroup label="2010"><option value="1265003999">Jan 2010</option><option value="1267423199" selected="selected" >Feb 2010</option></optgroup></select>'; // get graph data // could not use DB query builder. It does not support parentheses yet $graph_data = array(); $all_graphs = Incident_Model::get_incidents_by_interval('month'); $daily_graphs = Incident_Model::get_incidents_by_interval('day'); $weekly_graphs = Incident_Model::get_incidents_by_interval('week'); $hourly_graphs = Incident_Model::get_incidents_by_interval('hour'); $this->template->content->all_graphs = $all_graphs; $this->template->content->daily_graphs = $daily_graphs; // If we are looking at the standard street map set by user if (!isset($_GET['3dmap'])) { //echo 'STREET MAP'; // Javascript Header $this->template->header->map_enabled = 'streetmap'; $this->template->content->map_enabled = 'streetmap'; $this->template->content->map_container = 'map'; $this->template->header->main_page = TRUE; $this->template->header->validator_enabled = TRUE; // Map Settings $clustering = Kohana::config('settings.allow_clustering'); $marker_radius = Kohana::config('map.marker_radius'); $marker_opacity = Kohana::config('map.marker_opacity'); $marker_stroke_width = Kohana::config('map.marker_stroke_width'); $marker_stroke_opacity = Kohana::config('map.marker_stroke_opacity'); $this->template->header->js = $clustering ? new View('main_cluster_js') : new View('main_js'); $this->template->header->js->cluster = $clustering == 1 ? "true" : "false"; $this->template->header->js->marker_radius = $marker_radius >= 1 && $marker_radius <= 10 ? $marker_radius : 5; $this->template->header->js->marker_opacity = $marker_opacity >= 1 && $marker_opacity <= 10 ? $marker_opacity * 0.1 : 0.9; $this->template->header->js->marker_stroke_width = $marker_stroke_width >= 1 && $marker_stroke_width <= 5 ? $marker_stroke_width : 2; $this->template->header->js->marker_stroke_opacity = $marker_stroke_opacity >= 1 && $marker_stroke_opacity <= 10 ? $marker_stroke_opacity * 0.1 : 0.9; $this->template->header->js->default_map = Kohana::config('settings.default_map'); $this->template->header->js->default_zoom = Kohana::config('settings.default_zoom'); $this->template->header->js->latitude = Kohana::config('settings.default_lat'); $this->template->header->js->longitude = Kohana::config('settings.default_lon'); $this->template->header->js->graph_data = $graph_data; $this->template->header->js->all_graphs = $all_graphs; $this->template->header->js->daily_graphs = $daily_graphs; $this->template->header->js->hourly_graphs = $hourly_graphs; $this->template->header->js->weekly_graphs = $weekly_graphs; $this->template->header->js->default_map_all = Kohana::config('settings.default_map_all'); // $this->template->header->js->active_startDate = $active_startDate; $this->template->header->js->active_endDate = $active_endDate; // If we are viewing the 3D map } else { //echo '3D MAP'; // Javascript Header $this->template->header->map_enabled = '3dmap'; $this->template->content->map_enabled = '3dmap'; $this->template->content->map_container = 'map3d'; $this->template->header->main_page = FALSE; // Setting to false because we don't want all the external controls that the street map has $this->template->header->js = new View('main_3d_js'); $this->template->header->js->default_zoom = Kohana::config('settings.default_zoom'); $this->template->header->js->latitude = Kohana::config('settings.default_lat'); $this->template->header->js->longitude = Kohana::config('settings.default_lon'); // Override API URL $this->template->header->api_url = '<script src="http://www.google.com/jsapi?key=' . Kohana::config('settings.api_google') . '"> </script>'; } $footerjs = new View('footer_form_js'); // Pack the javascript using the javascriptpacker helper $this->template->header->js .= $footerjs; $myPacker = new javascriptpacker($this->template->header->js, 'Normal', true, false); $this->template->header->js = $myPacker->pack(); }
public function index() { $this->template->header->this_page = 'home'; $this->template->content = new View('main'); // Get all active categories $categories = array(); foreach (ORM::factory('category')->where('category_visible', '1')->find_all() as $category) { // Create a list of all categories $categories[$category->id] = array($category->category_title, $category->category_color); } $this->template->content->categories = $categories; // Get all active Shares $shares = array(); foreach (ORM::factory('sharing')->where('sharing_active', 1)->where('sharing_type', 1)->find_all() as $share) { $shares[$share->id] = array($share->sharing_site_name, $share->sharing_color); } $this->template->content->shares = $shares; // Get Reports // XXX: Might need to replace magic no. 8 with a constant $this->template->content->total_items = ORM::factory('incident')->where('incident_active', '1')->limit('8')->count_all(); $this->template->content->incidents = ORM::factory('incident')->where('incident_active', '1')->limit('10')->orderby('incident_date', 'desc')->find_all(); // Get Default Color $this->template->content->default_map_all = Kohana::config('settings.default_map_all'); // Get Twitter Hashtags $this->template->content->twitter_hashtag_array = array_filter(array_map('trim', explode(',', Kohana::config('settings.twitter_hashtags')))); // Get Report-To-Email $this->template->content->report_email = Kohana::config('email.username'); // Get SMS Numbers $phone_array = array(); $sms_no1 = Kohana::config('settings.sms_no1'); $sms_no2 = Kohana::config('settings.sms_no2'); $sms_no3 = Kohana::config('settings.sms_no3'); if (!empty($sms_no1)) { $phone_array[] = $sms_no1; } if (!empty($sms_no2)) { $phone_array[] = $sms_no2; } if (!empty($sms_no3)) { $phone_array[] = $sms_no3; } $this->template->content->phone_array = $phone_array; // Get RSS News Feeds $this->template->content->feeds = ORM::factory('feed_item')->limit('10')->orderby('item_date', 'desc')->find_all(); // Get Slider Dates By Year $startDate = ""; $endDate = ""; // We need to use the DB builder for a custom query $db = new Database(); $query = $db->query('SELECT DATE_FORMAT(incident_date, \'%Y\') AS incident_date FROM incident WHERE incident_active = 1 GROUP BY DATE_FORMAT(incident_date, \'%Y\') ORDER BY incident_date'); foreach ($query as $slider_date) { $startDate .= "<optgroup label=\"" . $slider_date->incident_date . "\">"; for ($i = 1; $i <= 12; $i++) { if ($i < 10) { $i = "0" . $i; } $startDate .= "<option value=\"" . strtotime($slider_date->incident_date . "-" . $i . "-01") . "\">" . date('M', mktime(0, 0, 0, $i, 1)) . " " . $slider_date->incident_date . "</option>"; } $startDate .= "</optgroup>"; $endDate .= "<optgroup label=\"" . $slider_date->incident_date . "\">"; for ($i = 1; $i <= 12; $i++) { if ($i < 10) { $i = "0" . $i; } $endDate .= "<option value=\"" . strtotime($slider_date->incident_date . "-" . $i . "-" . date('t', mktime(0, 0, 0, $i, 1))) . "\""; if ($i == 12) { $endDate .= " selected=\"selected\" "; } $endDate .= ">" . date('M', mktime(0, 0, 0, $i, 1)) . " " . $slider_date->incident_date . "</option>"; } $endDate .= "</optgroup>"; } $this->template->content->startDate = $startDate; $this->template->content->endDate = $endDate; // get graph data // could not use DB query builder. It does not support parentheses yet $graph_data = array(); $all_graphs = Incident_Model::get_incidents_by_interval('month'); $daily_graphs = Incident_Model::get_incidents_by_interval('day'); $weekly_graphs = Incident_Model::get_incidents_by_interval('week'); $hourly_graphs = Incident_Model::get_incidents_by_interval('hour'); $this->template->content->all_graphs = $all_graphs; $this->template->content->daily_graphs = $daily_graphs; // Javascript Header $this->template->header->map_enabled = TRUE; $this->template->header->main_page = TRUE; // Map Settings $clustering = Kohana::config('settings.allow_clustering'); $marker_radius = Kohana::config('map.marker_radius'); $marker_opacity = Kohana::config('map.marker_opacity'); $marker_stroke_width = Kohana::config('map.marker_stroke_width'); $marker_stroke_opacity = Kohana::config('map.marker_stroke_opacity'); $this->template->header->js = $clustering == 1 ? new View('main_cluster_js') : new View('main_js'); $this->template->header->js->marker_radius = $marker_radius >= 1 && $marker_radius <= 10 ? $marker_radius : 5; $this->template->header->js->marker_opacity = $marker_opacity >= 1 && $marker_opacity <= 10 ? $marker_opacity * 0.1 : 0.9; $this->template->header->js->marker_stroke_width = $marker_stroke_width >= 1 && $marker_stroke_width <= 5 ? $marker_stroke_width : 2; $this->template->header->js->marker_stroke_opacity = $marker_stroke_opacity >= 1 && $marker_stroke_opacity <= 10 ? $marker_stroke_opacity * 0.1 : 0.9; $this->template->header->js->default_map = Kohana::config('settings.default_map'); $this->template->header->js->default_zoom = Kohana::config('settings.default_zoom'); $this->template->header->js->latitude = Kohana::config('settings.default_lat'); $this->template->header->js->longitude = Kohana::config('settings.default_lon'); $this->template->header->js->graph_data = $graph_data; $this->template->header->js->all_graphs = $all_graphs; $this->template->header->js->daily_graphs = $daily_graphs; $this->template->header->js->hourly_graphs = $hourly_graphs; $this->template->header->js->weekly_graphs = $weekly_graphs; $this->template->header->js->categories = $categories; $this->template->header->js->default_map_all = Kohana::config('settings.default_map_all'); //$this->template->header->footerjs = new View('footer_form_js'); $footerjs = new View('footer_form_js'); // Pack the javascript using the javascriptpacker helper $myPacker = new javascriptpacker($footerjs, 'Normal', false, false); $footerjs = $myPacker->pack(); $this->template->header->js .= $footerjs; }
public function index() { $this->template->header->this_page = 'home'; $this->template->content = new View('main'); $this->template->content->set("user", $this->user); // What instances to show? $db = new Database(); $dbs = array(); $show_user = $this->user ? " OR user_id = " . $this->user->id . " " : ""; $sites = $db->query("SELECT id,dbdatabase,sitename,subdomain,tagline FROM sites WHERE is_approved AND (is_public {$show_user})"); $this->template->content->set("sites", $sites); $shares = array(); // Get all active top level categories $parent_categories = array(); foreach ($sites as $category) { // Create a list of all sites $parent_categories[$category->id] = array($category->sitename, $this->_id2color($category->id)); $shares[$category->id] = array($category->sitename, $this->_id2color($category->id), $category->subdomain); array_push($dbs, $category->dbdatabase); } $this->template->content->categories = $parent_categories; // Get all active Layers (KMZ/KML) $layers = array(); foreach (ORM::factory('layer')->where('layer_visible', 1)->find_all() as $layer) { $layers[$layer->id] = array($layer->layer_name, $layer->layer_color, $layer->layer_url, $layer->layer_file); } $this->template->content->layers = $layers; // Get all active Shares $this->template->content->shares = $shares; // Get Reports // XXX: Might need to replace magic no. 8 with a constant $this->template->content->total_items = ORM::factory('incident')->where('incident_active', '1')->limit('8')->count_all(); $this->template->content->incidents = ORM::factory('incident')->where('incident_active', '1')->limit('10')->orderby('incident_date', 'desc')->with('location')->find_all(); // Get Default Color $this->template->content->default_map_all = Kohana::config('settings.default_map_all'); // Get Twitter Hashtags $this->template->content->twitter_hashtag_array = array_filter(array_map('trim', explode(',', Kohana::config('settings.twitter_hashtags')))); // Get Report-To-Email $this->template->content->report_email = Kohana::config('settings.site_email'); // Get SMS Numbers $phone_array = array(); $sms_no1 = Kohana::config('settings.sms_no1'); $sms_no2 = Kohana::config('settings.sms_no2'); $sms_no3 = Kohana::config('settings.sms_no3'); if (!empty($sms_no1)) { $phone_array[] = $sms_no1; } if (!empty($sms_no2)) { $phone_array[] = $sms_no2; } if (!empty($sms_no3)) { $phone_array[] = $sms_no3; } $this->template->content->phone_array = $phone_array; // Get RSS News Feeds $this->template->content->feeds = ORM::factory('feed_item')->limit('10')->orderby('item_date', 'desc')->find_all(); // Get The START, END and most ACTIVE Incident Dates $startDate = ""; $endDate = ""; $active_month = 0; $active_startDate = 0; $active_endDate = 0; // First Get The Most Active Month $query = $db->query('SELECT incident_date, count(*) AS incident_count FROM incident WHERE incident_active = 1 GROUP BY DATE_FORMAT(incident_date, \'%Y-%m\') ORDER BY incident_count DESC LIMIT 1'); foreach ($query as $query_active) { $active_month = date('n', strtotime($query_active->incident_date)); $active_year = date('Y', strtotime($query_active->incident_date)); $active_startDate = strtotime($active_year . "-" . $active_month . "-01"); $active_endDate = strtotime($active_year . "-" . $active_month . "-" . date('t', mktime(0, 0, 0, $active_month, 1)) . " 23:59:59"); } // Next, Get the Range of Years $query = $db->query('SELECT DATE_FORMAT(incident_date, \'%Y\') AS incident_date FROM incident WHERE incident_active = 1 GROUP BY DATE_FORMAT(incident_date, \'%Y\') ORDER BY incident_date'); foreach ($query as $slider_date) { $years = $slider_date->incident_date; $startDate .= "<optgroup label=\"" . $years . "\">"; for ($i = 1; $i <= 12; $i++) { if ($i < 10) { $i = "0" . $i; } $startDate .= "<option value=\"" . strtotime($years . "-" . $i . "-01") . "\""; if ($active_month && (int) $i == $active_month - 1) { $startDate .= " selected=\"selected\" "; } $startDate .= ">" . date('M', mktime(0, 0, 0, $i, 1)) . " " . $years . "</option>"; } $startDate .= "</optgroup>"; $endDate .= "<optgroup label=\"" . $years . "\">"; for ($i = 1; $i <= 12; $i++) { if ($i < 10) { $i = "0" . $i; } $endDate .= "<option value=\"" . strtotime($years . "-" . $i . "-" . date('t', mktime(0, 0, 0, $i, 1)) . " 23:59:59") . "\""; if ($active_month && (int) $i == $active_month + 1 || $i == 12) { $endDate .= " selected=\"selected\" "; } $endDate .= ">" . date('M', mktime(0, 0, 0, $i, 1)) . " " . $years . "</option>"; } $endDate .= "</optgroup>"; } $this->template->content->startDate = $startDate; $this->template->content->endDate = $endDate; // get graph data // could not use DB query builder. It does not support parentheses yet $graph_data = array(); $all_graphs = Incident_Model::get_incidents_by_interval('month'); $daily_graphs = Incident_Model::get_incidents_by_interval('day'); $weekly_graphs = Incident_Model::get_incidents_by_interval('week'); $hourly_graphs = Incident_Model::get_incidents_by_interval('hour'); $this->template->content->all_graphs = $all_graphs; $this->template->content->daily_graphs = $daily_graphs; // If we are looking at the standard street map set by user if (!isset($_GET['3dmap'])) { //echo 'STREET MAP'; // Javascript Header $this->template->header->map_enabled = 'streetmap'; $this->template->content->map_enabled = 'streetmap'; $this->template->content->map_container = 'map'; $this->template->header->main_page = TRUE; $this->template->header->validator_enabled = TRUE; // Map Settings $clustering = Kohana::config('settings.allow_clustering'); $marker_radius = Kohana::config('map.marker_radius'); $marker_opacity = Kohana::config('map.marker_opacity'); $marker_stroke_width = Kohana::config('map.marker_stroke_width'); $marker_stroke_opacity = Kohana::config('map.marker_stroke_opacity'); $this->template->header->js = new View('main_cluster_js'); $this->template->header->js->cluster = $clustering == 1 ? "true" : "false"; $this->template->header->js->marker_radius = $marker_radius >= 1 && $marker_radius <= 10 ? $marker_radius : 5; $this->template->header->js->marker_opacity = $marker_opacity >= 1 && $marker_opacity <= 10 ? $marker_opacity * 0.1 : 0.9; $this->template->header->js->marker_stroke_width = $marker_stroke_width >= 1 && $marker_stroke_width <= 5 ? $marker_stroke_width : 2; $this->template->header->js->marker_stroke_opacity = $marker_stroke_opacity >= 1 && $marker_stroke_opacity <= 10 ? $marker_stroke_opacity * 0.1 : 0.9; $this->template->header->js->default_map = Kohana::config('settings.default_map'); $this->template->header->js->default_zoom = Kohana::config('settings.default_zoom'); $this->template->header->js->latitude = Kohana::config('settings.default_lat'); $this->template->header->js->longitude = Kohana::config('settings.default_lon'); $this->template->header->js->graph_data = $graph_data; $this->template->header->js->all_graphs = $all_graphs; $this->template->header->js->daily_graphs = $daily_graphs; $this->template->header->js->hourly_graphs = $hourly_graphs; $this->template->header->js->weekly_graphs = $weekly_graphs; $this->template->header->js->default_map_all = Kohana::config('settings.default_map_all'); // $this->template->header->js->active_startDate = $active_startDate; $this->template->header->js->active_endDate = $active_endDate; // If we are viewing the 3D map } else { //echo '3D MAP'; // Javascript Header $this->template->header->map_enabled = '3dmap'; $this->template->content->map_enabled = '3dmap'; $this->template->content->map_container = 'map3d'; $this->template->header->main_page = FALSE; // Setting to false because we don't want all the external controls that the street map has $this->template->header->js = new View('main_3d_js'); $this->template->header->js->default_zoom = Kohana::config('settings.default_zoom'); $this->template->header->js->latitude = Kohana::config('settings.default_lat'); $this->template->header->js->longitude = Kohana::config('settings.default_lon'); // Override API URL $this->template->header->api_url = '<script src="http://www.google.com/jsapi?key=' . Kohana::config('settings.api_google') . '"> </script>'; } $footerjs = new View('footer_form_js'); // Pack the javascript using the javascriptpacker helper $this->template->header->js .= $footerjs; $myPacker = new javascriptpacker($this->template->header->js, 'Normal', false, false); $this->template->header->js = $myPacker->pack(); }
public function index() { $this->template->header->this_page = 'home'; $this->template->content = new View($this->view_lang . '/main'); // Get all active categories $categories = array(); foreach (ORM::factory('category')->where('category_visible', '1')->find_all() as $category) { // Create a list of all categories $categories[$category->id] = array($category->category_title, $category->category_color); } $this->template->content->categories = $categories; // See if we posted anything $post = $this->input->post(); $this->template->content->post = $post; $this->template->content->user_signup_good = false; // Save the user signup data, if availible if ($post) { $user_signup = ORM::factory('user_signup'); // If the post data validates using the rules setup in the model. if ($user_signup->validate($post)) { $this->template->content->user_signup_good = true; $user_signup->save(); } else { $this->template->content->post = $post; } } // Get Reports // XXX: Might need to replace magic no. 8 with a constant $this->template->content->total_items = ORM::factory('incident')->where('incident_active', '1')->limit('8')->count_all(); $this->template->content->incidents = ORM::factory('incident')->where('incident_active', '1')->limit('10')->orderby('incident_date', 'desc')->find_all(); // Get SMS Numbers $phone_array = array(); $sms_no1 = Kohana::config('settings.sms_no1'); $sms_no2 = Kohana::config('settings.sms_no2'); $sms_no3 = Kohana::config('settings.sms_no3'); if (!empty($sms_no1)) { $phone_array[] = $sms_no1; } if (!empty($sms_no2)) { $phone_array[] = $sms_no2; } if (!empty($sms_no3)) { $phone_array[] = $sms_no3; } $this->template->content->phone_array = $phone_array; // Get the RSS blog feed $this->template->content->blog_feed = fetch_rss(Kohana::config('settings.blog_rss_url')); // Get RSS News Feeds $this->template->content->feeds = ORM::factory('feed_item')->where('feed_type', FEED_TYPE_TEXT)->limit('10')->orderby('item_date', 'desc')->find_all(); // Get video RSS feeds $this->template->content->video_feeds = ORM::factory('feed_item')->where('feed_type', FEED_TYPE_VIDEO)->limit('3')->orderby('item_date', 'desc')->find_all(); // Get photo RSS feeds $this->template->content->photo_feeds = ORM::factory('feed_item')->where('feed_type', FEED_TYPE_PHOTO)->limit('4')->orderby('item_date', 'desc')->find_all(); // Get Slider Dates By Year $startDate = ""; $endDate = ""; // Get the ladeleb.org info $cache_name = MAGPIE_CACHE_DIR . "/lade_feed"; $mtime = 0; if (file_exists($cache_name)) { $mtime = filemtime($cache_name); } $lade_reps = array(); $ctx = stream_context_create(array('http' => array('timeout' => 10))); if (!$mtime || time() - $mtime > LADE_FEED_REFRESH) { $lade_raw = @file_get_contents(LADE_FEED_URL, 0, $ctx); if (!$lade_raw) { $lade_raw = ""; } $lade_reports; preg_match_all('/<div class="NewsPTitle"><a href="(.*?)">\\n(.*?)\\n<\\/div>/', $lade_raw, $lade_reports); for ($i = 0; $i < count($lade_reports[1]); $i++) { array_push($lade_reps, array('http://www.observe.ladeleb.org' . $lade_reports[1][$i], $lade_reports[2][$i])); if ($i >= MAX_LADE_FEED) { break; } } if ($lade_raw) { file_put_contents($cache_name, serialize($lade_reps)); } else { touch($cache_name); } } else { $lade_reps = unserialize(file_get_contents($cache_name)); } $this->template->content->lade_reports = $lade_reps; // We need to use the DB builder for a custom query $db = new Database(); // Query $query = $db->query('SELECT DATE_FORMAT(incident_date, \'%Y\') AS incident_date FROM incident WHERE incident_active = 1 GROUP BY DATE_FORMAT(incident_date, \'%Y\') ORDER BY incident_date'); foreach ($query as $slider_date) { $startDate .= "<optgroup label=\"" . $slider_date->incident_date . "\">"; for ($i = START_REPORTS_MONTH; $i <= END_REPORTS_MONTH; $i++) { if ($i < 10) { $i = "0" . $i; } $startDate .= "<option value=\"" . strtotime($slider_date->incident_date . "-" . $i . "-01") . "\">" . date('M', mktime(0, 0, 0, $i, 1)) . " " . $slider_date->incident_date . "</option>"; } $startDate .= "</optgroup>"; $endDate .= "<optgroup label=\"" . $slider_date->incident_date . "\">"; for ($i = START_REPORTS_MONTH; $i <= END_REPORTS_MONTH; $i++) { if ($i < 10) { $i = "0" . $i; } $endDate .= "<option value=\"" . strtotime($slider_date->incident_date . "-" . $i . "-" . date('t', mktime(0, 0, 0, $i, 1))) . "\""; if ($i == date("n", time())) { $endDate .= " selected=\"selected\" "; } $endDate .= ">" . date('M', mktime(0, 0, 0, $i, 1)) . " " . $slider_date->incident_date . "</option>"; } $endDate .= "</optgroup>"; } $this->template->content->startDate = $startDate; $this->template->content->endDate = $endDate; // get graph data // could not use DB query builder. It does not support parentheses yet $graph_data = array(); $all_graphs = Incident_Model::get_incidents_by_interval('month'); $this->template->content->all_graphs = $all_graphs; // Javascript Header $this->template->header->map_enabled = TRUE; $this->template->header->main_page = TRUE; // Cluster Reports on Map? $clustering = Kohana::config('settings.allow_clustering'); if ($clustering == 1) { $this->template->header->js = new View('main_cluster_js'); } else { $this->template->header->js = new View('main_js'); } $this->template->header->js->default_map = Kohana::config('settings.default_map'); $this->template->header->js->default_zoom = Kohana::config('settings.default_zoom'); $this->template->header->js->latitude = Kohana::config('settings.default_lat'); $this->template->header->js->longitude = Kohana::config('settings.default_lon'); $this->template->header->js->graph_data = $graph_data; $this->template->header->js->all_graphs = $all_graphs; $this->template->header->js->categories = $categories; // Pack the javascript using the javascriptpacker helper $myPacker = new javascriptpacker($this->template->header->js, 'Normal', false, false); $this->template->header->js = $myPacker->pack(); }