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] git-svn-id: http://piwigo.org/svn/trunk@11362 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
c15baed214
commit
6623e735e8
2 changed files with 104 additions and 20 deletions
|
@ -2,36 +2,114 @@
|
|||
|
||||
if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
|
||||
|
||||
$edited_file = isset($_POST['edited_file']) ? $_POST['edited_file'] : '';
|
||||
$content_file = '';
|
||||
|
||||
if ((isset($_POST['edit'])) and !is_numeric($_POST['file_to_edit']))
|
||||
{
|
||||
$edited_file = $_POST['file_to_edit'];
|
||||
if (file_exists($edited_file))
|
||||
{
|
||||
$content_file = file_get_contents($edited_file);
|
||||
}
|
||||
else
|
||||
{
|
||||
$content_file = "/* " . l10n('locfiledit_newfile') . " */\n\n";
|
||||
}
|
||||
}
|
||||
elseif (isset($_POST['edited_file']))
|
||||
{
|
||||
$edited_file = $_POST['edited_file'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$edited_file = PHPWG_ROOT_PATH.PWG_LOCAL_DIR . 'css/'.get_default_theme().'-rules.css';
|
||||
}
|
||||
|
||||
if (file_exists($edited_file))
|
||||
{
|
||||
$content_file = file_get_contents($edited_file);
|
||||
}
|
||||
else
|
||||
{
|
||||
$content_file = "/* " . l10n('locfiledit_newfile') . " */\n\n";
|
||||
}
|
||||
|
||||
$selected = 0;
|
||||
$options[] = l10n('locfiledit_choose_file');
|
||||
$options[] = '----------------------';
|
||||
// $options[] = l10n('locfiledit_choose_file');
|
||||
// $options[] = '----------------------';
|
||||
$value = PHPWG_ROOT_PATH.PWG_LOCAL_DIR . "css/rules.css";
|
||||
$options[$value] = 'local / css / rules.css';
|
||||
if ($edited_file == $value) $selected = $value;
|
||||
$options[] = '----------------------';
|
||||
|
||||
foreach (get_dirs($conf['themes_dir']) as $theme_id)
|
||||
$options[$value] = (file_exists($value) ? '✔' : '✘').' local / css / rules.css';
|
||||
if ($edited_file == $value)
|
||||
{
|
||||
$value = PHPWG_ROOT_PATH.PWG_LOCAL_DIR . 'css/'.$theme_id.'-rules.css';
|
||||
$options[$value] = 'local / css / '.$theme_id.'-rules.css';
|
||||
$selected = $value;
|
||||
}
|
||||
|
||||
// themes are displayed in the same order as on screen
|
||||
// [Administration > Configuration > Themes]
|
||||
|
||||
include_once(PHPWG_ROOT_PATH.'admin/include/themes.class.php');
|
||||
$themes = new themes();
|
||||
$themes->sort_fs_themes();
|
||||
$default_theme = get_default_theme();
|
||||
$db_themes = $themes->get_db_themes();
|
||||
|
||||
$db_theme_ids = array();
|
||||
foreach ($db_themes as $db_theme)
|
||||
{
|
||||
array_push($db_theme_ids, $db_theme['id']);
|
||||
}
|
||||
|
||||
$active_themes = array();
|
||||
$inactive_themes = array();
|
||||
|
||||
foreach ($themes->fs_themes as $theme_id => $fs_theme)
|
||||
{
|
||||
if ($theme_id == 'default')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (in_array($theme_id, $db_theme_ids))
|
||||
{
|
||||
if ($theme_id == $default_theme)
|
||||
{
|
||||
array_unshift($active_themes, $fs_theme);
|
||||
}
|
||||
else
|
||||
{
|
||||
array_push($active_themes, $fs_theme);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
array_push($inactive_themes, $fs_theme);
|
||||
}
|
||||
}
|
||||
|
||||
$options[] = '';
|
||||
$options[] = '----- '.l10n('Active Themes').' -----';
|
||||
$options[] = '';
|
||||
foreach ($active_themes as $theme)
|
||||
{
|
||||
$value = PHPWG_ROOT_PATH.PWG_LOCAL_DIR . 'css/'.$theme['id'].'-rules.css';
|
||||
|
||||
$options[$value] = (file_exists($value) ? '✔' : '✘').' '.$theme['name'];
|
||||
|
||||
if ($default_theme == $theme['id'])
|
||||
{
|
||||
$options[$value].= ' ('.l10n('default').')';
|
||||
}
|
||||
|
||||
if ($edited_file == $value)
|
||||
{
|
||||
$selected = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$options[] = '';
|
||||
$options[] = '----- '.l10n('Inactive Themes').' -----';
|
||||
$options[] = '';
|
||||
foreach ($inactive_themes as $theme)
|
||||
{
|
||||
$value = PHPWG_ROOT_PATH.PWG_LOCAL_DIR . 'css/'.$theme['id'].'-rules.css';
|
||||
|
||||
$options[$value] = (file_exists($value) ? '✔' : '✘').' '.$theme['name'];
|
||||
|
||||
if ($edited_file == $value)
|
||||
{
|
||||
$selected = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$template->assign('css_lang_tpl', array(
|
||||
|
|
|
@ -52,7 +52,13 @@ if (document.getElementById("text") != null)
|
|||
{/if}
|
||||
|
||||
{if isset ($css_lang_tpl)}
|
||||
{html_options name=file_to_edit options=$css_lang_tpl.OPTIONS selected=$css_lang_tpl.SELECTED}
|
||||
<select name="file_to_edit">
|
||||
{foreach from=$css_lang_tpl.OPTIONS item=theme key=value}
|
||||
<option value="{$value}" {if $value == $css_lang_tpl.SELECTED}selected="selected"{/if} {if is_numeric($value)}disabled="disabled"{/if}>{$theme}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
|
||||
|
||||
<input class="submit" type="submit" value="{'locfiledit_edit'|@translate}" name="edit" />
|
||||
<br><br>
|
||||
{if isset ($css_lang_tpl.NEW_FILE_URL)}
|
||||
|
|
Loading…
Add table
Reference in a new issue