source: extensions/GMaps/gmaps_rb_callback.class.inc.php @ 17557

Last change on this file since 17557 was 7676, checked in by grum, 14 years ago

fix bug:2009 - MySQL error on search tab
fix bug:2012 - MySQL 5.1 incompatibility

  • Property svn:executable set to *
File size: 5.2 KB
Line 
1<?php
2/* -----------------------------------------------------------------------------
3  Plugin     : GMaps
4  Author     : Grum
5    email    : grum@piwigo.org
6    website  : http://photos.grum.fr
7
8    << May the Little SpaceFrog be with you ! >>
9  ------------------------------------------------------------------------------
10  See main.inc.php for release information
11
12
13  --------------------------------------------------------------------------- */
14
15  if(!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
16
17  include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCRequestBuilder.class.inc.php');
18
19load_language('plugin.lang', GMAPS_PATH);
20
21class RBCallBackGMaps extends GPCSearchCallback {
22
23  /**
24   * the getImageId returns the name of the image id attribute
25   * return String
26   */
27  static public function getImageId()
28  {
29    return("pgc.imageId");
30  }
31
32  /**
33   * the getSelect function must return an attribute list separated with a comma
34   *
35   * "att1, att2, att3, att4"
36   */
37  static public function getSelect($param="")
38  {
39    return("pgc.latitude, pgc.longitude");
40  }
41
42  /**
43   * the getFrom function must return a tables list separated with a comma
44   *
45   * "table1, (table2 left join table3 on table2.key = table3.key), table4"
46   */
47  static public function getFrom($param="")
48  {
49    global $prefixeTable;
50
51    return($prefixeTable."gmaps_cache pgc");
52  }
53
54  /**
55   * the getWhere function must return a ready to use where clause
56   *
57   * "(att1 = value0 OR att2 = value1) AND att4 LIKE value2 "
58   */
59  static public function getWhere($param="")
60  {
61    global $user;
62
63    $returned='';
64
65    if($param['bounds']['east']<$param['bounds']['west'])
66    {
67      $returned=" (pgc.longitude <= ".$param['bounds']['east']." OR pgc.longitude >= ".$param['bounds']['west'].") ";
68    }
69    else
70    {
71      $returned=" (pgc.longitude >= ".$param['bounds']['west']." AND pgc.longitude <= ".$param['bounds']['east'].") ";
72    }
73
74    $returned.=" AND pgc.latitude >= ".$param['bounds']['south']."
75                 AND pgc.latitude <= ".$param['bounds']['north']."
76                 AND pgc.requestId='".$param['requestId']."' ";
77
78    return($returned);
79  }
80
81  /**
82   * the getJoin function must return a ready to use where allowing to join the
83   * IMAGES table (key : id) with given conditions
84   *
85   * "att3 = pit.id "
86   */
87  static public function getJoin($param="")
88  {
89    return("pgc.imageId = pit.id");
90  }
91
92
93  /**
94   * the getFilter function must return a ready to use where clause
95   * this where clause is used to filter the cache when the used tables can
96   * return more than one result
97   *
98   * the filter can be empty, can be equal to the where clause, or can be equal
99   * to a sub part of the where clause
100   *
101   */
102  static public function getFilter($param="")
103  {
104    return(self::getWhere($param));
105  }
106
107  /**
108   * this function is called by the request builder, allowing to display plugin
109   * data with a specific format
110   *
111   * @param Array $attributes : array of ('attribute_name' => 'attribute_value')
112   * @return String : HTML formatted value
113   */
114  static public function formatData($attributes)
115  {
116    /* attributes is an array :
117     *    Array(
118     *      'csColors' => 'color1,color2,color3,...,colorN',
119     *      'csColorsPct' => 'pct1,pct2,pct3,...,pctN'
120     *    );
121     */
122    $returned=l10n('gmaps_geolocation')."&nbsp;:&nbsp;";
123
124    if($attributes['latitude']<0)
125    {
126      $returned.=GMaps_functions::DDtoDMS(abs($attributes['latitude'])).'&nbsp;'.l10n('gmaps_south');
127    }
128    else
129    {
130      $returned.=GMaps_functions::DDtoDMS($attributes['latitude']).'&nbsp;'.l10n('gmaps_north');
131    }
132
133    $returned.=', ';
134
135    if($attributes['longitude']<0)
136    {
137      $returned.=GMaps_functions::DDtoDMS(abs($attributes['longitude'])).'&nbsp;'.l10n('gmaps_west');
138    }
139    else
140    {
141      $returned.=GMaps_functions::DDtoDMS($attributes['longitude']).'&nbsp;'.l10n('gmaps_east');
142    }
143
144    return($returned);
145  }
146
147
148
149  /**
150   * this function is called by the request builder to make the search page, and
151   * must return the HTML & JS code of the dialogbox used to select criterion
152   *
153   * Notes :
154   *  - the dialogbox is a JS object with a public method 'show'
155   *  - when the method show is called, one parameter is given by the request
156   *    builder ; the parameter is an object defined as this :
157   *      {
158   *        cBuilder: an instance of the criteriaBuilder object used in the page,
159   *        eventOK : a callback function, called when the OK button is pushed
160   *        id:
161   *      }
162   *
163   *
164   *
165   *
166   * @param String $mode : can take 'admin' or 'public' values, allowing to
167   *                       return different interface if needed
168   * @return String : HTML formatted value
169   */
170  static public function getInterfaceContent($mode='admin')
171  {
172    return(GMaps_functions::dialogBoxGMaps());
173  }
174
175  /**
176   * this function returns the label displayed in the criterion menu
177   *
178   * @return String : label displayed in the criterions menu
179   */
180  static public function getInterfaceLabel()
181  {
182    return(l10n('gmaps_add_geographic_area'));
183  }
184
185  /**
186   * this function returns the name of the dialog box class
187   *
188   * @return String : name of the dialogbox class
189   */
190  static public function getInterfaceDBClass()
191  {
192    return('dialogChooseGMapsBox');
193  }
194
195}
196
197?>
Note: See TracBrowser for help on using the repository browser.