Esempio n. 1
0
 /**
  * Adds all the events to the main Ushahidi application
  */
 public function add()
 {
     // Add a Sub-Nav Link
     Event::add('ushahidi_action.nav_admin_reports', array($this, '_report_link'));
     // Only add the events if we are on that controller
     if (Router::$current_uri == "admin/reports") {
         plugin::add_stylesheet('analysis/views/css/buttons');
         // Add Buttons to the report List
         Event::add('ushahidi_action.report_extra_admin', array($this, '_reports_list_buttons'));
     } elseif (Router::$controller == 'analysis') {
         plugin::add_javascript('analysis/views/js/ui.dialog');
         plugin::add_javascript('analysis/views/js/ui.draggable');
         plugin::add_javascript('analysis/views/js/ui.resizable');
         plugin::add_stylesheet('analysis/views/css/main');
     } elseif (strripos(Router::$current_uri, "admin/reports/edit") !== false) {
         plugin::add_stylesheet('analysis/views/css/report');
         plugin::add_javascript('analysis/views/js/jquery.copy.min');
         Event::add('ushahidi_action.report_pre_form_admin', array($this, '_reports_list_analysis'));
         Event::add('ushahidi_action.header_scripts_admin', array($this, '_save_analysis_js'));
         Event::add('ushahidi_action.report_edit', array($this, '_save_analysis'));
     } elseif (strripos(Router::$current_uri, "reports/submit") !== false) {
         //Add dropdown fields to the submit form
         Event::add('ushahidi_action.report_form', array($this, '_submit_form'));
         //Save the contents of the dropdown
         Event::add('ushahidi_action.report_submit', array($this, '_handle_post_data'));
         Event::add('ushahidi_action.report_add', array($this, '_save_submit_form'));
     }
 }
 /**
  * Adds all the events to the main Ushahidi application
  */
 public function add()
 {
     // Only add the events if we are on that controller
     if (Router::$controller == 'reports') {
         switch (Router::$method) {
             // Hook into the Report Add/Edit Form in Admin
             case 'edit':
                 // Hook into the form itself
                 Event::add('ushahidi_action.report_form_admin', array($this, '_report_form'));
                 // Hook into the report_submit_admin (post_POST) event right before saving
                 // Event::add('ushahidi_action.report_submit_admin', array($this, '_report_validate'));
                 // Hook into the report_edit (post_SAVE) event
                 Event::add('ushahidi_action.report_edit', array($this, '_report_form_submit'));
                 break;
                 // Hook into the Report view (front end)
             // Hook into the Report view (front end)
             case 'view':
                 plugin::add_stylesheet('actionable/views/css/actionable');
                 Event::add('ushahidi_action.report_meta', array($this, '_report_view'));
                 break;
         }
     } elseif (Router::$controller == 'feed') {
         // Add Actionable Tag to RSS Feed
         Event::add('ushahidi_action.feed_rss_item', array($this, '_feed_rss'));
     }
 }
Esempio n. 3
0
    public function __construct()
    {
		parent::__construct();
		
		// Set Table Prefix
		$this->table_prefix = Kohana::config('database.default.table_prefix');
		
		// Load Header & Footer
        $this->template->header  = new View('keitai/header');
        $this->template->footer  = new View('keitai/footer');

		$this->template->header->site_name = Kohana::config('settings.site_name');
		$this->template->header->site_tagline = Kohana::config('settings.site_tagline');

		plugin::add_javascript('keitai/views/js/jquery');
		plugin::add_javascript('keitai/views/js/jquery.treeview');
		plugin::add_javascript('keitai/views/js/expand');
		plugin::add_stylesheet('keitai/views/css/styles');
		plugin::add_stylesheet('keitai/views/css/jquery.treeview');
		
		$this->template->header->show_map = FALSE;
		$this->template->header->js = "";
		$this->template->header->breadcrumbs = "";
		
		// Google Analytics
		$google_analytics = Kohana::config('settings.google_analytics');
		$this->template->footer->google_analytics = $this->_google_analytics($google_analytics);

		$this->template->header->latlong = (isset($_GET['latlong'])) ? $_GET['latlong'] : "";
		$this->template->footer->latlong = (isset($_GET['latlong'])) ? $_GET['latlong'] : "";
	}
 /**
  * Adds all the events to the main Ushahidi application
  */
 public function add()
 {
     // Only add the events if we are on that controller
     if (Router::$controller == 'reports' and (Router::$method == 'view' or Router::$method == 'index')) {
         plugin::add_stylesheet('printreport/css/print');
     }
 }
