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 | * cl_autosize_admin |
---|
25 | **********************************/ |
---|
26 | static public function cl_autosize_admin($menu) { |
---|
27 | global $lang ; |
---|
28 | array_push($menu, array('NAME' => 'Autosize', |
---|
29 | 'URL' => get_admin_plugin_menu_link(AUTOSIZE_PATH . 'admin/admin_autosize.php'))); |
---|
30 | return $menu; |
---|
31 | } //function cl_autosize_admin |
---|
32 | |
---|
33 | |
---|
34 | /************************** |
---|
35 | * autosize_calcContent * |
---|
36 | **************************/ |
---|
37 | static public function autosize_calcContent($content,$element_info){ |
---|
38 | |
---|
39 | global $conf,$page, $template,$picture,$user; |
---|
40 | global $defined_types,$pictureSelType ,$pictureDeriv ,$liste_type,$SRC_IMG; |
---|
41 | global $autosize_parametres,$user_status; |
---|
42 | global $infos_message,$error_message; |
---|
43 | //============================================================================== |
---|
44 | global $DEBUG_autosize; |
---|
45 | $DEBUG_autosize = isset($_POST['cl_debug']) ? $_POST['cl_debug'] : "false" ; |
---|
46 | $DEBUG_autosize = isset($_GET['cl_debug']) ? $_GET['cl_debug'] : $DEBUG_autosize ; |
---|
47 | $DEBUG_autosize = isset($conf['cl_debug']) ? $conf['cl_debug'] : $DEBUG_autosize ; |
---|
48 | //=============================================================== |
---|
49 | $ma_page=isset($page['body_id'])?$page['body_id']:"" ; |
---|
50 | if ($ma_page !='thePicturePage') return ; |
---|
51 | |
---|
52 | $types = array_intersect(array_keys(ImageStdParams::get_defined_type_map()), array("Autosize","SelMaxi")); |
---|
53 | if (count($types)==0){ |
---|
54 | include_once (AUTOSIZE_PATH.'maintain.inc.php'); |
---|
55 | if (isset($conf['cl_derivatives_sav'])) { |
---|
56 | plugin_deactivate() ; |
---|
57 | } |
---|
58 | plugin_activate(); |
---|
59 | unset ( $_COOKIE['autosize_reload']) ; |
---|
60 | } |
---|
61 | |
---|
62 | if (!isset($_COOKIE['autosize_reload'])){ |
---|
63 | autosize_controler::reload(); |
---|
64 | |
---|
65 | } |
---|
66 | //=================================================================== |
---|
67 | $current = $template->get_template_vars('current'); |
---|
68 | if (!isset($current)) return ; |
---|
69 | //=============================================================== |
---|
70 | global $imgSizeWH; |
---|
71 | $derivative = $current['src_image'] ; |
---|
72 | $imgSizeWH = $derivative->get_size(); |
---|
73 | $SRC_IMG = $derivative->get_url(); |
---|
74 | |
---|
75 | $picture['current']['scaled_width']=$imgSizeWH[0]; |
---|
76 | $picture['current']['scaled_height']= $imgSizeWH[1]; |
---|
77 | $picture['current']['high_url']= $SRC_IMG; |
---|
78 | $picture['current']['image_url']=$SRC_IMG; |
---|
79 | //=============================================================== |
---|
80 | global $infos_message; |
---|
81 | |
---|
82 | //============================================================== |
---|
83 | $autosize_parametres = cl_autosize_Get_Options(); |
---|
84 | return false ; |
---|
85 | }//calc_content ; |
---|
86 | |
---|
87 | |
---|
88 | |
---|
89 | /********************* |
---|
90 | * INIT |
---|
91 | *********************/ |
---|
92 | static public function init($content,$element_info){ |
---|
93 | |
---|
94 | |
---|
95 | global $template,$version,$icon_path,$page,$picture,$conf; |
---|
96 | global $user,$Css,$css_slideshow,$css_display,$liste_type; |
---|
97 | global $has_pamoorama,$pictureSelType,$pictureDeriv; |
---|
98 | global $infos_message,$warnings_message; |
---|
99 | //======================================================= |
---|
100 | global $has_pamoorama ; |
---|
101 | $has_pamoorama = isset($template->files['pamooramics_content'])?"true":"false"; |
---|
102 | $theme=$user['theme']; |
---|
103 | $Css = autosize_controler::css($theme."-rules.css"); |
---|
104 | |
---|
105 | $css_slideshow=isset($Css['.Autosize']['slideshow'])?$Css['.Autosize']['slideshow']:"yes"; |
---|
106 | $css_display= isset($Css['.Autosize']['display'])?$Css['.Autosize']['display']:"block"; |
---|
107 | //============================================================== |
---|
108 | $pictureDeriv = pwg_get_session_var('picture_deriv',$conf['derivative_default_size']); |
---|
109 | $default_size = $conf['derivative_default_size']; |
---|
110 | $autosize_parametres = cl_autosize_Get_Options(); |
---|
111 | //======================================================================= |
---|
112 | $pictureSelType = pwg_get_session_var('picture_sel_type',$pictureSelType); |
---|
113 | |
---|
114 | if(!isset($_COOKIE['picture_sel_type'])){ |
---|
115 | if($autosize_parametres->defaut_type=="off") |
---|
116 | $pictureSelType = pwg_get_session_var('picture_sel_type',"SelMaxi"); |
---|
117 | else |
---|
118 | $pictureSelType = pwg_get_session_var('picture_sel_type',"Autosize"); |
---|
119 | |
---|
120 | }else{ |
---|
121 | $pictureSelType = $_COOKIE['picture_sel_type'] ; |
---|
122 | } |
---|
123 | |
---|
124 | //===================================================================== |
---|
125 | |
---|
126 | $current = $template->get_template_vars('current'); |
---|
127 | |
---|
128 | global $set_miniature,$imgSizeWH,$DEBUG_autosize; |
---|
129 | global $theImageHeight,$theImageWidth,$theMainImageWidth; |
---|
130 | //=== Zone affichage == |
---|
131 | $theImageTop= isset($_COOKIE['theImageTop'])?$_COOKIE['theImageTop']:0; |
---|
132 | $theImageLeft=isset($_COOKIE['theImageLeft'])?$_COOKIE['theImageLeft']:0; |
---|
133 | |
---|
134 | $theImageRight=isset($_COOKIE['theImageRight'])?$_COOKIE['theImageRight']:0; |
---|
135 | $theImageBottom=isset($_COOKIE['theImageBottom'])?$_COOKIE['theImageBottom']:0; |
---|
136 | |
---|
137 | $windowWidth=$_COOKIE['windowWidth']; |
---|
138 | $windowHeight=$_COOKIE['windowHeight']; |
---|
139 | |
---|
140 | $theImageMargeWidth=isset($_COOKIE['theImageMargeWidth']) ? $_COOKIE['theImageMargeWidth']:0; |
---|
141 | $theImageMargeHeight=isset($_COOKIE['theImageMargeHeight'])?$_COOKIE['theImageMargeHeight']:0; |
---|
142 | |
---|
143 | $theImageWidth= $windowWidth - $theImageRight - $theImageLeft - $theImageMargeWidth; |
---|
144 | $theImageHeight= $windowHeight - $theImageTop - $theImageBottom - $theImageMargeHeight; |
---|
145 | $theImageWidth=isset($_COOKIE['theImageWidth']) ? $_COOKIE['theImageWidth']:$theImageWidth; |
---|
146 | $theImageHeight=isset($_COOKIE['theImageHeight'])?$_COOKIE['theImageHeight']:$theImageHeight; |
---|
147 | |
---|
148 | $retour= autosize_controler::get_min_max() ; |
---|
149 | |
---|
150 | if($theImageHeight!=0 && $theImageWidth!=0){ |
---|
151 | $pictureDeriv=$retour->type ; |
---|
152 | }else{ |
---|
153 | $pictureDeriv=$default_size; |
---|
154 | } |
---|
155 | |
---|
156 | //============================================================ |
---|
157 | pwg_set_session_var('picture_deriv',$pictureDeriv); |
---|
158 | setcookie( 'picture_deriv', |
---|
159 | $pictureDeriv, |
---|
160 | 0, |
---|
161 | cookie_path() |
---|
162 | ); |
---|
163 | //============================================================ |
---|
164 | pwg_set_session_var('picture_sel_type',$pictureSelType); |
---|
165 | setcookie( 'picture_sel_type', |
---|
166 | $pictureSelType, |
---|
167 | 0, |
---|
168 | cookie_path() |
---|
169 | ); |
---|
170 | //============================================================= |
---|
171 | $_COOKIE['picture_sel_type']=$pictureSelType; |
---|
172 | $_COOKIE['picture_deriv']=$pictureDeriv; |
---|
173 | |
---|
174 | |
---|
175 | $pattern = array(); |
---|
176 | if($has_pamoorama=="true"){ |
---|
177 | if($DEBUG_autosize == "c1") echo $theImageWidth . "x" . $theImageHeight ; |
---|
178 | |
---|
179 | $pattern[0] = '/width\:(.*)(\d+),/';$replacement[0] = 'width: '.$theImageWidth.' ,'; |
---|
180 | |
---|
181 | if(($theImageWidth!=0)){ |
---|
182 | $content= preg_replace($pattern, $replacement, $content); |
---|
183 | } |
---|
184 | if($DEBUG_autosize == "c1") { |
---|
185 | echo "<!-- " . $theImageWidth . "x" . $theImageHeight . " " .cl_print_var($content) ." -->"; |
---|
186 | die(); |
---|
187 | } |
---|
188 | return $content; |
---|
189 | } |
---|
190 | |
---|
191 | $pattern[0] = '/width\:(.*)(\d+)px/';$replacement[0] = 'width:100% '; |
---|
192 | $pattern[1] = '/height\:(.*)(\d+)px/';$replacement[1] = 'height:100% '; |
---|
193 | $pattern[2] = '/width=\"(\d+)\"/';$replacement[2] = ' '; |
---|
194 | $pattern[3] = '/height=\"(\d+)\"/';$replacement[3] = ' '; |
---|
195 | |
---|
196 | if ( preg_match("|charlie|", $content, $val) ){ |
---|
197 | |
---|
198 | |
---|
199 | $ncount=1; |
---|
200 | $content=str_replace( "<object" , "<object id='theMainImage' name='theMainImage' " ,$content,$ncount); |
---|
201 | $content=str_replace( "<embed" , "<embed id='theMainImage' name='theMainImage' " ,$content,$ncount); |
---|
202 | $content= preg_replace($pattern, "", $content); |
---|
203 | |
---|
204 | $content= "<div id='theMainImage' style='height:".$theImageHeight."px ;width:".$theImageWidth."px' >". $content . "<img src='".AUTOSIZE_PATH . "images/transparent.gif' /></div>"; |
---|
205 | $content= "<style>#theImageAndInfos{height:auto;width:auto;border:1px solid red;position:relative} |
---|
206 | #theImage{height:auto;border:1px solid blue;align:center;text-align:center;width:100%;position:relative} |
---|
207 | #theMainImage{height:auto;border:10px solid blue;align:center;text-align:center;position:static} |
---|
208 | |
---|
209 | |
---|
210 | </style>".$content; |
---|
211 | |
---|
212 | |
---|
213 | return $content; |
---|
214 | } |
---|
215 | |
---|
216 | $content= preg_replace($pattern, "", $content); |
---|
217 | |
---|
218 | }//INIT |
---|
219 | |
---|
220 | /************************ |
---|
221 | * INIT 2 |
---|
222 | *************************/ |
---|
223 | static public function init2($content,$element_info){ |
---|
224 | |
---|
225 | |
---|
226 | global $template,$version,$icon_path,$page,$picture,$conf; |
---|
227 | global $user,$Css,$css_slideshow,$css_display,$liste_type; |
---|
228 | global $infos_message; |
---|
229 | //content = photo |
---|
230 | |
---|
231 | //===================================================================== |
---|
232 | global $has_pamoorama,$pictureSelType,$pictureDeriv; |
---|
233 | global $theImageHeight,$theImageWidth; |
---|
234 | global $DEBUG_autosize; |
---|
235 | //-- si Autosize correction redim --------------- |
---|
236 | $current = $template->get_template_vars('current'); |
---|
237 | if (!isset($current)) return ; |
---|
238 | |
---|
239 | // if( $has_pamoorama=="true") return $content ; |
---|
240 | // if($pictureSelType!="Autosize") return $content ; |
---|
241 | |
---|
242 | $pattern = '/width=\"(\d+)\"/'; |
---|
243 | $replacement = ''; |
---|
244 | $content= preg_replace($pattern, $replacement, $content); |
---|
245 | |
---|
246 | $pattern = '/height=\"(\d+)\"/'; |
---|
247 | $replacement = ''; |
---|
248 | $content= preg_replace($pattern, "", $content) ; |
---|
249 | |
---|
250 | if( $has_pamoorama=="true") return $content ; |
---|
251 | |
---|
252 | if($DEBUG_autosize != "c1") return $content ; |
---|
253 | $content= preg_replace($pattern, "", $content) . $pictureDeriv . " " .$pictureSelType; |
---|
254 | die($content); |
---|
255 | |
---|
256 | |
---|
257 | $theImageHeight =abs($theImageHeight); |
---|
258 | $theImageWidth =abs($theImageWidth); |
---|
259 | |
---|
260 | if ( preg_match("|<img|", $content, $val) ){ |
---|
261 | $chars=substr($pictureDeriv,0,2); |
---|
262 | $content=str_replace("<img ","<!--img ",$content); |
---|
263 | $content=str_replace(">","-->",$content); |
---|
264 | $src=explode( 'src=',$content); |
---|
265 | $src=explode( ' ',$src[1]); |
---|
266 | $src=$src[0]; |
---|
267 | $char2=substr($src,-7); |
---|
268 | $content=str_replace("$char2", $chars.'.JPG"',$content); |
---|
269 | $ncount=1; |
---|
270 | $content=str_replace( "width" , "old_w" ,$content,$ncount); |
---|
271 | $content=str_replace( "height" , "old_h" ,$content,$ncount); |
---|
272 | if (isset($theImageHeight) && isset($theImagewidth)) |
---|
273 | $content=str_replace(" old_w","style='height:".$theImageHeight."px; width:".$theImageWidth."px;' old_w",$content,$ncount); |
---|
274 | $content=str_replace("<!--img ","<img ",$content); |
---|
275 | $content=str_replace("-->",">",$content); |
---|
276 | |
---|
277 | $content=$content. "<span><br> height:".$theImageHeight."px; width:".$theImageWidth."px; </span>" ; |
---|
278 | return $content ; |
---|
279 | } |
---|
280 | // id="charlie" |
---|
281 | if ( preg_match("|charlie|", $content, $val) ){ |
---|
282 | |
---|
283 | |
---|
284 | // return $content ; |
---|
285 | |
---|
286 | } |
---|
287 | |
---|
288 | |
---|
289 | |
---|
290 | |
---|
291 | |
---|
292 | } //INIT2 |
---|
293 | /*************************** |
---|
294 | * |
---|
295 | ***************************/ |
---|
296 | static public function reload(){ |
---|
297 | //========================================= |
---|
298 | include_once ( "include/functions_cookie.inc.php"); |
---|
299 | $set_miniature = "<!DOCTYPE html><html><head> |
---|
300 | <meta http-equiv='content-type' content='text/html; charset=UTF-8'/> |
---|
301 | <script type='text/javascript' src='themes/default/js/jquery.min.js'></script><script type='text/javascript' src='plugins/Autosize/js/autosizeDetect.js'></script> |
---|
302 | <script type='text/javascript' src='plugins/Autosize/js/autosize.cookie.js'></script> |
---|
303 | <script type='text/javascript' src='".PHPWG_ROOT_PATH."themes/default/js/plugins/jquery.ajaxmanager.js'></script>"; |
---|
304 | $set_miniature .= "<script type='text/javascript' src='".PHPWG_ROOT_PATH."plugins/Autosize/js/autosize_ajax.js' id='autosize_ajax' > </script >"; |
---|
305 | |
---|
306 | $set_var = "<script type='text/javascript'>\n var COOKIE_PATH = '".cookie_path()."';\n"; |
---|
307 | global $ma_page,$user,$element_info; |
---|
308 | $set_var .= " var mapage = '". $ma_page . "';\n"; |
---|
309 | $set_var .= " var theme = '" .$user['theme']. "';\n"; |
---|
310 | $set_var .= " var theMainImageWidth = '" .$element_info['width'] . "';\n"; |
---|
311 | $set_var .= " var theMainImageHeight = '" .$element_info['height'] . "';\n"; |
---|
312 | $set_var .= " var theMainImageSrc = '" .$element_info['path']. "';\n"; |
---|
313 | |
---|
314 | $set_var .= " </script >"; |
---|
315 | |
---|
316 | $autoscript=" |
---|
317 | </head> |
---|
318 | <body onload=on_load() style='background-color:black;color :white;font-size:30px ' > |
---|
319 | please wait, loading... |
---|
320 | <div></div> |
---|
321 | </body></html>"; |
---|
322 | echo $set_miniature ; |
---|
323 | echo $set_var ; |
---|
324 | echo $autoscript; |
---|
325 | die(); |
---|
326 | //========================================= |
---|
327 | |
---|
328 | } |
---|
329 | |
---|
330 | /************************ |
---|
331 | * cl_autosize_script_1 |
---|
332 | *************************/ |
---|
333 | static public function cl_autosize_script_1(){ |
---|
334 | global $user,$page,$template,$cl_plugin; |
---|
335 | global $has_pamoorama,$css_slideshow; |
---|
336 | global $pictureSelType,$pictureDeriv,$infos_message,$conf; |
---|
337 | global $DEBUG_autosize; |
---|
338 | |
---|
339 | $ma_page=isset($page['body_id'])?$page['body_id']:"" ; |
---|
340 | if ($ma_page !='thePicturePage') return ; |
---|
341 | if ( $has_pamoorama=="false" ) return ; |
---|
342 | if ($page['slideshow']){ |
---|
343 | //==== mise à l'échelle === |
---|
344 | $current = $template->get_template_vars('current'); |
---|
345 | $default_size = $conf['derivative_default_size']; |
---|
346 | |
---|
347 | if(isset($current['selected_derivative'])) { |
---|
348 | $model=$current['selected_derivative']->get_type() ; |
---|
349 | }else{ |
---|
350 | $model=$default_size; |
---|
351 | } |
---|
352 | |
---|
353 | $selected_derivative = $current['derivatives'][$model]; |
---|
354 | $template->append('current', array( |
---|
355 | 'selected_derivative' => $selected_derivative |
---|
356 | ), |
---|
357 | true); |
---|
358 | |
---|
359 | } |
---|
360 | |
---|
361 | |
---|
362 | |
---|
363 | $template->set_filenames(array('autosize_init'=>AUTOSIZE_PATH_ABS. "template/conflit.tpl" ) ); |
---|
364 | $autosize_parametres = cl_autosize_Get_Options() ; |
---|
365 | $theme=$user['theme']; |
---|
366 | |
---|
367 | //============================================================================== |
---|
368 | |
---|
369 | $template->assign( |
---|
370 | array( |
---|
371 | 'autosize_parametres' => $autosize_parametres , |
---|
372 | 'cl_plugins' => $cl_plugin , |
---|
373 | 'cl_version' => $cl_plugin['version'] , |
---|
374 | 'name' => $cl_plugin['name'] , |
---|
375 | 'has_pamoorama' => $has_pamoorama, |
---|
376 | 'theme' => $theme , |
---|
377 | 'DEBUG_autosize' => $DEBUG_autosize, |
---|
378 | 'AUTOSIZE_PATH' => str_replace("../","",AUTOSIZE_PATH) , |
---|
379 | 'AUTOSIZE_PATH_ABS' => AUTOSIZE_PATH_ABS, |
---|
380 | 'Version_pwg' => PHPWG_VERSION , |
---|
381 | 'slideshow' => $page['slideshow'] |
---|
382 | ) |
---|
383 | ); |
---|
384 | |
---|
385 | |
---|
386 | return $template->parse( 'autosize_init', false); |
---|
387 | |
---|
388 | |
---|
389 | }// function cl_autosize_script_1 |
---|
390 | |
---|
391 | /************************************* |
---|
392 | * cl_autosize_script_2() |
---|
393 | **************************************/ |
---|
394 | static public function cl_autosize_script_2() |
---|
395 | { global $css_slideshow; |
---|
396 | global $pictureSelType,$pictureDeriv,$infos_message; |
---|
397 | global $template,$user,$conf,$picture ,$page, $cl_plugin,$known_script ; |
---|
398 | global $template,$user,$conf,$picture ,$page, $cl_plugin ; |
---|
399 | global $has_pamoorama; |
---|
400 | global $DEBUG_autosize; |
---|
401 | |
---|
402 | $ma_page=isset($page['body_id'])?$page['body_id']:"" ; |
---|
403 | if ($ma_page !='thePicturePage') return ; |
---|
404 | |
---|
405 | $theme=$user['theme']; |
---|
406 | if ($has_pamoorama=="false" ) return ; |
---|
407 | if ($css_slideshow="no" and isset($_GET['slideshow'])) return ; |
---|
408 | $AUTOSIZE_PATH = dirname(__FILE__).'/'; |
---|
409 | |
---|
410 | //===================================================================== |
---|
411 | |
---|
412 | |
---|
413 | $template->assign( |
---|
414 | array( |
---|
415 | 'cl_version' => $cl_plugin['version'] , |
---|
416 | 'name' => $cl_plugin['name'] , |
---|
417 | 'ma_page' => $ma_page, |
---|
418 | 'theme' => $theme , |
---|
419 | 'DEBUG_autosize' => $DEBUG_autosize , |
---|
420 | 'AUTOSIZE_PATH' => AUTOSIZE_PATH |
---|
421 | |
---|
422 | ) |
---|
423 | ); |
---|
424 | |
---|
425 | $autoscript="<script type='text/javascript'> |
---|
426 | /* cl_autosize_script_2 */ |
---|
427 | if (typeof (save_framework) == 'function') |
---|
428 | save_framework('".$ma_page."'); |
---|
429 | |
---|
430 | </script>"; |
---|
431 | $template->append('footer_elements',$autoscript); |
---|
432 | |
---|
433 | return ; |
---|
434 | }// function cl_autosize_script_2 |
---|
435 | |
---|
436 | /************************************* |
---|
437 | * cl_autosize_script_3() |
---|
438 | **************************************/ |
---|
439 | static public function cl_autosize_script_3() { |
---|
440 | global $has_pamoorama,$template,$page,$infos_message; |
---|
441 | $ma_page=isset($page['body_id'])?$page['body_id']:"" ; |
---|
442 | if ($ma_page !='thePicturePage') return ; |
---|
443 | |
---|
444 | |
---|
445 | $template->func_combine_script(array('id'=>'my_script_2', |
---|
446 | 'path'=> AUTOSIZE_PATH.'js/JScript.js', |
---|
447 | 'require' => 'jquery'), |
---|
448 | $template->smarty); |
---|
449 | |
---|
450 | $template->func_combine_css(array('id'=>'autosize.css', |
---|
451 | 'path'=> AUTOSIZE_PATH.'css/autosize.css' |
---|
452 | )); |
---|
453 | |
---|
454 | |
---|
455 | $autoscript="<script type='text/javascript'> |
---|
456 | var COOKIE_PATH = '".cookie_path()."' ; |
---|
457 | </script>"; |
---|
458 | $template->append('footer_elements',$autoscript); |
---|
459 | if ($has_pamoorama=="false" ) return ; |
---|
460 | |
---|
461 | $autoscript="<script type='text/javascript'> |
---|
462 | if (typeof (Ajout_Ajax) == 'function') |
---|
463 | Ajout_Ajax(); |
---|
464 | </script>"; |
---|
465 | $template->append('footer_elements',$autoscript); |
---|
466 | |
---|
467 | |
---|
468 | return ; |
---|
469 | }// function cl_autosize_script_3 |
---|
470 | |
---|
471 | /************************ |
---|
472 | * cl_autosize_affiche |
---|
473 | *************************/ |
---|
474 | static public function cl_autosize_affiche(){ |
---|
475 | |
---|
476 | if (!defined('AUTOSIZE_PATH')) { |
---|
477 | define( 'AUTOSIZE_PATH', PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/' ); |
---|
478 | if (!defined('AUTOSIZE_PATH_ABS')) |
---|
479 | define( 'AUTOSIZE_PATH_ABS', realpath(AUTOSIZE_PATH)."/"); |
---|
480 | } |
---|
481 | |
---|
482 | |
---|
483 | global $user, $picture, $template,$page,$known_script; |
---|
484 | global $content, $element_info; |
---|
485 | global $infos_message,$error_message,$warnings_message; |
---|
486 | global $conf,$lang ,$user,$userdata; |
---|
487 | global $defined_types, $liste_type,$SRC_IMG; |
---|
488 | global $set_miniature; |
---|
489 | global $autosize_parametres,$user_status; |
---|
490 | global $has_pamoorama,$pictureSelType,$pictureDeriv; |
---|
491 | global $DEBUG_autosize; |
---|
492 | $ma_page=isset($page['body_id'])?$page['body_id']:"" ; |
---|
493 | if ($ma_page !='thePicturePage') return ; |
---|
494 | |
---|
495 | if(isset($set_miniature)){ |
---|
496 | |
---|
497 | $set_miniature = autosize_controler::cl_autosize_nofile($set_miniature) ; |
---|
498 | $template->append('footer_elements',$set_miniature); |
---|
499 | } |
---|
500 | |
---|
501 | global $css_slideshow,$css_display; |
---|
502 | $AUTOSIZE_PATH = dirname(__FILE__).'/'; |
---|
503 | $theme=$user['theme']; |
---|
504 | load_language('plugin.lang', AUTOSIZE_PATH); |
---|
505 | include_once (AUTOSIZE_PATH."include/affiche.php"); |
---|
506 | if($pictureSelType== $pictureDeriv ) return ; |
---|
507 | $file =AUTOSIZE_PATH_ABS.'template/picture_1.tpl' ; |
---|
508 | if ($css_display=="none" && $has_pamoorama=="true" ) { |
---|
509 | $css_display="block" ; |
---|
510 | } |
---|
511 | $file_css=AUTOSIZE_PATH."css/".$theme.".css"; |
---|
512 | if (!file_exists($file_css)) $file_css="no"; |
---|
513 | |
---|
514 | $template->set_filenames(array('autosize_content_header'=> $file )); |
---|
515 | $template->assign( array( AUTOSIZE_PATH,$AUTOSIZE_PATH, |
---|
516 | 'file_css' =>$file_css, |
---|
517 | 'css_display' => $css_display, |
---|
518 | 'theme' =>$theme |
---|
519 | )); |
---|
520 | $template->concat('autosize_content', $template->parse('autosize_content_header', true)); |
---|
521 | if ($css_display=="none" ) { |
---|
522 | return ; |
---|
523 | } |
---|
524 | |
---|
525 | $file =AUTOSIZE_PATH_ABS.'template/header.tpl' ; |
---|
526 | $template->set_filenames(array('autosize_init_header'=> $file )); |
---|
527 | $template->parse( 'autosize_init_header', false); |
---|
528 | $theme=$user['theme']; |
---|
529 | |
---|
530 | if($autosize_parametres->check_icon_v == 'on'){ |
---|
531 | $template->assign('cl_autosize_button', |
---|
532 | array( 'cl_autosize_info' => 'cl_autosize_info' , |
---|
533 | 'cl_autosize_info_1' => 'cl_autosize_info_' , |
---|
534 | 'cl_autosize_info_2' => 'cl_autosize_info_2' , |
---|
535 | 'URL' => $_SERVER['REQUEST_URI'] , |
---|
536 | 'ICON2' => AUTOSIZE_PATH . 'icons/button-maximize.png', |
---|
537 | 'ICON' => AUTOSIZE_PATH . 'icons/button-minimize.png', |
---|
538 | 'ICON1' => AUTOSIZE_PATH . 'icons/button-no.png' |
---|
539 | ) |
---|
540 | |
---|
541 | ); |
---|
542 | $template->set_filenames(array('cl_bp' => $AUTOSIZE_PATH. 'template/picture.tpl')); |
---|
543 | $template->concat('PLUGIN_PICTURE_ACTIONS', $template->parse('cl_bp', true)); |
---|
544 | } |
---|
545 | |
---|
546 | |
---|
547 | $template->set_filenames( |
---|
548 | array('autosize_content'=> $AUTOSIZE_PATH.'template/autosize.tpl', |
---|
549 | 'theme' => $theme ) |
---|
550 | ); |
---|
551 | |
---|
552 | $template->concat('autosize_content', $template->parse('autosize_content_header', true)); |
---|
553 | if(isset($conf['go_up_down']) && ($conf['go_up_down']==true) ){ |
---|
554 | $template->set_filenames(array('mes_script' => realpath(AUTOSIZE_PATH).'/template/mes_scripts.tpl') ); |
---|
555 | |
---|
556 | $template->func_combine_script(array('id'=>'my_script_2', |
---|
557 | 'path'=> AUTOSIZE_PATH.'/js/JScript.js', |
---|
558 | 'require' => 'jquery'), |
---|
559 | $template->smarty |
---|
560 | ); |
---|
561 | |
---|
562 | $template->assign(array( |
---|
563 | 'MY_FOOTER_PATH' =>AUTOSIZE_PATH |
---|
564 | )); |
---|
565 | $template->parse('mes_script'); |
---|
566 | } |
---|
567 | |
---|
568 | cl_aff_infos_plus(); |
---|
569 | return $template->parse( 'autosize_content', false); |
---|
570 | |
---|
571 | |
---|
572 | |
---|
573 | } //public function cl_autosize_affiche |
---|
574 | |
---|
575 | |
---|
576 | /**************************************** |
---|
577 | * |
---|
578 | ****************************************/ |
---|
579 | function Get_Options(&$parametres,$str_index){ |
---|
580 | global $conf ; |
---|
581 | if (!isset( $conf[$str_index])) { |
---|
582 | $conf[$str_index]=""; |
---|
583 | } |
---|
584 | $m_options= $conf[$str_index]; |
---|
585 | if(isset($m_options)) |
---|
586 | if ( preg_match("|s:(.*)|", $m_options, $val) ) |
---|
587 | $parametres = unserialize($conf[$str_index]); |
---|
588 | else{ |
---|
589 | $parametres=explode(",",$_options); |
---|
590 | } |
---|
591 | //====== par defaut ======================= |
---|
592 | $new_val=false; |
---|
593 | $def_para=Array(); |
---|
594 | |
---|
595 | $def_para['query'] = 'Qt' ; |
---|
596 | $def_para['type'] = 'Ty' ; |
---|
597 | |
---|
598 | $def_para['webmaster_type'] = 'Autosize' ; |
---|
599 | $def_para['admin_type'] = 'Autosize' ; |
---|
600 | $def_para['generic_type'] = 'Autosize' ; |
---|
601 | $def_para['guest_type'] = 'Autosize' ; |
---|
602 | $def_para['normal_type'] = 'Autosize' ; |
---|
603 | |
---|
604 | |
---|
605 | |
---|
606 | $def_para['mini_height'] = '150' ; |
---|
607 | $def_para['mini_width'] = '300' ; |
---|
608 | |
---|
609 | $def_para['mini_height2'] = '150' ; |
---|
610 | $def_para['mini_width2'] = '300' ; |
---|
611 | |
---|
612 | $def_para['echelle_max'] = '1.0'; |
---|
613 | $def_para['marge_basse'] = '0'; |
---|
614 | $def_para['fade_in'] = '0'; |
---|
615 | //================================================== |
---|
616 | $def_para['check_desc_v'] = "off" ; |
---|
617 | $def_para['check_icon_v'] = "off" ; |
---|
618 | $def_para['defaut_type'] = "off" ; |
---|
619 | |
---|
620 | $def_para['webmaster_enabled'] = "off" ; |
---|
621 | $def_para['admin_enabled'] = "off" ; |
---|
622 | $def_para['generic_enabled'] = "off" ; |
---|
623 | $def_para['guest_enabled'] = "off" ; |
---|
624 | $def_para['normal_enabled'] = "off" ; |
---|
625 | //=================================================== |
---|
626 | $para=$def_para; |
---|
627 | foreach ($para as $key => $value) { |
---|
628 | if( isset($parametres->$key) ){ |
---|
629 | $value=$parametres->$key; |
---|
630 | } |
---|
631 | if($def_para[$key] =="on" ||$def_para[$key] =="off" ){ |
---|
632 | $val_pg=(isset($_POST[$key]))? ($_POST[$key]=="off"||$_POST[$key]=="on")?$_POST[$key]:"on" : "off" ; |
---|
633 | $value =(isset($_POST[$key]))? $val_pg : $value ; |
---|
634 | $val_pg=(isset($_GET[$key]))? ($_GET[$key]=="off"||$_GET[$key]=="on")?$_GET[$key]:"on" : "off" ; |
---|
635 | $value =(isset($_GET[$key]))? $val_pg : $value ; |
---|
636 | }else{ |
---|
637 | $value =(isset($_POST[$key]))? $_POST[$key] : $value ; |
---|
638 | $value =(isset($_GET[$key]))? $_GET[$key] : $value ; |
---|
639 | } |
---|
640 | unset( $parametres->$key) ; |
---|
641 | $parametres->$key = $value ; |
---|
642 | } |
---|
643 | return $parametres ; |
---|
644 | } |
---|
645 | /****************************************************/ |
---|
646 | |
---|
647 | function listeFichiers($dir,$theme){ |
---|
648 | global $extensions_allowed; |
---|
649 | $extensions_allowed = array(); |
---|
650 | $extensions_allowed [] = 'css'; |
---|
651 | if ($handle = opendir($dir)) { |
---|
652 | while (false !== ($file = readdir($handle))) { |
---|
653 | if (($file <>'.') && ($file<>'..')) { |
---|
654 | if (is_file($dir.'/'.$file)){ |
---|
655 | $extension = pathinfo($dir.'/'.$file, PATHINFO_EXTENSION); |
---|
656 | if (in_array($extension,$extensions_allowed)){ |
---|
657 | $fileHandle = fopen($dir.'/'.$file, "r"); |
---|
658 | |
---|
659 | $intro = fread($fileHandle,filesize ($dir.'/'.$file)); |
---|
660 | fclose($fileHandle); |
---|
661 | if ($file== $theme){ |
---|
662 | flush(); |
---|
663 | return $intro ; |
---|
664 | } |
---|
665 | } |
---|
666 | } else { |
---|
667 | if (is_dir($dir.'/'.$file)){ |
---|
668 | listeFichiers($dir.'/'.$file,$theme); |
---|
669 | } |
---|
670 | } |
---|
671 | } |
---|
672 | } |
---|
673 | closedir($handle); |
---|
674 | } |
---|
675 | } |
---|
676 | //================================================ |
---|
677 | static public function css($theme_local) { |
---|
678 | $path = $_SERVER['DOCUMENT_ROOT']; |
---|
679 | if (substr($path,-1)=='/'){ |
---|
680 | $path = substr($path,0,-1); |
---|
681 | } |
---|
682 | if(isset($_GET['path'])) |
---|
683 | $path=$_GET['path']; |
---|
684 | else |
---|
685 | $path=PHPWG_ROOT_PATH."local/css/"; |
---|
686 | |
---|
687 | $mycssfile=$path.$theme_local; |
---|
688 | |
---|
689 | if(!file_exists($mycssfile)) |
---|
690 | $mycssfile=$path."default-rules.css"; |
---|
691 | |
---|
692 | if(!file_exists($mycssfile)){ |
---|
693 | return Array(); |
---|
694 | } |
---|
695 | |
---|
696 | $ret = file_get_contents ($mycssfile); |
---|
697 | |
---|
698 | function remove_comments( & $string ) { |
---|
699 | $string = preg_replace('#/\*.*?\*/#s',"",$string); |
---|
700 | return $string; |
---|
701 | } |
---|
702 | |
---|
703 | $order = array("\r\n", "\n", "\r"," "); |
---|
704 | $replace = ''; |
---|
705 | $newstr = str_replace($order, $replace, $ret); |
---|
706 | |
---|
707 | $order = array('"'); |
---|
708 | $replace = "'"; |
---|
709 | $newstr = str_replace($order, $replace, $newstr); |
---|
710 | |
---|
711 | |
---|
712 | $order = array("}"); |
---|
713 | $replace = '}\r\n'; |
---|
714 | $newstr = str_replace($order, $replace, $newstr); |
---|
715 | remove_comments($newstr); |
---|
716 | |
---|
717 | $newstr = explode('\r\n',$newstr); |
---|
718 | $css=Array(); |
---|
719 | |
---|
720 | foreach ($newstr as $key => $value) { |
---|
721 | if($value){ |
---|
722 | $css2=Array(); |
---|
723 | $key=explode("{",$value); |
---|
724 | $value = str_replace("}","",$key[1]) ; |
---|
725 | $value=explode(";",$value); |
---|
726 | foreach ($value as $key2 => $value2) { |
---|
727 | if($value2){ |
---|
728 | $key2=explode(":",$value2); |
---|
729 | $value2 = $key2[1] ; |
---|
730 | $css2[$key2[0]] = $value2 ; |
---|
731 | } |
---|
732 | } |
---|
733 | $css[$key[0]]=$css2 ; |
---|
734 | } |
---|
735 | } |
---|
736 | |
---|
737 | |
---|
738 | return $css; |
---|
739 | } |
---|
740 | |
---|
741 | /*************************** |
---|
742 | * get_min_max |
---|
743 | ***************************/ |
---|
744 | static public function get_min_max(){ |
---|
745 | global $liste_type,$img_all,$set_miniature,$template,$infos_message,$error_message,$has_pamoorama ; |
---|
746 | global $theImageWidth,$theImageHeight,$pictureSelType,$pictureDeriv ; |
---|
747 | $current = $template->get_template_vars('current'); |
---|
748 | $liste_type=""; |
---|
749 | $del_deriv_types = array(); |
---|
750 | $i=0; |
---|
751 | $defined_types = array_keys(ImageStdParams::get_defined_type_map()); |
---|
752 | foreach($defined_types as $type){ |
---|
753 | |
---|
754 | if($type!="Autosize" && $type!="SelMaxi" ){ |
---|
755 | $last_derivative= $type ; |
---|
756 | $del_deriv_types[$i] = $last_derivative ; |
---|
757 | $i++; |
---|
758 | } |
---|
759 | |
---|
760 | } |
---|
761 | ; |
---|
762 | $derivative=$current['derivatives'][$last_derivative] ; |
---|
763 | $img_all= $derivative->get_all($derivative->src_image); |
---|
764 | |
---|
765 | |
---|
766 | $retour = (object) ''; |
---|
767 | $maxi_image = (object) ''; |
---|
768 | $mini_image = (object) ''; |
---|
769 | $std_image = (object) ''; |
---|
770 | $default_image=(object) ''; |
---|
771 | $last_image=(object) ''; |
---|
772 | |
---|
773 | global $imgSizeWH ; |
---|
774 | $imgSizeWH = $derivative->get_size(); |
---|
775 | $theImage_maxi=0; |
---|
776 | $theImage_mini=0; |
---|
777 | $theImage_def=0; |
---|
778 | $No_files= array(); |
---|
779 | //================= Liste ========================= |
---|
780 | $ok= 0 ; |
---|
781 | $nofile=0 ; |
---|
782 | //============================================= |
---|
783 | // Liste mini maxi |
---|
784 | //============================================= |
---|
785 | foreach ($img_all as $img_select){ |
---|
786 | $img_type = $img_select->get_type(); |
---|
787 | $img_url = $img_select->get_path(); |
---|
788 | $imgWH = $img_select->get_size(); |
---|
789 | if ($img_type=="square" || $img_type=="thumb" ) continue ; |
---|
790 | if($img_type=="Autosize" || $img_type=="SelMaxi"){ |
---|
791 | $theImage_def +=1 ; |
---|
792 | continue; |
---|
793 | } |
---|
794 | if(!file_exists(PHPWG_ROOT_PATH.$img_url)){ |
---|
795 | $No_files[$img_type] = $img_select ; |
---|
796 | $nofile++ ; |
---|
797 | } |
---|
798 | if(file_exists(PHPWG_ROOT_PATH.$img_url)){ } // if file |
---|
799 | |
---|
800 | if ($theImage_def==0){ |
---|
801 | // Avant Autosize ou Original; |
---|
802 | if($img_type=="Original") { |
---|
803 | $theImage_def = 1; |
---|
804 | $theImage_maxi=1; |
---|
805 | $theImage_mini=1; |
---|
806 | if($ok==0){ |
---|
807 | $last_image->type=$img_type; |
---|
808 | $last_image->url=$img_url; |
---|
809 | $last_image=$img_select; |
---|
810 | } |
---|
811 | }else{ |
---|
812 | $last_derivative=$img_type ; |
---|
813 | $last_image= $img_select; |
---|
814 | } |
---|
815 | } |
---|
816 | if ($theImage_maxi==0){ |
---|
817 | $maxi_image= $img_select; |
---|
818 | } |
---|
819 | if ($theImage_mini==0){ |
---|
820 | $mini_image= $img_select; |
---|
821 | } |
---|
822 | |
---|
823 | $liste_type[$img_type]=$img_type.",".$img_url.",".$imgWH[0] .",".$imgWH[1] ; |
---|
824 | if( $img_type=="Original" && $theImage_def==0 ){ |
---|
825 | $theImage_def=1; |
---|
826 | $img_type = $last_derivative ; |
---|
827 | $img_url= $derivative->get_path(); |
---|
828 | $imgWH = $derivative->get_size(); |
---|
829 | |
---|
830 | $default_image->type=$img_type; |
---|
831 | $default_image->url=$img_url; |
---|
832 | $default_image=$img_select; |
---|
833 | |
---|
834 | } |
---|
835 | |
---|
836 | if($has_pamoorama==true) |
---|
837 | $test= ($imgWH[1] > $theImageHeight) ; |
---|
838 | else |
---|
839 | $test= ($imgWH[1] > $theImageHeight && $imgWH[0] > $theImageWidth); |
---|
840 | if($theImage_maxi==0) |
---|
841 | if( $test ){ |
---|
842 | $theImage_maxi=1; |
---|
843 | $maxi_image->type = $img_type; |
---|
844 | $img_type=$img_select->get_type(); |
---|
845 | if($img_type=="Original") |
---|
846 | $maxi_image = $last_image; |
---|
847 | else |
---|
848 | $maxi_image = $img_select; |
---|
849 | |
---|
850 | |
---|
851 | } else { |
---|
852 | |
---|
853 | $mini_image->type=$img_type; |
---|
854 | $mini_image->url=$img_url; |
---|
855 | $mini_image=$img_select; |
---|
856 | } |
---|
857 | |
---|
858 | } // for |
---|
859 | //================================================ |
---|
860 | |
---|
861 | |
---|
862 | $retour=(object)'' ; |
---|
863 | if ($pictureSelType=="Autosize") $retour= $maxi_image ; |
---|
864 | else if ($pictureSelType=="SelMaxi") $retour= $mini_image ; |
---|
865 | else $retour=$last_image ; |
---|
866 | if (!isset( $retour->type)){ |
---|
867 | $retour=$last_image; |
---|
868 | $retour->type = $retour->get_type(); |
---|
869 | $retour->url = $retour->get_path(); |
---|
870 | } |
---|
871 | |
---|
872 | if($nofile > 0){ |
---|
873 | |
---|
874 | $set_miniature=$No_files ; |
---|
875 | |
---|
876 | |
---|
877 | |
---|
878 | } |
---|
879 | |
---|
880 | |
---|
881 | if($retour->type=="Original") |
---|
882 | $retour->type=$last_derivative ; |
---|
883 | return $retour ; |
---|
884 | |
---|
885 | } |
---|
886 | //================================================================== |
---|
887 | static public function cl_autosize_nofile($img_all){ |
---|
888 | //=== verification fichiers absents === |
---|
889 | global $infos_message,$error_message; |
---|
890 | $ok=false ; |
---|
891 | $nofiles=array(); |
---|
892 | $file_no=(object) ''; |
---|
893 | |
---|
894 | $nosrc=false ; |
---|
895 | $ok=true ; |
---|
896 | $listes=""; |
---|
897 | foreach ($img_all as $img_select){ |
---|
898 | $img_url = $img_select->get_url(); |
---|
899 | if(!file_exists(PHPWG_ROOT_PATH.$img_url)){ |
---|
900 | $img_type = $img_select->get_type(); |
---|
901 | $file_id=explode("?",$img_url); |
---|
902 | if(count($file_id) ==1){ |
---|
903 | $file_id[]=$file_id[0] ; |
---|
904 | }else{ |
---|
905 | |
---|
906 | |
---|
907 | } |
---|
908 | |
---|
909 | if ( !preg_match("|".$file_id[1]."|", $listes) ){ |
---|
910 | |
---|
911 | $listes .= $file_id[1] ."<br />"; |
---|
912 | $file_no->url=$file_id[1] ; |
---|
913 | $id = $img_select->src_image->id; |
---|
914 | $file_no->id=$id ; |
---|
915 | $file_no->type=$img_type ; |
---|
916 | array_push($nofiles,serialize($file_no)) ; |
---|
917 | |
---|
918 | |
---|
919 | } |
---|
920 | |
---|
921 | $ok=false ; |
---|
922 | } |
---|
923 | } |
---|
924 | |
---|
925 | $exec_miniatures=""; |
---|
926 | $infos_message .= $infos_message; |
---|
927 | |
---|
928 | if(count($nofiles)>0){ |
---|
929 | //======================================================================================= |
---|
930 | if($nosrc!=true ){ |
---|
931 | $exec_miniatures = "<script type='text/javascript' src='".PHPWG_ROOT_PATH."themes/default/js/plugins/jquery.ajaxmanager.js' ></script>"; |
---|
932 | $exec_miniatures .= "<script type='text/javascript' src='".PHPWG_ROOT_PATH."plugins/Autosize/js/autosize_ajax.js' id='autosize_ajax' > </script >"; |
---|
933 | $nosrc=true ; |
---|
934 | } |
---|
935 | $exec_miniatures .= "<script type='text/javascript'> |
---|
936 | var nofile=Array("; |
---|
937 | for ($i=0;$i < count($nofiles);$i++){ |
---|
938 | $file=unserialize($nofiles[$i]); |
---|
939 | $exec_miniatures .= "{id:'".$file->id."',type:'". $file->type."',file:'". $file->url."'},\n" ; |
---|
940 | } |
---|
941 | if($i>0) $exec_miniatures .= "{id:'".$file->id."',type:'". $file->type."'}" ; |
---|
942 | $exec_miniatures .= "); </script>\n" ; |
---|
943 | $exec_miniatures .= "<script type='text/javascript' > |
---|
944 | if(typeof nofile!='undefined') |
---|
945 | getDerivativeUrls(nofile); |
---|
946 | </script>"; |
---|
947 | //================================================================================== |
---|
948 | |
---|
949 | return $exec_miniatures ; |
---|
950 | } |
---|
951 | |
---|
952 | } |
---|
953 | //================================================== |
---|
954 | } // class |
---|
955 | |
---|
956 | /************************************* |
---|
957 | * |
---|
958 | *************************************/ |
---|
959 | function cl_autosize_Get_Options() |
---|
960 | { |
---|
961 | global $conf,$autosize_parametres; |
---|
962 | $autosize_parametres =""; |
---|
963 | |
---|
964 | if (!isset($conf['cl_autosize'])) { |
---|
965 | $conf['cl_autosize']=""; |
---|
966 | $q = ' |
---|
967 | INSERT INTO '.CONFIG_TABLE.' (param, value, comment) |
---|
968 | VALUES ("cl_autosize","","Parametres du plugin Autosize") |
---|
969 | ;'; |
---|
970 | pwg_query($q); |
---|
971 | } |
---|
972 | |
---|
973 | |
---|
974 | |
---|
975 | $autosize_parametres = unserialize($conf['cl_autosize']); |
---|
976 | // $autosize_parametres = autosize_controler::Get_Options($autosize_parametres,'cl_autosize'); |
---|
977 | $autosize_parametres = cl_autosize_Set_Options(); |
---|
978 | return $autosize_parametres; |
---|
979 | } |
---|
980 | /* |
---|
981 | * |
---|
982 | */ |
---|
983 | function cl_autosize_Set_Options() { |
---|
984 | global $autosize_parametres; |
---|
985 | //============================================================================= |
---|
986 | $my_para=$autosize_parametres; |
---|
987 | if (empty($my_para)) |
---|
988 | $my_para = (object) ''; |
---|
989 | |
---|
990 | $my_para->query =(isset($_POST['query'])) ? $_POST['query'] : ((isset($my_para->query )) ? $my_para->query : 'Qt' ) ; |
---|
991 | $my_para->type=(isset($_POST['type']))? $_POST['type']: ((isset($my_para->type)) ? $my_para->type: 'Ty') ; |
---|
992 | |
---|
993 | $my_para->webmaster_type =(isset($_POST['webmaster_type'])) ? $_POST['webmaster_type'] : ((isset($my_para->webmaster_type )) ? $my_para->webmaster_type : 'Autosize' ) ; |
---|
994 | |
---|
995 | $my_para->admin_type =(isset($_POST['admin_type'])) ? $_POST['admin_type'] : ((isset($my_para->admin_type )) ? $my_para->admin_type : 'Autosize' ) ; |
---|
996 | |
---|
997 | $my_para->generic_type =(isset($_POST['generic_type'])) ? $_POST['generic_type'] : ((isset($my_para->generic_type )) ? $my_para->generic_type : 'Autosize' ) ; |
---|
998 | |
---|
999 | |
---|
1000 | $my_para->guest_type =(isset($_POST['guest_type'])) ? $_POST['guest_type'] : ((isset($my_para->guest_type )) ? $my_para->guest_type : 'Autosize' ) ; |
---|
1001 | |
---|
1002 | |
---|
1003 | $my_para->normal_type =(isset($_POST['normal_type'])) ? $_POST['normal_type'] : ((isset($my_para->normal_type )) ? $my_para->normal_type : 'Autosize' ) ; |
---|
1004 | |
---|
1005 | |
---|
1006 | |
---|
1007 | $my_para->mini_height =(isset($_POST['mini_height'])) ? $_POST['mini_height'] : ((isset($my_para->mini_height )) ? $my_para->mini_height : '150' ) ; |
---|
1008 | $my_para->mini_width=(isset($_POST['mini_width']))? $_POST['mini_width']: ((isset($my_para->mini_width)) ? $my_para->mini_width: '300') ; |
---|
1009 | |
---|
1010 | $my_para->mini_height2 =(isset($_POST['mini_height2'])) ? $_POST['mini_height2'] : ((isset($my_para->mini_height2 )) ? $my_para->mini_height2 : '150' ) ; |
---|
1011 | $my_para->mini_width2=(isset($_POST['mini_width2']))? $_POST['mini_width2']: ((isset($my_para->mini_width2)) ? $my_para->mini_width2: '300') ; |
---|
1012 | |
---|
1013 | $my_para->echelle_max=(isset($_POST['echelle_max']))? $_POST['echelle_max'] : ((isset($my_para->echelle_max)) ? $my_para->echelle_max : '1.0'); |
---|
1014 | $my_para->marge_basse=(isset($_POST['marge_basse']))? $_POST['marge_basse']: ((isset($my_para->marge_basse)) ? $my_para->marge_basse : '0'); |
---|
1015 | $my_para->fade_in=(isset($_POST['fade_in']))? $_POST['fade_in']: ((isset($my_para->fade_in)) ? $my_para->fade_in : '0'); |
---|
1016 | |
---|
1017 | //=============================================================================== |
---|
1018 | |
---|
1019 | if ( isset($_POST['submit'] ) && $_POST['submit'] == l10n('cl_autosize_save') ) { |
---|
1020 | $my_para->check_desc_v = isset($_POST['check_desc_v']) ? $_POST['check_desc_v'] : "off" ; |
---|
1021 | $my_para->check_icon_v = isset($_POST['check_icon_v']) ? $_POST['check_icon_v'] : "off" ; |
---|
1022 | $my_para->defaut_type= isset($_POST['defaut_type']) ? $_POST['defaut_type'] : "off" ; |
---|
1023 | |
---|
1024 | $my_para->webmaster_enabled = isset($_POST['webmaster_enabled']) ? $_POST['webmaster_enabled'] : "off" ; |
---|
1025 | $my_para->admin_enabled = isset($_POST['admin_enabled']) ? $_POST['admin_enabled'] : "off" ; |
---|
1026 | $my_para->generic_enabled = isset($_POST['generic_enabled']) ? $_POST['generic_enabled'] : "off" ; |
---|
1027 | $my_para->guest_enabled = isset($_POST['guest_enabled']) ? $_POST['guest_enabled'] : "off" ; |
---|
1028 | $my_para->normal_enabled = isset($_POST['normal_enabled']) ? $_POST['normal_enabled'] : "off" ; |
---|
1029 | |
---|
1030 | }else{ |
---|
1031 | $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') ; |
---|
1032 | $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') ; |
---|
1033 | $my_para->defaut_type = isset($_POST['defaut_type']) ? $_POST['defaut_type'] : ( ( isset($my_para->defaut_type) ) ? $my_para->defaut_type : 'off') ; |
---|
1034 | |
---|
1035 | $my_para->webmaster_enabled = isset($_POST['webmaster_enabled']) ? $_POST['webmaster_enabled'] : ( ( isset($my_para->webmaster_enabled) ) ? $my_para->webmaster_enabled : 'on') ; |
---|
1036 | $my_para->admin_enabled = isset($_POST['admin_enabled ']) ? $_POST['admin_enabled '] : ( ( isset($my_para->admin_enabled ) ) ? $my_para->admin_enabled : 'on') ; |
---|
1037 | $my_para->generic_enabled = isset($_POST['generic_enabled']) ? $_POST['generic_enabled'] : ( ( isset($my_para->generic_enabled) ) ? $my_para->generic_enabled : 'on') ; |
---|
1038 | $my_para->guest_enabled = isset($_POST['guest_enabled']) ? $_POST['guest_enabled'] : ( ( isset($my_para->guest_enabled) ) ? $my_para->guest_enabled : 'on') ; |
---|
1039 | $my_para->normal_enabled = isset($_POST['normal_enabled']) ? $_POST['normal_enabled'] : ( ( isset($my_para->normal_enabled) ) ? $my_para->normal_enabled : 'on') ; |
---|
1040 | |
---|
1041 | |
---|
1042 | } |
---|
1043 | |
---|
1044 | return $my_para; |
---|
1045 | } |
---|
1046 | /* |
---|
1047 | * |
---|
1048 | */ |
---|
1049 | function cl_autosize_sauve_options_inf() |
---|
1050 | { |
---|
1051 | global $options,$infos_message,$conf,$autosize_parametres ; |
---|
1052 | $infos_message .=l10n("cl_autosize_save_config")."<br>"; |
---|
1053 | $autosize_parametres=cl_autosize_Set_Options(); |
---|
1054 | if ( isset($autosize_parametres) ) { |
---|
1055 | $query = ' |
---|
1056 | UPDATE '.CONFIG_TABLE.' |
---|
1057 | SET value="'.addslashes(serialize($autosize_parametres)).'" |
---|
1058 | WHERE param = "cl_autosize" |
---|
1059 | LIMIT 1'; |
---|
1060 | pwg_query($query); |
---|
1061 | } |
---|
1062 | if (!isset($conf['cl_derivatives_sav'])) { |
---|
1063 | $q = ' |
---|
1064 | INSERT INTO '.CONFIG_TABLE.' (param, value, comment) |
---|
1065 | VALUES ("cl_derivatives_sav","","sauvegarde derivatives") |
---|
1066 | ;'; |
---|
1067 | pwg_query($q); |
---|
1068 | } |
---|
1069 | } |
---|
1070 | /************************* |
---|
1071 | * |
---|
1072 | *************************/ |
---|
1073 | if(!function_exists("cl_print_var")){ |
---|
1074 | function cl_print_var($variables){ |
---|
1075 | ob_start(); |
---|
1076 | echo '<pre>'; |
---|
1077 | print_r($variables); |
---|
1078 | echo '</pre>'; |
---|
1079 | $m= ob_get_contents(); |
---|
1080 | ob_end_clean(); |
---|
1081 | return $m; |
---|
1082 | } |
---|
1083 | } |
---|
1084 | /****************** |
---|
1085 | * |
---|
1086 | ******************/ |
---|
1087 | if(!function_exists("cl_aff_infos_plus")){ |
---|
1088 | function cl_aff_infos_plus() |
---|
1089 | { |
---|
1090 | global $template,$infos_message,$error_message,$warnings_message, $user ; |
---|
1091 | global $conf,$lang,$page ; |
---|
1092 | //============================================================== |
---|
1093 | if (isset($error_message)) { |
---|
1094 | if ($error_message <> ""){ |
---|
1095 | $error_message=str_replace("\n",'<br />',$error_message) ; |
---|
1096 | $template->assign('errors',$error_message); |
---|
1097 | $error_message=""; |
---|
1098 | } |
---|
1099 | } |
---|
1100 | //============================================================== |
---|
1101 | if (isset($warnings_message)) { |
---|
1102 | if ($warnings_message <> ""){ |
---|
1103 | $warnings_message=str_replace("\n",'<br />',$warnings_message) ; |
---|
1104 | $template->assign('warnings',$warnings_message); |
---|
1105 | $warnings_message=""; |
---|
1106 | } |
---|
1107 | } |
---|
1108 | //============================================= |
---|
1109 | if (isset($infos_message)){ |
---|
1110 | if ($infos_message <> ""){ |
---|
1111 | $infos_message=str_replace("\n",'<br />',$infos_message) ; |
---|
1112 | $template->assign('infos',$infos_message); |
---|
1113 | $infos_message=""; |
---|
1114 | } |
---|
1115 | } |
---|
1116 | //============================================================= |
---|
1117 | return; |
---|
1118 | |
---|
1119 | } // function cl_autosize_aff_infos_plus |
---|
1120 | //=============================================================== |
---|
1121 | } |
---|
1122 | |
---|
1123 | ?> |
---|