source: extensions/ASearchEngine/ase_rb_callback_rate.class.inc.php @ 9274

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

fix some bugs and implement public interface

  • Property svn:executable set to *
File size: 4.7 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 RBCallBackASERate 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("ase_pitn.id");
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(" ase_pitn.average_rate AS averageRate");
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(IMAGES_TABLE." ase_pitn ");
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=" ase_pitn.average_rate ";
64
65    switch($param['searchType'])
66    {
67      case 'no':
68        $returned.=" IS NULL ";
69        break;
70      case 'eq':
71        $returned.=" = '".$param['minValue']."' ";
72        break;
73      case 'bt':
74        $returned.=" BETWEEN '".$param['minValue']."' AND '".$param['maxValue']."' ";
75        break;
76      case 'gt':
77        $returned.=" >= '".$param['minValue']."' ";
78        break;
79      case 'lt':
80        $returned.=" <= '".$param['maxValue']."' ";
81        break;
82    }
83
84    return($returned);
85  }
86
87  /**
88   * the getJoin function must return a ready to use where allowing to join the
89   * IMAGES table (key : id) with given conditions
90   *
91   * "att3 = pit.id "
92   */
93  static public function getJoin($param="")
94  {
95    return("ase_pitn.id = pit.id");
96  }
97
98
99  /**
100   * the getFilter function must return a ready to use where clause
101   * this where clause is used to filter the cache when the used tables can
102   * return more than one result
103   *
104   * the filter can be empty, can be equal to the where clause, or can be equal
105   * to a sub part of the where clause
106   *
107   */
108  static public function getFilter($param="")
109  {
110    return("");
111  }
112
113  /**
114   * this function is called by the request builder, allowing to display plugin
115   * data with a specific format
116   *
117   * @param Array $attributes : array of ('attribute_name' => 'attribute_value')
118   * @return String : HTML formatted value
119   */
120  static public function formatData($attributes)
121  {
122    /* attributes is an array :
123     *    Array(
124     *      'csColors' => 'color1,color2,color3,...,colorN',
125     *      'csColorsPct' => 'pct1,pct2,pct3,...,pctN'
126     *    );
127     */
128    $returned="<span style='font-weight:bold;'>".l10n('ase_average_rate')."</span>&nbsp;:&nbsp;".$attributes['averageRate'];
129    return($returned);
130  }
131
132
133
134  /**
135   * this function is called by the request builder to make the search page, and
136   * must return the HTML & JS code of the dialogbox used to select criterion
137   *
138   * Notes :
139   *  - the dialogbox is a JS object with a public method 'show'
140   *  - when the method show is called, one parameter is given by the request
141   *    builder ; the parameter is an object defined as this :
142   *      {
143   *        cBuilder: an instance of the criteriaBuilder object used in the page,
144   *        eventOK : a callback function, called when the OK button is pushed
145   *        id:
146   *      }
147   *
148   *
149   *
150   *
151   * @param String $mode : can take 'admin' or 'public' values, allowing to
152   *                       return different interface if needed
153   * @return String : HTML formatted value
154   */
155  static public function getInterfaceContent($mode='admin')
156  {
157    return(ASE_functions::dialogBoxASERate());
158  }
159
160  /**
161   * this function returns the label displayed in the criterion menu
162   *
163   * @return String : label displayed in the criterions menu
164   */
165  static public function getInterfaceLabel()
166  {
167    return(l10n('ase_add_rate'));
168  }
169
170  /**
171   * this function returns the name of the dialog box class
172   *
173   * @return String : name of the dialogbox class
174   */
175  static public function getInterfaceDBClass()
176  {
177    return('dialogChooseASERateBox');
178  }
179
180}
181
182?>
Note: See TracBrowser for help on using the repository browser.