source: trunk/plugins/LocalFilesEditor/include/css.inc.php @ 11362

Last change on this file since 11362 was 11362, checked in by plg, 13 years ago

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]

File size: 2.6 KB
RevLine 
[10348]1<?php
2
3if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
4
5if ((isset($_POST['edit'])) and !is_numeric($_POST['file_to_edit']))
6{
7  $edited_file = $_POST['file_to_edit'];
[11362]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) ? '&#x2714;' : '&#x2718;').' 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')
[10348]59  {
[11362]60    continue;
[10348]61  }
[11362]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    }
73  }
[10348]74  else
75  {
[11362]76    array_push($inactive_themes, $fs_theme);
[10348]77  }
78}
79
[11362]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';
[10348]86
[11362]87  $options[$value] = (file_exists($value) ? '&#x2714;' : '&#x2718;').' '.$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)
[10348]104{
[11362]105  $value = PHPWG_ROOT_PATH.PWG_LOCAL_DIR . 'css/'.$theme['id'].'-rules.css';
106
107  $options[$value] = (file_exists($value) ? '&#x2714;' : '&#x2718;').' '.$theme['name'];
108 
[10348]109  if ($edited_file == $value)
[11362]110  {
[10348]111    $selected = $value;
[11362]112  }
[10348]113}
114
115$template->assign('css_lang_tpl', array(
116  'OPTIONS' => $options,
117  'SELECTED' => $selected
118  )
119);
120
121$codemirror_mode = 'text/css';
122
123?>
Note: See TracBrowser for help on using the repository browser.