public function groupmap($group_id) { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //Make sure we have a group if (!$group_id) { url::redirect('main'); } $group = ORM::factory('simplegroups_groups', $group_id)->find($group_id); if (!$group->loaded) { url::redirect('main'); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Setup the map adminmap_helper::setup_adminmap($this, "simplegroups/about_map", "simplegroups/css/simplegroupmap"); //get the categories adminmap_helper::set_categories($this, false, $group); //setup the map $clustering = Kohana::config('settings.allow_clustering'); $json_url = $clustering == 1 ? "simplegroupmap_json/cluster/{$group_id}" : "simplegroupmap_json/index/{$group_id}"; $json_timeline_url = "simplegroupmap_json/timeline/{$group_id}/"; adminmap_helper::set_map($this->template, $this->themes, $json_url, $json_timeline_url, 'simplegroups/mapview_js', 'simplegroups/frontend_map/main_map', 'simplegroups/frontend_map/main_timeline'); //setup the overlays and shares adminmap_helper::set_overlays_shares($this); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //stuff to setup the group $this->template->content->group_name = $group->name; $this->template->content->group_description = $group->description; $this->template->content->group_id = $group->id; $this->template->content->group_logo = $group->logo; $this->template->header->header_block = $this->themes->header_block(); }
public function index() { adminmap_helper::setup_adminmap($this); //get the categories adminmap_helper::set_categories($this, true, $this->group); //setup the map $clustering = Kohana::config('settings.allow_clustering'); $json_url = $clustering == 1 ? "admin/simplegroups/adminmap_json/cluster" : "admin/simplegroups/adminmap_json"; $json_timeline_url = "admin/simplegroups/adminmap_json/timeline/"; adminmap_helper::set_map($this->template, $this->template, $json_url, $json_timeline_url, 'simplegroups/mapview_js'); //setup the overlays and shares adminmap_helper::set_overlays_shares($this); }
public function index() { adminmap_helper::setup_adminmap($this); //get the categories adminmap_helper::set_categories($this, true); //setup the map $clustering = Kohana::config('settings.allow_clustering'); $json_url = ($clustering == 1) ? "json/cluster" : "json"; $json_timeline_url = "json/timeline/"; adminmap_helper::set_map($this->template, $this->template, $json_url, $json_timeline_url); //setup the overlays and shares adminmap_helper::set_overlays_shares($this); }//end index method
public function index($group_id, $width = 400) { $group = ORM::factory('simplegroups_groups', $group_id)->find($group_id); $this->template->header->this_page = 'bigmap'; $this->template->content = new View('adminmap/iframe_mapview'); $this->template->content->site_name = $group->name; //set the CSS for this plugin::add_stylesheet("adminmap/css/iframe_adminmap"); plugin::add_stylesheet("adminmap/css/jquery.hovertip-1.0"); //make sure the right java script files are used. //plugin::add_javascript("adminmap/js/jquery.address-1.4.min.js"); plugin::add_javascript("adminmap/js/jquery.flot"); plugin::add_javascript("adminmap/js/excanvas.min"); plugin::add_javascript("adminmap/js/timeline"); plugin::add_javascript("adminmap/js/jquery.hovertip-1.0"); // Cacheable Main Controller $this->is_cachable = TRUE; // Map and Slider Blocks $div_timeline = new View('adminmap/iframe_main_timeline'); // Filter::map_timeline - Modify Main Map Block Event::run('ushahidi_filter.map_timeline', $div_timeline); $this->template->content->div_timeline = $div_timeline; $this->template->content->width = $width; // Get locale $l = Kohana::config('locale.language.0'); // Get all active top level categories //$parent_categories = array(); adminmap_helper::set_categories($this, false, $group); //$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)->find_all() as $share) { $shares[$share->id] = array($share->sharing_name, $share->sharing_color); } $this->template->content->shares = $shares; // Get Default Color $this->template->content->default_map_all = Kohana::config('settings.default_map_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"); } //run some custom events for the timeline plugin Event::run('ushahidi_filter.active_startDate', $active_startDate); Event::run('ushahidi_filter.active_endDate', $active_endDate); Event::run('ushahidi_filter.active_month', $active_month); // 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>"; } //run more custom events for the timeline plugin Event::run('ushahidi_filter.startDate', $startDate); Event::run('ushahidi_filter.endDate', $endDate); $this->template->content->div_timeline->startDate = $startDate; $this->template->content->div_timeline->endDate = $endDate; // Javascript Header $this->themes->map_enabled = true; $this->themes->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'); // 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->themes->js = new View('adminmap/iframe_mapview_js'); $this->themes->js->json_url = $clustering == 1 ? "simplegroupmap_json/cluster/{$group_id}" : "simplegroupmap_json/index/{$group_id}"; $this->themes->js->marker_radius = $marker_radius >= 1 && $marker_radius <= 10 ? $marker_radius : 5; $this->themes->js->marker_opacity = $marker_opacity >= 1 && $marker_opacity <= 10 ? $marker_opacity * 0.1 : 0.9; $this->themes->js->marker_stroke_width = $marker_stroke_width >= 1 && $marker_stroke_width <= 5 ? $marker_stroke_width : 2; $this->themes->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->themes->js->numZoomLevels = $numZoomLevels; $this->themes->js->minZoomLevel = $minZoomLevel; $this->themes->js->maxZoomLevel = $maxZoomLevel; // pdestefanis - allows to limit the extents of the map $this->themes->js->lonFrom = $lonFrom; $this->themes->js->latFrom = $latFrom; $this->themes->js->lonTo = $lonTo; $this->themes->js->latTo = $latTo; $this->themes->js->default_map = Kohana::config('settings.default_map'); $this->themes->js->default_zoom = Kohana::config('settings.default_zoom'); $this->themes->js->latitude = Kohana::config('settings.default_lat'); $this->themes->js->longitude = Kohana::config('settings.default_lon'); $this->themes->js->default_map_all = Kohana::config('settings.default_map_all'); // $this->themes->js->active_startDate = $active_startDate; $this->themes->js->active_endDate = $active_endDate; //$myPacker = new javascriptpacker($js , 'Normal', false, false); //$js = $myPacker->pack(); // Rebuild Header Block $this->template->header->header_block = $this->themes->header_block(); }
public function index() { //////////////////////////////////////////////////////////////////////////////////////////////// // custom JS that the print map needs plugin::add_javascript("adminmap/js/jquery.address-1.4.min.js"); /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Setup the map adminmap_helper::setup_adminmap($this, "adminmap/print_mapview", "adminmap/css/print_adminmap"); //ARE WE CLUSTERING? $clustering = Kohana::config('settings.allow_clustering'); ///////////////////////////////////////////////////////////////////////////////////////////////////////// //get the CATEGORIES ///////////////////////////////////////////////////////////////////////////////////////////////////////// if (isset($this->group_id) && $this->group_id) { $group_id = $this->group_id; $group = ORM::factory('simplegroups_groups', $this->group_id)->find($this->group_id); //get the categories adminmap_helper::set_categories($this, false, $group); $json_url = $clustering == 1 ? "simplegroupmap_json/cluster/{$group_id}" : "simplegroupmap_json/index/{$group_id}"; $json_timeline_url = "simplegroupmap_json/timeline/{$group_id}/"; } else { //get the categories adminmap_helper::set_categories($this, false); $json_url = $clustering == 1 ? "bigmap_json/cluster" : "bigmap_json"; $json_timeline_url = "bigmap_json/timeline/"; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// //setup the map ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// adminmap_helper::set_map($this->template, $this->themes, $json_url, $json_timeline_url, 'adminmap/print_mapview_js', 'adminmap/big_main_map', 'adminmap/print_main_timeline'); ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// //setup the overlays and shares ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// adminmap_helper::set_overlays_shares($this); plugin::add_stylesheet("adminmap/css/jquery.hovertip-1.0"); plugin::add_javascript("adminmap/js/jquery.hovertip-1.0"); $this->template->header = new View('adminmap/print_map_header'); $this->template->header->site_name = $this->site_name; $this->template->header->this_page = ""; // Rebuild Header Block $this->template->header->header_block = $this->themes->header_block(); }