source: extensions/ASearchEngine/ase_rb_callback_tag.class.inc.php

Last change on this file was 7374, checked in by grum, 10 years ago

Add search by tag ; improve css theming ; add en_Uk language

  • Property svn:executable set to *
File size: 5.2 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 RBCallBackASETag 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_pitt.image_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    $returned=" ase_ptt.name AS tagName, ase_ptt.id AS tagId ";
40    return($returned);
41  }
42
43  /**
44   * the getFrom function must return a tables list separated with a comma
45   *
46   * "table1, (table2 left join table3 on table2.key = table3.key), table4"
47   */
48  static public function getFrom($param="")
49  {
50    global $prefixeTable;
51
52    return(IMAGE_TAG_TABLE." ase_pitt
53            JOIN ".TAGS_TABLE." ase_ptt
54            ON ase_ptt.id = ase_pitt.tag_id ");
55  }
56
57  /**
58   * the getWhere function must return a ready to use where clause
59   *
60   * "(att1 = value0 OR att2 = value1) AND att4 LIKE value2 "
61   */
62  static public function getWhere($param="")
63  {
64    global $user;
65
66    $returned='';
67    if($param['method']=='OR')
68    {
69      $list=array();
70      foreach($param['tags'] as $tag)
71      {
72        $list[]=$tag['id'];
73      }
74      $returned=" ase_pitt.tag_id IN (".implode(',', $list).")";
75    }
76    return($returned);
77  }
78
79
80  /**
81   * the getHaving function return a ready to user HAVING clause
82   *
83   * " FIND_IN_SET(value0, GROUP_CONCAT(DISTINCT att1 SEPARATOR ',')) AND
84   *   FIND_IN_SET(value0, GROUP_CONCAT(DISTINCT att1 SEPARATOR ',')) "
85   *
86   */
87  static public function getHaving($param="")
88  {
89    $returned='';
90    if($param['method']=='AND')
91    {
92      $tmp=array();
93      foreach($param['tags'] as $tag)
94      {
95        $tmp[]=" FIND_IN_SET(".$tag['id'].", GROUP_CONCAT(DISTINCT ase_pitt.tag_id SEPARATOR ',')) ";
96      }
97      $returned=implode(' AND ', $tmp);
98    }
99    return($returned);
100  }
101
102
103  /**
104   * the getJoin function must return a ready to use where allowing to join the
105   * IMAGES table (key : id) with given conditions
106   *
107   * "att3 = pit.id "
108   */
109  static public function getJoin($param="")
110  {
111    return("ase_pitt.image_id = pit.id");
112  }
113
114
115  /**
116   * the getFilter function must return a ready to use where clause
117   * this where clause is used to filter the cache when the used tables can
118   * return more than one result
119   *
120   * the filter can be empty, can be equal to the where clause, or can be equal
121   * to a sub part of the where clause
122   *
123   */
124  static public function getFilter($param="")
125  {
126    return("");
127  }
128
129  /**
130   * this function is called by the request builder, allowing to display plugin
131   * data with a specific format
132   *
133   * @param Array $attributes : array of ('attribute_name' => 'attribute_value')
134   * @return String : HTML formatted value
135   */
136  static public function formatData($attributes)
137  {
138    /* attributes is an array :
139     *    Array(
140     *      'csColors' => 'color1,color2,color3,...,colorN',
141     *      'csColorsPct' => 'pct1,pct2,pct3,...,pctN'
142     *    );
143     */
144    $returned="<span style='font-weight:bold;'>".l10n('ase_tags')."</span>&nbsp;:&nbsp;";
145    $attributes['tagName']=str_replace('#sep#', ', ', $attributes['tagName']);
146    $returned.=$attributes['tagName'];
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::dialogBoxASETag());
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_tag'));
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('dialogChooseASETagBox');
197  }
198
199}
200
201?>
Note: See TracBrowser for help on using the repository browser.