1 | <?php |
---|
2 | /* ----------------------------------------------------------------------------- |
---|
3 | Plugin : LMT |
---|
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/GPCCore.class.inc.php'); |
---|
18 | include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCRequestBuilder.class.inc.php'); |
---|
19 | |
---|
20 | load_language('plugin.lang', LMT_PATH); |
---|
21 | |
---|
22 | class RBCallBackLMT extends GPCSearchCallback { |
---|
23 | static public $lmtDefaultLicence=''; |
---|
24 | |
---|
25 | static public function init() |
---|
26 | { |
---|
27 | $config=array(); |
---|
28 | GPCCore::loadConfig('lmt', $config); |
---|
29 | |
---|
30 | self::$lmtDefaultLicence=$config['lmt_licence_default']; |
---|
31 | } |
---|
32 | |
---|
33 | /** |
---|
34 | * the getImageId returns the name of the image id attribute |
---|
35 | * return String |
---|
36 | */ |
---|
37 | static public function getImageId() |
---|
38 | { |
---|
39 | return("pit2.id"); |
---|
40 | } |
---|
41 | |
---|
42 | /** |
---|
43 | * the getSelect function must return an attribute list separated with a comma |
---|
44 | * |
---|
45 | * "att1, att2, att3, att4" |
---|
46 | */ |
---|
47 | static public function getSelect($param="") |
---|
48 | { |
---|
49 | //return("IF(pli.licence_type IS NULL, '".self::$lmtDefaultLicence."', pli.licence_type) AS imgLicence"); |
---|
50 | return("pli.licence_type"); |
---|
51 | } |
---|
52 | |
---|
53 | /** |
---|
54 | * the getFrom function must return a tables list separated with a comma |
---|
55 | * |
---|
56 | * "table1, (table2 left join table3 on table2.key = table3.key), table4" |
---|
57 | */ |
---|
58 | static public function getFrom($param="") |
---|
59 | { |
---|
60 | global $prefixeTable; |
---|
61 | |
---|
62 | return($prefixeTable."lmt_images pli |
---|
63 | RIGHT JOIN ".IMAGES_TABLE." pit2 ON pit2.id = pli.image_id "); |
---|
64 | } |
---|
65 | |
---|
66 | /** |
---|
67 | * the getWhere function must return a ready to use where clause |
---|
68 | * |
---|
69 | * "(att1 = value0 OR att2 = value1) AND att4 LIKE value2 " |
---|
70 | */ |
---|
71 | static public function getWhere($param="") |
---|
72 | { |
---|
73 | global $user, $prefixeTable; |
---|
74 | |
---|
75 | $returned=array(); |
---|
76 | |
---|
77 | foreach($param['licences'] as $val) |
---|
78 | { |
---|
79 | $returned[]="pli.licence_type = '$val'"; |
---|
80 | |
---|
81 | if($val==self::$lmtDefaultLicence) |
---|
82 | { |
---|
83 | $returned[]="pit2.id NOT IN (SELECT image_id FROM ".$prefixeTable."lmt_images)"; |
---|
84 | } |
---|
85 | } |
---|
86 | |
---|
87 | $returned=' '.implode(' OR ', $returned).' '; |
---|
88 | |
---|
89 | return($returned); |
---|
90 | } |
---|
91 | |
---|
92 | /** |
---|
93 | * the getJoin function must return a ready to use where allowing to join the |
---|
94 | * IMAGES table (key : id) with given conditions |
---|
95 | * |
---|
96 | * "att3 = pit.id " |
---|
97 | */ |
---|
98 | static public function getJoin($param="") |
---|
99 | { |
---|
100 | return("pit2.id = pit.id"); |
---|
101 | } |
---|
102 | |
---|
103 | |
---|
104 | /** |
---|
105 | * the getFilter function must return a ready to use where clause |
---|
106 | * this where clause is used to filter the cache when the used tables can |
---|
107 | * return more than one result |
---|
108 | * |
---|
109 | * the filter can be empty, can be equal to the where clause, or can be equal |
---|
110 | * to a sub part of the where clause |
---|
111 | * |
---|
112 | */ |
---|
113 | static public function getFilter($param="") |
---|
114 | { |
---|
115 | return(''); |
---|
116 | } |
---|
117 | |
---|
118 | /** |
---|
119 | * this function is called by the request builder, allowing to display plugin |
---|
120 | * data with a specific format |
---|
121 | * |
---|
122 | * @param Array $attributes : array of ('attribute_name' => 'attribute_value') |
---|
123 | * @return String : HTML formatted value |
---|
124 | */ |
---|
125 | static public function formatData($attributes) |
---|
126 | { |
---|
127 | /* attributes is an array : |
---|
128 | * Array( |
---|
129 | * 'csColors' => 'color1,color2,color3,...,colorN', |
---|
130 | * 'csColorsPct' => 'pct1,pct2,pct3,...,pctN' |
---|
131 | * ); |
---|
132 | */ |
---|
133 | if($attributes['licence_type']=='') $attributes['licence_type']=self::$lmtDefaultLicence; |
---|
134 | $returned="<img class='imgLicence' src='./plugins/lmt/img/".strtolower($attributes['licence_type'])."_80x15.png'> ".l10n('lmt_lbl_cc_s-'.strtolower($attributes['licence_type'])); |
---|
135 | |
---|
136 | return($returned); |
---|
137 | } |
---|
138 | |
---|
139 | |
---|
140 | |
---|
141 | /** |
---|
142 | * this function is called by the request builder to make the search page, and |
---|
143 | * must return the HTML & JS code of the dialogbox used to select criterion |
---|
144 | * |
---|
145 | * Notes : |
---|
146 | * - the dialogbox is a JS object with a public method 'show' |
---|
147 | * - when the method show is called, one parameter is given by the request |
---|
148 | * builder ; the parameter is an object defined as this : |
---|
149 | * { |
---|
150 | * cBuilder: an instance of the criteriaBuilder object used in the page, |
---|
151 | * eventOK : a callback function, called when the OK button is pushed |
---|
152 | * id: |
---|
153 | * } |
---|
154 | * |
---|
155 | * |
---|
156 | * |
---|
157 | * |
---|
158 | * @param String $mode : can take 'admin' or 'public' values, allowing to |
---|
159 | * return different interface if needed |
---|
160 | * @return String : HTML formatted value |
---|
161 | */ |
---|
162 | static public function getInterfaceContent($mode='admin') |
---|
163 | { |
---|
164 | return(LMT_functions::dialogBoxLMT()); |
---|
165 | } |
---|
166 | |
---|
167 | /** |
---|
168 | * this function returns the label displayed in the criterion menu |
---|
169 | * |
---|
170 | * @return String : label displayed in the criterions menu |
---|
171 | */ |
---|
172 | static public function getInterfaceLabel() |
---|
173 | { |
---|
174 | return(l10n('lmt_add_licence_type')); |
---|
175 | } |
---|
176 | |
---|
177 | /** |
---|
178 | * this function returns the name of the dialog box class |
---|
179 | * |
---|
180 | * @return String : name of the dialogbox class |
---|
181 | */ |
---|
182 | static public function getInterfaceDBClass() |
---|
183 | { |
---|
184 | return('dialogChooseLMTBox'); |
---|
185 | } |
---|
186 | } |
---|
187 | |
---|
188 | RBCallBackLMT::init(); |
---|
189 | |
---|
190 | |
---|
191 | ?> |
---|