1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | Piwigo - a PHP based picture gallery | |
---|
4 | // | Autosize | |
---|
5 | // +-----------------------------------------------------------------------+ |
---|
6 | // | Copyright(C) 2010 cljosse | |
---|
7 | // +-----------------------------------------------------------------------+ |
---|
8 | // | This program is free software; you can redistribute it and/or modify | |
---|
9 | // | it under the terms of the GNU General Public License as published by | |
---|
10 | // | the Free Software Foundation | |
---|
11 | // | | |
---|
12 | // | This program is distributed in the hope that it will be useful, but | |
---|
13 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
14 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
15 | // | General Public License for more details. | |
---|
16 | // | | |
---|
17 | // | You should have received a copy of the GNU General Public License | |
---|
18 | // | along with this program; if not, write to the Free Software | |
---|
19 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
20 | // | USA. | |
---|
21 | // +-----------------------------------------------------------------------+ |
---|
22 | class autosize_controler { |
---|
23 | //============================================================ |
---|
24 | /* |
---|
25 | * cl_autosize_script_1 |
---|
26 | */ |
---|
27 | static public function cl_autosize_script_1() |
---|
28 | { |
---|
29 | global $template,$user,$conf,$picture ,$page, $cl_plugin ; |
---|
30 | |
---|
31 | header ('X-UA-Compatible: n=7') ; |
---|
32 | header ('X-UA-Compatible: IE=Edge') ; |
---|
33 | if(isset($page['body_id']) && $page['body_id'] == 'theAdminPage' ) return ; |
---|
34 | |
---|
35 | if ('kardon' == $user['theme'] and isset($_GET['slideshow'])) return ; |
---|
36 | |
---|
37 | $ma_page=isset($page['body_id'])?$page['body_id']:"" ; |
---|
38 | if ($ma_page=='thePiwiShackControllerPage') return ; |
---|
39 | |
---|
40 | |
---|
41 | if (PHPWG_VERSION < 2.2 ) |
---|
42 | $file =AUTOSIZE_PATH_ABS.'template/header_2_1.tpl' ; |
---|
43 | else |
---|
44 | $file =AUTOSIZE_PATH_ABS.'template/header_2_2.tpl' ; |
---|
45 | $template->set_filenames(array('autosize_init_header'=> $file )); |
---|
46 | $template->set_filenames(array('autosize_init'=>AUTOSIZE_PATH_ABS. "template/conflit.tpl" ) ); |
---|
47 | //================================================================================================= |
---|
48 | $DEBUG_autosize = isset($_POST['cl_debug_conflit']) ? $_POST['cl_debug_conflit'] : "false" ; |
---|
49 | $DEBUG_autosize = isset($_GET['cl_debug_conflit']) ? $_GET['cl_debug_conflit'] : $DEBUG_autosize ; |
---|
50 | $DEBUG_autosize = isset($conf['cl_debug_conflit']) ? $conf['cl_debug_conflit'] : $DEBUG_autosize ; |
---|
51 | //================================================================================================= |
---|
52 | |
---|
53 | $autosize_parametres = cl_autosize_Get_Options() ; |
---|
54 | $theme=$user['theme']; |
---|
55 | $template->assign( |
---|
56 | array( |
---|
57 | 'autosize_parametres' => $autosize_parametres , |
---|
58 | 'cl_plugins' => $cl_plugin , |
---|
59 | 'cl_version' => $cl_plugin['version'] , |
---|
60 | 'name' => $cl_plugin['name'] , |
---|
61 | 'pamoorama' => isset($PAMOORAMICS_PATH)?"true":"false", |
---|
62 | 'theme' => $theme , |
---|
63 | 'DEBUG_autosize' => $DEBUG_autosize , |
---|
64 | 'AUTOSIZE_PATH' => str_replace("../","",AUTOSIZE_PATH) , |
---|
65 | 'AUTOSIZE_PATH_ABS' => AUTOSIZE_PATH_ABS, |
---|
66 | 'Version_pwg' => PHPWG_VERSION |
---|
67 | ) |
---|
68 | ); |
---|
69 | $template->concat('cl_conflit_init', $template->parse('autosize_init_header', true)); |
---|
70 | return $template->parse( 'autosize_init', false); |
---|
71 | }// function cl_autosize_script_1 |
---|
72 | //=========================================================== |
---|
73 | /* |
---|
74 | * cl_autosize_script_2(admin) |
---|
75 | */ |
---|
76 | static public function cl_autosize_script_2() |
---|
77 | { |
---|
78 | global $template,$user,$conf,$picture ,$page, $cl_plugin,$known_script ; |
---|
79 | if ('kardon' == $user['theme'] and isset($_GET['slideshow'])) return ; |
---|
80 | |
---|
81 | $AUTOSIZE_PATH = dirname(__FILE__).'/'; |
---|
82 | //================================================================================================= |
---|
83 | $DEBUG_autosize = isset($_POST['cl_debug_conflit']) ? $_POST['cl_debug_conflit'] : "false" ; |
---|
84 | $DEBUG_autosize = isset($_GET['cl_debug_conflit']) ? $_GET['cl_debug_conflit'] : $DEBUG_autosize ; |
---|
85 | $DEBUG_autosize = isset($conf['cl_debug_conflit']) ? $conf['cl_debug_conflit'] : $DEBUG_autosize ; |
---|
86 | //================================================================================================= |
---|
87 | |
---|
88 | |
---|
89 | $ma_page=isset($page['body_id'])?$page['body_id']:"" ; |
---|
90 | $theme=$user['theme']; |
---|
91 | if ($ma_page=='thePiwiShackControllerPage') return ; |
---|
92 | |
---|
93 | $template->assign( |
---|
94 | array( |
---|
95 | 'cl_version' => $cl_plugin['version'] , |
---|
96 | 'name' => $cl_plugin['name'] , |
---|
97 | 'ma_page' => $ma_page, |
---|
98 | |
---|
99 | 'theme' => $theme , |
---|
100 | 'DEBUG_autosize' => $DEBUG_autosize , |
---|
101 | 'AUTOSIZE_PATH' => AUTOSIZE_PATH |
---|
102 | ) |
---|
103 | ); |
---|
104 | |
---|
105 | $autoscript="<script type='text/javascript'> |
---|
106 | /* cl_autosize_script_2 */ |
---|
107 | if (typeof (save_framework) == 'function') |
---|
108 | save_framework('".$ma_page."'); |
---|
109 | </script>"; |
---|
110 | |
---|
111 | $autoscript .="<input id='ret_autosize' type='hidden' value='' />"; |
---|
112 | $autoscript .="<input id='src_img_h' type='hidden' value='' />"; |
---|
113 | $autoscript .="<input id='src_img_w' type='hidden' value='' />"; |
---|
114 | $autoscript .="<input id='window_height' type='hidden' value='' />"; |
---|
115 | $autoscript .="<input id='window_width' type='hidden' value='' />"; |
---|
116 | $autoscript .='<div id="Debug6" align=center style="display:none"></div>'; |
---|
117 | $template->append('footer_elements',$autoscript); |
---|
118 | return ; |
---|
119 | }// function cl_autosize_script_2 |
---|
120 | |
---|
121 | //================================================================ |
---|
122 | /* |
---|
123 | * cl_autosize_admin |
---|
124 | */ |
---|
125 | static public function cl_autosize_admin($menu) |
---|
126 | { |
---|
127 | global $lang ; |
---|
128 | array_push($menu, array('NAME' => 'Autosize', |
---|
129 | 'URL' => get_admin_plugin_menu_link(AUTOSIZE_PATH . 'admin/admin_autosize.php'))); |
---|
130 | return $menu; |
---|
131 | } //function cl_autosize_admin |
---|
132 | |
---|
133 | //=============================================================== |
---|
134 | /* |
---|
135 | * |
---|
136 | */ |
---|
137 | static public function cl_autosize_affiche() |
---|
138 | { |
---|
139 | global $user, $picture, $template,$page,$known_script; |
---|
140 | global $content, $element_info; |
---|
141 | global $infos_message,$erreur_message; |
---|
142 | global $conf,$lang ,$user,$userdata; |
---|
143 | if ('kardon' == $user['theme'] and isset($_GET['slideshow'])) return ; |
---|
144 | load_language('plugin.lang', AUTOSIZE_PATH); |
---|
145 | $AUTOSIZE_PATH = dirname(__FILE__).'/'; |
---|
146 | if (isset( $page['body_id']) && $page['body_id']=='thePicturePage' ) { |
---|
147 | if ( isset($picture['current'])){ |
---|
148 | $autosize_parametres = cl_autosize_Get_Options(); |
---|
149 | include (AUTOSIZE_PATH."include/affiche.php"); |
---|
150 | |
---|
151 | if (PHPWG_VERSION < 2.2 ) |
---|
152 | $file =AUTOSIZE_PATH_ABS.'template/picture_2_1.tpl' ; |
---|
153 | else |
---|
154 | $file =AUTOSIZE_PATH_ABS.'template/picture_2_2.tpl' ; |
---|
155 | |
---|
156 | |
---|
157 | |
---|
158 | $template->set_filenames(array('autosize_content_header'=> $file )); |
---|
159 | $template->concat('autosize_content', $template->parse('autosize_content_header', true)); |
---|
160 | |
---|
161 | $template->set_filenames(array('autosize_init_header'=> $file )); |
---|
162 | |
---|
163 | if($autosize_parametres->check_icon_v == 'on'){ |
---|
164 | $template->assign('cl_autosize_button', |
---|
165 | array( 'cl_autosize_info' => 'cl_autosize_info' , |
---|
166 | 'cl_autosize_info_2' => 'cl_autosize_info_2' , |
---|
167 | 'URL' => $_SERVER['REQUEST_URI'] , |
---|
168 | 'ICON2' => AUTOSIZE_PATH . 'icons/button-maximize.png', |
---|
169 | 'ICON' => AUTOSIZE_PATH . 'icons/button-minimize.png' |
---|
170 | ) |
---|
171 | |
---|
172 | ); |
---|
173 | $template->set_filenames(array('cl_bp' => $AUTOSIZE_PATH. 'template/picture.tpl')); |
---|
174 | $template->concat('PLUGIN_PICTURE_ACTIONS', $template->parse('cl_bp', true)); |
---|
175 | } |
---|
176 | $template->set_filenames( |
---|
177 | array('autosize_content'=> $AUTOSIZE_PATH.'template/autosize.tpl') |
---|
178 | ); |
---|
179 | $template->concat('autosize_content', $template->parse('autosize_content_header', true)); |
---|
180 | if(isset($conf['go_up_down']) && ($conf['go_up_down']==true) ){ |
---|
181 | $template->set_filenames(array('mes_script' => realpath(AUTOSIZE_PATH).'/template/mes_scripts.tpl') ); |
---|
182 | $template->func_combine_script(array('id'=>'my_script_2', |
---|
183 | 'path'=> AUTOSIZE_PATH.'/js/JScript.js', |
---|
184 | 'require' => 'jquery'), |
---|
185 | $template->smarty); |
---|
186 | $template->assign(array( |
---|
187 | 'MY_FOOTER_PATH' =>AUTOSIZE_PATH |
---|
188 | )); |
---|
189 | |
---|
190 | $template->parse('mes_script'); |
---|
191 | } |
---|
192 | |
---|
193 | |
---|
194 | |
---|
195 | return $template->parse( 'autosize_content', false); |
---|
196 | } |
---|
197 | } |
---|
198 | |
---|
199 | } //public function cl_autosize_affiche |
---|
200 | //=============================================================== |
---|
201 | /* |
---|
202 | * |
---|
203 | */ |
---|
204 | static public function cl_autosize_aff_infos_plus() |
---|
205 | { |
---|
206 | global $template,$infos_message,$erreur_message, $user ; |
---|
207 | global $conf,$lang ; |
---|
208 | |
---|
209 | //============================================================== |
---|
210 | if (isset($erreur_message)) |
---|
211 | { |
---|
212 | if ($erreur_message <> "") |
---|
213 | { |
---|
214 | $erreur_message=str_replace("\n",'<br />',$erreur_message) ; |
---|
215 | $template->assign('errors',$erreur_message); |
---|
216 | $erreur_message=""; |
---|
217 | } |
---|
218 | } |
---|
219 | if (isset($infos_message)) |
---|
220 | { |
---|
221 | |
---|
222 | if ($infos_message <> "") |
---|
223 | { |
---|
224 | $infos_message=str_replace("\n",'<br />',$infos_message) ; |
---|
225 | $template->assign('infos',$infos_message); |
---|
226 | $infos_message=""; |
---|
227 | } |
---|
228 | } |
---|
229 | //============================================================= |
---|
230 | return; |
---|
231 | |
---|
232 | } // function cl_autosize_aff_infos_plus |
---|
233 | //=============================================================== |
---|
234 | /* |
---|
235 | * |
---|
236 | */ |
---|
237 | static public function cl_ajuste_data($content){ |
---|
238 | global $template,$user,$conf,$picture ; |
---|
239 | $AUTOSIZE_PATH = realpath(AUTOSIZE_PATH .'/'); |
---|
240 | $userdata=$user; |
---|
241 | $fields = array( 'maxwidth', 'maxheight' ); |
---|
242 | |
---|
243 | $ThePicture = $template->get_template_vars('current'); |
---|
244 | $data = array(); |
---|
245 | return $content; |
---|
246 | |
---|
247 | $data['maxwidth'] = '1200'; |
---|
248 | $data['maxheight'] ='250'; |
---|
249 | $data['user_id'] = $userdata['id']; |
---|
250 | foreach ($fields as $field) |
---|
251 | { |
---|
252 | if (isset($_POST[$field])) |
---|
253 | { |
---|
254 | $data[$field] = $_POST[$field]; |
---|
255 | } |
---|
256 | } |
---|
257 | |
---|
258 | if($data['maxwidth'] != "" ) |
---|
259 | { |
---|
260 | $picture['current']['scaled_width']=$data['maxwidth']; |
---|
261 | $picture['current']['scaled_height']=$data['maxheight']; |
---|
262 | mass_updates(USER_INFOS_TABLE, |
---|
263 | array('primary' => array('user_id'), 'update' => $fields), |
---|
264 | array($data)); |
---|
265 | } |
---|
266 | |
---|
267 | return $content; |
---|
268 | } |
---|
269 | |
---|
270 | } // class |
---|
271 | |
---|
272 | |
---|
273 | /* |
---|
274 | * |
---|
275 | */ |
---|
276 | function cl_autosize_Get_Options() |
---|
277 | { |
---|
278 | global $conf,$autosize_parametres; |
---|
279 | $autosize_parametres = unserialize($conf['cl_autosize']); |
---|
280 | $autosize_parametres = cl_autosize_Set_Options(); |
---|
281 | return $autosize_parametres; |
---|
282 | } |
---|
283 | /* |
---|
284 | * |
---|
285 | */ |
---|
286 | function cl_autosize_Set_Options() |
---|
287 | { |
---|
288 | |
---|
289 | global $autosize_parametres; |
---|
290 | //============================================================================= |
---|
291 | $my_para=$autosize_parametres; |
---|
292 | |
---|
293 | $my_para->query =(isset($_POST['query'])) ? $_POST['query'] : ((isset($my_para->query )) ? $my_para->query : 'Qt' ) ; |
---|
294 | $my_para->type=(isset($_POST['type']))? $_POST['type']: ((isset($my_para->type)) ? $my_para->type: 'Ty') ; |
---|
295 | |
---|
296 | $my_para->webmaster_height =(isset($_POST['webmaster_height'])) ? $_POST['webmaster_height'] : ((isset($my_para->webmaster_height )) ? $my_para->webmaster_height : '100%' ) ; |
---|
297 | $my_para->webmaster_width=(isset($_POST['webmaster_width']))? $_POST['webmaster_width']: ((isset($my_para->webmaster_width)) ? $my_para->webmaster_width: '100%') ; |
---|
298 | |
---|
299 | $my_para->admin_height =(isset($_POST['admin_height'])) ? $_POST['admin_height'] : ((isset($my_para->admin_height )) ? $my_para->admin_height : '100%' ) ; |
---|
300 | $my_para->admin_width=(isset($_POST['admin_width']))? $_POST['admin_width']: ((isset($my_para->admin_width)) ? $my_para->admin_width: '100%') ; |
---|
301 | |
---|
302 | $my_para->generic_height =(isset($_POST['generic_height'])) ? $_POST['generic_height'] : ((isset($my_para->generic_height )) ? $my_para->generic_height : '100%' ) ; |
---|
303 | $my_para->generic_width=(isset($_POST['generic_width']))? $_POST['generic_width']: ((isset($my_para->generic_width)) ? $my_para->generic_width: '100%') ; |
---|
304 | |
---|
305 | $my_para->guest_height =(isset($_POST['guest_height'])) ? $_POST['guest_height'] : ((isset($my_para->guest_height )) ? $my_para->guest_height : '100%' ) ; |
---|
306 | $my_para->guest_width=(isset($_POST['guest_width']))? $_POST['guest_width']: ((isset($my_para->guest_width)) ? $my_para->guest_width: '100%') ; |
---|
307 | |
---|
308 | $my_para->normal_height =(isset($_POST['normal_height'])) ? $_POST['normal_height'] : ((isset($my_para->normal_height )) ? $my_para->normal_height : '100%' ) ; |
---|
309 | $my_para->normal_width=(isset($_POST['normal_width']))? $_POST['normal_width']: ((isset($my_para->normal_width)) ? $my_para->normal_width: '100%') ; |
---|
310 | |
---|
311 | |
---|
312 | $my_para->mini_height =(isset($_POST['mini_height'])) ? $_POST['mini_height'] : ((isset($my_para->mini_height )) ? $my_para->mini_height : '150' ) ; |
---|
313 | $my_para->mini_width=(isset($_POST['mini_width']))? $_POST['mini_width']: ((isset($my_para->mini_width)) ? $my_para->mini_width: '300') ; |
---|
314 | |
---|
315 | $my_para->mini_height2 =(isset($_POST['mini_height2'])) ? $_POST['mini_height2'] : ((isset($my_para->mini_height2 )) ? $my_para->mini_height2 : '150' ) ; |
---|
316 | $my_para->mini_width2=(isset($_POST['mini_width2']))? $_POST['mini_width2']: ((isset($my_para->mini_width2)) ? $my_para->mini_width2: '300') ; |
---|
317 | |
---|
318 | $my_para->echelle_max=(isset($_POST['echelle_max']))? $_POST['echelle_max'] : ((isset($my_para->echelle_max)) ? $my_para->echelle_max : '1.0'); |
---|
319 | $my_para->marge_basse=(isset($_POST['marge_basse']))? $_POST['marge_basse']: ((isset($my_para->marge_basse)) ? $my_para->marge_basse : '0'); |
---|
320 | $my_para->fade_in=(isset($_POST['fade_in']))? $_POST['fade_in']: ((isset($my_para->fade_in)) ? $my_para->fade_in : '0'); |
---|
321 | |
---|
322 | //=============================================================================== |
---|
323 | |
---|
324 | if ( isset($_POST['submit'] ) && $_POST['submit'] == l10n('cl_autosize_save') ) { |
---|
325 | $my_para->check_desc_v = isset($_POST['check_desc_v']) ? $_POST['check_desc_v'] : "off" ; |
---|
326 | $my_para->check_icon_v = isset($_POST['check_icon_v']) ? $_POST['check_icon_v'] : "off" ; |
---|
327 | $my_para->check_auto_w = isset($_POST['check_auto_w']) ? $_POST['check_auto_w'] : "off" ; |
---|
328 | |
---|
329 | $my_para->webmaster_enabled = isset($_POST['webmaster_enabled']) ? $_POST['webmaster_enabled'] : "off" ; |
---|
330 | $my_para->admin_enabled = isset($_POST['admin_enabled']) ? $_POST['admin_enabled'] : "off" ; |
---|
331 | $my_para->generic_enabled = isset($_POST['generic_enabled']) ? $_POST['generic_enabled'] : "off" ; |
---|
332 | $my_para->guest_enabled = isset($_POST['guest_enabled']) ? $_POST['guest_enabled'] : "off" ; |
---|
333 | $my_para->normal_enabled = isset($_POST['normal_enabled']) ? $_POST['normal_enabled'] : "off" ; |
---|
334 | |
---|
335 | }else{ |
---|
336 | $my_para->check_desc_v = isset($_POST['check_desc_v']) ? $_POST['check_desc_v'] : ( ( isset($my_para->check_desc_v) ) ? $my_para->check_desc_v : 'off') ; |
---|
337 | $my_para->check_icon_v = isset($_POST['check_icon_v']) ? $_POST['check_icon_v'] : ( ( isset($my_para->check_icon_v) ) ? $my_para->check_icon_v : 'off') ; |
---|
338 | $my_para->check_auto_w = isset($_POST['check_auto_w']) ? $_POST['check_auto_w'] : ( ( isset($my_para->check_auto_w) ) ? $my_para->check_auto_w : 'off') ; |
---|
339 | |
---|
340 | |
---|
341 | $my_para->webmaster_enabled = isset($_POST['webmaster_enabled']) ? $_POST['webmaster_enabled'] : ( ( isset($my_para->webmaster_enabled) ) ? $my_para->webmaster_enabled : 'on') ; |
---|
342 | $my_para->admin_enabled = isset($_POST['admin_enabled ']) ? $_POST['admin_enabled '] : ( ( isset($my_para->admin_enabled ) ) ? $my_para->admin_enabled : 'on') ; |
---|
343 | $my_para->generic_enabled = isset($_POST['generic_enabled']) ? $_POST['generic_enabled'] : ( ( isset($my_para->generic_enabled) ) ? $my_para->generic_enabled : 'on') ; |
---|
344 | $my_para->guest_enabled = isset($_POST['guest_enabled']) ? $_POST['guest_enabled'] : ( ( isset($my_para->guest_enabled) ) ? $my_para->guest_enabled : 'on') ; |
---|
345 | $my_para->normal_enabled = isset($_POST['normal_enabled']) ? $_POST['normal_enabled'] : ( ( isset($my_para->normal_enabled) ) ? $my_para->normal_enabled : 'on') ; |
---|
346 | |
---|
347 | |
---|
348 | } |
---|
349 | |
---|
350 | return $my_para; |
---|
351 | } |
---|
352 | /* |
---|
353 | * |
---|
354 | */ |
---|
355 | function cl_autosize_sauve_options_inf() |
---|
356 | { |
---|
357 | global $options,$infos_message,$conf,$autosize_parametres ; |
---|
358 | $infos_message .=l10n("cl_autosize_save_config")."<br>"; |
---|
359 | $autosize_parametres=cl_autosize_Set_Options(); |
---|
360 | |
---|
361 | if ( isset($autosize_parametres) ) |
---|
362 | { |
---|
363 | |
---|
364 | $query = ' |
---|
365 | UPDATE '.CONFIG_TABLE.' |
---|
366 | SET value="'.addslashes(serialize($autosize_parametres)).'" |
---|
367 | WHERE param = "cl_autosize" |
---|
368 | LIMIT 1'; |
---|
369 | pwg_query($query); |
---|
370 | } |
---|
371 | |
---|
372 | } |
---|
373 | |
---|
374 | function auto_memo_var($variables) |
---|
375 | { |
---|
376 | ob_start(); |
---|
377 | echo '<pre>'; |
---|
378 | print_r($variables); |
---|
379 | echo '</pre>'; |
---|
380 | $m= ob_get_contents(); |
---|
381 | ob_end_clean(); |
---|
382 | return $m; |
---|
383 | } |
---|
384 | |
---|
385 | |
---|
386 | ?> |
---|