[pLog-svn] r4690 - in plog/trunk: class/action class/controller class/gallery/dao class/net class/template/smarty/plugins class/view templates/misc templates/standard

oscar at devel.lifetype.net oscar at devel.lifetype.net
Sun Feb 4 10:57:09 EST 2007


Author: oscar
Date: 2007-02-04 10:57:09 -0500 (Sun, 04 Feb 2007)
New Revision: 4690

Added:
   plog/trunk/class/action/locationdisplay.class.php
   plog/trunk/class/view/locationview.class.php
   plog/trunk/templates/misc/location.template
Modified:
   plog/trunk/class/controller/admincontrollermap.properties.php
   plog/trunk/class/controller/controllermap.properties.php
   plog/trunk/class/gallery/dao/galleryresources.class.php
   plog/trunk/class/net/baserequestgenerator.class.php
   plog/trunk/class/template/smarty/plugins/function.location_display.php
   plog/trunk/class/view/smartyview.class.php
   plog/trunk/templates/standard/footer.template
   plog/trunk/templates/standard/post.template
   plog/trunk/templates/standard/resource.template
Log:
more changes for the google maps integration, now location data is displayed for posts, blogs and files that have it in the public side of the blog. Displaying location data is implemented in a pop-up window but I'd rather use a dhtml overlay.... it's fancier :) If anybody knows how to do it please let me know.

I will set up a test server soon for those interested in testing this feature.


Added: plog/trunk/class/action/locationdisplay.class.php
===================================================================
--- plog/trunk/class/action/locationdisplay.class.php	                        (rev 0)
+++ plog/trunk/class/action/locationdisplay.class.php	2007-02-04 15:57:09 UTC (rev 4690)
@@ -0,0 +1,29 @@
+<?php
+
+	lt_include( PLOG_CLASS_PATH."class/action/blogaction.class.php" );
+	lt_include( PLOG_CLASS_PATH."class/dao/locations.class.php" );
+	lt_include( PLOG_CLASS_PATH."class/view/locationview.class.php" );	
+
+	class LocationDisplay extends BlogAction
+	{
+		function LocationDisplay( $actionInfo, $request )
+		{
+			$this->BlogAction( $actionInfo, $request );
+		}
+		
+		function perform()
+		{
+			$locs = new Locations();
+			$location = $locs->getLocation( $this->_request->getValue( "locId" ));
+			
+			$this->_view = new LocationView( $this->_blogInfo );
+			$this->_view->setLatitude( $location->getLatitude());
+			$this->_view->setLongitude( $location->getLongitude());
+			$this->_view->setDescription( $location->getDescription());
+			
+			$this->setCommonData();
+			
+			return( true );
+		}
+	}
+?>
\ No newline at end of file

Modified: plog/trunk/class/controller/admincontrollermap.properties.php
===================================================================
--- plog/trunk/class/controller/admincontrollermap.properties.php	2007-02-04 14:42:56 UTC (rev 4689)
+++ plog/trunk/class/controller/admincontrollermap.properties.php	2007-02-04 15:57:09 UTC (rev 4690)
@@ -318,5 +318,4 @@
 	$actions["updatePluginSettings"] = "AdminUpdatePluginSettingsAction";	
 	// location chooser
 	$actions['locationChooser'] = 'AdminLocationChooserAction';
-	$actions['locationDisplay'] = 'AdminLocationDisplayAction';	
 ?>
\ No newline at end of file

Modified: plog/trunk/class/controller/controllermap.properties.php
===================================================================
--- plog/trunk/class/controller/controllermap.properties.php	2007-02-04 14:42:56 UTC (rev 4689)
+++ plog/trunk/class/controller/controllermap.properties.php	2007-02-04 15:57:09 UTC (rev 4690)
@@ -28,4 +28,6 @@
     $actions["Search"] = "SearchAction";
 	// serves a resource
 	$actions["ResourceServer"] = "ResourceServerAction";
+	// displays a location
+	$actions["locationDisplay"] = "LocationDisplay";
 ?>
\ No newline at end of file

Modified: plog/trunk/class/gallery/dao/galleryresources.class.php
===================================================================
--- plog/trunk/class/gallery/dao/galleryresources.class.php	2007-02-04 14:42:56 UTC (rev 4689)
+++ plog/trunk/class/gallery/dao/galleryresources.class.php	2007-02-04 15:57:09 UTC (rev 4690)
@@ -106,7 +106,7 @@
 			$id = $resource->getId();
 			$query = "SELECT id, owner_id, album_id, description,
         	                 date, flags, resource_type, file_path, file_name,
