Dotclear

source: plugins/myLocation/trunk/_public.php @ 2844

Revision 2844, 3.8 KB checked in by Tomtom33, 13 years ago (diff)

myLocation 0.1.3:

  • Fixed CSS overwrite
  • Updated fr locale
Line 
1<?php
2# -- BEGIN LICENSE BLOCK ----------------------------------
3# This file is part of myLocation, a plugin for Dotclear.
4#
5# Copyright (c) 2010 Tomtom and contributors
6# http://blog.zenstyle.fr/
7#
8# Licensed under the GPL version 2.0 license.
9# A copy of this license is available in LICENSE file or at
10# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
11# -- END LICENSE BLOCK ------------------------------------
12
13if (!defined('DC_RC_PATH')) { return; }
14
15$core->addBehavior('publicFooterContent',array('myLocationBehaviors','publicFooterContent'));
16$core->addBehavior('templateBeforeBlock',array('myLocationBehaviors','templateBeforeBlock'));
17$core->addBehavior('coreBeforeCommentCreate',array('myLocationBehaviors','coreBeforeCommentCreate'));
18$core->addBehavior('coreBlogGetComments',array('myLocationBehaviors','coreBlogGetComments'));
19
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
27class myLocationBehaviors
28{
29     public static function publicFooterContent($core,$_ctx)
30     {
31          $js = $core->blog->getQMarkURL().'pf='.basename(dirname(__FILE__)).'/js/post.js';
32          $css =
33               $core->blog->settings->myLocation->css === '' ? 
34               $core->blog->getQMarkURL().'pf='.basename(dirname(__FILE__)).'/style.css' : 
35               $core->blog->settings->myLocation->css;
36         
37          echo $core->blog->settings->myLocation->enable ?
38          '<link rel="stylesheet" media="screen" type="text/css" href="'.$css.'" />'."\n".
39          '<script type="text/javascript">'."\n".
40          '//<![CDATA['."\n".
41          'var post_location_checkbox = "'.__('Add my location').'";'."\n".
42          'var post_location_search = "'.__('Searching...').'";'."\n".
43          'var post_location_error_denied = "'.__('Permission denied by your browser').'";'."\n".
44          'var post_location_error_unavailable = "'.__('You location is currently unavailable. Please, try later').'";'."\n".
45          'var post_location_error_accuracy = "'.__('You location is currently unavailable for the choosen accuracy').'";'."\n".
46          'var post_location_longitude = "'.(isset($_POST['c_location_longitude']) ? $_POST['c_location_longitude'] : '').'";'."\n".
47          'var post_location_latitude = "'.(isset($_POST['c_location_latitude']) ? $_POST['c_location_latitude'] : '').'";'."\n".
48          'var post_location_address = "'.(isset($_POST['c_location_address']) ? $_POST['c_location_address'] : '').'";'."\n".
49          'var post_location_accuracy = "'.$core->blog->settings->myLocation->accuracy.'";'."\n".
50          '//]]>'."\n".
51          '</script>'."\n".
52          '<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>'."\n".
53          '<script type="text/javascript" src="'.$js.'"></script>'."\n" : '';
54     }
55     
56     public static function templateBeforeBlock($core,$tag,$attr)
57     {
58          if ($tag === 'Comments') {
59               return '<?php $params["columns"][] = "comment_location"; ?>';
60          }
61     }
62     
63     public static function publicCommentAfterContent($core,$_ctx)
64     {
65          if ($_ctx->comments->hasLocation()) {
66               echo '<p class="comment-location">'.$_ctx->comments->getLocation().'</p>';
67          }
68     }
69     
70     public static function templateAfterValue($core,$tag,$attr)
71     {
72          $fit_tag = $core->blog->settings->myLocation->position;
73         
74          if ($tag === $fit_tag) {
75               return
76               "<?php\n".
77               'if ($_ctx->comments->hasLocation()) {'."\n".
78                    'echo \'&nbsp;<span class="comment-location">\'.$_ctx->comments->getLocation().\'</span>\';'."\n".
79               '}'."\n".
80               "?>";
81          }
82     }
83     
84     public static function coreBeforeCommentCreate($blog,$cur)
85     {
86          $location = array(
87               'longitude' => $_POST['c_location_longitude'],
88               'latitude' => $_POST['c_location_latitude'],
89               'address' => $_POST['c_location_address']
90          );
91          $cur->comment_location = serialize($location);
92     }
93     
94     public static function coreBlogGetComments($rs)
95     {
96          $rs->extend('rsExtCommentLocation');
97     }
98}
99
100?>
Note: See TracBrowser for help on using the repository browser.

Sites map