Exemplo n.º 1
0
 /**
  * Returns an image map
  *
  * @param mixed $lat latitude or an array of marker points
  * @param float $lon longitude
  * @param integer $zoom zoom level (1-19)
  * @param string $type map type (roadmap or mobile)
  * @param integer $width map width
  * @param integer $height map height
  * @return string
  */
 public static function static_map($lat = 0, $lon = 0, $zoom = 6, $type = NULL, $width = 300, $height = 300)
 {
     // Valid map types
     $types = array('roadmap', 'mobile');
     // Maximum width and height are 640px
     $width = min(640, abs($width));
     $height = min(640, abs($height));
     $parameters['size'] = $width . 'x' . $height;
     // Minimum zoom = 0, maximum zoom = 19
     $parameters['zoom'] = max(0, min(19, abs($zoom)));
     if (in_array($type, $types)) {
         // Set map type
         $parameters['maptype'] = $type;
     }
     if (is_array($lat)) {
         foreach ($lat as $_lat => $_lon) {
             $parameters['markers'][] = $_lat . ',' . $_lon;
         }
         $parameters['markers'] = implode('|', $parameters['markers']);
     } else {
         $parameters['center'] = $lat . ',' . $lon;
     }
     return Gmap::api_url('staticmap', $parameters);
 }
Exemplo n.º 2
0
        ?>
				</dd>
				<?php 
    }
    ?>

			</dl>
				<?php 
    if ($venue->latitude && $venue->longitude) {
        ?>
			<div id="map" style="display: none"><?php 
        echo __('Map loading');
        ?>
</div>
					<?php 
        $map = new Gmap('map', array('ScrollWheelZoom' => true));
        $map->center($venue->latitude, $venue->longitude, 15)->controls('small')->types();
        $map->add_marker($venue->latitude, $venue->longitude, '<strong>' . html::chars($venue->name) . '</strong><p>' . html::chars($venue->address) . '<br />' . html::chars($venue->zip) . ' ' . html::chars($venue->city_name) . '</p>');
        widget::add('foot', html::script_source($map->render('gmaps/jquery_event')));
        widget::add('foot', html::script_source("\$('.contact a[href=#map]').click(function() { \$('#map').toggle('normal', gmap_open); return false; });"));
        ?>
				<?php 
    }
    ?>
			<?php 
}
?>

		</article>

		<?php 