-        	                 metadata, thumbnail_format, properties, file_size
+        	                 metadata, thumbnail_format, properties, file_size, loc_id
         	          FROM {$prefix}gallery_resources 
 			          WHERE album_id = '$albumId' AND date >= '$date' AND id > $id
 					  ORDER BY date ASC,id ASC LIMIT 1";
@@ -146,7 +146,7 @@
 			$id = $resource->getId();
 			$query = "SELECT id, owner_id, album_id, description,
         	                 date, flags, resource_type, file_path, file_name,
-        	                 metadata, thumbnail_format, properties, file_size
+        	                 metadata, thumbnail_format, properties, file_size, loc_id
         	          FROM {$prefix}gallery_resources 
 			          WHERE album_id = '$albumId' AND date <= '$date' AND id < $id
 					  ORDER BY date DESC,id DESC LIMIT 1";

Modified: plog/trunk/class/net/baserequestgenerator.class.php
===================================================================
--- plog/trunk/class/net/baserequestgenerator.class.php	2007-02-04 14:42:56 UTC (rev 4689)
+++ plog/trunk/class/net/baserequestgenerator.class.php	2007-02-04 15:57:09 UTC (rev 4690)
@@ -694,5 +694,15 @@
 		{
 			throw( new Exception( "This function must be implemented by child classes." ));		
 		}		
+		
+		/**
+		 * Links to a location map
+		 *
+		 * @param loc Location object
+		 */
+		function locationLink( $loc )
+		{
+			return( $this->getIndexUrl(false)."?op=locationDisplay&amp;locId=".$loc->getId());
+		}
     }
 ?>
\ No newline at end of file

Modified: plog/trunk/class/template/smarty/plugins/function.location_display.php
===================================================================
--- plog/trunk/class/template/smarty/plugins/function.location_display.php	2007-02-04 14:42:56 UTC (rev 4689)
+++ plog/trunk/class/template/smarty/plugins/function.location_display.php	2007-02-04 15:57:09 UTC (rev 4690)
@@ -13,8 +13,20 @@
 	
 	$location = $params["location"];
 
-	$code = "window.open('?op=locationDisplay&amp;lat=".$location->getLatitude().
-	       "&amp;long=".$location->getLongitude()."&amp;desc=".urlencode($location->getDescription())."',".
+	if( isset( $smarty->_tpl_vars["blog"] )) {
+		$blog = $smarty->_tpl_vars["blog"];
+		$url = $blog->getBlogRequestGenerator();
+		$baseUrl = $url->getIndexUrl();
+	}
+	else {
+		include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
+		$baseUrl = $config->getValue( "base_url" );
+		if(( $scriptName = $config->getValue( "script_name" )) == "" )
+			$scriptName = "index.php";
+		$baseUrl = $baseUrl + "/".$scriptName;
+	}
+
+	$code = "window.open('".$baseUrl."?op=locationDisplay&amp;locId=".$location->getId()."',".
 	       "'Location Viewer','scrollbars=no,resizable=no,toolbar=no,height=500,width=590')";
 	
 	return( $code );

Added: plog/trunk/class/view/locationview.class.php
===================================================================
--- plog/trunk/class/view/locationview.class.php	                        (rev 0)
+++ plog/trunk/class/view/locationview.class.php	2007-02-04 15:57:09 UTC (rev 4690)
@@ -0,0 +1,74 @@
+<?php
+
+	include_once( PLOG_CLASS_PATH."class/view/view.class.php" );
+    lt_include( PLOG_CLASS_PATH.'class/template/templateservice.class.php' );	
+	
+	class LocationView extends View
+	{
+		var $_lat;
+		var $_long;
+		var $_desc;	
+		var $_blogInfo;
+		var $_width;
+		var $_height;		
+		
+		function LocationView( $blogInfo )
+		{
+			$this->View(); 
+			
+			$this->_blogInfo = $blogInfo;
+			
+			$ts = new TemplateService();			
+			$this->_template = $ts->Template( "location", "misc", $this->_blogInfo );
+			$this->_template->useTemplateLoadOrder = true;			
+			
+			$this->_width = 590;
+			$this->_height = 500;
+		}
+		
+		function setLatitude( $lat )
+		{
+			$this->_lat = $lat;
+		}
+		
+		function setLongitude( $long )
+		{
+			$this->_long = $long;
+		}
+		
+		function setDescription( $desc )
+		{
+			$this->_desc = $desc;
+		}
+		
+		function setWidth( $width )
+		{
+			$this->_width = $width;
+		}
+		
+		function setHeight( $height )
+		{
+			$this->_height = $height;
+		}
+
+		function render()
+		{
+			parent::render();
+			
+			// google API key
+			$config =& Config::getConfig();
+			$this->setValue( "google_maps_api_key", $config->getValue( "google_maps_api_key" ));
+			$this->setValue( "startLatitude", $this->_lat );
+			$this->setValue( "startLongitude", $this->_long );
+			$this->setValue( "startDescription", $this->_desc );
+			$this->setValue( 'locale', $this->_blogInfo->getLocale());
+			
+			// width and height
+			$this->setValue( 'width', $this->_width );
+			$this->setValue( 'height', $this->_height );
+			
+			$this->_template->assign( $this->_params->getAsArray());
+			print( $this->_template->fetch());
+		}		
+	}
+?>
\ No newline at end of file

