Dotclear

Changeset 2423


Ignore:
Timestamp:
07/01/10 22:58:02 (13 years ago)
Author:
Moe
Message:

clean:config 1.4.1:

  • Dotclear 2.2 support (break 2.1 compatibility)
Location:
plugins/cleanConfig
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • plugins/cleanConfig/_define.php

    r2402 r2423  
    2929     /* Description */        "Delete blog and global settings", 
    3030     /* Author      */        "Moe (http://gniark.net/)", 
    31      /* Version     */        "1.4", 
     31     /* Version     */        "1.4.1", 
    3232     /* Permissions */        null 
    3333); 
  • plugins/cleanConfig/inc/lib.cleanconfig.php

    r2402 r2423  
    3131     { 
    3232          global $core; 
     33           
     34          $set =& $core->blog->settings; 
    3335 
    3436          if ($limit == 'blog') 
    3537          { 
    36                # Settings compatibility test 
    37                if (version_compare(DC_VERSION,'2.2-alpha1','>=')) { 
    38                     $core->blog->settings->{$namespace}->drop($setting); 
    39                } else { 
    40                     $core->blog->settings->drop($setting); 
    41                } 
     38               $set->{$namespace}->drop($setting); 
    4239          } 
    4340          elseif ($limit == 'global') 
     
    5956     { 
    6057          global $core; 
     58           
     59          $set =& $core->blog->settings; 
    6160 
    6261          $str = '<p>'.__('Use carefully. Only settings related to plugins can be deleted.').'</p>'."\n"; 
     
    7170           
    7271          $table->part('body'); 
    73  
    74           $settings = array(); 
    75  
    76           # limit to blog 
    77           if ($limit == 'blog') 
    78           { 
    79                $dump = $core->blog->settings->dumpSettings(); 
    80           } 
    81           # global 
    82           else 
    83           { 
    84                $dump = $core->blog->settings->dumpGlobalSettings(); 
    85           } 
    86  
    87           foreach ($dump as $k => $v) { 
    88                $settings[$v['ns']][$k] = $v; 
    89           } 
    9072           
    91           ksort($settings); 
    92  
     73          $namespaces = $set->dumpNamespaces(); 
     74           
    9375          # number of settings 
    9476          $i = 0; 
    95           foreach ($settings as $k => $v) 
     77           
     78          # Parse all the namespaces 
     79          foreach (array_keys($namespaces) as $null => $ns) 
    9680          { 
     81               # only settings related to plugins 
     82               if (($ns == 'system') OR ($ns == 'widgets')) {continue;} 
     83                
     84               # limit to blog 
     85               if ($limit == 'blog') 
     86               { 
     87                    $dump = $set->{$ns}->dumpSettings(); 
     88               } 
     89               # global 
     90               else 
     91               { 
     92                    $dump = $set->{$ns}->dumpGlobalSettings(); 
     93               } 
     94                
    9795               # echo namespace 
    9896               $echo_ns = false; 
    99                # only settings related to plugins  
    100                if (($k != 'system') AND ($k != 'widgets')) 
     97                
     98               foreach ($dump as $name => $v) 
    10199               { 
    102                     ksort($v); 
    103                     foreach ($v as $k => $v) 
     100                    # hide global settings on blog settings 
     101                    if ((($limit == 'global') AND ($v['global'])) 
     102                         OR (($limit == 'blog') AND (!$v['global']))) 
    104103                    { 
    105                          # hide deleted settings 
    106                          if (!((!empty($_POST['settings'])) AND (in_array($k,$_POST['settings'])))) 
     104                         # echo namespace  
     105                         if (!$echo_ns) 
    107106                         { 
    108                               # hide global settings on blog settings 
    109                               if ((($limit == 'global') AND ($v['global'])) OR (($limit == 'blog') AND (!$v['global']))) 
    110                               { 
    111                                    $table->row(); 
    112                                    # echo namespace  
    113                                    if (!$echo_ns) 
    114                                    { 
    115                                         $table->row(); 
    116                                         $table->cell(__('namespace:'). 
    117                                              ' <strong>'.$v['ns'].'</strong>', 
    118                                              'class="ns-name" colspan="5"'); 
    119                                         $echo_ns = true; 
    120                                    } 
    121                                     
    122                                    $id = html::escapeHTML($v['ns'].'|'.$k); 
    123                                    $table->row('class="line"'); 
    124                                    $table->cell(form::checkbox(array('settings[]',$id), 
    125                                         $id,false,$v['ns'])); 
    126                                    $table->cell('<label for="'.$id.'">'.$k.'</label>'); 
    127                                    # boolean 
    128                                    if (($v['type']) == 'boolean') 
    129                                    { 
    130                                         $value = ($v['value']) ? 'true' : 'false'; 
    131                                    } 
    132                                    #other types 
    133                                    else 
    134                                    { 
    135                                         $value = form::field(html::escapeHTML($k.'_field'),40, 
    136                                              null,html::escapeHTML($v['value']),null,null,null, 
    137                                              'readonly="readonly"'); 
    138                                    } 
    139                                    $table->cell($value); 
    140                                    $table->cell($v['type']); 
    141                                    $table->cell($v['label'],'class="maximal"'); 
    142                                     
    143                                    $i++; 
    144                               } 
     107                              $table->row(); 
     108                              $table->cell(__('namespace:'). 
     109                                   ' <strong>'.$v['ns'].'</strong>', 
     110                                   'class="ns-name" colspan="5"'); 
     111                              $echo_ns = true; 
    145112                         } 
     113                          
     114                         $id = html::escapeHTML($v['ns'].'|'.$name); 
     115                         $table->row('class="line"'); 
     116                         $table->cell(form::checkbox(array('settings[]',$id), 
     117                              $id,false,$v['ns'])); 
     118                         $table->cell('<label for="'.$id.'">'.$name.'</label>'); 
     119                         # boolean 
     120                         if (($v['type']) == 'boolean') 
     121                         { 
     122                              $value = ($v['value']) ? 'true' : 'false'; 
     123                         } 
     124                         # other types 
     125                         else 
     126                         { 
     127                              $value = form::field(html::escapeHTML($ns.'_field'),40, 
     128                                   null,html::escapeHTML($v['value']),null,null,null, 
     129                                   'readonly="readonly"'); 
     130                         } 
     131                         $table->cell($value); 
     132                         $table->cell($v['type']); 
     133                         $table->cell($v['label'],'class="maximal"'); 
     134                          
     135                         $i++; 
    146136                    } 
    147137               } 
     
    159149               $str .= ('<p class="checkboxes-helpers"></p>'. 
    160150               '<p>'.form::hidden(array('limit',$limit),$limit). 
    161                '<input type="submit" name="delete" value="'.__('Delete selected settings').'" /></p>'."\n". 
    162                '<p>'.$core->formNonce().'</p>'); 
     151               '<p>'.$core->formNonce().'</p>'. 
     152               '<input type="submit" name="delete" value="'. 
     153                    __('Delete selected settings').'" /></p>'); 
    163154          } 
    164155          $str .= '</form>'."\n"; 
Note: See TracChangeset for help on using the changeset viewer.

Sites map