Changeset 12901

Show
Ignore:
Timestamp:
10/19/07 13:54:38 (1 year ago)
Author:
bergie
Message:

Backporting the latest positioning stuff

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/MidCOM_2_8/midcom.core/midcom/services/auth.php

    r12388 r12901  
    23882388    function _load_class_magic_privileges(&$class) 
    23892389    { 
    2390         // Check if we have loaded these privileges already... 
    2391         if (array_key_exists($class->__new_class_name__, $this->_default_magic_class_privileges)) 
     2390        if (!isset($class->__new_class_name__)) 
     2391        { 
     2392            $loadable_class = get_class($class); 
     2393        } 
     2394        else 
     2395        { 
     2396            $loadable_class = $class->__new_class_name__; 
     2397        } 
     2398 
     2399        // Check if we have loaded these privileges already...         
     2400        if (array_key_exists($loadable_class, $this->_default_magic_class_privileges)) 
    23922401        { 
    23932402            return; 
    23942403        } 
    23952404 
     2405        if (!method_exists($class, 'get_class_magic_default_privileges')) 
     2406        { 
     2407            $this->_default_magic_class_privileges[$loadable_class] = array 
     2408            ( 
     2409                'EVERYONE' => array(), 
     2410                'ANONYMOUS' => array(), 
     2411                'USERS' => array() 
     2412            ); 
     2413            return; 
     2414        } 
     2415         
    23962416        $privs = $class->get_class_magic_default_privileges(); 
    2397         $this->_default_magic_class_privileges[$class->__new_class_name__] = $privs; 
     2417        $this->_default_magic_class_privileges[$loadable_class] = $privs; 
    23982418 
    23992419        return; 
  • branches/MidCOM_2_8/midcom.core/package-template.xml

    r12889 r12901  
    3131    <time>19:10:53</time> 
    3232    <version> 
    33         <release>2.8.0beta6</release> 
     33        <release>2.8.0beta7</release> 
    3434        <api>2.8.0</api> 
    3535    </version> 
  • branches/MidCOM_2_8/midcom.helper.datamanager2/config/manifest.inc

    r12889 r12901  
    11'name' => 'midcom.helper.datamanager2', 
    2 'version' => '1.0.4beta6', 
     2'version' => '1.0.4beta8', 
    33'state' => 'beta', 
    44'purecode' => true, 
  • branches/MidCOM_2_8/midcom.helper.datamanager2/static/position/position_widget.css

    r12271 r12901  
    44} 
    55 
    6 .position_widget_tab_content_place .geodata_btn 
     6.position_widget_tab_content .geodata_btn 
    77{ 
    88    margin-right: 5px; 
     
    1414} 
    1515 
    16 .position_widget_tab_content_place .indicator 
     16.position_widget_tab_content .indicator 
    1717{ 
    1818    margin-right: 5px; 
     
    2222    background: url('../ajax-loading-small.gif'); 
    2323} 
     24 
     25.position_widget_actions 
     26{ 
     27    margin-bottom: 10px; 
     28} 
     29.position_widget_actions div 
     30{ 
     31    font-weight: bold; 
     32    cursor: pointer; 
     33} 
  • branches/MidCOM_2_8/midcom.helper.datamanager2/static/position/widget.js

    r12271 r12901  
    1 var widgets = []; 
    2 var current_pos = null; 
    3 var position_marker = null; 
    4 var widgets_mapstrations = []; 
    5  
    6 function init_position_widget(widget_id, mapstration) 
    7 {    
    8     jQuery('#' + widget_id).each(function(i,w){ 
    9         var widget = jQuery(w); 
    10  
    11         widgets[w.id] = widget; 
    12  
    13         var geodata_btn = jQuery('#' + widget_id + '_geodata_btn', widget); 
    14         var indicator = jQuery('#' + widget_id + '_indicator', widget); 
    15         var status_box = jQuery('#' + widget_id + '_status_box', widget); 
    16  
    17         var backend_url = jQuery('input.position_widget_backend_url',widget).attr('value'); 
    18         var backend_service = jQuery('input.position_widget_backend_service',widget).attr('value'); 
    19          
    20         var input_data = {}; 
     1jQuery.fn.extend({ 
     2        dm2_position_widget: function(mapstraction, options) { 
     3                options = jQuery.extend(jQuery.midcom_helper_datamanager2_widget_position.defaults, options); 
     4        return this.each(function() { 
     5                    return new jQuery.midcom_helper_datamanager2_widget_position(this, mapstraction, options); 
     6        }); 
     7        }, 
     8        dm2_pw_new_position: function(point) { 
     9                return this.trigger("new_position",[point]); 
     10        }, 
     11        dm2_pw_clear_alternative_markers: function() { 
     12                return this.trigger("clear_alternative_markers",[]); 
     13        }, 
     14        dm2_pw_set_marker: function(label, info) { 
     15                return this.trigger("set_marker",[label, info]); 
     16        }, 
     17        dm2_pw_init_current_pos: function(lat, lon) 
     18        { 
     19            return this.trigger("init_current_pos",[lat, lon]); 
     20        }, 
     21        dm2_pw_position_map_to_current: function() { 
     22                return this.trigger("position_map_to_current",[]); 
     23        } 
     24}); 
     25 
     26jQuery.midcom_helper_datamanager2_widget_position = function(widget_block, mapstraction, options) { 
     27     
     28    var widget = jQuery(widget_block); 
     29    var widget_id = widget.attr('id'); 
     30 
     31    mapstraction.addMapTypeControls(); 
     32    mapstraction.addEventListener('click', new_position); 
     33     
     34    var geodata_btn = jQuery('#' + widget_id + '_geodata_btn', widget); 
     35    var indicator = jQuery('#' + widget_id + '_indicator', widget); 
     36     
     37    var revgeodata_btn = jQuery('#' + widget_id + '_revgeodata_btn', widget); 
     38    var revindicator = jQuery('#' + widget_id + '_revindicator', widget); 
     39     
     40    var actions_cam = jQuery('#' + widget_id + '_position_widget_action_cam', widget); 
     41     
     42    var status_box = jQuery('#' + widget_id + '_status_box', widget); 
     43 
     44    var current_pos_icon_url = MIDCOM_STATIC_URL + '/midcom.helper.datamanager2/position/current_position_marker.png' 
     45    var backend_url = jQuery('input.position_widget_backend_url',widget).attr('value'); 
     46    var backend_service = jQuery('input.position_widget_backend_service',widget).attr('value');         
     47    var input_data = {}; 
     48    var current_pos = null; 
     49    var position_marker = null; 
     50    var alternative_markers = null; 
     51    var alternative_markers_visible = true; 
     52         
     53    widget.bind("new_position", function(event, point){ 
     54        new_position(point); 
     55        }).bind("clear_alternative_markers", function(event, point){ 
     56        clear_alternative_markers(); 
     57    }).bind("set_marker", function(event, label, info){ 
     58        set_marker(label, info); 
     59    }).bind("init_current_pos", function(event, lat, lon){ 
     60        init_current_pos(lat, lon); 
     61    }).bind("position_map_to_current", function(event){ 
     62        position_map_to_current(); 
     63    }); 
     64     
     65    indicator.hide(); 
     66    revindicator.hide(); 
     67     
     68    geodata_btn.bind('click', function(e){ 
     69        refresh_geodata(); 
     70        geodata_btn.hide(); 
     71        indicator.show(); 
     72    }); 
     73    revgeodata_btn.bind('click', function(e){ 
     74        var lat = jQuery('#' + input_data['latitude']['id']).attr('value'); 
     75        var lon = jQuery('#' + input_data['longitude']['id']).attr('value'); 
     76         
     77        new_position(new LatLonPoint(lat,lon)); 
     78         
     79        revgeodata_btn.hide(); 
     80        revindicator.show(); 
     81    }); 
     82 
     83    actions_cam.bind('click', function(e){ 
     84        clear_alternative_markers(); 
     85    }); 
     86         
     87        jQuery('.position_widget_input',widget).each(function(i, o){ 
     88        var jqo = jQuery(o); 
     89        var key = get_key_name(jqo.attr('name')); 
     90        input_data[key] = { 
     91            id: jqo.attr('id'), 
     92            value: jqo.attr('value') 
     93        }; 
     94 
     95        if (input_data[key]['value'] == undefined) 
     96        { 
     97            input_data[key]['value'] = ''; 
     98        } 
     99    }); 
     100     
     101    function disable_tabs() 
     102    { 
     103        widget.disableTab(1); 
     104        widget.disableTab(2); 
     105        widget.disableTab(3); 
     106    } 
     107    function enable_tabs() 
     108    { 
     109        widget.enableTab(1); 
     110        widget.enableTab(2); 
     111        widget.enableTab(3); 
     112    } 
     113     
     114    function new_position(point) 
     115    { 
     116        current_pos = point; 
     117         
     118        jQuery('#' + input_data['latitude']['id']).attr('value', current_pos.lat); 
     119        jQuery('#' + input_data['longitude']['id']).attr('value', current_pos.lon); 
     120         
     121        set_marker('Current position', ''); 
     122        get_reversed_geodata(); 
     123    } 
     124     
     125    function get_reversed_geodata() 
     126    { 
     127        disable_tabs(); 
     128        clear_alternative_markers(); 
     129         
     130        var opts_str = '?'; 
     131        jQuery.each(options, function(key,value){ 
     132            opts_str += 'options[' + key + ']=' + value + '&'; 
     133        }); 
     134         
     135        opts_str = opts_str.substr(0,opts_str.length-1); 
     136         
     137        var get_params = { 
     138            service: backend_service, 
     139            dir: 'reverse', 
     140            latitude: current_pos.lat, 
     141            longitude: current_pos.lon 
     142        }; 
     143         
     144        jQuery.ajax({ 
     145            type: "GET", 
     146            url: backend_url + opts_str, 
     147            data: get_params, 
     148            dataType: "xml", 
     149            error: function(request, type, expobj){ 
     150                parse_error(request.responseText); 
     151            }, 
     152            success: function(data){ 
     153                var parsed = parse_response(data); 
     154                update_widget_inputs(parsed[0], true); 
     155                handle_alternatives(parsed); 
     156            } 
     157        }); 
     158         
     159        function parse_error(error_string) 
     160        { 
     161            indicator.hide(); 
     162            revindicator.hide(); 
     163            geodata_btn.show(); 
     164            revgeodata_btn.show(); 
     165            enable_tabs(); 
     166             
     167            status_box.html(error_string); 
     168        } 
     169 
     170        function parse_response(data) 
     171        { 
     172            status_box.html(''); 
     173             
     174            var results = []; 
     175            jQuery('position',data).each(function(idx) {             
     176                var rel_this = jQuery(this); 
     177 
     178                results[idx] = { 
     179                    latitude: rel_this.find("latitude").text(), 
     180                    longitude: rel_this.find("longitude").text(), 
     181                    distance: { 
     182                        meters: rel_this.find("distance").find("meters").text(), 
     183                        bearing: rel_this.find("distance").find("bearing").text() 
     184                    }, 
     185                    city: rel_this.find("city").text(), 
     186                    region: rel_this.find("region").text(), 
     187                    country: rel_this.find("country").text(), 
     188                    alternate_names: rel_this.find("alternate_names").text(), 
     189                    accuracy: rel_this.find("accuracy").text() 
     190                }; 
     191            }); 
     192 
     193                return results; 
     194        } 
     195    } 
     196     
     197    function refresh_geodata() 
     198    { 
     199        disable_tabs(); 
     200        clear_alternative_markers(); 
     201 
     202        var opts_str = '?'; 
     203        jQuery.each(options, function(key,value){ 
     204            opts_str += 'options[' + key + ']=' + value + '&'; 
     205        }); 
     206         
     207        opts_str = opts_str.substr(0,opts_str.length-1); 
     208         
     209        var get_params = { 
     210            service: backend_service, 
     211        }; 
    21212 
    22213        jQuery('.position_widget_input',widget).each(function(i, o){ 
     
    32223                input_data[key]['value'] = ''; 
    33224            } 
    34         }); 
    35  
    36         widgets_mapstrations[widget_id] = mapstration; 
    37         widgets_mapstrations[widget_id].addMapTypeControls(); 
    38         widgets_mapstrations[widget_id].addEventListener('click', new_position); 
    39          
    40         function new_position(point) 
    41         { 
    42             current_pos = point; 
     225            else 
     226            { 
     227                get_params[key] = input_data[key]['value']; 
     228            } 
     229        }); 
     230 
     231        jQuery.ajax({ 
     232            type: "GET", 
     233            url: backend_url + opts_str, 
     234            data: get_params, 
     235            dataType: "xml", 
     236            error: function(request, type, expobj){ 
     237                parse_error(request.responseText); 
     238            }, 
     239            success: function(data){ 
     240                var parsed = parse_response(data); 
     241                update_widget(parsed[0]); 
     242                handle_alternatives(parsed); 
     243            } 
     244        }); 
     245 
     246        function parse_error(error_string) 
     247        { 
     248            indicator.hide(); 
     249            revindicator.hide(); 
     250            geodata_btn.show(); 
     251            revgeodata_btn.show(); 
     252            enable_tabs(); 
    43253             
    44             jQuery('#' + input_data['latitude']['id']).attr('value',current_pos.lat); 
    45             jQuery('#' + input_data['longitude']['id']).attr('value',current_pos.lon); 
    46              
    47             set_marker('Current position','',widget_id); 
    48             get_reversed_geodata(); 
    49         } 
    50  
     254            status_box.html(error_string); 
     255        } 
     256 
     257        function parse_response(data) 
     258        { 
     259            status_box.html(''); 
     260             
     261            var results = []; 
     262            jQuery('position',data).each(function(idx) {             
     263                var rel_this = jQuery(this); 
     264 
     265                results[idx] = {             
     266                    latitude: rel_this.find("latitude").text(),  
     267                    longitude: rel_this.find("longitude").text(), 
     268                    distance: { 
     269                        meters: rel_this.find("distance").find("meters").text(), 
     270                        bearing: rel_this.find("distance").find("bearing").text() 
     271                    }, 
     272                    accuracy: rel_this.find("accuracy").text(), 
     273                    city: rel_this.find("city").text(), 
     274                    region: rel_this.find("region").text(), 
     275                    country: rel_this.find("country").text(), 
     276                    alternate_names: rel_this.find("alternate_names").text(), 
     277                    postalcode: rel_this.find("postalcode").text() 
     278                }; 
     279            }); 
     280 
     281                return results; 
     282        } 
     283    } 
     284     
     285    function update_widget(location_data) 
     286    { 
     287        update_widget_inputs(location_data); 
     288 
     289        current_pos = new LatLonPoint(location_data['latitude'],location_data['longitude']); 
     290 
     291        var info = location_data['city'] + ", " + location_data['country'] + ", " + location_data['postalcode']; 
     292        var label = 'Current position'; 
     293        if (input_data['description']) 
     294        { 
     295            label = input_data['description']; 
     296        } 
     297        else if (location_data['description']) 
     298        { 
     299            label = location_data['description']; 
     300        } 
     301         
     302        set_marker(label, info); 
     303    } 
     304     
     305    function update_widget_inputs(location_data, skip_lat_lon) 
     306    { 
     307        if (skip_lat_lon == undefined) 
     308        { 
     309            var skip_lat_lon = false; 
     310        } 
     311         
     312        enable_tabs(); 
    51313        indicator.hide(); 
    52  
    53         geodata_btn.bind('click', function(e){ 
    54             refresh_geodata(); 
    55             geodata_btn.hide(); 
    56             indicator.show(); 
    57         }); 
    58          
    59         function get_reversed_geodata() 
    60         { 
    61             var get_params = { 
    62                 service: backend_service, 
    63                 dir: 'reverse', 
    64                 latitude: current_pos.lat, 
    65                 longitude: current_pos.lon 
    66             }; 
    67              
    68             jQuery.ajax({ 
    69                 type: "GET", 
    70                 url: backend_url, 
    71                 data: get_params, 
    72                 dataType: "xml", 
    73                 error: function(request, type, expobj){ 
    74                     parse_error(request.responseText); 
    75                 }, 
    76                 success: function(data){ 
    77                     var parsed = parse_response(data); 
    78                     update_widget_inputs(parsed); 
    79                 } 
    80             }); 
    81              
    82             function parse_error(error_string) 
    83                 { 
    84                 indicator.hide(); 
    85                 geodata_btn.show(); 
    86                  
    87                 status_box.html(error_string); 
    88                 } 
    89  
    90             function parse_response(data) 
    91                 { 
    92                     status_box.html(''); 
    93                      
    94                 var results = []; 
    95                 jQuery('position',data).each(function(idx) {             
    96                     var rel_this = jQuery(this); 
    97  
    98                     results[idx] = { 
    99                         accuracy: rel_this.find("accuracy").text(), 
    100                         city: rel_this.find("city").text(), 
    101                         region: rel_this.find("region").text(), 
    102                         country: rel_this.find("country").text(), 
    103                         accuracy: rel_this.find("accuracy").text() 
    104                     }; 
    105                 }); 
    106  
    107                 return results[0]; 
    108                 } 
    109         } 
    110          
    111         function refresh_geodata() 
    112         { 
    113             var get_params = { 
    114                 service: backend_service 
    115             }; 
    116  
    117             jQuery('.position_widget_input',widget).each(function(i, o){ 
    118                 var jqo = jQuery(o); 
    119                 var key = get_key_name(jqo.attr('name')); 
    120                 input_data[key] = { 
    121                     id: jqo.attr('id'), 
    122                     value: jqo.attr('value') 
    123                 }; 
    124  
    125                 if (input_data[key]['value'] == undefined) 
     314        revindicator.hide(); 
     315        geodata_btn.show(); 
     316        revgeodata_btn.show(); 
     317                     
     318        jQuery.each(location_data, function(key,value){ 
     319            if (input_data[key]) 
     320            { 
     321                if (skip_lat_lon) 
    126322                { 
    127                     input_data[key]['value'] = ''; 
     323                    if (   key != 'latitude' 
     324                        && key != 'longitude') 
     325                    { 
     326                        jQuery('#' + input_data[key]['id']).attr('value',value);                     
     327                    }                     
    128328                } 
    129329                else 
    130330                { 
    131                     get_params[key] = input_data[key]['value']; 
    132                 } 
    133             }); 
    134  
    135             // jQuery.each(input_data, function(i,o){ 
    136             //     if (o['value'] != '') 
    137             //     { 
    138             //         get_params[i] = o['value']; 
    139             //     } 
    140             // }); 
    141  
    142             jQuery.ajax({ 
    143                 type: "GET", 
    144                 url: backend_url, 
    145                 data: get_params, 
    146                 dataType: "xml", 
    147                 error: function(request, type, expobj){ 
    148                     parse_error(request.responseText); 
    149                 }, 
    150                 success: function(data){ 
    151                     var parsed = parse_response(data); 
    152                     update_widget(parsed); 
    153                 } 
    154             }); 
    155  
    156             function parse_error(error_string) 
    157                 { 
    158                 indicator.hide(); 
    159                 geodata_btn.show(); 
    160                  
    161                 status_box.html(error_string); 
    162                 } 
    163  
    164             function parse_response(data) 
    165                 { 
    166                     status_box.html(''); 
    167                      
    168                 var results = []; 
    169                 jQuery('position',data).each(function(idx) {             
    170                     var rel_this = jQuery(this); 
    171  
    172                     results[idx] = {                 
    173                         latitude: rel_this.find("latitude").text(),  
    174                         longitude: rel_this.find("longitude").text(), 
    175                         accuracy: rel_this.find("accuracy").text(), 
    176                         city: rel_this.find("city").text(), 
    177                         region: rel_this.find("region").text(), 
    178                         country: rel_this.find("country").text(), 
    179                         postalcode: rel_this.find("postalcode").text() 
    180                     }; 
    181                 }); 
    182  
    183                 return results[0]; 
    184                 } 
    185         } 
    186  
    187         function update_widget(location_data) 
    188         { 
    189             indicator.hide(); 
    190             geodata_btn.show(); 
    191  
    192             update_widget_inputs(location_data); 
    193  
    194             current_pos = new LatLonPoint(location_data['latitude'],location_data['longitude']); 
    195  
    196             var info = location_data['city'] + ", " + location_data['country'] + ", " + location_data['postalcode']; 
    197             var label = 'Current position'; 
    198             if (input_data['description']) 
    199             { 
    200                 label = input_data['description']; 
    201             } 
    202             else if (location_data['description']) 
    203             { 
    204                 label = location_data['description']; 
    205             } 
    206              
    207             set_marker(label, info, widget_id); 
    208         } 
    209          
    210         function update_widget_inputs(location_data) 
    211         { 
    212             jQuery.each(location_data, function(key,value){ 
    213                 if (input_data[key]) 
    214                 { 
    215331                    jQuery('#' + input_data[key]['id']).attr('value',value); 
    216332                } 
    217                 else 
     333            } 
     334        }); 
     335    } 
     336 
     337    function get_key_name(key) 
     338    { 
     339        var re = /widget_([a-z]*)_([a-z]{5,11})_([a-z]*)/; 
     340        var reg = re.exec(key); 
     341         
     342        return reg[3]; 
     343    } 
     344     
     345    function handle_alternatives(items) 
     346    { 
     347        var total = items.length; 
     348        for (var i=1; i<total; i++) 
     349        {                
     350            var point = new LatLonPoint(items[i]['latitude'],items[i]['longitude']); 
     351            var info = items[i]['city'] + ", " + items[i]['country'] + ", " + items[i]['postalcode']; 
     352            set_alternative_marker('Alternative position', info, point); 
     353        } 
     354    } 
     355     
     356    function init_current_pos(lat, lon) 
     357    { 
     358        current_pos = new LatLonPoint(lat,lon); 
     359        set_marker('Current position', ''); 
     360    } 
     361 
     362    function set_marker(label, info) 
     363    { 
     364        if (position_marker != null) 
     365        { 
     366             mapstraction.removeMarker(position_marker); 
     367        } 
     368 
     369        position_marker = new Marker(current_pos); 
     370        position_marker.setIcon(current_pos_icon_url); 
     371         
     372        //position_marker.draggable = true; 
     373        //position_marker.draggable_end_event = function(marker){var p = marker.getPoint(); alert(p.lat);}; 
     374        //position_marker.addEventListener('dragend', function(){alert('drop');}); 
     375        // jQuery.extend(this, function(){ 
     376        //             var point = position_marker.getPoint(); 
     377        //             dm2_pw_new_position(point); 
     378        //         }); 
     379 
     380        if (label != undefined) 
     381        { 
     382            position_marker.setLabel(label);                 
     383        } 
     384 
     385        if (   info != undefined 
     386            && info != '') 
     387        { 
     388            position_marker.setInfoBubble(info); 
     389        } 
     390 
     391        mapstraction.addMarker(position_marker); 
     392 
     393        // if (info != undefined) 
     394        // { 
     395        //     position_marker[widget_id].openBubble(); 
     396        // } 
     397    } 
     398 
     399    function set_alternative_marker(label, info, pos) 
     400    { 
     401        if (! alternative_markers) 
     402        { 
     403            alternative_markers = []; 
     404        } 
     405 
     406        var last_key = alternative_markers.push( new Marker(pos) ); 
     407 
     408        if (label != undefined) 
     409        { 
     410            alternative_markers[last_key-1].setLabel(label);                 
     411        } 
     412 
     413        if (   info != undefined 
     414            && info != '') 
     415        { 
     416            alternative_markers[last_key-1].setInfoBubble(info); 
     417        } 
     418 
     419        mapstraction.addMarker(alternative_markers[last_key-1]); 
     420 
     421        // if (info != undefined) 
     422        // { 
     423        //     alternative_markers[widget_id][last_key-1].openBubble(); 
     424        // } 
     425    } 
     426 
     427    function clear_alternative_markers() 
     428    { 
     429        if (   alternative_markers 
     430            && alternative_markers.length > 0) 
     431        { 
     432            var length = alternative_markers.length; 
     433            for (var i=0; i<length; i++) 
     434            { 
     435                mapstraction.removeMarker(alternative_markers[i]); 
     436            } 
     437        } 
     438    } 
     439 
     440    function toggle_alternative_markers() 
     441    { 
     442        if (! alternative_markers_visible) 
     443        { 
     444            alternative_markers_visible = true; 
     445 
     446            if (   alternative_markers 
     447                && alternative_markers.length > 0) 
     448            { 
     449                var length = alternative_markers.length; 
     450                for (var i=0; i<length; i++) 
    218451                { 
    219                     //console.log("Key: "+key+" not found in items."); 
     452                    alternative_markers[i].show(); 
    220453                } 
    221             }); 
    222         } 
    223  
    224         function get_key_name(key) 
    225         { 
    226             //var re = /^\s*(\s*)_(\w{5,11})_(\s*)$/; 
    227             var re = /widget_([a-z]*)_([a-z]{5,11})_([a-z]*)/; 
    228             var reg = re.exec(key); 
    229             // console.log("Reg: "+reg); 
    230             // console.log("Reg.length: "+reg.length); 
    231             // console.log("Reg[0]: "+reg[0]+" Reg[1]: "+reg[1]+" Reg[2]: "+reg[2]); 
    232              
    233             return reg[3]; 
    234         } 
    235  
    236     }); 
    237 
    238  
    239 function init_current_pos(widget_id,lat,lon) 
    240 
    241     current_pos = new LatLonPoint(lat,lon); 
    242     set_marker('Current position','',widget_id); 
    243 
    244  
    245 function set_marker(label, info, widget_id) 
    246 
    247     // console.log("set_marker label: "+label+" info: "+info+" widget_id: "+widget_id); 
    248      
    249     if (position_marker != null) 
    250     { 
    251          widgets_mapstrations[widget_id].removeMarker(position_marker); 
    252     } 
    253      
    254     position_marker = new Marker(current_pos); 
    255      
    256     if (label != undefined) 
    257     { 
    258         position_marker.setLabel(label);                 
    259     } 
    260      
    261     if (   info != undefined 
    262         && info != '') 
    263     { 
    264         position_marker.setInfoBubble(info); 
    265     } 
    266      
    267     widgets_mapstrations[widget_id].addMarker(position_marker); 
    268  
    269     // if (info != undefined) 
    270     // { 
    271     //     position_marker.openBubble(); 
    272     // } 
    273 
    274  
    275 function position_map_to_current(widget_id) 
    276 
    277     //console.log("position_map_to_current widget_id: "+widget_id); 
    278     //console.log("current_pos: "+current_pos); 
    279      
    280     if (current_pos != null) 
    281     { 
    282         widgets_mapstrations[widget_id].resizeTo(400,280); 
    283         widgets_mapstrations[widget_id].setCenterAndZoom(current_pos, 13); 
    284         widgets_mapstrations[widget_id].resizeTo(420,300); 
    285     } 
    286 
     454            } 
     455        } 
     456        else 
     457        { 
     458            alternative_markers_visible = false; 
     459 
     460            if (   alternative_markers 
     461                && alternative_markers.length > 0) 
     462            { 
     463                var length = alternative_markers.length; 
     464                for (var i=0; i<length; i++) 
     465                { 
     466                    alternative_markers[i].hide(); 
     467                } 
     468            } 
     469        } 
     470    } 
     471 
     472    function position_map_to_current() 
     473    { 
     474        if (current_pos != null) 
     475        { 
     476            mapstraction.resizeTo(400,280); 
     477            mapstraction.setCenterAndZoom(current_pos, 13); 
     478            mapstraction.resizeTo(420,300); 
     479        } 
     480    }     
     481     
     482}; 
     483 
     484jQuery.midcom_helper_datamanager2_widget_position.defaults = { 
     485    maxRows: 20, 
     486    radius: 5 
     487}; 
  • branches/MidCOM_2_8/midcom.helper.datamanager2/widget/position.php

    r12271 r12901  
    3535 */ 
    3636 
    37 class midcom_helper_datamanager2_widget_position extends midcom_helper_datamanager2_widget_simpleposition 
     37class midcom_helper_datamanager2_widget_position extends midcom_helper_datamanager2_widget 
    3838{ 
    3939    /** 
     
    5454     */ 
    5555    var $enabled_methods = null; 
     56     
     57    /** 
     58     * The service backend to use for searches. Defaults to geonames 
     59     */ 
     60    var $service = null; 
    5661 
    5762    /** 
     
    5964     */ 
    6065    var $_widget_elements = array(); 
    61  
    62     var $_main_group = array(); 
    63      
    64     var $service = null; 
    65      
    66     var $_countrylist = array(); 
    67      
     66    var $_main_group = array();     
     67    var $_countrylist = array();     
    6868    var $_other_xep_keys = array(); 
     69     
     70    /** 
     71     * Options to pass to the javascript widget. 
     72     * Possible values: 
     73     * - (int) maxRows : Maximum amount of results returned. If this is set greater than 1, 
     74     *   the widget will show alternative results and lets user to choose the best match. 
     75     *   Defaults to: 20 
     76     * - (int) radius : Radius of the area we search for alternatives. (in Kilometers) 
     77     *   Defaults to: 5 
     78     */ 
     79      
     80    var $js_maxRows = null; 
     81    var $js_radius = null; 
     82     
     83    var $js_options = array(); 
     84    var $js_options_str = ''; 
    6985     
    7086    /** 
     
    7591    function _on_initialize() 
    7692    { 
     93        if (version_compare(phpversion(), "5.0.0", "<")) 
     94        { 
     95            debug_push_class(__CLASS__, __FUNCTION__); 
     96            debug_add("The position widget used on field {$this->name} currently requires PHP5.", 
     97                MIDCOM_LOG_ERROR); 
     98            debug_pop(); 
     99        } 
     100         
    77101        if (is_a('midcom_helper_datamanager2_type_position', $this->_type)) 
    78102        { 
     
    81105                MIDCOM_LOG_WARN); 
    82106            debug_pop(); 
    83             //return false; 
     107            return false; 
    84108        } 
    85109         
     
    134158            fxSpeed: 'fast', 
    135159            onShow: function() { 
    136                 position_map_to_current('{$this->_element_id}'); 
     160                //dm2_pw_position_map_to_current('{$this->_element_id}'); 
     161                jQuery('#{$this->_element_id}').dm2_pw_position_map_to_current(); 
    137162            } 
    138163        }"; 
     
    142167         
    143168        $this->_get_country_list(); 
     169        $this->_init_widgets_js_options(); 
    144170         
    145171        $this->_other_xep_keys = array( 
     
    216242    function _add_place_method_elements() 
    217243    { 
    218         $html = "\n<div id=\"{$this->_element_id}_tab_content_place\" class=\"position_widget_tab_content_place\"><!-- tab_content_place starts -->\n";         
     244        $html = "\n<div id=\"{$this->_element_id}_tab_content_place\" class=\"position_widget_tab_content position_widget_tab_content_place\"><!-- tab_content_place starts -->\n";         
    219245         
    220246        $html .= "<div class=\"geodata_btn\" id='{$this->_element_id}_geodata_btn'></div>"; 
     
    246272        $html .= "</label>"; 
    247273         
     274        $html .= "<label for='{$this->_element_id}_input_place_region' id='{$this->_element_id}_input_place_region_label'>"; 
     275        $html .= "<span class=\"field_text\">" . $_MIDCOM->i18n->get_string('region', 'org.routamc.positioning') . "</span>";         
     276        $html .= "<input size=\"40\" class=\"shorttext position_widget_input position_widget_input_place_region\" id=\"{$this->_element_id}_input_place_region\" name=\"{$this->_element_id}_input_place_region\" type=\"text\" value=\"{$this->_type->location->region}\" />"; 
     277        $html .= "</label>"; 
     278         
    248279        $html .= "<label for='{$this->_element_id}_input_place_street' id='{$this->_element_id}_input_place_street_label'>"; 
    249280        $html .= "<span class=\"field_text\">" . $_MIDCOM->i18n->get_string('street', 'org.routamc.positioning') . "</span>";         
     
    278309            $html 
    279310        ); 
    280          
    281         // $this->_widget_elements[] =& HTML_QuickForm::createElement 
    282         // ( 
    283         //     'text', 
    284         //     "{$this->_element_id}_input_place_name", 
    285         //     $_MIDCOM->i18n->get_string('name', 'org.routamc.positioning'), 
    286         //     array 
    287         //     ( 
    288         //         'class'         => 'shorttext position_widget_input_place_name', 
    289         //         'id'            => "{$this->_element_id}_input_place_name", 
    290         //     ) 
    291         // ); 
    292         //  
    293         // $this->_widget_elements[] =& HTML_QuickForm::createElement 
    294         // ( 
    295         //     'text', 
    296         //     "{$this->_element_id}_input_place_country", 
    297         //     $_MIDCOM->i18n->get_string('country', 'org.routamc.positioning'), 
    298         //     array 
    299         //     ( 
    300         //         'class'         => '