Changeset 18325 for extensions/Autosize/autosize.inc.php
- Timestamp:
- Sep 28, 2012, 11:13:50 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Autosize/autosize.inc.php
r18234 r18325 36 36 // header ('X-UA-Compatible: n=7') ; 37 37 // header ('X-UA-Compatible: IE=Edge') ; 38 39 38 global $template,$version,$icon_path,$page,$picture,$conf; 39 global $user,$Css,$css_slideshow,$css_display; 40 40 $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 42 48 //==================================================================== 43 49 $pictureDeriv = pwg_get_session_var('picture_deriv',$conf['derivative_default_size']); … … 45 51 $SRC_IMG=""; 46 52 //===================================================================== 53 47 54 if(!isset($_COOKIE['picture_deriv'])) 48 if(isset($current['derivatives']['Autosize'])) 55 if(isset($current['derivatives']['Autosize'])){ 49 56 $_COOKIE['picture_deriv']="Autosize"; 50 51 if(isset( $_COOKIE['picture_deriv'])) 57 } 58 if(isset( $_COOKIE['picture_deriv'])) 52 59 $model= $_COOKIE['picture_deriv'] ; 53 60 else 54 61 $model= $pictureDeriv ; 55 62 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 56 70 if(!isset($current['derivatives'][$model])) 57 71 $model=$default_size ; 58 72 59 73 $selected_derivative = $current['derivatives'][$model]; 74 /* 75 'selected_derivative' => $selected_derivative, 76 'unique_derivatives' => $unique_derivatives, 77 */ 60 78 61 79 … … 78 96 $template->assign('current[selected_derivative]', $selected_derivative , true); 79 97 $current = $template->get_template_vars('current'); 80 } 81 98 } 82 99 return $content; 100 83 101 84 102 }//INIT … … 105 123 $current = $template->get_template_vars('current'); 106 124 if (!isset($current)) return ; 125 107 126 //=============================================================== 108 127 $derivative = $current['src_image'] ; … … 168 187 if (!isset($_COOKIE['theMainImageWidth'])) setcookie('theMainImageWidth',$window_width); 169 188 170 // 171 189 //================= Liste ========================= 172 190 $last_defined=ImageStdParams::get_defined_type_map(); 173 191 foreach ($img_all as $img_select){ … … 214 232 } 215 233 } 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 245 235 return false ; 246 236 … … 258 248 global $has_pamoorama; 259 249 global $autosize_parametres,$user_status; 260 261 250 262 251 if(isset($page['body_id']) && $page['body_id'] == 'theAdminPage' ) return ; 263 252 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; 268 254 $AUTOSIZE_PATH = dirname(__FILE__).'/'; 255 $theme=$user['theme']; 256 257 load_language('plugin.lang', AUTOSIZE_PATH); 269 258 if (isset( $page['body_id']) && $page['body_id']=='thePicturePage' ) { 270 259 if ( isset($picture['current'])){ 271 260 include (AUTOSIZE_PATH."include/affiche.php"); 272 273 261 $file =AUTOSIZE_PATH_ABS.'template/picture_1.tpl' ; 262 if ($css_display=="none" && $has_pamoorama) { 263 $css_display="block" ; 264 } 274 265 $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 282 276 $file =AUTOSIZE_PATH_ABS.'template/header.tpl' ; 283 277 $template->set_filenames(array('autosize_init_header'=> $file )); … … 308 302 $template->set_filenames(array('mes_script' => realpath(AUTOSIZE_PATH).'/template/mes_scripts.tpl') ); 309 303 $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'), 312 306 $template->smarty); 313 307 $template->assign(array( … … 330 324 331 325 $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 } 339 341 $template->set_filenames(array('autosize_init'=>AUTOSIZE_PATH_ABS. "template/conflit.tpl" ) ); 340 342 $autosize_parametres = cl_autosize_Get_Options() ; … … 356 358 'AUTOSIZE_PATH' => str_replace("../","",AUTOSIZE_PATH) , 357 359 'AUTOSIZE_PATH_ABS' => AUTOSIZE_PATH_ABS, 358 'Version_pwg' => PHPWG_VERSION ) 360 'Version_pwg' => PHPWG_VERSION , 361 'slideshow' => $page['slideshow'] 362 ) 359 363 ); 364 360 365 return $template->parse( 'autosize_init', false); 366 361 367 }// function cl_autosize_script_1 362 368 … … 367 373 { 368 374 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 377 384 $AUTOSIZE_PATH = dirname(__FILE__).'/'; 378 385 //================================================================ … … 590 597 return $parametres ; 591 598 } 599 /****************************************************/ 600 601 function 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 //================================================ 631 function 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 648 function 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); 665 remove_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 592 693 } // class 593 694 … … 718 819 return $m; 719 820 } 720 821 822 721 823 722 824 ?>
Note: See TracChangeset
for help on using the changeset viewer.