Esempio n. 5
0
 /**
  * Adds all the events to the main Ushahidi application
  */
 public function add()
 {
     // Add a Sub-Nav Link
     Event::add('ushahidi_action.nav_admin_settings', array($this, '_settings_link'));
     Event::add('ushahidi_action.nav_main_top', array($this, '_top_nav_link'));
     // Only add the events if we are on the main controller
     if (Router::$controller == 'main') {
         switch (Router::$method) {
             // Hook into the main dashboard
             case 'index':
                 plugin::add_stylesheet('flickrwijit/media/css/style');
                 plugin::add_stylesheet('../media/css/picbox/picbox');
                 plugin::add_javascript('../media/js/picbox');
                 Event::add('ushahidi_action.main_sidebar', array($this, '_display_flickrwiji'));
                 break;
         }
     } elseif (Router::$controller == 'flickrwijit') {
         // Add Flickrwijit to settings page
         switch (Router::$method) {
             case 'index':
                 //Hook js and css files into flickrwijit page
                 plugin::add_stylesheet('flickrwijit/media/css/style');
                 plugin::add_stylesheet('../media/css/picbox/picbox');
                 plugin::add_javascript('../media/js/picbox');
                 break;
         }
     }
 }
 /**
  * Adds all the events to the main Ushahidi application
  */
 public function add()
 {
     if (Router::$controller == 'main') {
         // Add stylesheet
         plugin::add_stylesheet('categorycloud/views/css/categorycloud');
         Event::add('ushahidi_action.main_sidebar', array($this, '_generate_cloud'));
     }
 }
 /**
  * Adds all other events for the plugin framework to the application
  */
 public function add()
 {
     // Add the nexmo plugin to the list of SMS providers
     plugin::add_sms_provider('nexmo');
     // Add Nexmo CSS
     plugin::add_stylesheet('nexmo/views/css/nexmo');
     // Add event callbacks
     Event::add('nexmo_action.update_message_log', array($this, 'update_message_log'));
 }
Esempio n. 8
0
 public function add()
 {
     switch (Router::$current_uri) {
         case "reports/download":
             plugin::add_stylesheet('downloadreports/views/css/download_reports');
             Event::add('ushahidi_action.header_scripts', array($this, '_add_scripts'));
             break;
     }
 }
Esempio n. 9
0
 public static function setup_adminmap($map_controller, $map_view = "adminmap/mapview", $map_css = "adminmap/css/adminmap")
 {
     //set the CSS for this
     plugin::add_stylesheet($map_css);
     plugin::add_javascript("adminmap/js/jquery.flot");
     plugin::add_javascript("adminmap/js/excanvas.min");
     plugin::add_javascript("adminmap/js/timeline");
     $map_controller->template->content = new View($map_view);
     // Get Default Color
     $map_controller->template->content->default_map_all = Kohana::config('settings.default_map_all');
 }
Esempio n. 10
0
 public function add()
 {
     // Add an Admin Sub-Nav Link
     Event::add('ushahidi_action.nav_admin_settings', array($this, '_settings_link'));
     // Add the events on the main controller only
     if (Router::$controller == 'crowdflower_settings') {
         switch (Router::$method) {
             // Hook into the main dashboard
             case 'index':
                 plugin::add_stylesheet('crowdflower/media/css/crowdflower');
                 break;
         }
     }
 }
