'Autosize', 'URL' => get_admin_plugin_menu_link(AUTOSIZE_PATH . 'admin/admin_autosize.php'))); return $menu; } //function cl_autosize_admin /************************** * autosize_calcContent * **************************/ static public function autosize_calcContent($content,$element_info){ global $conf,$page, $template,$picture,$user; global $defined_types,$pictureSelType,$pictureMap ,$pictureDeriv ,$liste_type,$SRC_IMG; global $autosize_parametres,$user_status; global $infos_message,$error_message; //============================================================================== global $DEBUG_autosize; if( isset($_GET['cl_debug']) && $_GET['cl_debug'] =='false') { $DEBUG_autosize=""; }else{ $DEBUG_autosize = isset($_POST['cl_debug']) ? $_POST['cl_debug'] : "" ; $DEBUG_autosize = isset($_GET['cl_debug']) ? $_GET['cl_debug'] : $DEBUG_autosize ; $DEBUG_autosize = isset($conf['cl_debug']) ? $conf['cl_debug']."," . $DEBUG_autosize : $DEBUG_autosize ; //=============================================================== } if(preg_match("|event|", $DEBUG_autosize, $val)) $infos_message = "autosize_calcContent, " ; $ma_page=isset($page['body_id'])?$page['body_id']:"" ; if ($ma_page !='thePicturePage') return ; $default_size = $conf['derivative_default_size']; //============================================================ self::get_cookies(); $types = array_intersect(array_keys(ImageStdParams::get_defined_type_map()), array("Autosize","SelMaxi")); if (count($types)==0){ include_once (AUTOSIZE_PATH.'maintain.inc.php'); if (isset($conf['cl_derivatives_sav'])) { plugin_deactivate() ; } plugin_activate(); unset ( $_COOKIE['autosize_reload']) ; } if(preg_match("|test|", $DEBUG_autosize, $val)) { $infos_message .= "#65 autosize_calcContent:
"; if ( isset($_COOKIE['pwg_id']) ) unset ($_COOKIE['pwg_id']) ; $infos_message .= "SESSION:" . cl_print_var($_SESSION) ; $infos_message .= "COOKIE:" . cl_print_var($_COOKIE) ; $infos_message .= "GET:" . cl_print_var($_GET) ; $infos_message .= "POST:" . cl_print_var($_POST) ; $infos_message .= "$pictureDeriv $pictureSelType $pictureMap "; // self::Fin_php ("#75: ".$DEBUG_autosize); } if(!isset($_COOKIE['picture_deriv'] )){ if(preg_match("|test_1|", $DEBUG_autosize, $val)) { $infos_message .= "not COOKIE['picture_deriv'] -> reload():
"; self::Fin_php("#80 autosize_calcContent:" . $DEBUG_autosize ); } unset($_COOKIE['autosize_reload']); } if (!isset($_COOKIE['autosize_reload']) ){ if(preg_match("|test_2|", $DEBUG_autosize, $val)) { $infos_message .= "not COOKIE['autosize_reload'] -> reload():
"; self::Fin_php("#87 autosize_calcContent:" . $DEBUG_autosize); } self::reload("#89"); // self::Fin_php("#90 autosize_calcContent:" + $DEBUG_autosize); } //=================================================================== $current = $template->get_template_vars('current'); if (!isset($current)) return ; //=============================================================== global $imgSizeWH; $derivative = $current['src_image'] ; $imgSizeWH = $derivative->get_size(); $SRC_IMG = $derivative->get_url(); $picture['current']['scaled_width']=$imgSizeWH[0]; $picture['current']['scaled_height']= $imgSizeWH[1]; $picture['current']['high_url']= $SRC_IMG; $picture['current']['image_url']=$SRC_IMG; $picture['current']['thumbnail']=$SRC_IMG; //============================================================== $autosize_parametres = cl_autosize_Get_Options(); return false ; }//calc_content ; /********************* * INIT *********************/ static public function init_3(){ } static public function init_1($content, $image) { global $conf, $template, $page; if(!isset($conf['AS_panorama'])) return $content; $asp = & $conf['AS_panorama']; if ( !stristr($image['name'], $asp['in_mode_360']) and !stristr($image['name'], $asp['in_mode_180']) ) return $content; $asp['min_viewport_width']=$_COOKIE['windowWidth'] -$_COOKIE['theImageLeft']-$_COOKIE['theImageRight']; $asp['viewport_height']=$_COOKIE['windowHeight']-130 ; $asp['start_position']= 10; } /*********************/ static public function init($content,$element_info){ global $template,$version,$icon_path,$page,$picture,$conf; global $user,$Css,$css_slideshow,$css_display,$liste_type; global $has_pamoorama,$pictureSelType,$pictureDeriv,$pictureMap; global $infos_message,$warnings_message; global $set_miniature,$imgSizeWH,$DEBUG_autosize; global $theImageHeight,$theImageWidth,$theImageLeft,$theImageTop,$windowWidth,$windowHeight,$theMainImageSize; //======================================================= global $has_pamoorama ; if( isset($_GET['cl_debug']) && $_GET['cl_debug'] =='false') { $DEBUG_autosize=""; }else{ $DEBUG_autosize = isset($_POST['cl_debug']) ? $_POST['cl_debug'] : "" ; $DEBUG_autosize = isset($_GET['cl_debug']) ? $_GET['cl_debug'] : $DEBUG_autosize ; $DEBUG_autosize = isset($conf['cl_debug']) ? $conf['cl_debug']."," . $DEBUG_autosize : $DEBUG_autosize ; //=============================================================== } if(preg_match("|event|", $DEBUG_autosize, $val)) { $infos_message .= "init, ";} ; $has_pamoorama = isset($template->files['pamooramics_content'])?"true":"false"; $theme=$user['theme']; $Css = self::css($theme."-rules.css"); $css_slideshow=isset($Css['.Autosize']['slideshow'])?$Css['.Autosize']['slideshow']:"yes"; $css_display= isset($Css['.Autosize']['display'])?$Css['.Autosize']['display']:"block"; $default_size = $conf['derivative_default_size']; //============================================================ self::get_cookies(); //============================================================== if(preg_match("|test|", $DEBUG_autosize, $val)) { $infos_message .= "#133
Init:SESSION:" . cl_print_var($_SESSION) ; if ( isset($_COOKIE['pwg_id']) ) unset ($_COOKIE['pwg_id']) ; $infos_message .= "GET:" . cl_print_var($_GET) ; $infos_message .= "POST:" . cl_print_var($_POST) ; $infos_message .= "$pictureDeriv $pictureSelType $pictureMap "; // self::Fin_php("#138: ".$DEBUG_autosize); } $autosize_parametres = cl_autosize_Get_Options(); //===================================================================== $current = $template->get_template_vars('current'); //=== Zone affichage == $windowWidth=$_COOKIE['windowWidth'] ; $windowHeight=$_COOKIE['windowHeight'] ; $theImageTop= isset($_COOKIE['theImageTop'])?$_COOKIE['theImageTop']:0; $theImageLeft=isset($_COOKIE['theImageLeft'])?$_COOKIE['theImageLeft']:0; $theImageRight=isset($_COOKIE['theImageRight'])?$_COOKIE['theImageRight']:0; $theImageBottom=isset($_COOKIE['theImageBottom'])?$_COOKIE['theImageBottom']:0; $theImageMargeWidth=isset($_COOKIE['theImageMargeWidth']) ? $_COOKIE['theImageMargeWidth']:0; $theImageMargeHeight=isset($_COOKIE['theImageMargeHeight'])?$_COOKIE['theImageMargeHeight']:0; $theImageMargeHeight -= 2; if(isset($_COOKIE['theImageWidth'])){ $theImageWidth= $_COOKIE['theImageWidth']; $theImageHeight= $_COOKIE['theImageHeight'] ; } $theImageWidth= $windowWidth - $theImageLeft - $theImageMargeWidth; $theImageHeight= $windowHeight - $theImageTop - $theImageMargeHeight ; if (isset($element_info['is_gvideo']) && $element_info['is_gvideo'] ){ $pictureDeriv=$default_size; }else{ $retour = self::get_min_max() ; $theMainImageSize = $retour->get_size(); $theMainImageWidth= isset($_COOKIE['theMainImageWidth'])?$_COOKIE['theMainImageWidth']:$theMainImageSize[0]; $theMainImageHeight= isset($_COOKIE['theMainImageHeight'])?$_COOKIE['theMainImageHeight']:$theMainImageSize[1] ; if($theImageHeight!=0 && $theImageWidth!=0){ $pictureDeriv=$retour->type ; }else{ $pictureDeriv=$default_size; } } if(preg_match("|test|", $DEBUG_autosize, $val)) { $infos_message .= "#208
Init:SESSION:" . cl_print_var($_SESSION) ; if ( isset($_COOKIE['pwg_id']) ) unset ($_COOKIE['pwg_id']) ; $infos_message .= "Init: COOKIE:" . cl_print_var($_COOKIE) ; $infos_message .= "GET:" . cl_print_var($_GET) ; $infos_message .= "POST:" . cl_print_var($_POST) ; $infos_message .=("#193: ".$DEBUG_autosize); } $pattern = array(); if($has_pamoorama=="true"){ if(preg_match("|c1|", $DEBUG_autosize, $val)) echo $theImageWidth . "x" . $theImageHeight ; $pattern[0] = '/width\:(.*)(\d+),/';$replacement[0] = 'width: '.$theImageWidth.' ,'; if(($theImageWidth!=0)){ $content= preg_replace($pattern, $replacement, $content); } if(preg_match("|c1|", $DEBUG_autosize, $val)) { echo ""; self::Fin_php("#225: " . $DEBUG_autosize); } return $content; } if(isset($_GET['map'])){ return $content; } $pattern[0] = '/width\:(.*)(\d+)px/';$replacement[0] = 'width:100% '; $pattern[1] = '/height\:(.*)(\d+)px/';$replacement[1] = 'height:100% '; $pattern[2] = '/width=\"(\d+)\"/';$replacement[2] = ' '; $pattern[3] = '/height=\"(\d+)\"/';$replacement[3] = ' '; if ( strstr( $content,"iframe")||strstr($content,"charlie" )){ $pictureSelType="Autosize"; $pictureDeriv=$conf['derivative_default_size']; $_COOKIE['picture_sel_type']=$pictureSelType; $_COOKIE['picture_deriv']=$pictureDeriv; $ncount=1; if (strstr($content,"charlie" )){ $content=str_replace( "". $content . ""; $content= "".$content; return $content; } $content= preg_replace($pattern, "", $content); return $content; }//INIT /************************ * INIT 2 *************************/ static public function init2($content,$element_info){ global $template,$version,$icon_path,$page,$picture,$conf; global $user,$Css,$css_slideshow,$css_display,$liste_type; global $infos_message; //content = photo //===================================================================== global $has_pamoorama,$pictureSelType,$pictureDeriv; global $DEBUG_autosize; if(preg_match("|event|", $DEBUG_autosize, $val)) { $infos_message .= "init2, ";} ; global $theImageHeight,$theImageWidth,$theImageLeft,$theImageTop,$windowWidth,$windowHeight,$theMainImageSize; //-- si Autosize correction redim --------------- $current = $template->get_template_vars('current'); if (!isset($current)) return ; if($pictureSelType!="Autosize") return $content ; $pattern =Array('/width=\"(\d+)\"/','/height=\"(\d+)\"/'); $replacement = Array('',"style='height:".$theImageHeight."px'"); $replacement = Array('',""); $content= preg_replace($pattern, $replacement, $content); if( $has_pamoorama=="true") return $content ; if( !preg_match("|c1|", $DEBUG_autosize, $val) ) return $content ; //************************ c1 *************************************** echo "theMainImageWidth :" . $theMainImageSize[0] . " X " . $theMainImageSize[1] . "
"; echo "theImageWidth :" . $theImageWidth . " X " . $theImageHeight . "
"; echo $infos_message."
"; $Ratio = $theMainImageSize[0]/$theMainImageSize[1]; $nh = intval($theImageWidth / $Ratio) ; $nw = intval($theImageHeight * $Ratio) ; echo $nw . "x " . $nh ."
"; if($theMainImageSize[0] < $nw){ echo "HEIGHT " .$theImageHeight . " WIDTH " . $nw."
"; } if($theMainImageSize[1] < $nh ){ echo "HEIGHT " . $nh . " WIDTH " . ($theImageWidth)."
"; } $content= $content . $pictureDeriv . " " .$pictureSelType; echo "
"; echo "left:".$theImageLeft."px;top:".$theImageTop."px;width:".$theImageWidth ."px;height:" .$theImageHeight."px;"; echo "
"; self::Fin_php("#320 : " . $content + $DEBUG_autosize); } //INIT2 /*************************** * ***************************/ static public function reload($id_ret){ //========================================= include_once ( "include/functions_cookie.inc.php"); global $ma_page,$user,$element_info,$infos_message,$DEBUG_autosize; global $pictureDeriv,$pictureSelType,$pictureMap; global $conf; $set_miniature = " "; $set_miniature .= ""; $set_var = ""; $autoscript=" please wait, loading($id_ret)...
"; $default_size = $conf['derivative_default_size']; //======================================================================= $pictureSelType = pwg_get_session_var('picture_sel_type',$default_size); $pictureDeriv = pwg_get_session_var('picture_deriv',$default_size); $pictureMap = pwg_get_session_var('picture_map',$default_size); //======================================================================= $autosize_parametres = cl_autosize_Get_Options(); $userst= $user['status']."_enabled" ; $userst=$autosize_parametres-> $userst; $usertype= $user['status']."_type" ; $usertype = $autosize_parametres->$usertype; if($userst=='off'){ }else{ if($usertype!="Autosize" && $usertype!="SelMaxi" ){ $pictureSelType = $usertype; $pictureDeriv = $usertype; }else if($autosize_parametres->defaut_type=="off"){ $pictureSelType = pwg_get_session_var('picture_sel_type',"SelMaxi"); }else { $pictureSelType = pwg_get_session_var('picture_sel_type',"Autosize"); } } //============================================================ self::save_cookies(); if( !isset($_COOKIE['picture_deriv']) ){ echo "INIT
";
  print_r($_COOKIE);
  self::Fin_php("#393: ".$DEBUG_autosize);
}