Exemplo n.º 3
0
 /**
  * User profile
  */
 public function _view()
 {
     $this->tab_id = 'profile';
     $owner = $this->user && $this->member->id == $this->user->id;
     if ($owner && $this->user->newcomments) {
         $this->user->newcomments = 0;
         $this->user->save();
     }
     // Actions
     if ($this->member->has_access(User_Model::ACCESS_EDIT)) {
         $this->page_actions[] = array('link' => url::user($this->member) . '/edit', 'text' => __('Settings'), 'class' => 'settings');
     }
     // Picture
     widget::add('side', View_Mod::factory('member/member', array('mod_class' => 'member member-' . $this->member->id, 'user' => $this->member)));
     // Comments
     if ($this->member->has_access(User_Model::ACCESS_COMMENT)) {
         $comment = new User_Comment_Model();
         $form_values = $comment->as_array();
         $form_errors = array();
         // check post
         if (csrf::valid() && ($post = $this->input->post())) {
             $comment->user_id = $this->member->id;
             $comment->author_id = $this->user->id;
             $comment->comment = $post['comment'];
             if (isset($post['private'])) {
                 $comment->private = 1;
             }
             try {
                 $comment->save();
                 if (!$owner) {
                     $this->member->newcomments += 1;
                     $this->member->save();
                 }
                 $this->user->commentsleft += 1;
                 $this->user->save();
                 if (!request::is_ajax()) {
                     url::redirect(url::current());
                 }
             } catch (ORM_Validation_Exception $e) {
                 $form_errors = $e->validation->errors();
                 $form_values = arr::overwrite($form_values, $post);
             }
         }
         // Handle pagination
         $per_page = 25;
         $page_num = $this->uri->segment('page') ? $this->uri->segment('page') : 1;
         $page_offset = ($page_num - 1) * $per_page;
         $total_comments = $this->member->get_comment_count();
         $comments = $this->member->find_comments($page_num, $per_page, $this->user);
         $pagination = new Pagination(array('items_per_page' => $per_page, 'total_items' => $total_comments));
         $view = View::factory('generic/comments', array('delete' => '/member/comment/%d/delete/?token=' . csrf::token(), 'private' => '/member/comment/%d/private/?token=' . csrf::token(), 'comments' => $comments, 'errors' => $form_errors, 'values' => $form_values, 'pagination' => $pagination, 'user' => $this->user));
         if (request::is_ajax()) {
             echo $view;
             return;
         }
         widget::add('main', $view);
     }
     // Basic info
     $basic_info = array();
     if (!empty($this->member->name)) {
         $basic_info[__('Name')] = html::specialchars($this->member->name);
     }
     if (!empty($this->member->city_name)) {
         $basic_info[__('City')] = html::specialchars($this->member->city_name);
     }
     if (!empty($this->member->dob) && $this->member->dob != '0000-00-00') {
         $basic_info[__('Date of Birth')] = __(':dob (:years years)', array(':dob' => date::format('DMYYYY', $this->member->dob), ':years' => date::timespan(strtotime($this->member->dob), null, 'years')));
     }
     if (!empty($this->member->gender)) {
         $basic_info[__('Gender')] = $this->member->gender == 'm' ? __('Male') : __('Female');
     }
     if (!empty($this->member->latitude) && !empty($this->member->longitude)) {
         $basic_info[__('Location')] = $this->member->latitude . ', ' . $this->member->longitude;
         $basic_info[__('Location')] = html::anchor('#map', __('Toggle map'), array('class' => 'expander', 'title' => __('Show/hide'))) . '<div id="map" style="display: none">' . __('Map loading') . '</div>';
         $map = new Gmap('map', array('ScrollWheelZoom' => true));
         $map->center($this->member->latitude, $this->member->longitude, 15)->controls('small')->types();
         $map->add_marker($this->member->latitude, $this->member->longitude, html::avatar($this->member->avatar, $this->member->username) . html::user($this->member));
         widget::add('foot', html::script_source($map->render('gmaps/jquery_event')));
         widget::add('foot', html::script_source("\$('a[href*=\"#map\"]:first').click(function() { \$('#map').toggle('normal', gmap_open); return false; });"));
     }
     // Site info
     $site_info = array(__('Registered') => date::format('DMYYYY_HM', $this->member->created) . ' [#' . $this->member->id . ']', __('Logins') => __(':logins (:ago ago)', array(':logins' => number_format($this->member->logins, 0), ':ago' => '<abbr title="' . date::format('DMYYYY_HM', $this->member->last_login) . '">' . date::timespan_short($this->member->last_login) . '</abbr>')), __('Posts') => number_format($this->member->posts, 0), __('Comments') => number_format($this->member->commentsleft, 0));
     // Initialize tabs
     $tabs = array('basic-info' => array('href' => '#basic-info', 'title' => __('Basic info'), 'tab' => new View('generic/list_info', array('id' => 'basic-info', 'title' => __('Basic info'), 'list' => $basic_info))), 'site-info' => array('href' => '#site-info', 'title' => __('Site info'), 'tab' => new View('generic/list_info', array('id' => 'site-info', 'title' => __('Site info'), 'list' => $site_info))));
     widget::add('side', View::factory('generic/tabs', array('id' => 'info-tab', 'tabs' => $tabs)));
     $this->_side_views();
 }
Exemplo n.º 4
0
 public function jquery()
 {
     $map = new Gmap('map');
     $map->center(0, 35, 16)->controls('large');
     View::factory('gmaps/jquery')->set(array('api_url' => Gmap::api_url(), 'map' => $map->render('gmaps/jquery_javascript')))->render(TRUE);
 }
Exemplo n.º 5
0
 /**
  * Tests the factory method.
  * 
  * @test
  * @covers Gmap::__construct
  * @covers Gmap::factory
  */
 function test_factory_metod()
 {
     $this->assertEquals(new Gmap(), Gmap::factory());
 }
Exemplo n.º 6
0
 /**
  * Set a new position to show, when starting up the map.
  *
  * @param float $lat
  * @param float $lng
  * @return Gmap
  */
 public function set_pos($lat = NULL, $lng = NULL)
 {
     if ($lat != NULL) {
         $this->_options['lat'] = Gmap::validate_latitude($lat);
     }
     // if
     if ($lng != NULL) {
         $this->_options['lng'] = Gmap::validate_longitude($lng);
     }
     // if
     return $this;
 }
