source: extensions/ASearchEngine/ase_rb_callback.class.inc.php @ 30957

Last change on this file since 30957 was 7318, checked in by grum, 14 years ago

fix some bugs and implement public interface

  • Property svn:executable set to *
File size: 5.3 KB
Line 
1<?php
2/* -----------------------------------------------------------------------------
3  Plugin     : Advanced Search Engine
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', ASE_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.userId='".$user['id']."'
77                 AND pgc.requestId='".$param['requestId']."' ";
78
79    return($returned);
80  }
81
82  /**
83   * the getJoin function must return a ready to use where allowing to join the
84   * IMAGES table (key : id) with given conditions
85   *
86   * "att3 = pit.id "
87   */
88  static public function getJoin($param="")
89  {
90    return("pgc.imageId = pit.id");
91  }
92
93
94  /**
95   * the getFilter function must return a ready to use where clause
96   * this where clause is used to filter the cache when the used tables can
97   * return more than one result
98   *
99   * the filter can be empty, can be equal to the where clause, or can be equal
100   * to a sub part of the where clause
101   *
102   */
103  static public function getFilter($param="")
104  {
105    return("");
106  }
107
108  /**
109   * this function is called by the request builder, allowing to display plugin
110   * data with a specific format
111   *
112   * @param Array $attributes : array of ('attribute_name' => 'attribute_value')
113   * @return String : HTML formatted value
114   */
115  static public function formatData($attributes)
116  {
117    /* attributes is an array :
118     *    Array(
119     *      'csColors' => 'color1,color2,color3,...,colorN',
120     *      'csColorsPct' => 'pct1,pct2,pct3,...,pctN'
121     *    );
122     */
123    $returned=l10n('gmaps_geolocation')."&nbsp;:&nbsp;";
124
125    if($attributes['latitude']<0)
126    {
127      $returned.=GMaps_functions::DDtoDMS(abs($attributes['latitude'])).'&nbsp;'.l10n('gmaps_south');
128    }
129    else
130    {
131      $returned.=GMaps_functions::DDtoDMS($attributes['latitude']).'&nbsp;'.l10n('gmaps_north');
132    }
133
134    $returned.=', ';
135
136    if($attributes['longitude']<0)
137    {
138      $returned.=GMaps_functions::DDtoDMS(abs($attributes['longitude'])).'&nbsp;'.l10n('gmaps_west');
139    }
140    else
141    {
142      $returned.=GMaps_functions::DDtoDMS($attributes['longitude']).'&nbsp;'.l10n('gmaps_east');
143    }
144
145    return($returned);
146  }
147
148
149
150  /**
151   * this function is called by the request builder to make the search page, and
152   * must return the HTML & JS code of the dialogbox used to select criterion
153   *
154   * Notes :
155   *  - the dialogbox is a JS object with a public method 'show'
156   *  - when the method show is called, one parameter is given by the request
157   *    builder ; the parameter is an object defined as this :
158   *      {
159   *        cBuilder: an instance of the criteriaBuilder object used in the page,
160   *        eventOK : a callback function, called when the OK button is pushed
161   *        id:
162   *      }
163   *
164   *
165   *
166   *
167   * @param String $mode : can take 'admin' or 'public' values, allowing to
168   *                       return different interface if needed
169   * @return String : HTML formatted value
170   */
171  static public function getInterfaceContent($mode='admin')
172  {
173    return(GMaps_functions::dialogBoxGMaps());
174  }
175
176  /**
177   * this function returns the label displayed in the criterion menu
178   *
179   * @return String : label displayed in the criterions menu
180   */
181  static public function getInterfaceLabel()
182  {
183    return(l10n('gmaps_add_geographic_area'));
184  }
185
186  /**
187   * this function returns the name of the dialog box class
188   *
189   * @return String : name of the dialogbox class
190   */
191  static public function getInterfaceDBClass()
192  {
193    return('dialogChooseGMapsBox');
194  }
195
196}
197
198?>
Note: See TracBrowser for help on using the repository browser.