[pLog-svn] r4635 - in plog/trunk: class/action/admin class/controller class/template/smarty/plugins class/view/admin class/view/admin/chooser js/location templates/admin templates/admin/chooser
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Tue Jan 30 17:36:18 EST 2007
Author: oscar
Date: 2007-01-30 17:36:18 -0500 (Tue, 30 Jan 2007)
New Revision: 4635
Added:
plog/trunk/class/action/admin/adminlocationdisplayaction.class.php
plog/trunk/class/template/smarty/plugins/function.location_display.php
Modified:
plog/trunk/class/controller/controllermap.properties.php
plog/trunk/class/template/smarty/plugins/function.location_chooser.php
plog/trunk/class/view/admin/adminview.class.php
plog/trunk/class/view/admin/chooser/adminlocationchooserview.class.php
plog/trunk/js/location/location.js
plog/trunk/templates/admin/blogsettings.template
plog/trunk/templates/admin/chooser/header.template
plog/trunk/templates/admin/chooser/location.template
plog/trunk/templates/admin/newpost.template
plog/trunk/templates/admin/newresource.template
plog/trunk/templates/admin/resourceinfo.template
plog/trunk/templates/admin/resources.template
Log:
More changes for the integration of location data (too many to list)
Added: plog/trunk/class/action/admin/adminlocationdisplayaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminlocationdisplayaction.class.php (rev 0)
+++ plog/trunk/class/action/admin/adminlocationdisplayaction.class.php 2007-01-30 22:36:18 UTC (rev 4635)
@@ -0,0 +1,37 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/view/admin/chooser/adminlocationchooserview.class.php" );
+
+ class AdminLocationDisplayAction extends AdminAction
+ {
+ function AdminLocationDisplayAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+ }
+
+ function perform()
+ {
+ $this->_view = new AdminLocationChooserView( $this->_blogInfo );
+
+ // if the parameter is available, it takes precedence over 'lat' and 'long'
+ if( $c = $this->_request->getValue( "c" )) {
+ $coords = explode( ",", $c );
+ $this->_view->setLatitude( $coords[0] );
+ $this->_view->setLongitude( $coords[1] );
+ }
+ else {
+ $this->_view->setLatitude( $this->_request->getValue( "lat" ));
+ $this->_view->setLongitude( $this->_request->getValue( "long" ));
+ }
+
+ $this->_view->setDescription( $this->_request->getValue( "desc" ));
+
+ // and set the mode to viewer instead of chooser
+ $this->_view->setMode( LOCATION_POPUP_VIEWER_MODE );
+
+ // render the view
+ $this->setCommonData();
+ }
+ }
+?>
\ No newline at end of file
Modified: plog/trunk/class/controller/controllermap.properties.php
===================================================================
--- plog/trunk/class/controller/controllermap.properties.php 2007-01-30 21:47:30 UTC (rev 4634)
+++ plog/trunk/class/controller/controllermap.properties.php 2007-01-30 22:36:18 UTC (rev 4635)
@@ -26,6 +26,6 @@
$actions["ViewResource"] = "ViewResourceAction";
// executes a search
$actions["Search"] = "SearchAction";
- // servers a resource
+ // serves a resource
$actions["ResourceServer"] = "ResourceServerAction";
?>
\ No newline at end of file
Modified: plog/trunk/class/template/smarty/plugins/function.location_chooser.php
===================================================================
--- plog/trunk/class/template/smarty/plugins/function.location_chooser.php 2007-01-30 21:47:30 UTC (rev 4634)
+++ plog/trunk/class/template/smarty/plugins/function.location_chooser.php 2007-01-30 22:36:18 UTC (rev 4635)
@@ -31,7 +31,10 @@
// message for the "add new" string
isset( $params["addNewString"] ) ? $addNewString = $params["addNewString"] : $addNewString = "Add New";
- $code = "<select name=\"locationId\" id=\"locationId\" onChange=\"if(this.options[this.selectedIndex].value == -1) window.open('?op=locationChooser','Location Chooser','scrollbars=no,resizable=no,toolbar=no,height=540,width=620');\">";
+ // whether to use the location display icon next to the drop-down list
+ isset( $params["showDisplayLink"]) ? $showDisplayLink = true : $showDisplayLink = false;
+
+ $code = "<select name=\"locationId\" id=\"locationId\" onChange=\"if(this.options[this.selectedIndex].value == -1) window.open('?op=locationChooser','Location Chooser','scrollbars=no,resizable=no,toolbar=no,height=530,width=590');\">";
foreach( $locs as $loc ) {
$code .= "<option value=\"".$loc->getLatitude().",".$loc->getLongitude()."\"";
if( $default ) {
@@ -46,6 +49,22 @@
$code .= "<option value=\"-1\">$addNewString</option>";
$code .= " </select>";
+ if( $showDisplayLink ) {
+ $code .= "<script type=\"text/javascript\">
+ function displaySelectedLocation() {
+ list = document.getElementById('locationId');
+ if( list.options[list.selectedIndex].value == -1 )
+ return false;
+ coords = list.options[list.selectedIndex].value;
+ text = list.options[list.selectedIndex].text;
+ url = '?op=locationDisplay&c=' + coords + '&desc=' + text;
+ window.open(url,'Location Viewer','scrollbars=no,resizable=no,toolbar=no,height=500,width=590');
+ }
+ </script>
+ ";
+ $code .= " <a href=\"#\" onClick=\"displaySelectedLocation()\"><img src=\"imgs/admin/icon_globe-16.png\" alt=\"Location Display\" style=\"border:0px\" /></a>";
+ }
+
$code .= "<input type=\"hidden\" name=\"locationDesc\" id=\"locationDesc\" value=\"\" />
<input type=\"hidden\" name=\"locationLat\" id=\"locationLat\" value=\"\" />
<input type=\"hidden\" name=\"locationLong\" id=\"locationLong\" value=\"\" />";
Added: plog/trunk/class/template/smarty/plugins/function.location_display.php
===================================================================
--- plog/trunk/class/template/smarty/plugins/function.location_display.php (rev 0)
+++ plog/trunk/class/template/smarty/plugins/function.location_display.php 2007-01-30 22:36:18 UTC (rev 4635)
@@ -0,0 +1,22 @@
+<?php
+/**
+ * Smarty {location_display} function plugin
+ *
+ * Generates all code necessary to call the location viewer
+ */
+function smarty_function_location_display($params, &$smarty)
+{
+ // parameter with the locations
+ if( !isset( $params["location"] )) {
+ $smarty->trigger_error( "Error in location_display: the location parameter is missing!" );
+ }
+
+ $location = $params["location"];
+
+ $code = "window.open('?op=locationDisplay&lat=".$location->getLatitude().
+ "&long=".$location->getLongitude()."&desc=".urlencode($location->getDescription())."',".
+ "'Location Viewer','scrollbars=no,resizable=no,toolbar=no,height=500,width=590')";
+
+ return( $code );
+}
+?>
\ No newline at end of file
Modified: plog/trunk/class/view/admin/adminview.class.php
===================================================================
--- plog/trunk/class/view/admin/adminview.class.php 2007-01-30 21:47:30 UTC (rev 4634)
+++ plog/trunk/class/view/admin/adminview.class.php 2007-01-30 22:36:18 UTC (rev 4635)
@@ -91,7 +91,8 @@
// set a few common parametres...
$config =& Config::getConfig();
- $this->setValue( 'baseurl', $config->getValue( 'base_url'));
+ $this->setValue( 'baseurl', $config->getValue( 'base_url'));
+ lt_include( PLOG_CLASS_PATH."class/misc/version.class.php" );
$this->setValue( 'version', Version::getVersion());
$this->setValue( 'uploads_enabled', $config->getValue( 'uploads_enabled' ));
$this->setValue( 'bayesian_filter_enabled', $config->getValue( 'bayesian_filter_enabled' ));
Modified: plog/trunk/class/view/admin/chooser/adminlocationchooserview.class.php
===================================================================
--- plog/trunk/class/view/admin/chooser/adminlocationchooserview.class.php 2007-01-30 21:47:30 UTC (rev 4634)
+++ plog/trunk/class/view/admin/chooser/adminlocationchooserview.class.php 2007-01-30 22:36:18 UTC (rev 4635)
@@ -3,26 +3,69 @@
lt_include( PLOG_CLASS_PATH."class/view/admin/adminsiteblogslistview.class.php" );
lt_include( PLOG_CLASS_PATH."class/dao/locations.class.php" );
+ define( "LOCATION_POPUP_CHOOSER_MODE", 1 );
+ define( "LOCATION_POPUP_VIEWER_MODE", 2 );
+
/**
* \ingroup View
* @private
*/
class AdminLocationChooserView extends AdminTemplatedView
{
+ var $_lat;
+ var $_long;
+ var $_mode;
+ var $_desc;
+
function AdminLocationChooserView( $blogInfo, $params = Array())
{
$this->AdminTemplatedView( $blogInfo, "chooser/location" );
+
+ // no latitude and longitude
+ $this->_lat = 0;
+ $this->_long = 0;
+ // no description either
+ $this->_desc = "";
+
+ // the default mode is chooser
+ $this->_mode = LOCATION_POPUP_CHOOSER_MODE;
}
+ function setLatitude( $lat )
+ {
+ $this->_lat = $lat;
+ }
+
+ function setLongitude( $long )
+ {
+ $this->_long = $long;
+ }
+
+ function setDescription( $desc )
+ {
+ $this->_desc = $desc;
+ }
+
+ function setMode( $mode )
+ {
+ $this->_mode = $mode;
+ }
+
function render()
{
- // load the list of currently defined locations
- $locs = new Locations();
- $blogLocations = $locs->getBlogLocations( $this->_blogInfo->getId());
- $this->setValue( "locations", $blogLocations );
+ // load the list of currently defined locations if needed
+ if( $this->_mode == LOCATION_POPUP_CHOOSER_MODE ) {
+ $locs = new Locations();
+ $blogLocations = $locs->getBlogLocations( $this->_blogInfo->getId());
+ $this->setValue( "locations", $blogLocations );
+ }
// 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( "mode", $this->_mode );
return( parent::render());
}
Modified: plog/trunk/js/location/location.js
===================================================================
--- plog/trunk/js/location/location.js 2007-01-30 21:47:30 UTC (rev 4634)
+++ plog/trunk/js/location/location.js 2007-01-30 22:36:18 UTC (rev 4635)
@@ -32,6 +32,12 @@
var globalMarker = new GMarker( new GLatLng(0,0));
/**
+ * Whether we're in display-only mode or we are allowed
+ * to move the marker around
+ */
+var displayOnlyMode = false;
+
+/**
* The global GMap2 object, please do not modify this
*/
var map;
@@ -72,8 +78,14 @@
mapOpts = { mapTypes: new Array( G_HYBRID_MAP ) };
map = new GMap2(document.getElementById("map"), mapOpts );
// place the centre of the map somewhere in the middle of the atlantic ocean
- map.setCenter(new GLatLng(37.160316, -38.671875), 13);
- map.setZoom( 2 );
+ if( markerLat != 0 || markerLong != 0 ) {
+ map.setCenter( new GLatLng( markerLat, markerLong ), 13 );
+ LocationChooserClickHandler( null, new GLatLng( markerLat, markerLong ));
+ }
+ else {
+ map.setCenter( new GLatLng(37.160316, -38.671875), 2 );
+ }
+
// add two controls to our map
map.addControl(new GLargeMapControl());
@@ -82,7 +94,9 @@
map.addControl(new LifetypeLocationSelectorControl());
// add a click listener
- GEvent.addListener(map, "click", LocationChooserClickHandler );
+ if( !displayOnlyMode ) {
+ GEvent.addListener(map, "click", LocationChooserClickHandler );
+ }
}
}
@@ -157,7 +171,7 @@
function LocationChooserAddLocation()
{
if( !markerAdded ) {
- window.alert( "No marker has been set yet." );
+ window.alert( locationLocaleNoMarkerHasBeenSetYet );
return false;
}
@@ -170,7 +184,6 @@
coords = locationList.options[i].value.split(",");
optLatLng = new GLatLng( coords[0], coords[1] );
if( currentLatLng.equals( optLatLng )) {
- window.alert("Location already exists!");
locationList.selectedIndex = i;
return true;
}
Modified: plog/trunk/templates/admin/blogsettings.template
===================================================================
--- plog/trunk/templates/admin/blogsettings.template 2007-01-30 21:47:30 UTC (rev 4634)
+++ plog/trunk/templates/admin/blogsettings.template 2007-01-30 22:36:18 UTC (rev 4635)
@@ -64,7 +64,7 @@
<label for="locId">{$locale->tr("location")}</label>
<span class="required"*</span>
<div class="formHelp">{$locale->tr("blog_location_help")}</div>
- {location_chooser blogId=$blog->getId() addNewString=$locale->tr("add_new") default=$blog->getLocation()}
+ {location_chooser blogId=$blog->getId() addNewString=$locale->tr("add_new") default=$blog->getLocation() showDisplayLink=1}
</div>
{/if}
Modified: plog/trunk/templates/admin/chooser/header.template
===================================================================
--- plog/trunk/templates/admin/chooser/header.template 2007-01-30 21:47:30 UTC (rev 4634)
+++ plog/trunk/templates/admin/chooser/header.template 2007-01-30 22:36:18 UTC (rev 4635)
@@ -12,30 +12,5 @@
var plogBaseUrl = '{$baseurl}';
var indexPage = '{$config->getValue("script_name")}';
</script>
- <STYLE type="text/css">{literal}
- html,body {
- margin : 0px;
- padding : 5px;
- background : #FFFFFF;
- }
- #container
- {
- text-align : center;
- margin-left : auto;
- margin-right : auto;
- width : 400px;
- }
-.info
-{
- font : 12px verdana, tahoma, arial, sans-serif;
- margin-bottom : 10px;
- width : 385px;
-}
-#list_action_bar
-{
- width : 385px;
- padding : 4px;
-}
- {/literal}</style>
</head>
<body>
\ No newline at end of file
Modified: plog/trunk/templates/admin/chooser/location.template
===================================================================
--- plog/trunk/templates/admin/chooser/location.template 2007-01-30 21:47:30 UTC (rev 4634)
+++ plog/trunk/templates/admin/chooser/location.template 2007-01-30 22:36:18 UTC (rev 4635)
@@ -13,15 +13,24 @@
// localized messages
var locationLocaleNoMarkerHasBeenSetYet = "{$locale->tr("error_no_marker_set")}";
var locationLocaleNoDescriptionError = "{$locale->tr("error_no_description_set")}";
+
+ {if $mode==2}
+ var markerLat = '{$startLatitude}';
+ var markerLong = '{$startLongitude}';
+ var markerDesc = '{$startDescription}';
+ var useCustomLocationControl = false;
+ var displayOnlyMode = true;
+ {/if}
</script>
- <body onload="LocationChooserLoad()" onunload="GUnload()">
- <div id="map" style="width: 590px; height: 500px;margin-bottom: 10px;"></div>
- <div id="data" style="width:100%">
- <input type="hidden" name="lat" value="" id="lat" />
- <input type="hidden" name="long" value="" id="long" />
+ <body onload="LocationChooserLoad()" onunload="GUnload()" style="padding:0;margin:0">
+ <div id="map" style="width: 590px; height: 500px;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%" >
<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" />
{include file="$admintemplatepath/chooser/footer.template"}
\ No newline at end of file
Modified: plog/trunk/templates/admin/newpost.template
===================================================================
--- plog/trunk/templates/admin/newpost.template 2007-01-30 21:47:30 UTC (rev 4634)
+++ plog/trunk/templates/admin/newpost.template 2007-01-30 22:36:18 UTC (rev 4635)
@@ -142,7 +142,7 @@
<label for="locId">{$locale->tr("location")}</label>
<span class="required"*</span>
<div class="formHelp">{$locale->tr("article_location_help")}</div>
- {location_chooser blogId=$blog->getId() addNewString=$locale->tr("add_new")}
+ {location_chooser blogId=$blog->getId() addNewString=$locale->tr("add_new") showDisplayLink=1}
</div>
{/if}
Modified: plog/trunk/templates/admin/newresource.template
===================================================================
--- plog/trunk/templates/admin/newresource.template 2007-01-30 21:47:30 UTC (rev 4634)
+++ plog/trunk/templates/admin/newresource.template 2007-01-30 22:36:18 UTC (rev 4635)
@@ -41,7 +41,7 @@
<label for="locId">{$locale->tr("location")}</label>
<span class="required"*</span>
<div class="formHelp">{$locale->tr("location_help")}</div>
- {location_chooser locations=$locations addNewString=$locale->tr("add_new")}
+ {location_chooser locations=$locations addNewString=$locale->tr("add_new") showDisplayLink=1}
</div>
{/if}
Modified: plog/trunk/templates/admin/resourceinfo.template
===================================================================
--- plog/trunk/templates/admin/resourceinfo.template 2007-01-30 21:47:30 UTC (rev 4634)
+++ plog/trunk/templates/admin/resourceinfo.template 2007-01-30 22:36:18 UTC (rev 4635)
@@ -49,7 +49,7 @@
{/if}
{if $resource->hasLocationData()}
{assign var=loc value=$resource->getLocation()}
- {$locale->tr("location")}: <a onClick="window.open('?op=locationDisplay','Location Chooser','scrollbars=no,resizable=no,toolbar=no,height=540,width=620');return false;" href="#">{$loc->getDescription()}</a><br/>
+ {$locale->tr("location")}: <a onClick="{location_display location=$loc}" href="#">{$loc->getDescription()}</a><br/>
{/if}
</span>
</div>
Modified: plog/trunk/templates/admin/resources.template
===================================================================
--- plog/trunk/templates/admin/resources.template 2007-01-30 21:47:30 UTC (rev 4634)
+++ plog/trunk/templates/admin/resources.template 2007-01-30 22:36:18 UTC (rev 4635)
@@ -107,7 +107,10 @@
{/if}
</a><br/>
{if $resource->hasLocationData()}
- <img src="imgs/admin/icon_globe-16.png" alt="Location Data" />
+ {assign var=location value=$resource->getLocation()}
+ <a href="" onClick="{location_display location=$location}">
+ <img src="imgs/admin/icon_globe-16.png" alt="Location Data" />
+ </a>
{/if}
<a href="admin.php?op=resourceInfo&resourceId={$resource->getId()}">{$resource->getFileName()}</a>
</td>
More information about the pLog-svn
mailing list