Changeset 7134 for extensions/Random_Header
- Timestamp:
- Oct 9, 2010, 5:45:58 AM (14 years ago)
- Location:
- extensions/Random_Header
- Files:
-
- 4 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Random_Header/admin/rh_admin.php
r3687 r7134 2 2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 3 3 4 global $template; 4 5 $me = get_plugin_data($plugin_id); 5 global $template; 6 include_once(PHPWG_ROOT_PATH.'admin/include/themes.class.php'); 7 6 8 7 9 $template->set_filenames( array('plugin_admin_content' => dirname(__FILE__).'/rh_admin.tpl') ); 8 $ template->assign( 'RH_VERSION' , RH_VERSION);10 $rhthemes = new themes(); 9 11 10 foreach (str_replace(" ", "_", get_pwg_themes()) as $pwg_template) { 12 13 foreach (get_pwg_themes() as $pwg_templateID => $pwg_template) { 11 14 if (isset($_POST['submit'])) { 12 $me->rh_config[$pwg_template ]['selected_cat'] = $_POST[$pwg_template.'selected_cat'];13 $me->rh_config[$pwg_template ]['active_on_picture'] = (isset( $_POST[$pwg_template.'active_on_picture'] )) ? $_POST[$pwg_template.'active_on_picture'] : 'off' ;14 $me->rh_config[$pwg_template ]['concat_before'] = (isset( $_POST[$pwg_template.'concat_before'] )) ? $_POST[$pwg_template.'concat_before'] : 'off' ;15 $me->rh_config[$pwg_template ]['concat_after'] = (isset( $_POST[$pwg_template.'concat_after'] )) ? $_POST[$pwg_template.'concat_after'] : 'off' ;16 $me->rh_config[$pwg_template ]['head_css'] = $_POST[$pwg_template.'head_css'];17 $me->rh_config[$pwg_template ]['img_css'] = $_POST[$pwg_template.'img_css'];18 $me->rh_config[$pwg_template ]['mode_background'] = (isset( $_POST[$pwg_template.'mode_background'] )) ? $_POST[$pwg_template.'mode_background'] : 'off' ;15 $me->rh_config[$pwg_templateID]['selected_cat'] = $_POST[$pwg_templateID.'selected_cat']; 16 $me->rh_config[$pwg_templateID]['active_on_picture'] = (isset( $_POST[$pwg_templateID.'active_on_picture'] )) ? $_POST[$pwg_templateID.'active_on_picture'] : 'off' ; 17 $me->rh_config[$pwg_templateID]['concat_before'] = (isset( $_POST[$pwg_templateID.'concat_before'] )) ? $_POST[$pwg_templateID.'concat_before'] : 'off' ; 18 $me->rh_config[$pwg_templateID]['concat_after'] = (isset( $_POST[$pwg_templateID.'concat_after'] )) ? $_POST[$pwg_templateID.'concat_after'] : 'off' ; 19 $me->rh_config[$pwg_templateID]['head_css'] = $_POST[$pwg_templateID.'head_css']; 20 $me->rh_config[$pwg_templateID]['img_css'] = $_POST[$pwg_templateID.'img_css']; 21 $me->rh_config[$pwg_templateID]['mode_background'] = (isset( $_POST[$pwg_templateID.'mode_background'] )) ? $_POST[$pwg_templateID.'mode_background'] : 'off' ; 19 22 $me->save_config(); 20 23 } 21 24 22 $template->append('themes', array( 23 'CURRENT_THEME' => $pwg_template, 24 'ACTIVE_ON_PICTURE' => ($me->rh_config[$pwg_template]['active_on_picture']=='on') ? 'checked' : '', 25 'MODE_BACKGROUND' => ($me->rh_config[$pwg_template]['mode_background']=='on') ? 'checked' : '', 26 'CONCAT_BEFORE' => ($me->rh_config[$pwg_template]['concat_before']=='on') ? 'checked' : '', 27 'CONCAT_AFTER' => ($me->rh_config[$pwg_template]['concat_after']=='on') ? 'checked' : '', 28 'HEAD_CSS' => $me->rh_config[$pwg_template]['head_css'], 29 'IMG_CSS' => $me->rh_config[$pwg_template]['img_css'], 30 'CATSELECTED' => $me->rh_config[$pwg_template]['selected_cat'] 25 $template->append('rhthemes', array( 26 'CURRENT_THEME_NAME'=> $pwg_template, 27 'CURRENT_THEME_ID' => $pwg_templateID, 28 'ACTIVE_ON_PICTURE' => ($me->rh_config[$pwg_templateID]['active_on_picture']=='on') ? 'checked' : '', 29 'MODE_BACKGROUND' => ($me->rh_config[$pwg_templateID]['mode_background']=='on') ? 'checked' : '', 30 'CONCAT_BEFORE' => ($me->rh_config[$pwg_templateID]['concat_before']=='on') ? 'checked' : '', 31 'CONCAT_AFTER' => ($me->rh_config[$pwg_templateID]['concat_after']=='on') ? 'checked' : '', 32 'HEAD_CSS' => $me->rh_config[$pwg_templateID]['head_css'], 33 'IMG_CSS' => $me->rh_config[$pwg_templateID]['img_css'], 34 'CATSELECTED' => $me->rh_config[$pwg_templateID]['selected_cat'] 31 35 )); 32 36 } … … 37 41 'categories' 38 42 ); 43 39 44 load_language('plugin.lang', RH_PATH); 40 45 46 47 41 48 $template->assign_var_from_handle( 'ADMIN_CONTENT', 'plugin_admin_content'); 42 49 ?> -
extensions/Random_Header/admin/rh_admin.tpl
r4538 r7134 1 <div class="titrePage"><h2>Random Header<br />{$RH_VERSION}</h2></div> 1 {html_head}<style type="text/css"> 2 .randomHeader_fieldset legend{ldelim}color:#ff3363;font-weight:bold;} 3 .randomHeader_fieldset{ldelim}width:345px;float:left;overflow-x:auto;padding:5px;margin:3px;} 4 .rh_input{ldelim}width:335px;} 5 6 .themeBox {ldelim} 7 display: block; 8 width: 185px; 9 } 10 </style>{/html_head} 11 <div class="titrePage"><h2>Random Header v2.1</h2></div> 2 12 <p>{'rh_description'|@translate}</p> 3 13 <p><i>{'rh_aide'|@translate}</i></p> 4 14 <form method="post" action="" class="properties"> 5 <style> 6 .randomHeader_fieldset legend{ldelim}color:#ff3363;font-weight:bold;} 7 .randomHeader_fieldset{ldelim} 8 width:345px; 9 overflow-x:auto; 10 float:left; 11 padding: 5px; 12 margin: 3px; 13 }#ff3363 14 .rh_input{ldelim} 15 width:335px; 16 } 17 </style> 18 {foreach from=$themes item=i} 15 16 {foreach from=$rhthemes item=i} 19 17 <fieldset class="randomHeader_fieldset"> 20 18 21 <legend>{'rh_theme'|@translate} : {$i.CURRENT_THEME}</legend> 22 19 <legend>{'rh_theme'|@translate} : {$i.CURRENT_THEME_NAME}</legend> 23 20 <p> 24 21 <label> 25 22 {'rh_headers_category'|@translate}<br /> 26 <select class="categoryDropDown" name="{$i.CURRENT_THEME }selected_cat">23 <select class="categoryDropDown" name="{$i.CURRENT_THEME_ID}selected_cat"> 27 24 <option value="0">{'rh_inactif'|@translate}</option> 28 25 {html_options options=$categories selected=$i.CATSELECTED} … … 32 29 33 30 <p> 34 <input type="checkbox" {$i.MODE_BACKGROUND} name="{$i.CURRENT_THEME }mode_background">31 <input type="checkbox" {$i.MODE_BACKGROUND} name="{$i.CURRENT_THEME_ID}mode_background"> 35 32 <label>{'rh_as_background'|@translate}</label> 36 33 </p> 37 34 38 35 <p> 39 <input type="checkbox" {$i.ACTIVE_ON_PICTURE} name="{$i.CURRENT_THEME }active_on_picture">36 <input type="checkbox" {$i.ACTIVE_ON_PICTURE} name="{$i.CURRENT_THEME_ID}active_on_picture"> 40 37 <label>{'rh_on_picture'|@translate}</label> 41 38 </p> … … 44 41 <label>{'rh_additional_css'|@translate} :<br /></label> 45 42 <i>#theHeader :</i><br /> 46 <input class="rh_input" type="text" name="{$i.CURRENT_THEME }head_css" value="{$i.HEAD_CSS}"><br />47 <i>#RandomImage : {'rh_inactif_on_bg'|@translate}</i><br /><input class="rh_input" type="text" name="{$i.CURRENT_THEME }img_css" value="{$i.IMG_CSS}"><br />43 <input class="rh_input" type="text" name="{$i.CURRENT_THEME_ID}head_css" value="{$i.HEAD_CSS}"><br /> 44 <i>#RandomImage : {'rh_inactif_on_bg'|@translate}</i><br /><input class="rh_input" type="text" name="{$i.CURRENT_THEME_ID}img_css" value="{$i.IMG_CSS}"><br /> 48 45 </p> 49 46 50 47 <p> 51 48 <label>{'rh_concat'|@translate} :<br /></label> 52 {'rh_before'|@translate} : <input type="checkbox" {$i.CONCAT_BEFORE} name="{$i.CURRENT_THEME }concat_before"> {'rh_after'|@translate} : <input type="checkbox" {$i.CONCAT_AFTER} name="{$i.CURRENT_THEME}concat_after">49 {'rh_before'|@translate} : <input type="checkbox" {$i.CONCAT_BEFORE} name="{$i.CURRENT_THEME_ID}concat_before"> {'rh_after'|@translate} : <input type="checkbox" {$i.CONCAT_AFTER} name="{$i.CURRENT_THEME_ID}concat_after"> 53 50 </p> 54 51 … … 57 54 <div align="center" style="clear:left"><input class="submit" type="submit" value="{'rh_submit'|@translate}" name="submit" /></div> 58 55 </form> 59 -
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.