source: extensions/Autosize/autosize.inc.php @ 18949

Last change on this file since 18949 was 18949, checked in by cljosse, 11 years ago

[extensions] Autosize fix compatibility with 2.4 (charlie's)

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