Changeset 7358


Ignore:
Timestamp:
Oct 23, 2010, 10:53:37 PM (14 years ago)
Author:
repie38
Message:

moved conf file to db (_config table)
small fix on admin panel
new maintain procedures including upgrade from 2.1 or earlier (get conf from file and delete it)
deleted themes conf is no more stocked

Location:
extensions/Random_Header
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • extensions/Random_Header/admin/rh_admin.css

    r7330 r7358  
    1 .randomHeader_fieldset legend{color:#ff3363;font-weight:bold;}
    2 .randomHeader_fieldset{overflow-x:auto;}
    3 .rh_input{width:335px;}
    4 .rhconf{float:left;}
    5 .rhactive{background-color:lightgreen;}
    6 .rhinactive{border-color:red;}
    7 
    8 
     1.randomHeader_fieldset legend{color:#ff3363;font-weight:bold;}
    92
    103.black_overlay{
  • extensions/Random_Header/admin/rh_admin.php

    r7330 r7358  
    66include_once(PHPWG_ROOT_PATH.'admin/include/themes.class.php');
    77
     8// delete conf for deleted themes (but not for deactivated themes)
     9foreach ($me->rh_config as $theme_in_rh_conf => $test) {
     10        if (!file_exists($conf['themes_dir'].'/'.$theme_in_rh_conf.'/'.'themeconf.inc.php')) {
     11                unset($me->rh_config[$theme_in_rh_conf]);
     12        }
     13}
     14$me->save_config();
     15
     16
    817
    918$template->set_filenames( array('plugin_admin_content' => dirname(__FILE__).'/rh_admin.tpl') );
     19$template->assign("RH_VERSION",RH_VERSION);
     20$template->assign("RH_confpanel",realpath( dirname(__FILE__).'/rh_theme_conf.tpl'));
    1021$rhthemes = new themes();
    11 
     22$rh_vierge=0;
    1223
    1324foreach (get_pwg_themes() as  $pwg_templateID => $pwg_template) {
     
    2132                $me->rh_config[$pwg_templateID]['mode_background']              = (isset( $_POST[$pwg_templateID.'mode_background'] )) ? $_POST[$pwg_templateID.'mode_background'] : 'off' ;
    2233                $me->save_config();
     34               
    2335        }
    2436       
    2537        $rhscreenshot=(file_exists(PHPWG_THEMES_PATH.$pwg_templateID . '/screenshot.png')) ? PHPWG_THEMES_PATH.$pwg_templateID . '/screenshot.png' : PHPWG_ROOT_PATH.'admin/themes/'.$conf['admin_theme'].'/images/missing_screenshot.png';
    26     $rhthemboxclass=($me->rh_config[$pwg_templateID]['selected_cat']!=0) ? 'themeDefault' : 'toto';     
    27        
     38    $rhthemboxclass=($me->rh_config[$pwg_templateID]['selected_cat']!=0) ? 'themeDefault' : '';     
     39        $rh_vierge=($me->rh_config[$pwg_templateID]['selected_cat']!=0) ? $rh_vierge+1 : $rh_vierge;
    2840        $template->append('rhthemes', array(
    2941                                'CURRENT_THEME_NAME'=> $pwg_template,
     
    4052                                ));
    4153}
    42 
     54$template->assign('rh_vierge',$rh_vierge);
    4355display_select_cat_wrapper(
    4456          'SELECT id,name,uppercats,global_rank FROM '.CATEGORIES_TABLE,
  • extensions/Random_Header/admin/rh_admin.tpl

    r7330 r7358  
    33{/html_head}
    44
    5 
    6 <div class="titrePage"><h2>Random Header v2.2</h2></div>
     5<div class="titrePage"><h2>Random Header {$RH_VERSION}</h2></div>
    76<p>{'rh_description'|@translate}</p>
    87<p><i>{'rh_aide'|@translate}</i></p>
    98<form method="post" action="" class="properties">
    10 
    11 
     9 
     10 
    1211<div id="themesContent">
     12{if $rh_vierge!=0}
    1313        <fieldset>
    1414                <legend>{'rh_active_conf'|@translate}</legend>
    1515               
    16                
    1716                <div class="themeBoxes">
    1817                {foreach from=$rhthemes item=i}
    19                 {if $i.CATSELECTED!=0}
    20                
    21                
    22                         <div class="themeBox {$i.THEMEBOXCLASS}">
    23                                 <div class="themeName">{$i.CURRENT_THEME_NAME}</div>
    24                                 <div class="themeShot"><img src="{$i.SCREENSHOT_URL}" alt=""></div>
    25                                 <div class="themeActions">
    26                                         <div>
    27                                                 <a href="javascript:void(0)" onclick="document.getElementById('light{$i.CURRENT_THEME_ID}').style.display='block';document.getElementById('fade').style.display='block'" title="">Configurer</a>
    28                                         </div>
    29                                 </div> <!-- themeActions -->
    30                         </div>
    31                        
    32                
    33                
    34                
    35                
    36                
    37                 <div id="light{$i.CURRENT_THEME_ID}" class="rhconfpanel">
    38                 <fieldset class="randomHeader_fieldset" style="float:left;">
    39                        
    40                         <legend>{'rh_theme'|@translate} : {$i.CURRENT_THEME_NAME}</legend>
    41                        
    42                         <p>
    43                         <label>
    44                       {'rh_headers_category'|@translate}<br />
    45                       <select class="categoryDropDown" name="{$i.CURRENT_THEME_ID}selected_cat">
    46                         <option value="0">{'rh_inactif'|@translate}</option>
    47                         {html_options options=$categories selected=$i.CATSELECTED}
    48                       </select>
    49                     </label>
    50                         </p>
    51                        
    52                         <p>
    53                         <input type="checkbox" {$i.MODE_BACKGROUND} name="{$i.CURRENT_THEME_ID}mode_background">
    54                         <label>{'rh_as_background'|@translate}</label>
    55                         </p>
    56                        
    57                         <p>
    58                         <input type="checkbox" {$i.ACTIVE_ON_PICTURE} name="{$i.CURRENT_THEME_ID}active_on_picture">
    59                         <label>{'rh_on_picture'|@translate}</label>
    60                         </p>
    61                        
    62                         <p>
    63                         <label>{'rh_additional_css'|@translate} :<br /></label>
    64                         <i>#theHeader :</i><br />
    65                         <input class="rh_input" type="text" name="{$i.CURRENT_THEME_ID}head_css" value="{$i.HEAD_CSS}"><br />
    66                         <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 />
    67                         </p>
    68                        
    69                         <p>
    70                         <label>{'rh_concat'|@translate} :</label>
    71                         <input type="checkbox" {$i.CONCAT_BEFORE} name="{$i.CURRENT_THEME_ID}concat_before"> {'rh_before'|@translate} &nbsp; <input type="checkbox" {$i.CONCAT_AFTER} name="{$i.CURRENT_THEME_ID}concat_after"> {'rh_after'|@translate}
    72                         </p>
    73                        
    74                 </fieldset>
    75                 <div  style="float:right;">
    76                         <a style="border:none;" href="javascript:void(0)" onclick="document.getElementById('light{$i.CURRENT_THEME_ID}').style.display='none';document.getElementById('fade').style.display='none'" titlte="{'Close this window'|@translate}">
    77                         <img src="{$ROOT_URL}{$themeconf.admin_icon_dir}/exit.png" class="button" alt="exit"></a>
    78                 </div>
    79                 <br />
    80                 <div align="center" style="clear:left;"><input class="submit" type="submit" value="{'rh_submit'|@translate}" name="submit" /></div>
    81                
    82                
    83                
    84                 </div> 
    85 
    86 
    87                 {/if}
     18                        {if $i.CATSELECTED!=0}
     19                                {include file="$RH_confpanel"}
     20                        {/if}
    8821                {/foreach}
    89 
     22                </div> <!-- themeBoxes -->
    9023        </fieldset>
    91        
    92        
    93        
     24{/if}   
    9425       
    9526        <fieldset>
    9627                <legend>{'rh_inactive_conf'|@translate} : </legend>
    9728               
    98                
    9929                <div class="themeBoxes">
    10030                {foreach from=$rhthemes item=i}
    101                 {if $i.CATSELECTED==0}
    102                
    103                
    104                         <div class="themeBox {$i.THEMEBOXCLASS}">
    105                                 <div class="themeName">{$i.CURRENT_THEME_NAME}</div>
    106                                 <div class="themeShot"><img src="{$i.SCREENSHOT_URL}" alt=""></div>
    107                                 <div class="themeActions">
    108                                         <div>
    109                                                 <a href="javascript:void(0)" onclick="document.getElementById('light{$i.CURRENT_THEME_ID}').style.display='block';document.getElementById('fade').style.display='block'" title="">Configurer</a>
    110                                         </div>
    111                                 </div> <!-- themeActions -->
    112                         </div>
    113                        
    114                
    115                
    116                
    117                
    118                
    119                 <div id="light{$i.CURRENT_THEME_ID}" class="rhconfpanel">
    120                 <fieldset class="randomHeader_fieldset" style="float:left;">
    121                        
    122                         <legend>{'rh_theme'|@translate} : {$i.CURRENT_THEME_NAME}</legend>
    123                        
    124                         <p>
    125                         <label>
    126                       {'rh_headers_category'|@translate}<br />
    127                       <select class="categoryDropDown" name="{$i.CURRENT_THEME_ID}selected_cat">
    128                         <option value="0">{'rh_inactif'|@translate}</option>
    129                         {html_options options=$categories selected=$i.CATSELECTED}
    130                       </select>
    131                     </label>
    132                         </p>
    133                        
    134                         <p>
    135                         <input type="checkbox" {$i.MODE_BACKGROUND} name="{$i.CURRENT_THEME_ID}mode_background">
    136                         <label>{'rh_as_background'|@translate}</label>
    137                         </p>
    138                        
    139                         <p>
    140                         <input type="checkbox" {$i.ACTIVE_ON_PICTURE} name="{$i.CURRENT_THEME_ID}active_on_picture">
    141                         <label>{'rh_on_picture'|@translate}</label>
    142                         </p>
    143                        
    144                         <p>
    145                         <label>{'rh_additional_css'|@translate} :<br /></label>
    146                         <i>#theHeader :</i><br />
    147                         <input class="rh_input" type="text" name="{$i.CURRENT_THEME_ID}head_css" value="{$i.HEAD_CSS}"><br />
    148                         <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 />
    149                         </p>
    150                        
    151                         <p>
    152                         <label>{'rh_concat'|@translate} :</label>
    153                         <input type="checkbox" {$i.CONCAT_BEFORE} name="{$i.CURRENT_THEME_ID}concat_before"> {'rh_before'|@translate} &nbsp; <input type="checkbox" {$i.CONCAT_AFTER} name="{$i.CURRENT_THEME_ID}concat_after"> {'rh_after'|@translate}
    154                         </p>
    155                        
    156                 </fieldset>
    157                 <div  style="float:right;">
    158                         <a style="border:none;" href="javascript:void(0)" onclick="document.getElementById('light{$i.CURRENT_THEME_ID}').style.display='none';document.getElementById('fade').style.display='none'" titlte="{'Close this window'|@translate}">
    159                         <img src="{$ROOT_URL}{$themeconf.admin_icon_dir}/exit.png" class="button" alt="exit"></a>
    160                 </div>
    161                 <br />
    162                 <div align="center" style="clear:left;"><input class="submit" type="submit" value="{'rh_submit'|@translate}" name="submit" /></div>
    163                
    164                
    165                
    166                 </div> 
    167 
    168 
    169                 {/if}
     31                        {if $i.CATSELECTED==0}
     32                                {include file="$RH_confpanel"}
     33                        {/if}
    17034                {/foreach}
    171 
     35                </div> <!-- themeBoxes -->
    17236        </fieldset>
    17337       
    174 </div> 
     38</div> <!-- themesContent -->
     39 
    17540<div id="fade" class="black_overlay"></div>
    17641 
    177 <div align="center" style="clear:left"><input class="submit" type="submit" value="{'rh_submit'|@translate}" name="submit" /></div>
     42<div style="text-align:center;clear:left"><input class="submit" type="submit" value="{'rh_submit'|@translate}" name="submit" ></div>
    17843</form>
  • extensions/Random_Header/main.inc.php

    r7330 r7358  
    1515class RandomHeader
    1616{
    17          var $rh_config;
     17        var $rh_config;
     18       
    1819        function load_config()
    19     {
    20         $x = file_get_contents( dirname(__FILE__).'/data.dat' );
    21                
    22         if ($x!==false)
    23                 $this->rh_config = unserialize($x);
    24 
    25                 foreach (get_pwg_themes() as $pwg_templateID => $pwg_template) {
     20    {
     21                global $conf;
     22                $this->rh_config = unserialize($conf['Random_Header']);
     23                foreach (get_pwg_themes() as $pwg_templateID => $pwg_template) {
    2624               
    2725                          if (empty($this->rh_config[$pwg_templateID]['selected_cat']))  {
     
    3836                }
    3937                }
    40 
    41     }
    42        
    43        
     38        }
    4439       
    4540    function save_config()
    46     {
    47         $file = fopen( dirname(__FILE__).'/data.dat', 'w' );
    48         fwrite($file, serialize($this->rh_config) );
    49         fclose( $file );
    50     }
     41        {
     42                $query = '
     43                                        UPDATE '.CONFIG_TABLE.'
     44                                        SET value = "'.addslashes(serialize($this->rh_config)).'"
     45                                        WHERE param = "Random_Header"
     46                                        ;';
     47                pwg_query($query);
     48               
     49                load_conf_from_db();
     50        }
    5151       
    5252        function plugin_admin_menu($menu)
     
    6565               
    6666                $usertheme=$user['theme'] ;
    67 
     67               
     68                if (isset($this->rh_config[$usertheme])){
    6869                if ( !defined('IN_ADMIN') && isset($page['body_id']) && ($page['body_id']!='thePicturePage' || $this->rh_config[$usertheme]['active_on_picture']=='on') ) {
    6970
     
    8384                                }
    8485                        }
    85                 }
     86                }}
    8687        }
    8788
Note: See TracChangeset for help on using the changeset viewer.