[mapserver-commits] r7897 - trunk/mapserver/mapscript/php3

svn at osgeo.org svn at osgeo.org
Thu Sep 4 13:22:23 EDT 2008


Author: Assefa
Date: 2008-09-04 13:22:22 -0400 (Thu, 04 Sep 2008)
New Revision: 7897

Modified:
   trunk/mapserver/mapscript/php3/README
   trunk/mapserver/mapscript/php3/mapscript_i.c
   trunk/mapserver/mapscript/php3/php_mapscript.c
   trunk/mapserver/mapscript/php3/php_mapscript.h
Log:
add metadata functions on the class object #2579

Modified: trunk/mapserver/mapscript/php3/README
===================================================================
--- trunk/mapserver/mapscript/php3/README	2008-09-04 03:31:29 UTC (rev 7896)
+++ trunk/mapserver/mapscript/php3/README	2008-09-04 17:22:22 UTC (rev 7897)
@@ -995,6 +995,16 @@
                 echo $class->numstyles; : will echo 1 
 
 
+   int getMetaData(string name)
+        Fetch class metadata entry by name.  Returns "" if no entry 
+        matches the name.  Note that the search is case sensitive.
+
+   int setMetaData(string name, string value)
+        Set a metadata entry for the class.  Returns MS_SUCCESS/MS_FAILURE.
+
+   int removeMetaData(string name)
+        Remove a metadata entry for the class.  Returns MS_SUCCESS/MS_FAILURE.
+
  ImageObj Class:
  ---------------
 

Modified: trunk/mapserver/mapscript/php3/mapscript_i.c
===================================================================
--- trunk/mapserver/mapscript/php3/mapscript_i.c	2008-09-04 03:31:29 UTC (rev 7896)
+++ trunk/mapserver/mapscript/php3/mapscript_i.c	2008-09-04 17:22:22 UTC (rev 7897)
@@ -697,6 +697,21 @@
     return msDeleteStyle(self, index);
 }
 
+char *classObj_getMetaData(classObj *self, char *name) {
+    return(msLookupHashTable(&(self->metadata), name));
+  }
+
+
+int classObj_setMetaData(classObj *self, char *name, char *value) {
+    if (msInsertHashTable(&(self->metadata), name, value) == NULL)
+	return MS_FAILURE;
+    return MS_SUCCESS;
+  }
+
+int classObj_removeMetaData(classObj *self, char *name) {
+    return(msRemoveHashTable(&(self->metadata), name));
+  }
+
 /**********************************************************************
  * class extensions for pointObj, useful many places
  **********************************************************************/

Modified: trunk/mapserver/mapscript/php3/php_mapscript.c
===================================================================
--- trunk/mapserver/mapscript/php3/php_mapscript.c	2008-09-04 03:31:29 UTC (rev 7896)
+++ trunk/mapserver/mapscript/php3/php_mapscript.c	2008-09-04 17:22:22 UTC (rev 7897)
@@ -233,6 +233,10 @@
 DLEXPORT void php3_ms_class_moveStyleDown(INTERNAL_FUNCTION_PARAMETERS);
 DLEXPORT void php3_ms_class_deleteStyle(INTERNAL_FUNCTION_PARAMETERS);
 
+DLEXPORT void php3_ms_class_getMetaData(INTERNAL_FUNCTION_PARAMETERS);
+DLEXPORT void php3_ms_class_setMetaData(INTERNAL_FUNCTION_PARAMETERS);
+DLEXPORT void php3_ms_class_removeMetaData(INTERNAL_FUNCTION_PARAMETERS);
+
 DLEXPORT void php3_ms_label_setProperty(INTERNAL_FUNCTION_PARAMETERS);
 DLEXPORT void php3_ms_label_setBinding(INTERNAL_FUNCTION_PARAMETERS);
 DLEXPORT void php3_ms_label_removeBinding(INTERNAL_FUNCTION_PARAMETERS);
@@ -815,6 +819,9 @@
     {"movestyleup",     php3_ms_class_moveStyleUp,      NULL},   
     {"movestyledown",   php3_ms_class_moveStyleDown,    NULL},   
     {"deletestyle",     php3_ms_class_deleteStyle,      NULL},   
+    {"getmetadata",     php3_ms_class_getMetaData,        NULL},
+    {"setmetadata",     php3_ms_class_setMetaData,        NULL},
+    {"removemetadata",  php3_ms_class_removeMetaData,     NULL},
     {NULL, NULL, NULL}
 };
 
@@ -9564,9 +9571,136 @@
 }
 
 
