Changeset 17503 for extensions/Autosize/autosize.inc.php
- Timestamp:
- Aug 9, 2012, 8:35:17 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Autosize/autosize.inc.php
r17308 r17503 21 21 // +-----------------------------------------------------------------------+ 22 22 class autosize_controler { 23 //============================================================ 24 /* 25 * cl_autosize_script_1 26 */ 27 static public function cl_autosize_script_1() 28 { 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(){ 29 313 global $user,$page,$template,$cl_plugin; 30 // header ('X-UA-Compatible: n=7') ;31 // header ('X-UA-Compatible: IE=Edge') ;32 314 if(isset($page['body_id']) && $page['body_id'] == 'theAdminPage' ) return ; 315 33 316 $ma_page=isset($page['body_id'])?$page['body_id']:"" ; 34 if ($ma_page=='thePiwiShackControllerPage') return ; 35 if (!isset($template->files['pamooramics_content'])) return ; 317 if ($ma_page=='thePiwiShackControllerPage') return ; 36 318 if ('kardon' == $user['theme'] and isset($_GET['slideshow'])) return ; 319 global $has_pamoorama; 37 320 $has_pamoorama=isset($template->files['pamooramics_content']); 38 39 $file =AUTOSIZE_PATH_ABS.'template/header.tpl' ; 40 $template->set_filenames(array('autosize_init_header'=> $file )); 321 if (!$has_pamoorama) return ; 322 41 323 $template->set_filenames(array('autosize_init'=>AUTOSIZE_PATH_ABS. "template/conflit.tpl" ) ); 42 //================================================================43 $DEBUG_autosize = isset($_POST['cl_debug_conflit']) ? $_POST['cl_debug_conflit'] : "false" ;44 $DEBUG_autosize = isset($_GET['cl_debug_conflit']) ? $_GET['cl_debug_conflit'] : $DEBUG_autosize ;45 $DEBUG_autosize = isset($conf['cl_debug_conflit']) ? $conf['cl_debug_conflit'] : $DEBUG_autosize ;46 //======================================================================47 324 $autosize_parametres = cl_autosize_Get_Options() ; 48 325 $theme=$user['theme']; 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 //============================================================================== 49 331 $template->assign( 50 332 array( … … 54 336 'name' => $cl_plugin['name'] , 55 337 'pamoorama' => $has_pamoorama, 56 'theme' => $theme , 57 'DEBUG_autosize' => $DEBUG_autosize,338 'theme' => $theme , 339 'DEBUG_autosize' => $DEBUG_autosize, 58 340 'AUTOSIZE_PATH' => str_replace("../","",AUTOSIZE_PATH) , 59 341 'AUTOSIZE_PATH_ABS' => AUTOSIZE_PATH_ABS, 60 342 'Version_pwg' => PHPWG_VERSION ) 61 343 ); 62 $template->concat('cl_conflit_init', $template->parse('autosize_init_header', true)); 63 return $template->parse( 'autosize_init', false); 344 return $template->parse( 'autosize_init', false); 64 345 }// function cl_autosize_script_1 65 346 … … 71 352 global $template,$user,$conf,$picture ,$page, $cl_plugin,$known_script ; 72 353 global $template,$user,$conf,$picture ,$page, $cl_plugin ; 354 if(isset($page['body_id']) && $page['body_id'] == 'theAdminPage' ) return ; 355 73 356 if ('kardon' == $user['theme'] and isset($_GET['slideshow'])) return ; 74 if (!isset($PAMOORAMICS_PATH)) return ; 357 global $has_pamoorama; 358 if (!$has_pamoorama) return ; 359 75 360 $AUTOSIZE_PATH = dirname(__FILE__).'/'; 76 361 //================================================================ … … 88 373 $src_img_h=isset($_POST['src_img_h'])?$_POST['src_img_h']: $img_width ; 89 374 $src_img_w= isset($_POST['src_img_w'])?$_POST['src_img_w']:$img_height ; 375 376 377 include_once (PHPWG_ROOT_PATH.'include/functions_cookie.inc.php') ; 90 378 if(isset($_COOKIE['img_w'])){ 91 379 $src_img_w=$_COOKIE['img_w']; … … 93 381 } 94 382 95 $window_height= isset($_ POST['window_height'])?$_POST['window_height']: $img_scaled_height ;96 $window_width= isset($_ POST['window_width'])?$_POST['window_width']: $img_scaled_width ;383 $window_height= isset($_SESSION['height'])?$_SESSION['height']: $img_scaled_height ; 384 $window_width= isset($_SESSION['width'])?$_SESSION['width']: $img_scaled_width ; 97 385 98 386 … … 118 406 ) 119 407 ); 120 include_once (PHPWG_ROOT_PATH.'include/functions_cookie.inc.php') ; 408 121 409 $autoscript="<script type='text/javascript'> 122 410 /* cl_autosize_script_2 */ … … 131 419 * cl_autosize_script_3() 132 420 **************************************/ 133 static public function cl_autosize_script_3() 134 { 135 global $template; 136 137 138 $has_pamoorama=isset($template->files['pamooramics_content']); 139 if (!$has_pamoorama) return ; 140 141 $autoscript="<div id='debug' >TEST</div> 142 <script type='text/javascript'> 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 ; 426 427 $autoscript="<script type='text/javascript'> 143 428 if (typeof (Ajout_Ajax) == 'function') 144 429 Ajout_Ajax(); … … 148 433 }// function cl_autosize_script_3 149 434 150 //================================================================151 /*152 * cl_autosize_admin153 */154 static public function cl_autosize_admin($menu)155 {156 global $lang ;157 array_push($menu, array('NAME' => 'Autosize',158 'URL' => get_admin_plugin_menu_link(AUTOSIZE_PATH . 'admin/admin_autosize.php')));159 return $menu;160 } //function cl_autosize_admin161 //=====================================162 163 164 // this is the default handler that generates the display for the element165 static public function autosize_calcContent($content)166 {167 global $conf;168 169 global $page, $template,$picture;170 171 172 $current = $template->get_template_vars('current');173 $defined_types = array_keys(ImageStdParams::get_defined_type_map());174 if (isset($current)){175 if (!isset($current['selected_derivative'])){176 $model= $defined_types[count($defined_types)-1];177 $selected_derivative = $current['derivatives'][$model];178 $template->append('current', array(179 'selected_derivative' => $selected_derivative180 ), true);181 182 183 $current = $template->get_template_vars('current');184 }185 186 $derivative=$current['selected_derivative'] ;187 $imgScaledWH=$derivative->src_image->get_size();188 $imgSizeWH = $derivative->get_size();189 $img_type = $derivative->get_type();190 $img_url = $derivative->get_url();191 $img_all= $derivative->get_all($derivative->src_image);192 $scaled_size=$derivative->get_size_hr(); //792 x 441193 $scaled_size=$derivative->get_scaled_size_htm(); // width="792" height="441"194 //================= taille mis a l'échelle195 $scaled_size=$derivative->get_scaled_size(100,100); // array([0]=>100,[1]=>55)196 $src= $derivative->src_image ;197 198 }199 200 $img_scaled_width=isset($imgScaledWH)?$imgScaledWH[0]:"480";201 $img_scaled_height=isset($imgScaledWH)?$imgScaledWH[1]:"320";202 $current = $template->get_template_vars('picture');203 $picture['current']['scaled_width']=$img_scaled_width;204 $picture['current']['scaled_height']= $img_scaled_height;205 $picture['current']['image_url']=$src->rel_path;206 207 }208 209 //===============================================================210 /*211 *212 */213 static public function cl_autosize_affiche()214 {215 global $user, $picture, $template,$page,$known_script;216 global $content, $element_info;217 global $infos_message,$erreur_message;218 global $conf,$lang ,$user,$userdata;219 if ('kardon' == $user['theme'] and isset($_GET['slideshow'])) return ;220 load_language('plugin.lang', AUTOSIZE_PATH);221 222 $AUTOSIZE_PATH = dirname(__FILE__).'/';223 if (isset( $page['body_id']) && $page['body_id']=='thePicturePage' ) {224 if ( isset($picture['current'])){225 $autosize_parametres = cl_autosize_Get_Options();226 include (AUTOSIZE_PATH."include/affiche.php");227 $file =AUTOSIZE_PATH_ABS.'template/picture_1.tpl' ;228 $template->set_filenames(array('autosize_content_header'=> $file ));229 $template->concat('autosize_content', $template->parse('autosize_content_header', true));230 $template->set_filenames(array('autosize_init_header'=> $file ));231 $theme=$user['theme'];232 $deriv_type = pwg_get_session_var('picture_deriv', IMG_LARGE);233 $defined_types = array_keys(ImageStdParams::get_defined_type_map());234 235 if($autosize_parametres->check_icon_v == 'on'){236 $template->assign('cl_autosize_button',237 array( 'cl_autosize_info' => 'cl_autosize_info' ,238 'cl_autosize_info_1' => 'cl_autosize_info_' ,239 'cl_autosize_info_2' => 'cl_autosize_info_2' ,240 'URL' => $_SERVER['REQUEST_URI'] ,241 'ICON2' => AUTOSIZE_PATH . 'icons/button-maximize.png',242 'ICON' => AUTOSIZE_PATH . 'icons/button-minimize.png',243 'ICON1' => AUTOSIZE_PATH . 'icons/button-no.png'244 )245 246 );247 $template->set_filenames(array('cl_bp' => $AUTOSIZE_PATH. 'template/picture.tpl'));248 $template->concat('PLUGIN_PICTURE_ACTIONS', $template->parse('cl_bp', true));249 }250 $template->set_filenames(251 array('autosize_content'=> $AUTOSIZE_PATH.'template/autosize.tpl',252 'theme' => $theme )253 );254 $template->concat('autosize_content', $template->parse('autosize_content_header', true));255 if(isset($conf['go_up_down']) && ($conf['go_up_down']==true) ){256 $template->set_filenames(array('mes_script' => realpath(AUTOSIZE_PATH).'/template/mes_scripts.tpl') );257 $template->func_combine_script(array('id'=>'my_script_2',258 'path'=> AUTOSIZE_PATH.'/js/JScript.js',259 'require' => 'jquery'),260 $template->smarty);261 $template->assign(array(262 'MY_FOOTER_PATH' =>AUTOSIZE_PATH263 ));264 265 $template->parse('mes_script');266 }267 268 return $template->parse( 'autosize_content', false);269 }270 }271 272 } //public function cl_autosize_affiche273 435 //=============================================================== 274 436 /* … … 520 682 pwg_query($query); 521 683 } 522 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 } 523 691 } 524 692 525 function auto_memo_var($variables)693 function print_var($variables) 526 694 { 527 695 ob_start();
Note: See TracChangeset
for help on using the changeset viewer.