Dotclear

Changeset 2874


Ignore:
Timestamp:
01/13/11 01:17:44 (13 years ago)
Author:
Tomtom33
Message:

Watch out #5

Location:
plugins/myGmaps/branches
Files:
6 deleted
7 edited
1 moved

Legend:

Unmodified
Added
Removed
  • plugins/myGmaps/branches/_prepend.php

    r2868 r2874  
    11<?php 
    22 
     3$__autoload['myGmapsUtils'] = dirname(__FILE__).'/inc/lib.my.gmaps.ui.php'; 
    34$__autoload['adminMyGmapsList'] = dirname(__FILE__).'/inc/lib.my.gmaps.ui.php'; 
    45 
  • plugins/myGmaps/branches/inc/lib.my.gmaps.ui.php

    r2870 r2874  
    11<?php 
     2 
     3class myGmapsUtils 
     4{ 
     5     public static function getMapIcons() 
     6     { 
     7          $list = files::getDirList(path::real(dirname(__FILE__).'/../icons')); 
     8          return $list['files']; 
     9     } 
     10      
     11     public static function getAdminIconURL($filename) 
     12     { 
     13          return sprintf('index.php?pf=myGmaps/icons/%s',$filename); 
     14     } 
     15      
     16     public static function getMapIconsJS() 
     17     { 
     18          $root = path::real(dirname(__FILE__).'/../icons'); 
     19          $icons = array(); 
     20           
     21          $mask = '#'.$root.'/(.*)#'; 
     22           
     23          foreach (self::getMapIcons() as $icon) 
     24          { 
     25               $icon = preg_replace('#'.$root.'/(.*)#',"'index.php?pf=myGmaps/icons/$1'",$icon);  
     26               array_push($icons,$icon); 
     27          } 
     28           
     29          return sprintf('myGmaps.icons = [%s];',implode(',',$icons)); 
     30     } 
     31} 
    232 
    333class adminMyGmapsList extends adminGenericList 
  • plugins/myGmaps/branches/js/_maps.js

    r2872 r2874  
    2727      
    2828     var icon = new google.maps.MarkerImage( 
    29           'index.php?pf=myGmaps/icons/target_icon.png', 
     29          'index.php?pf=myGmaps/images/target_icon.png', 
    3030          null, 
    3131          null, 
     
    6161          } 
    6262     }); 
     63      
     64     // Icons tab 
     65     $('#icons-form li').each(function() { 
     66          var css = { 
     67               'background-position': 'middle center', 
     68               'cursor': 'pointer', 
     69               'height': '50px' 
     70          }; 
     71          $(this).css(css); 
     72          $(this).children('input').css('display','none'); 
     73          $(this).click(function() { 
     74               if ($(this).children('input').is(':checked')) { 
     75                    $(this).children('input').removeAttr('checked'); 
     76                    $(this).css('background-color','transparent'); 
     77               } 
     78               else { 
     79                    $(this).children('input').attr('checked',true); 
     80                    $(this).css('background-color','#ccc'); 
     81               } 
     82          }); 
     83     }); 
     84     $('#icons-form input[name=delete]').click(function() { 
     85          if ($('#icons-form li input:checked').size() == 0) { 
     86               alert(myGmaps.msg.no_icon_selected); 
     87               return false; 
     88          } 
     89     }); 
    6390}); 
  • plugins/myGmaps/branches/js/myGmaps.js

    r2873 r2874  
    345345      
    346346     updIcon: function(marker) { 
    347           var icon = myGmaps.icons[(myGmaps.iconIndex++) % myGmaps.icons.length]; 
     347          var icon = myGmaps.icons[myGmaps.iconIndex++ % myGmaps.icons.length]; 
    348348          for (i in myGmaps.markers) { 
    349349               myGmaps.markers[i].setIcon(icon); 
  • plugins/myGmaps/branches/map.php

    r2873 r2874  
    330330     dcPage::jsVar('myGmaps.msg.type',__('Type')). 
    331331     dcPage::jsVar('myGmaps.msg.coordinates',__('Coordinates')). 
    332      $jsVar. 
     332     myGmapsUtils::getMapIconsJS(). 
    333333     '</script>'. 
    334334'</head>'. 
  • plugins/myGmaps/branches/maps.php

    r2872 r2874  
    2121          $core->blog->settings->myGmaps->put('scrollwheel',$_POST['scrollwheel']); 
    2222          http::redirect($p_url.'&go=maps&tab=config&upd=0'); 
     23     } catch (Exception $e) { 
     24          $core->error->add($e->getMessage()); 
     25     } 
     26} 
     27# Add icon 
     28if (!empty($_POST['send'])) { 
     29     try{ 
     30          files::uploadStatus($_FILES['upfile']); 
     31          $fm = new filemanager(dirname(__FILE__).'/icons'); 
     32          $fm->uploadFile($_FILES['upfile']['tmp_name'],$_FILES['upfile']['name']); 
     33          http::redirect($p_url.'&go=maps&tab=icons&add=1'); 
     34     } catch (Exception $e) { 
     35          $core->error->add($e->getMessage()); 
     36     } 
     37} 
     38# Delete icons 
     39if (!empty($_POST['delete'])) { 
     40     try { 
     41          foreach ($_POST['ids'] as $filename) { 
     42               unlink(dirname(__FILE__).'/icons/'.$filename); 
     43          } 
     44          http::redirect($p_url.'&go=maps&tab=icons&del=1'); 
    2345     } catch (Exception $e) { 
    2446          $core->error->add($e->getMessage()); 
     
    221243     dcPage::jsVar('myGmaps.msg.type',__('Type')). 
    222244     dcPage::jsVar('myGmaps.msg.coordinates',__('Coordinates')). 
     245     dcPage::jsVar('myGmaps.msg.no_icon_selected',__('Please, select at leat one icon')). 
    223246     '</script>'. 
    224247'</head>'. 
     
    228251if (isset($_GET['upd']) && $_GET['upd'] === '0') { 
    229252     echo '<p class="message">'.__('Configuration has been successfully saved').'</p>'; 
     253} 
     254if (isset($_GET['add']) && $_GET['add'] === '1') { 
     255     echo '<p class="message">'.__('Icon has been successfully added').'</p>'; 
     256} 
     257if (isset($_GET['del']) && $_GET['del'] === '1') { 
     258     echo '<p class="message">'.__('Selected icons have been successfully deleted').'</p>'; 
    230259} 
    231260 
     
    335364     '</form>'. 
    336365     '</div>'; 
     366      
     367     echo 
     368     '<div class="multi-part" id="icons" title="'.__('Icons').'">'. 
     369     '<form method="post" action="'.$p_url.'&amp;tab=icons" id="icons-form" enctype="multipart/form-data">'. 
     370     '<fieldset><legend>'.__('Add icon').'</legend>'. 
     371     '<p><label>'.__('Choose a file:'). 
     372     ' ('.sprintf(__('Maximum size %s'),files::size(DC_MAX_UPLOAD_SIZE)).')'. 
     373     '<input type="file" name="upfile" size="20" />'. 
     374     '</label></p>'. 
     375     '<p><input type="submit" name="send" value="'.__('send').'" /></p>'. 
     376     '</fieldset>'. 
     377     '<fieldset><legend>'.__('Delete icons').'</legend>'. 
     378     '<p>'.__('Select icons to delete by clicking on them').'</p>'. 
     379     '<ul>'; 
     380     foreach (myGmapsUtils::getMapIcons() as $icon) { 
     381          echo sprintf( 
     382               '<li style="background-image: url(%1$s); background-repeat: no-repeat; background-position: top center;">%2$s</li>', 
     383               myGmapsUtils::getAdminIconURL(basename($icon)), 
     384               form::checkbox(array('ids[]'),basename($icon),false) 
     385          ); 
     386     } 
     387     echo 
     388     '</ul>'. 
     389     '<p>'. 
     390     $core->formNonce(). 
     391     '<input type="submit" name="delete" value="'.__('Delete selected icons').'" />'. 
     392     '</p>'. 
     393     '</fieldset>'. 
     394     '</form>'. 
     395     '</div>'; 
    337396} 
    338397 
  • plugins/myGmaps/branches/style.css

    r2868 r2874  
    5252     background: transparent url(http://google.com/mapfiles/ms/t/Bpd.png) no-repeat top left; 
    5353} 
     54/* Icons management */ 
     55#icons-form ul { 
     56     overflow: hidden; 
     57     padding: 0; 
     58     margin: 0; 
     59} 
     60#icons-form ul li { 
     61     float: left; 
     62     margin: 0.2em; 
     63     list-style: none; 
     64     width: 50px; 
     65     height: 70px; 
     66} 
     67#icons-form ul li input{ 
     68     margin-top: 50px; 
     69     margin-left: 20px; 
     70} 
     71#icons-form ul li.jquery { 
     72     background-position: middle center; 
     73     cursor: pointer; 
     74     height: 50px; 
     75} 
Note: See TracChangeset for help on using the changeset viewer.

Sites map