source: extensions/ASearchEngine/ase_rb_callback_category.class.inc.php @ 13371

Last change on this file since 13371 was 7328, checked in by grum, 14 years ago

fix bugs, add functionnalities and update css

  • Property svn:executable set to *
File size: 4.9 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 RBCallBackASECategory 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_pict.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    return(" ase_pct.id AS categoryId, ase_pct.name AS categoryName");
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, $user;
50
51    return("((".IMAGE_CATEGORY_TABLE." ase_pict JOIN ".CATEGORIES_TABLE." ase_pct
52      ON ase_pict.category_id = ase_pct.id) JOIN ".USER_CACHE_CATEGORIES_TABLE." ase_pucc ON ase_pucc.cat_id = ase_pct.id AND ase_pucc.user_id='".$user['id']."') ");
53  }
54
55  /**
56   * the getWhere function must return a ready to use where clause
57   *
58   * "(att1 = value0 OR att2 = value1) AND att4 LIKE value2 "
59   */
60  static public function getWhere($param="")
61  {
62    global $user;
63
64    $returned=array();
65    if($param['subCat']=='y')
66    {
67      foreach($param['catIdList'] as $catId)
68      {
69        $returned[]=" FIND_IN_SET($catId, ase_pct.uppercats) ";
70      }
71    }
72
73    return(implode(' OR ', $returned));
74  }
75
76  /**
77   * the getJoin function must return a ready to use where allowing to join the
78   * IMAGES table (key : id) with given conditions
79   *
80   * "att3 = pit.id "
81   */
82  static public function getJoin($param="")
83  {
84    return("ase_pict.image_id = pit.id");
85  }
86
87
88  /**
89   * the getFilter function must return a ready to use where clause
90   * this where clause is used to filter the cache when the used tables can
91   * return more than one result
92   *
93   * the filter can be empty, can be equal to the where clause, or can be equal
94   * to a sub part of the where clause
95   *
96   */
97  static public function getFilter($param="")
98  {
99    return("");
100  }
101
102  /**
103   * this function is called by the request builder, allowing to display plugin
104   * data with a specific format
105   *
106   * @param Array $attributes : array of ('attribute_name' => 'attribute_value')
107   * @return String : HTML formatted value
108   */
109  static public function formatData($attributes)
110  {
111    /* attributes is an array :
112     *    Array(
113     *      'csColors' => 'color1,color2,color3,...,colorN',
114     *      'csColorsPct' => 'pct1,pct2,pct3,...,pctN'
115     *    );
116     */
117    if(strpos($attributes['categoryName'], '#sep#')>0)
118    {
119      $cat=l10n('Categories');
120      $attributes['categoryName']=str_replace('#sep#', ', ', $attributes['categoryName']);
121    }
122    else
123    {
124      $cat=l10n('Category');
125    }
126    $returned="<span style='font-weight:bold;'>$cat</span>&nbsp;:&nbsp;".$attributes['categoryName'];
127
128    return($returned);
129  }
130
131
132
133  /**
134   * this function is called by the request builder to make the search page, and
135   * must return the HTML & JS code of the dialogbox used to select criterion
136   *
137   * Notes :
138   *  - the dialogbox is a JS object with a public method 'show'
139   *  - when the method show is called, one parameter is given by the request
140   *    builder ; the parameter is an object defined as this :
141   *      {
142   *        cBuilder: an instance of the criteriaBuilder object used in the page,
143   *        eventOK : a callback function, called when the OK button is pushed
144   *        id:
145   *      }
146   *
147   *
148   *
149   *
150   * @param String $mode : can take 'admin' or 'public' values, allowing to
151   *                       return different interface if needed
152   * @return String : HTML formatted value
153   */
154  static public function getInterfaceContent($mode='admin')
155  {
156    return(ASE_functions::dialogBoxASECategory());
157  }
158
159  /**
160   * this function returns the label displayed in the criterion menu
161   *
162   * @return String : label displayed in the criterions menu
163   */
164  static public function getInterfaceLabel()
165  {
166    return(l10n('ase_add_category'));
167  }
168
169  /**
170   * this function returns the name of the dialog box class
171   *
172   * @return String : name of the dialogbox class
173   */
174  static public function getInterfaceDBClass()
175  {
176    return('dialogChooseASECategoryBox');
177  }
178
179}
180
181?>
Note: See TracBrowser for help on using the repository browser.