[Mapbender-commits] r10048 - in trunk/mapbender/http: classes php
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Tue Feb 5 09:31:03 PST 2019
Author: armin11
Date: 2019-02-05 09:31:03 -0800 (Tue, 05 Feb 2019)
New Revision: 10048
Modified:
trunk/mapbender/http/classes/class_group.php
trunk/mapbender/http/php/mod_syncCkan_server.php
Log:
Fix
Modified: trunk/mapbender/http/classes/class_group.php
===================================================================
--- trunk/mapbender/http/classes/class_group.php 2019-02-05 16:53:57 UTC (rev 10047)
+++ trunk/mapbender/http/classes/class_group.php 2019-02-05 17:31:03 UTC (rev 10048)
@@ -464,8 +464,8 @@
//approval_status
for($a = 0; $a < count($mappingHash); $a++) {
if (isset($this->{$mappingHash[$a]['groupAttribute']}) && $this->{$mappingHash[$a]['groupAttribute']} !== "" && $mappingHash[$a]['ckanName'] !== false) {
- if ($this->{$mappingHash[$a]['groupAttribute']} == 'name') {
- $jsonOutput->{$mappingHash[$a]['ckanName']} = str_replace('-','_',str_replace(' ','_',strtolower($this->{$mappingHash[$a]['groupAttribute']})));
+ if ($mappingHash[$a]['ckanName'] == 'name') {
+ $jsonOutput->{$mappingHash[$a]['ckanName']} = $this->specialCharsToSlug(str_replace('-','_',str_replace(' ','_',strtolower($this->{$mappingHash[$a]['groupAttribute']}))));
} else {
if (is_array($mappingHash[$a]['ckanName'])) {
foreach($mappingHash[$a]['ckanName'] as $ckanAttributeName) {
@@ -490,6 +490,18 @@
}
}
+public function specialCharsToSlug($string) {
+ $string = str_replace("ä", "ae", $string);
+ $string = str_replace("ü", "ue", $string);
+ $string = str_replace("ö", "oe", $string);
+ $string = str_replace("Ä", "Ae", $string);
+ $string = str_replace("Ü", "Ue", $string);
+ $string = str_replace("Ö", "Oe", $string);
+ $string = str_replace("ß", "ss", $string);
+ $string = str_replace("´", "", $string);
+ return $string;
+}
+
/*
* @return Array of Groups
* @param $filter UNUSED! AssocArray, valid keys "id","name". Use SQL's % and _ to perform simple matching
Modified: trunk/mapbender/http/php/mod_syncCkan_server.php
===================================================================
--- trunk/mapbender/http/php/mod_syncCkan_server.php 2019-02-05 16:53:57 UTC (rev 10047)
+++ trunk/mapbender/http/php/mod_syncCkan_server.php 2019-02-05 17:31:03 UTC (rev 10048)
@@ -305,10 +305,10 @@
$ckanResultObject = json_decode($ckanResult);
if ($ckanResultObject->success == true) {
//give back ckan id of organization
-$e = new mb_notice("orga found!");
+$e = new mb_exception("orga found!");
//get revision_list of organization to get last change date!
$ckanResultOrgaRevList = $syncCkanClass->getRemoteCkanOrgaRevList($requestPostJson);
-$e = new mb_notice("orga rev list: ".$ckanResultOrgaRevList);
+$e = new mb_exception("orga rev list: ".$ckanResultOrgaRevList);
//extract last timestamp:
$ckanResultOrgaRevListObject = json_decode($ckanResultOrgaRevList);
//check for update if needed!
@@ -320,24 +320,24 @@
//$dateTimeCkanOrga = new DateTime($ckanResultObject->result->created);
$dateTimeMapbenderOrga = new DateTime($orga->updated);
-$e = new mb_notice("datetime ckan: ".$dateTimeCkanOrga->format('Y-m-d H:i:s')." - datetime mapbender: ".$dateTimeMapbenderOrga->format('Y-m-d H:i:s'));
+$e = new mb_exception("datetime ckan: ".$dateTimeCkanOrga->format('Y-m-d H:i:s')." - datetime mapbender: ".$dateTimeMapbenderOrga->format('Y-m-d H:i:s'));
if (($dateTimeCkanOrga < $dateTimeMapbenderOrga) || $ckanResultObject->result->state == "deleted") {
$ckanOrgaRepresentation = $syncCkanClass->getInternalOrgaAsCkan($orga->serialId);
$ckanResult = $syncCkanClass->updateRemoteCkanOrga($ckanOrgaRepresentation);
-$e = new mb_notice("update organization ! ".$ckanResult); //id needed!!!!
+$e = new mb_exception("update organization ! ".$ckanResult); //id needed!!!!
} else {
-$e = new mb_notice("no update required!");
+$e = new mb_exception("no update required!");
}
} else {
-$e = new mb_notice("organization not found - try to create it!");
+$e = new mb_exception("organization not found - try to create it!");
//try to create it
$ckanResult = $syncCkanClass->createRemoteCkanOrga($ckanOrgaRepresentation);
-$e = new mb_notice("result of creation: ". $ckanResult);
+$e = new mb_exception("result of creation: ". $ckanResult);
$ckanResultObject = json_decode($ckanResult);
if ($ckanResultObject->success == true) {
-$e = new mb_notice("organization successfully created!: ");
+$e = new mb_exception("organization successfully created!: ");
} else {
- $e = new mb_notice("an error occured when trying to create organization via ckan api! ");
+ $e = new mb_exception("an error occured when trying to create organization via ckan api! ");
}
}
} else {
@@ -350,16 +350,16 @@
$requestPostJson = json_encode($requestPost);
//check if already exists and/or state is "deleted"- than update and set to active
$ckanResult = $syncCkanClass->getRemoteCkanOrga($requestPostJson);
-$e = new mb_notice("remote ckan organization: ".$ckanResult);
+$e = new mb_exception("remote ckan organization: ".$ckanResult);
$ckanResultObject = json_decode($ckanResult);
if ($ckanResultObject->success == false) {
-$e = new mb_notice("organization not found - try to create it!");
+$e = new mb_exception("organization not found - try to create it!");
//try to create it
$ckanResult = $syncCkanClass->createRemoteCkanOrga($ckanOrgaRepresentation);
-$e = new mb_notice("result of creation: ". $ckanResult);
+$e = new mb_exception("result of creation: ". $ckanResult);
$ckanResultObject = json_decode($ckanResult);
if ($ckanResultObject->success == true) {
-$e = new mb_notice("organization successfully created!: ");
+$e = new mb_exception("organization successfully created!: ");
//store uuid of external created ckan organization into mapbender database as foreign key
$sql = "UPDATE mb_group SET mb_group_ckan_uuid = $1 WHERE mb_group_id = $2";
$v = array($ckanResultObject->result->id, $orga->serialId);
@@ -372,7 +372,7 @@
//set orga->id for further requests
$orga->id = $ckanResultObject->result->id;
} else {
- $e = new mb_notice("an error occured! ");
+ $e = new mb_exception("an error occured! ");
}
} else {
//a organization was found with the requested name - get the id from this organisation and fill it into the mapbender database before updating
@@ -390,7 +390,7 @@
$ckanOrgaRepresentationObject->id = $ckanResultObject->result->id;
$ckanOrgaRepresentation = json_encode($ckanOrgaRepresentationObject);
$ckanResultOrgaRevList = $syncCkanClass->getRemoteCkanOrgaRevList($requestPostJson);
-$e = new mb_notice("orga rev list: ".$ckanResultOrgaRevList);
+$e = new mb_exception("orga rev list: ".$ckanResultOrgaRevList);
//extract last timestamp:
$ckanResultOrgaRevListObject = json_decode($ckanResultOrgaRevList);
//check for update if needed!
@@ -405,7 +405,7 @@
$dateTimeMapbenderOrga = new DateTime($orga->updated);
if (($dateTimeCkanOrga < $dateTimeMapbenderOrga) || $ckanResultObject->result->state == "deleted") {
$ckanResult = $syncCkanClass->updateRemoteCkanOrga($ckanOrgaRepresentation);
-$e = new mb_notice("update organization ! ".$ckanResult); //id needed!!!!
+$e = new mb_exception("update organization ! ".$ckanResult); //id needed!!!!
}
}
}
@@ -416,7 +416,7 @@
$requestPost->{'id'} = $editingUserName;
$requestPostJson = json_encode($requestPost);
$ckanResultUser = $syncCkanClass->getRemoteCkanUser($requestPostJson);
-$e = new mb_notice("get user: ".$ckanResultUser); //id needed!!!!
+$e = new mb_exception("get user: ".$ckanResultUser); //id needed!!!!
$ckanResultUserObject = json_decode($ckanResultUser);
if ($ckanResultUserObject->success == true) {
@@ -430,7 +430,7 @@
$requestPost->{'password'} = "1234".$editingUserName."5678";
$requestPostJson = json_encode($requestPost);
$ckanResultUser = $syncCkanClass->createRemoteCkanUser($requestPostJson);
-$e = new mb_notice("get user: ".$ckanResultUser);
+$e = new mb_exception("get user: ".$ckanResultUser);
$ckanResultUserObject = json_decode($ckanResultUser);
}
@@ -456,9 +456,9 @@
$requestPost->{'capacity'} = "editor";
$requestPostJson = json_encode($requestPost);
$ckanResultMember = $syncCkanClass->getRemoteCkanMember($requestPostJson);
-$e = new mb_notice("get member: ".$ckanResultMember);
+$e = new mb_exception("get member: ".$ckanResultMember);
$ckanResultMemberObject = json_decode($ckanResultMember);
-$e = new mb_notice("number of editors: ".count($ckanResultMemberObject->result));
+$e = new mb_exception("number of editors: ".count($ckanResultMemberObject->result));
if (count($ckanResultMemberObject->result == 0)) {
//add membership for editor
$requestPost = new stdClass();
@@ -468,7 +468,7 @@
$requestPost->{'capacity'} = "editor";
$requestPostJson = json_encode($requestPost);
$ckanResultMember = $syncCkanClass->createRemoteCkanMember($requestPostJson);
-$e = new mb_notice("get member after creating: ".$ckanResultMember);
+$e = new mb_exception("get member after creating: ".$ckanResultMember);
}
}
}
More information about the Mapbender_commits
mailing list