[Cartoweb-users] Edit plugin.

Oliver Christen oliver.christen at camptocamp.com
Fri Sep 26 02:33:45 EDT 2008

mmm, the plugin was not designed to deal with predefined/constant values.

you need to extend the edit plugin and add something like this at the end of the filterPostRequest function :

        // look in $request for any new feaures and insert the timestamp, var1, var2, sessionid
        $r = $request->getRequest();
        $nf = array();
        foreach ($r as $key => $value) {
            if (strpos($key, 'edit_feature_') !== false) {
                if (array_key_exists('operation', $value) && $value['operation'] == 'insert') {                    
                    $value['timestamp'] = date('Y-m-d');
                    $value['var1'] = 'default value for var1';
                    $value['var2'] = 'default value for var2';
                    $value['sessionid'] = $r['PHPSESSID'];
                    $nf[$key] = $value;
        // insert modified feature back into $request
        foreach ($nf as $key => $value) {
            $request->setValue($key, $value);

see http://www.cartoweb.org/doc/cw3.5/xhtml/dev.newplugin.html#dev.newplugin.adapting.extending
there are multiple example in the mailinglist archive about extending plugins

  ----- Original Message ----- 
  From: Nikos Papadakis 
  Cc: cartoweb-users at lists.maptools.org 
  Sent: Thursday, September 25, 2008 4:38 PM
  Subject: Re: [Cartoweb-users] Edit plugin.

  O/H Oliver Christen έγραψε: 
    please remove

    {if $edit_allowed|default:''}<div id="edit_div"

    from your template header section, it has absolutly nothing to do there

    that should go usualy in the body section, where you want to see the selected elements array appear.


  Thank you.
  I placed the above statement where i should and now the plugin works!
  But now i have a problem using the tools.
  I can select and edit all points that alreadt exhist in the database!
  The problem i have is with points that create myself.
  I can create them but when i move or delete them i get the following error message.

Error [2, array_key_exists() [function.array-key-exists]: The first argument should be either a string or an integer, C:\ms4w\apps\cartoweb3\projects\mytest\plugins\edit\client\ClientEdit.php, 245]

With the configuration i have,each entry in the database has 7 columns wich are:
gid (integer),v_poi (integer),v_poi_point (integer),city (string),city_lat (string),label(string),the_geom(geometry).
The v_poi field has the same values with the gid field.
The v_poi_point field is always 0 (Strange shapefile source!!!)
In my map file i have choosen to edit only the attributes city,city_lat and label.
I guess that the problem with the points i create is that when they are written in the postgis database
their entries have the field gid filled,the other two fields (v_poi,v_poi_point) are not filled!

If i am right how can i fill them automatically with the proper values.(That is,v_poi equal to gid and v_poi_point=0).

Thank you very much!


  Cartoweb-users mailing list
  Cartoweb-users at lists.maptools.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/cartoweb-users/attachments/20080926/d385f2ed/attachment.html

More information about the Cartoweb-users mailing list