Esempio n. 11
0
	/**
	 * Adds all the events to the main Ushahidi application
	 */
	public function add()
	{
		// Only add the events if we are on that controller
		if (Router::$controller == 'main')
		{
			plugin::add_javascript('fullscreenmap/views/js/jquery.colorbox');
			#plugin::add_javascript('fullscreenmap/views/js/ui.draggable');
			plugin::add_stylesheet('fullscreenmap/views/css/fullscreenmap');
			plugin::add_stylesheet('fullscreenmap/views/css/colorbox');
			
			Event::add('ushahidi_action.header_scripts', array($this, '_main_js'));
			Event::add('ushahidi_action.map_main_filters', array($this, '_button'));
		}
	}
Esempio n. 12
0
 /**
  * Adds all the events to the main Ushahidi application
  */
 public function add()
 {
     if (Router::$controller == "main" || Router::$controller == "bigmap" || Router::$method == "groupmap") {
         Event::add('ushahidi_action.header_scripts', array($this, '_add_js'));
         plugin::add_stylesheet("densitymap/css/densitymap");
     }
     if (Router::$controller == "reports") {
         Event::add('ushahidi_filter.fetch_incidents_set_params', array($this, '_add_incident_filter'));
         Event::add('ushahidi_action.report_filters_ui', array($this, '_add_report_filter_ui'));
         Event::add('ushahidi_action.header_scripts', array($this, '_add_report_filter_js'));
     }
     if (Router::$controller == "json" || Router::$controller == "densitymap") {
         Event::add('ushahidi_filter.fetch_incidents_set_params', array($this, '_add_incident_filter'));
     }
 }
 /**
  * Adds all the events to the main Ushahidi application
  */
 public function add()
 {
     if (Router::$controller == 'reports' and (Router::$method == 'view' or Router::$method == 'edit')) {
         Event::add('ushahidi_action.report_extra', array($this, 'show_ivr_history'));
         Event::add('ushahidi_action.report_form_admin', array($this, 'show_ivr_history'));
         plugin::add_stylesheet('ivr_api/css/ivr_api');
         Event::add('ushahidi_action.header_scripts', array($this, 'add_js'));
         Event::add('ushahidi_action.header_scripts_admin', array($this, 'add_js_admin'));
     }
     //get the export link up on the reports page
     Event::add('ushahidi_action.nav_admin_reports', array($this, 'reports_menu_link'));
     if (Router::$controller == "reports") {
         Event::add('ushahidi_filter.fetch_incidents_set_params', array($this, '_add_ivr_comment_filter'));
         Event::add('ushahidi_action.report_filters_ui', array($this, '_add_report_filter_ui'));
         Event::add('ushahidi_action.header_scripts', array($this, '_add_report_filter_js'));
     }
 }
Esempio n. 14
0
 /**
  * Adds all the events to the main Ushahidi application
  */
 public function add()
 {
     //Just in case we need this
     Event::add('ushahidi_action.nav_main_top', array($this, '_add_big_map_tab'));
     //adds the big map  tab
     Event::add('ushahidi_action.nav_admin_main_top', array($this, '_admin_nav_tab'));
     //adds the admin map  tab
     if (Router::$controller == "main") {
         Event::add('ushahidi_action.map_main_filters', array($this, '_add_big_map_main_button'));
         //adds the big map  tab
         //use sneaky JS
         plugin::add_javascript("adminmap/js/embedd_setup");
         plugin::add_stylesheet("adminmap/css/embedd_setup");
         Event::add('ushahidi_action.main_sidebar', array($this, '_add_embedd'));
     }
     //if dealing with the
     if (Router::$controller == "reports") {
         Event::add('ushahidi_filter.fetch_incidents_set_params', array($this, '_add_logical_operator_filter'));
         Event::add('ushahidi_action.report_filters_ui', array($this, '_add_report_filter_ui'));
         Event::add('ushahidi_action.header_scripts', array($this, '_add_report_filter_js'));
     }
 }
 /**
  * Adds all the events to the main Ushahidi application
  */
 public function add()
 {
     // Only add the events if we are on that controller
     if (Router::$controller == 'reports') {
         switch (Router::$method) {
             // Hook into the Report Add/Edit Form in Admin
             case 'edit':
                 plugin::add_stylesheet('locationhighlightlite/media/css/locationhighlightlite');
                 plugin::add_javascript('locationhighlightlite/media/js/locationhighlightlite');
                 break;
                 //Hook into frontend Submit View
             //Hook into frontend Submit View
             case 'submit':
                 plugin::add_stylesheet('locationhighlightlite/media/css/locationhighlightlite');
                 plugin::add_javascript('locationhighlightlite/media/js/locationhighlightlite');
                 break;
             default:
                 break;
         }
         //end of switch
     }
     //end of if reports
 }
