aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/photos.php41
-rw-r--r--mod/photos.php8
-rw-r--r--view/css/mod_photos.css1
-rwxr-xr-xview/tpl/photo_view.tpl10
4 files changed, 59 insertions, 1 deletions
diff --git a/include/photos.php b/include/photos.php
index 4b7809fc1..4785e47c4 100644
--- a/include/photos.php
+++ b/include/photos.php
@@ -205,6 +205,17 @@ function photo_upload($channel, $observer, $args) {
// Create item container
+ $lat = $lon = null;
+
+ if($exif && $exif['GPS']) {
+ if(get_pconfig($channel_id,'system','allow_photo_location')) {
+ $lat = getGps($exif['GPS']['GPSLatitude'], $exif['GPSLatitudeRef']);
+ $lon = getGps($exif['GPS']['GPSLongitude'], $exif['GPSLongitudeRef']);
+ }
+ }
+
+
+
$item_flags = ITEM_WALL|ITEM_ORIGIN|ITEM_THREAD_TOP;
$item_restrict = (($visible) ? ITEM_VISIBLE : ITEM_HIDDEN);
$title = '';
@@ -212,6 +223,9 @@ function photo_upload($channel, $observer, $args) {
$arr = array();
+ if($lat && $lon)
+ $arr['coord'] = $lat . ' ' . $lon;
+
$arr['aid'] = $account_id;
$arr['uid'] = $channel_id;
$arr['mid'] = $mid;
@@ -481,3 +495,30 @@ function photos_create_item($channel, $creator_hash, $photo, $visible = false) {
return $item_id;
}
+
+
+function getGps($exifCoord, $hemi) {
+
+ $degrees = count($exifCoord) > 0 ? gps2Num($exifCoord[0]) : 0;
+ $minutes = count($exifCoord) > 1 ? gps2Num($exifCoord[1]) : 0;
+ $seconds = count($exifCoord) > 2 ? gps2Num($exifCoord[2]) : 0;
+
+ $flip = ($hemi == 'W' or $hemi == 'S') ? -1 : 1;
+
+ return floatval($flip * ($degrees + ($minutes / 60) + ($seconds / 3600)));
+
+}
+
+function gps2Num($coordPart) {
+
+ $parts = explode('/', $coordPart);
+
+ if (count($parts) <= 0)
+ return 0;
+
+ if (count($parts) == 1)
+ return $parts[0];
+
+ return floatval($parts[0]) / floatval($parts[1]);
+}
+
diff --git a/mod/photos.php b/mod/photos.php
index 58a38f3f3..503a113dc 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -843,6 +843,8 @@ function photos_content(&$a) {
dbesc($datum)
);
+ $map = null;
+
if($linked_items) {
xchan_query($linked_items);
@@ -882,6 +884,10 @@ function photos_content(&$a) {
intval(local_channel())
);
}
+
+ if($link_item['coord']) {
+ $map = generate_map($link_item['coord']);
+ }
}
// logger('mod_photo: link_item' . print_r($link_item,true));
@@ -1115,6 +1121,8 @@ function photos_content(&$a) {
'$tags' => $tags,
'responses' => $responses,
'$edit' => $edit,
+ '$map' => $map,
+ '$map_text' => t('Map'),
'$likebuttons' => $likebuttons,
'$like' => $like_e,
'$dislike' => $dislike_e,
diff --git a/view/css/mod_photos.css b/view/css/mod_photos.css
index a2b3459cf..f95a0ca2f 100644
--- a/view/css/mod_photos.css
+++ b/view/css/mod_photos.css
@@ -19,6 +19,7 @@
}
#photo-edit,
+#photo-map,
#photo-album-edit-wrapper,
#photo-upload-form {
display: none;
diff --git a/view/tpl/photo_view.tpl b/view/tpl/photo_view.tpl
index 3ece68876..1deaa67fc 100755
--- a/view/tpl/photo_view.tpl
+++ b/view/tpl/photo_view.tpl
@@ -7,10 +7,15 @@
{{if $tools}}
<a class="btn btn-default btn-xs" title="{{$tools.profile.1}}" href="{{$tools.profile.0}}"><i class="icon-user"></i></a>
{{/if}}
+ {{if $map}}
+ <div class="btn-group btn-group">
+ <i class="icon-globe btn btn-default btn-xs" title="{{$map_text}}" onclick="openClose('photo-map');"></i>
+ </div>
+ {{/if}}
<div class="btn-group btn-group dropdown">
{{if $edit}}
- <i class="icon-pencil btn btn-default btn-xs" title="{{$edit.edit}}" onclick="openClose('photo-edit');"></i>
+ <i class="icon-pencil btn btn-default btn-xs" title="{{$edit.edit}}" onclick="openClose('photo-edit'); $('#map-frame').attr('src',function(i,val) { return val;});"></i>
{{/if}}
{{if $lock}}
<i id="lockview" class="icon-lock btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown" title="{{$lock}}" onclick="lockview(event,{{$id}});" ></i><ul id="panel-{{$id}}" class="lockview-panel dropdown-menu"></ul>
@@ -31,6 +36,9 @@
<div class="clear"></div>
</div>
+ <div id="photo-map">
+ {{$map}}
+ </div>
<div id="photo-edit" class="section-content-tools-wrapper">
<form action="photos/{{$edit.nickname}}/{{$edit.resource_id}}" method="post" id="photo_edit_form">
<input type="hidden" name="item_id" value="{{$edit.item_id}}" />