Modified: plog/trunk/class/view/smartyview.class.php
===================================================================
--- plog/trunk/class/view/smartyview.class.php	2007-02-04 14:42:56 UTC (rev 4689)
+++ plog/trunk/class/view/smartyview.class.php	2007-02-04 15:57:09 UTC (rev 4690)
@@ -245,7 +245,7 @@
 				header( $header );					
 			}
 			else {
-				// send the results if needed				
+				// send the results if needed
 				$sendOutput = true;
 			}
 			

Added: plog/trunk/templates/misc/location.template
===================================================================
--- plog/trunk/templates/misc/location.template	                        (rev 0)
+++ plog/trunk/templates/misc/location.template	2007-02-04 15:57:09 UTC (rev 4690)
@@ -0,0 +1,45 @@
+{assign var=htmlarea value=$blogsettings->getValue("htmlarea_enabled")}
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html>
+ <head>
+  <meta http-equiv="Content-Type" content="text/html; charset={$locale->getCharset()}"/> 
+  <link rel="stylesheet" href="styles/admin.css" type="text/css" />
+  <title>LifeType Admin</title>
+  <script type="text/javascript" src="js/ui/common.js"></script>
+  <script type="text/javascript" src="js/ui/forms.js"></script>
+  <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key={$google_maps_api_key}" type="text/javascript"></script>
+  <script type="text/javascript" src="js/location/location.js"></script>
+  <script type="text/javascript">
+	var locations = new Array(
+	  new Array( "0,0", "-- {$locale->tr("select")} --" )
+	  {foreach from=$locations item=loc name=locationsLoop}
+	  {if $smarty.foreach.locationsLoop.first},{/if}
+	  new Array( "{$loc->getLatitude()},{$loc->getLongitude()}", "{$loc->getDescription()}" ){if !$smarty.foreach.locationsLoop.last},{/if}
+	  {/foreach}
+	);
+	// localized messages
+	var locationLocaleNoMarkerHasBeenSetYet = "{$locale->tr("error_no_marker_set")}";
+	var locationLocaleNoDescriptionError    = "{$locale->tr("error_no_description_set")}";
+	
+	var markerLat = '{$startLatitude}';
+	var markerLong = '{$startLongitude}';
+	var markerDesc = '{$startDescription}';
+	var useCustomLocationControl = false;
+	var displayOnlyMode = true;
+  </script>
+</head>
+<body>
+  <body onload="LocationChooserLoad()" onunload="GUnload()" style="padding:0;margin:0">
+    <div id="map" style="width: {$width}px; height: {$height}px;margin:0;margin-bottom:5px;padding:0;"></div>
+    {if $mode==1}
+    <div id="data" style="width:100%;padding-left:10px">
+    Description:
+    <input type="text" name="locationDesc" value="" id="locationDesc" style="width:60%" >&nbsp;
+    <input type="button" onClick="if( LocationChooserAddLocation()) window.close(); " value="{$locale->tr("add_location")}" />
+    </div>
+    {/if}
+    <input type="hidden" name="lat" value="" id="lat" />
+    <input type="hidden" name="long" value="" id="long" />
+	</body>
+</html>
\ No newline at end of file

Modified: plog/trunk/templates/standard/footer.template
===================================================================
--- plog/trunk/templates/standard/footer.template	2007-02-04 14:42:56 UTC (rev 4689)
+++ plog/trunk/templates/standard/footer.template	2007-02-04 15:57:09 UTC (rev 4690)
@@ -13,7 +13,12 @@
   	<img id="UserPicture" src="{$picture->getPreviewLink()}" alt="{$blogOwner->getUsername()}" />
   	<p>{$AboutMyself}</p>
   	<div class="clearer">&nbsp;</div>
+	{if $blog->hasLocationData()}
+		{assign var=loc value=$blog->getLocation()}
+		{$locale->tr("location")}: <a href="#" onClick="javascript:{location_display location=$loc}">{$loc->getDescription()}</a>
+	{/if}
   	</div>
+
 {/if}
 
 

