[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 | // +-----------------------------------------------------------------------+ |
---|
| 22 | class autosize_controler { |
---|
[17503] | 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 | * INIT |
---|
| 34 | *********************/ |
---|
| 35 | static public function init($content){ |
---|
| 36 | // header ('X-UA-Compatible: n=7') ; |
---|
| 37 | // header ('X-UA-Compatible: IE=Edge') ; |
---|
| 38 | global $template,$version,$icon_path,$page,$picture,$conf; |
---|
| 39 | |
---|
| 40 | $current = $template->get_template_vars('current'); |
---|
| 41 | |
---|
| 42 | $model= $_COOKIE['picture_deriv'] ; |
---|
| 43 | $has_pamoorama=isset($template->files['pamooramics_content']); |
---|
| 44 | //==================================================================== |
---|
| 45 | $pictureDeriv = pwg_get_session_var('picture_deriv',$conf['derivative_default_size']); |
---|
| 46 | $SRC_IMG=""; |
---|
| 47 | $selected_derivative = $current['derivatives'][$pictureDeriv]; |
---|
| 48 | if (!isset($current['selected_derivative'])){ |
---|
| 49 | $template->append('current', array( |
---|
| 50 | 'selected_derivative' => $selected_derivative |
---|
| 51 | ), |
---|
| 52 | true); |
---|
| 53 | $current = $template->get_template_vars('current'); |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | if(isset($current['derivatives'][$model])) { |
---|
| 57 | $selected_derivative = $current['derivatives'][$model]; |
---|
| 58 | $template->assign('current[selected_derivative]', $selected_derivative |
---|
| 59 | , true); |
---|
| 60 | $current = $template->get_template_vars('current'); |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | return $content; |
---|
| 64 | |
---|
| 65 | }//INIT |
---|
| 66 | /************************** |
---|
| 67 | * autosize_calcContent * |
---|
| 68 | **************************/ |
---|
| 69 | static public function autosize_calcContent($content){ |
---|
| 70 | global $conf,$page, $template,$picture,$user; |
---|
| 71 | global $defined_types,$maxi_img ,$pictureDeriv ,$liste_type,$SRC_IMG,$select_type; |
---|
| 72 | global $has_pamoorama; |
---|
| 73 | global $autosize_parametres,$user_status; |
---|
| 74 | $defined_types = array_keys(ImageStdParams::get_defined_type_map()); |
---|
| 75 | //=============================================================== |
---|
| 76 | if(isset($page['body_id']) && $page['body_id'] == 'theAdminPage' ) return ; |
---|
| 77 | if (!isset($_COOKIE['autosize_reload'])){ |
---|
| 78 | $autoscript="<script type='text/javascript' src='themes/default/js/jquery.min.js'></script> <script type='text/javascript' src='plugins/autosize/js/autosizeDetect.js'></script> |
---|
| 79 | <script type='text/javascript' src='plugins/Autosize/js/autosize.cookie.js'></script> |
---|
| 80 | <body onload=on_load() style='background-color:black;color :white;font-size:30px ' > |
---|
| 81 | please wait, loading... |
---|
| 82 | </body>"; |
---|
| 83 | echo $autoscript; |
---|
| 84 | die(); |
---|
| 85 | } |
---|
| 86 | $current = $template->get_template_vars('current'); |
---|
| 87 | if (!isset($current)) return ; |
---|
| 88 | //=============================================================== |
---|
| 89 | $derivative = $current['src_image'] ; |
---|
| 90 | $imgScaledWH = $derivative->get_size(); |
---|
| 91 | $SRC_IMG = $derivative->get_url(); |
---|
| 92 | $picture['current']['scaled_width']=$imgScaledWH[0]; |
---|
| 93 | $picture['current']['scaled_height']= $imgScaledWH[1]; |
---|
| 94 | $picture['current']['high_url']= $SRC_IMG; |
---|
| 95 | $picture['current']['image_url']=$SRC_IMG; |
---|
| 96 | //=============================================================== |
---|
| 97 | |
---|
| 98 | $user_status = $user['status'] ; |
---|
| 99 | $autosize_parametres = cl_autosize_Get_Options(); |
---|
| 100 | $user_type= get_user_status($user_status)."_type"; |
---|
| 101 | $select_type=$autosize_parametres->$user_type ; |
---|
| 102 | |
---|
| 103 | |
---|
| 104 | if (isset($_COOKIE['theImageHeight'])){ |
---|
| 105 | pwg_set_session_var('theImageWidtht',$_COOKIE['theImageWidth']); |
---|
| 106 | pwg_set_session_var('theImageHeight',$_COOKIE['theImageHeight']); |
---|
| 107 | } |
---|
| 108 | if (isset($_COOKIE['theMainImageHeight'])) pwg_set_session_var('theMainImageHeight',$_COOKIE['theMainImageHeight']); |
---|
| 109 | if (isset($_COOKIE['theMainImageWidth'])) pwg_set_session_var('theImageWidth',$_COOKIE['theMainImageWidth']); |
---|
| 110 | |
---|
| 111 | |
---|
| 112 | if (isset($_COOKIE['picture_deriv'])) |
---|
| 113 | pwg_set_session_var('picture_deriv',$_COOKIE['picture_deriv']); |
---|
| 114 | else |
---|
| 115 | pwg_set_session_var('picture_deriv',$select_type); |
---|
| 116 | |
---|
| 117 | |
---|
| 118 | $model= $conf['derivative_default_size'] ; // par defaut |
---|
| 119 | $pictureDeriv = pwg_get_session_var('picture_deriv', $model); |
---|
| 120 | |
---|
| 121 | |
---|
| 122 | $model=$pictureDeriv ; |
---|
| 123 | |
---|
| 124 | $value=0; |
---|
| 125 | $liste_type=""; |
---|
| 126 | $maxi_info=""; |
---|
| 127 | if($model!="Autosize" & $model!="SelMaxi"){ |
---|
| 128 | |
---|
| 129 | }else{ |
---|
| 130 | $model=$conf['derivative_default_size'] ; |
---|
| 131 | } |
---|
| 132 | $derivative=$current['derivatives'][$model] ; |
---|
| 133 | $img_all= $derivative->get_all($derivative->src_image); |
---|
| 134 | $maxi_img=""; |
---|
| 135 | $mini_img=""; |
---|
| 136 | $maxi_url=""; |
---|
| 137 | $imgSizeWH = $derivative->get_size(); |
---|
| 138 | //==== valeur taille image ==== |
---|
| 139 | |
---|
| 140 | $window_width=$imgSizeWH[0]; |
---|
| 141 | $window_height=$imgSizeWH[1]; |
---|
| 142 | //echo "<div style='background-color:black;color:white' >INIT: $model w:$window_width x h:$window_height </div>"; |
---|
| 143 | |
---|
| 144 | |
---|
| 145 | $window_width = pwg_get_session_var('theMainImageWidth',$imgSizeWH[0]); |
---|
| 146 | $window_height = pwg_get_session_var('theMainImageHeight',$imgSizeWH[1]); |
---|
| 147 | |
---|
| 148 | if (!isset($_COOKIE['theMainImageHeight'])) setcookie('theMainImageHeight', $window_height ); |
---|
| 149 | if (!isset($_COOKIE['theMainImageWidth'])) setcookie('theMainImageWidth',$window_width); |
---|
| 150 | |
---|
| 151 | // echo "<div style='background-color:black;color:white' >$select_type w: $window_width x h: $window_height </div>"; |
---|
| 152 | |
---|
| 153 | $last_defined=ImageStdParams::get_defined_type_map(); |
---|
| 154 | foreach ($img_all as $img_select){ |
---|
| 155 | $img_type = $img_select->get_type(); |
---|
| 156 | if ($img_type=="square" || $img_type=="thumb" ) continue ; |
---|
| 157 | |
---|
| 158 | $img_url = $img_select->get_url(); |
---|
| 159 | $imgSizeWH = $img_select->get_size(); |
---|
| 160 | if($img_type=="Autosize" || $img_type=="SelMaxi"){ |
---|
| 161 | $img_url = $img_select->src_image->get_url(); |
---|
| 162 | $imgSizeWH = $img_select->src_image->get_size(); |
---|
| 163 | $liste_type[$img_type]=$img_type.",".$img_url.",".$imgSizeWH[0] .",".$imgSizeWH[1] ; |
---|
| 164 | }else{ |
---|
| 165 | $liste_type[$img_type]=$img_type.",".$img_url.",".$imgSizeWH[0] .",".$imgSizeWH[1] ; |
---|
| 166 | if ($img_type=="Original"){ |
---|
| 167 | |
---|
| 168 | break ; |
---|
| 169 | } |
---|
| 170 | |
---|
| 171 | |
---|
| 172 | |
---|
| 173 | if($window_height < $imgSizeWH[0] ){ |
---|
| 174 | $maxi_img= $img_type; |
---|
| 175 | $maxi_url= $img_url; |
---|
| 176 | $maxi_i=$img_select; |
---|
| 177 | } |
---|
| 178 | if($window_height < $imgSizeWH[0] && $mini_img==""){ |
---|
| 179 | $mini_img= $img_type; |
---|
| 180 | $mini_url= $img_url; |
---|
| 181 | $mini_i=$img_select; |
---|
| 182 | |
---|
| 183 | }else if($imgSizeWH[0] > 10 && $maxi_img==""){ |
---|
| 184 | $last_img=$img_select; |
---|
| 185 | } |
---|
| 186 | |
---|
| 187 | |
---|
| 188 | if($select_type==$img_type){ |
---|
| 189 | if($maxi_img==""){ |
---|
| 190 | $maxi_img= $img_type; |
---|
| 191 | $maxi_url= $img_url; |
---|
| 192 | $maxi_i=$img_select; |
---|
| 193 | } |
---|
| 194 | |
---|
| 195 | break ; |
---|
| 196 | } |
---|
| 197 | } |
---|
| 198 | |
---|
| 199 | } |
---|
| 200 | |
---|
| 201 | //============================================================== |
---|
| 202 | //==== Réécriture selection ==== |
---|
| 203 | if( $img_type=="SelMaxi"){ |
---|
| 204 | $maxi_img= $mini_img; |
---|
| 205 | $maxi_url= $mini_img; |
---|
| 206 | } |
---|
| 207 | if ( !array_key_exists($maxi_img, $last_defined) ){ |
---|
| 208 | $maxi_img = $last_img->get_type(); |
---|
| 209 | $maxi_url = $last_img->get_url(); |
---|
| 210 | $imgSizeWH = $last_img->get_size(); |
---|
| 211 | } |
---|
| 212 | $model= $maxi_img; |
---|
| 213 | pwg_set_session_var('picture_deriv', $maxi_img); |
---|
| 214 | $_COOKIE['picture_deriv']=$maxi_img ; |
---|
| 215 | $_COOKIE['picture_map']= $maxi_img ; |
---|
| 216 | $_COOKIE['imgSrc']= $maxi_url; |
---|
| 217 | |
---|
| 218 | if (isset($_COOKIE['picture_deriv'])){ |
---|
| 219 | if ( array_key_exists($_COOKIE['picture_deriv'], ImageStdParams::get_defined_type_map()) ){ |
---|
| 220 | pwg_set_session_var('picture_deriv', $_COOKIE['picture_deriv']); |
---|
| 221 | }else{ |
---|
| 222 | echo "<pre>".$_COOKIE['picture_deriv']. "No exist " ; |
---|
| 223 | print_r($img_all ); |
---|
| 224 | die(); |
---|
| 225 | } |
---|
| 226 | setcookie('picture_deriv', false, 0, cookie_path() ); |
---|
| 227 | } |
---|
| 228 | |
---|
| 229 | |
---|
| 230 | return false ; |
---|
| 231 | |
---|
| 232 | } |
---|
| 233 | |
---|
| 234 | /************************ |
---|
| 235 | * cl_autosize_affiche |
---|
| 236 | *************************/ |
---|
| 237 | static public function cl_autosize_affiche(){ |
---|
| 238 | global $user, $picture, $template,$page,$known_script; |
---|
| 239 | global $content, $element_info; |
---|
| 240 | global $infos_message,$erreur_message; |
---|
| 241 | global $conf,$lang ,$user,$userdata; |
---|
| 242 | global $defined_types,$maxi_img ,$pictureDeriv ,$liste_type,$SRC_IMG,$select_type; |
---|
| 243 | global $has_pamoorama; |
---|
| 244 | global $autosize_parametres,$user_status; |
---|
| 245 | |
---|
| 246 | if(isset($page['body_id']) && $page['body_id'] == 'theAdminPage' ) return ; |
---|
| 247 | |
---|
| 248 | if ('kardon' == $user['theme'] and isset($_GET['slideshow'])) return ; |
---|
| 249 | load_language('plugin.lang', AUTOSIZE_PATH); |
---|
| 250 | $AUTOSIZE_PATH = dirname(__FILE__).'/'; |
---|
| 251 | if (isset( $page['body_id']) && $page['body_id']=='thePicturePage' ) { |
---|
| 252 | |
---|
| 253 | if ( isset($picture['current'])){ |
---|
| 254 | include (AUTOSIZE_PATH."include/affiche.php"); |
---|
| 255 | |
---|
| 256 | $file =AUTOSIZE_PATH_ABS.'template/picture_1.tpl' ; |
---|
| 257 | $template->set_filenames(array('autosize_content_header'=> $file )); |
---|
| 258 | $template->assign( |
---|
| 259 | array( |
---|
| 260 | 'select_type' =>$select_type, |
---|
| 261 | )); |
---|
| 262 | |
---|
| 263 | $template->concat('autosize_content', $template->parse('autosize_content_header', true)); |
---|
| 264 | |
---|
| 265 | $file =AUTOSIZE_PATH_ABS.'template/header.tpl' ; |
---|
| 266 | $template->set_filenames(array('autosize_init_header'=> $file )); |
---|
| 267 | $template->parse( 'autosize_init_header', false); |
---|
| 268 | |
---|
| 269 | $theme=$user['theme']; |
---|
| 270 | |
---|
| 271 | if($autosize_parametres->check_icon_v == 'on'){ |
---|
| 272 | $template->assign('cl_autosize_button', |
---|
| 273 | array( 'cl_autosize_info' => 'cl_autosize_info' , |
---|
| 274 | 'cl_autosize_info_1' => 'cl_autosize_info_' , |
---|
| 275 | 'cl_autosize_info_2' => 'cl_autosize_info_2' , |
---|
| 276 | 'URL' => $_SERVER['REQUEST_URI'] , |
---|
| 277 | 'ICON2' => AUTOSIZE_PATH . 'icons/button-maximize.png', |
---|
| 278 | 'ICON' => AUTOSIZE_PATH . 'icons/button-minimize.png', |
---|
| 279 | 'ICON1' => AUTOSIZE_PATH . 'icons/button-no.png' |
---|
| 280 | ) |
---|
| 281 | |
---|
| 282 | ); |
---|
| 283 | $template->set_filenames(array('cl_bp' => $AUTOSIZE_PATH. 'template/picture.tpl')); |
---|
| 284 | $template->concat('PLUGIN_PICTURE_ACTIONS', $template->parse('cl_bp', true)); |
---|
| 285 | } |
---|
| 286 | $template->set_filenames( |
---|
| 287 | array('autosize_content'=> $AUTOSIZE_PATH.'template/autosize.tpl', |
---|
| 288 | 'theme' => $theme ) |
---|
| 289 | ); |
---|
| 290 | $template->concat('autosize_content', $template->parse('autosize_content_header', true)); |
---|
| 291 | |
---|
| 292 | if(isset($conf['go_up_down']) && ($conf['go_up_down']==true) ){ |
---|
| 293 | $template->set_filenames(array('mes_script' => realpath(AUTOSIZE_PATH).'/template/mes_scripts.tpl') ); |
---|
| 294 | $template->func_combine_script(array('id'=>'my_script_2', |
---|
| 295 | 'path'=> AUTOSIZE_PATH.'/js/JScript.js', |
---|
| 296 | 'require' => 'jquery'), |
---|
| 297 | $template->smarty); |
---|
| 298 | $template->assign(array( |
---|
| 299 | 'MY_FOOTER_PATH' =>AUTOSIZE_PATH |
---|
| 300 | )); |
---|
| 301 | $template->parse('mes_script'); |
---|
| 302 | } |
---|
| 303 | return $template->parse( 'autosize_content', false); |
---|
| 304 | } |
---|
| 305 | } |
---|
| 306 | |
---|
| 307 | } //public function cl_autosize_affiche |
---|
| 308 | |
---|
| 309 | /************************ |
---|
| 310 | * cl_autosize_script_1 |
---|
| 311 | *************************/ |
---|
| 312 | static public function cl_autosize_script_1(){ |
---|
[17192] | 313 | global $user,$page,$template,$cl_plugin; |
---|
[17308] | 314 | if(isset($page['body_id']) && $page['body_id'] == 'theAdminPage' ) return ; |
---|
[17503] | 315 | |
---|
[10347] | 316 | $ma_page=isset($page['body_id'])?$page['body_id']:"" ; |
---|
[17503] | 317 | if ($ma_page=='thePiwiShackControllerPage') return ; |
---|
[17308] | 318 | if ('kardon' == $user['theme'] and isset($_GET['slideshow'])) return ; |
---|
[17503] | 319 | global $has_pamoorama; |
---|
[17308] | 320 | $has_pamoorama=isset($template->files['pamooramics_content']); |
---|
[17503] | 321 | if (!$has_pamoorama) return ; |
---|
[17308] | 322 | |
---|
[10845] | 323 | $template->set_filenames(array('autosize_init'=>AUTOSIZE_PATH_ABS. "template/conflit.tpl" ) ); |
---|
[10347] | 324 | $autosize_parametres = cl_autosize_Get_Options() ; |
---|
| 325 | $theme=$user['theme']; |
---|
[17503] | 326 | //============================================================================== |
---|
| 327 | $DEBUG_autosize = isset($_POST['cl_debug_conflit']) ? $_POST['cl_debug_conflit'] : "false" ; |
---|
| 328 | $DEBUG_autosize = isset($_GET['cl_debug_conflit']) ? $_GET['cl_debug_conflit'] : $DEBUG_autosize ; |
---|
| 329 | $DEBUG_autosize = isset($conf['cl_debug_conflit']) ? $conf['cl_debug_conflit'] : $DEBUG_autosize ; |
---|
| 330 | //============================================================================== |
---|
[10347] | 331 | $template->assign( |
---|
| 332 | array( |
---|
[17308] | 333 | 'autosize_parametres' => $autosize_parametres , |
---|
| 334 | 'cl_plugins' => $cl_plugin , |
---|
| 335 | 'cl_version' => $cl_plugin['version'] , |
---|
| 336 | 'name' => $cl_plugin['name'] , |
---|
| 337 | 'pamoorama' => $has_pamoorama, |
---|
[17503] | 338 | 'theme' => $theme , |
---|
| 339 | 'DEBUG_autosize' => $DEBUG_autosize, |
---|
[17308] | 340 | 'AUTOSIZE_PATH' => str_replace("../","",AUTOSIZE_PATH) , |
---|
| 341 | 'AUTOSIZE_PATH_ABS' => AUTOSIZE_PATH_ABS, |
---|
| 342 | 'Version_pwg' => PHPWG_VERSION ) |
---|
[10347] | 343 | ); |
---|
[17503] | 344 | return $template->parse( 'autosize_init', false); |
---|
[8627] | 345 | }// function cl_autosize_script_1 |
---|
[16931] | 346 | |
---|
| 347 | /************************************* |
---|
| 348 | * cl_autosize_script_2() |
---|
| 349 | **************************************/ |
---|
[8627] | 350 | static public function cl_autosize_script_2() |
---|
| 351 | { |
---|
[8911] | 352 | global $template,$user,$conf,$picture ,$page, $cl_plugin,$known_script ; |
---|
[17192] | 353 | global $template,$user,$conf,$picture ,$page, $cl_plugin ; |
---|
[17503] | 354 | if(isset($page['body_id']) && $page['body_id'] == 'theAdminPage' ) return ; |
---|
| 355 | |
---|
[11429] | 356 | if ('kardon' == $user['theme'] and isset($_GET['slideshow'])) return ; |
---|
[17503] | 357 | global $has_pamoorama; |
---|
| 358 | if (!$has_pamoorama) return ; |
---|
| 359 | |
---|
[11429] | 360 | $AUTOSIZE_PATH = dirname(__FILE__).'/'; |
---|
[16931] | 361 | //================================================================ |
---|
[10845] | 362 | $DEBUG_autosize = isset($_POST['cl_debug_conflit']) ? $_POST['cl_debug_conflit'] : "false" ; |
---|
| 363 | $DEBUG_autosize = isset($_GET['cl_debug_conflit']) ? $_GET['cl_debug_conflit'] : $DEBUG_autosize ; |
---|
| 364 | $DEBUG_autosize = isset($conf['cl_debug_conflit']) ? $conf['cl_debug_conflit'] : $DEBUG_autosize ; |
---|
[16931] | 365 | //===================================================================== |
---|
[17308] | 366 | $ma_page=isset($page['body_id'])?$page['body_id']:"" ; |
---|
| 367 | $theme=$user['theme']; |
---|
| 368 | if ($ma_page=='thePiwiShackControllerPage') return ; |
---|
| 369 | $img_width=isset($picture['current']['width'])?$picture['current']['width']:480; |
---|
| 370 | $img_height=isset($picture['current']['height'])?$picture['current']['height']:320; |
---|
| 371 | $img_scaled_width=isset($picture['current']['scaled_width'])?$picture['current']['scaled_width']:480; |
---|
| 372 | $img_scaled_height=isset($picture['current']['scaled_height'])?$picture['current']['scaled_height']:320; |
---|
| 373 | $src_img_h=isset($_POST['src_img_h'])?$_POST['src_img_h']: $img_width ; |
---|
| 374 | $src_img_w= isset($_POST['src_img_w'])?$_POST['src_img_w']:$img_height ; |
---|
[17503] | 375 | |
---|
| 376 | |
---|
| 377 | include_once (PHPWG_ROOT_PATH.'include/functions_cookie.inc.php') ; |
---|
[12527] | 378 | if(isset($_COOKIE['img_w'])){ |
---|
[17308] | 379 | $src_img_w=$_COOKIE['img_w']; |
---|
| 380 | $src_img_h=$_COOKIE['img_h']; |
---|
[12527] | 381 | } |
---|
| 382 | |
---|
[17503] | 383 | $window_height= isset($_SESSION['height'])?$_SESSION['height']: $img_scaled_height ; |
---|
| 384 | $window_width= isset($_SESSION['width'])?$_SESSION['width']: $img_scaled_width ; |
---|
[11961] | 385 | |
---|
| 386 | |
---|
| 387 | $size=array( |
---|
| 388 | 'src_img_h' => $src_img_h, |
---|
| 389 | 'src_img_w' => $src_img_w, |
---|
| 390 | 'window_height' =>$window_height, |
---|
| 391 | 'window_width' => $window_width |
---|
[12527] | 392 | |
---|
[11961] | 393 | ); |
---|
| 394 | |
---|
[8627] | 395 | $template->assign( |
---|
| 396 | array( |
---|
| 397 | 'cl_version' => $cl_plugin['version'] , |
---|
| 398 | 'name' => $cl_plugin['name'] , |
---|
| 399 | 'ma_page' => $ma_page, |
---|
| 400 | |
---|
| 401 | 'theme' => $theme , |
---|
[10845] | 402 | 'DEBUG_autosize' => $DEBUG_autosize , |
---|
[11961] | 403 | 'AUTOSIZE_PATH' => AUTOSIZE_PATH, |
---|
| 404 | 'Size' => $size |
---|
[16124] | 405 | |
---|
[8627] | 406 | ) |
---|
| 407 | ); |
---|
[17503] | 408 | |
---|
[8627] | 409 | $autoscript="<script type='text/javascript'> |
---|
| 410 | /* cl_autosize_script_2 */ |
---|
| 411 | if (typeof (save_framework) == 'function') |
---|
[16124] | 412 | save_framework('".$ma_page."'); |
---|
[16579] | 413 | var cookie_path ='". cookie_path() ."' |
---|
[8627] | 414 | </script>"; |
---|
| 415 | $template->append('footer_elements',$autoscript); |
---|
| 416 | return ; |
---|
| 417 | }// function cl_autosize_script_2 |
---|
[17308] | 418 | /************************************* |
---|
| 419 | * cl_autosize_script_3() |
---|
| 420 | **************************************/ |
---|
[17503] | 421 | static public function cl_autosize_script_3() { |
---|
| 422 | global $template,$page; |
---|
| 423 | if(isset($page['body_id']) && $page['body_id'] == 'theAdminPage' ) return ; |
---|
| 424 | global $has_pamoorama; |
---|
| 425 | if (!$has_pamoorama) return ; |
---|
[8627] | 426 | |
---|
[17503] | 427 | $autoscript="<script type='text/javascript'> |
---|
[17308] | 428 | if (typeof (Ajout_Ajax) == 'function') |
---|
| 429 | Ajout_Ajax(); |
---|
| 430 | </script>"; |
---|
| 431 | $template->append('footer_elements',$autoscript); |
---|
| 432 | return ; |
---|
| 433 | }// function cl_autosize_script_3 |
---|
| 434 | |
---|
[8627] | 435 | //=============================================================== |
---|
| 436 | /* |
---|
[7375] | 437 | * |
---|
| 438 | */ |
---|
[7193] | 439 | static public function cl_autosize_aff_infos_plus() |
---|
| 440 | { |
---|
| 441 | global $template,$infos_message,$erreur_message, $user ; |
---|
[8627] | 442 | global $conf,$lang ; |
---|
[7669] | 443 | |
---|
[7193] | 444 | //============================================================== |
---|
| 445 | if (isset($erreur_message)) |
---|
| 446 | { |
---|
| 447 | if ($erreur_message <> "") |
---|
| 448 | { |
---|
| 449 | $erreur_message=str_replace("\n",'<br />',$erreur_message) ; |
---|
| 450 | $template->assign('errors',$erreur_message); |
---|
| 451 | $erreur_message=""; |
---|
| 452 | } |
---|
| 453 | } |
---|
| 454 | if (isset($infos_message)) |
---|
| 455 | { |
---|
| 456 | |
---|
| 457 | if ($infos_message <> "") |
---|
| 458 | { |
---|
| 459 | $infos_message=str_replace("\n",'<br />',$infos_message) ; |
---|
| 460 | $template->assign('infos',$infos_message); |
---|
| 461 | $infos_message=""; |
---|
| 462 | } |
---|
| 463 | } |
---|
| 464 | //============================================================= |
---|
| 465 | return; |
---|
| 466 | |
---|
[7375] | 467 | } // function cl_autosize_aff_infos_plus |
---|
[8627] | 468 | //=============================================================== |
---|
| 469 | /* |
---|
| 470 | * |
---|
| 471 | */ |
---|
| 472 | static public function cl_ajuste_data($content){ |
---|
| 473 | global $template,$user,$conf,$picture ; |
---|
[11961] | 474 | global $size; |
---|
[11429] | 475 | $AUTOSIZE_PATH = realpath(AUTOSIZE_PATH .'/'); |
---|
[8627] | 476 | $userdata=$user; |
---|
| 477 | $fields = array( 'maxwidth', 'maxheight' ); |
---|
[8070] | 478 | |
---|
[8627] | 479 | $ThePicture = $template->get_template_vars('current'); |
---|
| 480 | $data = array(); |
---|
| 481 | return $content; |
---|
[7816] | 482 | |
---|
[11961] | 483 | $data['maxwidth'] = $size['src_img_w']; |
---|
| 484 | $data['maxheight'] =$size['src_img_h']; |
---|
[8627] | 485 | $data['user_id'] = $userdata['id']; |
---|
| 486 | foreach ($fields as $field) |
---|
[7943] | 487 | { |
---|
[8627] | 488 | if (isset($_POST[$field])) |
---|
| 489 | { |
---|
| 490 | $data[$field] = $_POST[$field]; |
---|
| 491 | } |
---|
[7943] | 492 | } |
---|
[7193] | 493 | |
---|
[8627] | 494 | if($data['maxwidth'] != "" ) |
---|
| 495 | { |
---|
| 496 | $picture['current']['scaled_width']=$data['maxwidth']; |
---|
| 497 | $picture['current']['scaled_height']=$data['maxheight']; |
---|
| 498 | mass_updates(USER_INFOS_TABLE, |
---|
| 499 | array('primary' => array('user_id'), 'update' => $fields), |
---|
| 500 | array($data)); |
---|
| 501 | } |
---|
[7943] | 502 | |
---|
[8627] | 503 | return $content; |
---|
| 504 | } |
---|
[7375] | 505 | |
---|
[11961] | 506 | |
---|
| 507 | /**************************************** |
---|
| 508 | * |
---|
| 509 | ****************************************/ |
---|
| 510 | function Get_Options(&$parametres,$str_index){ |
---|
| 511 | global $conf ; |
---|
[16124] | 512 | if (!isset( $conf[$str_index])) { |
---|
| 513 | $conf[$str_index]=""; |
---|
| 514 | } |
---|
[11961] | 515 | $m_options= $conf[$str_index]; |
---|
| 516 | if(isset($m_options)) |
---|
| 517 | if ( preg_match("|s:(.*)|", $m_options, $val) ) |
---|
| 518 | $parametres = unserialize($conf[$str_index]); |
---|
| 519 | else{ |
---|
| 520 | $parametres=explode(",",$_options); |
---|
| 521 | } |
---|
| 522 | //====== par defaut ======================= |
---|
| 523 | $new_val=false; |
---|
| 524 | $def_para=Array(); |
---|
| 525 | |
---|
| 526 | $def_para['query'] = 'Qt' ; |
---|
| 527 | $def_para['type'] = 'Ty' ; |
---|
| 528 | |
---|
[16931] | 529 | $def_para['webmaster_type'] = 'Autosize' ; |
---|
| 530 | $def_para['admin_type'] = 'Autosize' ; |
---|
| 531 | $def_para['generic_type'] = 'Autosize' ; |
---|
| 532 | $def_para['guest_type'] = 'Autosize' ; |
---|
| 533 | $def_para['normal_type'] = 'Autosize' ; |
---|
| 534 | |
---|
[11961] | 535 | |
---|
| 536 | |
---|
| 537 | $def_para['mini_height'] = '150' ; |
---|
| 538 | $def_para['mini_width'] = '300' ; |
---|
| 539 | |
---|
| 540 | $def_para['mini_height2'] = '150' ; |
---|
| 541 | $def_para['mini_width2'] = '300' ; |
---|
| 542 | |
---|
| 543 | $def_para['echelle_max'] = '1.0'; |
---|
| 544 | $def_para['marge_basse'] = '0'; |
---|
| 545 | $def_para['fade_in'] = '0'; |
---|
| 546 | //================================================== |
---|
| 547 | $def_para['check_desc_v'] = "off" ; |
---|
| 548 | $def_para['check_icon_v'] = "off" ; |
---|
[16931] | 549 | |
---|
[11961] | 550 | $def_para['webmaster_enabled'] = "off" ; |
---|
| 551 | $def_para['admin_enabled'] = "off" ; |
---|
| 552 | $def_para['generic_enabled'] = "off" ; |
---|
| 553 | $def_para['guest_enabled'] = "off" ; |
---|
| 554 | $def_para['normal_enabled'] = "off" ; |
---|
| 555 | //=================================================== |
---|
| 556 | $para=$def_para; |
---|
| 557 | foreach ($para as $key => $value) { |
---|
| 558 | if( isset($parametres->$key) ){ |
---|
| 559 | $value=$parametres->$key; |
---|
| 560 | } |
---|
| 561 | if($def_para[$key] =="on" ||$def_para[$key] =="off" ){ |
---|
| 562 | $val_pg=(isset($_POST[$key]))? ($_POST[$key]=="off"||$_POST[$key]=="on")?$_POST[$key]:"on" : "off" ; |
---|
| 563 | $value =(isset($_POST[$key]))? $val_pg : $value ; |
---|
| 564 | $val_pg=(isset($_GET[$key]))? ($_GET[$key]=="off"||$_GET[$key]=="on")?$_GET[$key]:"on" : "off" ; |
---|
| 565 | $value =(isset($_GET[$key]))? $val_pg : $value ; |
---|
| 566 | }else{ |
---|
| 567 | $value =(isset($_POST[$key]))? $_POST[$key] : $value ; |
---|
| 568 | $value =(isset($_GET[$key]))? $_GET[$key] : $value ; |
---|
| 569 | } |
---|
| 570 | unset( $parametres->$key) ; |
---|
| 571 | $parametres->$key = $value ; |
---|
| 572 | } |
---|
| 573 | return $parametres ; |
---|
| 574 | } |
---|
[7375] | 575 | } // class |
---|
| 576 | |
---|
[11961] | 577 | /************************************* |
---|
[7375] | 578 | * |
---|
[11961] | 579 | *************************************/ |
---|
[7193] | 580 | function cl_autosize_Get_Options() |
---|
| 581 | { |
---|
[7394] | 582 | global $conf,$autosize_parametres; |
---|
[12652] | 583 | $autosize_parametres =""; |
---|
| 584 | |
---|
| 585 | if (!isset($conf['cl_autosize'])) { |
---|
| 586 | $conf['cl_autosize']=""; |
---|
| 587 | $q = ' |
---|
| 588 | INSERT INTO '.CONFIG_TABLE.' (param, value, comment) |
---|
| 589 | VALUES ("cl_autosize","","Parametres du plugin Autosize") |
---|
| 590 | ;'; |
---|
| 591 | pwg_query($q); |
---|
| 592 | } |
---|
| 593 | |
---|
| 594 | |
---|
| 595 | |
---|
[7394] | 596 | $autosize_parametres = unserialize($conf['cl_autosize']); |
---|
[11961] | 597 | // $autosize_parametres = autosize_controler::Get_Options($autosize_parametres,'cl_autosize'); |
---|
[7394] | 598 | $autosize_parametres = cl_autosize_Set_Options(); |
---|
| 599 | return $autosize_parametres; |
---|
[7375] | 600 | } |
---|
| 601 | /* |
---|
| 602 | * |
---|
[7193] | 603 | */ |
---|
[11961] | 604 | function cl_autosize_Set_Options() { |
---|
[7193] | 605 | global $autosize_parametres; |
---|
| 606 | //============================================================================= |
---|
[7962] | 607 | $my_para=$autosize_parametres; |
---|
[16124] | 608 | if (empty($my_para)) |
---|
| 609 | $my_para = (object) ''; |
---|
| 610 | |
---|
[7962] | 611 | $my_para->query =(isset($_POST['query'])) ? $_POST['query'] : ((isset($my_para->query )) ? $my_para->query : 'Qt' ) ; |
---|
| 612 | $my_para->type=(isset($_POST['type']))? $_POST['type']: ((isset($my_para->type)) ? $my_para->type: 'Ty') ; |
---|
[7193] | 613 | |
---|
[16931] | 614 | $my_para->webmaster_type =(isset($_POST['webmaster_type'])) ? $_POST['webmaster_type'] : ((isset($my_para->webmaster_type )) ? $my_para->webmaster_type : 'Autosize' ) ; |
---|
[7193] | 615 | |
---|
[16931] | 616 | $my_para->admin_type =(isset($_POST['admin_type'])) ? $_POST['admin_type'] : ((isset($my_para->admin_type )) ? $my_para->admin_type : 'Autosize' ) ; |
---|
[7193] | 617 | |
---|
[16931] | 618 | $my_para->generic_type =(isset($_POST['generic_type'])) ? $_POST['generic_type'] : ((isset($my_para->generic_type )) ? $my_para->generic_type : 'Autosize' ) ; |
---|
[7193] | 619 | |
---|
| 620 | |
---|
[16931] | 621 | $my_para->guest_type =(isset($_POST['guest_type'])) ? $_POST['guest_type'] : ((isset($my_para->guest_type )) ? $my_para->guest_type : 'Autosize' ) ; |
---|
[7193] | 622 | |
---|
[7725] | 623 | |
---|
[16931] | 624 | $my_para->normal_type =(isset($_POST['normal_type'])) ? $_POST['normal_type'] : ((isset($my_para->normal_type )) ? $my_para->normal_type : 'Autosize' ) ; |
---|
| 625 | |
---|
| 626 | |
---|
| 627 | |
---|
[7962] | 628 | $my_para->mini_height =(isset($_POST['mini_height'])) ? $_POST['mini_height'] : ((isset($my_para->mini_height )) ? $my_para->mini_height : '150' ) ; |
---|
| 629 | $my_para->mini_width=(isset($_POST['mini_width']))? $_POST['mini_width']: ((isset($my_para->mini_width)) ? $my_para->mini_width: '300') ; |
---|
| 630 | |
---|
| 631 | $my_para->mini_height2 =(isset($_POST['mini_height2'])) ? $_POST['mini_height2'] : ((isset($my_para->mini_height2 )) ? $my_para->mini_height2 : '150' ) ; |
---|
| 632 | $my_para->mini_width2=(isset($_POST['mini_width2']))? $_POST['mini_width2']: ((isset($my_para->mini_width2)) ? $my_para->mini_width2: '300') ; |
---|
| 633 | |
---|
[9473] | 634 | $my_para->echelle_max=(isset($_POST['echelle_max']))? $_POST['echelle_max'] : ((isset($my_para->echelle_max)) ? $my_para->echelle_max : '1.0'); |
---|
[9225] | 635 | $my_para->marge_basse=(isset($_POST['marge_basse']))? $_POST['marge_basse']: ((isset($my_para->marge_basse)) ? $my_para->marge_basse : '0'); |
---|
[9473] | 636 | $my_para->fade_in=(isset($_POST['fade_in']))? $_POST['fade_in']: ((isset($my_para->fade_in)) ? $my_para->fade_in : '0'); |
---|
[7962] | 637 | |
---|
[7193] | 638 | //=============================================================================== |
---|
| 639 | |
---|
| 640 | if ( isset($_POST['submit'] ) && $_POST['submit'] == l10n('cl_autosize_save') ) { |
---|
[7962] | 641 | $my_para->check_desc_v = isset($_POST['check_desc_v']) ? $_POST['check_desc_v'] : "off" ; |
---|
| 642 | $my_para->check_icon_v = isset($_POST['check_icon_v']) ? $_POST['check_icon_v'] : "off" ; |
---|
[16931] | 643 | |
---|
[7394] | 644 | |
---|
[7962] | 645 | $my_para->webmaster_enabled = isset($_POST['webmaster_enabled']) ? $_POST['webmaster_enabled'] : "off" ; |
---|
| 646 | $my_para->admin_enabled = isset($_POST['admin_enabled']) ? $_POST['admin_enabled'] : "off" ; |
---|
| 647 | $my_para->generic_enabled = isset($_POST['generic_enabled']) ? $_POST['generic_enabled'] : "off" ; |
---|
| 648 | $my_para->guest_enabled = isset($_POST['guest_enabled']) ? $_POST['guest_enabled'] : "off" ; |
---|
| 649 | $my_para->normal_enabled = isset($_POST['normal_enabled']) ? $_POST['normal_enabled'] : "off" ; |
---|
[7394] | 650 | |
---|
[7193] | 651 | }else{ |
---|
[7962] | 652 | $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') ; |
---|
| 653 | $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') ; |
---|
[7394] | 654 | |
---|
| 655 | |
---|
[16931] | 656 | |
---|
[7962] | 657 | $my_para->webmaster_enabled = isset($_POST['webmaster_enabled']) ? $_POST['webmaster_enabled'] : ( ( isset($my_para->webmaster_enabled) ) ? $my_para->webmaster_enabled : 'on') ; |
---|
| 658 | $my_para->admin_enabled = isset($_POST['admin_enabled ']) ? $_POST['admin_enabled '] : ( ( isset($my_para->admin_enabled ) ) ? $my_para->admin_enabled : 'on') ; |
---|
| 659 | $my_para->generic_enabled = isset($_POST['generic_enabled']) ? $_POST['generic_enabled'] : ( ( isset($my_para->generic_enabled) ) ? $my_para->generic_enabled : 'on') ; |
---|
| 660 | $my_para->guest_enabled = isset($_POST['guest_enabled']) ? $_POST['guest_enabled'] : ( ( isset($my_para->guest_enabled) ) ? $my_para->guest_enabled : 'on') ; |
---|
| 661 | $my_para->normal_enabled = isset($_POST['normal_enabled']) ? $_POST['normal_enabled'] : ( ( isset($my_para->normal_enabled) ) ? $my_para->normal_enabled : 'on') ; |
---|
[7394] | 662 | |
---|
| 663 | |
---|
[7193] | 664 | } |
---|
[7316] | 665 | |
---|
[7962] | 666 | return $my_para; |
---|
[7193] | 667 | } |
---|
[7375] | 668 | /* |
---|
| 669 | * |
---|
[7193] | 670 | */ |
---|
| 671 | function cl_autosize_sauve_options_inf() |
---|
| 672 | { |
---|
| 673 | global $options,$infos_message,$conf,$autosize_parametres ; |
---|
| 674 | $infos_message .=l10n("cl_autosize_save_config")."<br>"; |
---|
| 675 | $autosize_parametres=cl_autosize_Set_Options(); |
---|
[12652] | 676 | if ( isset($autosize_parametres) ) { |
---|
[7193] | 677 | $query = ' |
---|
| 678 | UPDATE '.CONFIG_TABLE.' |
---|
| 679 | SET value="'.addslashes(serialize($autosize_parametres)).'" |
---|
| 680 | WHERE param = "cl_autosize" |
---|
| 681 | LIMIT 1'; |
---|
| 682 | pwg_query($query); |
---|
| 683 | } |
---|
[17503] | 684 | if (!isset($conf['cl_derivatives_sav'])) { |
---|
| 685 | $q = ' |
---|
| 686 | INSERT INTO '.CONFIG_TABLE.' (param, value, comment) |
---|
| 687 | VALUES ("cl_derivatives_sav","","sauvegarde derivatives") |
---|
| 688 | ;'; |
---|
| 689 | pwg_query($q); |
---|
| 690 | } |
---|
[7193] | 691 | } |
---|
[7375] | 692 | |
---|
[17503] | 693 | function print_var($variables) |
---|
[8729] | 694 | { |
---|
| 695 | ob_start(); |
---|
| 696 | echo '<pre>'; |
---|
| 697 | print_r($variables); |
---|
| 698 | echo '</pre>'; |
---|
| 699 | $m= ob_get_contents(); |
---|
| 700 | ob_end_clean(); |
---|
| 701 | return $m; |
---|
| 702 | } |
---|
| 703 | |
---|
[7375] | 704 | |
---|
[7193] | 705 | ?> |
---|