[Mapbender-commits] r9153 - in trunk/mapbender/http: css php plugins

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Feb 18 07:16:49 PST 2015


Author: syed
Date: 2015-02-18 07:16:49 -0800 (Wed, 18 Feb 2015)
New Revision: 9153

Added:
   trunk/mapbender/http/php/mb_publish_wmc.php
   trunk/mapbender/http/php/mb_unpublish_wmc.php
Modified:
   trunk/mapbender/http/css/kmltree.css
   trunk/mapbender/http/php/mb_list_wmc_local_data.php
   trunk/mapbender/http/plugins/kmlTree.js
Log:
add dataset-publication

Modified: trunk/mapbender/http/css/kmltree.css
===================================================================
--- trunk/mapbender/http/css/kmltree.css	2015-02-17 11:03:48 UTC (rev 9152)
+++ trunk/mapbender/http/css/kmltree.css	2015-02-18 15:16:49 UTC (rev 9153)
@@ -177,3 +177,28 @@
     background-repeat: no-repeat;
     background-position: 50% 50%;
 }
+
+.kmltree-metadata-list {
+    list-style-type: none;
+}
+
+.kmltree-metadata-list li {
+    cursor: pointer;
+    line-height: 22px;
+}
+
+.kmltree-metadata-list li img {
+    vertical-align: middle;
+}
+
+#licenseTbl td, #licenseTbl th{
+
+border: 1px solid rgb(211, 214, 255);
+
+}
+#licenseTbl td:empty{
+
+border: none !important;
+
+}
+

Modified: trunk/mapbender/http/php/mb_list_wmc_local_data.php
===================================================================
--- trunk/mapbender/http/php/mb_list_wmc_local_data.php	2015-02-17 11:03:48 UTC (rev 9152)
+++ trunk/mapbender/http/php/mb_list_wmc_local_data.php	2015-02-18 15:16:49 UTC (rev 9153)
@@ -20,7 +20,7 @@
 
 $user_id = Mapbender::session()->get("mb_user_id");
 
-$sql = 'select wmc_id, wmc_title, wmc_timestamp, wmc_local_data_size from mb_user_wmc where wmc_has_local_data = 1 and (fkey_user_id = $1 or wmc_local_data_public = 1);';
+$sql = 'select a.wmc_id, a.wmc_local_data_public, a.wmc_title, a.wmc_timestamp, a.wmc_local_data_size, termsofuse.symbollink from mb_user_wmc a left join termsofuse on termsofuse.termsofuse_id = a.wmc_local_data_fkey_termsofuse_id where wmc_has_local_data = 1 and (fkey_user_id = $1 or wmc_local_data_public = 1);';
 
 $v = array($user_id);
 $t = array("i");
@@ -31,6 +31,8 @@
     $wmc[] = $row['wmc_id'];
     $wmc[] = $row['wmc_title'];
     $wmc[] = $row['wmc_timestamp'];
+    $wmc[] = $row['symbollink'];
+    $wmc[] = $row['wmc_local_data_public'] == 1;
     $wmc[] = $row['wmc_local_data_size'];
     $wmcs[] = $wmc;
 }

Added: trunk/mapbender/http/php/mb_publish_wmc.php
===================================================================
--- trunk/mapbender/http/php/mb_publish_wmc.php	                        (rev 0)
+++ trunk/mapbender/http/php/mb_publish_wmc.php	2015-02-18 15:16:49 UTC (rev 9153)
@@ -0,0 +1,56 @@
+<?php
+
+/**
+ * @version   Changed: ### 2015-02-12 14:11:41 UTC ###
+ * @author    Raphael.Syed <raphael.syed at WhereGroup.com> http://WhereGroup.com
+ */
+require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
+// require_once(dirname(__FILE__) . "/../classes/class_wmc.php");
+/**
+ * unpublish the the given wmc
+ */
+
+$user_id = Mapbender::session()->get("mb_user_id");
+$wmc_id = $_POST["wmc_id"];
+$dataMode = $_POST['mode'];
+$dataLicense = $_POST['license'];
+
+
+if($dataMode === 'getLicenseMode'){
+
+    $sql = 'SELECT symbollink,description,isopen FROM termsofuse WHERE name = $1';
+    $v = array($dataLicense);
+    $t = array("s");
+    header('Content-Type: application/json');
+    $res = db_prep_query($sql, $v, $t);
+    while($row = db_fetch_array($res)){
+        echo json_encode($row);
+    }
+}else if($dataMode === 'saveLicenseMode'){
+
+    // #1 Update wmc_local_data_public
+    $sql =  'UPDATE mb_user_wmc mb  SET wmc_local_data_public = 1, wmc_local_data_fkey_termsofuse_id = t.termsofuse_id from termsofuse t WHERE mb.wmc_id = $1 AND mb.fkey_user_id = $2 AND t.name = $3';
+    $v = array($wmc_id,$user_id,$dataLicense);
+    $t = array("s","i","s");
+    header('Content-Type: application/json');
+    $res = db_prep_query($sql, $v, $t);
+
+
+
+}else if($dataMode === 'getAllLicencesMode'){
+
+    $resultArray = array();
+    $sql = 'SELECT name FROM termsofuse';
+    header('Content-Type: application/json');
+    $res = db_query($sql);
+
+    //echo db_fetch_array($res);
+    while($row = db_fetch_array($res)){
+        $resultArray[]= $row;
+    }
+    echo json_encode($resultArray);
+
+}
+
+
+?>