Esempio n. 16
0
 /**
  * Function: add
  *
  * Description: Adds all the events to the main Ushahidi application
  *
  * Views:
  *
  * Results: This plugin has registered for all the events that it wants to know about
  */
 public function add()
 {
     //Just in case we need this
     Event::add('ushahidi_action.nav_main_top', array($this, '_add_big_map_tab'));
     //adds the big map  tab
     Event::add('ushahidi_action.nav_admin_main_top', array($this, '_admin_nav_tab'));
     //adds the admin map  tab
     if (Router::$controller == "main") {
         Event::add('ushahidi_action.map_main_filters', array($this, '_add_big_map_main_button'));
         //adds the big map  tab
         //use sneaky JS
         if (ORM::factory('enhancedmap_settings')->where('key', 'enable_iframemap')->find()->value == "true") {
             plugin::add_javascript("enhancedmap/js/embedd_setup");
             plugin::add_stylesheet("enhancedmap/css/embedd_setup");
             Event::add('ushahidi_action.main_sidebar', array($this, '_add_embedd'));
         }
         plugin::add_stylesheet("enhancedmap/css/printmap_link");
         Event::add('ushahidi_filter.map_main', array($this, '_add_printmap'));
     }
     //if dealing with the
     if (Router::$controller == "reports") {
         Event::add('ushahidi_action.report_filters_ui', array($this, '_add_report_filter_ui'));
         Event::add('ushahidi_action.header_scripts', array($this, '_add_report_filter_js'));
     }
     //always filter the fetch incidents params, well don't use it if the high performance version is at play
     if (Router::$controller != "hpbigmap_json" and Router::$controller != "hpiframemap_json" and Router::$controller != "hpadminmap_json") {
         plugin::add_javascript("enhancedmap/js/LoadingPanel");
         Event::add('ushahidi_filter.fetch_incidents_set_params', array($this, '_add_logical_operator_filter'));
     }
     if (Router::$controller == "adminmap") {
         plugin::add_javascript("enhancedmap/js/LoadingPanel");
         //hide the content div
         Event::add('ushahidi_action.header_scripts_admin', array($this, '_hide_content_for_adminmap'));
     }
     //adds the ability to see all approved and unapproved reports
     Event::add('ushahidi_filter.fetch_incidents_set_params', array($this, '_add_all_reports_filter'));
 }
