[Mapbender-commits] r4974 - in trunk/mapbender/http: classes
javascripts php
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Wed Nov 11 12:00:37 EST 2009
Author: kmq
Date: 2009-11-11 12:00:34 -0500 (Wed, 11 Nov 2009)
New Revision: 4974
Modified:
trunk/mapbender/http/classes/class_wmc.php
trunk/mapbender/http/javascripts/mod_savewmc.php
trunk/mapbender/http/php/mod_savewmc_server.php
Log:
saving inspire categories in WMCs
Modified: trunk/mapbender/http/classes/class_wmc.php
===================================================================
--- trunk/mapbender/http/classes/class_wmc.php 2009-11-11 16:13:03 UTC (rev 4973)
+++ trunk/mapbender/http/classes/class_wmc.php 2009-11-11 17:00:34 UTC (rev 4974)
@@ -124,6 +124,8 @@
var $wmc_descriptionurl_format;
var $wmc_descriptionurl_type;
+ var $inspireCats;
+
public function __construct () {
$this->userId = Mapbender::session()->get("mb_user_id");
$this->wmc_id = time();
@@ -424,7 +426,13 @@
$v = array($this->xml, time(), $user->isPublic()?1:0, $this->wmc_abstract, $this->wmc_srs, $this->wmc_extent->minx, $this->wmc_extent->minx,
$this->wmc_extent->maxx, $this->wmc_extent->maxy ,$this->userId, administration::convertOutgoingString($this->wmc_title),$row[2]);
$t = array("s", "s","i","s","s","i","i","i","i", "i", "s","s");
+ // need the database Id
$wmc_DB_ID = $row[3];
+ $delsql = "DELETE FROM wmc_md_topic_category WHERE fkey_wmc_id = $1;";
+ $delv = array($wmc_DB_ID);
+ $delt = array("s");
+ db_prep_query($delsql, $delv,$delt);
+
}
@@ -460,10 +468,13 @@
}
else {
-
+ // because the wmc id is created each time a wmc is instantiated $this->wmc_id has nothing to do with the database wmc_id
+ // this is some duct tape to fix it :-(
+ // see also above where wmc_DB_ID is defined if we need to update
+ if(!isset($wmc_DB_ID)) { $wmc_DB_ID = $this->wmc_id; }
+
+ // update keywords
foreach($this->keyword as $keyword){
-
-
// if a keyword does not yet exist, create it
$keywordExistsSql = "SELECT keyword FROM keyword WHERE keyword = $1";
@@ -477,13 +488,9 @@
}
}
- // because the wmc id is created each time a wmc is instantiated $this->wmc_id has nothing to do with the database wmc_id
- // this is some duct tape to fix it :-(
- // see also above where wmc_DB_ID is defined if we need to update
- if(!isset($wmc_DB_ID)) { $wmc_DB_ID = $this->wmc_id; }
- $keywordsql = "INSERT into wmc_keyword (fkey_keyword_id,fkey_wmc_id) SELECT keyword.keyword_id,$1 FROM keyword WHERE keyword = $2 AND NOT EXISTS (SELECT fkey_wmc_id FROM wmc_keyword WHERE fkey_wmc_id = $3 );";
+ $keywordsql = "INSERT INTO wmc_keyword (fkey_keyword_id,fkey_wmc_id) SELECT keyword.keyword_id,$1 FROM keyword WHERE keyword = $2 AND NOT EXISTS (SELECT fkey_wmc_id FROM wmc_keyword WHERE fkey_wmc_id = $3 );";
$v = array($wmc_DB_ID, $keyword,$wmc_DB_ID);
$t = array("s","s","s");
$res = db_prep_query($keywordsql, $v, $t);
@@ -491,6 +498,17 @@
}
}
+ // update categories
+ $this->inspireCats = $this->inspireCats? $this->inspireCats: array();
+ foreach($this->inspireCats as $catId)
+ {
+
+ $catSql = "INSERT INTO wmc_md_topic_category (fkey_wmc_id, fkey_md_topic_category_id) VALUES ($1,$2)";
+ $v = array($wmc_DB_ID, $catId);
+ $t = array("s","s");
+ $res = db_prep_query($catSql, $v, $t);
+
+ }
$result["success"] = true;
$msg = "WMC document '" . $this->wmc_title . "' has been saved.";
Modified: trunk/mapbender/http/javascripts/mod_savewmc.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_savewmc.php 2009-11-11 16:13:03 UTC (rev 4973)
+++ trunk/mapbender/http/javascripts/mod_savewmc.php 2009-11-11 17:00:34 UTC (rev 4974)
@@ -110,7 +110,7 @@
$("#saveWMCForm form #inspire_cat :checkbox").each(function(){
if(!!$(this).attr('checked'))
{
- inspire_cat[$(this).id] = true;
+ inspire_cat[$(this).attr('id')] = true;
}
});
@@ -118,6 +118,7 @@
attributes.title = $("#wmcname").val();
attributes.abstract = $("#wmcabstract").val();
attributes.keywords = $("#wmckeywords").val();
+ attributes.inspirecat = inspire_cat;
if (!!attributes.title) {
sendMapDataToServer(attributes, 0, (function(result, status) {
//alert(status + ": " + result);
Modified: trunk/mapbender/http/php/mod_savewmc_server.php
===================================================================
--- trunk/mapbender/http/php/mod_savewmc_server.php 2009-11-11 16:13:03 UTC (rev 4973)
+++ trunk/mapbender/http/php/mod_savewmc_server.php 2009-11-11 17:00:34 UTC (rev 4974)
@@ -77,13 +77,24 @@
$ajaxResponse->send();
exit;
}
-
+ foreach($mapObject as $map)
+ {
+ if (isset($mapObject->isOverview) && $mapObject->isOverview == "1") { continue; }
+ $wmc->wmc_extent = $map->extent;
+ $wmc->wmc_srs = $map->epsg;
+ }
// make a keyword array here
$wmc->keyword = explode(" ",$attributes->keywords);
- $wmc->wmc_extent = $mapObject[0]->extent;
- $wmc->wmc_srs = $mapObject[0]->epsg;
$wmc->wmc_abstract = $attributes->abstract;
+ $inspireCat = $attributes->inspirecat;
+ foreach($inspireCat as $cat)
+ {
+ $parts = explode("_",$cat);
+ $wmc->inspireCats[] = $parts[0];
+ }
+
+
$result = $wmc->insert($overwrite);
$ajaxResponse->setSuccess(true);
$ajaxResponse->setResult($result);
More information about the Mapbender_commits
mailing list