[Mapbender-commits] r3463 - in branches/print_dev/http/print: .
classes
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Mon Jan 19 12:10:24 EST 2009
Author: mschulz
Date: 2009-01-19 12:10:23 -0500 (Mon, 19 Jan 2009)
New Revision: 3463
Modified:
branches/print_dev/http/print/classes/factoryClasses.php
branches/print_dev/http/print/classes/mbPdf.php
branches/print_dev/http/print/mod_printPDF_div.php
branches/print_dev/http/print/testConfigTemplate.json
branches/print_dev/http/print/testfactories.php
Log:
div gui module with one-click download (not finished)
Modified: branches/print_dev/http/print/classes/factoryClasses.php
===================================================================
--- branches/print_dev/http/print/classes/factoryClasses.php 2009-01-16 14:54:41 UTC (rev 3462)
+++ branches/print_dev/http/print/classes/factoryClasses.php 2009-01-19 17:10:23 UTC (rev 3463)
@@ -20,8 +20,12 @@
private function readConfig($jsonConfFile) {
$admin = new administration();
$mbjson = new Mapbender_JSON();
- $jsonStr = $admin->char_encode(file_get_contents(dirname(__FILE__) . "/../".$jsonConfFile));
- $jsonConf = $mbjson->decode($jsonStr);
+ $jsonStr = file_get_contents(dirname(__FILE__) . "/../".$jsonConfFile);
+ if ($jsonStr == false) {
+ $e = new mb_exception("mbPdfFactory: config file could not be read.");
+ die("config not found.");
+ }
+ $jsonConf = $mbjson->decode($admin->char_encode($jsonStr));
return $jsonConf;
}
Modified: branches/print_dev/http/print/classes/mbPdf.php
===================================================================
--- branches/print_dev/http/print/classes/mbPdf.php 2009-01-16 14:54:41 UTC (rev 3462)
+++ branches/print_dev/http/print/classes/mbPdf.php 2009-01-19 17:10:23 UTC (rev 3463)
@@ -20,13 +20,23 @@
return $prefix."_".substr(md5(uniqid(rand())),0,7).".".$suffix;
}
+ public function returnPDF() {
+ if ($this->isSaved) {
+ header('Content-Type:application/pdf');
+ header('Content-Disposition:attachment;filename="'.$this->outputFileName.'"');
+ $this->objPdf->Output($this->outputFileName,'D');
+ }
+ else
+ die("PDF output not rendered yet.");
+ }
+
public function returnURL() {
+ $mbjson = new Mapbender_JSON();
if ($this->isSaved) {
- $mbjson = new Mapbender_JSON();
return $mbjson->encode(array("outputFileName"=>TMPDIR."/".$this->outputFileName));
}
else
- die("PDF output not rendered yet.");
+ return $mbjson->encode(array("error"=>"Possibly no map urls delivered."));
}
}
Modified: branches/print_dev/http/print/mod_printPDF_div.php
===================================================================
--- branches/print_dev/http/print/mod_printPDF_div.php 2009-01-16 14:54:41 UTC (rev 3462)
+++ branches/print_dev/http/print/mod_printPDF_div.php 2009-01-19 17:10:23 UTC (rev 3463)
@@ -35,26 +35,78 @@
$.get("../print/testConfigTemplate.json", function(json, status){
var obj = eval('(' + json + ')');
buildForm(obj);
+ hookForm();
});
+}
+
+function hookForm() {
var options = {
- target: '#printPDF',
- url: 'testfactories.php',
- beforeSubmit: showWorking,
- success: function() {
- alert('Thanks for your comment!');
- }
+ url: '../print/testfactories.php',
+ beforeSubmit: validate,
+ success: showResult
};
$("#"+myId+"_form").ajaxForm(options);
}
-function showWorking(formData, jqForm, options) {
+function validate(formData, jqForm, options) {
$('#printPDF_working_bg').show();
$('#printPDF_working').show();
- var queryString = jqForm.length;
- alert('About to submit: \n\n' + queryString);
- return true;
+ var ind = getMapObjIndexByName(myTarget);
+ var f = jqForm[0];
+ f.map_url.value = '';
+ f.overview_url.value = '';
+ for(var i=0; i < mb_mapObj[ind].wms.length; i++){
+ if(mb_mapObj[ind].wms[i].gui_wms_visible > 0){
+ if(mb_mapObj[ind].wms[i].mapURL != false && mb_mapObj[ind].wms[i].mapURL != 'false' && mb_mapObj[ind].wms[i].mapURL != ''){
+ if(f.map_url.value != ""){
+ f.map_url.value += '___';
+ }
+ //alert(f.map_url.value);
+ f.map_url.value += mb_mapObj[ind].wms[i].mapURL;
+ }
+ }
+ }
+ for(var j=0; j < formData.length; j++){
+ if (formData[j].name == "map_url") {
+ formData[j].value = f.map_url.value;
+ break;
+ }
+ }
+
+ //overview_url
+ var ind_overview = getMapObjIndexByName('overview');
+
+ if(mb_mapObj[ind_overview].mapURL != false ){
+ //f.overview_url.value = mb_mapObj[ind_overview].mapURL;
+ for(var j=0; j < formData.length; j++){
+ if (formData[j].name == "overview_url") {
+ formData[j].value = mb_mapObj[ind_overview].mapURL;
+ break;
+ }
+ }
+ }
+
+ if (f.map_url.value!="") {
+ return true;
+ } else {
+ $('#printPDF_working_bg').hide();
+ $('#printPDF_working').hide();
+ return false;
+ }
+
}
+function showResult(res) {
+ $('#printPDF_working_bg').hide();
+ $('#printPDF_working').hide();
+ /*
+ if (res.outputFileName)
+ window.location = res.outputFileName;
+ else
+ $('#printPDF_result').html(text);
+ */
+}
+
function buildForm(json) {
/* first let's build some defaults then the stuff from config */
@@ -83,5 +135,5 @@
}
str += '</div>\n';
}
- $("#submit").before(str);
+ $("#formsubmit").before(str);
}
\ No newline at end of file
Modified: branches/print_dev/http/print/testConfigTemplate.json
===================================================================
--- branches/print_dev/http/print/testConfigTemplate.json 2009-01-16 14:54:41 UTC (rev 3462)
+++ branches/print_dev/http/print/testConfigTemplate.json 2009-01-19 17:10:23 UTC (rev 3463)
@@ -15,7 +15,8 @@
"label" : "DPI",
"type" : "select",
"size" : 20,
- "options" : [{
+ "options" : [
+ {
"value" : "val1",
"label" : "label1"
},{
@@ -32,7 +33,7 @@
"label" : "Kommentar",
"type" : "textarea",
"size" : 5
- },
+ }
],
"pages" : [
{
Modified: branches/print_dev/http/print/testfactories.php
===================================================================
--- branches/print_dev/http/print/testfactories.php 2009-01-16 14:54:41 UTC (rev 3462)
+++ branches/print_dev/http/print/testfactories.php 2009-01-19 17:10:23 UTC (rev 3463)
@@ -7,6 +7,6 @@
$pdf->render();
$pdf->save();
-
-print $pdf->returnURL();
+$pdf->returnPDF();
+//print $pdf->returnURL();
?>
\ No newline at end of file
More information about the Mapbender_commits
mailing list