If your date.php file is on a separate server, it seems like a good idea to
save the sample code in a local file, as you've done, and then make that script
issue a subsequent request to date.php.
It looks like the SESSION parameter is not getting sent to your script. It
could be a case issue - it might get sent as lowercase 'session' instead. Are
you able to use Fiddler or Firebug to determine which parameters are actually
getting sent to your script? I also remember seeing a defect where the
parameters got sent twice, which caused problems.
If your InvokeUrl.js (in the fusion/widgets folder) contains a section like
this:
execute : function() {
var url = this.sBaseUrl;
//add in other parameters to the url here
var map = this.getMap();
var params = [];
params.push('LOCALE='+Fusion.locale);
params.push('SESSION='+map.getSessionID());
params.push('MAPNAME='+map.getMapName());
params = params.concat(this.additionalParameters);
try changing it to:
execute : function() {
var url = this.sBaseUrl;
//add in other parameters to the url here
var map = this.getMap();
var taskPaneTarget = Fusion.getWidgetById(this.sTarget);
var params = [];
if ( taskPaneTarget == null ) {
params.push('LOCALE='+Fusion.locale);
params.push('SESSION='+map.getSessionID());
params.push('MAPNAME='+map.getMapName());
}
params = params.concat(this.additionalParameters);
An alternative approach would be to fix the InvokeUrl.js file so that it
handles the $CurrentSelection variable correctly, but that would require a bit
of figuring out.
Chris.
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of achectl
Sent: Wednesday, March 25, 2009 3:40 AM
To: [email protected]
Subject: RE: [mapguide-users] What is %24CurrentSelection???
I also tried to put the php file to fusion template directory and then run the
invokeurl widget.
<?php
$mapName = "";
$sessionId = "";
try
{
// Initialize the web tier API
MgInitializeWebTier("C:\Program
Files\MapGuideOpenSource2.0\WebServerExtensions\www\webconfig.ini");
// Read the map name and session ID
GetRequestParameters();
// Create a site connection
$user = new MgUserInformation($sessionId);
$siteConnection = new MgSiteConnection();
$siteConnection->Open($user);
// Create a resource service instance
$resourceService = $siteConnection->CreateService(0);
// Retrieve the selection
$selection = new MgSelection($map, $selectionXml);
//$selection = new MgSelection();
//$selection->Open($resourceService, $mapName);
// Output the selection
echo $selection->ToXml();
}
catch(MgException $e)
{
// Output error details
echo "<Message>" . $e->GetMessage() . "</Message>";
echo "<Details>" . $e->GetDetails() . "</Details>";
}
function GetParameters($params)
{
global $mapName;
global $sessionId;
$mapName = $params['MAPNAME'];
$sessionId = $params['SESSION'];
}
function GetRequestParameters()
{
if($_SERVER['REQUEST_METHOD'] == "POST")
GetParameters($_POST);
else
GetParameters($_GET);
}
?>
It prompts the error as below:
Invalid argument(s): [1] = "" The session ID is invalid because the session
separator character was not found.Invalid argument(s): [1] = "" The session ID
is invalid because the session separator character was not found. Exception
occurred in method MgUserInformation.SetMgSessionId at line 183 in file
d:\build\mapguide_open_source_v2.0\build_30.11\mgdev\common\mapguidecommon\System/UserInformation.cpp
The php file should be run the same server with mapguide.
Hi Chris,
I tried to add the syntax to the date.php by using "include "mapguide.php";",
the MgInitializeWebTier path was updated. And I would like to mention that the
date.php isn't running into mapguide web server. It is running on xampp LAMP
software of Windows.
And I tried to run the php program date.php, the error was prompted.
Fatal error: Call to undefined function mginitializewebtier() in
C:\xampp\htdocs\mrbs\web\mapguide.php on line 9
Also I have added the path as below into the php.ini file.
; Directory in which the loadable extensions (modules) reside.
extension_dir = "C:\Program
Files\MapGuideOpenSource2.0\WebServerExtensions\php\ext"
extension=php_MapGuideApi.dll
The result is same.
I have question, why the parameter (e.g. SESSION, LOCALE & MAPNAME) of
invokeURL.js file do not added to the date.php, but the invoke url have right
parameters! It is not %24CurrentSelection.
Thanks.
You should be able to include this code at the beginning of your own php file.
I believe it is called date.php. This file presumably does something useful
with the information about the current selection. You should be able to
retrieve the information you need from the MgSelection object using some simple
php calls instead of calling echo $selection->ToXml().
>From your original screenshots it looks like you have already managed to
>create an InvokeURL command in MapGuide Studio, but if you have specific
>questions about the process, let me know.
Chris.
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of achectl
Sent: Tuesday, March 17, 2009 10:52 PM
To: [email protected]
Subject: RE: [mapguide-users] What is %24CurrentSelection???
Thanks a lot Chris
Which file I need to modify and copy & place the below PHP code to that file
for testing? I will try to modify the code. Note: I will change the path for
webconfig.ini. :-( I need to complete the invokeURL problem asap. What is
the proper way to do InvokeURL of MapGuide Studio?
Thanks
Achectl
Chris Claydon wrote:
>
> In a basic web layout, I'm pretty sure $CurrentSelection returns you the
> current selection in XML format. This corresponds to the string you get if
> you call ToXml() on an MgSelection object using the web tier API.
>
> It appears that the flexible web layout code does not treat
> $CurrentSelection as a special case, and simply returns the URL-encoded
> version of variable name itself.
>
> The solution is to get hold of the MgSelection object for the current map
> selection within the invoked PHP code. The following PHP code will dump
> out the selection XML. You should be able to extend it pretty easily to
> extract exactly what you need from the selection...
>
> (Note that you may need to adjust the path to the webconfig.ini file in
> the call to MgInitializeWebTier)
>
> Hope this helps,
>
> Chris.
>
> <?php
>
> $mapName = "";
> $sessionId = "";
>
> try
> {
> // Initialize the web tier API
> MgInitializeWebTier("C:/Program
> Files/Autodesk/MapGuideEnterprise2009/WebServerExtensions/www/webconfig.ini");
>
> // Read the map name and session ID
> GetRequestParameters();
>
> // Create a site connection
> $user = new MgUserInformation($sessionId);
> $siteConnection = new MgSiteConnection();
> $siteConnection->Open($user);
>
> // Create a resource service instance
> $resourceService = $siteConnection->CreateService(0);
>
> // Retrieve the selection
> $selection = new MgSelection();
> $selection->Open($resourceService, $mapName);
>
> // Output the selection
> echo $selection->ToXml();
> }
> catch(MgException $e)
> {
> // Output error details
> echo "<Message>" . $e->GetMessage() . "</Message>";
> echo "<Details>" . $e->GetDetails() . "</Details>";
> }
>
>
> function GetParameters($params)
> {
> global $mapName;
> global $sessionId;
>
> $mapName = $params['MAPNAME'];
> $sessionId = $params['SESSION'];
> }
>
> function GetRequestParameters()
> {
> if($_SERVER['REQUEST_METHOD'] == "POST")
> GetParameters($_POST);
> else
> GetParameters($_GET);
> }
> ?>
>
>
>
_______________________________________________
mapguide-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapguide-users
--
View this message in context:
http://n2.nabble.com/What-is--24CurrentSelection----tp2490302p2531485.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
_______________________________________________
mapguide-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapguide-users
_______________________________________________
mapguide-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapguide-users