if (!defined('BASEPATH')) {
    exit('No direct script access allowed');
}
/**
* Plugin - Google Maps for ExpressionEngine
*
* @package			Google Maps for ExpressionEngine
* @version			2.5 - Build 20120131
* @author			Justin Kimbrell <http://objectivehtml.com>
* @copyright 		Copyright (c) 2012 Justin Kimbrell <http://objectivehtml.com>
* @license 		Creative Commons Attribution 3.0 Unported License -
					please see LICENSE file included with this distribution
* @link			http://objectivehtml.com/google-maps
*/
$plugin_info = array('pi_name' => 'Google Maps for ExpressionEngine', 'pi_version' => '2.5', 'pi_author' => 'Justin Kimbrell', 'pi_author_url' => 'http://objectivehtml.com/documentation/google-maps-for-expressionengine', 'pi_description' => 'Creates static and dynamic maps from content channels.', 'pi_usage' => Gmap::usage());
class Gmap
{
    private $args = array('map' => array('backgroundColor', 'disableDefaultUI', 'disableDoubleClickZoom', 'draggable', 'draggableCursor', 'heading', 'keyboardShortcuts', 'mapTypeControl', 'mapTypeControlOptions', 'mapTypeId', 'maxZoom', 'minZoom', 'noClear', 'overviewMapControl', 'overviewMapControlOptions', 'panControl', 'panControlOptions', 'rotateControl', 'rotateControlOptions', 'scaleControl', 'scaleControlOptions', 'scrollwheel', 'streetView', 'streetViewControl', 'streetViewControlOptions', 'tilt', 'title', 'zoomControl', 'zoomControlOptions', 'zoom'), 'channel' => array('author_id', 'backspace', 'cache', 'refresh', 'cat_limit', 'category', 'category_group', 'isable', 'channel', 'display_by', 'dynamic', 'dynamic_start', 'entry_id', 'entry_id_from', 'entry_id_to', 'fixed_order', 'group_id', 'limit', 'month_limit', 'offset', 'orderby', 'paginate', 'paginate_base', 'paginate_type', 'related_categories_mode', 'relaxed_categories', 'require_entry', 'show_current_week', 'show_expired', 'show_future_entries', 'show_pages', 'sort', 'start_day', 'start_on', 'status', 'stop_before', 'sticky', 'track_views', 'uncategorized_entries', 'url_title', 'username', 'week_sort', 'year', 'month', 'day'), 'plugin' => array('center', 'channel', 'hide_markers', 'open_windows', 'map_type', 'id', 'class', 'style', 'style_link', 'style_obj', 'extend_bounds', 'show_one_window', 'icon', 'show_coordinate', 'add_title_to_dropdown', 'metric', 'offset', 'distance', 'cache_post', 'show_sql', 'require', 'name'), 'fields' => array('address_field', 'city_field', 'state_field', 'zipcode_field', 'country_field', 'latitude_field', 'longitude_field', 'zoom_field', 'address', 'latitude', 'longitude', 'gmap_field', 'lat_lng'));
    public $geocoder_response;
    public function __construct()
    {
        $this->EE =& get_instance();
        $this->EE->load->config('gmap');
    }
    public function init()
    {
        $this->args = $this->_fetch_params(FALSE);
        return $this->_init_map();
    }
    public function center()
Exemplo n.º 8
0
 /**
  * Edit venue
  *
  * @param  integer|string  $venue_id
  * @param  integer|string  $category_id
  */
 public function _venue_edit($venue_id = false, $category_id = false)
 {
     $this->history = false;
     $venue = new Venue_Model((int) $venue_id);
     // Check access
     if (!($venue->loaded() && $venue->has_access(Venue_Model::ACCESS_EDIT)) && !(!$venue->loaded() && $this->visitor->logged_in(array('admin', 'venue moderator', 'venue')))) {
         url::back('venues');
     }
     $errors = $form_errors = array();
     $form_values = $venue->as_array();
     // check post
     if (request::method() == 'post') {
         $post = array_merge($this->input->post(), $_FILES);
         $extra = array('author_id' => $this->user->id);
         // got address, get geocode
         if (!empty($post['address']) && !empty($post['city_name'])) {
             list($extra['latitude'], $extra['longitude']) = Gmap::address_to_ll(implode(', ', array($post['address'], $post['zip'], $post['city_name'])));
         }
         if (csrf::valid() && $venue->validate($post, true, $extra)) {
             // handle logo upload
             if (isset($post->logo) && empty($post->logo['error'])) {
                 $logo = Image_Model::factory('venues.logo', $post->logo, $this->user->id);
                 if ($logo->id) {
                     $venue->add($logo);
                     $venue->default_image_id = $logo->id;
                     $venue->save();
                 }
             }
             // handle picture uploads
             foreach (array($post->picture1, $post->picture2) as $picture) {
                 if (isset($picture) && empty($picture['error'])) {
                     $image = Image_Model::factory('venues.image', $picture, $this->user->id);
                     if ($image->id) {
                         $venue->add($image);
                         $venue->save();
                     }
                 }
             }
             // update tags
             $venue->remove(ORM::factory('tag'));
             if (!empty($post->tags)) {
                 foreach ($post->tags as $tag_id => $tag) {
                     $venue->add(ORM::factory('tag', $tag_id));
                 }
             }
             url::redirect(url::model($venue));
         } else {
             $form_errors = $post->errors();
         }
         $form_values = arr::overwrite($form_values, $post->as_array());
     }
     // editing old?
     if ($venue_id) {
         if ($venue->has_access(Venue_Model::ACCESS_DELETE)) {
             $this->page_actions[] = array('link' => 'venue/' . url::title($venue->id, $venue->name) . '/delete/?token=' . csrf::token(), 'text' => __('Delete venue'), 'class' => 'venue-delete');
         }
         $this->page_subtitle = __('Edit venue');
         if (!$venue->id) {
             $errors = array('venues.error_venue_not_found');
         } else {
             $venue_category = $venue->venue_category;
         }
     } else {
         $this->page_subtitle = __('Add venue');
         if ($category_id) {
             $venue_category = new Venue_Category_Model((int) $category_id);
             if ($venue_category->id) {
                 $form_values['venue_category_id'] = $venue_category->id;
             } else {
                 $errors = array('venues.error_venue_category_not_found');
             }
         }
     }
     $this->page_actions[] = array('link' => 'venue/' . url::title($venue->id, $venue->name), 'text' => __('Cancel'), 'class' => 'cancel');
     $this->breadcrumb[] = html::anchor('/venues/' . url::title($venue_category->id, $venue_category->name), $venue_category->name);
     if ($venue->id) {
         $this->breadcrumb[] = html::anchor('/venue/' . url::title($venue->id, $venue->name), $venue->name);
     }
     // show form
     if (empty($errors)) {
         $form = array();
         // tags
         if ($venue_category->tag_group_id) {
             $form['tags'] = $form_values['tags'] = array();
             foreach ($venue_category->tag_group->tags as $tag) {
                 $form['tags'][$tag->id] = $tag->name;
                 if ($venue->has($tag)) {
                     $form_values['tags'][$tag->id] = $tag->name;
                 }
             }
         }
         $venue_categories = ORM::factory('venue_category')->find_all()->select_list('id', 'name');
         $form['venue_category_id'] = $venue_categories;
         widget::add('main', View_Mod::factory('venues/venue_edit', array('form' => $form, 'values' => $form_values, 'errors' => $form_errors)));
         // city autocomplete
         $this->_autocomplete_city();
     } else {
         $this->_error(Kohana::lang('generic.error'), $errors);
     }
     $this->_side_views();
 }
Exemplo n.º 9
0
    ?>
,
		<?php 
} else {
    ?>
		mapTypeControl: false,
		<?php 
}
?>

		<?php 