Modified: plog/trunk/templates/standard/post.template
===================================================================
--- plog/trunk/templates/standard/post.template	2007-02-04 14:42:56 UTC (rev 4689)
+++ plog/trunk/templates/standard/post.template	2007-02-04 15:57:09 UTC (rev 4690)
@@ -14,6 +14,9 @@
 <img src="{$url->getTemplateFile("imgs/permalink.gif")}" alt="" /><a title="{$locale->tr("permalink_title")} -> {$post->getTopic()}" href="{$url->postPermalink($post)}">{$locale->tr("permalink")}</a> | 
 {if $blogsettings->getValue("comments_enabled") && $post->getCommentsEnabled()==1 || $post->getNumComments() > 0 }<img src="{$url->getTemplateFile("imgs/comment.gif")}" alt="" /><a href="{$url->postPermalink($post)}#comments" title="{$locale->tr("comments")|capitalize} -> {$post->getTopic()}">{if $post->getNumComments() == 0 }{$locale->tr("add_comment")}{else if}{$locale->tr("comments")|capitalize} ({$post->getNumComments()}){/if}</a> | {/if} 
 <img src="{$url->getTemplateFile("imgs/trackback.gif")}" alt="" />{if $post->getNumTrackbacks() > 0}<a href="{$url->postTrackbackStatsLink($post)}" title="{$locale->tr("trackbacks")} -> {$post->getTopic()}">{$locale->tr("trackbacks")} ({$post->getNumTrackbacks()})</a>{else}{$locale->tr("trackbacks")} ({$post->getNumTrackbacks()}){/if}
+{if $post->hasLocationData()} 
+| {$locale->tr("location")}: {assign var=loc value=$post->getLocation()}<a href="#" onClick="javascript:{location_display location=$loc}">{$loc->getDescription()}</a>
+{/if}
 </p>
 
 {else}
@@ -24,6 +27,9 @@
 {assign var=prevpost value=$post->getPrevArticle()}{if $prevpost == true}<img src="{$url->getTemplateFile("imgs/previous.gif")}" alt="" /><a href="{$url->postPermalink($prevpost)}" title="{$locale->tr("previous_post")}: {$prevpost->getTopic()}">{$locale->tr("previous_post")}</a> | {/if} 
 {if $blogsettings->getValue("comments_enabled") && $post->getCommentsEnabled()==1 || $post->getNumComments() > 0 }<img src="{$url->getTemplateFile("imgs/comment.gif")}" alt="" />{$locale->tr("comments")|capitalize} ({$post->getNumComments()}) | {/if}
 <img src="{$url->getTemplateFile("imgs/trackback.gif")}" alt="" />{if $post->getNumTrackbacks() > 0}<a href="{$url->postTrackbackStatsLink($post)}" title="{$locale->tr("trackbacks")} -> {$post->getTopic()}">{$locale->tr("trackbacks")} ({$post->getNumTrackbacks()})</a>{else}{$locale->tr("trackbacks")} ({$post->getNumTrackbacks()}){/if}
+{if $post->hasLocationData()} 
+| {$locale->tr("location")}: {assign var=loc value=$post->getLocation()}<a href="#" onClick="javascript:{location_display location=$loc}">{$loc->getDescription()}</a>
+{/if}
 </p>
 
-{/if}
+{/if}
\ No newline at end of file

Modified: plog/trunk/templates/standard/resource.template
===================================================================
--- plog/trunk/templates/standard/resource.template	2007-02-04 14:42:56 UTC (rev 4689)
+++ plog/trunk/templates/standard/resource.template	2007-02-04 15:57:09 UTC (rev 4690)
@@ -9,7 +9,12 @@
 
 	<div id="Resource-Desc">
     	<a href="{$url->resourceDownloadLink($resource)}">{$locale->tr("download")}</a> 
-    	({$metadata->getRoundedSize()}) | {$locale->tr("created")} {$locale->formatDate($updated,"%d %b, %Y")}</div>
+    	({$metadata->getRoundedSize()}) | {$locale->tr("created")} {$locale->formatDate($updated,"%d %b, %Y")}<br/>
+		{if $resource->hasLocationData()}
+		 {assign var=location value=$resource->getLocation()}
+		 {$locale->tr("location")}: <a href="#" onClick="{location_display location=$location}">{$location->getDescription()}</a>
+		{/if}
+	</div>
  
  	<div id="Resource">    
   	<p>{$resource->getDescription()}</p>
@@ -51,7 +56,7 @@
  	</div>
  
  
-		{assign var=album value=$resource->getAlbum()} 
+		{assign var=album value=$resource->getAlbum()} 
 	<p><a href="{$url->albumLink($album)}">{$locale->tr("parent")}</a></p>
 
 </div>



More information about the pLog-svn mailing list