[mapserver-commits] r12507 - in trunk: docs/en/mapscript docs/en/mapscript/php mapserver mapserver/mapscript/php mapserver/mapscript/swiginc

svn at osgeo.org svn at osgeo.org
Mon Aug 29 14:11:12 EDT 2011


Author: schpidi
Date: 2011-08-29 11:11:12 -0700 (Mon, 29 Aug 2011)
New Revision: 12507

Modified:
   trunk/docs/en/mapscript/mapscript.txt
   trunk/docs/en/mapscript/php/index.txt
   trunk/mapserver/HISTORY.TXT
   trunk/mapserver/mapscript/php/mapscript_i.c
   trunk/mapserver/mapscript/php/owsrequest.c
   trunk/mapserver/mapscript/php/php_mapscript.h
   trunk/mapserver/mapscript/swiginc/owsrequest.i
Log:
Added addParameter() method to MapScript (#3973).


Modified: trunk/docs/en/mapscript/mapscript.txt
===================================================================
--- trunk/docs/en/mapscript/mapscript.txt	2011-08-29 12:26:49 UTC (rev 12506)
+++ trunk/docs/en/mapscript/mapscript.txt	2011-08-29 18:11:12 UTC (rev 12507)
@@ -2083,6 +2083,16 @@
 
 .. note:: MapServer's OWSRequest supports only single valued parameters.
 
+addParameter( string name, string value ) : void
+    Add a request parameter, even if the parameter key was previousely set.
+    This is useful when multiple parameters with the same key are required.
+    For example
+
+::
+    
+    request.addParameter('SIZE', 'x(100)')
+    request.addParameter('SIZE', 'y(100)')
+
 getName( int index ) : string
     Return the name of the parameter at *index* in the request's array
     of parameter names.

Modified: trunk/docs/en/mapscript/php/index.txt
===================================================================
--- trunk/docs/en/mapscript/php/index.txt	2011-08-29 12:26:49 UTC (rev 12506)
+++ trunk/docs/en/mapscript/php/index.txt	2011-08-29 18:11:12 UTC (rev 12507)
@@ -1835,6 +1835,16 @@
 
        $request->setparameter('REQUEST', 'GetMap');
 
+int addparameter(string name, string value)
+    Add a request parameter, even if the parameter key was previousely set.
+    This is useful when multiple parameters with the same key are required.
+    For example :
+    
+    .. code-block:: php
+
+        $request->addparameter('SIZE', 'x(100)');
+        $request->addparameter('SIZE', 'y(100)');
+
 .. index::
    triple: MapScript; PHP; pointObj
 

Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT	2011-08-29 12:26:49 UTC (rev 12506)
+++ trunk/mapserver/HISTORY.TXT	2011-08-29 18:11:12 UTC (rev 12507)
@@ -15,6 +15,8 @@
 Current Version (SVN trunk, 6.1-dev, future 6.2): 
 -------------------------------------------------
 
+- Added addParameter() method to MapScript (#3973)
+
 - Changed msDrawVectorLayer() not to cache shapes if attribute binding is present after	the first style	(#3976)
 
 - Fix mapscript to build when TRUE macro is not defined (#3926)

Modified: trunk/mapserver/mapscript/php/mapscript_i.c
===================================================================
--- trunk/mapserver/mapscript/php/mapscript_i.c	2011-08-29 12:26:49 UTC (rev 12506)
+++ trunk/mapserver/mapscript/php/mapscript_i.c	2011-08-29 18:11:12 UTC (rev 12507)
@@ -1460,6 +1460,16 @@
     }
 }
 
+void cgirequestObj_addParameter(cgiRequestObj *self, char *name, char *value)
+{
+    if (self->NumParams == MS_DEFAULT_CGI_PARAMS) {
+      msSetError(MS_CHILDERR, "Maximum number of items, %d, has been reached", "addParameter()", MS_DEFAULT_CGI_PARAMS);
+    }
+    self->ParamNames[self->NumParams] = strdup(name);
+    self->ParamValues[self->NumParams] = strdup(value);
+    self->NumParams++;
+}
+
 char *cgirequestObj_getName(cgiRequestObj *self, int index)
 {
     if (index < 0 || index >= self->NumParams) {

Modified: trunk/mapserver/mapscript/php/owsrequest.c
===================================================================
--- trunk/mapserver/mapscript/php/owsrequest.c	2011-08-29 12:26:49 UTC (rev 12506)
+++ trunk/mapserver/mapscript/php/owsrequest.c	2011-08-29 18:11:12 UTC (rev 12507)
@@ -51,6 +51,11 @@
   ZEND_ARG_INFO(0, value)
 ZEND_END_ARG_INFO()
 
+ZEND_BEGIN_ARG_INFO_EX(owsrequest_addParameter_args, 0, 0, 2)
+  ZEND_ARG_INFO(0, name)
+  ZEND_ARG_INFO(0, value)
+ZEND_END_ARG_INFO()
+
 ZEND_BEGIN_ARG_INFO_EX(owsrequest_getName_args, 0, 0, 1)
   ZEND_ARG_INFO(0, index)
 ZEND_END_ARG_INFO()
@@ -231,6 +236,33 @@
 }
 /* }}} */
 
+/* {{{ proto int owsrequest.addParameter(string name, string value)
+   Add a request parameter. */
+PHP_METHOD(OWSRequestObj, addParameter)
+{
+    char *name;
+    long name_len;
+    char *value;
+    long value_len;
+    zval *zobj = getThis();
+    php_owsrequest_object *php_owsrequest;
+
+    PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
+    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss",
+                              &name, &name_len, &value, &value_len) == FAILURE) {
+        PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
+        return;
+    }
+    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
+
+    php_owsrequest = (php_owsrequest_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+
+    cgirequestObj_addParameter(php_owsrequest->cgirequest, name, value);
+
+    RETURN_LONG(MS_SUCCESS);
+}
+/* }}} */
+
 /* {{{ proto string owsrequest.getName(int index) 
    Return the name of the parameter at index in the request’s array of parameter names. */
 PHP_METHOD(OWSRequestObj, getName)
@@ -319,6 +351,7 @@
     PHP_ME(OWSRequestObj, __set, owsrequest___set_args, ZEND_ACC_PUBLIC)
     PHP_ME(OWSRequestObj, loadParams, NULL, ZEND_ACC_PUBLIC)
     PHP_ME(OWSRequestObj, setParameter, owsrequest_setParameter_args, ZEND_ACC_PUBLIC)
+    PHP_ME(OWSRequestObj, addParameter, owsrequest_addParameter_args, ZEND_ACC_PUBLIC)
     PHP_ME(OWSRequestObj, getName, owsrequest_getName_args, ZEND_ACC_PUBLIC)
     PHP_ME(OWSRequestObj, getValue, owsrequest_getValue_args, ZEND_ACC_PUBLIC)
     PHP_ME(OWSRequestObj, getValueByName, owsrequest_getValueByName_args, ZEND_ACC_PUBLIC)

Modified: trunk/mapserver/mapscript/php/php_mapscript.h
===================================================================
--- trunk/mapserver/mapscript/php/php_mapscript.h	2011-08-29 12:26:49 UTC (rev 12506)
+++ trunk/mapserver/mapscript/php/php_mapscript.h	2011-08-29 18:11:12 UTC (rev 12507)
@@ -763,6 +763,7 @@
                              ms_uint32 raw_post_data_length,
                              void* thread_context);
 void cgirequestObj_setParameter(cgiRequestObj *self, char *name, char *value);
+void cgirequestObj_addParameter(cgiRequestObj *self, char *name, char *value);
 char *cgirequestObj_getName(cgiRequestObj *self, int index);
 char *cgirequestObj_getValue(cgiRequestObj *self, int index);
 char *cgirequestObj_getValueByName(cgiRequestObj *self, const char *name);

Modified: trunk/mapserver/mapscript/swiginc/owsrequest.i
===================================================================
--- trunk/mapserver/mapscript/swiginc/owsrequest.i	2011-08-29 12:26:49 UTC (rev 12506)
+++ trunk/mapserver/mapscript/swiginc/owsrequest.i	2011-08-29 18:11:12 UTC (rev 12507)
@@ -112,6 +112,16 @@
             self->NumParams++;
         }
     }
+    
+    void addParameter(char *name, char *value)
+    {
+        if (self->NumParams == MS_DEFAULT_CGI_PARAMS) {
+            msSetError(MS_CHILDERR, "Maximum number of items, %d, has been reached", "addParameter()", MS_DEFAULT_CGI_PARAMS);
+        }
+        self->ParamNames[self->NumParams] = strdup(name);
+        self->ParamValues[self->NumParams] = strdup(value);
+        self->NumParams++;
+    }
 
     char *getName(int index) 
     {



More information about the mapserver-commits mailing list