+
+/**********************************************************************
+ *                        class->getMetaData()
+ **********************************************************************/
+
+/* {{{ proto string class.getMetaData(string name)
+   Return MetaData entry by name, or empty string if not found. */
+
+DLEXPORT void php3_ms_class_getMetaData(INTERNAL_FUNCTION_PARAMETERS)
+{
+    classObj *self;
+    pval   *pThis, *pName;
+    char   *pszValue = NULL;
+
+#ifdef PHP4
+    HashTable   *list=NULL;
+#endif
+
+#ifdef PHP4
+    pThis = getThis();
+#else
+    getThis(&pThis);
+#endif
+
+    if (pThis == NULL ||
+        getParameters(ht, 1, &pName) != SUCCESS)
+    {
+        WRONG_PARAM_COUNT;
+    }
+
+    convert_to_string(pName);
+
+    self = (classObj *)_phpms_fetch_handle(pThis, PHPMS_GLOBAL(le_msclass),
+                                           list TSRMLS_CC);
+    if (self == NULL || 
+        (pszValue = classObj_getMetaData(self, pName->value.str.val)) == NULL)
+    {
+        pszValue = "";
+    }
+
+    RETURN_STRING(pszValue, 1);
+}
 /* }}} */
 
+/**********************************************************************
+ *                        class->setMetaData()
+ **********************************************************************/
 
+/* {{{ proto int class.setMetaData(string name, string value)
+   Set MetaData entry by name.  Returns MS_SUCCESS/MS_FAILURE */
+
+DLEXPORT void php3_ms_class_setMetaData(INTERNAL_FUNCTION_PARAMETERS)
+{
+    classObj *self;
+    pval   *pThis, *pName, *pValue;
+    int    nStatus = MS_FAILURE;
+#ifdef PHP4
+    HashTable   *list=NULL;
+#endif
+
+#ifdef PHP4
+    pThis = getThis();
+#else
+    getThis(&pThis);
+#endif
+
+    if (pThis == NULL ||
+        getParameters(ht, 2, &pName, &pValue) != SUCCESS)
+    {
+        WRONG_PARAM_COUNT;
+    }
+
+    convert_to_string(pName);
+    convert_to_string(pValue);
+
+    self = (classObj *)_phpms_fetch_handle(pThis, PHPMS_GLOBAL(le_msclass),
+                                           list TSRMLS_CC);
+    if (self == NULL || 
+        (nStatus = classObj_setMetaData(self, 
+                                        pName->value.str.val,  
+                                        pValue->value.str.val)) != MS_SUCCESS)
+    {
+        _phpms_report_mapserver_error(E_ERROR);
+    }
+
+    RETURN_LONG(nStatus);
+}
+/* }}} */
+
+
+/**********************************************************************
+ *                        class->removeMetaData()
+ **********************************************************************/
+
+/* {{{ proto int class.removeMetaData(string name)
+   Remove MetaData entry by name.  Returns MS_SUCCESS/MS_FAILURE */
+
+DLEXPORT void php3_ms_class_removeMetaData(INTERNAL_FUNCTION_PARAMETERS)
+{
+    classObj *self;
+    pval   *pThis, *pName;
+    int    nStatus = MS_FAILURE;
+    HashTable   *list=NULL;
+    pThis = getThis();
+
+
+    if (pThis == NULL ||
+        getParameters(ht, 1, &pName) != SUCCESS)
+    {
+        WRONG_PARAM_COUNT;
+    }
+
+    convert_to_string(pName);
+
+    self = (classObj *)_phpms_fetch_handle(pThis, PHPMS_GLOBAL(le_msclass),
+                                           list TSRMLS_CC);
+    if (self == NULL || 
+        (nStatus = classObj_removeMetaData(self, 
+                                        pName->value.str.val)) != MS_SUCCESS)
+    {
+        _phpms_report_mapserver_error(E_ERROR);
+    }
+
+    RETURN_LONG(nStatus);
+}
+
+
+/* }}} */
+
+
 /*=====================================================================
  *                 PHP function wrappers - colorObj class
  *====================================================================*/

Modified: trunk/mapserver/mapscript/php3/php_mapscript.h
===================================================================
--- trunk/mapserver/mapscript/php3/php_mapscript.h	2008-09-04 03:31:29 UTC (rev 7896)
+++ trunk/mapserver/mapscript/php3/php_mapscript.h	2008-09-04 17:22:22 UTC (rev 7897)
@@ -200,6 +200,9 @@
 int             classObj_moveStyleUp(classObj *self, int index);
 int             classObj_moveStyleDown(classObj *self, int index);
 int             classObj_deleteStyle(classObj *self, int index);
+char            *classObj_getMetaData(classObj *self, char *name);
+int             classObj_setMetaData(classObj *self, char *name, char *value);
+int             classObj_removeMetaData(classObj *self, char *name);
 
 pointObj       *pointObj_new();
 void            pointObj_destroy(pointObj *self);



More information about the mapserver-commits mailing list