Added: trunk/mapbender/http/php/mb_unpublish_wmc.php
===================================================================
--- trunk/mapbender/http/php/mb_unpublish_wmc.php	                        (rev 0)
+++ trunk/mapbender/http/php/mb_unpublish_wmc.php	2015-02-18 15:16:49 UTC (rev 9153)
@@ -0,0 +1,37 @@
+<?php
+
+/**
+ * @version   Changed: ### 2015-02-12 14:11:41 UTC ###
+ * @author    Raphael.Syed <raphael.syed at WhereGroup.com> http://WhereGroup.com
+ */
+require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
+// require_once(dirname(__FILE__) . "/../classes/class_wmc.php");
+/**
+ * unpublish the the given wmc
+ */
+
+$user_id = Mapbender::session()->get("mb_user_id");
+$wmc_id = $_POST["wmc_id"];
+
+
+// $wmc = new wmc();
+
+
+
+
+// $sql = 'UPDATE mb_user_wmc SET wmc_local_data_public=0, wmc_local_data_fkey_termsofuse_id =8 WHERE wmc_id= $1 AND fkey_user_id = $2'; // $sql = 'select wmc from mb_user_wmc where wmc_id = $1 and wmc_has_local_data = 1 and fkey_user_id = $2;';
+$sql = 'UPDATE mb_user_wmc SET wmc_local_data_public=0, wmc_local_data_fkey_termsofuse_id = null WHERE wmc_id= $1 AND fkey_user_id = $2'; // $sql = 'select wmc from mb_user_wmc where wmc_id = $1 and wmc_has_local_data = 1 and fkey_user_id = $2;';
+// $sql = 'SELECT wmc_local_data_public FROM mb_user_wmc WHERE wmc_id= $1 AND fkey_user_id = $2'; // $sql = 'select wmc from mb_user_wmc where wmc_id = $1 and wmc_has_local_data = 1 and fkey_user_id = $2;';
+
+$v = array($wmc_id, $user_id);
+$t = array("i", "i");
+$res = db_prep_query($sql, $v, $t);
+
+if (!$res) {
+    return false;
+}
+else {
+    echo true;
+}
+
+?>

Modified: trunk/mapbender/http/plugins/kmlTree.js
===================================================================
--- trunk/mapbender/http/plugins/kmlTree.js	2015-02-17 11:03:48 UTC (rev 9152)
+++ trunk/mapbender/http/plugins/kmlTree.js	2015-02-18 15:16:49 UTC (rev 9153)
@@ -36,25 +36,25 @@
  * http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt
  */
 
