source: extensions/ASearchEngine/ase_rb_callback_date.class.inc.php @ 9684

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

fix some bugs and implement public interface

  • Property svn:executable set to *
File size: 5.1 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 RBCallBackASEDate 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_pitd.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    if($param['dateType']=='c')
40    {
41      return(" ase_pitd.date_creation AS dateCreation");
42    }
43    else
44    {
45      return(" ase_pitd.date_available AS dateAvailable");
46    }
47  }
48
49  /**
50   * the getFrom function must return a tables list separated with a comma
51   *
52   * "table1, (table2 left join table3 on table2.key = table3.key), table4"
53   */
54  static public function getFrom($param="")
55  {
56    global $prefixeTable;
57
58    return(IMAGES_TABLE." ase_pitd ");
59  }
60
61  /**
62   * the getWhere function must return a ready to use where clause
63   *
64   * "(att1 = value0 OR att2 = value1) AND att4 LIKE value2 "
65   */
66  static public function getWhere($param="")
67  {
68    global $user;
69
70    if($param['dateType']=='c')
71    {
72      $returned=" ase_pitd.date_creation ";
73    }
74    else
75    {
76      $returned=" ase_pitd.date_available ";
77    }
78
79    switch($param['searchType'])
80    {
81      case 'eq':
82        $returned.=" = '".$param['from']."' ";
83        break;
84      case 'bt':
85        $returned.=" BETWEEN '".$param['from']."' AND '".$param['to']."' ";
86        break;
87      case 'gt':
88        $returned.=" >= '".$param['from']."' ";
89        break;
90      case 'lt':
91        $returned.=" <= '".$param['to']."' ";
92        break;
93    }
94
95    return($returned);
96  }
97
98  /**
99   * the getJoin function must return a ready to use where allowing to join the
100   * IMAGES table (key : id) with given conditions
101   *
102   * "att3 = pit.id "
103   */
104  static public function getJoin($param="")
105  {
106    return("ase_pitd.id = pit.id");
107  }
108
109
110  /**
111   * the getFilter function must return a ready to use where clause
112   * this where clause is used to filter the cache when the used tables can
113   * return more than one result
114   *
115   * the filter can be empty, can be equal to the where clause, or can be equal
116   * to a sub part of the where clause
117   *
118   */
119  static public function getFilter($param="")
120  {
121    return("");
122  }
123
124  /**
125   * this function is called by the request builder, allowing to display plugin
126   * data with a specific format
127   *
128   * @param Array $attributes : array of ('attribute_name' => 'attribute_value')
129   * @return String : HTML formatted value
130   */
131  static public function formatData($attributes)
132  {
133    /* attributes is an array :
134     *    Array(
135     *      'csColors' => 'color1,color2,color3,...,colorN',
136     *      'csColorsPct' => 'pct1,pct2,pct3,...,pctN'
137     *    );
138     */
139    $returned="<span style='font-weight:bold;'>";
140    if(array_key_exists('dateCreation', $attributes))
141    {
142      $returned.=l10n('ase_dateCreation')."</span>&nbsp;:&nbsp;".$attributes['dateCreation'];
143    }
144    else
145    {
146      $returned.=l10n('ase_Available')."</span>&nbsp;:&nbsp;".$attributes['dateAvailable'];
147    }
148    return($returned);
149  }
150
151
152
153  /**
154   * this function is called by the request builder to make the search page, and
155   * must return the HTML & JS code of the dialogbox used to select criterion
156   *
157   * Notes :
158   *  - the dialogbox is a JS object with a public method 'show'
159   *  - when the method show is called, one parameter is given by the request
160   *    builder ; the parameter is an object defined as this :
161   *      {
162   *        cBuilder: an instance of the criteriaBuilder object used in the page,
163   *        eventOK : a callback function, called when the OK button is pushed
164   *        id:
165   *      }
166   *
167   *
168   *
169   *
170   * @param String $mode : can take 'admin' or 'public' values, allowing to
171   *                       return different interface if needed
172   * @return String : HTML formatted value
173   */
174  static public function getInterfaceContent($mode='admin')
175  {
176    return(ASE_functions::dialogBoxASEDate());
177  }
178
179  /**
180   * this function returns the label displayed in the criterion menu
181   *
182   * @return String : label displayed in the criterions menu
183   */
184  static public function getInterfaceLabel()
185  {
186    return(l10n('ase_add_date'));
187  }
188
189  /**
190   * this function returns the name of the dialog box class
191   *
192   * @return String : name of the dialogbox class
193   */
194  static public function getInterfaceDBClass()
195  {
196    return('dialogChooseASEDateBox');
197  }
198
199}
200
201?>
Note: See TracBrowser for help on using the repository browser.