Esempio n. 17
0
 public function index($width = 400)
 {
     $this->template->header->this_page = 'bigmap';
     $this->template->content = new View('adminmap/iframe_mapview');
     $this->template->content->site_name = $this->template->header->site_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();
     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) {
             // Check for localization of child category
             $translated_title = Category_Lang_Model::category_title($child->id, $l);
             if ($translated_title) {
                 $display_title = $translated_title;
             } else {
                 $display_title = $child->category_title;
             }
             $children[$child->id] = array($display_title, $child->category_color, $child->category_image);
             if ($child->category_trusted) {
                 // Get Trusted Category Count
                 $trusted = ORM::factory("incident")->join("incident_category", "incident.id", "incident_category.incident_id")->where("category_id", $child->id);
                 if (!$trusted->count_all()) {
                     unset($children[$child->id]);
                 }
             }
         }
         // Check for localization of parent category
         $translated_title = Category_Lang_Model::category_title($category->id, $l);
         if ($translated_title) {
             $display_title = $translated_title;
         } else {
             $display_title = $category->category_title;
         }
         // Put it all together
         $parent_categories[$category->id] = array($display_title, $category->category_color, $category->category_image, $children);
         if ($category->category_trusted) {
             // Get Trusted Category Count
             $trusted = ORM::factory("incident")->join("incident_category", "incident.id", "incident_category.incident_id")->where("category_id", $category->id);
             if (!$trusted->count_all()) {
                 unset($parent_categories[$category->id]);
             }
         }
     }
     $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 Incident Dates
     $startDate = "";
     $endDate = "";
     $display_startDate = 0;
     $display_endDate = 0;
     $db = new Database();
     // Next, Get the Range of Years
     $query = $db->query('SELECT DATE_FORMAT(incident_date, \'%Y-%c\') AS dates FROM ' . $this->table_prefix . 'incident WHERE incident_active = 1 GROUP BY DATE_FORMAT(incident_date, \'%Y-%c\') ORDER BY incident_date');
     $first_year = date('Y');
     $last_year = date('Y');
     $first_month = 1;
     $last_month = 12;
     $i = 0;
     foreach ($query as $data) {
         $date = explode('-', $data->dates);
         $year = $date[0];
         $month = $date[1];
         // Set first year
         if ($i == 0) {
             $first_year = $year;
             $first_month = $month;
         }
         // Set last dates
         $last_year = $year;
         $last_month = $month;
         $i++;
     }
     $show_year = $first_year;
     $selected_start_flag = TRUE;
     while ($show_year <= $last_year) {
         $startDate .= "<optgroup label=\"" . $show_year . "\">";
         $s_m = 1;
         if ($show_year == $first_year) {
             // If we are showing the first year, the starting month may not be January
             $s_m = $first_month;
         }
         $l_m = 12;
         if ($show_year == $last_year) {
             // If we are showing the last year, the ending month may not be December
             $l_m = $last_month;
         }
         for ($i = $s_m; $i <= $l_m; $i++) {
             if ($i < 10) {
                 // All months need to be two digits
                 $i = "0" . $i;
             }
             $startDate .= "<option value=\"" . strtotime($show_year . "-" . $i . "-01") . "\"";
             if ($selected_start_flag == TRUE) {
                 $display_startDate = strtotime($show_year . "-" . $i . "-01");
                 $startDate .= " selected=\"selected\" ";
                 $selected_start_flag = FALSE;
             }
             $startDate .= ">" . date('M', mktime(0, 0, 0, $i, 1)) . " " . $show_year . "</option>";
         }
         $startDate .= "</optgroup>";
         $endDate .= "<optgroup label=\"" . $show_year . "\">";
         for ($i = $s_m; $i <= $l_m; $i++) {
             if ($i < 10) {
                 // All months need to be two digits
                 $i = "0" . $i;
             }
             $endDate .= "<option value=\"" . strtotime($show_year . "-" . $i . "-" . date('t', mktime(0, 0, 0, $i, 1)) . " 23:59:59") . "\"";
             if ($i == $l_m and $show_year == $last_year) {
                 $display_endDate = strtotime($show_year . "-" . $i . "-" . date('t', mktime(0, 0, 0, $i, 1)) . " 23:59:59");
                 $endDate .= " selected=\"selected\" ";
             }
             $endDate .= ">" . date('M', mktime(0, 0, 0, $i, 1)) . " " . $show_year . "</option>";
         }
         $endDate .= "</optgroup>";
         // Show next year
         $show_year++;
     }
     Event::run('ushahidi_filter.active_startDate', $display_startDate);
     Event::run('ushahidi_filter.active_endDate', $display_endDate);
     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 ? "bigmap_json/cluster" : "bigmap_json";
     $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 = $display_startDate;
     $this->themes->js->active_endDate = $display_endDate;
     //$myPacker = new javascriptpacker($js , 'Normal', false, false);
     //$js = $myPacker->pack();
     // Rebuild Header Block
     $this->template->header->header_block = $this->themes->header_block();
 }
