Dotclear


Ignore:
Timestamp:
08/25/14 09:20:20 (11 years ago)
Author:
Nicolas <nikrou77@…>
Branch:
default
Message:

Addresses #1896
Preferences: one editor for each available formats.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • admin/preferences.php

    r2720 r2736  
    2727 
    2828$user_options = $core->auth->getOptions(); 
    29 if (empty($user_options['editor'])) { 
    30     $user_options['editor'] = ''; 
     29if (empty($user_options['editor']) || !is_array($user_options['editor'])) { 
     30     $user_options['editor'] = array(); 
    3131} 
    3232 
     
    6565$editors = array_keys($editors_combo); 
    6666 
    67 # Formaters combo 
    68 $formaters_combo = dcAdminCombos::getFormatersCombo(); 
    69 $formaters_combo_editor = array(); 
    70  
    71 if (!empty($user_options['editor']) && !empty($formaters_combo[$user_options['editor']])) { 
    72     $formaters_combo_editor = $formaters_combo[$user_options['editor']]; 
    73 } elseif (count($editors)!=0) { 
    74     $formaters_combo_editor = $formaters_combo[$editors[0]]; 
    75 } else { 
    76     $formaters_combo = array(); 
    77 } 
    78  
     67# Format by editors 
     68$formaters = $core->getFormaters(); 
     69$format_by_editors = array(); 
     70foreach ($formaters as $editor => $formats) { 
     71     foreach ($formats as $format) { 
     72          $format_by_editors[$format][$editor] = $editor; 
     73     } 
     74} 
     75$available_formats = array('' => ''); 
     76foreach (array_keys($format_by_editors) as $format) { 
     77     $available_formats[$format] = $format; 
     78     if (!isset($user_options['editor'][$format])) { 
     79          $user_options['editor'][$format] = ''; 
     80     } 
     81} 
    7982$status_combo = dcAdminCombos::getPostStatusescombo(); 
    8083 
     
    150153 
    151154# Update user options 
    152 if (isset($_POST['user_post_format'])) 
     155if (isset($_POST['user_editor'])) 
    153156{ 
    154157     try 
     
    333336                    sprintf(__('Password strength: %s'),__('strong'))."', '". 
    334337                    sprintf(__('Password strength: %s'),__('very strong'))."']});\n". 
    335           "});\n". 
    336         'var formats_by_editor = \''.json_encode($formaters_combo).'\';'. 
     338          "});". 
    337339          "\n//]]>\n". 
    338340          "</script>\n". 
     
    471473echo 
    472474'<div class="fieldset">'. 
    473 '<h4>'.__('Edition').'</h4>'. 
    474  
    475 '<p class="field"><label for="user_editor">'.__('Preferred editor:').'</label>'. 
    476 form::combo('user_editor',array_merge(array(__('Choose an editor') => ''),$editors_combo),$user_options['editor']).'</p>'. 
    477  
     475'<h4>'.__('Edition').'</h4>'; 
     476 
     477foreach ($format_by_editors as $format => $editors) { 
     478     echo 
     479     '<p class="field"><label for="user_editor">'.sprintf(__('Preferred editor for %s:'),$format).'</label>'. 
     480     form::combo( 
     481          'user_editor['.$format.']', 
     482          array_merge(array(__('Choose an editor') => ''),$editors),$user_options['editor'][$format] 
     483     ).'</p>'; 
     484} 
     485echo 
    478486'<p class="field"><label for="user_post_format">'.__('Preferred format:').'</label>'. 
    479 form::combo('user_post_format',array_merge(array('' => ''), $formaters_combo_editor),$user_options['post_format']).'</p>'. 
    480  
     487form::combo('user_post_format',$available_formats,$user_options['post_format']).'</p>'; 
     488 
     489echo 
    481490'<p class="field"><label for="user_post_status">'.__('Default entry status:').'</label>'. 
    482491form::combo('user_post_status',$status_combo,$user_post_status).'</p>'. 
Note: See TracChangeset for help on using the changeset viewer.

Sites map