[Cartoweb-users] Plugins

Alexandre Saunier alexandre.saunier at camptocamp.com
Mon May 29 14:13:58 EDT 2006


Jacolin Yves wrote:
> I'd like to create a plugin to manage postgis Layers : create layers, export 
> and import layers.

> First of all, what is the difference between client side and server side. the 
> aim of the client side code, is it to create dynamic content for the 
> interface and the server side to realise request, calculation, ... ?

CartoWeb has two main parts:
- Cartoclient (client-side core + client-side plugins parts)
- Cartoserver (server-side core + server-side plugins parts)

One of the main reasons of this distinction is the ability to have 
CartoWeb set up as a SOAP web-service (one or several Cartoclients 
queriing a Cartoserver that is not necessarily on the same webserver). 
Even when using CartoWeb in direct mode (no web service) both sides have 
separated tasks:
- Cartoclient: user interface management (HTML generation + POST/GET 
processing), request compilation, "classical" web tasks such as search 
tools, carts,..., etc.
- Cartoserver: MapServer management (calls to MapScript), most 
geographical computing and request processing, data storage, etc.

> So about my plugin, I will use a template to display the form (to create a new 
> layer), the client side will be empty (may be not) and the server side will 
> do the request into the postgis DB ?

Smarty templates and forms processing must be handled by your plugin 
client side. Make it implement the GuiProvider interface.
See http://cartoweb.org/doc/misc/plugins_diagram.pdf

All that deals with MapServer layers is a job for your plugin server side.

> If I extend the edit plugin with my own class. Can I use all config parameter 
> of this class (like parameter for the connection to db) ?

Yes. Please note that extended plugins use the same config files than 
their parent plugins (in your case, edit.ini, even if your extended 
plugin is called someCrazyOtherName).
Same thing for templates: you may overload templates files or create 
some new ones, but you will have to save them in your project in the 
parent plugin directory, not in your extended plugin directory.

> Last (but not least), how does cw3 to use plugin ? I know that the name of the 
> plugin and the files have to be the same (well almost), but I don't know 
> exactly the plugin is run ... Can you help me ?

Most of your questions are probably answered in the doc:

Say you want to extend the "edit" plugin and name your new plugin 

Write in your client_conf/client.ini:
loadPlugins = plugin1, plugin2, ..., edit, someExample
and in server_conf/yourProject.ini:
mapInfo.loadPlugins = pluginA, pluginB, ..., edit, someExample

In your project directory, files are then:
o someExample/client/ClientSomeExample.php (with class ClientSomeExample 
extending ClientEdit)
o someExample/server/ServerSomeExample.php (with class ServerSomeExample 
extending ServerEdit)
o possibly: someExample/common/SomeExample.php (with class SomeExample 
extending Edit) + some WSDL file if you plan to use SOAP
o edit/templates/whateverName.tpl
o client_conf/edit.ini


More information about the Cartoweb-users mailing list