mirror of
https://github.com/phpbb/phpbb.git
synced 2025-04-21 16:22:22 +02:00
[ticket/9675] Add option to delete template/theme/imageset when deleting style.
PHPBB3-9675
This commit is contained in:
parent
afc856417f
commit
ffcd307746
@ -22,6 +22,20 @@
|
||||
<dt><label for="new_id">{L_REPLACE}:</label><br /><span>{L_REPLACE_EXPLAIN}</span></dt>
|
||||
<dd><select id="new_id" name="new_id">{S_REPLACE_OPTIONS}</select></dd>
|
||||
</dl>
|
||||
<!-- IF S_DELETE_STYLE -->
|
||||
<dl>
|
||||
<dt><label for="new_template_id">{L_REPLACE_TEMPLATE}:</label><br /><span>{L_REPLACE_TEMPLATE_EXPLAIN}</span></dt>
|
||||
<dd><select id="new_template_id" name="new_template_id">{S_REPLACE_TEMPLATE_OPTIONS}</select></dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label for="new_theme_id">{L_REPLACE_THEME}:</label><br /><span>{L_REPLACE_THEME_EXPLAIN}</span></dt>
|
||||
<dd><select id="new_theme_id" name="new_theme_id">{S_REPLACE_THEME_OPTIONS}</select></dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label for="new_imageset_id">{L_REPLACE_IMAGESET}:</label><br /><span>{L_REPLACE_IMAGESET_EXPLAIN}</span></dt>
|
||||
<dd><select id="new_imageset_id" name="new_imageset_id">{S_REPLACE_IMAGESET_OPTIONS}</select></dd>
|
||||
</dl>
|
||||
<!-- ENDIF -->
|
||||
|
||||
<p class="quick">
|
||||
<input class="button1" type="submit" name="update" value="{L_DELETE}" />
|
||||
|
@ -1587,7 +1587,7 @@ parse_css_file = {PARSE_CSS_FILE}
|
||||
{
|
||||
case 'style':
|
||||
$sql_from = STYLES_TABLE;
|
||||
$sql_select = 'style_name';
|
||||
$sql_select = 'style_name, template_id, theme_id, imageset_id';
|
||||
$sql_where = 'AND style_active = 1';
|
||||
break;
|
||||
|
||||
@ -1678,6 +1678,51 @@ parse_css_file = {PARSE_CSS_FILE}
|
||||
{
|
||||
set_config('default_style', $new_id);
|
||||
}
|
||||
|
||||
// Remove the components
|
||||
$components = array('template', 'theme', 'imageset');
|
||||
foreach ($components as $component)
|
||||
{
|
||||
$new_id = request_var('new_' . $component . '_id', 0);
|
||||
$style_id = $style_row[$component . '_id'];
|
||||
|
||||
if (($new_id == 0) || ($component === 'template' && ($conflicts = $this->check_inheritance($component, $style_id))))
|
||||
{
|
||||
// We can not delete the template, as the selected one is inheriting from this one.
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($component == 'imageset')
|
||||
{
|
||||
$sql = 'DELETE FROM ' . STYLES_IMAGESET_DATA_TABLE . "
|
||||
WHERE imageset_id = $style_id";
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
|
||||
switch ($component)
|
||||
{
|
||||
case 'template':
|
||||
$sql_from = STYLES_TEMPLATE_TABLE;
|
||||
break;
|
||||
|
||||
case 'theme':
|
||||
$sql_from = STYLES_THEME_TABLE;
|
||||
break;
|
||||
|
||||
case 'imageset':
|
||||
$sql_from = STYLES_IMAGESET_TABLE;;
|
||||
break;
|
||||
}
|
||||
|
||||
$sql = "DELETE FROM $sql_from
|
||||
WHERE {$component}_id = $style_id";
|
||||
$db->sql_query($sql);
|
||||
|
||||
$sql = 'UPDATE ' . STYLES_TABLE . "
|
||||
SET {$component}_id = $new_id
|
||||
WHERE {$component}_id = $style_id";
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1718,6 +1763,63 @@ parse_css_file = {PARSE_CSS_FILE}
|
||||
'NAME' => $style_row[$mode . '_name'],
|
||||
)
|
||||
);
|
||||
|
||||
if ($mode == 'style')
|
||||
{
|
||||
$template->assign_vars(array(
|
||||
'S_DELETE_STYLE' => true,
|
||||
));
|
||||
|
||||
$components = array('template', 'theme', 'imageset');
|
||||
foreach ($components as $mode)
|
||||
{
|
||||
$sql_where = '';
|
||||
switch ($mode)
|
||||
{
|
||||
case 'template':
|
||||
$sql_from = STYLES_TEMPLATE_TABLE;
|
||||
$sql_select = 'template_name, template_path, template_storedb';
|
||||
$sql_where = ' AND template_inherits_id <> ' . $style_row[$mode . '_id'];
|
||||
break;
|
||||
|
||||
case 'theme':
|
||||
$sql_from = STYLES_THEME_TABLE;
|
||||
$sql_select = 'theme_name, theme_path, theme_storedb';
|
||||
break;
|
||||
|
||||
case 'imageset':
|
||||
$sql_from = STYLES_IMAGESET_TABLE;
|
||||
$sql_select = 'imageset_name, imageset_path';
|
||||
break;
|
||||
}
|
||||
|
||||
$sql = "SELECT {$mode}_id, {$mode}_name
|
||||
FROM $sql_from
|
||||
WHERE {$mode}_id <> {$style_row[$mode . '_id']}
|
||||
$sql_where
|
||||
ORDER BY {$mode}_name ASC";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$s_options = '<option value="0">' . $user->lang['KEEP_' . strtoupper($mode)] . '</option>';
|
||||
|
||||
$set_default = true;
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if ($set_default)
|
||||
{
|
||||
$s_options .= '<option value="' . $row[$mode . '_id'] . '" selected="selected">' . $row[$mode . '_name'] . '</option>';
|
||||
$set_default = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$s_options .= '<option value="' . $row[$mode . '_id'] . '">' . $row[$mode . '_name'] . '</option>';
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$template->assign_var('S_REPLACE_' . strtoupper($mode) . '_OPTIONS', $s_options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -285,11 +285,14 @@ $lang = array_merge($lang, array(
|
||||
'INSTALLED_TEMPLATE' => 'Installed templates',
|
||||
'INSTALLED_THEME' => 'Installed themes',
|
||||
|
||||
'KEEP_IMAGESET' => 'Keep imageset',
|
||||
'KEEP_TEMPLATE' => 'Keep template',
|
||||
'KEEP_THEME' => 'Keep theme',
|
||||
|
||||
'LINE_SPACING' => 'Line spacing',
|
||||
'LOCALISED_IMAGES' => 'Localised',
|
||||
'LOCATION_DISABLED_EXPLAIN' => 'This setting is inherited and cannot be changed.',
|
||||
|
||||
|
||||
'NO_CLASS' => 'Cannot find class in stylesheet.',
|
||||
'NO_IMAGESET' => 'Cannot find imageset on filesystem.',
|
||||
'NO_IMAGE' => 'No image',
|
||||
|
Loading…
x
Reference in New Issue
Block a user