Changeset 11362


Ignore:
Timestamp:
Jun 14, 2011, 12:03:09 PM (9 years ago)
Author:
plg
Message:

merge r11361 from branch 2.2 to trunk

bug 2341 fixed: simplified selection for CSS file to edit. We display the list
of themes in the same order as on [Administration > Configuration > Themes]

Location:
trunk/plugins/LocalFilesEditor
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/plugins/LocalFilesEditor/include/css.inc.php

    r10348 r11362  
    33if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    44
    5 $edited_file = isset($_POST['edited_file']) ? $_POST['edited_file'] : '';
    6 $content_file = '';
    7 
    85if ((isset($_POST['edit'])) and !is_numeric($_POST['file_to_edit']))
    96{
    107  $edited_file = $_POST['file_to_edit'];
    11   if (file_exists($edited_file))
     8}
     9elseif (isset($_POST['edited_file']))
     10{
     11  $edited_file = $_POST['edited_file'];
     12}
     13else
     14{
     15  $edited_file = PHPWG_ROOT_PATH.PWG_LOCAL_DIR . 'css/'.get_default_theme().'-rules.css';
     16}
     17
     18if (file_exists($edited_file))
     19{
     20  $content_file = file_get_contents($edited_file);
     21}
     22else
     23{
     24  $content_file = "/* " . l10n('locfiledit_newfile') . " */\n\n";
     25}
     26
     27$selected = 0;
     28// $options[] = l10n('locfiledit_choose_file');
     29// $options[] = '----------------------';
     30$value = PHPWG_ROOT_PATH.PWG_LOCAL_DIR . "css/rules.css";
     31
     32$options[$value] = (file_exists($value) ? '✔' : '✘').' local / css / rules.css';
     33if ($edited_file == $value)
     34{
     35  $selected = $value;
     36}
     37
     38// themes are displayed in the same order as on screen
     39// [Administration > Configuration > Themes]
     40
     41include_once(PHPWG_ROOT_PATH.'admin/include/themes.class.php');
     42$themes = new themes();
     43$themes->sort_fs_themes();
     44$default_theme = get_default_theme();
     45$db_themes = $themes->get_db_themes();
     46
     47$db_theme_ids = array();
     48foreach ($db_themes as $db_theme)
     49{
     50  array_push($db_theme_ids, $db_theme['id']);
     51}
     52
     53$active_themes = array();
     54$inactive_themes = array();
     55
     56foreach ($themes->fs_themes as $theme_id => $fs_theme)
     57{
     58  if ($theme_id == 'default')
    1259  {
    13     $content_file = file_get_contents($edited_file);
     60    continue;
     61  }
     62
     63  if (in_array($theme_id, $db_theme_ids))
     64  {
     65    if ($theme_id == $default_theme)
     66    {
     67      array_unshift($active_themes, $fs_theme);
     68    }
     69    else
     70    {
     71      array_push($active_themes, $fs_theme);
     72    }
    1473  }
    1574  else
    1675  {
    17     $content_file = "/* " . l10n('locfiledit_newfile') . " */\n\n";
     76    array_push($inactive_themes, $fs_theme);
    1877  }
    1978}
    2079
    21 $selected = 0;
    22 $options[] = l10n('locfiledit_choose_file');
    23 $options[] = '----------------------';
    24 $value = PHPWG_ROOT_PATH.PWG_LOCAL_DIR . "css/rules.css";
    25 $options[$value] = 'local / css / rules.css';
    26 if ($edited_file == $value) $selected = $value;
    27 $options[] = '----------------------';
     80$options[] = '';
     81$options[] = '----- '.l10n('Active Themes').' -----';
     82$options[] = '';
     83foreach ($active_themes as $theme)
     84{
     85  $value = PHPWG_ROOT_PATH.PWG_LOCAL_DIR . 'css/'.$theme['id'].'-rules.css';
    2886
    29 foreach (get_dirs($conf['themes_dir']) as $theme_id)
     87  $options[$value] = (file_exists($value) ? '✔' : '✘').' '.$theme['name'];
     88
     89  if ($default_theme == $theme['id'])
     90  {
     91    $options[$value].= ' ('.l10n('default').')';
     92  }
     93 
     94  if ($edited_file == $value)
     95  {
     96    $selected = $value;
     97  }
     98}
     99
     100$options[] = '';
     101$options[] = '----- '.l10n('Inactive Themes').' -----';
     102$options[] = '';
     103foreach ($inactive_themes as $theme)
    30104{
    31   $value = PHPWG_ROOT_PATH.PWG_LOCAL_DIR . 'css/'.$theme_id.'-rules.css';
    32   $options[$value] = 'local / css / '.$theme_id.'-rules.css';
     105  $value = PHPWG_ROOT_PATH.PWG_LOCAL_DIR . 'css/'.$theme['id'].'-rules.css';
     106
     107  $options[$value] = (file_exists($value) ? '✔' : '✘').' '.$theme['name'];
     108 
    33109  if ($edited_file == $value)
     110  {
    34111    $selected = $value;
     112  }
    35113}
    36114
  • trunk/plugins/LocalFilesEditor/template/admin.tpl

    r10348 r11362  
    5353
    5454{if isset ($css_lang_tpl)}
    55 {html_options name=file_to_edit options=$css_lang_tpl.OPTIONS selected=$css_lang_tpl.SELECTED}
     55<select name="file_to_edit">
     56{foreach from=$css_lang_tpl.OPTIONS item=theme key=value}
     57  <option value="{$value}" {if $value == $css_lang_tpl.SELECTED}selected="selected"{/if} {if is_numeric($value)}disabled="disabled"{/if}>{$theme}</option>
     58{/foreach}
     59</select>
     60
     61
    5662<input class="submit" type="submit" value="{'locfiledit_edit'|@translate}" name="edit" />
    5763<br><br>
Note: See TracChangeset for help on using the changeset viewer.