Esempio n. 18
0
 /**
  * Add Edit decayimage 
  */
 public function index()
 {
     // The default decayimage thumb file name
     $default_decayimage_thumb = 'Question_icon_thumb.png';
     $this->template->content = new View('decayimage/settings');
     $this->template->content->title = Kohana::lang('decayimage.decayimage');
     plugin::add_stylesheet('decayimage/css/decayimage');
     // Setup and initialize form field names
     $form = array('action' => '', 'decayimage_id' => '', 'decayimage_image' => '', 'decayimage_file' => '', 'decayimage_thumb' => '', 'category_id' => '');
     // Copy the form as errors, so the errors will be stored with keys corresponding to the form field names
     $errors = $form;
     $form_error = FALSE;
     $form_saved = FALSE;
     $form_action = "";
     $parents_array = array();
     // Check, has the form been submitted, if so, setup validation
     if ($_POST) {
         $post = new Validation($_POST);
         $post->pre_filter('trim');
         $post->add_callbacks('category_id', array($this, '_is_valid_category'));
         // if we have an action == 'a' but and a decayimage_id then what we really
         // mean is to perform and edit
         if ($post->action == 'a' && isset($post->category_id)) {
             $post->add_rules('category_id', 'required', 'numeric');
             if ($post->validate() && ($decayimage = ORM::factory('decayimage')->where('category_id', $post->category_id)->find()) && $decayimage->loaded) {
                 $post->decayimage_id = $decayimage->id;
                 $post->action = 'e';
             }
         }
         // Check for action
         if ($post->action == 'a') {
             // Create a new decayimage row
             $decayimage = new Decayimage_Model($post->decayimage_id);
             // Handle the case where we recieve new files
             if (upload::valid($_FILES['decayimage_file']) && strlen($_FILES['decayimage_file']['name']) && ($_FILES = Validation::factory($_FILES)->add_rules('decayimage_file', 'upload::valid', 'upload::type[gif,jpg,png]', 'upload::size[50K]')) && $_FILES->validate() && $post->validate()) {
                 // Upload the file and create a thumb
                 $modified_files = $this->_handle_new_decayimage_fileupload(0);
                 if (!$modified_files) {
                     $form_saved = false;
                     $form_error = TRUE;
                     $post->add_error('decayimage', Kohana::lang('decayimage.cant_upload_file'));
                 } else {
                     $decayimage->decayimage_image = $modified_files[0];
                     $decayimage->decayimage_thumb = $modified_files[1];
                     // Update the relevant decayimage from the db
                     $decayimage->category_id = $post->category_id;
                     $decayimage->save();
                     $form_saved = TRUE;
                     $form_action = Kohana::lang('decayimage.added');
                 }
             } else {
                 if ($post->add_rules('decayimage_thumb', 'required', 'length[5,255]') && $post->add_callbacks('decayimage_thumb', array($this, '_is_valid_decayimage_thumb')) && $post->validate()) {
                     // Upload the file and create a thumb
                     $decayimage->decayimage_thumb = $post->decayimage_thumb;
                     // Update the relevant decayimage from the db
                     $decayimage->category_id = $post->category_id;
                     $decayimage->save();
                     $form_saved = TRUE;
                     $form_action = Kohana::lang('decayimage.added');
                 } else {
                     // There was an error in validation
                     $form_error = TRUE;
                     $form = arr::overwrite($form, $post->as_array());
                     $errors = arr::overwrite($errors, $post->errors('decayimage'));
                 }
             }
         } elseif ($post->action == 'e') {
             // Setup validation for new $_FILES
             if (upload::valid($_FILES['decayimage_file']) && strlen($_FILES['decayimage_file']['name'])) {
                 $_FILES = Validation::factory($_FILES)->add_rules('decayimage_file', 'upload::valid', 'upload::type[gif,jpg,png]', 'upload::size[50K]');
             } else {
                 $post->add_rules('decayimage_thumb', 'required', 'length[5,255]');
                 $post->add_callbacks('decayimage_thumb', array($this, '_is_valid_decayimage_thumb'));
             }
             // Validate all input
             $post->add_rules('decayimage_id', 'required', 'numeric');
             $post->add_callbacks('decayimage_id', array($this, '_is_valid_decayimage_id'));
             if ($post->validate()) {
                 // Get the relevant decayimage from the db
                 $decayimage = new Decayimage_Model($post->decayimage_id);
                 // If a file was uploaded we will need to convert it to an apropriate icon size
                 if (upload::valid($_FILES['decayimage_file']) && strlen($_FILES['decayimage_file']['name']) && $_FILES->validate()) {
                     $modified_files = $this->_handle_new_decayimage_fileupload($post->decayimage_id);
                     if (!$modified_files) {
                         $form_saved = false;
                         $form_error = TRUE;
                         $post->add_error('decayimage', Kohana::lang('decayimage.cant_upload_file'));
                     } else {
                         $decayimage->decayimage_image = $modified_files[0];
                         $decayimage->decayimage_thumb = $modified_files[1];
                     }
                 } else {
                     $decayimage->decayimage_thumb = $post->decayimage_thumb;
                 }
                 // Update the relevant decayimage from the db
                 $decayimage->category_id = $post->category_id;
                 $decayimage->save();
                 $form_saved = TRUE;
                 $form_action = Kohana::lang('decayimage.updated');
             } else {
                 // There were errors
                 $form_error = TRUE;
             }
         } elseif ($post->action == 'd') {
             // TODO: https://github.com/March-hare/decayimage/issues/3
             // Make sure its not the Default entry
             $post->add_rules('decayimage_id', 'required', 'numeric');
             if ($post->validate()) {
                 $decayimage = ORM::factory('decayimage', $post->decayimage_id);
                 if ($decayimage->decayimage_image != 'Question_icon.png') {
                     $decayimage->delete();
                 } else {
                     $form_error = TRUE;
                     $post->add_error('decayimage', Kohana::lang('decayimage.cant_del_default'));
                 }
             } else {
                 $form_error = TRUE;
             }
         } elseif ($post->action == 'r') {
             // TODO: Revert to default decayimage action
             $decayimage = ORM::factory('decayimage')->where('category_id', 0)->find();
             $decayimage->decayimage_image = 'Question_icon.png';
             $decayimage->decayimage_thumb = 'Question_icon_thumb.png';
             $decayimage->save();
         }
         if ($form_error) {
             $form = arr::overwrite($form, $post->as_array());
             $errors = arr::overwrite($errors, $post->errors('decayimage'));
         }
     }
     //get array of categories
     $categories = ORM::factory("category")->where("category_visible", "1")->find_all();
     $cat_array[0] = Kohana::lang('decayimage.default_incident_icon');
     foreach ($categories as $category) {
         $cat_array[$category->id] = $category->category_title;
     }
     //get array of decay images
     $decayimages = ORM::factory("decayimage")->find_all();
     $decayimage_array = array();
     foreach ($decayimages as $decayimage) {
         $decayimage_array[$decayimage->decayimage_thumb] = $decayimage->decayimage_thumb;
     }
     $this->template->content->form_action = $form_action;
     $this->template->content->errors = $errors;
     $this->template->content->cat_array = $cat_array;
     $this->template->content->decayimage_array = $decayimage_array;
     $this->template->content->url_site = url::site();
     $this->template->content->default_decayimage_thumb = $default_decayimage_thumb;
     $this->template->content->decayimages = $decayimages;
     $this->template->content->form_error = $form_error;
     $this->template->content->form_saved = $form_saved;
     $this->template->js = new View('decayimage/settings_js');
     $this->template->js->default_decayimage_thumb = $default_decayimage_thumb;
 }
