Example #1
0
 /**
  * Generate the Map Array.
  * These are the maps that show up in the Layer Switcher
  * if $all is set to TRUE all maps are rendered
  * **caveat is that each mapping api js must be loaded **
  * 
  * @param   bool  $all
  * @return  string $js
  */
 public static function layers_array($all = FALSE)
 {
     // Javascript
     $js = "[";
     // Get All Layers
     $layers = map::base();
     // Next get the default base layer
     $default_map = Kohana::config('settings.default_map');
     if (!isset($layers[$default_map])) {
         // Map Layer Doesn't Exist - default to google
         $default_map = "google_normal";
     }
     // Get openlayers type
     $openlayers_type = $layers[$default_map]->openlayers;
     $js .= $default_map;
     foreach ($layers as $layer) {
         if ($layer->name != $default_map and $layer->active) {
             if ($all == TRUE) {
                 $js .= "," . $layer->name;
             } else {
                 if ($layer->openlayers == $openlayers_type) {
                     $js .= "," . $layer->name;
                 }
             }
         }
     }
     $js .= "]";
     return $js;
 }
Example #2
0
 private function _generate_settings_map_js()
 {
     $map_layers = array();
     $layers = map::base();
     foreach ($layers as $layer) {
         $map_layers[$layer->name] = array();
         $map_layers[$layer->name]['title'] = $layer->title;
         $map_layers[$layer->name]['openlayers'] = $layer->openlayers;
         if (isset($layer->api_signup)) {
             $map_layers[$layer->name]['api_signup'] = $layer->api_signup;
         } else {
             $map_layers[$layer->name]['api_signup'] = "";
         }
     }
     return json_encode($map_layers);
 }
Example #3
0
Kohana::config_set('settings.email_host', $settings->email_host);
Kohana::config_set('settings.email_servertype', $settings->email_servertype);
Kohana::config_set('settings.email_ssl', $settings->email_ssl);
Kohana::config_set('settings.alerts_email', $settings->alerts_email);
Kohana::config_set('settings.db_version', $settings->db_version);
Kohana::config_set('settings.ushahidi_version', $settings->ushahidi_version);
Kohana::config_set('settings.private_deployment', $settings->private_deployment);
// Set Site Timezone
if (function_exists('date_default_timezone_set')) {
    $timezone = $settings->site_timezone;
    // Set default timezone, due to increased validation of date settings
    // which cause massive amounts of E_NOTICEs to be generated in PHP 5.2+
    date_default_timezone_set(empty($timezone) ? date_default_timezone_get() : $timezone);
    Kohana::config_set('settings.site_timezone', $timezone);
}
// Cache Settings
$cache_pages = $settings->cache_pages ? TRUE : FALSE;
Kohana::config_set('cache.cache_pages', $cache_pages);
Kohana::config_set('cache.default.lifetime', $settings->cache_pages_lifetime);
$default_map = $settings->default_map;
$map_layer = map::base($default_map);
if ($map_layer) {
    Kohana::config_set('settings.api_url', "<script type=\"text/javascript\" src=\"" . $map_layer->api_url . "\"></script>");
}
// And in case you want to display all maps on one page...
$api_google = $settings->api_google;
$api_yahoo = $settings->api_yahoo;
Kohana::config_set('settings.api_url_all', '<script src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6"></script><script type="text/javascript" src="http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=' . $api_yahoo . '"></script><script src="http://maps.google.com/maps/api/js?v=3.2&amp;sensor=false" type="text/javascript"></script>' . html::script('http://www.openstreetmap.org/openlayers/OpenStreetMap.js'));
// Additional Mime Types (KMZ/KML)
Kohana::config_set('mimes.kml', array('text/xml'));
Kohana::config_set('mimes.kmz', array('text/xml'));
Example #4
0
    // which cause massive amounts of E_NOTICEs to be generated in PHP 5.2+
    date_default_timezone_set(empty($timezone) ? date_default_timezone_get() : $timezone);
    Kohana::config_set('settings.site_timezone', $timezone);
}
// Cache Settings
$cache_pages = (isset($settings['cache_pages']) and $settings['cache_pages']) ? TRUE : FALSE;
Kohana::config_set('cache.cache_pages', $cache_pages);
Kohana::config_set('cache.default.lifetime', isset($settings['cache_pages_lifetime']) ? $settings['cache_pages_lifetime'] : 1800);
$default_map = isset($settings['default_map']) ? $settings['default_map'] : 'osm_mapnik';
$map_layer = map::base($default_map);
if (!empty($map_layer->api_url)) {
    Kohana::config_set('settings.api_url', $map_layer->api_url);
}
// And in case you want to display all maps on one page...
$api_url_all = array();
foreach (map::base() as $layer) {
    if (empty($layer->api_url)) {
        continue;
    }
    // Add to array, use url as key to avoid dupes
    $api_url_all[$layer->api_url] = $layer->api_url;
}
Kohana::config_set('settings.api_url_all', $api_url_all);
// Additional Mime Types (KMZ/KML)
Kohana::config_set('mimes.kml', array('text/xml'));
Kohana::config_set('mimes.kmz', array('text/xml'));
// Set 'settings.forgot_password_key' if not set already
if (!Kohana::config('settings.forgot_password_secret')) {
    $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()_+[]{};:,.?`~';
    $key = text::random($pool, 64);
    Settings_Model::save_setting('forgot_password_secret', $key);