Dotclear

Changeset 2843


Ignore:
Timestamp:
01/10/11 13:19:18 (13 years ago)
Author:
Tomtom33
Message:

myLocation 0.1.2:

  • Improvements of CSS/JS load
  • Moved plugin configuration in a specific page
Location:
plugins/myLocation/trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • plugins/myLocation/trunk/_admin.php

    r2693 r2843  
    1313if (!defined('DC_CONTEXT_ADMIN')) { return; } 
    1414 
    15 $core->addBehavior('adminBlogPreferencesForm',array('myLocationBehaviors','adminBlogPreferencesForm')); 
    16 $core->addBehavior('adminBeforeBlogSettingsUpdate',array('myLocationBehaviors','adminBeforeBlogSettingsUpdate')); 
    17  
    18 class myLocationBehaviors 
    19 { 
    20      public static function adminBlogPreferencesForm($core,$settings) 
    21      { 
    22           echo 
    23           '<fieldset><legend>'.__('Geolocation').'</legend>'. 
    24           '<p><label class="classic">'. 
    25           form::checkbox('mylocation_enable','1',$settings->myLocation->enable). 
    26           __('Enable geolocation').'</label></p>'. 
    27           '</fieldset>'; 
    28      } 
    29  
    30      public static function adminBeforeBlogSettingsUpdate($settings) 
    31      { 
    32           $settings->myLocation->put('enable',!empty($_POST['mylocation_enable'])); 
    33      } 
    34 } 
     15$_menu['Plugins']->addItem(__('myLocation'),'plugin.php?p=myLocation','index.php?pf=myLocation/icon.png', 
     16     preg_match('/plugin.php\?p=myLocation(&.*)?$/',$_SERVER['REQUEST_URI']), 
     17     $core->auth->check('admin',$core->blog->id)); 
    3518 
    3619?> 
  • plugins/myLocation/trunk/_define.php

    r2699 r2843  
    1515          /* Description*/         "Display your current location", 
    1616          /* Author */             "Tomtom (http://blog.zenstyle.fr)", 
    17           /* Version */            '0.1.1', 
     17          /* Version */            '0.1.2', 
    1818          /* Permissions */        'usage,contentadmin' 
    1919); 
  • plugins/myLocation/trunk/_install.php

    r2699 r2843  
    2222$core->blog->settings->addNamespace('myLocation'); 
    2323$core->blog->settings->myLocation->put('enable',false,'boolean','Enable myLocation',false,true); 
     24$core->blog->settings->myLocation->put('position','afterContent','string','Position of location display',false,true); 
     25$core->blog->settings->myLocation->put('accuracy','city','string','Geolocalisation accuracy',false,true); 
     26$core->blog->settings->myLocation->put('css','','string','Custom CSS',false,true); 
    2427 
    2528# --INSTALL AND UPDATE PROCEDURES-- 
  • plugins/myLocation/trunk/_public.php

    r2693 r2843  
    1313if (!defined('DC_RC_PATH')) { return; } 
    1414 
    15 $core->addBehavior('publicHeadContent',array('myLocationBehaviors','publicHeadContent')); 
     15$core->addBehavior('publicFooterContent',array('myLocationBehaviors','publicFooterContent')); 
    1616$core->addBehavior('templateBeforeBlock',array('myLocationBehaviors','templateBeforeBlock')); 
    17 $core->addBehavior('publicCommentAfterContent',array('myLocationBehaviors','publicCommentAfterContent')); 
    1817$core->addBehavior('coreBeforeCommentCreate',array('myLocationBehaviors','coreBeforeCommentCreate')); 
    1918$core->addBehavior('coreBlogGetComments',array('myLocationBehaviors','coreBlogGetComments')); 
    2019 
     20if ($core->blog->settings->myLocation->position === 'afterContent') { 
     21     $core->addBehavior('publicCommentAfterContent',array('myLocationBehaviors','publicCommentAfterContent')); 
     22} 
     23else { 
     24     $core->addBehavior('templateAfterValue',array('myLocationBehaviors','templateAfterValue')); 
     25} 
     26 
    2127class myLocationBehaviors 
    2228{ 
    23      public static function publicHeadContent($core,$_ctx) 
     29     public static function publicFooterContent($core,$_ctx) 
    2430     { 
    2531          $js = $core->blog->getQMarkURL().'pf='.basename(dirname(__FILE__)).'/js/post.js'; 
     
    3440          'var post_location_error_denied = "'.__('Permission denied by your browser').'";'."\n". 
    3541          'var post_location_error_unavailable = "'.__('You location is currently unavailable. Please, try later').'";'."\n". 
     42          'var post_location_error_accuracy = "'.__('You location is currently unavailable for the choosen accuracy').'";'."\n". 
    3643          'var post_location_longitude = "'.(isset($_POST['c_location_longitude']) ? $_POST['c_location_longitude'] : '').'";'."\n". 
    3744          'var post_location_latitude = "'.(isset($_POST['c_location_latitude']) ? $_POST['c_location_latitude'] : '').'";'."\n". 
    3845          'var post_location_address = "'.(isset($_POST['c_location_address']) ? $_POST['c_location_address'] : '').'";'."\n". 
     46          'var post_location_accuracy = "'.$core->blog->settings->myLocation->accuracy.'";'."\n". 
    3947          '//]]>'."\n". 
    4048          '</script>'."\n". 
     
    5765     } 
    5866      
     67     public static function templateAfterValue($core,$tag,$attr) 
     68     { 
     69          $fit_tag = $core->blog->settings->myLocation->position; 
     70           
     71          if ($tag === $fit_tag) { 
     72               return 
     73               "<?php\n". 
     74               'if ($_ctx->comments->hasLocation()) {'."\n". 
     75                    'echo \'&nbsp;<span class="comment-location">\'.$_ctx->comments->getLocation().\'</span>\';'."\n". 
     76               '}'."\n". 
     77               "?>"; 
     78          } 
     79     } 
     80      
    5981     public static function coreBeforeCommentCreate($blog,$cur) 
    6082     { 
  • plugins/myLocation/trunk/inc/class.rs.ext.comment.location.php

    r2693 r2843  
    3636          sprintf('http://maps.google.com/maps?q=%s,+%s+%s',$location['latitude'],$location['longitude'],''); 
    3737      
    38           echo sprintf('<a href="%s">%s</a>',$url,$address); 
     38          return sprintf('<a href="%s">%s</a>',$url,$address); 
    3939     } 
    4040} 
  • plugins/myLocation/trunk/js/post.js

    r2693 r2843  
    6464          function succesCallback(position) { 
    6565               $('input[type="submit"]').removeAttr('disabled'); 
    66                var address; 
     66               var address = ''; 
    6767               var geocoder = new google.maps.Geocoder(); 
    6868               var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); 
    6969               geocoder.geocode({'latLng': latlng}, function(results, status) { 
    7070                    if (status == google.maps.GeocoderStatus.OK) { 
    71                          for (var i = 2; i < results.length; i++) { 
    72                               if (results[i]) { 
    73                                    address = results[i].formatted_address; 
    74                                    break; 
     71                         for (var i = 0; i < results.length; i++) { 
     72                              for (var j = 0; j < results[i].types.length; j++) { 
     73                                   if (results[i].types[j] == post_location_accuracy) { 
     74                                        address = results[i].formatted_address; 
     75                                        break; 
     76                                   } 
    7577                              } 
    7678                         } 
     79                         $('#c_location_longitude').val(position.coords.longitude); 
     80                         $('#c_location_latitude').val(position.coords.latitude); 
     81                         $('#c_location_address').val(address); 
     82                         if (address.length > 0) { 
     83                              updLocationLabel(address,'success'); 
     84                         } 
     85                         else { 
     86                              updLocationLabel(post_location_error_accuracy,'unavailable'); 
     87                         } 
    7788                    } 
    78                     $('#c_location_longitude').val(position.coords.longitude); 
    79                     $('#c_location_latitude').val(position.coords.latitude); 
    80                     if (address.length > 0) { 
     89                    else { 
     90                         $('#c_location_longitude').val(position.coords.longitude); 
     91                         $('#c_location_latitude').val(position.coords.latitude); 
    8192                         $('#c_location_address').val(address); 
    82                          updLocationLabel(address,'success'); 
     93                         updLocationLabel(post_location_error_unavailable,'unavailable'); 
    8394                    } 
    8495               }); 
  • plugins/myLocation/trunk/locales/fr/main.po

    r2693 r2843  
    11# Language: Français 
    2 # Module: myLocation - 0.1 
    3 # Date: 2010-10-01 17:32:35 
     2# Module: myLocation - 0.1.2 
     3# Date: 2011-01-10 12:17:41 
    44# Translated with translater 1.5 
    55 
     
    77msgstr "" 
    88"Content-Type: text/plain; charset=UTF-8\n" 
    9 "Project-Id-Version: myLocation 0.1\n" 
     9"Project-Id-Version: myLocation 0.1.2\n" 
    1010"POT-Creation-Date: \n" 
    11 "PO-Revision-Date: 2010-10-01T17:32:35+00:00\n" 
    12 "Last-Translator: Thomas Bouron\n" 
     11"PO-Revision-Date: 2011-01-10T12:17:41+00:00\n" 
     12"Last-Translator: Tomtom\n" 
    1313"Language-Team: \n" 
    1414"MIME-Version: 1.0\n" 
    1515"Content-Transfer-Encoding: 8bit\n" 
    1616 
    17 #: _admin.php:23 
    18 msgid "Geolocation" 
    19 msgstr "Géo localisation" 
     17#: _admin.php:15 
     18#: index.php:50 
     19#: index.php:60 
     20msgid "myLocation" 
     21msgstr "myLocation" 
    2022 
    21 #: _admin.php:26 
    22 msgid "Enable geolocation" 
    23 msgstr "Activer la géo localisation" 
    24  
    25 #: _public.php:32 
     23#: _public.php:38 
    2624msgid "Add my location" 
    2725msgstr "Ajouter ma localisation" 
    2826 
    29 #: _public.php:33 
     27#: _public.php:39 
    3028msgid "Searching..." 
    3129msgstr "Recherche..." 
    3230 
    33 #: _public.php:34 
     31#: _public.php:40 
    3432msgid "Permission denied by your browser" 
    3533msgstr "Permission refusé par votre navigateur" 
    3634 
    37 #: _public.php:35 
     35#: _public.php:41 
    3836msgid "You location is currently unavailable. Please, try later" 
    3937msgstr "Votre localisation actuelle est indisponible. Merci de réessayer plus tard" 
     38 
     39#: _public.php:42 
     40msgid "You location is currently unavailable for the choosen accuracy" 
     41msgstr "Votre localisation actuelle est indisponible pour le niveau de précision demandé" 
    4042 
    4143#: inc/class.rs.ext.comment.location.php:32 
     
    4345msgstr "Voir sur la carte" 
    4446 
     47#: index.php:33 
     48msgid "After content" 
     49msgstr "Après le contenu" 
     50 
     51#: index.php:34 
     52msgid "After author name" 
     53msgstr "Après l'auteur" 
     54 
     55#: index.php:37 
     56msgid "Street address" 
     57msgstr "Adresse" 
     58 
     59#: index.php:38 
     60msgid "Postal code" 
     61msgstr "Code postal" 
     62 
     63#: index.php:39 
     64msgid "Administrative area" 
     65msgstr "Zone administrative" 
     66 
     67#: index.php:40 
     68msgid "Neighborhood" 
     69msgstr "Environ" 
     70 
     71#: index.php:41 
     72msgid "State" 
     73msgstr "Région" 
     74 
     75#: index.php:42 
     76msgid "Country" 
     77msgstr "Pays" 
     78 
     79#: index.php:56 
     80msgid "Configuration has been successfully updated" 
     81msgstr "La configuration a été mise à jour avec succès" 
     82 
     83#: index.php:62 
     84msgid "General options" 
     85msgstr "Options générales" 
     86 
     87#: index.php:65 
     88msgid "Enable geolocation" 
     89msgstr "Activer la géo localisation" 
     90 
     91#: index.php:67 
     92msgid "Position of location display" 
     93msgstr "Position de l'affichage de la localisation" 
     94 
     95#: index.php:71 
     96msgid "Custom CSS" 
     97msgstr "CSS personnalisée" 
     98 
     99#: index.php:74 
     100msgid "Leave blank to use the default plugin CSS" 
     101msgstr "Laissez vide pour utiliser la CSS par défaut du plugin" 
     102 
     103#: index.php:76 
     104msgid "Geolocalisation accuracy" 
     105msgstr "Précision de la géo localisation" 
     106 
     107msgid "Geolocation" 
     108msgstr "Géo localisation" 
     109 
Note: See TracChangeset for help on using the changeset viewer.

Sites map