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