if(preg_match("|vue_init|", $DEBUG_autosize, $val)) {    
  $infos_message.="Reload: $userst 
$usertype
autosize_parametres:" . cl_print_var($autosize_parametres) ; if ( isset($_COOKIE['pwg_id']) ) unset ($_COOKIE['pwg_id']) ; echo "Reload: SESSION:" . cl_print_var($_SESSION) ; echo "Reload: COOKIE:" . cl_print_var($_COOKIE) ; echo "GET:" . cl_print_var($_GET) ; echo "POST:" . cl_print_var($_POST) ; self::Fin_php("#403: ".$DEBUG_autosize); } $infos_message.="Reload: $userst
$usertype
autosize_parametres:" . cl_print_var($autosize_parametres) ; if(!preg_match("|aff_init|", $DEBUG_autosize, $val)) { $infos_message=""; } echo $set_miniature ; echo $set_var ; echo $autoscript; // self::Fin_php("#411: ".$DEBUG_autosize); } /************************ * cl_autosize_script_1 *************************/ static public function cl_autosize_script_1(){ global $user,$page,$template,$cl_plugin,$cl_version; global $has_pamoorama,$css_slideshow; global $pictureSelType,$pictureDeriv,$infos_message,$conf; global $DEBUG_autosize; if(preg_match("|event|", $DEBUG_autosize, $val)) { $infos_message .= "cl_autosize_script_1, " ;} ; $ma_page=isset($page['body_id'])?$page['body_id']:"" ; if ($ma_page !='thePicturePage') return ; if ( $has_pamoorama=="false" ) return ; if ($page['slideshow']){ //==== mise à l'échelle === $current = $template->get_template_vars('current'); $default_size = $conf['derivative_default_size']; if(isset($current['selected_derivative'])) { $model=$current['selected_derivative']->get_type() ; }else{ $model=$default_size; } $selected_derivative = $current['derivatives'][$model]; $template->append('current', array( 'selected_derivative' => $selected_derivative ), true); } $template->set_filenames(array('autosize_init'=>AUTOSIZE_PATH_ABS. "template/conflit.tpl" ) ); $autosize_parametres = cl_autosize_Get_Options() ; $theme=$user['theme']; //============================================================================== $template->assign( array( 'autosize_parametres' => $autosize_parametres , 'cl_plugins' => $cl_plugin , 'cl_version' => $cl_version , 'name' => $cl_plugin['name'] , 'has_pamoorama' => $has_pamoorama, 'theme' => $theme , 'DEBUG_autosize' => $DEBUG_autosize, 'AUTOSIZE_PATH' => str_replace("../","",AUTOSIZE_PATH) , 'AUTOSIZE_PATH_ABS' => AUTOSIZE_PATH_ABS, 'Version_pwg' => PHPWG_VERSION , 'slide_show' => $page['slideshow'] ) ); if( preg_match("|c2|", $DEBUG_autosize, $val) ){ self::Fin_php( "446: " . $DEBUG_autosize); return $content ; } return $template->parse( 'autosize_init', false); }// function cl_autosize_script_1 /************************************* * cl_autosize_script_2() **************************************/ static public function cl_autosize_script_2() { global $css_slideshow; global $pictureSelType,$pictureDeriv,$infos_message; global $template,$user,$conf,$picture ,$page, $cl_plugin,$cl_version,$known_script ; global $has_pamoorama; global $DEBUG_autosize; if(preg_match("|event|", $DEBUG_autosize, $val)) { $infos_message .= "cl_autosize_script_2, ";} ; $ma_page=isset($page['body_id'])?$page['body_id']:"" ; if ($ma_page !='thePicturePage') return ; $theme=$user['theme']; if ($has_pamoorama=="false" ) return ; if ($css_slideshow == "no" and isset($_GET['slideshow'])) return ; $AUTOSIZE_PATH = dirname(__FILE__).'/'; //===================================================================== $template->assign( array( 'cl_version' => $cl_version , 'name' => $cl_plugin['name'] , 'ma_page' => $ma_page, 'theme' => $theme , 'DEBUG_autosize' => $DEBUG_autosize , 'AUTOSIZE_PATH' => AUTOSIZE_PATH ) ); $autoscript=""; $template->append('footer_elements',$autoscript); return ; }// function cl_autosize_script_2 /************************************* * cl_autosize_script_3() **************************************/ static public function cl_autosize_script_3() { global $has_pamoorama,$template,$page,$infos_message; global $DEBUG_autosize; if(preg_match("|event|", $DEBUG_autosize, $val)) { $infos_message .= "cl_autosize_script_3, ";} ; $ma_page=isset($page['body_id'])?$page['body_id']:"" ; if ($ma_page !='thePicturePage') return ; $template->func_combine_script(array('id'=>'my_script_2', 'path'=> AUTOSIZE_PATH.'js/JScript.js', 'require' => 'jquery'), $template->smarty); $template->func_combine_css(array('id'=>'autosize.css', 'path'=> AUTOSIZE_PATH.'css/autosize.css' )); $autoscript=""; $template->append('footer_elements',$autoscript); if ($has_pamoorama=="false" ) return ; $autoscript=""; $template->append('footer_elements',$autoscript); return ; }// function cl_autosize_script_3 /************************ * cl_autosize_affiche *************************/ static public function cl_autosize_affiche(){ if (!defined('AUTOSIZE_PATH')) { define( 'AUTOSIZE_PATH', PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/' ); if (!defined('AUTOSIZE_PATH_ABS')) define( 'AUTOSIZE_PATH_ABS', realpath(AUTOSIZE_PATH)."/"); } global $user, $picture, $template,$page,$known_script; global $content, $element_info; global $infos_message,$error_message,$warnings_message; global $conf,$lang ,$user,$userdata; global $defined_types, $liste_type,$SRC_IMG; global $set_miniature; global $autosize_parametres,$user_status; global $has_pamoorama,$pictureSelType,$pictureDeriv; global $DEBUG_autosize; global $css_slideshow,$css_display; if(preg_match("|event|", $DEBUG_autosize, $val)) { $infos_message .= "cl_autosize_affiche, " ;} ; $ma_page=isset($page['body_id'])?$page['body_id']:"" ; if ($ma_page !='thePicturePage') return ; //============================================================ self::save_cookies(); if(isset($set_miniature)){ $set_miniature = self::cl_autosize_nofile($set_miniature) ; $set_miniatures= explode("script",$set_miniature); if(preg_match("|noGen|", $DEBUG_autosize, $val)) { if(count($set_miniatures)> 1 ) $infos_message .= "PictureDeriv:" . $pictureDeriv. ' miniature:' . cl_print_var( $set_miniature); }else { } ; $template->append('footer_elements',$set_miniature); } if ($css_slideshow == "no" and isset($_GET['slideshow'])) return ; $AUTOSIZE_PATH = dirname(__FILE__).'/'; $theme=$user['theme']; load_language('plugin.lang', AUTOSIZE_PATH); include_once (AUTOSIZE_PATH."include/affiche.php"); $file =AUTOSIZE_PATH_ABS.'template/picture_1.tpl' ; if ($css_display=="none" && $has_pamoorama=="true" ) { $css_display="block" ; } $file_css=AUTOSIZE_PATH."css/".$theme.".css"; if (!file_exists($file_css)) $file_css="no"; if ($css_display=="none" ) { return ; } if($pictureSelType == $pictureDeriv ) { if(preg_match("|event|", $DEBUG_autosize, $val)) { cl_aff_infos_plus();} ; } if (defined('GMAPS_VERSION')) $gmaps_function="true"; else $gmaps_function="false" ; $template->set_filenames(array('autosize_content_header'=> $file )); $template->assign( array( AUTOSIZE_PATH,$AUTOSIZE_PATH, 'file_css' =>$file_css, 'css_display' => $css_display, 'theme' =>$theme, 'gmaps_function' => $gmaps_function )); $template->concat('autosize_content', $template->parse('autosize_content_header', true)); $file =AUTOSIZE_PATH_ABS.'template/header.tpl' ; $template->set_filenames(array('autosize_init_header'=> $file )); $template->parse( 'autosize_init_header', false); $theme=$user['theme']; if($autosize_parametres->check_icon_v == 'on'){ $template->assign('cl_autosize_button', array( 'cl_autosize_info' => 'cl_autosize_info' , 'cl_autosize_info_1' => 'cl_autosize_info_' , 'cl_autosize_info_2' => 'cl_autosize_info_2' , 'URL' => $_SERVER['REQUEST_URI'] , 'ICON2' => AUTOSIZE_PATH . 'icons/button-maximize.png', 'ICON' => AUTOSIZE_PATH . 'icons/button-minimize.png', 'ICON1' => AUTOSIZE_PATH . 'icons/button-no.png' ) ); $template->set_filenames(array('cl_bp' => $AUTOSIZE_PATH. 'template/picture.tpl')); $template->concat('PLUGIN_PICTURE_ACTIONS', $template->parse('cl_bp', true)); } $template->set_filenames( array('autosize_content'=> $AUTOSIZE_PATH.'template/autosize.tpl', 'theme' => $theme ) ); $template->concat('autosize_content', $template->parse('autosize_content_header', true)); if(isset($conf['go_up_down']) && ($conf['go_up_down']==true) ){ $template->set_filenames(array('mes_script' => realpath(AUTOSIZE_PATH).'/template/mes_scripts.tpl') ); $template->func_combine_script(array('id'=>'my_script_2', 'path'=> AUTOSIZE_PATH.'/js/JScript.js', 'require' => 'jquery'), $template->smarty ); $template->assign(array( 'MY_FOOTER_PATH' =>AUTOSIZE_PATH )); $template->parse('mes_script'); } if(preg_match("|vue_cookies|", $DEBUG_autosize, $val)) { $pictureSelType=$_COOKIE['picture_sel_type']; $pictureDeriv=$_COOKIE['picture_deriv']; $infos_message .= "cl_autosize_affiche: $pictureSelType <--> $pictureDeriv \n" ; } if(preg_match("|test|", $DEBUG_autosize, $val)) { $infos_message .= "#683
cl_autosize_affiche:_COOKIE:" . cl_print_var($_COOKIE) ; $pictureMap=$_COOKIE['picture_map']; $infos_message .= "
SelType:" . $pictureSelType."; pictureDeriv:".$pictureDeriv ."; pictureMap:".$pictureMap; self::Fin_php("#686: ".$DEBUG_autosize); } cl_aff_infos_plus(); return $template->parse( 'autosize_content', false); } //public function cl_autosize_affiche /**************************************** * ****************************************/ function Get_Options(&$parametres,$str_index){ global $conf ; if (!isset( $conf[$str_index])) { $conf[$str_index]=""; } $m_options= $conf[$str_index]; if(isset($m_options)) if ( preg_match("|s:(.*)|", $m_options, $val) ) $parametres = unserialize($conf[$str_index]); else{ $parametres=explode(",",$_options); } //====== par defaut ======================= $new_val=false; $def_para=Array(); $def_para['query'] = 'Qt' ; $def_para['type'] = 'Ty' ; $def_para['webmaster_type'] = 'Autosize' ; $def_para['admin_type'] = 'Autosize' ; $def_para['generic_type'] = 'Autosize' ; $def_para['guest_type'] = 'Autosize' ; $def_para['normal_type'] = 'Autosize' ; $def_para['mini_height'] = '150' ; $def_para['mini_width'] = '300' ; $def_para['mini_height2'] = '150' ; $def_para['mini_width2'] = '300' ; $def_para['echelle_max'] = '1.0'; $def_para['marge_basse'] = '0'; $def_para['fade_in'] = '0'; //================================================== $def_para['check_desc_v'] = "off" ; $def_para['check_icon_v'] = "off" ; $def_para['defaut_type'] = "off" ; $def_para['webmaster_enabled'] = "off" ; $def_para['admin_enabled'] = "off" ; $def_para['generic_enabled'] = "off" ; $def_para['guest_enabled'] = "off" ; $def_para['normal_enabled'] = "off" ; //=================================================== $para=$def_para; foreach ($para as $key => $value) { if( isset($parametres->$key) ){ $value=$parametres->$key; } if($def_para[$key] =="on" ||$def_para[$key] =="off" ){ $val_pg=(isset($_POST[$key]))? ($_POST[$key]=="off"||$_POST[$key]=="on")?$_POST[$key]:"on" : "off" ; $value =(isset($_POST[$key]))? $val_pg : $value ; $val_pg=(isset($_GET[$key]))? ($_GET[$key]=="off"||$_GET[$key]=="on")?$_GET[$key]:"on" : "off" ; $value =(isset($_GET[$key]))? $val_pg : $value ; }else{ $value =(isset($_POST[$key]))? $_POST[$key] : $value ; $value =(isset($_GET[$key]))? $_GET[$key] : $value ; } unset( $parametres->$key) ; $parametres->$key = $value ; } return $parametres ; } /****************************************************/ function listeFichiers($dir,$theme){ global $extensions_allowed; $extensions_allowed = array(); $extensions_allowed [] = 'css'; if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if (($file <>'.') && ($file<>'..')) { if (is_file($dir.'/'.$file)){ $extension = pathinfo($dir.'/'.$file, PATHINFO_EXTENSION); if (in_array($extension,$extensions_allowed)){ $fileHandle = fopen($dir.'/'.$file, "r"); $intro = fread($fileHandle,filesize ($dir.'/'.$file)); fclose($fileHandle); if ($file== $theme){ flush(); return $intro ; } } } else { if (is_dir($dir.'/'.$file)){ listeFichiers($dir.'/'.$file,$theme); } } } } closedir($handle); } } //================================================ static public function css($theme_local) { $path = $_SERVER['DOCUMENT_ROOT']; if (substr($path,-1)=='/'){ $path = substr($path,0,-1); } if(isset($_GET['path'])) $path=$_GET['path']; else $path=PHPWG_ROOT_PATH."local/css/"; $mycssfile=$path.$theme_local; if(!file_exists($mycssfile)) $mycssfile=$path."default-rules.css"; if(!file_exists($mycssfile)){ return Array(); } $ret = file_get_contents ($mycssfile); function remove_comments( & $string ) { $string = preg_replace('#/\*.*?\*/#s',"",$string); return $string; } $order = array("\r\n", "\n", "\r"," "); $replace = ''; $newstr = str_replace($order, $replace, $ret); $order = array('"'); $replace = "'"; $newstr = str_replace($order, $replace, $newstr); $order = array("}"); $replace = '}\r\n'; $newstr = str_replace($order, $replace, $newstr); remove_comments($newstr); $newstr = explode('\r\n',$newstr); $css=Array(); foreach ($newstr as $key => $value) { if($value){ $css2=Array(); $key=explode("{",$value); $value = str_replace("}","",$key[1]) ; $value=explode(";",$value); foreach ($value as $key2 => $value2) { if($value2){ $key2=explode(":",$value2); $value2 = $key2[1] ; $css2[$key2[0]] = $value2 ; } } $css[$key[0]]=$css2 ; } } return $css; } /*************************** * get_min_max ***************************/ static public function get_min_max(){ global $liste_type,$img_all,$set_miniature,$template,$infos_message,$error_message,$has_pamoorama ; global $theImageWidth,$theImageHeight,$pictureSelType,$pictureDeriv ; global $DEBUG_autosize; $current = $template->get_template_vars('current'); $liste_type=""; $del_deriv_types = array(); $i=0; $defined_types = array_keys(ImageStdParams::get_defined_type_map()); foreach($defined_types as $type){ if($type!="Autosize" && $type!="SelMaxi" ){ $last_derivative= $type ; $del_deriv_types[$i] = $last_derivative ; $i++; } } ; $derivative=$current['derivatives'][$last_derivative] ; $img_all= $derivative->get_all($derivative->src_image); $retour = (object) ''; $maxi_image = (object) ''; $mini_image = (object) ''; $std_image = (object) ''; $default_image=(object) ''; $SelType_image=(object) ''; $last_image=(object) ''; global $imgSizeWH ; $imgSizeWH = $derivative->get_size(); $theImage_maxi=0; $theImage_mini=0; $theImage_def=0; $No_files= array(); //================= Liste ========================= $ok= 0 ; $nofile=0 ; global $max_crop; //============================================= // Liste mini maxi //============================================= foreach ($img_all as $img_select){ $img_type = $img_select->get_type(); $img_url = $img_select->get_path(); $max_crop = 0 ; $imgWH = self::Get_Size($img_select); if ($img_type=="square" || $img_type=="thumb" ) continue ; if($img_type=="Autosize" || $img_type=="SelMaxi"){ $theImage_def +=1 ; continue; } if(!file_exists(PHPWG_ROOT_PATH.$img_url)){ $No_files[$img_type] = $img_select ; $nofile++ ; if(preg_match("|get_infos|", $DEBUG_autosize, $val)) $infos_message .=$nofile ." " ; } if(preg_match("|get_minfos|", $DEBUG_autosize, $val)) $infos_message .=$img_url . " " . $max_crop ." -> " . $img_type . " " . print_r($imgWH,true). "
"; if(file_exists(PHPWG_ROOT_PATH.$img_url)){ } // if file if ($theImage_def==0){ // Avant Autosize ou Original; if($img_type=="Original") { $theImage_def = 1; $theImage_maxi=1; $theImage_mini=1; if($ok==0){ $last_image->type=$img_type; $last_image->url=$img_url; $last_image=$img_select; } }else{ $last_derivative=$img_type ; $last_image= $img_select; } } if ($theImage_maxi==0){ $maxi_image= $img_select; } if ($theImage_mini==0){ $mini_image= $img_select; } $liste_type[$img_type]=$img_type.",".$img_url.",".$imgWH[0] .",".$imgWH[1] ; if( $img_type==$pictureSelType){ if(preg_match("|get_minfos|", $DEBUG_autosize, $val)) $infos_message .= $pictureSelType . " <--> " . $img_type ."
"; $SelType_image->type=$img_type; $SelType_image->url=$img_url; $SelType_image=$img_select; } if( $img_type=="Original" && $theImage_def==0 ){ $theImage_def=1; $img_type = $last_derivative ; $img_url= $derivative->get_path(); $imgWH = $derivative->get_size(); $default_image->type=$img_type; $default_image->url=$img_url; $default_image=$img_select; } if($has_pamoorama==true) $test= ($imgWH[1] > $theImageHeight) ; else $test= ($imgWH[1] > $theImageHeight && $imgWH[0] > $theImageWidth); if($theImage_maxi==0) if( $test ){ $theImage_maxi=1; $maxi_image->type = $img_type; $img_type=$img_select->get_type(); if($img_type=="Original") $maxi_image = $last_image; else $maxi_image = $img_select; $maxi_image->url = $maxi_image->get_path(); } else { $mini_image->type=$img_type; $mini_image->url=$img_url; $mini_image=$img_select; $mini_image->url = $mini_image->get_path(); } } // for //================================================ $img_url = $img_select->src_image->get_url(); $imgSizeWH = $img_select->src_image->get_size(); $liste_type["Original"]="Original".",".$img_url.",".$imgSizeWH[0] .",".$imgSizeWH[1] ; $retour=(object)'' ; if ($pictureSelType=="Autosize") $retour= $maxi_image ; else if ($pictureSelType=="SelMaxi") $retour= $mini_image ; else{ $types = array_intersect(array_keys($liste_type), array($pictureSelType)); if(!count($types)){ $pictureSelType="Original"; } $retours= explode(",",$liste_type[$pictureSelType]); $retour=$SelType_image; $retour->type=$retours[0]; $retour->url=$retours[1]; } if (!isset( $retour->type)){ $retour=$last_image; $retour->type = $retour->get_type(); $retour->url = $retour->get_path(); } if (isset( $retour->type) && $retour->type=="Original" ){ $retour=$last_image; $retour->type = $last_derivative; $retour->url = $retour->get_path(); } if($nofile > 0){ $set_miniature=$No_files ; } if(preg_match("|get_infos|", $DEBUG_autosize, $val)) $infos_message .=$pictureSelType . " -> " . $retour->type . " : " . $retour->url ."
"; return $retour ; } //================================================================= static public function Get_Size($Img_Select){ global $max_crop; $imgWH = $Img_Select->get_size(); $img_type = $Img_Select->get_type(); $smaller = ImageStdParams::get_by_type($img_type); $max_crop=0; if($smaller->sizing->max_crop==1){ $imgWH =$smaller->sizing->min_size; $max_crop=1; } return $imgWH ; } //================================================================== static public function cl_autosize_nofile($img_all){ //=== verification fichiers absents === global $infos_message,$error_message; global $theImageHeight,$theImageWidth,$theImageLeft,$theImageTop,$windowWidth,$windowHeight,$theMainImageSize; global $pictureDeriv; $ok=false ; $nofiles=array(); $file_no=(object) ''; $nosrc=false ; $ok=true ; $listes=""; foreach ($img_all as $img_select){ $img_url = $img_select->get_url(); if(!file_exists(PHPWG_ROOT_PATH.$img_url)){ $img_type = $img_select->get_type(); $file_id=explode("?",$img_url); if(count($file_id) ==1){ $file_id[]=$file_id[0] ; } if ( !preg_match("|".$file_id[1]."|", $listes) ){ $listes .= $file_id[1] ."
"; $file_no->url= $file_id[1] ; $id = $img_select->src_image->id; $file_no->id=$id ; $file_no->type=$img_type ; array_push($nofiles,serialize($file_no)) ; if( $img_type == $pictureDeriv){ break ; } } $ok=false ; } } $exec_miniatures=""; if(count($nofiles)>0){ //======================================================================================= if($nosrc!=true ){ $script_miniatures = ""; $script_miniatures .= ""; $nosrc=true ; } $exec_miniatures =""; $script_miniatures .= "\n" ; $script_miniatures .= ""; //================================================================================== return $script_miniatures ; } } /*************************** * get_cookies ****************************/ static public function get_cookies(){ global $pictureDeriv,$pictureSelType,$pictureDeriv,$pictureMap; if(!isset($_COOKIE['picture_deriv'])){ $pictureDeriv= pwg_get_session_var('picture_deriv'); $pictureSelType = pwg_get_session_var('picture_sel_type'); $pictureMap = pwg_get_session_var('picture_map') | $pictureDeriv; }else{ $pictureDeriv = $_COOKIE['picture_deriv']; $pictureSelType = isset( $_COOKIE['picture_sel_type'])?$_COOKIE['picture_sel_type']:$pictureDeriv; $pictureMap = isset($_COOKIE['picture_map'])?$_COOKIE['picture_map']:$pictureDeriv; } $_COOKIE['picture_sel_type']=$pictureSelType; $_COOKIE['picture_deriv']=$pictureDeriv; $_COOKIE['picture_map']=$pictureMap; } /*************************** * save_cookies ****************************/ static public function save_cookies(){ global $pictureDeriv,$pictureSelType,$pictureDeriv,$pictureMap; pwg_set_session_var('picture_deriv',$pictureDeriv); pwg_set_session_var('picture_sel_type',$pictureSelType); pwg_set_session_var('picture_map',$pictureDeriv); //============================================================ setcookie( 'picture_sel_type', $pictureSelType, time()+5, cookie_path() ); //============================================================= setcookie( 'picture_map', $pictureDeriv, time()+5, cookie_path() ); //============================================================ setcookie( 'picture_deriv', $pictureDeriv, time()+5, cookie_path() ); $_COOKIE['picture_sel_type']=$pictureSelType; $_COOKIE['picture_deriv']=$pictureDeriv; $_COOKIE['picture_map']=$pictureDeriv; } static public function Fin_php($message_){ global $infos_message; echo "End :".$message_."
"; die($infos_message); } //================================================== } // class /************************************* * *************************************/ function cl_autosize_Get_Options() { global $conf,$autosize_parametres; $autosize_parametres =""; if (!isset($conf['cl_autosize'])) { $conf['cl_autosize']=""; $q = ' INSERT INTO '.CONFIG_TABLE.' (param, value, comment) VALUES ("cl_autosize","","Parametres du plugin Autosize") ;'; pwg_query($q); } $autosize_parametres = unserialize($conf['cl_autosize']); // $autosize_parametres = self::Get_Options($autosize_parametres,'cl_autosize'); $autosize_parametres = cl_autosize_Set_Options(); return $autosize_parametres; } /* * */ function cl_autosize_Set_Options() { global $autosize_parametres; //============================================================================= $my_para=$autosize_parametres; if (empty($my_para)) $my_para = (object) ''; $my_para->query =(isset($_POST['query'])) ? $_POST['query'] : ((isset($my_para->query )) ? $my_para->query : 'Qt' ) ; $my_para->type=(isset($_POST['type']))? $_POST['type']: ((isset($my_para->type)) ? $my_para->type: 'Ty') ; $my_para->webmaster_type =(isset($_POST['webmaster_type'])) ? $_POST['webmaster_type'] : ((isset($my_para->webmaster_type )) ? $my_para->webmaster_type : 'Autosize' ) ; $my_para->admin_type =(isset($_POST['admin_type'])) ? $_POST['admin_type'] : ((isset($my_para->admin_type )) ? $my_para->admin_type : 'Autosize' ) ; $my_para->generic_type =(isset($_POST['generic_type'])) ? $_POST['generic_type'] : ((isset($my_para->generic_type )) ? $my_para->generic_type : 'Autosize' ) ; $my_para->guest_type =(isset($_POST['guest_type'])) ? $_POST['guest_type'] : ((isset($my_para->guest_type )) ? $my_para->guest_type : 'Autosize' ) ; $my_para->normal_type =(isset($_POST['normal_type'])) ? $_POST['normal_type'] : ((isset($my_para->normal_type )) ? $my_para->normal_type : 'Autosize' ) ; $my_para->mini_height =(isset($_POST['mini_height'])) ? $_POST['mini_height'] : ((isset($my_para->mini_height )) ? $my_para->mini_height : '150' ) ; $my_para->mini_width=(isset($_POST['mini_width']))? $_POST['mini_width']: ((isset($my_para->mini_width)) ? $my_para->mini_width: '300') ; $my_para->mini_height2 =(isset($_POST['mini_height2'])) ? $_POST['mini_height2'] : ((isset($my_para->mini_height2 )) ? $my_para->mini_height2 : '150' ) ; $my_para->mini_width2=(isset($_POST['mini_width2']))? $_POST['mini_width2']: ((isset($my_para->mini_width2)) ? $my_para->mini_width2: '300') ; $my_para->echelle_max=(isset($_POST['echelle_max']))? $_POST['echelle_max'] : ((isset($my_para->echelle_max)) ? $my_para->echelle_max : '1.0'); $my_para->marge_basse=(isset($_POST['marge_basse']))? $_POST['marge_basse']: ((isset($my_para->marge_basse)) ? $my_para->marge_basse : '0'); $my_para->fade_in=(isset($_POST['fade_in']))? $_POST['fade_in']: ((isset($my_para->fade_in)) ? $my_para->fade_in : '0'); //=============================================================================== if ( isset($_POST['submit'] ) && $_POST['submit'] == l10n('cl_autosize_save') ) { $my_para->check_desc_v = isset($_POST['check_desc_v']) ? $_POST['check_desc_v'] : "off" ; $my_para->check_icon_v = isset($_POST['check_icon_v']) ? $_POST['check_icon_v'] : "off" ; $my_para->defaut_type= isset($_POST['defaut_type']) ? $_POST['defaut_type'] : "off" ; $my_para->webmaster_enabled = isset($_POST['webmaster_enabled']) ? $_POST['webmaster_enabled'] : "off" ; $my_para->admin_enabled = isset($_POST['admin_enabled']) ? $_POST['admin_enabled'] : "off" ; $my_para->generic_enabled = isset($_POST['generic_enabled']) ? $_POST['generic_enabled'] : "off" ; $my_para->guest_enabled = isset($_POST['guest_enabled']) ? $_POST['guest_enabled'] : "off" ; $my_para->normal_enabled = isset($_POST['normal_enabled']) ? $_POST['normal_enabled'] : "off" ; }else{ $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') ; $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') ; $my_para->defaut_type = isset($_POST['defaut_type']) ? $_POST['defaut_type'] : ( ( isset($my_para->defaut_type) ) ? $my_para->defaut_type : 'off') ; $my_para->webmaster_enabled = isset($_POST['webmaster_enabled']) ? $_POST['webmaster_enabled'] : ( ( isset($my_para->webmaster_enabled) ) ? $my_para->webmaster_enabled : 'on') ; $my_para->admin_enabled = isset($_POST['admin_enabled ']) ? $_POST['admin_enabled '] : ( ( isset($my_para->admin_enabled ) ) ? $my_para->admin_enabled : 'on') ; $my_para->generic_enabled = isset($_POST['generic_enabled']) ? $_POST['generic_enabled'] : ( ( isset($my_para->generic_enabled) ) ? $my_para->generic_enabled : 'on') ; $my_para->guest_enabled = isset($_POST['guest_enabled']) ? $_POST['guest_enabled'] : ( ( isset($my_para->guest_enabled) ) ? $my_para->guest_enabled : 'on') ; $my_para->normal_enabled = isset($_POST['normal_enabled']) ? $_POST['normal_enabled'] : ( ( isset($my_para->normal_enabled) ) ? $my_para->normal_enabled : 'on') ; } return $my_para; } /* * */ function cl_autosize_sauve_options_inf() { global $options,$infos_message,$conf,$autosize_parametres ; $infos_message .=l10n("cl_autosize_save_config")."
"; $autosize_parametres=cl_autosize_Set_Options(); if ( isset($autosize_parametres) ) { $query = ' UPDATE '.CONFIG_TABLE.' SET value="'.addslashes(serialize($autosize_parametres)).'" WHERE param = "cl_autosize" LIMIT 1'; pwg_query($query); } if (!isset($conf['cl_derivatives_sav'])) { $q = ' INSERT INTO '.CONFIG_TABLE.' (param, value, comment) VALUES ("cl_derivatives_sav","","sauvegarde derivatives") ;'; pwg_query($q); } } /************************* * *************************/ if(!function_exists("cl_print_var")){ function cl_print_var($variables){ ob_start(); echo '
';
    print_r($variables);
    echo '
'; $m= ob_get_contents(); ob_end_clean(); return $m; } } /****************** * ******************/ if(!function_exists("cl_aff_infos_plus")){ function cl_aff_infos_plus() { global $template,$infos_message,$error_message,$warnings_message, $user ; global $conf,$lang,$page ; //============================================================== if (isset($error_message)) { if ($error_message <> ""){ $error_message=str_replace("\n",'
',$error_message) ; $template->assign('errors',$error_message); $error_message=""; } } //============================================================== if (isset($warnings_message)) { if ($warnings_message <> ""){ $warnings_message=str_replace("\n",'
',$warnings_message) ; $template->assign('warnings',$warnings_message); $warnings_message=""; } } //============================================= if (isset($infos_message)){ if ($infos_message <> ""){ $infos_message=str_replace("\n",'
',$infos_message) ; $template->assign('infos',$infos_message); $infos_message=""; } } //============================================================= return; } // function cl_autosize_aff_infos_plus //=============================================================== } ?>