put server-save into "extras"

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@47 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Pavol Rusnak 2009-06-06 23:54:53 +00:00
parent 35e68a1dd5
commit 8a55732a30
8 changed files with 27 additions and 43 deletions

View File

@ -1,12 +0,0 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" version="1.1" height="100%" width="100%" id="svg_image" xml:space="preserve">
<path stroke="black" fill="none" id="svg_1" d="M207 137 L206 136 L205 135 L205 134 L205 133 L205 132 L206 131 L208 130 L209 129 L211 128 L215 125 L218 123 L248 103 L252 102 L257 100 L258 100 L262 100 L264 100 L267 101 L269 103 L271 106 L272 108 L274 112 L274 114 L275 119 L275 124 L275 131 L274 137 L269 177 L259 207 L249 252 L248 258 L247 264 L246 266 L246 268 L246 269 L247 269 L248 269 L249 269 L252 268 L253 267 L256 266 L257 265 L259 264 L259 263 " />
<path stroke="black" fill="none" id="svg_2" d="M376 139 L391 114 L394 112 L398 109 L400 109 L402 109 L403 109 L404 109 L405 109 L406 109 L407 110 L408 112 L409 114 L409 118 L410 123 L405 173 L395 218 L380 263 L379 267 L364 292 L363 295 L361 299 L360 302 L359 304 L359 305 L361 306 L363 306 L366 307 L368 308 L370 308 L371 309 L372 309 L373 309 L373 310 L373 311 L372 313 L371 314 L371 315 L371 316 L372 316 L374 315 L378 313 L380 312 L382 310 L383 309 L382 309 L379 311 L376 312 L373 314 L372 315 L371 316 L370 316 L370 317 L369 317 L368 318 L366 319 L364 320 L361 321 L358 321 L355 321 L353 321 L350 321 L348 321 L345 320 L342 320 L340 319 L338 319 L336 319 L335 318 L334 318 L333 318 L333 317 L333 316 " />
<ellipse stroke="black" fill="none" id="svg_3" ry="120" rx="92.5" cy="207" cx="630.5" />
<ellipse stroke="black" fill="#e28383" id="svg_6" ry="100" rx="93" cy="252" cx="465" />
</svg>

Before

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -1,9 +0,0 @@
<?php
$svg= $_REQUEST["svg_data"];
$svg_data= urldecode($svg);
$file = "SavedImage.svg";
$fh = fopen($file, "w") or die("Can't open file");
fwrite($fh, $svg_data);
fclose($fh);
echo "File Saved Successfully";
?>

View File

@ -12,7 +12,6 @@
<body> <body>
<p>SVG-edit @ <a href="http://svg-edit.googlecode.com/">http://svg-edit.googlecode.com/</a></p> <p>SVG-edit @ <a href="http://svg-edit.googlecode.com/">http://svg-edit.googlecode.com/</a></p>
<p>Click Here to see <a href="SavedImage.svg">Saved Image</a> </p>
<div id="svg_editor"> <div id="svg_editor">
<div id="color_picker" class="tools_flyout"></div> <div id="color_picker" class="tools_flyout"></div>

View File

@ -7,7 +7,6 @@ $(document).ready(function(){
}); });
$('#palette').append(str); $('#palette').append(str);
var pos = $('#tools_rect_show').position(); var pos = $('#tools_rect_show').position();
$('#tools_rect').css({'left': pos.left+2, 'top': pos.top+2}); $('#tools_rect').css({'left': pos.left+2, 'top': pos.top+2});
pos = $('#tools_ellipse_show').position(); pos = $('#tools_ellipse_show').position();
@ -123,7 +122,7 @@ $(document).ready(function(){
}); });
$('#tool_submit').click(function(){ $('#tool_submit').click(function(){
SvgCanvas.serialize(serializeHandler); SvgCanvas.save();
}); });
var colorPicker = function(elem) { var colorPicker = function(elem) {
@ -191,20 +190,4 @@ $(document).ready(function(){
$('#tools_ellipse').show(); $('#tools_ellipse').show();
}); });
}) });
var serializeHandler = function(svg) {
//alert(svg);
submitSvgStr(svg);
}
function submitSvgStr(str){
//alert("This is svg image in string format \n This will be posted to server \n " + str)
//posting the data to server
$.post(
"save.php",
{svg_data: escape(str)},
function(data){
alert(data);
});
}

View File

@ -408,11 +408,11 @@ function SvgCanvas(doc)
// public functions // public functions
this.serialize = function(handler) { this.save = function() {
var str = "<?xml version=\"1.0\" standalone=\"no\"?>\n" var str = "<?xml version=\"1.0\" standalone=\"no\"?>\n"
str += "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n"; str += "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n";
str += svgToString(svgroot, 0); str += svgToString(svgroot, 0);
handler(str); this.saveHandler(str);
} }
this.clear = function() { this.clear = function() {
@ -504,4 +504,8 @@ function SvgCanvas(doc)
}); });
} }
this.saveHandler = function(svg) {
alert(svg);
}
} }

View File

@ -0,0 +1,8 @@
Usage:
1) copy file svg-editor-save.php into the directory
2) edit the end of the svgcanvas.js and change this.saveHandler method
into the method described in svg-editor-save.js
3) now the drawings will be saved into the file named saved.svg

View File

@ -0,0 +1,3 @@
this.saveHandler = function(svg) {
$.post("svg-editor-save.php", { svg_data: escape(svg) } );
});

View File

@ -0,0 +1,8 @@
<?php
$svg = $_REQUEST["svg_data"];
$svg_data = urldecode($svg);
$file = "saved.svg";
$fh = fopen($file, "w") or die("Can't open file");
fwrite($fh, $svg_data);
fclose($fh);
?>