Changeset 18716 for extensions/Autosize/autosize.inc.php
- Timestamp:
- Oct 22, 2012, 4:47:26 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Autosize/autosize.inc.php
r18341 r18716 30 30 return $menu; 31 31 } //function cl_autosize_admin 32 33 34 /************************** 35 * autosize_calcContent * 36 **************************/ 37 static public function autosize_calcContent($content,$element_info){ 38 39 global $conf,$page, $template,$picture,$user; 40 global $defined_types,$pictureSelType ,$pictureDeriv ,$liste_type,$SRC_IMG; 41 global $autosize_parametres,$user_status; 42 global $infos_message,$error_message; 43 //============================================================================== 44 global $DEBUG_autosize; 45 $DEBUG_autosize = isset($_POST['cl_debug']) ? $_POST['cl_debug'] : "false" ; 46 $DEBUG_autosize = isset($_GET['cl_debug']) ? $_GET['cl_debug'] : $DEBUG_autosize ; 47 $DEBUG_autosize = isset($conf['cl_debug']) ? $conf['cl_debug'] : $DEBUG_autosize ; 48 //=============================================================== 49 $ma_page=isset($page['body_id'])?$page['body_id']:"" ; 50 if ($ma_page !='thePicturePage') return ; 51 52 $types = array_intersect(array_keys(ImageStdParams::get_defined_type_map()), array("Autosize","SelMaxi")); 53 if (count($types)==0){ 54 include_once (AUTOSIZE_PATH.'maintain.inc.php'); 55 if (isset($conf['cl_derivatives_sav'])) { 56 plugin_deactivate() ; 57 } 58 plugin_activate(); 59 unset ( $_COOKIE['autosize_reload']) ; 60 } 61 62 if (!isset($_COOKIE['autosize_reload'])){ 63 autosize_controler::reload(); 64 65 } 66 //=================================================================== 67 $current = $template->get_template_vars('current'); 68 if (!isset($current)) return ; 69 //=============================================================== 70 global $imgSizeWH; 71 $derivative = $current['src_image'] ; 72 $imgSizeWH = $derivative->get_size(); 73 $SRC_IMG = $derivative->get_url(); 74 75 $picture['current']['scaled_width']=$imgSizeWH[0]; 76 $picture['current']['scaled_height']= $imgSizeWH[1]; 77 $picture['current']['high_url']= $SRC_IMG; 78 $picture['current']['image_url']=$SRC_IMG; 79 //=============================================================== 80 global $infos_message; 81 82 //============================================================== 83 $autosize_parametres = cl_autosize_Get_Options(); 84 return false ; 85 }//calc_content ; 86 87 88 32 89 /********************* 33 90 * INIT 34 91 *********************/ 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 global $user,$Css,$css_slideshow,$css_display; 40 $current = $template->get_template_vars('current'); 41 //======================================================= 92 static public function init($content,$element_info){ 93 94 95 global $template,$version,$icon_path,$page,$picture,$conf; 96 global $user,$Css,$css_slideshow,$css_display,$liste_type; 97 global $has_pamoorama,$pictureSelType,$pictureDeriv; 98 global $infos_message,$warnings_message; 99 //======================================================= 100 global $has_pamoorama ; 101 $has_pamoorama = isset($template->files['pamooramics_content'])?"true":"false"; 42 102 $theme=$user['theme']; 43 103 $Css = autosize_controler::css($theme."-rules.css"); 44 $css_slideshow=isset($Css['.Autosize']['slideshow'])?$Css['.Autosize']['slideshow']:"yes"; 45 46 $css_display= isset($Css['.Autosize']['display'])?$Css['.Autosize']['display']:"block"; 47 48 //==================================================================== 104 105 $css_slideshow=isset($Css['.Autosize']['slideshow'])?$Css['.Autosize']['slideshow']:"yes"; 106 $css_display= isset($Css['.Autosize']['display'])?$Css['.Autosize']['display']:"block"; 107 //============================================================== 49 108 $pictureDeriv = pwg_get_session_var('picture_deriv',$conf['derivative_default_size']); 50 109 $default_size = $conf['derivative_default_size']; 51 $SRC_IMG=""; 110 $autosize_parametres = cl_autosize_Get_Options(); 111 //======================================================================= 112 $pictureSelType = pwg_get_session_var('picture_sel_type',$pictureSelType); 113 114 if(!isset($_COOKIE['picture_sel_type'])){ 115 if($autosize_parametres->defaut_type=="off") 116 $pictureSelType = pwg_get_session_var('picture_sel_type',"SelMaxi"); 117 else 118 $pictureSelType = pwg_get_session_var('picture_sel_type',"Autosize"); 119 120 }else{ 121 $pictureSelType = $_COOKIE['picture_sel_type'] ; 122 } 123 52 124 //===================================================================== 53 125 54 if(!isset($_COOKIE['picture_deriv'])) 55 if(isset($current['derivatives']['Autosize'])){ 56 $_COOKIE['picture_deriv']="Autosize"; 126 $current = $template->get_template_vars('current'); 127 128 global $set_miniature,$imgSizeWH,$DEBUG_autosize; 129 global $theImageHeight,$theImageWidth,$theMainImageWidth; 130 //=== Zone affichage == 131 $theImageTop= isset($_COOKIE['theImageTop'])?$_COOKIE['theImageTop']:0; 132 $theImageLeft=isset($_COOKIE['theImageLeft'])?$_COOKIE['theImageLeft']:0; 133 134 $theImageRight=isset($_COOKIE['theImageRight'])?$_COOKIE['theImageRight']:0; 135 $theImageBottom=isset($_COOKIE['theImageBottom'])?$_COOKIE['theImageBottom']:0; 136 137 $windowWidth=$_COOKIE['windowWidth']; 138 $windowHeight=$_COOKIE['windowHeight']; 139 140 $theImageMargeWidth=isset($_COOKIE['theImageMargeWidth']) ? $_COOKIE['theImageMargeWidth']:0; 141 $theImageMargeHeight=isset($_COOKIE['theImageMargeHeight'])?$_COOKIE['theImageMargeHeight']:0; 142 143 $theImageWidth= $windowWidth - $theImageRight - $theImageLeft - $theImageMargeWidth; 144 $theImageHeight= $windowHeight - $theImageTop - $theImageBottom - $theImageMargeHeight; 145 $theImageWidth=isset($_COOKIE['theImageWidth']) ? $_COOKIE['theImageWidth']:$theImageWidth; 146 $theImageHeight=isset($_COOKIE['theImageHeight'])?$_COOKIE['theImageHeight']:$theImageHeight; 147 148 $retour= autosize_controler::get_min_max() ; 149 150 if($theImageHeight!=0 && $theImageWidth!=0){ 151 $pictureDeriv=$retour->type ; 152 }else{ 153 $pictureDeriv=$default_size; 154 } 155 156 //============================================================ 157 pwg_set_session_var('picture_deriv',$pictureDeriv); 158 setcookie( 'picture_deriv', 159 $pictureDeriv, 160 0, 161 cookie_path() 162 ); 163 //============================================================ 164 pwg_set_session_var('picture_sel_type',$pictureSelType); 165 setcookie( 'picture_sel_type', 166 $pictureSelType, 167 0, 168 cookie_path() 169 ); 170 //============================================================= 171 $_COOKIE['picture_sel_type']=$pictureSelType; 172 $_COOKIE['picture_deriv']=$pictureDeriv; 173 174 175 $pattern = array(); 176 if($has_pamoorama=="true"){ 177 if($DEBUG_autosize == "c1") echo $theImageWidth . "x" . $theImageHeight ; 178 179 $pattern[0] = '/width\:(.*)(\d+),/';$replacement[0] = 'width: '.$theImageWidth.' ,'; 180 181 if(($theImageWidth!=0)){ 182 $content= preg_replace($pattern, $replacement, $content); 57 183 } 58 if(isset( $_COOKIE['picture_deriv'])) 59 $model= $_COOKIE['picture_deriv'] ; 60 else 61 $model= $pictureDeriv ; 62 63 64 65 if (($css_display=="none" || $css_slideshow=="no") && ($model=="SelMaxi" || $model=="Autosize") ) { 66 $model=$default_size ; 67 $_COOKIE['picture_deriv'] =$model ; 184 if($DEBUG_autosize == "c1") { 185 echo "<!-- " . $theImageWidth . "x" . $theImageHeight . " " .cl_print_var($content) ." -->"; 186 die(); 187 } 188 return $content; 189 } 190 191 $pattern[0] = '/width\:(.*)(\d+)px/';$replacement[0] = 'width:100% '; 192 $pattern[1] = '/height\:(.*)(\d+)px/';$replacement[1] = 'height:100% '; 193 $pattern[2] = '/width=\"(\d+)\"/';$replacement[2] = ' '; 194 $pattern[3] = '/height=\"(\d+)\"/';$replacement[3] = ' '; 195 196 if ( preg_match("|charlie|", $content, $val) ){ 197 198 199 $ncount=1; 200 $content=str_replace( "<object" , "<object id='theMainImage' name='theMainImage' " ,$content,$ncount); 201 $content=str_replace( "<embed" , "<embed id='theMainImage' name='theMainImage' " ,$content,$ncount); 202 $content= preg_replace($pattern, "", $content); 203 204 $content= "<div id='theMainImage' style='height:".$theImageHeight."px ;width:".$theImageWidth."px' >". $content . "<img src='".AUTOSIZE_PATH . "images/transparent.gif' /></div>"; 205 $content= "<style>#theImageAndInfos{height:auto;width:auto;border:1px solid red;position:relative} 206 #theImage{height:auto;border:1px solid blue;align:center;text-align:center;width:100%;position:relative} 207 #theMainImage{height:auto;border:10px solid blue;align:center;text-align:center;position:static} 208 209 210 </style>".$content; 211 212 213 return $content; 214 } 215 216 $content= preg_replace($pattern, "", $content); 217 218 }//INIT 219 220 /************************ 221 * INIT 2 222 *************************/ 223 static public function init2($content,$element_info){ 224 225 226 global $template,$version,$icon_path,$page,$picture,$conf; 227 global $user,$Css,$css_slideshow,$css_display,$liste_type; 228 global $infos_message; 229 //content = photo 230 231 //===================================================================== 232 global $has_pamoorama,$pictureSelType,$pictureDeriv; 233 global $theImageHeight,$theImageWidth; 234 global $DEBUG_autosize; 235 //-- si Autosize correction redim --------------- 236 $current = $template->get_template_vars('current'); 237 if (!isset($current)) return ; 238 239 // if( $has_pamoorama=="true") return $content ; 240 // if($pictureSelType!="Autosize") return $content ; 241 242 $pattern = '/width=\"(\d+)\"/'; 243 $replacement = ''; 244 $content= preg_replace($pattern, $replacement, $content); 245 246 $pattern = '/height=\"(\d+)\"/'; 247 $replacement = ''; 248 $content= preg_replace($pattern, "", $content) ; 249 250 if( $has_pamoorama=="true") return $content ; 251 252 if($DEBUG_autosize != "c1") return $content ; 253 $content= preg_replace($pattern, "", $content) . $pictureDeriv . " " .$pictureSelType; 254 die($content); 255 256 257 $theImageHeight =abs($theImageHeight); 258 $theImageWidth =abs($theImageWidth); 259 260 if ( preg_match("|<img|", $content, $val) ){ 261 $chars=substr($pictureDeriv,0,2); 262 $content=str_replace("<img ","<!--img ",$content); 263 $content=str_replace(">","-->",$content); 264 $src=explode( 'src=',$content); 265 $src=explode( ' ',$src[1]); 266 $src=$src[0]; 267 $char2=substr($src,-7); 268 $content=str_replace("$char2", $chars.'.JPG"',$content); 269 $ncount=1; 270 $content=str_replace( "width" , "old_w" ,$content,$ncount); 271 $content=str_replace( "height" , "old_h" ,$content,$ncount); 272 if (isset($theImageHeight) && isset($theImagewidth)) 273 $content=str_replace(" old_w","style='height:".$theImageHeight."px; width:".$theImageWidth."px;' old_w",$content,$ncount); 274 $content=str_replace("<!--img ","<img ",$content); 275 $content=str_replace("-->",">",$content); 276 277 $content=$content. "<span><br> height:".$theImageHeight."px; width:".$theImageWidth."px; </span>" ; 278 return $content ; 279 } 280 // id="charlie" 281 if ( preg_match("|charlie|", $content, $val) ){ 282 283 284 // return $content ; 285 286 } 287 288 289 290 291 292 } //INIT2 293 /*************************** 294 * 295 ***************************/ 296 static public function reload(){ 297 //========================================= 298 include_once ( "include/functions_cookie.inc.php"); 299 $set_miniature = "<!DOCTYPE html><html><head> 300 <meta http-equiv='content-type' content='text/html; charset=UTF-8'/> 301 <script type='text/javascript' src='themes/default/js/jquery.min.js'></script><script type='text/javascript' src='plugins/Autosize/js/autosizeDetect.js'></script> 302 <script type='text/javascript' src='plugins/Autosize/js/autosize.cookie.js'></script> 303 <script type='text/javascript' src='".PHPWG_ROOT_PATH."themes/default/js/plugins/jquery.ajaxmanager.js'></script>"; 304 $set_miniature .= "<script type='text/javascript' src='".PHPWG_ROOT_PATH."plugins/Autosize/js/autosize_ajax.js' id='autosize_ajax' > </script >"; 305 306 $set_var = "<script type='text/javascript'>\n var COOKIE_PATH = '".cookie_path()."';\n"; 307 global $ma_page,$user,$element_info; 308 $set_var .= " var mapage = '". $ma_page . "';\n"; 309 $set_var .= " var theme = '" .$user['theme']. "';\n"; 310 $set_var .= " var theMainImageWidth = '" .$element_info['width'] . "';\n"; 311 $set_var .= " var theMainImageHeight = '" .$element_info['height'] . "';\n"; 312 $set_var .= " var theMainImageSrc = '" .$element_info['path']. "';\n"; 313 314 $set_var .= " </script >"; 315 316 $autoscript=" 317 </head> 318 <body onload=on_load() style='background-color:black;color :white;font-size:30px ' > 319 please wait, loading... 320 <div></div> 321 </body></html>"; 322 echo $set_miniature ; 323 echo $set_var ; 324 echo $autoscript; 325 die(); 326 //========================================= 327 68 328 } 69 329 70 if(!isset($current['derivatives'][$model])) 71 $model=$default_size ; 72 73 $selected_derivative = $current['derivatives'][$model]; 74 /* 75 'selected_derivative' => $selected_derivative, 76 'unique_derivatives' => $unique_derivatives, 77 */ 78 79 80 if (!isset($current['selected_derivative'])){ 81 82 $current['SelMaxi'] = ImageStdParams::get_custom(900,900); 83 $selected_derivative = ImageStdParams::get_custom($_COOKIE['theImageWidth'], $_COOKIE['theImageHeight']); 84 85 $selected_derivative->type=$model; 86 $template->append('current', array( 330 /************************ 331 * cl_autosize_script_1 332 *************************/ 333 static public function cl_autosize_script_1(){ 334 global $user,$page,$template,$cl_plugin; 335 global $has_pamoorama,$css_slideshow; 336 global $pictureSelType,$pictureDeriv,$infos_message,$conf; 337 global $DEBUG_autosize; 338 339 $ma_page=isset($page['body_id'])?$page['body_id']:"" ; 340 if ($ma_page !='thePicturePage') return ; 341 if ( $has_pamoorama=="false" ) return ; 342 if ($page['slideshow']){ 343 //==== mise à l'échelle === 344 $current = $template->get_template_vars('current'); 345 $default_size = $conf['derivative_default_size']; 346 347 if(isset($current['selected_derivative'])) { 348 $model=$current['selected_derivative']->get_type() ; 349 }else{ 350 $model=$default_size; 351 } 352 353 $selected_derivative = $current['derivatives'][$model]; 354 $template->append('current', array( 87 355 'selected_derivative' => $selected_derivative 88 356 ), 89 357 true); 90 $current = $template->get_template_vars('current'); 358 359 } 360 361 362 363 $template->set_filenames(array('autosize_init'=>AUTOSIZE_PATH_ABS. "template/conflit.tpl" ) ); 364 $autosize_parametres = cl_autosize_Get_Options() ; 365 $theme=$user['theme']; 366 367 //============================================================================== 368 369 $template->assign( 370 array( 371 'autosize_parametres' => $autosize_parametres , 372 'cl_plugins' => $cl_plugin , 373 'cl_version' => $cl_plugin['version'] , 374 'name' => $cl_plugin['name'] , 375 'has_pamoorama' => $has_pamoorama, 376 'theme' => $theme , 377 'DEBUG_autosize' => $DEBUG_autosize, 378 'AUTOSIZE_PATH' => str_replace("../","",AUTOSIZE_PATH) , 379 'AUTOSIZE_PATH_ABS' => AUTOSIZE_PATH_ABS, 380 'Version_pwg' => PHPWG_VERSION , 381 'slideshow' => $page['slideshow'] 382 ) 383 ); 91 384 92 } 93 94 if(isset($current['derivatives'][$model])) { 95 $selected_derivative = $current['derivatives'][$model]; 96 $template->assign('current[selected_derivative]', $selected_derivative , true); 97 $current = $template->get_template_vars('current'); 98 } 99 return $content; 100 101 102 }//INIT 103 /************************** 104 * autosize_calcContent * 105 **************************/ 106 static public function autosize_calcContent($content){ 107 global $conf,$page, $template,$picture,$user; 108 global $defined_types,$maxi_img ,$pictureDeriv ,$liste_type,$SRC_IMG,$select_type; 109 global $has_pamoorama; 110 global $autosize_parametres,$user_status; 111 $defined_types = array_keys(ImageStdParams::get_defined_type_map()); 112 //=============================================================== 113 if(isset($page['body_id']) && $page['body_id'] == 'theAdminPage' ) return ; 114 if (!isset($_COOKIE['autosize_reload'])){ 115 $autoscript="<script type='text/javascript' src='themes/default/js/jquery.min.js'></script> <script type='text/javascript' src='plugins/Autosize/js/autosizeDetect.js'></script> 116 <script type='text/javascript' src='plugins/Autosize/js/autosize.cookie.js'></script> 117 <body onload=on_load() style='background-color:black;color :white;font-size:30px ' > 118 please wait, loading... 119 </body>"; 120 echo $autoscript; 121 die(); 122 } 123 $current = $template->get_template_vars('current'); 124 if (!isset($current)) return ; 125 126 //=============================================================== 127 $derivative = $current['src_image'] ; 128 $imgScaledWH = $derivative->get_size(); 129 $SRC_IMG = $derivative->get_url(); 130 $picture['current']['scaled_width']=$imgScaledWH[0]; 131 $picture['current']['scaled_height']= $imgScaledWH[1]; 132 $picture['current']['high_url']= $SRC_IMG; 133 $picture['current']['image_url']=$SRC_IMG; 134 //=============================================================== 135 136 $user_status = $user['status'] ; 137 $autosize_parametres = cl_autosize_Get_Options(); 138 $user_type= get_user_status($user_status)."_type"; 139 $select_type=$autosize_parametres->$user_type ; 140 141 142 if (isset($_COOKIE['theImageHeight'])){ 143 pwg_set_session_var('theImageWidtht',$_COOKIE['theImageWidth']); 144 pwg_set_session_var('theImageHeight',$_COOKIE['theImageHeight']); 145 } 146 if (isset($_COOKIE['theMainImageHeight'])) pwg_set_session_var('theMainImageHeight',$_COOKIE['theMainImageHeight']); 147 if (isset($_COOKIE['theMainImageWidth'])) pwg_set_session_var('theImageWidth',$_COOKIE['theMainImageWidth']); 148 149 150 if (isset($_COOKIE['picture_deriv'])) 151 pwg_set_session_var('picture_deriv',$_COOKIE['picture_deriv']); 152 else 153 pwg_set_session_var('picture_deriv',$select_type); 154 155 156 $model= $conf['derivative_default_size'] ; // par defaut 157 $pictureDeriv = pwg_get_session_var('picture_deriv', $model); 158 159 160 $model=$pictureDeriv ; 161 162 $value=0; 163 $liste_type=""; 164 $maxi_info=""; 165 if($model!="Autosize" & $model!="SelMaxi"){ 385 386 return $template->parse( 'autosize_init', false); 387 388 389 }// function cl_autosize_script_1 390 391 /************************************* 392 * cl_autosize_script_2() 393 **************************************/ 394 static public function cl_autosize_script_2() 395 { global $css_slideshow; 396 global $pictureSelType,$pictureDeriv,$infos_message; 397 global $template,$user,$conf,$picture ,$page, $cl_plugin,$known_script ; 398 global $template,$user,$conf,$picture ,$page, $cl_plugin ; 399 global $has_pamoorama; 400 global $DEBUG_autosize; 401 402 $ma_page=isset($page['body_id'])?$page['body_id']:"" ; 403 if ($ma_page !='thePicturePage') return ; 404 405 $theme=$user['theme']; 406 if ($has_pamoorama=="false" ) return ; 407 if ($css_slideshow="no" and isset($_GET['slideshow'])) return ; 408 $AUTOSIZE_PATH = dirname(__FILE__).'/'; 409 410 //===================================================================== 411 412 413 $template->assign( 414 array( 415 'cl_version' => $cl_plugin['version'] , 416 'name' => $cl_plugin['name'] , 417 'ma_page' => $ma_page, 418 'theme' => $theme , 419 'DEBUG_autosize' => $DEBUG_autosize , 420 'AUTOSIZE_PATH' => AUTOSIZE_PATH 421 422 ) 423 ); 424 425 $autoscript="<script type='text/javascript'> 426 /* cl_autosize_script_2 */ 427 if (typeof (save_framework) == 'function') 428 save_framework('".$ma_page."'); 166 429 167 }else{ 168 $model=$conf['derivative_default_size'] ; // format par défaut 169 } 170 $derivative=$current['derivatives'][$model] ; 171 $img_all= $derivative->get_all($derivative->src_image); 172 $maxi_img=""; 173 $mini_img=""; 174 $maxi_url=""; 175 $imgSizeWH = $derivative->get_size(); 176 //==== valeur taille image ==== 177 178 $window_width=$imgSizeWH[0]; 179 $window_height=$imgSizeWH[1]; 180 430 </script>"; 431 $template->append('footer_elements',$autoscript); 432 433 return ; 434 }// function cl_autosize_script_2 435 436 /************************************* 437 * cl_autosize_script_3() 438 **************************************/ 439 static public function cl_autosize_script_3() { 440 global $has_pamoorama,$template,$page,$infos_message; 441 $ma_page=isset($page['body_id'])?$page['body_id']:"" ; 442 if ($ma_page !='thePicturePage') return ; 181 443 182 444 183 $window_width = pwg_get_session_var('theMainImageWidth',$imgSizeWH[0]); 184 $window_height = pwg_get_session_var('theMainImageHeight',$imgSizeWH[1]); 185 186 if (!isset($_COOKIE['theMainImageHeight'])) setcookie('theMainImageHeight', $window_height ); 187 if (!isset($_COOKIE['theMainImageWidth'])) setcookie('theMainImageWidth',$window_width); 188 189 //================= Liste ========================= 190 $last_defined=ImageStdParams::get_defined_type_map(); 191 foreach ($img_all as $img_select){ 192 $img_type = $img_select->get_type(); 193 if ($img_type=="square" || $img_type=="thumb" ) continue ; 194 if (!isset($last_img)) $last_img = $img_select; 195 196 $img_url = $img_select->get_url(); 197 $imgSizeWH = $img_select->get_size(); 198 if(!file_exists(PHPWG_ROOT_PATH.$img_url)){ 199 // echo $img_url ."<br />"; 200 } 201 if(file_exists(PHPWG_ROOT_PATH.$img_url)){ 202 if($img_type=="Autosize" || $img_type=="SelMaxi"){ 203 $img_url = $img_select->src_image->get_url(); 204 $imgSizeWH = $img_select->src_image->get_size(); 205 $liste_type[$img_type]=$img_type.",".$img_url.",".$imgSizeWH[0] .",".$imgSizeWH[1] ; 206 207 } 208 $liste_type[$img_type]=$img_type.",".$img_url.",".$imgSizeWH[0] .",".$imgSizeWH[1] ; 209 210 if($window_height < $imgSizeWH[0] ){ 211 $maxi_img= $img_type; 212 $maxi_url= $img_url; 213 $maxi_i=$img_select; 214 } 215 216 if($window_height < $imgSizeWH[0] && $mini_img==""){ 217 $mini_img= $img_type; 218 $mini_url= $img_url; 219 $mini_i=$img_select; 220 } 221 222 if($select_type == $img_type){ 223 if($maxi_img==""){ 224 $maxi_img = $img_type; 225 $maxi_url = $img_url; 226 $maxi_i = $img_select; 227 } 228 if($mini_img==""){ 229 $mini_img= $img_type; 230 $mini_url= $img_url; 231 $mini_i=$img_select; 232 } 233 break ; 234 } 235 } 236 } 237 238 return false ; 239 240 } 445 $template->func_combine_script(array('id'=>'my_script_2', 446 'path'=> AUTOSIZE_PATH.'js/JScript.js', 447 'require' => 'jquery'), 448 $template->smarty); 449 450 $template->func_combine_css(array('id'=>'autosize.css', 451 'path'=> AUTOSIZE_PATH.'css/autosize.css' 452 )); 453 454 455 $autoscript="<script type='text/javascript'> 456 var COOKIE_PATH = '".cookie_path()."' ; 457 </script>"; 458 $template->append('footer_elements',$autoscript); 459 if ($has_pamoorama=="false" ) return ; 460 461 $autoscript="<script type='text/javascript'> 462 if (typeof (Ajout_Ajax) == 'function') 463 Ajout_Ajax(); 464 </script>"; 465 $template->append('footer_elements',$autoscript); 466 467 468 return ; 469 }// function cl_autosize_script_3 241 470 242 471 /************************ … … 244 473 *************************/ 245 474 static public function cl_autosize_affiche(){ 475 476 if (!defined('AUTOSIZE_PATH')) { 477 define( 'AUTOSIZE_PATH', PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/' ); 478 if (!defined('AUTOSIZE_PATH_ABS')) 479 define( 'AUTOSIZE_PATH_ABS', realpath(AUTOSIZE_PATH)."/"); 480 } 481 482 246 483 global $user, $picture, $template,$page,$known_script; 247 484 global $content, $element_info; 248 global $infos_message,$err eur_message;485 global $infos_message,$error_message,$warnings_message; 249 486 global $conf,$lang ,$user,$userdata; 250 global $defined_types,$maxi_img ,$pictureDeriv ,$liste_type,$SRC_IMG,$select_type; 251 global $has_pamoorama; 252 global $autosize_parametres,$user_status; 253 254 if(isset($page['body_id']) && $page['body_id'] == 'theAdminPage' ) return ; 255 487 global $defined_types, $liste_type,$SRC_IMG; 488 global $set_miniature; 489 global $autosize_parametres,$user_status; 490 global $has_pamoorama,$pictureSelType,$pictureDeriv; 491 global $DEBUG_autosize; 492 $ma_page=isset($page['body_id'])?$page['body_id']:"" ; 493 if ($ma_page !='thePicturePage') return ; 494 495 if(isset($set_miniature)){ 496 497 $set_miniature = autosize_controler::cl_autosize_nofile($set_miniature) ; 498 $template->append('footer_elements',$set_miniature); 499 } 500 256 501 global $css_slideshow,$css_display; 257 502 $AUTOSIZE_PATH = dirname(__FILE__).'/'; 258 503 $theme=$user['theme']; 259 260 504 load_language('plugin.lang', AUTOSIZE_PATH); 261 if (isset( $page['body_id']) && $page['body_id']=='thePicturePage' ) { 262 if ( isset($picture['current'])){ 263 include (AUTOSIZE_PATH."include/affiche.php"); 264 $file =AUTOSIZE_PATH_ABS.'template/picture_1.tpl' ; 265 if ($css_display=="none" && $has_pamoorama) { 505 include_once (AUTOSIZE_PATH."include/affiche.php"); 506 if($pictureSelType== $pictureDeriv ) return ; 507 $file =AUTOSIZE_PATH_ABS.'template/picture_1.tpl' ; 508 if ($css_display=="none" && $has_pamoorama=="true" ) { 266 509 $css_display="block" ; 267 510 } 268 511 $file_css=AUTOSIZE_PATH."css/".$theme.".css"; 269 if (!file_exists($file_css)){ 270 $file_css="no"; 271 } 272 512 if (!file_exists($file_css)) $file_css="no"; 273 513 274 514 $template->set_filenames(array('autosize_content_header'=> $file )); 275 515 $template->assign( array( AUTOSIZE_PATH,$AUTOSIZE_PATH, 276 516 'file_css' =>$file_css, 277 'css_display' => $css_display, 278 'select_type' =>$select_type, 517 'css_display' => $css_display, 279 518 'theme' =>$theme 280 519 )); … … 283 522 return ; 284 523 } 285 524 286 525 $file =AUTOSIZE_PATH_ABS.'template/header.tpl' ; 287 526 $template->set_filenames(array('autosize_init_header'=> $file )); … … 304 543 $template->concat('PLUGIN_PICTURE_ACTIONS', $template->parse('cl_bp', true)); 305 544 } 545 546 306 547 $template->set_filenames( 307 548 array('autosize_content'=> $AUTOSIZE_PATH.'template/autosize.tpl', 308 549 'theme' => $theme ) 309 550 ); 551 310 552 $template->concat('autosize_content', $template->parse('autosize_content_header', true)); 311 553 if(isset($conf['go_up_down']) && ($conf['go_up_down']==true) ){ 312 554 $template->set_filenames(array('mes_script' => realpath(AUTOSIZE_PATH).'/template/mes_scripts.tpl') ); 555 313 556 $template->func_combine_script(array('id'=>'my_script_2', 314 557 'path'=> AUTOSIZE_PATH.'/js/JScript.js', 315 558 'require' => 'jquery'), 316 $template->smarty); 559 $template->smarty 560 ); 561 317 562 $template->assign(array( 318 563 'MY_FOOTER_PATH' =>AUTOSIZE_PATH … … 320 565 $template->parse('mes_script'); 321 566 } 567 568 cl_aff_infos_plus(); 322 569 return $template->parse( 'autosize_content', false); 323 }324 }570 571 325 572 326 573 } //public function cl_autosize_affiche 327 328 /************************329 * cl_autosize_script_1330 *************************/331 static public function cl_autosize_script_1(){332 global $user,$page,$template,$cl_plugin;333 if(isset($page['body_id']) && $page['body_id'] == 'theAdminPage' ) return ;334 335 $ma_page=isset($page['body_id'])?$page['body_id']:"" ;336 if ($ma_page=='thePiwiShackControllerPage') return ;337 global $has_pamoorama,$css_slideshow;338 $has_pamoorama = isset($template->files['pamooramics_content']);339 if (!$has_pamoorama) return ;340 341 if ($page['slideshow']){342 $current = $template->get_template_vars('current');343 $model=$current['selected_derivative']->type ;344 $selected_derivative = $current['derivatives'][$model];345 $template->append('current', array(346 'selected_derivative' => $selected_derivative347 ),348 true);349 350 }351 $template->set_filenames(array('autosize_init'=>AUTOSIZE_PATH_ABS. "template/conflit.tpl" ) );352 $autosize_parametres = cl_autosize_Get_Options() ;353 $theme=$user['theme'];354 //==============================================================================355 $DEBUG_autosize = isset($_POST['cl_debug_conflit']) ? $_POST['cl_debug_conflit'] : "false" ;356 $DEBUG_autosize = isset($_GET['cl_debug_conflit']) ? $_GET['cl_debug_conflit'] : $DEBUG_autosize ;357 $DEBUG_autosize = isset($conf['cl_debug_conflit']) ? $conf['cl_debug_conflit'] : $DEBUG_autosize ;358 //==============================================================================359 $template->assign(360 array(361 'autosize_parametres' => $autosize_parametres ,362 'cl_plugins' => $cl_plugin ,363 'cl_version' => $cl_plugin['version'] ,364 'name' => $cl_plugin['name'] ,365 'pamoorama' => $has_pamoorama,366 'theme' => $theme ,367 'DEBUG_autosize' => $DEBUG_autosize,368 'AUTOSIZE_PATH' => str_replace("../","",AUTOSIZE_PATH) ,369 'AUTOSIZE_PATH_ABS' => AUTOSIZE_PATH_ABS,370 'Version_pwg' => PHPWG_VERSION ,371 'slideshow' => $page['slideshow']372 )373 );374 375 return $template->parse( 'autosize_init', false);376 377 }// function cl_autosize_script_1378 379 /*************************************380 * cl_autosize_script_2()381 **************************************/382 static public function cl_autosize_script_2()383 {384 global $template,$user,$conf,$picture ,$page, $cl_plugin,$known_script ;385 global $template,$user,$conf,$picture ,$page, $cl_plugin ;386 if(isset($page['body_id']) && $page['body_id'] == 'theAdminPage' ) return ;387 global $has_pamoorama;388 if (!$has_pamoorama) return ;389 global $css_slideshow;390 391 if ($css_slideshow="no" and isset($_GET['slideshow'])) return ;392 393 394 $AUTOSIZE_PATH = dirname(__FILE__).'/';395 //================================================================396 $DEBUG_autosize = isset($_POST['cl_debug_conflit']) ? $_POST['cl_debug_conflit'] : "false" ;397 $DEBUG_autosize = isset($_GET['cl_debug_conflit']) ? $_GET['cl_debug_conflit'] : $DEBUG_autosize ;398 $DEBUG_autosize = isset($conf['cl_debug_conflit']) ? $conf['cl_debug_conflit'] : $DEBUG_autosize ;399 //=====================================================================400 $ma_page=isset($page['body_id'])?$page['body_id']:"" ;401 $theme=$user['theme'];402 if ($ma_page=='thePiwiShackControllerPage') return ;403 $img_width=isset($picture['current']['width'])?$picture['current']['width']:480;404 $img_height=isset($picture['current']['height'])?$picture['current']['height']:320;405 $img_scaled_width=isset($picture['current']['scaled_width'])?$picture['current']['scaled_width']:480;406 $img_scaled_height=isset($picture['current']['scaled_height'])?$picture['current']['scaled_height']:320;407 $src_img_h=isset($_POST['src_img_h'])?$_POST['src_img_h']: $img_width ;408 $src_img_w= isset($_POST['src_img_w'])?$_POST['src_img_w']:$img_height ;409 410 411 include_once (PHPWG_ROOT_PATH.'include/functions_cookie.inc.php') ;412 if(isset($_COOKIE['img_w'])){413 $src_img_w=$_COOKIE['img_w'];414 $src_img_h=$_COOKIE['img_h'];415 }416 417 $window_height= isset($_SESSION['height'])?$_SESSION['height']: $img_scaled_height ;418 $window_width= isset($_SESSION['width'])?$_SESSION['width']: $img_scaled_width ;419 420 421 $size=array(422 'src_img_h' => $src_img_h,423 'src_img_w' => $src_img_w,424 'window_height' =>$window_height,425 'window_width' => $window_width426 427 );428 429 $template->assign(430 array(431 'cl_version' => $cl_plugin['version'] ,432 'name' => $cl_plugin['name'] ,433 'ma_page' => $ma_page,434 435 'theme' => $theme ,436 'DEBUG_autosize' => $DEBUG_autosize ,437 'AUTOSIZE_PATH' => AUTOSIZE_PATH,438 'Size' => $size439 440 )441 );442 443 $autoscript="<script type='text/javascript'>444 /* cl_autosize_script_2 */445 if (typeof (save_framework) == 'function')446 save_framework('".$ma_page."');447 var cookie_path ='". cookie_path() ."'448 </script>";449 $template->append('footer_elements',$autoscript);450 return ;451 }// function cl_autosize_script_2452 /*************************************453 * cl_autosize_script_3()454 **************************************/455 static public function cl_autosize_script_3() {456 global $template,$page;457 if(isset($page['body_id']) && $page['body_id'] == 'theAdminPage' ) return ;458 global $has_pamoorama;459 if (!$has_pamoorama) return ;460 461 $autoscript="<script type='text/javascript'>462 if (typeof (Ajout_Ajax) == 'function')463 Ajout_Ajax();464 </script>";465 $template->append('footer_elements',$autoscript);466 return ;467 }// function cl_autosize_script_3468 469 //===============================================================470 /*471 *472 */473 static public function cl_autosize_aff_infos_plus()474 {475 global $template,$infos_message,$erreur_message, $user ;476 global $conf,$lang ;477 478 //==============================================================479 if (isset($erreur_message))480 {481 if ($erreur_message <> "")482 {483 $erreur_message=str_replace("\n",'<br />',$erreur_message) ;484 $template->assign('errors',$erreur_message);485 $erreur_message="";486 }487 }488 if (isset($infos_message))489 {490 491 if ($infos_message <> "")492 {493 $infos_message=str_replace("\n",'<br />',$infos_message) ;494 $template->assign('infos',$infos_message);495 $infos_message="";496 }497 }498 //=============================================================499 return;500 501 } // function cl_autosize_aff_infos_plus502 //===============================================================503 /*504 *505 */506 static public function cl_ajuste_data($content){507 global $template,$user,$conf,$picture ;508 global $size;509 $AUTOSIZE_PATH = realpath(AUTOSIZE_PATH .'/');510 $userdata=$user;511 $fields = array( 'maxwidth', 'maxheight' );512 513 $ThePicture = $template->get_template_vars('current');514 $data = array();515 return $content;516 517 $data['maxwidth'] = $size['src_img_w'];518 $data['maxheight'] =$size['src_img_h'];519 $data['user_id'] = $userdata['id'];520 foreach ($fields as $field)521 {522 if (isset($_POST[$field]))523 {524 $data[$field] = $_POST[$field];525 }526 }527 528 if($data['maxwidth'] != "" )529 {530 $picture['current']['scaled_width']=$data['maxwidth'];531 $picture['current']['scaled_height']=$data['maxheight'];532 mass_updates(USER_INFOS_TABLE,533 array('primary' => array('user_id'), 'update' => $fields),534 array($data));535 }536 537 return $content;538 }539 574 540 575 … … 581 616 $def_para['check_desc_v'] = "off" ; 582 617 $def_para['check_icon_v'] = "off" ; 583 618 $def_para['defaut_type'] = "off" ; 619 584 620 $def_para['webmaster_enabled'] = "off" ; 585 621 $def_para['admin_enabled'] = "off" ; … … 702 738 return $css; 703 739 } 704 //================================================= 705 706 740 741 /*************************** 742 * get_min_max 743 ***************************/ 744 static public function get_min_max(){ 745 global $liste_type,$img_all,$set_miniature,$template,$infos_message,$error_message,$has_pamoorama ; 746 global $theImageWidth,$theImageHeight,$pictureSelType,$pictureDeriv ; 747 $current = $template->get_template_vars('current'); 748 $liste_type=""; 749 $del_deriv_types = array(); 750 $i=0; 751 $defined_types = array_keys(ImageStdParams::get_defined_type_map()); 752 foreach($defined_types as $type){ 753 754 if($type!="Autosize" && $type!="SelMaxi" ){ 755 $last_derivative= $type ; 756 $del_deriv_types[$i] = $last_derivative ; 757 $i++; 758 } 759 760 } 761 ; 762 $derivative=$current['derivatives'][$last_derivative] ; 763 $img_all= $derivative->get_all($derivative->src_image); 764 765 766 $retour = (object) ''; 767 $maxi_image = (object) ''; 768 $mini_image = (object) ''; 769 $std_image = (object) ''; 770 $default_image=(object) ''; 771 $last_image=(object) ''; 772 773 global $imgSizeWH ; 774 $imgSizeWH = $derivative->get_size(); 775 $theImage_maxi=0; 776 $theImage_mini=0; 777 $theImage_def=0; 778 $No_files= array(); 779 //================= Liste ========================= 780 $ok= 0 ; 781 $nofile=0 ; 782 //============================================= 783 // Liste mini maxi 784 //============================================= 785 foreach ($img_all as $img_select){ 786 $img_type = $img_select->get_type(); 787 $img_url = $img_select->get_path(); 788 $imgWH = $img_select->get_size(); 789 if ($img_type=="square" || $img_type=="thumb" ) continue ; 790 if($img_type=="Autosize" || $img_type=="SelMaxi"){ 791 $theImage_def +=1 ; 792 continue; 793 } 794 if(!file_exists(PHPWG_ROOT_PATH.$img_url)){ 795 $No_files[$img_type] = $img_select ; 796 $nofile++ ; 797 } 798 if(file_exists(PHPWG_ROOT_PATH.$img_url)){ } // if file 799 800 if ($theImage_def==0){ 801 // Avant Autosize ou Original; 802 if($img_type=="Original") { 803 $theImage_def = 1; 804 $theImage_maxi=1; 805 $theImage_mini=1; 806 if($ok==0){ 807 $last_image->type=$img_type; 808 $last_image->url=$img_url; 809 $last_image=$img_select; 810 } 811 }else{ 812 $last_derivative=$img_type ; 813 $last_image= $img_select; 814 } 815 } 816 if ($theImage_maxi==0){ 817 $maxi_image= $img_select; 818 } 819 if ($theImage_mini==0){ 820 $mini_image= $img_select; 821 } 822 823 $liste_type[$img_type]=$img_type.",".$img_url.",".$imgWH[0] .",".$imgWH[1] ; 824 if( $img_type=="Original" && $theImage_def==0 ){ 825 $theImage_def=1; 826 $img_type = $last_derivative ; 827 $img_url= $derivative->get_path(); 828 $imgWH = $derivative->get_size(); 829 830 $default_image->type=$img_type; 831 $default_image->url=$img_url; 832 $default_image=$img_select; 833 834 } 835 836 if($has_pamoorama==true) 837 $test= ($imgWH[1] > $theImageHeight) ; 838 else 839 $test= ($imgWH[1] > $theImageHeight && $imgWH[0] > $theImageWidth); 840 if($theImage_maxi==0) 841 if( $test ){ 842 $theImage_maxi=1; 843 $maxi_image->type = $img_type; 844 $img_type=$img_select->get_type(); 845 if($img_type=="Original") 846 $maxi_image = $last_image; 847 else 848 $maxi_image = $img_select; 849 850 851 } else { 852 853 $mini_image->type=$img_type; 854 $mini_image->url=$img_url; 855 $mini_image=$img_select; 856 } 857 858 } // for 859 //================================================ 860 861 862 $retour=(object)'' ; 863 if ($pictureSelType=="Autosize") $retour= $maxi_image ; 864 else if ($pictureSelType=="SelMaxi") $retour= $mini_image ; 865 else $retour=$last_image ; 866 if (!isset( $retour->type)){ 867 $retour=$last_image; 868 $retour->type = $retour->get_type(); 869 $retour->url = $retour->get_path(); 870 } 871 872 if($nofile > 0){ 873 874 $set_miniature=$No_files ; 875 876 877 878 } 879 880 881 if($retour->type=="Original") 882 $retour->type=$last_derivative ; 883 return $retour ; 884 885 } 886 //================================================================== 887 static public function cl_autosize_nofile($img_all){ 888 //=== verification fichiers absents === 889 global $infos_message,$error_message; 890 $ok=false ; 891 $nofiles=array(); 892 $file_no=(object) ''; 893 894 $nosrc=false ; 895 $ok=true ; 896 $listes=""; 897 foreach ($img_all as $img_select){ 898 $img_url = $img_select->get_url(); 899 if(!file_exists(PHPWG_ROOT_PATH.$img_url)){ 900 $img_type = $img_select->get_type(); 901 $file_id=explode("?",$img_url); 902 if(count($file_id) ==1){ 903 $file_id[]=$file_id[0] ; 904 }else{ 905 906 907 } 908 909 if ( !preg_match("|".$file_id[1]."|", $listes) ){ 910 911 $listes .= $file_id[1] ."<br />"; 912 $file_no->url=$file_id[1] ; 913 $id = $img_select->src_image->id; 914 $file_no->id=$id ; 915 $file_no->type=$img_type ; 916 array_push($nofiles,serialize($file_no)) ; 917 918 919 } 920 921 $ok=false ; 922 } 923 } 924 925 $exec_miniatures=""; 926 $infos_message .= $infos_message; 927 928 if(count($nofiles)>0){ 929 //======================================================================================= 930 if($nosrc!=true ){ 931 $exec_miniatures = "<script type='text/javascript' src='".PHPWG_ROOT_PATH."themes/default/js/plugins/jquery.ajaxmanager.js' ></script>"; 932 $exec_miniatures .= "<script type='text/javascript' src='".PHPWG_ROOT_PATH."plugins/Autosize/js/autosize_ajax.js' id='autosize_ajax' > </script >"; 933 $nosrc=true ; 934 } 935 $exec_miniatures .= "<script type='text/javascript'> 936 var nofile=Array("; 937 for ($i=0;$i < count($nofiles);$i++){ 938 $file=unserialize($nofiles[$i]); 939 $exec_miniatures .= "{id:'".$file->id."',type:'". $file->type."',file:'". $file->url."'},\n" ; 940 } 941 if($i>0) $exec_miniatures .= "{id:'".$file->id."',type:'". $file->type."'}" ; 942 $exec_miniatures .= "); </script>\n" ; 943 $exec_miniatures .= "<script type='text/javascript' > 944 if(typeof nofile!='undefined') 945 getDerivativeUrls(nofile); 946 </script>"; 947 //================================================================================== 948 949 return $exec_miniatures ; 950 } 951 952 } 953 //================================================== 707 954 } // class 708 955 … … 773 1020 $my_para->check_desc_v = isset($_POST['check_desc_v']) ? $_POST['check_desc_v'] : "off" ; 774 1021 $my_para->check_icon_v = isset($_POST['check_icon_v']) ? $_POST['check_icon_v'] : "off" ; 775 1022 $my_para->defaut_type= isset($_POST['defaut_type']) ? $_POST['defaut_type'] : "off" ; 776 1023 777 1024 $my_para->webmaster_enabled = isset($_POST['webmaster_enabled']) ? $_POST['webmaster_enabled'] : "off" ; … … 784 1031 $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') ; 785 1032 $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') ; 786 787 1033 $my_para->defaut_type = isset($_POST['defaut_type']) ? $_POST['defaut_type'] : ( ( isset($my_para->defaut_type) ) ? $my_para->defaut_type : 'off') ; 788 1034 789 1035 $my_para->webmaster_enabled = isset($_POST['webmaster_enabled']) ? $_POST['webmaster_enabled'] : ( ( isset($my_para->webmaster_enabled) ) ? $my_para->webmaster_enabled : 'on') ; … … 822 1068 } 823 1069 } 824 825 function print_var($variables) 826 { 827 ob_start(); 828 echo '<pre>'; 829 print_r($variables); 830 echo '</pre>'; 831 $m= ob_get_contents(); 832 ob_end_clean(); 833 return $m; 1070 /************************* 1071 * 1072 *************************/ 1073 if(!function_exists("cl_print_var")){ 1074 function cl_print_var($variables){ 1075 ob_start(); 1076 echo '<pre>'; 1077 print_r($variables); 1078 echo '</pre>'; 1079 $m= ob_get_contents(); 1080 ob_end_clean(); 1081 return $m; 1082 } 834 1083 } 835 836 1084 /****************** 1085 * 1086 ******************/ 1087 if(!function_exists("cl_aff_infos_plus")){ 1088 function cl_aff_infos_plus() 1089 { 1090 global $template,$infos_message,$error_message,$warnings_message, $user ; 1091 global $conf,$lang,$page ; 1092 //============================================================== 1093 if (isset($error_message)) { 1094 if ($error_message <> ""){ 1095 $error_message=str_replace("\n",'<br />',$error_message) ; 1096 $template->assign('errors',$error_message); 1097 $error_message=""; 1098 } 1099 } 1100 //============================================================== 1101 if (isset($warnings_message)) { 1102 if ($warnings_message <> ""){ 1103 $warnings_message=str_replace("\n",'<br />',$warnings_message) ; 1104 $template->assign('warnings',$warnings_message); 1105 $warnings_message=""; 1106 } 1107 } 1108 //============================================= 1109 if (isset($infos_message)){ 1110 if ($infos_message <> ""){ 1111 $infos_message=str_replace("\n",'<br />',$infos_message) ; 1112 $template->assign('infos',$infos_message); 1113 $infos_message=""; 1114 } 1115 } 1116 //============================================================= 1117 return; 1118 1119 } // function cl_autosize_aff_infos_plus 1120 //=============================================================== 1121 } 837 1122 838 1123 ?>
Note: See TracChangeset
for help on using the changeset viewer.