[Mapbender-commits] r9158 - in trunk/mapbender/http: geoportal/preview javascripts php plugins
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Mon Mar 2 02:07:02 PST 2015
Author: syed
Date: 2015-03-02 02:07:02 -0800 (Mon, 02 Mar 2015)
New Revision: 9158
Added:
trunk/mapbender/http/php/mb_metadata_uploadLayerPreview.php
Modified:
trunk/mapbender/http/geoportal/preview/
trunk/mapbender/http/javascripts/mod_savewmc.php
trunk/mapbender/http/plugins/mb_digitize_widget.php
trunk/mapbender/http/plugins/mb_metadata_edit.js
Log:
add mb_metadata_uploadLayerPreview.php
Property changes on: trunk/mapbender/http/geoportal/preview
___________________________________________________________________
Added: svn:ignore
+ *preview.jpg
*preview.png
Modified: trunk/mapbender/http/javascripts/mod_savewmc.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_savewmc.php 2015-03-02 09:27:24 UTC (rev 9157)
+++ trunk/mapbender/http/javascripts/mod_savewmc.php 2015-03-02 10:07:02 UTC (rev 9158)
@@ -2,8 +2,8 @@
/*
* License:
* Copyright (c) 2009, Open Source Geospatial Foundation
- * This program is dual licensed under the GNU General Public License
- * and Simplified BSD license.
+ * This program is dual licensed under the GNU General Public License
+ * and Simplified BSD license.
* http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt
*/
require_once(dirname(__FILE__)."/../php/mb_validatePermission.php");
@@ -46,7 +46,7 @@
while($row = db_fetch_array($res)) {
$i++;
$str .= "<label for=\"{$prefix}_wmcIsoTopicCategory_{$row[0]}\">" .
- "<input class=\"wmcIsoTopicCategory\" id=\"{$prefix}_wmcIsoTopicCategory_{$row[0]}\" " .
+ "<input class=\"wmcIsoTopicCategory\" id=\"{$prefix}_wmcIsoTopicCategory_{$row[0]}\" " .
"type=\"checkbox\" />{$row[1]}</label>";
}
return $str;
@@ -84,23 +84,28 @@
$labelCategories = $translatedI18nObj["labelCategories"];
echo <<<HTML
+//TODO: add input for uuid,title already there. created and updated need no input.just save it to the database...
-var wmcSaveFormHtml = '<form><fieldset>' +
- '<label for="{$e_id}_wmctype">{$labelNewOrOverwrite}</label>' +
- '<select class="ui-corner-all" id="{$e_id}_wmctype">' +
- '<option value="">{$labelNewWmc}</option></select>' +
- '<label for="{$e_id}_wmcname">{$labelName}</label>' +
- '<input id="{$e_id}_wmcname" type="text" class="text ui-widget-content ui-corner-all" />' +
- '<label for="{$e_id}_wmcabstract">{$labelAbstract}</label>' +
- '<textarea id="{$e_id}_wmcabstract" class="text ui-widget-content ui-corner-all"></textarea>' +
- '<label for="{$e_id}_wmckeywords">{$labelKeywords}</label>' +
- '<input id="{$e_id}_wmckeywords" type="text" class="text ui-widget-content ui-corner-all" />' +
- '<input id="{$e_id}_wmc_id" type="hidden" />' +
- '</fieldset><fieldset id="{$e_id}_isoTopic_cat"><legend>{$labelCategories}' +
- '</legend>' +
- '{$saveWmcCategoryString}' +
+var wmc_uuid = UUID.genV4().toString();
+
+var wmcSaveFormHtml = '<form><fieldset>' +
+ '<label for="{$e_id}_wmctype">{$labelNewOrOverwrite}</label>' +
+ '<select class="ui-corner-all" id="{$e_id}_wmctype">' +
+ '<option value="">{$labelNewWmc}</option></select>' +
+ '<label for="{$e_id}_wmcname">{$labelName}</label>' +
+ '<input id="{$e_id}_wmcname" type="text" class="text ui-widget-content ui-corner-all" />' +
+ '<label for="{$e_id}_wmcabstract">{$labelAbstract}</label>' +
+ '<textarea id="{$e_id}_wmcabstract" class="text ui-widget-content ui-corner-all"></textarea>' +
+ '<label for="{$e_id}_wmckeywords">{$labelKeywords}</label>' +
+ '<input id="{$e_id}_wmckeywords" type="text" class="text ui-widget-content ui-corner-all" />' +
+ '<input id="{$e_id}_wmc_id" type="hidden" />' +
+ '<input id="{$e_id}_wmc_id" type="hidden" />' +
+ '<input id="{$e_id}_wmc_uuid" value={wmc_uuid} />' +
+ '</fieldset><fieldset id="{$e_id}_isoTopic_cat"><legend>{$labelCategories}' +
+ '</legend>' +
+ '{$saveWmcCategoryString}' +
'</fieldset></form>';
-
+
var originalI18nObj = $originalI18nObjJson;
var translatedI18nObj = $translatedI18nObjJson;
Added: trunk/mapbender/http/php/mb_metadata_uploadLayerPreview.php
===================================================================
--- trunk/mapbender/http/php/mb_metadata_uploadLayerPreview.php (rev 0)
+++ trunk/mapbender/http/php/mb_metadata_uploadLayerPreview.php 2015-03-02 10:07:02 UTC (rev 9158)
@@ -0,0 +1,141 @@
+<?php
+
+/**
+ * @version Changed: ### 2015-02-26 13:38:03 UTC ###
+ * @author Raphael.Syed <raphael.syed at WhereGroup.com> http://WhereGroup.com
+ */
+
+
+/**
+ * Gets an image for layer or wmc preview.
+ * Convert the image to the right format and save it in the @preview_dir
+ */
+
+require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
+
+$user_id = Mapbender::session()->get("mb_user_id");
+$data = $_POST;
+$source_id = $data['source_id'];
+//set variables
+$width;
+$height;
+$new_name;
+//get the http referer and the service (wms,wmc)
+$referer = explode('=',$_SERVER["HTTP_REFERER"]);
+$service = end($referer);
+// get the file informations
+$info = pathinfo($_FILES['image']['name']);
+// get the extension of the file
+$ext = $info['extension'];
+// set the new fileName
+if ($service == 'admin_wmc_metadata') {
+
+ $new_name = $source_id."_wmc_preview.png";//.$ext;
+}
+else {
+
+ $new_name = $source_id."_layer_map_preview.png";//.$ext;
+
+}
+// get the ímage
+$image = $_FILES['image']['tmp_name'];
+//resize the image to 200px * 200px
+$new_image = dirname(__FILE__)."/../geoportal/preview/".$new_name;
+// get image size
+$size = Getimagesize($image);
+$images_orig;
+//create an gd-image-object from the source file
+switch ($ext) {
+ case 'jpg':
+
+ $images_orig = ImageCreateFromJPEG($image);
+ break;
+
+ case 'png':
+
+ $images_orig = ImageCreateFrompng($image);
+ break;
+
+ case 'gif':
+
+ $images_orig = ImageCreateFromgif($image);
+ break;
+
+ default:
+
+ return;
+ break;
+}
+//if width and height are to big
+if ($size[0] >= 200 || $size[1] >= 200) {
+ // width of the origin image
+ $photoW = ImagesX($images_orig);
+ // height of the origin image
+ $photoH = ImagesY($images_orig);
+ // create new image with the calculated size
+ $images_target = ImageCreateTrueColor(200, 200);
+ //fill the new image with transparency background
+ $color = imagecolorallocatealpha($images_target, 0, 0, 0, 127); //fill transparent back
+ imagefill($images_target, 0, 0, $color);
+ imagealphablending( $images_target, false );
+ imagesavealpha($images_target, true);
+ //set the new image width and height
+ if ($size[0] > $size[1] || $size[0] == $size[1]) {
+
+ $width = 200;
+ $height = round($width*$size[1]/$size[0]);
+ // calculate the height of the src_image in the target_image
+ $startHeight = round((200-$height)/2);
+ // resize the image:
+ ImageCopyResampled($images_target, $images_orig, 0, $startHeight, 0, 0, $width, $height, $photoW, $photoH);
+
+ }else{
+
+ $height = 200;
+ $width = round($height*$size[0]/$size[1]);
+ $startWidth = round((200-$width)/2);
+ ImageCopyResampled($images_target, $images_orig, $startWidth, 0, 0, 0, $width, $height, $photoW, $photoH);
+ }
+ // set new target dir
+ $target = dirname(__FILE__).'/../tmp/'.$new_name;
+ // move File to the new target directory --> always save as png
+ Imagepng($images_target,$new_image);
+ // free space
+ ImageDestroy($images_orig);
+ ImageDestroy($images_target);
+ return;
+} // if image-width and height are to small
+else if($size[0] < 200 && $size[1] < 200){
+ //set the new image width
+ $width = $size[0];
+ // scale the height
+ $height = $size[1];
+ // width of the origin image
+ $photoW = ImagesX($images_orig);
+ // height of the origin image
+ $photoH = ImagesY($images_orig);
+ // create new image with the calculated size
+ $images_target = ImageCreateTrueColor(200, 200);
+ //fill the new image with transparency background
+ $color = imagecolorallocatealpha($images_target, 0, 0, 0, 127); //fill transparent back
+ imagefill($images_target, 0, 0, $color);
+ imagealphablending( $images_target, false );
+ imagesavealpha($images_target, true);
+ // calculate the height of the src_image in the target_image
+ $startHeight = round((200-$height)/2);
+ $startWidth = round((200-$width)/2);
+ // resize the image
+ ImageCopyResampled($images_target, $images_orig, $startWidth, $startHeight, 0, 0, $width, $height, $photoW, $photoH);
+ // set new target dir
+ $target = dirname(__FILE__).'/../tmp/'.$new_name;
+ // move File to the new target directory --> always save as png
+ Imagepng($images_target,$new_image);
+ // free space
+ ImageDestroy($images_orig);
+ ImageDestroy($images_target);
+ return;
+}
+
+
+
+
Modified: trunk/mapbender/http/plugins/mb_digitize_widget.php
===================================================================
--- trunk/mapbender/http/plugins/mb_digitize_widget.php 2015-03-02 09:27:24 UTC (rev 9157)
+++ trunk/mapbender/http/plugins/mb_digitize_widget.php 2015-03-02 10:07:02 UTC (rev 9158)
@@ -71,6 +71,7 @@
'<div class="digitize-image digitize-point"></div>' +
'<div class="digitize-image digitize-line"></div>' +
'<div class="digitize-image digitize-polygon"></div>' +
+ '<div class="digitize-image digitize-attributes editFeatureCollection"></div>' +
'</div>';
var editHtml = '<div title="Edit feature">' +
@@ -564,42 +565,80 @@
};
var editAttributes = function(feature, kml, url) {
+
return function() {
- attributesDialog.dialog('open');
- attributesDialog.find('*').unbind();
- var rows = '';
- $.each(feature.properties, function(k, v) {
- if(k.match(/Mapbender:/)) return;
- rows += '<tr><td>' + k + '</td><td><input type="text" name="' + k + '" value="' + v + '"></input></td></tr>';
- });
- attributesDialog.find('table').html(rows);
- attributesDialog.find('.digitize-add').bind('click', function() {
- var newRow = $('<tr><td><input type="text"></input></td><td><input type="text"></input></td></tr>');
- attributesDialog.find('table').append(newRow);
- newRow.find('input').first().bind('change', function() {
- newRow.find('input').last().attr('name', $(this).val());
+
+ if ($(this).hasClass('editFeatureCollection')) {
+
+ var featureCollAttrDlg = $('<div id="featureCollAttrDlg"></div>').dialog({
+ title: "Featurecollection attributes ",// of "+ url,
+ width: 400,
+ // height: 212,
+ position: {
+ my: "center",
+ at: "top",
+ of: window
+ },
+ close: function(){
+ $('#featureCollAttrDlg').dialog('destroy');
+ $('#featureCollAttrDlg').remove();
+ }
+ });
+
+ var featureCollectionContent = "<div class='digitize-image digitize-style'></div>"+
+ "<br><br>"+
+ "<div><table>"+
+ "<tr><td>uuid</td><td><input type='text' value='test'/></td></tr>"+
+ "<tr><td>title</td><td><input type='text' value='test'/></td></tr>"+
+ "<tr><td>created</td><td><input type='text' value='test'/></td></tr>"+
+ "<tr><td>updated</td><td><input type='text' value='test'/></td></tr>"+
+ "</table></div>"+
+ "<br><br/>"+
+ "<div class='digitize-image digitize-add'></div>"+
+ "<div class='digitize-image digitize-save'></div>";
+ $('#featureCollAttrDlg').append(featureCollectionContent);
+
+ }else{
+
+ attributesDialog.dialog('open');
+ attributesDialog.find('*').unbind();
+ var rows = '';
+ $.each(feature.properties, function(k, v) {
+ if(k.match(/Mapbender:/)) return;
+ rows += '<tr><td>' + k + '</td><td><input type="text" name="' + k + '" value="' + v + '"></input></td></tr>';
});
- });
+ attributesDialog.find('table').html(rows);
+ attributesDialog.find('.digitize-add').bind('click', function() {
+ var newRow = $('<tr><td><input type="text"></input></td><td><input type="text"></input></td></tr>');
+ attributesDialog.find('table').append(newRow);
+ newRow.find('input').first().bind('change', function() {
+ newRow.find('input').last().attr('name', $(this).val());
+ });
+ });
- var $link = $('li[title="' + url + '"] > ul > li');
+ var $link = $('li[title="' + url + '"] > ul > li');
- attributesDialog.find('.digitize-style').bind('click', editStyle($link, null));
- attributesDialog.find('.digitize-save').bind('click', function() {
- attributesDialog.find('table input').each(function() {
- var k = $(this).attr('name');
- var v = $(this).val();
- if(k) {
- feature.properties[k] = v;
- }
+ attributesDialog.find('.digitize-style').bind('click', editStyle($link, null));
+ attributesDialog.find('.digitize-save').bind('click', function() {
+ attributesDialog.find('table input').each(function() {
+ var k = $(this).attr('name');
+ var v = $(this).val();
+ if(k) {
+ feature.properties[k] = v;
+ }
+ });
+ feature.properties.updated = new Date().toISOString();
+
+ attributesDialog.dialog('close');
+ editDialog.dialog('close');
+ kml.refresh(url);
});
- feature.properties.updated = new Date().toISOString();
+ var preview = attributesDialog.find('.digitize-preview').html('').get(0);
+ kml.renderPreview(feature, preview);
- attributesDialog.dialog('close');
- editDialog.dialog('close');
- kml.refresh(url);
- });
- var preview = attributesDialog.find('.digitize-preview').html('').get(0);
- kml.renderPreview(feature, preview);
+ }
+
+
};
};
@@ -731,6 +770,11 @@
digitizingFor = $link.parent().attr('title');
that.activate();
});
+ // get the featureCollection data
+ var url = $link.parent().attr('title');
+ var featureCollection = $('#mapframe1').data('kml')._kmls[url].data;
+ digitizeDialog.find('.digitize-attributes').bind('click', editAttributes(featureCollection, kml, url));
+
digitizeDialog.find('.digitize-remove').bind('click', function() {
var kml = $('#mapframe1').data('kml');
var url = $link.parent().attr('title');
Modified: trunk/mapbender/http/plugins/mb_metadata_edit.js
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_edit.js 2015-03-02 09:27:24 UTC (rev 9157)
+++ trunk/mapbender/http/plugins/mb_metadata_edit.js 2015-03-02 10:07:02 UTC (rev 9158)
@@ -6,7 +6,7 @@
* Files:
*
* SQL:
- *
+ *
* Help:
*
* Maintainer:
@@ -27,7 +27,7 @@
var validator;
var formReady = false;
var wmsId;
-
+
this.events = {
showOriginalMetadata : new Mapbender.Event(),
submit: new Mapbender.Event()
@@ -40,7 +40,7 @@
}
return true;
};
-
+
this.serialize = function (callback) {
$metadataForm.submit();
var data = null;
@@ -54,7 +54,7 @@
}
return data !== null ? data.wms : data;
};
-
+
// second optional parameter formData
var fillForm = function (obj) {
if (arguments.length >= 2) {
@@ -63,7 +63,7 @@
that.valid();
return;
}
-
+
// get metadata from server
var req = new Mapbender.Ajax.Request({
url: "../plugins/mb_metadata_server.php",
@@ -82,7 +82,7 @@
that.valid();
}
});
- req.send();
+ req.send();
};
this.fillMdContact = function(obj) {
@@ -106,7 +106,7 @@
}
});
req.send();
- }
+ }
//Show more information about the licences
this.fillLicence = function(obj) {
@@ -140,12 +140,12 @@
}
});
req.send();
- }
+ }
this.fill = function (obj) {
$metadataForm.easyform("fill", obj);
};
-
+
var showOriginalMetadata = function () {
that.events.showOriginalMetadata.trigger({
data : {
@@ -154,23 +154,23 @@
}
});
};
-
+
this.init = function (obj) {
-
+
wmsId = obj;
-
+
if (!wmsId) {
return;
}
-
+
var formData = arguments.length >= 2 ? arguments[1] : undefined;
-
+
if (!formReady) {
$metadataForm.load("../plugins/mb_metadata_edit.php", function () {
$metadataForm.find(".help-dialog").helpDialog();
$metadataForm.find(".original-metadata-wms").bind("click", function() {
showOriginalMetadata();
- });
+ });
validator = $metadataForm.validate({
submitHandler: function () {
return false;
@@ -188,7 +188,7 @@
}
fillForm(obj);
};
-
+
Mapbender.events.localize.register(function () {
that.valid();
var formData = $metadataForm.easyform("serialize");
More information about the Mapbender_commits
mailing list