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