[Mapbender-commits] r6816 - trunk/mapbender/http/php
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Thu Aug 26 03:35:20 EDT 2010
Author: kmq
Date: 2010-08-26 07:35:20 +0000 (Thu, 26 Aug 2010)
New Revision: 6816
Modified:
trunk/mapbender/http/php/mod_editElements.php
Log:
changed the way elements are renamed and copied see ticket #677
Modified: trunk/mapbender/http/php/mod_editElements.php
===================================================================
--- trunk/mapbender/http/php/mod_editElements.php 2010-08-25 22:36:51 UTC (rev 6815)
+++ trunk/mapbender/http/php/mod_editElements.php 2010-08-26 07:35:20 UTC (rev 6816)
@@ -110,7 +110,7 @@
</style>
<?php
# handle database updates etc.....
-if(isset($mySave) && ($mySave == '1' || $mySave == '2')) {
+if((isset($mySave) && ($mySave == '1' || $mySave == '2')) || isset($myDuplicate)) {
# check module-permission ---------------------------------------------------------
# e_attributes
# e_js_file
@@ -163,8 +163,9 @@
if ($mySave == '1'){
//copy element vars
+ //If the name of the element (e_id) was changed in the update, then the elementvarrs must be copied from the old e_id to the new e_id
$sql = "SELECT * FROM gui_element_vars WHERE fkey_e_id = $1 AND fkey_gui_id = $2";
- $v = array($e_id_,$_POST["originGuiOfSelectedElement"]);
+ $v = array($orig_e_id_,$_POST["originGuiOfSelectedElement"]);
$t = array('s','s');
$c = 0;
$res_vars = db_prep_query($sql,$v,$t);
@@ -172,7 +173,7 @@
db_begin();
$sql = "DELETE FROM gui_element WHERE e_id = $1 AND fkey_gui_id = $2 ";
- $v = array($e_id_,$guiList1);
+ $v = array($orig_e_id_,$guiList1);
$t = array('s','s');
$res = db_prep_query($sql,$v,$t);
@@ -222,6 +223,62 @@
$v = array($guiDesc,$guiId);
$t = array('s','s');
$res = db_prep_query($sql,$v,$t);
+ }elseif($myDuplicate == '1'){
+ //copy element vars
+ //If the name of the element (e_id) was changed in the update, then the elementvarrs must be copied from the old e_id to the new e_id
+ $sql = "SELECT * FROM gui_element_vars WHERE fkey_e_id = $1 AND fkey_gui_id = $2";
+ $v = array($orig_e_id_,$_POST["originGuiOfSelectedElement"]);
+ $t = array('s','s');
+ $c = 0;
+ $res_vars = db_prep_query($sql,$v,$t);
+
+ db_begin();
+
+ //$sql = "DELETE FROM gui_element WHERE e_id = $1 AND fkey_gui_id = $2 ";
+ //$v = array($orig_e_id_,$guiList1);
+ //$t = array('s','s');
+ //$res = db_prep_query($sql,$v,$t);
+
+ if($e_left == ''){$e_left = NULL;}
+ if($e_top == ''){$e_top = NULL;}
+ if($e_width < 1){$e_width = NULL;}
+ if($e_height < 1){$e_height = NULL;}
+ if($e_z_index < 1){$e_z_index = NULL;}
+ if($e_pos == ''){$e_pos = 2;}
+ if($e_public == ''){$e_public = 1;}
+
+ $sql = "INSERT INTO gui_element(fkey_gui_id,e_id,e_pos,e_public,e_comment,e_element,e_src,";
+ $sql .= "e_attributes,e_left,e_top,e_width,e_height,e_z_index,e_more_styles,e_content,";
+ $sql .= "e_closetag,e_js_file,e_mb_mod,e_target,e_requires,e_url,e_title) ";
+ $sql .= "VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22)";
+ $v = array($guiList1,$e_id_,$e_pos,$e_public,$e_comment,$e_element,$e_src,$e_attributes,$e_left,
+ $e_top,$e_width,$e_height,$e_z_index,$e_more_styles,$e_content,$e_closetag,$e_js_file,
+ $e_mb_mod,$e_target,$e_requires,$e_url,$e_title);
+ $t = array('s','s','i','i','s','s','s','s','i','i','i','i','i','s','s','s','s','s','s','s','s','s');
+ $res = db_prep_query($sql,$v,$t);
+ if(!$res){
+ db_rollback();
+ }
+
+ //copy element vars
+
+ while($row = db_fetch_array($res_vars)){
+ $sql = array();
+ $v = array();
+ $t = array();
+ $r = array();
+ $sql[$c] = "INSERT INTO gui_element_vars (fkey_gui_id,fkey_e_id,var_name,var_value,context,var_type) ";
+ $sql[$c] .= "VALUES ($1,$2,$3,$4,$5,$6)";
+ $v[$c] = array($guiList1,$e_id_,$row["var_name"],$row["var_value"],$row["context"],$row["var_type"]);
+ $t[$c] = array('s','s','s','s','s','s');
+ $r[$c] = db_prep_query($sql[$c],$v[$c],$t[$c]);
+ if(!$r){
+ db_rollback();
+ }
+ $c++;
+ }
+ db_commit();
+
}
}
@@ -352,6 +409,14 @@
document.form1.submit();
}
}
+
+function thisDuplicate(){
+ var newName = prompt("Enter new name: ");
+ document.form1.e_id_.value = newName;
+ document.form1.myDuplicate.value = 1;
+ document.form1.submit();
+}
+
function thisShow(){ document.form1.myShow.value = 1;
document.form1.submit();
}
@@ -467,6 +532,7 @@
echo "</div>\n";
echo "<div class='buttonbar'>\n";
echo "<input type='button' class='' name='' value='save' onclick='thisSave()'> \n";
+ echo "<input type='button' class='' name='' value='duplicate' onclick='thisDuplicate()'> \n";
echo "<input type='button' class='' name='' value='delete' onclick='thisDelete()'> \n";
echo "<input type='button' class='' name='' value='show' onclick='thisShow()'> \n";
echo "<input type='button' class='' name='' value='sql' onclick='thisExport()'> \n";
@@ -551,7 +617,7 @@
$t = array();
$res = db_prep_query($sql,$v,$t);
if($row = db_fetch_array($res)){
- echo "<tr><td>ID: </td><td><input type='text' class='textfield' name='e_id_' value='".$row["e_id"]."'></td></tr>\n";
+ echo "<tr><td>ID: </td><td><input type='text' class='textfield' name='e_id_' value='".$row["e_id"]."'><input type='hidden' class='textfield' name='orig_e_id_' value='".$row["e_id"]."'></td></tr>\n";
echo "<tr><td>Position: </td><td><input type='text' class='textfield' name='e_pos' value='".$row["e_pos"]."'></td></tr>\n";
echo "<tr><td>ON/OFF: </td><td><input type='text' class='textfield' name='e_public' value='".$row["e_public"]."'></td></tr>\n";
echo "<tr><td>Comment: </td><td><textarea cols='32' rows='5' name='e_comment' >".stripslashes($row["e_comment"])."</textarea></td></tr>\n";
@@ -576,7 +642,7 @@
echo "</table>";
}
else if(isset($guiList1)){
- echo "<tr><td>ID: </td><td><input type='text' class='textfield' name='e_id_' value='".$e_id_."'></td></tr>\n";
+ echo "<tr><td>ID: </td><td><input type='text' class='textfield' name='e_id_' value='".$e_id_."'><input type='hidden' class='textfield' name='orig_e_id_' value='".$row["e_id"]."'></td></tr>\n";
echo "<tr><td>Position: </td><td><input type='text' class='textfield' name='e_pos' value='".$e_pos."'></td></tr>\n";
echo "<tr><td>ON/OFF: </td><td><input type='text' class='textfield' name='e_public' value='".$e_public."'></td></tr>\n";
echo "<tr><td>Comment: </td><td><textarea cols='32' rows='5' name='e_comment' >".stripslashes($e_comment)."</textarea></td></tr>\n";
@@ -602,6 +668,7 @@
echo "<input type='hidden' name='originGuiOfSelectedElement' value='" . $_POST["originGuiOfSelectedElement"] . "'>";
echo "<input type='hidden' name='myDelete'>";
+echo "<input type='hidden' name='myDuplicate'>";
echo "<input type='hidden' name='mySave'>";
echo "<input type='hidden' name='myShow'>";
echo "<input type='hidden' name='all'>";
More information about the Mapbender_commits
mailing list