Changeset 7134 for extensions/Random_Header/main.inc.php
- Timestamp:
- Oct 9, 2010, 5:45:58 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Random_Header/main.inc.php
r5499 r7134 2 2 /* 3 3 Plugin Name: Random Header 4 Version: 2. 0.e4 Version: 2.1 5 5 Description: Random Header allow you to show in the header a random picture from the choosen categorie, as a normal image, or as a background 6 Plugin URI: http://p hpwebgallery.net/ext/extension_view.php?eid=1886 Plugin URI: http://piwigo.org/ext/extension_view.php?eid=188 7 7 Author: repie38 8 Author URI: http://www.pierre-b.com8 Author URI: 9 9 */ 10 10 11 11 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 12 DEFINE('RH_VERSION','v2. 0.e');12 DEFINE('RH_VERSION','v2.1'); 13 13 define('RH_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/'); 14 15 if (! function_exists('get_file_contents')) {16 function get_file_contents($url, $totalTries = 5)17 {18 $Tries = 0;19 do20 {21 if ($Tries > 0) sleep(1); # Wait for a sec before retrieving again22 $contents = @file_get_contents($url);23 $Tries++;24 } while ($Tries <= $totalTries && $contents === FALSE);25 if ($contents == "") $contents = FALSE;26 return $contents;27 }28 }29 14 30 15 class RandomHeader 31 16 { 32 var $rh_config; 33 17 var $rh_config; 34 18 function load_config() 35 19 { 36 $x = get_file_contents( dirname(__FILE__).'/data.dat' );20 $x = file_get_contents( dirname(__FILE__).'/data.dat' ); 37 21 38 22 if ($x!==false) 39 23 $this->rh_config = unserialize($x); 40 24 41 foreach (str_replace(" ", "_", get_pwg_themes()) as $pwg_template) { 42 if (empty($this->rh_config[$pwg_template]['selected_cat'])) { 25 foreach (get_pwg_themes() as $pwg_templateID => $pwg_template) { 26 27 if (empty($this->rh_config[$pwg_templateID]['selected_cat'])) { 43 28 44 $this->rh_config[$pwg_template ]['selected_cat'] = '0';45 $this->rh_config[$pwg_template ]['active_on_picture']='off';46 $this->rh_config[$pwg_template ]['head_css']='';47 $this->rh_config[$pwg_template ]['img_css']='';48 $this->rh_config[$pwg_template ]['mode_background']='off';49 $this->rh_config[$pwg_template ]['concat_before'] ='off' ;50 $this->rh_config[$pwg_template ]['concat_after'] ='off' ;29 $this->rh_config[$pwg_templateID]['selected_cat'] = '0'; 30 $this->rh_config[$pwg_templateID]['active_on_picture']='off'; 31 $this->rh_config[$pwg_templateID]['head_css']=''; 32 $this->rh_config[$pwg_templateID]['img_css']=''; 33 $this->rh_config[$pwg_templateID]['mode_background']='off'; 34 $this->rh_config[$pwg_templateID]['concat_before'] ='off' ; 35 $this->rh_config[$pwg_templateID]['concat_after'] ='off' ; 51 36 52 37 $this->save_config(); … … 55 40 56 41 } 42 43 44 57 45 function save_config() 58 46 { … … 61 49 fclose( $file ); 62 50 } 63 function plugin_admin_menu($menu) 64 { 65 array_push($menu, 66 array( 67 'NAME' => 'Random Header', 68 'URL' => get_admin_plugin_menu_link(dirname(__FILE__).'/admin/rh_admin.php') 69 )); 70 return $menu; 71 } 72 51 52 function plugin_admin_menu($menu) 53 { 54 array_push($menu,array( 55 'NAME' => 'Random Header', 56 'URL' => get_admin_plugin_menu_link(dirname(__FILE__).'/admin/rh_admin.php'))); 57 return $menu; 58 } 59 73 60 function randombanner(){ 74 61 global $page; … … 76 63 global $conf; 77 64 global $user; 78 $usertheme=str_replace(" ", "_", $user['template'].'/'.$user['theme'] ); 65 66 $usertheme=$user['theme'] ; 67 79 68 if ( !defined('IN_ADMIN') && isset($page['body_id']) && ($page['body_id']!='thePicturePage' || $this->rh_config[$usertheme]['active_on_picture']=='on') ) { 80 69 … … 97 86 } 98 87 88 } 99 89 100 }101 90 $obj = new RandomHeader(); 102 91 $obj->load_config(); 103 104 92 add_event_handler('loc_begin_page_header', array(&$obj, 'randombanner') ); 105 93 add_event_handler('get_admin_plugin_menu_links', array(&$obj, 'plugin_admin_menu') );
Note: See TracChangeset
for help on using the changeset viewer.