Changeset 2870
- Timestamp:
- 01/12/11 17:30:28 (13 years ago)
- Location:
- plugins/myGmaps/branches
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/myGmaps/branches/inc/lib.my.gmaps.ui.php
r2868 r2870 3 3 class adminMyGmapsList extends adminGenericList 4 4 { 5 public function display($page,$nb_per_page,$ enclose_block='')5 public function display($page,$nb_per_page,$p_url,$enclose_block='') 6 6 { 7 7 if ($this->rs->isEmpty()) … … 38 38 while ($this->rs->fetch()) 39 39 { 40 echo $this->postLine( );40 echo $this->postLine($p_url); 41 41 } 42 42 … … 47 47 } 48 48 49 private function postLine( )49 private function postLine($p_url) 50 50 { 51 51 if ($this->core->auth->check('categories',$this->core->blog->id)) { … … 54 54 $cat_link = '%2$s'; 55 55 } 56 $p_url = 'plugin.php?p='.basename(dirname(__FILE__));57 56 $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; 58 57 switch ($this->rs->post_status) { … … 80 79 '<td class="nowrap">'. 81 80 form::checkbox(array('entries[]'),$this->rs->post_id,'','','',!$this->rs->isEditable()).'</td>'. 82 '<td class="maximal"><a href="'.$p_url.'& do=edit&id='.$this->rs->post_id.'">'.81 '<td class="maximal"><a href="'.$p_url.'&go=map&id='.$this->rs->post_id.'">'. 83 82 html::escapeHTML($this->rs->post_title).'</a></td>'. 84 83 '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt).'</td>'. -
plugins/myGmaps/branches/js/_map.js
r2868 r2870 49 49 myGmaps.scrollwheel = $('input[name=scrollwheel]').val() == '1' ? true : false; 50 50 } 51 if ($('input[name=map_type]').val() != '') { 52 myGmaps.type = $('input[name=map_type]').val(); 53 } 54 if ($('input[name=elt_type]').val() != '') { 55 myGmaps.elt_type = $('input[name=elt_type]').val(); 56 } 57 if (myGmaps.elt_type == 'polyline') { 58 myGmaps.options[myGmaps.elt_type].strokeWeight = $('input[name=stroke_weight]').val(); 59 myGmaps.options[myGmaps.elt_type].strokeOpacity = $('input[name=stroke_opacity]').val(); 60 myGmaps.options[myGmaps.elt_type].strokeColor = $('input[name=stroke_color]').val(); 61 } 62 if (myGmaps.elt_type == 'polygon') { 63 myGmaps.options[myGmaps.elt_type].strokeWeight = $('input[name=stroke_weight]').val(); 64 myGmaps.options[myGmaps.elt_type].strokeOpacity = $('input[name=stroke_opacity]').val(); 65 myGmaps.options[myGmaps.elt_type].strokeColor = $('input[name=stroke_color]').val(); 66 myGmaps.options[myGmaps.elt_type].strokeWeight = $('input[name=stroke_weight]').val(); 67 } 68 51 69 myGmaps.init(); 52 myGmaps. updDetails();70 myGmaps.loadData(); 53 71 54 72 // Events … … 57 75 $('li#none,li#marker,li#polyline,li#polygon').click(function() { 58 76 myGmaps.startDraw($(this).attr('id')); 77 59 78 }); 60 79 $('input[name=reset]').click(function () { … … 72 91 }); 73 92 $('#entry-form').submit(function () { 74 var post_maps = $('#post_maps').val();75 if (post_maps == '') {76 $('#post_maps').val('none');77 }78 93 var content = $("textarea[name=post_content]").val(); 79 94 if (content == '') { 80 95 $("textarea[name=post_content]").val('Pas de description'); 81 96 } 82 setConfig(); return false; 83 var center = map.getCenter().lat()+','+map.getCenter().lng(); 84 var zoom = map.getZoom(); 85 var map_type = map.getMapTypeId(); 86 var elt_type = type == 'hand' ? 'none' : type; 87 88 $('input[name=center]').val(center); 89 $('input[name=zoom]').val(zoom); 90 $('input[name=map_type]').val(map_type); 91 $('input[name=elt_type]').val(elt_type); 92 93 var list = []; 94 var icon = ''; 95 for (i in markers) { 96 if (is_url(markers[i])) { 97 list.push(markers[i]); 98 } 99 else { 100 list.push(markers[i].getPosition().lat() + "|" + markers[i].getPosition().lng() + "|" + icon); 101 } 102 } 103 $('#post_excerpt').val(list.join('\n')); 97 myGmaps.setMapPoints(); 104 98 return true; 105 99 }); -
plugins/myGmaps/branches/js/myGmaps.js
r2869 r2870 21 21 polygon: null 22 22 }, 23 options: { 24 polyline: { 25 strokeColor: '#000000', 26 strokeWeight: 3, 27 strokeOpacity: 0.5 28 }, 29 polygon: { 30 fillColor: '#5555FF', 31 strokeColor: '#000000', 32 strokeWeight: 3, 33 strokeOpacity: 0.5 34 } 35 }, 23 36 infowindow: null, 24 37 msg: {}, … … 34 47 myGmaps.path.polygon = new google.maps.MVCArray; 35 48 // Init objects 36 myGmaps.objects.polyline = new google.maps.Polyline({ 37 strokeColor: '#000000', 38 strokeWeight: 3, 39 strokeOpacity: 0.5 40 }); 41 myGmaps.objects.polygon = new google.maps.Polygon({ 42 fillColor: '#5555FF', 43 strokeColor: '#000000', 44 strokeWeight: 3, 45 strokeOpacity: 0.5 46 }); 49 myGmaps.objects.polyline = new google.maps.Polyline(myGmaps.options.polyline); 50 myGmaps.objects.polygon = new google.maps.Polygon(myGmaps.options.polygon); 47 51 myGmaps.objects.polyline.setPath(new google.maps.MVCArray([myGmaps.path.polyline])); 48 52 myGmaps.objects.polygon.setPath(new google.maps.MVCArray([myGmaps.path.polygon])); … … 72 76 73 77 loadData: function() { 74 var list = $('input[name=post_excerpt]').val().split("\n"); 78 var list = $('textarea[name=post_excerpt]').val().split("\n"); 79 myGmaps.elt_type = $('input[name=elt_type]').val(); 75 80 for (var i = 0; i < list.length; i++) { 76 81 if (list[i].length > 0) { … … 366 371 }, 367 372 373 setMapPoints: function() { 374 var type = ''; 375 var icon = ''; 376 var stroke_weight = ''; 377 var stroke_opacity = ''; 378 var stroke_color = ''; 379 var fill_color = ''; 380 var list = []; 381 var points = []; 382 383 if (myGmaps.path.polyline.length > 0) { 384 type = 'polyline'; 385 list = myGmaps.markers; 386 stroke_weight = myGmaps.objects.polyline.strokeWeight; 387 stroke_opacity = myGmaps.objects.polyline.strokeOpacity; 388 stroke_color = myGmaps.objects.polyline.strokeColor; 389 } 390 else if (myGmaps.path.polygon.length > 0) { 391 type = 'polygon'; 392 list = myGmaps.markers; 393 stroke_weight = myGmaps.objects.polygon.strokeWeight; 394 stroke_opacity = myGmaps.objects.polygon.strokeOpacity; 395 stroke_color = myGmaps.objects.polygon.strokeColor; 396 fill_color = myGmaps.objects.polygon.fillColor; 397 } 398 else if (myGmaps.markers.length > 0) { 399 type = 'marker'; 400 list = myGmaps.markers; 401 } 402 else if (myGmaps.kmls.length > 0) { 403 type = 'kml'; 404 list = myGmaps.kmls; 405 } 406 else { 407 type = 'none'; 408 } 409 410 for (i in list) { 411 if (myGmaps.is_url(list[i].url)) { 412 points.push(list[i].url); 413 } 414 else { 415 points.push(list[i].getPosition().lat() + "|" + list[i].getPosition().lng() + "|" + icon); 416 } 417 } 418 419 $('input[name=elt_type]').val(type); 420 $('input[name=stroke_weight]').val(stroke_weight); 421 $('input[name=stroke_opacity]').val(stroke_opacity); 422 $('input[name=stroke_color]').val(stroke_color); 423 $('input[name=fill_color]').val(fill_color); 424 $('textarea[name=post_excerpt]').val(points.join("\n")); 425 }, 426 368 427 select: function(id) { 369 428 $('li#none').removeClass('selected'); -
plugins/myGmaps/branches/map.php
r2868 r2870 15 15 $post_dt = ''; 16 16 $post_type = 'map'; 17 $post_maps = 'none';18 17 $post_format = $core->auth->getOption('post_format'); 19 18 $post_password = ''; … … 31 30 $post_open_tb = ''; 32 31 $post_meta = array(); 32 $post_meta = array( 33 'center' => $core->blog->settings->myGmaps->center, 34 'zoom' => $core->blog->settings->myGmaps->center, 35 'map_type' => $core->blog->settings->myGmaps->map_type, 36 'elt_type' => 'none', 37 'stroke_weight' => '', 38 'stroke_opacity' => '', 39 'stroke_color' => '', 40 'fill_color' => '' 41 ); 33 42 34 43 $post_media = array(); … … 108 117 $post_dt = date('Y-m-d H:i',strtotime($post->post_dt)); 109 118 $post_type = $post->post_type; 110 $post_maps = $post->post_maps;111 119 $post_format = $post->post_format; 112 120 $post_password = $post->post_password; … … 179 187 $post_open_tb = !empty($_POST['post_open_tb']); 180 188 $post_selected = !empty($_POST['post_selected']); 181 $post_lang = $ _POST['post_lang'];189 $post_lang = $core->auth->getInfo('user_lang'); 182 190 $post_password = !empty($_POST['post_password']) ? $_POST['post_password'] : null; 183 191 … … 234 242 $core->callBehavior('adminAfterPostUpdate',$cur,$post_id); 235 243 236 if (isset($_POST['post_maps'])) { 237 $tags = $_POST['post_maps']; 238 $myGmaps_center = $_POST['myGmaps_center']; 239 $myGmaps_zoom = $_POST['myGmaps_zoom']; 240 $myGmaps_type = $_POST['myGmaps_type']; 241 $meta =& $GLOBALS['core']->meta; 242 $meta->delPostMeta($post_id,'map'); 243 $meta->delPostMeta($post_id,'map_options'); 244 245 foreach ($meta->splitMetaValues($tags) as $tag) { 246 $meta->setPostMeta($post_id,'map',$tag); 247 } 248 $map_options = $myGmaps_center.','.$myGmaps_zoom.','.$myGmaps_type; 249 $meta->setPostMeta($post_id,'map_options',$map_options); 244 foreach ($post_meta as $k => $v) { 245 $core->meta->delPostMeta($post_id,$k); 246 $core->meta->setPostMeta($post_id,$k,(array_key_exists($k,$_POST) ? $_POST[$k] : $v)); 250 247 } 251 http::redirect(''.$p_url.'& do=edit&id='.$post_id.'&upd=1');248 http::redirect(''.$p_url.'&go=map&id='.$post_id.'&upd=1'); 252 249 } 253 250 catch (Exception $e) … … 270 267 $core->callBehavior('adminAfterPostCreate',$cur,$return_id); 271 268 272 if (isset($_POST['post_maps'])) { 273 $tags = $_POST['post_maps']; 274 $myGmaps_center = $_POST['myGmaps_center']; 275 $myGmaps_zoom = $_POST['myGmaps_zoom']; 276 $myGmaps_type = $_POST['myGmaps_type']; 277 $meta =& $GLOBALS['core']->meta; 278 279 foreach ($meta->splitMetaValues($tags) as $tag) { 280 $meta->setPostMeta($return_id,'map',$tag); 281 } 282 $map_options = $myGmaps_center.','.$myGmaps_zoom.','.$myGmaps_type; 283 $meta->setPostMeta($return_id,'map_options',$map_options); 269 foreach ($post_meta as $k => $v) { 270 $core->meta->setPostMeta($return_id,$k,(array_key_exists($k,$_POST) ? $_POST[$k] : $v)); 284 271 } 285 286 http::redirect(''.$p_url.'&do=edit&id='.$return_id.'&crea=1'); 272 http::redirect(''.$p_url.'&go=map&id='.$return_id.'&crea=1'); 287 273 } 288 274 catch (Exception $e) … … 299 285 $core->callBehavior('adminBeforePostDelete',$post_id); 300 286 $core->blog->delPost($post_id); 301 http::redirect($p_url.'& do=list');287 http::redirect($p_url.'&go=maps'); 302 288 } catch (Exception $e) { 303 289 $core->error->add($e->getMessage()); … … 381 367 echo 382 368 '<div id="edit-entry">'. 383 '<form action="'.$p_url.'& do=edit" method="post" id="entry-form">'.369 '<form action="'.$p_url.'&go=map" method="post" id="entry-form">'. 384 370 '<div id="entry-sidebar">'; 385 371 … … 410 396 form::field('post_title',20,255,html::escapeHTML($post_title),'maximal',2). 411 397 '</label></p>'; 412 413 $meta =& $GLOBALS['core']->meta;414 415 if(isset($post)) {416 echo form::hidden('post_maps',$meta->getMetaStr($post->post_meta,'map')).'</p>';417 } else {418 echo form::hidden('post_maps','').'</p>';419 }420 398 421 399 echo … … 460 438 '</p>'; 461 439 462 $metas = array( 463 'elt_type' => array_key_exists('elt_type',$post_meta) ? $post_meta['elt_type'] : 'none', 464 'stroke_weight' => array_key_exists('stroke_weight',$post_meta) ? $post_meta['stroke_weight'] : '', 465 'stroke_opacity' => array_key_exists('stroke_opacity',$post_meta) ? $post_meta['stroke_opacity'] : '', 466 'stroke_color' => array_key_exists('stroke_color',$post_meta) ? $post_meta['stroke_color'] : '', 467 'fill_color' => array_key_exists('fill_color',$post_meta) ? $post_meta['fill_color'] : '' 468 ); 469 foreach ($metas as $k => $v) { 470 echo form::hidden($k,$v); 471 } 472 473 echo 474 form::hidden('center',$core->blog->settings->myGmaps->center). 475 form::hidden('zoom',$core->blog->settings->myGmaps->zoom). 476 form::hidden('map_type',$core->blog->settings->myGmaps->map_type). 477 form::hidden('scrollwheel',$core->blog->settings->myGmaps->scrollwheel); 478 479 echo 480 '<p>'. 440 echo '<p>'; 441 foreach ($post_meta as $k => $v) { 442 echo form::hidden($k,$v[0]); 443 } 444 echo 445 form::hidden('scrollwheel',$core->blog->settings->myGmaps->scrollwheel). 481 446 ($post_id ? form::hidden('id',$post_id) : ''). 482 447 '<input type="submit" value="'.__('save').' (s)" tabindex="4" '. -
plugins/myGmaps/branches/maps.php
r2868 r2870 277 277 278 278 # Show posts 279 $post_list->display($page,$nb_per_page, 279 $post_list->display($page,$nb_per_page,$p_url, 280 280 '<form action="'.$p_url.'" method="post" id="form-entries">'. 281 281
Note: See TracChangeset
for help on using the changeset viewer.