if ($options['gmap_controls']['navigation']['display']) {
    ?>
		navigationControl: true,
		navigationControlOptions: <?php 
    echo Gmap::clean_json_string(json_encode(Arr::extract($options['gmap_controls']['navigation'], array('style', 'position'))));
    ?>
,
		<?php 
} else {
    ?>
		navigationControl: false,
		<?php 
}
?>

		<?php 
if ($options['gmap_controls']['scale']['display']) {
    ?>
		scaleControl: true,
		<?php 
Exemplo n.º 10
0
Arquivo: info.php Projeto: anqqa/Anqh
    echo $user->latitude;
    ?>
, <?php 
    echo $user->longitude;
    ?>
</dd>
		<dd><?php 
    echo html::anchor('#map', __('Toggle map'), array('class' => 'expander', 'title' => __('Show/hide')));
    ?>
</dd>
		<dd><div id="map" style="display: none"><?php 
    echo __('Map loading');
    ?>
</div></dd>
		<?php 
    $map = new Gmap('map', array('ScrollWheelZoom' => true));
    $map->center($user->latitude, $user->longitude, 15)->controls('small')->types('G_PHYSICAL_MAP', 'add');
    $map->add_marker($user->latitude, $user->longitude, '<strong>' . html::specialchars($user->username) . '</strong>');
    widget::add('foot', html::script_source($map->render('gmaps/jquery_event')));
    widget::add('foot', html::script_source("\$('a[href*=\"#map\"]:first').click(function() { \$('#map').toggle('normal', gmap_open); return false; });"));
    ?>
		<?php 
}
?>
	</dl>
</div>

<div id="site-info">
	<h4><?php 
echo __('Site Info');
?>