[Cartoweb-users] Problem ini file parsing and question about switches

Dirk Jesko ml.dje at geocontent.de
Fri Apr 13 11:29:08 EDT 2007


Hello Alexandre,

thanks. Maybe, I made a wrong assumption. I thought, all ini files are 
handled equally and I can add additional keys that I need in an extended 
plugin without problems.

This is what I did resp. planning to do:
So far, I have an extended exportPdf plugin (cExportPdf), which, among 
other things, generates a copyright message based on the activated 
layers. The messages are currently stored in metadata entries within the 
map file. The client part of the plugin concatenates the messages of all 
currently active layers (duplicates are removed). The generated string 
is assigned to a certain block which is defined in exportPdf.ini. There 
is no problem with this part.

Now, I would like to change the way of storing the copyright messages 
and generating the string, since ther are identical messages for many 
layers. Therefore, my idea was to define the messages for groups of 
layers within the ini file of the exportPdf plugin (or my cExportPdf 
plugin). The best idea I that came into my mind was to define the layers 
and according messages in the way I described (I took that approach from 
the locate.ini). Then I planned to use ConfigParser::parseObjectArray to 
retrieve the layer lists and messages.

The simple problem that I can not solve is: How do I get my extended 
plugin to read the additional configuration entries so I can use them 
within the Client class?

I would like to change as little as possible of the existing code. If 
the idea with the ini file does not work, I will stay with the layer 
metadata approach.


Thanks for any help,
Dirk



Alexandre Saunier wrote:
> Hello
>
> Dirk Jesko wrote:
>> 1. I have extended the exportPdf plugin to handle copyright strings. 
>> The plan is to define the strings in exportPdf.ini in the following way
>>
>> copyright.0.layers = layer1, layer2, ...
>> copyright.0.text = "Copyright message 1"
>> copyright.1.layers = layer3, layer4, ...
>> copyright.1.text = "Copyright message 2"
>> ...
>>
>> Then I would like to retrieve the information in the client part of 
>> the plugin. However, as soon as the definition are added to 
>> exportPdf.ini, I get the following error while Cartoweb is loading
>>
>> PHP Parse error:  parse error, unexpected T_LNUMBER, expecting 
>> T_STRING or T_VARIABLE or '{' or '$' in 
>> C:\www\cartoweb3\common\StructHandler.php(47) : eval()'d code on line 1
>>
>> If I remove the numbers from the keys, e.g. copyright.layers instead 
>> of  copyright.0.layers The error disappears. Since the same kind of 
>> definition work in locate.ini, I am a little confused.
>
> I'm pretty confused as well since your exportPdf.ini syntax is not 
> standard at all! Have you extended the ClientExportPdf class in some 
> way of your own to make it read such a configuration?
>
> The standard syntax for blocks in exportPdf.ini is something like:
> blocks.copyright.content = "Copyright message"
>
> In the standard exportPdf plugin I don't think there's a way to switch 
> the copyright text depending on the layers selection. However that 
> should be possible by doing something like (not tested):
>
> 1. extend the exportPdf plugin client class (ClientExportPdf) in your 
> project
>
> 2. overload the ClientExportPdf::createBlock() method and replace the 
> following code:
>


More information about the Cartoweb-users mailing list