Esempio n. 19
0
 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();
 }
Esempio n. 20
0
 /**
  * Function: index
  *
  * Description: This controller calls the helper functions to create and assemble the various components
  * needed to make a working map
  *
  *	@param int $width - Width of the iframe
  *
  * Views: enhancedmap/iframe_mapview,
  *
  * Results: User gets a map that they can interact with
  */
 public function index($width = 400)
 {
     //set the title of the page
     $this->template->header->this_page = 'bigmap';
     //javascript for the big map special features
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // Setup the map
     enhancedmap_helper::setup_enhancedmap($this, "enhancedmap/iframe_mapview", "enhancedmap/css/iframe_adminmap");
     //set the site name
     $this->template->content->site_name = $this->template->header->site_name;
     //set the width of the map
     $this->template->content->width = $width;
     //ARE WE CLUSTERING?
     $clustering = cookie::get('clustering', Kohana::config('settings.allow_clustering'));
     /////////////////////////////////////////////////////////////////////////////////////////////////////////
     //get the CATEGORIES
     /////////////////////////////////////////////////////////////////////////////////////////////////////////
     //get the categories
     enhancedmap_helper::set_categories($this, false);
     $json_url = $clustering == 1 ? "iframemap_json/cluster" : "iframemap_json";
     $json_timeline_url = "bigmap_json/timeline/";
     //boolean filter
     $this->template->content->div_boolean_filter = enhancedmap_helper::get_boolean_filter();
     //boolean filter
     $this->template->content->div_categories_filter = enhancedmap_helper::set_categories();
     /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     //setup the map
     /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     enhancedmap_helper::set_map($this->template, $this->themes, $json_url, $json_timeline_url, 'enhancedmap/adminmap_js', 'enhancedmap/big_main_map', 'enhancedmap/iframe_main_timeline');
     /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     //setup the overlays and shares
     /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     //layers
     $this->template->content->div_layers_filter = enhancedmap_helper::set_layers();
     //shares
     $this->template->content->div_shares_filter = enhancedmap_helper::set_shares(false, false);
     plugin::add_stylesheet("enhancedmap/css/jquery.hovertip-1.0");
     plugin::add_javascript("enhancedmap/js/jquery.hovertip-1.0");
     // Rebuild Header Block
     $this->template->header->header_block = $this->themes->header_block();
 }