-if( typeof window.DOMParser === "undefined" ){
-    window.DOMParser = function(){};
+if (typeof window.DOMParser === "undefined") {
+    window.DOMParser = function() {};
 
-    window.DOMParser.prototype.parseFromString = function(str, contentType){
-        if(typeof ActiveXObject !== 'undefined'){
+    window.DOMParser.prototype.parseFromString = function(str, contentType) {
+        if (typeof ActiveXObject !== 'undefined') {
             var xmldata = new ActiveXObject('MSXML.DomDocument');
             xmldata.async = false;
             xmldata.loadXML(str);
             return xmldata;
-        } else if(typeof XMLHttpRequest !== 'undefined'){
+        } else if (typeof XMLHttpRequest !== 'undefined') {
             var xmldata = new XMLHttpRequest;
 
-            if(!contentType){
+            if (!contentType) {
                 contentType = 'application/xml';
             }
 
             xmldata.open('GET', 'data:' + contentType + ';charset=utf-8,' + encodeURIComponent(str), false);
 
-            if(xmldata.overrideMimeType) {
+            if (xmldata.overrideMimeType) {
                 xmldata.overrideMimeType(contentType);
             }
 
@@ -66,7 +66,7 @@
 }
 
 var $kmlTree = $(this);
-var KmlTree = function(o){
+var KmlTree = function(o) {
     $kmlTree.children().remove();
     $kmlTree.addClass('kmlTree');
     var $KMLfolder = $('<li class="open kml"><ul></ul></li>');
@@ -76,115 +76,409 @@
 
     var selectButton = $('<img id="toggle-select-features" src="../img/osgeo_graphics/geosilk/cursor.png"></img>');
 
-    $addButton.click(function(){
-        var dlg = $('<div ></div>').dialog({
-            "title": "My spatial data",
-            width: 450,
-            height: 420,
-            close: function() {
-                $('#kml-load-tabs').tabs('destroy');
-                $(this).html('').dialog('destroy');
-            }
-        });
-        var dlgcontent = '<div id="kml-load-tabs">'
-                         + '<ul><li><a class="icon icon-wmc" href="#kml-from-wmc">Stored data</a></li>'
-                         + '<li><a class="icon icon-local" href="#kml-from-upload">Upload</a></li>'
-                         + '<li><a class="icon icon-remote" href="#kml-from-url">External source</a></li>'
-                         + '<li><a class="icon icon-new" href="#kml-new">New</a></li></ul>'
-                         + '<div id="kml-from-wmc">wmc</div>'
-                         + '<div id="kml-from-upload">'
-                         + '<iframe name="kml-upload-target" style="width: 0; height: 0; border: 0px;"></iframe>'
-                         + '<form action="../php/uploadKml.php" method="post" enctype="multipart/form-data" target="kml-upload-target">'
-                         + '<input type="file" name="kml"></input>'
-                         + '<input type="submit" class="upload" value="Upload"></input><br>'
-                         + 'You can upload local KML, GPX and geoJSON files here. The filename should'
-                         + ' have the typical file extension (.kml, .gpx or .geojson) and the size'
-                         + ' is limited to 250kb of data.'
-                         + '</div>'
-                         + '</form>'
-                         + '<div id="kml-from-url">URL: <input class="kmlurl" /><button class="add" name="add" value="add"></button><br>'
-                         + 'You can give an url to a datafile which is located somewhere in the www. '
-                         + 'Only KML, geoJSON and GPX files are supported. The files will be validated before they'
-                         + ' are loaded into the mapviewer.'
-                         + '</div>'
-                         + '<div id="kml-new">'
-                         + '<label>Title: <input type="text" name="kml-new-title"></input></label>'
-                         + '<button class="add-kml"></button>'
-                         + '</div>'
-                         + '</div>';
-        $('#kml-load-tabs').remove();
-        $(dlg).append(dlgcontent);
-        $.ajax({
-            type: 'get',
-            url: '../php/mb_list_wmc_local_data.php',
-            success: function(data) {
-                $.each(data, function(_, v) {
-                    v[2] = new Date(v[2] * 1000);
-                    v[3] = Math.round(v[3] / 1024) + 'kb';
-                });
-                $('#kml-from-wmc').html('<table class="display"></table>').find('table').dataTable({
-                    aaData: data,
-                    aoColumns: [{sTitle: 'ID'}, {sTitle: 'Title'}, {sTitle: 'last change'}, {sTitle: 'size'}]
-                })
-                .find('tr').bind('click', function() {
-                    $(this).addClass('row_selected').siblings().removeClass('row_selected');
-                })
-                .bind('dblclick', function() {
-                    var id = $($(this).find('td')[0]).text();
-                    $.ajax({
-                        type: 'post',
-                        url: '../php/mb_load_local_data.php',
-                        data: {
-                            id: id
-                        },
-                        success: function(data) {
-                            var kml = $('#mapframe1').data('kml');
-                            $.each(data, function(url, json) {
-                                kml.addLayer(url, json.data);
-                            });
-                            $(dlg).dialog('destroy');
+    $addButton.click(function() {
+        if ($('#mySpatialData').dialog('isOpen') === true) {
+
+
+            return;
+
+        } else {
+            var dlg = $('<div id="mySpatialData"></div>').dialog({
+                "title": "My spatial data",
+                width: 720,
+                height: 420,
+                close: function() {
+                    $('#kml-load-tabs').tabs('destroy');
+                    $(this).html('').dialog('destroy');
+                    // $('#mySpatialData').dialog('destroy');
+                    $('#mySpatialData').remove();
+                }
+            });
+            var dlgcontent = '<div id="kml-load-tabs">' + '<ul><li><a class="icon icon-wmc" href="#kml-from-wmc">Stored data</a></li>' + '<li><a class="icon icon-local" href="#kml-from-upload">Upload</a></li>' + '<li><a class="icon icon-remote" href="#kml-from-url">External source</a></li>' + '<li><a class="icon icon-new" href="#kml-new">New</a></li></ul>' + '<div id="kml-from-wmc">wmc</div>' + '<div id="kml-from-upload">' + '<iframe name="kml-upload-target" style="width: 0; height: 0; border: 0px;"></iframe>' + '<form action="../php/uploadKml.php" method="post" enctype="multipart/form-data" target="kml-upload-target">' + '<input type="file" name="kml"></input>' + '<input type="submit" class="upload" value="Upload"></input><br>' + 'You can upload local KML, GPX and geoJSON files here. The filename should' + ' have the typical file extension (.kml, .gpx or .geojson) and the size' + ' is limited to 250kb of data.' + '</div>' + '</form>' + '<div id="kml-from-url">URL: <input cl
 ass="kmlurl" /><button class="add" name="add" value="add"></button><br>' + 'You can give an url to a datafile which is located somewhere in the www. ' + 'Only KML, geoJSON and GPX files are supported. The files will be validated before they' + ' are loaded into the mapviewer.' + '</div>' + '<div id="kml-new">' + '<label>Title: <input type="text" name="kml-new-title"></input></label>' + '<button class="add-kml"></button>' + '</div>' + '</div>';
+            $('#kml-load-tabs').remove();
+            $(dlg).append(dlgcontent);
+            $.ajax({
+                type: 'get',
+                url: '../php/mb_list_wmc_local_data.php',
+                success: function(data) {
+                    var origData = $.extend(true, {}, data);
+                    $.each(data, function(_, v) {
+                        v[2] = new Date(v[2] * 1000);
+                        if (v[3]) {
+                            v[3] = '<img src="' + v[3] + '"></img>';
                         }
+                        if (v[4]) {
+                            v[4] = '<img src="../img/osgeo_graphics/check.png"></img><img src="../img/osgeo_graphics/geosilk/link22.png"></img>';
+                        } else {
+                            v[4] = '<img src="../img/button_digitize/geomRemove.png"></img>';
+                        }
+                        v[5] = Math.round(v[5] / 1024) + 'kb';
                     });
+                    $('#kml-from-wmc').html('<table class="display"></table>').find('table').dataTable({
+                            aaData: data,
+                            aoColumns: [{
+                                sTitle: 'ID'
+                            }, {
+                                sTitle: 'Title'
+                            }, {
+                                sTitle: 'last change'
+                            }, {
+                                sTitle: 'License'
+                            }, {
+                                sTitle: 'public'
+                            }, {
+                                sTitle: 'size'
+                            }]
+                        })
+                        .find('tr').bind('click', function() {
+                            var id = $($(this).find('td')[0]).text();
+                            var d;
+                            $.each(origData, function(_, val) {
+                                if (val[0] == id) {
+                                    d = val;
+                                }
+                            });
+                            var dlg = '<div title="Options ' + d[1] + '">' +
+                                '<ul class="kmltree-metadata-list">' + '<li class="kmltree-metadata-delete"><img style="vertical-align: middle;" src="../img/button_digitize/geomRemove.png"></img>Delete datacollection</li>';
+
+                            if (d[4]) {
+                                dlg += '<li class="kmltree-metadata-unpublish"><img style="vertical-align: middle;" src="../img/gnome/emblem-unreadable.png"></img>Withdraw publication</li>';
+                            } else {
+                                dlg += '<li class="kmltree-metadata-publish"><img style="vertical-align: middle;" src="../img/gnome/share.png"></img>Publish datacollection</li>';
+                            }
+
+                            dlg += '</ul></div>';
+
+                            dlg = $(dlg).appendTo('body');
+
+                            $(dlg).dialog({
+                                create: function() {
+                                    $(dlg).find('li.kmltree-metadata-delete').bind('click', function() {
+                                        if (confirm('Really delete spatial data set?')) {
+                                            $(dlg).dialog('destroy');
+                                            $.ajax({
+                                                type: 'post',
+                                                url: '../php/mb_delete_local_data.php',
+                                                data: {
+                                                    id: id
+                                                },
+                                                success: function(data) {
+                                                    if (!data.success) {
+                                                        alert('Problem when deleting local data: ' + data.message);
+                                                    }
+                                                }
+                                            });
+                                        }
+                                    });
+
+                                    $(dlg).find('li.kmltree-metadata-unpublish').bind('click', function() {
+                                        if (confirm('Really unpublish spatial data set?')) {
+                                            $(dlg).dialog('destroy');
+                                            $.ajax({
+                                                url: '../php/mb_unpublish_wmc.php',
+                                                type: 'POST',
+                                                data: {
+                                                    wmc_id: id
+                                                },
+
+                                                success: function(data) {
+
+                                                    $('#mySpatialData').dialog('destroy');
+                                                    $('#mySpatialData').remove();
+                                                    $($addButton).trigger('click');
+
+
+
+                                                }
+
+
+                                            });
+
+
+
+                                        }
+                                    });
+
+                                    $(dlg).find('li.kmltree-metadata-publish').bind('click', function() {
+                                        var publishDialog;
+                                        $(dlg).dialog('destroy');
+                                        if ($('#wmcPublishConfirm').dialog('isOpen') === true) {
+
+
+                                            return;
+
+                                        } else {
+
+                                            publishDialog = $('<div id="wmcPublishConfirm"></div>').dialog({
+                                                title: "Publish datacollection " + d[1],
+                                                width: 720,
+                                                height: 180,
+                                                position: {
+                                                    my: "center",
+                                                    at: "top",
+                                                    of: window
+                                                },
+                                                close: function() {
+                                                    // $('#kml-load-tabs').tabs('destroy');
+                                                    // $(this).html('').dialog('destroy');
+                                                    $('#wmcPublishConfirm').dialog('destroy');
+                                                    $('#wmcPublishConfirm').remove();
+                                                }
+                                            });
+
+                                            var publishDlgContent = "<div style='font-size:16px;text-align:justify'>If you want to publish a datacolletcion, you first have to choose a license" +
+                                                " under which you want to distribute your data. Actually only OpenData compatible" +
+                                                " licences are supported in this application. Please read the licenses carefully before" +
+                                                " you activate this option. All of your data will be available for each person in the web" +
+                                                " in different formats and may be redistributed freely without any copyright. </div>" +
+                                                "<table style='margin-top:7px' ><tr><th id = 'publishDenied' style='width:50%;cursor:pointer'><img src='../img/button_digitize/geomRemove.png'></img>  No, I dont't want to publish</th>" +
+                                                "<th style='width:16%;visibility:hidden'>empty</th>" +
+                                                "<th id = 'publishConfirmed' style='width:50%;cursor:pointer'><img src='../img/osgeo_graphics/check.png'></img>  Yes, I know what I am doing </th></tr></table>";
+
+                                            $(publishDialog).append(publishDlgContent);
+
+
+                                        }
+
+
+
+
+
+
+                                        $(publishDialog).find('#publishConfirmed').bind('click', function() {
+                                            $(publishDialog).dialog('close');
+                                            // var initialLicense;
+                                            var chooseLicenseDialog = $('<div id="chooseLicenseDialog"></div>').dialog({
+                                                title: "Choose OpenData license for datacollection " + d[1],
+                                                width: 720,
+                                                height: 150,
+                                                position: {
+                                                    my: "center",
+                                                    at: "top",
+                                                    of: window
+                                                },
+                                                close: function() {
+                                                    // $('#kml-load-tabs').tabs('destroy');
+                                                    // $(this).html('').dialog('destroy');
+                                                    $('#chooseLicenseDialog').dialog('destroy');
+                                                    $('#chooseLicenseDialog').remove();
+                                                }
+                                            });
+
+                                            var chooseLicenseDlgCont = "<div><table id='licenseTbl'style='border-collapse: collapse'>" +
+                                                "<tr><th>Lizenz</th>" +
+                                                "<th>Logo</th><th>Beschreibung</th><th>Opendata</th></tr>" +
+                                                "<tr><td><select id='licenseChooser name='license'>" +
+                                                // "<option>Lizenz wählen</option>" +
+                                                // "<option>cc-by</option><option>cc-by-nc</option>" +
+                                                // "<option>cc-by-nd</option><option>cc-by-nc-nd</option>" +
+                                                // "<option>cc-by-sa</option><option>cc-by-nc-sa</option>"+
+                                                "</select></td>" +
+                                                "<td id='licenseImg'></td>" +
+                                                "<td id='licenseDescription'></td>" +
+                                                "<td id='licenseOpen'></td></tr>" + // TODO: add content for this field
+                                                "<tr id='submitLicense' ><td style='border:none;cursor:pointer; nowrap'><img src='../img/osgeo_graphics/check.png' style='margin-top:10px'/> <span>Publish data</span></td></tr>" +
+                                                "</table></div>";
+
+                                            //  add options for the select box
+                                            $(chooseLicenseDialog).append(chooseLicenseDlgCont);
+
+                                            $.ajax({
+                                                url: '../php/mb_publish_wmc.php',
+                                                type: 'POST',
+                                                data: {
+                                                    wmc_id: id,
+                                                    mode: 'getAllLicencesMode',
+                                                    license: 'empty'
+                                                },
+
+                                                success: function(data) {
+
+                                                    for (var i = 0; i < data.length; i++) {
+
+                                                        $('#licenseTbl select').append("<option>" + data[i].name + "</option>");
+                                                    }
+
+
+
+                                                }
+
+
+
+                                            });
+
+
+
+
+                                            $.ajax({
+                                                url: '../php/mb_publish_wmc.php',
+                                                type: 'POST',
+                                                data: {
+                                                    wmc_id: id,
+                                                    mode: 'getLicenseMode',
+                                                    license: 'cc-by-nc-nd'
+                                                },
+
+                                                success: function(data) {
+
+                                                    $('#licenseImg').html('<img src="' + data.symbollink + '" />');
+                                                    $('#licenseDescription').html('<a href="' + data.description + '" />' + data.description + '</a>');
+                                                    if (data.isopen == 1) {
+
+                                                        $('#licenseOpen').html('<img src="../img/od_80x15_blue.png" />');
+                                                    }else{
+
+                                                        $('#licenseOpen').html('<span>No OpenData</span>');
+                                                    }
+                                                    // console.log(data['description']);
+
+
+
+                                                }
+
+                                            });
+
+
+                                            $('#licenseTbl select').bind('change', function(event) {
+                                                $('#licenseImg').html('');
+                                                $('#licenseDescription').html('');
+
+                                                $.ajax({
+                                                    url: '../php/mb_publish_wmc.php',
+                                                    type: 'POST',
+                                                    data: {
+                                                        wmc_id: id,
+                                                        mode: 'getLicenseMode',
+                                                        license: $('#licenseTbl select').val()
+                                                    },
+
+                                                    success: function(data) {
+
+                                                        $('#licenseImg').html('<img src="' + data.symbollink + '" />');
+                                                        $('#licenseDescription').html('<a href="' + data.description + '" />' + data.description + '</a>');
+                                                        if (data.isopen == 1) {
+
+                                                            $('#licenseOpen').html('<img src="../img/od_80x15_blue.png" />');
+
+                                                        }else{
+
+                                                            $('#licenseOpen').html('<span>No OpenData</span>');
+                                                        }
+                                                        // console.log(data['description']);
+
+
+
+
+                                                    }
+
+                                                });
+                                            });
+
+                                            $('#submitLicense').bind('click', function(event) {
+                                                //save the license from the choosed wmc
+
+                                                $.ajax({
+                                                    url: '../php/mb_publish_wmc.php',
+                                                    type: 'POST',
+                                                    data: {
+                                                        wmc_id: id,
+                                                        mode: 'saveLicenseMode',
+                                                        license: $('#licenseTbl select').val()
+                                                    },
+
+                                                    success: function(data) {
+
+                                                        $('#chooseLicenseDialog').dialog('destroy');
+                                                        $('#chooseLicenseDialog').remove();
+                                                        $('#mySpatialData').dialog('destroy');
+                                                        $('#mySpatialData').remove();
+                                                        $($addButton).trigger('click');
+
+
+
+
+                                                    }
+
+                                                });
+                                            });
+
+                                        });
+
+                                        $(publishDialog).find('#publishDenied').bind('click', function() {
+                                            $(publishDialog).dialog('close');
+
+
+                                        });
+
+
+                                    });
+
+                                }
+                            });
+                        })
+                        .bind('dblclick', function() {
+                            var id = $($(this).find('td')[0]).text();
+                            $.ajax({
+                                type: 'post',
+                                url: '../php/mb_load_local_data.php',
+                                data: {
+                                    id: id
+                                },
+                                success: function(data) {
+                                    var kml = $('#mapframe1').data('kml');
+                                    $.each(data, function(url, json) {
+                                        kml.addLayer(url, json.data);
+                                    });
+                                    $(dlg).dialog('destroy');
+                                }
+                            });
+                        });
+                }
+            });
+            $('#kml-load-tabs').tabs();
+            $('#kml-load-tabs').find('button.add').bind('click', function() {
+                $('#mapframe1').kml({
+                    url: $('#kml-load-tabs').find('.kmlurl').val()
                 });
-            }
-        });
-        $('#kml-load-tabs').tabs();
-        $('#kml-load-tabs').find('button.add').bind('click', function() {
-            $('#mapframe1').kml({ url: $('#kml-load-tabs').find('.kmlurl').val()});
-            $(dlg).dialog('destroy');
-        });
-        $('#kml-load-tabs').find('button.add-kml').bind('click', function() {
-            var kml = $('#mapframe1').data('kml');
-            var title = $('#kml-load-tabs input[name="kml-new-title"]').val();
-            if(title == '') {
-                return;
-            }
-            kml.addLayer(title, {features: [], type: 'FeatureCollection'});
-            $(dlg).dialog('destroy');
-        });
-        var ifr = $('iframe[name="kml-upload-target"]')[0];
-        var onloadfun = function() {
-            ifr.onload = null;
-            var txt = $(this).contents().find('pre').text();
-            var data;
-            try {
-                data = JSON.parse(txt);
-            } catch(e) {
-                var xml = new DOMParser().parseFromString(txt, 'application/xml');
-                data = toGeoJSON.gpx(xml);
-            }
-            var kml = $('#mapframe1').data('kml');
-            var name = $('#kml-from-upload input[type="file"]').val();
-            if(name.match(/[\\]([^\\]+)/g)) {
-                name = name.match(/[\\]([^\\]+)/g);
-            }
-            name = name[name.length-1];
-            kml.addLayer(name, data);
-            $(dlg).dialog('destroy');
-        };
-        $('#kml-from-upload form').bind('submit', function() {
-            ifr.onload = onloadfun;
-        });
+                $(dlg).dialog('destroy');
+            });
+            $('#kml-load-tabs').find('button.add-kml').bind('click', function() {
+                var kml = $('#mapframe1').data('kml');
+                var title = $('#kml-load-tabs input[name="kml-new-title"]').val();
+                if (title == '') {
+                    return;
+                }
+                kml.addLayer(title, {
+                    features: [],
+                    type: 'FeatureCollection'
+                });
+                $(dlg).dialog('destroy');
+            });
+            var ifr = $('iframe[name="kml-upload-target"]')[0];
+            var onloadfun = function() {
+                ifr.onload = null;
+                var txt = $(this).contents().find('pre').text();
+                var data;
+                try {
+                    data = JSON.parse(txt);
+                } catch (e) {
+                    var xml = new DOMParser().parseFromString(txt, 'application/xml');
+                    data = toGeoJSON.gpx(xml);
+                }
+                var kml = $('#mapframe1').data('kml');
+                var name = $('#kml-from-upload input[type="file"]').val();
+                if (name.match(/[\\]([^\\]+)/g)) {
+                    name = name.match(/[\\]([^\\]+)/g);
+                }
+                name = name[name.length - 1];
+                kml.addLayer(name, data);
+                $(dlg).dialog('destroy');
+            };
+            $('#kml-from-upload form').bind('submit', function() {
+                ifr.onload = onloadfun;
+            });
+
+        }
     });
     $KMLfolder.find('ul').before(selectButton);
     $KMLfolder.find("ul").before($addButton);
@@ -205,35 +499,36 @@
         }
     });
 
-    o.$target.bind('kml:loaded',function(e,obj){
+    o.$target.bind('kml:loaded', function(e, obj) {
         //console.log(obj);
-        var checked = obj.display ? 'checked="checked"':'';
+        var checked = obj.display ? 'checked="checked"' : '';
 
         title = obj.url;
-        if(obj.refreshing) {
+        if (obj.refreshing) {
             $KMLfolder.find('ul li[title="' + title + '"]').remove();
         }
-        abbrevTitle = title.length < 20 ?  title : title.substr(0,17) + "...";
-        $kmlEntry = $('<li title="'+ title +'" class="open"><button class="digitize-menu-arrow"></button><button class="toggle" name="toggle" value="toggle" ></button> <input type="checkbox"'+checked  +'/><a href="#">'+abbrevTitle+'</a></li>');
+        abbrevTitle = title.length < 20 ? title : title.substr(0, 17) + "...";
+        $kmlEntry = $('<li title="' + title + '" class="open"><button class="digitize-menu-arrow"></button><button class="toggle" name="toggle" value="toggle" ></button> <input type="checkbox"' + checked + '/><a href="#">' + abbrevTitle + '</a></li>');
         $KMLfolder.children("ul").append($kmlEntry);
 
-        $kmlEntry.find("a").bind("click",(function(url){return function(){
-                                                            $('#mapframe1').data('kml').zoomToLayer(url);
-                                                        };
-                                                       })(obj.url));
+        $kmlEntry.find("a").bind("click", (function(url) {
+            return function() {
+                $('#mapframe1').data('kml').zoomToLayer(url);
+            };
+        })(obj.url));
 
         $featureList = $("<ul />");
         $kmlEntry.append($featureList);
-        for(var i = obj.data.features.length - 1;i >= 0; --i){
+        for (var i = obj.data.features.length - 1; i >= 0; --i) {
             var multi = obj.data.features[i].geometry.type.match(/^Multi/i);
             var toggle = '';
-            if(multi) {
+            if (multi) {
                 toggle = '<button class="toggle" name="toggle" value="toggle"></button>';
             }
             title = obj.data.features[i].properties.name;
-            abbrevTitle = title.length < 20 ?  title : title.substr(0,17) + "...";
+            abbrevTitle = title.length < 20 ? title : title.substr(0, 17) + "...";
             var displ = obj.data.features[i].display === true || obj.data.features[i].display === undefined;
-            $feature = $('<li idx="' + i + '" title="'+ title +'"><button class="digitize-menu-arrow"></button>' + toggle + '<input type="checkbox" ' + (displ ? 'checked="checked"' : '') + '/><div class="style-preview" style="width: 20px; height: 20px; display: inline;"></div><a href="#" >'+ abbrevTitle + '</a></li>');
+            $feature = $('<li idx="' + i + '" title="' + title + '"><button class="digitize-menu-arrow"></button>' + toggle + '<input type="checkbox" ' + (displ ? 'checked="checked"' : '') + '/><div class="style-preview" style="width: 20px; height: 20px; display: inline;"></div><a href="#" >' + abbrevTitle + '</a></li>');
             $featureList.append($feature);
 
             var preview = $feature.find('.style-preview').get(0);
@@ -241,47 +536,53 @@
 
             title = obj.data.features[i].properties.name;
 
-            $feature.bind('mouseout',(function(jsonFeature){return function(){
-                                                                var map = o.$target.mapbender();
-                                                                var g = new GeometryArray();
-                                                                g.importGeoJSON(jsonFeature,false);
-                                                                var feature = g.get(0);
+            $feature.bind('mouseout', (function(jsonFeature) {
+                return function() {
+                    var map = o.$target.mapbender();
+                    var g = new GeometryArray();
+                    g.importGeoJSON(jsonFeature, false);
+                    var feature = g.get(0);
 
-                                                                if(feature.geomType != "point"){
-                                                                    var me = $kmlTree.mapbender();
-                                                                    me.resultHighlight.clean();
-                                                                    me.resultHighlight.paint();
-                                                                }
-                                                            }})(obj.data.features[i]));
-            $feature.bind('mouseover',(function(jsonFeature){return function(){
-                                                                 var map = o.$target.mapbender();
-                                                                 var g = new GeometryArray();
-                                                                 g.importGeoJSON(jsonFeature,false);
-                                                                 var feature = g.get(0);
+                    if (feature.geomType != "point") {
+                        var me = $kmlTree.mapbender();
+                        me.resultHighlight.clean();
+                        me.resultHighlight.paint();
+                    }
+                }
+            })(obj.data.features[i]));
+            $feature.bind('mouseover', (function(jsonFeature) {
+                return function() {
+                    var map = o.$target.mapbender();
+                    var g = new GeometryArray();
+                    g.importGeoJSON(jsonFeature, false);
+                    var feature = g.get(0);
 
-                                                                 if(feature.geomType != "point"){
-                                                                     var me = $kmlTree.mapbender();
-                                                                     feature = feature.getBBox4();
-                                                                     me.resultHighlight = new Highlight(
-                                                                         [o.target],
-                                                                         "KmlTreeHighlight",
-                                                                         {"position":"absolute", "top":"0px", "left":"0px", "z-index":100},
-                                                                         2);
+                    if (feature.geomType != "point") {
+                        var me = $kmlTree.mapbender();
+                        feature = feature.getBBox4();
+                        me.resultHighlight = new Highlight(
+                            [o.target],
+                            "KmlTreeHighlight", {
+                                "position": "absolute",
+                                "top": "0px",
+                                "left": "0px",
+                                "z-index": 100
+                            },
+                            2);
 
-                                                                     me.resultHighlight.add(feature, "#00ff00");
-                                                                     me.resultHighlight.paint();
-                                                                 }
-                                                                 else if(feature.geomType == "point"){
+                        me.resultHighlight.add(feature, "#00ff00");
+                        me.resultHighlight.paint();
+                    } else if (feature.geomType == "point") {
 
-                                                                 }
+                    }
 
-                                                             };
-                                                            })(obj.data.features[i]));
+                };
+            })(obj.data.features[i]));
         }
 
         $('button.digitize-layer', $kmlEntry).bind('click', function() {
             var active = $(this).toggleClass('active').hasClass('active');
-            if(active) {
+            if (active) {
                 $(this).parent().siblings().find('button.digitize-layer').removeClass('active');
             }
         });
@@ -311,18 +612,18 @@
             }
         });
 
-        $('input[type="checkbox"]', $kmlEntry).bind('click', function(){
+        $('input[type="checkbox"]', $kmlEntry).bind('click', function() {
             var idx = $(this).parent().attr('idx');
 
-            if(idx === undefined) {
-                if($(this).attr('checked')){
-                    o.$target.kml('show',obj.url);
-                }else{
-                    o.$target.kml('hide',obj.url);
+            if (idx === undefined) {
+                if ($(this).attr('checked')) {
+                    o.$target.kml('show', obj.url);
+                } else {
+                    o.$target.kml('hide', obj.url);
                 }
             } else {
                 var kml = $('#mapframe1').data('kml');
-                if($(this).attr('checked')) {
+                if ($(this).attr('checked')) {
                     kml.showFeature(obj.url, idx);
                 } else {
                     kml.hideFeature(obj.url, idx);
@@ -330,11 +631,11 @@
             }
         });
 
-        $("button.toggle",$kmlEntry).bind('click', function(){
-            if($(this).parent().hasClass("open")){
+        $("button.toggle", $kmlEntry).bind('click', function() {
+            if ($(this).parent().hasClass("open")) {
                 $(this).parent().removeClass("open");
                 $(this).parent().addClass("closed");
-            }else{
+            } else {
                 $(this).parent().removeClass("closed");
                 $(this).parent().addClass("open");
             }
@@ -354,6 +655,6 @@
 
 };
 
-Mapbender.events.init.register(function(){
+Mapbender.events.init.register(function() {
     $kmlTree.mapbender(new KmlTree(options));
 });



More information about the Mapbender_commits mailing list