Ignore:
Timestamp:
Sep 28, 2012, 11:13:50 AM (12 years ago)
Author:
cljosse
Message:

[extensions] Autosize fix compatibility with 2.4, add theme directive

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/Autosize/autosize.inc.php

    r18234 r18325  
    3636  // header ('X-UA-Compatible: n=7')  ;
    3737 // header ('X-UA-Compatible: IE=Edge')  ;
    38  global  $template,$version,$icon_path,$page,$picture,$conf;
    39  
     38global  $template,$version,$icon_path,$page,$picture,$conf;
     39global $user,$Css,$css_slideshow,$css_display;
    4040  $current = $template->get_template_vars('current'); 
    41   $has_pamoorama=isset($template->files['pamooramics_content']);
     41//=======================================================
     42  $theme=$user['theme']; 
     43  $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
    4248//====================================================================   
    4349  $pictureDeriv = pwg_get_session_var('picture_deriv',$conf['derivative_default_size']);
     
    4551  $SRC_IMG="";
    4652//=====================================================================
     53
    4754if(!isset($_COOKIE['picture_deriv']))
    48     if(isset($current['derivatives']['Autosize']))
     55    if(isset($current['derivatives']['Autosize'])){
    4956        $_COOKIE['picture_deriv']="Autosize";
    50 
    51 if(isset( $_COOKIE['picture_deriv']))
     57        }
     58if(isset( $_COOKIE['picture_deriv'])) 
    5259  $model=  $_COOKIE['picture_deriv'] ;
    5360else
    5461  $model= $pictureDeriv ;
    5562
     63
     64 
     65 if (($css_display=="none" || $css_slideshow=="no") && ($model=="SelMaxi" || $model=="Autosize") ) {
     66   $model=$default_size ;
     67   $_COOKIE['picture_deriv'] =$model ;
     68}
     69
    5670 if(!isset($current['derivatives'][$model]))
    5771   $model=$default_size ;
    58 
     72 
    5973$selected_derivative =  $current['derivatives'][$model];
     74     /*
     75      'selected_derivative' => $selected_derivative,
     76      'unique_derivatives' => $unique_derivatives,
     77      */
    6078
    6179
     
    7896    $template->assign('current[selected_derivative]', $selected_derivative , true);
    7997    $current = $template->get_template_vars('current');
    80   }
    81 
     98  } 
    8299return $content;
     100
    83101
    84102}//INIT
     
    105123  $current = $template->get_template_vars('current');
    106124  if (!isset($current)) return ;
     125 
    107126//===============================================================
    108127    $derivative = $current['src_image'] ;
     
    168187if (!isset($_COOKIE['theMainImageWidth']))  setcookie('theMainImageWidth',$window_width);
    169188
    170 //
    171 
     189//================= Liste =========================
    172190    $last_defined=ImageStdParams::get_defined_type_map(); 
    173191    foreach ($img_all as $img_select){
     
    214232                }
    215233      }
    216 //==============================================================   
    217   //==== Réécriture selection ====
    218   if( $img_type=="SelMaxi"){
    219       $maxi_img= $mini_img;
    220       $maxi_url= $mini_img;
    221   }
    222   if ( !array_key_exists($maxi_img, $last_defined) ){
    223    
    224             $maxi_img = $last_img->get_type();   
    225             $maxi_url  = $last_img->get_url();
    226             $imgSizeWH  =  $last_img->get_size();       
    227  
    228   }
    229  $model= $maxi_img;
    230    
    231   /*  $_COOKIE['picture_deriv']=$maxi_img ;
    232     $_COOKIE['picture_map']=  $maxi_img ;
    233     $_COOKIE['imgSrc']=       $maxi_url;
    234    */
    235   if (isset($_COOKIE['picture_deriv'])){   
    236       if ( array_key_exists($_COOKIE['picture_deriv'], ImageStdParams::get_defined_type_map()) ){
    237    //         pwg_set_session_var('picture_deriv', $_COOKIE['picture_deriv']);
    238         }else{
    239      //       pwg_set_session_var('picture_deriv', $_COOKIE['picture_deriv']);
    240         }
    241   //  setcookie('picture_deriv', false, 0, cookie_path() );
    242   } 
    243 
    244  
     234
    245235return false ;
    246236
     
    258248    global  $has_pamoorama;
    259249    global $autosize_parametres,$user_status;
    260  
    261 
     250   
    262251    if(isset($page['body_id']) &&       $page['body_id'] == 'theAdminPage' ) return ;   
    263252
    264  if ('kardon' == $user['theme'] and isset($_GET['slideshow'])) return ;
    265      if ('stripped' == $user['theme'] ) return ;
    266 
    267                 load_language('plugin.lang', AUTOSIZE_PATH);
     253  global $css_slideshow,$css_display;
    268254                $AUTOSIZE_PATH = dirname(__FILE__).'/';
     255   $theme=$user['theme']; 
     256
     257                load_language('plugin.lang', AUTOSIZE_PATH);
    269258                 if (isset( $page['body_id']) && $page['body_id']=='thePicturePage'  ) {
    270259                        if ( isset($picture['current'])){       
    271260                                include (AUTOSIZE_PATH."include/affiche.php");
    272 
    273261        $file =AUTOSIZE_PATH_ABS.'template/picture_1.tpl' ;
     262         if ($css_display=="none"  &&  $has_pamoorama) {   
     263            $css_display="block" ;
     264         }
    274265        $template->set_filenames(array('autosize_content_header'=> $file ));
    275         $template->assign(
    276                                         array( 
    277             'select_type' =>$select_type,
    278             ));
    279 
    280         $template->concat('autosize_content', $template->parse('autosize_content_header', true)); 
    281 
     266        $template->assign(      array( AUTOSIZE_PATH,$AUTOSIZE_PATH,
     267                                  'css_display' => $css_display,
     268                                  'select_type' =>$select_type,
     269                                  'theme' =>$theme
     270                          ));
     271        $template->concat('autosize_content', $template->parse('autosize_content_header', true));
     272     if ($css_display=="none" ) {       
     273        return ;
     274      } 
     275   
    282276        $file =AUTOSIZE_PATH_ABS.'template/header.tpl' ;
    283277        $template->set_filenames(array('autosize_init_header'=> $file ));
     
    308302        $template->set_filenames(array('mes_script' => realpath(AUTOSIZE_PATH).'/template/mes_scripts.tpl') );
    309303        $template->func_combine_script(array('id'=>'my_script_2',
    310         'path'=> AUTOSIZE_PATH.'/js/JScript.js',
    311         'require' => 'jquery'),
     304                                             'path'=> AUTOSIZE_PATH.'/js/JScript.js',
     305                                             'require' => 'jquery'),
    312306        $template->smarty);
    313307        $template->assign(array(
     
    330324 
    331325    $ma_page=isset($page['body_id'])?$page['body_id']:"" ;
    332     if ($ma_page=='thePiwiShackControllerPage') return ;   
    333     if ('kardon' == $user['theme'] and isset($_GET['slideshow'])) return ;
    334     global  $has_pamoorama;
    335     $has_pamoorama=isset($template->files['pamooramics_content']);
    336   if (!$has_pamoorama) return ;
    337       if ('stripped' == $user['theme'] ) return ;
    338 
     326    if ($ma_page=='thePiwiShackControllerPage') return ; 
     327    global  $has_pamoorama,$css_slideshow; 
     328    $has_pamoorama = isset($template->files['pamooramics_content']); 
     329 if (!$has_pamoorama) return ;
     330
     331 if ($page['slideshow']){
     332    $current = $template->get_template_vars('current');
     333    $model=$current['selected_derivative']->type ;
     334    $selected_derivative =  $current['derivatives'][$model]; 
     335    $template->append('current', array(
     336                                'selected_derivative' => $selected_derivative
     337                                    ),
     338                      true);
     339
     340 }
    339341    $template->set_filenames(array('autosize_init'=>AUTOSIZE_PATH_ABS. "template/conflit.tpl" ) );
    340342    $autosize_parametres =       cl_autosize_Get_Options() ;                   
     
    356358          'AUTOSIZE_PATH' => str_replace("../","",AUTOSIZE_PATH)  ,
    357359          'AUTOSIZE_PATH_ABS' => AUTOSIZE_PATH_ABS,
    358           'Version_pwg' => PHPWG_VERSION           )
     360          'Version_pwg' => PHPWG_VERSION ,
     361          'slideshow' => $page['slideshow']
     362         )
    359363    );
     364   
    360365    return $template->parse( 'autosize_init', false);
     366
    361367        }// function cl_autosize_script_1
    362368
     
    367373 {
    368374           global  $template,$user,$conf,$picture ,$page, $cl_plugin,$known_script ;
    369                 global  $template,$user,$conf,$picture ,$page, $cl_plugin ;
    370             if(isset($page['body_id']) &&       $page['body_id'] == 'theAdminPage' ) return ;   
    371    
    372    if ('kardon' == $user['theme'] and isset($_GET['slideshow'])) return ;
    373      global  $has_pamoorama;
    374        if (!$has_pamoorama) return ;
    375        if ('stripped' == $user['theme'] ) return ;
    376 
     375     global  $template,$user,$conf,$picture ,$page, $cl_plugin ;
     376     if(isset($page['body_id']) &&      $page['body_id'] == 'theAdminPage' ) return ;   
     377       global  $has_pamoorama;
     378  if (!$has_pamoorama) return ;
     379  global $css_slideshow;
     380 
     381 if ($css_slideshow="no" and isset($_GET['slideshow'])) return ;   
     382 
     383   
    377384                        $AUTOSIZE_PATH = dirname(__FILE__).'/';
    378385//================================================================
     
    590597    return $parametres ;
    591598  }
     599  /****************************************************/
     600 
     601function listeFichiers($dir,$theme){
     602  global $extensions_allowed;
     603  $extensions_allowed = array();
     604  $extensions_allowed [] = 'css';
     605  if ($handle = opendir($dir)) {   
     606    while (false !== ($file = readdir($handle))) {
     607      if (($file <>'.') && ($file<>'..')) {
     608        if (is_file($dir.'/'.$file)){
     609          $extension = pathinfo($dir.'/'.$file, PATHINFO_EXTENSION);
     610          if (in_array($extension,$extensions_allowed)){
     611            $fileHandle = fopen($dir.'/'.$file, "r");
     612           
     613            $intro = fread($fileHandle,filesize ($dir.'/'.$file));
     614            fclose($fileHandle);
     615            if ($file== $theme){       
     616              flush();   
     617              return $intro ;
     618            }
     619          }
     620      } else {
     621        if (is_dir($dir.'/'.$file)){
     622          listeFichiers($dir.'/'.$file,$theme);
     623        }
     624      }
     625    }
     626   }
     627   closedir($handle);
     628  }
     629}
     630//================================================
     631function css($theme_local) {   
     632    $path = $_SERVER['DOCUMENT_ROOT'];
     633    if (substr($path,-1)=='/'){
     634              $path =  substr($path,0,-1);
     635          }
     636     if(isset($_GET['path']))
     637              $path=$_GET['path'];
     638          else
     639              $path=PHPWG_ROOT_PATH."local/css/";
     640
     641              $mycssfile=$path.$theme_local;
     642
     643              if(!file_exists($mycssfile))
     644               $mycssfile=$path."default-rules.css";
     645
     646      $ret =   file_get_contents ($mycssfile);
     647
     648function remove_comments( & $string ) {
     649   $string = preg_replace('#/\*.*?\*/#s',"",$string);
     650   return $string;
     651 }
     652
     653$order   = array("\r\n", "\n", "\r"," ");
     654$replace = '';
     655$newstr = str_replace($order, $replace, $ret);
     656
     657$order   = array('"');
     658$replace = "'";
     659$newstr = str_replace($order, $replace, $newstr);
     660
     661
     662$order   = array("}");
     663$replace = '}\r\n';
     664$newstr = str_replace($order, $replace, $newstr);
     665remove_comments($newstr);
     666
     667$newstr = explode('\r\n',$newstr);
     668$css=Array();
     669   
     670  foreach ($newstr as $key => $value) {   
     671   if($value){
     672    $css2=Array();
     673      $key=explode("{",$value);   
     674      $value = str_replace("}","",$key[1]) ;
     675      $value=explode(";",$value);
     676           foreach ($value as $key2 => $value2) {   
     677            if($value2){
     678              $key2=explode(":",$value2);   
     679                $value2 =  $key2[1] ;
     680                $css2[$key2[0]] = $value2 ;
     681            }
     682           }
     683      $css[$key[0]]=$css2 ;
     684     }   
     685}
     686
     687       
     688                    return $css;
     689        }
     690//=================================================
     691
     692
    592693} // class
    593694
     
    718819  return $m;           
    719820}
    720    
     821
     822
    721823
    722824?>
Note: See TracChangeset for help on using the changeset viewer.