[Linpha-cvs] SF.net SVN: linpha: [4801] trunk/linpha2
Status: Inactive
Brought to you by:
bzrudi
From: <fan...@us...> - 2007-11-20 22:04:24
|
Revision: 4801 http://linpha.svn.sourceforge.net/linpha/?rev=4801&view=rev Author: fangehrn Date: 2007-11-20 14:04:16 -0800 (Tue, 20 Nov 2007) Log Message: ----------- 2007-11-20 flo * finished basic part of the map plugin now working: - creating markers - deleting markers - assign albums to markers - change/delete assigned albums - load/show gps images - create thumbnail list - image navigation Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/include/sql.data.php trunk/linpha2/lib/plugins/maps/LinMaps.js trunk/linpha2/lib/plugins/maps/class.googlemaps.js trunk/linpha2/lib/plugins/maps/module.maps.php trunk/linpha2/templates/default/maps.head.php trunk/linpha2/templates/default/maps.html.php trunk/linpha2/templates/default/themes/default/colorsettings.php trunk/linpha2/templates/default/themes/default/css/maps.css Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-11-18 22:29:28 UTC (rev 4800) +++ trunk/linpha2/ChangeLog 2007-11-20 22:04:16 UTC (rev 4801) @@ -1,3 +1,15 @@ + +2007-11-20 flo + * finished basic part of the map plugin + now working: + - creating markers + - deleting markers + - assign albums to markers + - change/delete assigned albums + - load/show gps images + - create thumbnail list + - image navigation + 2007-11-18 flo * installer - some UI improvements Modified: trunk/linpha2/lib/include/sql.data.php =================================================================== --- trunk/linpha2/lib/include/sql.data.php 2007-11-18 22:29:28 UTC (rev 4800) +++ trunk/linpha2/lib/include/sql.data.php 2007-11-20 22:04:16 UTC (rev 4801) @@ -114,6 +114,7 @@ 'plugins_maps_defaultMarkerZoom' => '10', 'plugins_maps_mapType' => 'google', 'plugins_maps_google_key' => 'ABQIAAAAAXCMfho4_sqSSh0VqMB80xT2yXp_ZAY8_ufC3CFXhHIE1NvwkxSfO_6bbb_ScfT_zPgcnJMKyGltOg', // key for http://localhost + 'plugins_maps_markerThumbSize' => '350', ); Modified: trunk/linpha2/lib/plugins/maps/LinMaps.js =================================================================== --- trunk/linpha2/lib/plugins/maps/LinMaps.js 2007-11-18 22:29:28 UTC (rev 4800) +++ trunk/linpha2/lib/plugins/maps/LinMaps.js 2007-11-20 22:04:16 UTC (rev 4801) @@ -19,6 +19,7 @@ this.markersData = false; this.markersObj = new Array(); + this.imagesObj = new Array(); }, /** @@ -55,7 +56,7 @@ for( i = 0; i < myLinMaps.markersData.markers.length; i++ ) { - myLinMaps.markersObj[i] = myLinMapObject.createMarker( myLinMaps.markersData.markers[i] ); + myLinMaps.markersObj[i] = myLinMapObject.createMarker( myLinMaps.markersData.markers[i], false ); } /** @@ -134,15 +135,29 @@ assignAlbum: function(markerId,albId) { - alert( markerId + ' ' + albId ); myLinGlobal.AjaxPost('cmd=assignAlbum&markerId='+markerId+'&albId='+albId,myLinMaps.assignAlbumFinish); }, - assignAlbumFinsih: function(t) + assignAlbumChange: function(markerId,albId) { + myLinGlobal.AjaxPost('cmd=assignAlbumChange&markerId='+markerId+'&albId='+albId,myLinMaps.assignAlbumFinish); + }, + assignAlbumDelete: function(markerId,albId) { + myLinGlobal.AjaxPost('cmd=assignAlbumDelete&markerId='+markerId+'&albId='+albId,myLinMaps.assignAlbumFinish); }, - deleteAssignedAlbum: function(markerId,albId) + assignAlbumFinish: function(t) { + xmlAnswer = t.responseXML.documentElement; + // recreate marker on success + if( xmlAnswer.getElementsByTagName('responseCode').item(0).firstChild.data == 'success' ) + { + myLinMaps.loadMarkers(); + } + else + { + // print error message + alert(xmlAnswer.getElementsByTagName('responseMsg').item(0).firstChild.data ); + } }, loadAlbums: function() @@ -163,9 +178,16 @@ myLinGlobal.createPopup('linDivPopupAlbums'); }, - + + /** + * Thumbnail functions + */ loadImages: function(albId) { + this.startLoading(); + + myLinMapObject.closeMarkerWindows(); + if( !this.showNav ) { this.toggleNav(); } @@ -179,47 +201,49 @@ //myLinMaps.images = t.responseText.evalJSON(true); /** + * delete existing images + */ + $('linDivMapNav').innerHTML = ''; + if( myLinMaps.imagesObj ) + { + for( i = 0; i < myLinMaps.imagesObj.length; i++ ) + { + myLinMapObject.removeMarker( myLinMaps.imagesObj[i] ); + } + + myLinMaps.imagesObj = new Array(); + } + + + /** * draw new markers / create thumbnails list */ - $('linDivMapNav').innerHTML = ''; - //myLinMapObject.initBounds(); + myLinMapObject.initBounds(); for( i = 0; i < myLinMaps.imagesData.images.length; i++ ) { thumbId = myLinMaps.imagesData.images[i].id; - var ElemImg = Builder.node('img', {src: thumbSrc + thumbId, width: displayThumbSize, height: displayThumbSize}); - var ElemA = Builder.node('a', {href: 'javascript:myLinMaps.openImage(' + i + ')'}); + var ElemImg = Builder.node('img', {src: thumbSrc + thumbId, className: 'linImgMapThumb', width: displayThumbSize, height: displayThumbSize}); + var ElemA = Builder.node('a', {id: "thumb_"+thumbId, href: 'javascript:myLinMapObject.openImage(' + i + ')'}); var ElemDiv = Builder.node('div', {className: 'linDivMapsThumb'}); ElemA.appendChild( ElemImg ); ElemDiv.appendChild( ElemA ); $('linDivMapNav').appendChild(ElemDiv); - //myLinMaps.imagesObj[i] = myLinMapObject.createMarker( myLinMaps.imagesData.images[i] ); - + if( i == 0 ) + myLinMaps.imagesObj[i] = myLinMapObject.createMarker( myLinMaps.imagesData.images[i], true ); + else + myLinMaps.imagesObj[i] = myLinMapObject.createMarker( myLinMaps.imagesData.images[i], false ); } - //myLinMapObject.updateCenter(); + myLinMapObject.updateCenter(0); + + myLinMaps.stopLoading(); }, - - openImage: function(imgIndex) - { - alert( myLinMaps.imagesData.images[imgIndex].lat + ' ' + myLinMaps.imagesData.images[imgIndex].lon); - }, - -/* getMarkerInfo: function( markerNode ) // maybe use markerId oder markerIndex (but that could be unsafe) - { - var infoStr = '<b>' + markerNode.name + '</b><br />' + markerNode.text; - - return infoStr; - },*/ - - /** - * Thumbnail functions - */ toggleNav: function() { @@ -247,6 +271,15 @@ // update google map size myLinMapObject.checkResize(); + }, + + + + startLoading: function() { + Element.show('linDivLoadingOuter'); + }, + stopLoading: function() { + Element.hide('linDivLoadingOuter'); } Modified: trunk/linpha2/lib/plugins/maps/class.googlemaps.js =================================================================== --- trunk/linpha2/lib/plugins/maps/class.googlemaps.js 2007-11-18 22:29:28 UTC (rev 4800) +++ trunk/linpha2/lib/plugins/maps/class.googlemaps.js 2007-11-20 22:04:16 UTC (rev 4801) @@ -89,7 +89,7 @@ googlemap.setCenter(this.bounds.getCenter(), zoom); }, - createMarker: function( markerNode ) + createMarker: function( markerNode, markerType, openMarker ) { /*var icon = new GIcon(); icon.image = image[0]; @@ -135,7 +135,24 @@ //alert( markerNode.id + ' ' + markerNode.name + ' ' + markerNode.lat + ' ' + markerNode.lon); var point = new GLatLng( markerNode.lat, markerNode.lon); - var icon = new GIcon(G_DEFAULT_ICON, "http://maps.google.com/mapfiles/ms/micons/blue-dot.png") + + switch(markerNode.type) { + case 'album': + var icon = new GIcon(G_DEFAULT_ICON, "http://maps.google.com/mapfiles/ms/micons/blue-dot.png") + break; + case 'marker': + var icon = new GIcon(G_DEFAULT_ICON, "http://maps.google.com/mapfiles/ms/micons/purple-dot.png") + break; + case 'albumWithImg': + var icon = new GIcon(G_DEFAULT_ICON, "http://maps.google.com/mapfiles/ms/micons/green-dot.png") + break; + case 'images': + var icon = new GIcon(G_DEFAULT_ICON, "http://maps.google.com/mapfiles/ms/micons/yellow-dot.png") + break; + default: + var icon = new GIcon(G_DEFAULT_ICON, "http://maps.google.com/mapfiles/ms/micons/blue-dot.png") + break; + } icon.iconSize = new GSize(32, 32); var marker = new GMarker(point, icon); @@ -147,6 +164,10 @@ this.bounds.extend(point); + if( openMarker ) { + GEvent.trigger(marker, 'click'); + } + return marker; }, @@ -180,11 +201,20 @@ myLinMaps.updateEditMarker(); }, + closeMarkerWindows: function() { + googlemap.closeInfoWindow(); + }, + removeMarker: function( marker) { googlemap.removeOverlay( marker ); }, + openImage: function(imgIndex) + { + GEvent.trigger(myLinMaps.imagesObj[imgIndex], 'click'); + }, + checkResize: function() { //alert("typeof googlemap.checkResize: " + typeof googlemap.checkResize ); Modified: trunk/linpha2/lib/plugins/maps/module.maps.php =================================================================== --- trunk/linpha2/lib/plugins/maps/module.maps.php 2007-11-18 22:29:28 UTC (rev 4800) +++ trunk/linpha2/lib/plugins/maps/module.maps.php 2007-11-20 22:04:16 UTC (rev 4801) @@ -50,23 +50,28 @@ while($data = $query->FetchRow()) { - $path = htmlspecialchars($data['albPath'],ENT_QUOTES); - - /*if($allowed) { - if( $data['albId'] != 0 ) { - $text = '<a href=\'javascript:myLinMaps.assignAlbumChange('.$data['id'].','.$data['albId'].')\'>'.i18n("Change Assigned Album").'</a>' . - '<br /><a href=\'javascript:myLinMaps.deleteAssignedAlbum('.$data['id'].','.$data['albId'].')\'>'.i18n("Delete Assigned Album").'</a>'; + if( $data['albId']!=0 ) { + + $query2 = $GLOBALS['linpha']->db->Execute("SELECT P.parent_id " . + "FROM ".LIN_PREFIX."meta_exif E INNER JOIN ".LIN_PREFIX."photos P on E.md5sum = P.md5sum " . + "WHERE gpslatituderef IS NOT NULL " . + "AND gpslatitude IS NOT NULL " . + "AND gpslongituderef IS NOT NULL " . + "AND gpslongitude IS NOT NULL " . + "AND P.parent_id = '".LinSql::linAddslashes($data['albId'])."'"); + if($query2->EOF) { + $type = 'album'; } else { - $text = '<a href=\'javascript:myLinMaps.assignAlbum('.$data['id'].',0)\'>'.i18n("Assign Album").'</a>'; + $type = 'albumWithImg'; } - - $text .= '<br /><a href=\'javascript:if(confirm(\'test\')){myLinMaps.deleteMarker('.$data['id'].')}\'>'.i18n("Delete Marker").'</a>'; - + } else { - $text = $path; - }*/ + $type = 'marker'; + } + + $path = htmlspecialchars($data['albPath'],ENT_QUOTES); - echo '{"id": '.$data['id'].', "albId": '.$data['albId'].', "path": "'.$path.'", ' . + echo '{"id": '.$data['id'].', "type": "'.$type.'", "albId": '.$data['albId'].', "path": "'.$path.'", ' . '"name": "'.htmlspecialchars($data['markerName'],ENT_QUOTES).'", ' . '"lat": '.$data['markerLat'].', "lon": '.$data['markerLon'].', ' . '"zoom": '.$data['markerZoom'].'}'; @@ -176,6 +181,8 @@ break; case 'assignAlbum': + case 'assignAlbumChange': + case 'assignAlbumDelete': header('Content-type: text/xml'); echo '<?xml version="1.0" ?>'."\n"; @@ -196,8 +203,12 @@ $markerId = intval($_REQUEST['markerId']); $albId = intval($_REQUEST['albId']); + $arrAlbPath = LinSql::getFullFilenameFromId($albId); + $albPath = implode('/',$arrAlbPath); + $GLOBALS['linpha']->db->Execute("UPDATE ".LIN_PREFIX."plugins_maps_markers " . - "SET albId = '".LinSql::linAddslashes($albId)."' WHERE id='".LinSql::linAddslashes($markerId)."'"); + "SET albId = '".LinSql::linAddslashes($albId)."', " . + "albPath = '".LinSql::linAddslashes($albPath)."' WHERE id='".LinSql::linAddslashes($markerId)."'"); echo '<responseCode>success</responseCode>'."\n"; } @@ -278,7 +289,7 @@ $latlon = getExifLatLon($data); echo '{"id": '.$data['id'].', "parent_id": '.$data['parent_id'].', ' . - '"name": "'.htmlspecialchars( $data['name'] ,ENT_QUOTES).'", ' . + '"type": "images", "text": "", "name": "'.htmlspecialchars( $data['name'] ,ENT_QUOTES).'", ' . '"lat": '.$latlon['gpslatitude'].', "lon": '.$latlon['gpslongitude'] . "}"; Modified: trunk/linpha2/templates/default/maps.head.php =================================================================== --- trunk/linpha2/templates/default/maps.head.php 2007-11-18 22:29:28 UTC (rev 4800) +++ trunk/linpha2/templates/default/maps.head.php 2007-11-20 22:04:16 UTC (rev 4801) @@ -9,6 +9,7 @@ var displayThumbSize = <?php echo $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_display']; ?>; var linMapsDefaultMarkerZoom = <?php echo $GLOBALS['linpha']->sql->config->value['plugins_maps_defaultMarkerZoom']; ?>; +var linMapsMarkerThumbSize = <?php echo $GLOBALS['linpha']->sql->config->value['plugins_maps_markerThumbSize']; ?>; </script> <?php Modified: trunk/linpha2/templates/default/maps.html.php =================================================================== --- trunk/linpha2/templates/default/maps.html.php 2007-11-18 22:29:28 UTC (rev 4800) +++ trunk/linpha2/templates/default/maps.html.php 2007-11-20 22:04:16 UTC (rev 4801) @@ -30,12 +30,17 @@ <div id="linDivPopupHelp" style="display: none"> <div> - Legend:<br /> - (red) current marker<br /> - (yellow) location marker<br /> - (blue) location marker with assigned albums<br /> - (green) location marker with assigned images (GPS)<br /> - (pink) images<br /> + <b><?php echo i18n("Legend:"); ?></b><br /><br /> + <img src="http://maps.google.com/mapfiles/ms/micons/red-dot.png" style="vertical-align:middle" alt="red" /> + <?php echo i18n("Current Marker"); ?><br /><br /> + <img src="http://maps.google.com/mapfiles/ms/micons/purple-dot.png" style="vertical-align:middle" alt="blue" /> + <?php echo i18n("Location Marker"); ?><br /><br /> + <img src="http://maps.google.com/mapfiles/ms/micons/blue-dot.png" style="vertical-align:middle" alt="purple" /> + <?php echo i18n("Location Marker With Assigned Albums"); ?><br /><br /> + <img src="http://maps.google.com/mapfiles/ms/micons/green-dot.png" style="vertical-align:middle" alt="green" /> + <?php echo i18n("Location Marker With Assigned Images (GPS)"); ?><br /><br /> + <img src="http://maps.google.com/mapfiles/ms/micons/yellow-dot.png" style="vertical-align:middle" alt="yellow" /> + <?php echo i18n("Images"); ?><br /><br /> </div> <?php @@ -44,27 +49,27 @@ ?> <br /> <div> - Create marker:<br /> + <b>Create marker:</b><br /> 1. Enter address or just press "Geocode"<br /> 2. Drag the marker to fine adjust<br /> 3. Check marker name<br /> 4. Press "Save"<br /> <br /> - Assign albums:<br /> + <b>Assign albums:</b><br /> 1. Click on a marker<br /> 2. Press "Assign album"<br /> 3. Choose album and press "Save"<br /> 4. Repeat for multiple albums<br /> <br /> - Assign images to an album marker:<br /> + <b>Assign images to an album marker:</b><br /> This is done automatically. But it's required that your images have the GPS information stored inside. You will need a GPS Data Logger to do this automatically. It is also possible do it manually. Robogeo is a tool, but - it is not free. + it is not free.<br /> </div> <div> - Not assigned images:<br /> + <b>Not assigned images:</b><br /> albums/album1 (22 images)<br /> </div> <?php @@ -95,34 +100,64 @@ </fieldset> </div> +<div id="linDivLoadingOuter" style="display: none;" class="linBackground"> + <?php echo $linTpl->divRoundCorners('top'); ?> + <div id="linDivLoading"> + <img src="<?php echo LINPHA_CLIENT; ?>/lib/graphics/loading.gif" /> + </div> + <?php echo $linTpl->divRoundCorners('bottom'); ?> +</div> + <script language="JavaScript" type="text/javascript"> function linGetMarkerHtml(markerNode) { - var htmlStr = '<b>' + markerNode.name + '</b><br />' + markerNode.path; - <?php - if( $GLOBALS['linpha']->sql->checkPermission('plugins_maps_setMarkers') ) + var htmlStr = '<b>' + markerNode.name + '</b><br />'; + + if( markerNode.type == 'images' ) { - ?> - htmlStr += '<br /><br /><form><select name="linInputAlbum" style="width: 250px;"><?php - linBuildAlbumSelect($with_all_albs_entry=false,$with_linebreaks=false); ?></select><br />'; + htmlStr += '<img src="'+imageSrc+markerNode.id+'" width="' + + linMapsMarkerThumbSize+'" >' + markerNode.text; - if(markerNode.albId != 0) + $('thumb_'+markerNode.id).focus(); + } + else + { + + if( markerNode.albId != 0 ) { + htmlStr += '<?php echo i18n("Album"); ?>: ' + markerNode.path + '<br />'; + + if( markerNode.type == 'albumWithImg') { + htmlStr += '<a href="javascript:myLinMaps.loadImages('+ markerNode.albId +')"><?php + echo i18n("Open Images"); ?></a><br />'; + } + } + + <?php + if( $GLOBALS['linpha']->sql->checkPermission('plugins_maps_setMarkers') ) { - htmlStr += '<input type="button" value="<?php echo i18n("Change Assigned Album"); - ?>" onclick="myLinMaps.assignAlbumChange(' + markerNode.id + ',this.form.linInputAlbum.value)">' + - '<br /><input type="button" value="<?php echo i18n("Delete Assigned Album"); - ?>" onclick="myLinMaps.deleteAssignedAlbum(' + markerNode.id + ',' + markerNode.albId + ')">'; - } else { - htmlStr += '<input type="button" value="<?php echo i18n("Assign Album"); - ?>" onclick="myLinMaps.assignAlbum(this.form.linInputAlbum.value)">'; + ?> + htmlStr += '<br /><fieldset style="width: 350px;"><legend><?php + echo i18n("Edit Marker"); ?></legend><form><select name="linInputAlbum" style="width: 250px;"><?php + linBuildAlbumSelect($with_all_albs_entry=false,$with_linebreaks=false); ?></select><br />'; + + if(markerNode.albId != 0) + { + htmlStr += '<input type="button" value="<?php echo i18n("Change Assigned Album"); + ?>" onclick="myLinMaps.assignAlbumChange(' + markerNode.id + ',this.form.linInputAlbum.value)">' + + '<input type="button" value="<?php echo i18n("Delete"); + ?>" onclick="myLinMaps.assignAlbumDelete(' + markerNode.id + ',0)"><br /><br />'; + } else { + htmlStr += '<input type="button" value="<?php echo i18n("Assign Album"); + ?>" onclick="myLinMaps.assignAlbum(' + markerNode.id + ', this.form.linInputAlbum.value)">'; + } + + htmlStr += '<input type="button" value="<?php echo i18n("Delete Marker"); ?>" onclick="if(confirm(\'<?php + echo sprintf(LIN_STR_CONFIRMDELETE, i18n("this marker")); + ?>\')){myLinMaps.deleteMarker(' + markerNode.id + ');}"></form></fieldset>'; + <?php } - - htmlStr += '<input type="button" value="<?php echo i18n("Delete Marker"); ?>" onclick="if(confirm(\'<?php - echo sprintf(LIN_STR_CONFIRMDELETE, i18n("this marker")); - ?>\')){myLinMaps.deleteMarker(' + markerNode.id + ');}"></form>'; - <?php + ?> } - ?> return htmlStr; } Modified: trunk/linpha2/templates/default/themes/default/colorsettings.php =================================================================== --- trunk/linpha2/templates/default/themes/default/colorsettings.php 2007-11-18 22:29:28 UTC (rev 4800) +++ trunk/linpha2/templates/default/themes/default/colorsettings.php 2007-11-20 22:04:16 UTC (rev 4801) @@ -26,7 +26,7 @@ background-color: #<?php echo $_GET['bodybg']; ?>; } - #linDivMainOuter, #linDivMetaStaticOuter, #linDivNavigationOuter, .linButton, #linDivThumbnaviOuter, #linDivSlideshowControls, .roundAlphabottomInner { + #linDivMainOuter, #linDivMetaStaticOuter, #linDivNavigationOuter, .linButton, #linDivThumbnaviOuter, #linDivSlideshowControls, .roundAlphabottomInner, .linBackground { background-color: #<?php echo $_GET['bg']; ?>; } Modified: trunk/linpha2/templates/default/themes/default/css/maps.css =================================================================== --- trunk/linpha2/templates/default/themes/default/css/maps.css 2007-11-18 22:29:28 UTC (rev 4800) +++ trunk/linpha2/templates/default/themes/default/css/maps.css 2007-11-20 22:04:16 UTC (rev 4801) @@ -1,3 +1,8 @@ + +form { + margin: 0; +} + #linDivMapMain { height: 675px; } @@ -39,12 +44,28 @@ background-color: white; } -#linDivEditMarker form { - margin: 0; -} .linInputEditMarker { display: block; float: left; width: 125px; -} \ No newline at end of file +} + +.linImgMapThumb { + border: 1px solid grey; +} + +#linDivLoadingOuter { + position: absolute; + top: 40%; + left: 40%; + z-index: 100; +} + +#linDivLoading { + width: 50px; + height: 30px; + + padding-top: 3px; + padding-left: 20px; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |