[Chameleon] Using context files on startup with chameleon
Paul Spencer
pagameba at magma.ca
Mon May 31 12:26:08 EDT 2004
Liz,
the code would look something like:
$aszFile = file( $szURL );
$szContext = tempnam($_SESSION['gszTmpPath'], "context").".cml";
$fh = fopen($szContext, "w");
$nLines = count($aszFile);
for($i=0; $i<$nLines; $i++)
{
fwrite($fh, $aszFile[$i]);
}
fclose($fh);
This will copy the remote file from $szURL to a local temporary file
$szContext, which you can then use to open using the mapscript function.
Note that you would have to do this after the call to initialize the
application object, because you may not have $_SESSION['gszTmpPath']
before than.
Also, you will need to add some logic to prevent you from loading it
multiple times ... I'd suggest using a session variable:
if (!$_SESSION['gbContextLoaded'])
{
//load context
$_SESSION['gbContextLoaded'] = true;
}
Cheers,
PAul
Godwin, Liz wrote:
> I have a chameleon application that is running with a plain map file and
> a context file, which contains the layer info for the map.
>
> In my index.phtml file, the context is loaded with the
> oMap->loadMapContext() command.
>
> This command will ONLY accept a FULL local filesystem string. ie..
> "/ms4w/apps/appname/htdocs/contextfile.xml"
>
> I'd like to write my application to allow it to accept a remote context
> file (http://host/appname/contextfile.xml)? I know chameleon is capable
> because it has a widget that does this. What code would I need to use
> here instead. I'm poking around the ContextSelector widget, but if
> someone has a quick answer it may save me some time.
>
> Thanks!
>
> Liz Godwin
> ------------------------------------------------------------------------
> Agriculture and Agri-Food Canada/Agriculture et Agroalimentaire Canada
> 960 Carling Ave/960 av Carling
> Ottawa, ON
> Telephone/Téléphone: 613-759-1850
> Facsimile/Télécopieur: 613-759-1937
> godwinl at agr.gc.ca <mailto:godwinl at agr.gc.ca>
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Chameleon mailing list
> Chameleon at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/chameleon
--
-----------------------------------------------------------------
|Paul Spencer pspencer at dmsolutions.ca |
|-----------------------------------------------------------------|
|Applications & Software Development |
|DM Solutions Group Inc http://www.dmsolutions.ca/|
-----------------------------------------------------------------
More information about the Chameleon
mailing list