Esempio n. 21
0
 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();
 }
Esempio n. 22
0
 /**
  * Function: index
  *
  * Description: This controller calls the helper functions to create and assemble the various components
  * needed to make a working map
  *
  * Views: enhancedmap/print_mapview, enhancedmap/print_map_header
  *
  * Results: User gets a map that they can interact with
  */
 public function index()
 {
     ////////////////////////////////////////////////////////////////////////////////////////////////
     // custom JS that the print map needs
     plugin::add_javascript("enhancedmap/js/jquery.address-1.4.min.js");
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // Setup the map
     enhancedmap_helper::setup_enhancedmap($this, "enhancedmap/print_mapview", "enhancedmap/css/print_enhancedmap");
     //ARE WE CLUSTERING?
     $clustering = cookie::get('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);
         $this->template->content->div_categories_filter = enhancedmap_helper::set_categories(false, $group);
         $urlParams = array('sgid' => $group_id);
     } else {
         //get the categories
         $this->template->content->div_categories_filter = enhancedmap_helper::set_categories();
         $urlParams = array();
     }
     //status filter
     $this->template->content->div_status_filter = enhancedmap_helper::get_status_filter();
     //boolean filter
     $this->template->content->div_boolean_filter = enhancedmap_helper::get_boolean_filter();
     //dot size selector
     $this->template->content->div_dotsize_selector = enhancedmap_helper::get_dotsize_selector();
     //clustering selector
     $this->template->content->div_clustering_selector = enhancedmap_helper::get_clustering_selector();
     /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     //setup the map
     /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $json_url = $clustering == 1 ? "bigmap_json/cluster" : "bigmap_json";
     $json_timeline_url = "bigmap_json/timeline/";
     enhancedmap_helper::set_map($this->template, $this->themes, $json_url, $json_timeline_url, 'enhancedmap/print_mapview_js', 'enhancedmap/big_main_map', 'enhancedmap/print_main_timeline', $urlParams);
     /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     //setup the overlays and shares
     /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     //layers
     $this->template->content->div_layers_filter = enhancedmap_helper::set_layers();
     //shares
     $this->template->content->div_shares_filter = enhancedmap_helper::set_shares(false, false);
     plugin::add_stylesheet("enhancedmap/css/jquery.hovertip-1.0");
     plugin::add_javascript("enhancedmap/js/jquery.hovertip-1.0");
     $this->template->header = new View('enhancedmap/print_map_header');
     $this->template->header->site_name = $this->site_name;
     $this->template->header->this_page = "printmap";
     // Rebuild Header Block
     $this->template->header->header_block = $this->themes->header_block();
 }