Line 99 | Line 99 |
---|
$this->template_cfg .= ' # Some configuration options
|
$this->template_cfg .= ' # Some configuration options
|
# # You can use this function to inherit templates from another template. # The template of the given name has to be installed. # Templates cannot inherit from inheriting templates. #';
| # Template inheritance # See http://blog.phpbb.com/2008/07/31/templating-just-got-easier/ # Set value to empty or this template name to ignore template inheritance. inherit_from = {INHERIT_FROM} ';
|
$this->imageset_keys = array( 'logos' => array(
| $this->imageset_keys = array( 'logos' => array(
|
Line 510 | Line 510 |
---|
$db->sql_transaction('commit');
$cache->destroy('sql', STYLES_IMAGESET_DATA_TABLE);
|
$db->sql_transaction('commit');
$cache->destroy('sql', STYLES_IMAGESET_DATA_TABLE);
|
| $cache->destroy('imageset_site_logo_md5');
|
add_log('admin', 'LOG_IMAGESET_REFRESHED', $imageset_row['imageset_name']); trigger_error($user->lang['IMAGESET_REFRESHED'] . adm_back_link($this->u_action));
| add_log('admin', 'LOG_IMAGESET_REFRESHED', $imageset_row['imageset_name']); trigger_error($user->lang['IMAGESET_REFRESHED'] . adm_back_link($this->u_action));
|
Line 539 | Line 540 |
---|
global $user, $template, $db, $config, $phpbb_root_path, $phpEx;
$sql_from = '';
|
global $user, $template, $db, $config, $phpbb_root_path, $phpEx;
$sql_from = '';
|
| $sql_sort = 'LOWER(' . $mode . '_name)';
|
$style_count = array();
switch ($mode) { case 'style': $sql_from = STYLES_TABLE;
|
$style_count = array();
switch ($mode) { case 'style': $sql_from = STYLES_TABLE;
|
| $sql_sort = 'style_active DESC, ' . $sql_sort;
|
$sql = 'SELECT user_style, COUNT(user_style) AS style_count FROM ' . USERS_TABLE . '
| $sql = 'SELECT user_style, COUNT(user_style) AS style_count FROM ' . USERS_TABLE . '
|
Line 570 | Line 573 |
---|
case 'imageset': $sql_from = STYLES_IMAGESET_TABLE; break;
|
case 'imageset': $sql_from = STYLES_IMAGESET_TABLE; break;
|
| default: trigger_error($user->lang['NO_MODE'] . adm_back_link($this->u_action), E_USER_WARNING);
|
}
$l_prefix = strtoupper($mode);
| }
$l_prefix = strtoupper($mode);
|
Line 593 | Line 599 |
---|
);
$sql = "SELECT *
|
);
$sql = "SELECT *
|
FROM $sql_from";
| FROM $sql_from ORDER BY $sql_sort ASC";
|
$result = $db->sql_query($sql);
$installed = array();
| $result = $db->sql_query($sql);
$installed = array();
|
Line 629 | Line 636 |
---|
'NAME' => $row[$mode . '_name'], 'STYLE_COUNT' => ($mode == 'style' && isset($style_count[$row['style_id']])) ? $style_count[$row['style_id']] : 0,
|
'NAME' => $row[$mode . '_name'], 'STYLE_COUNT' => ($mode == 'style' && isset($style_count[$row['style_id']])) ? $style_count[$row['style_id']] : 0,
|
| 'S_INACTIVE' => ($mode == 'style' && !$row['style_active']) ? true : false,
|
) ); }
| ) ); }
|
Line 658 | Line 667 |
---|
if ($name && !in_array($name, $installed)) {
|
if ($name && !in_array($name, $installed)) {
|
$new_ary[] = array(
| // The array key is used for sorting later on. // $file is appended because $name doesn't have to be unique. $new_ary[$name . $file] = array(
|
'path' => $file, 'name' => $name, 'copyright' => $items['copyright'],
| 'path' => $file, 'name' => $name, 'copyright' => $items['copyright'],
|
Line 674 | Line 685 |
---|
if (sizeof($new_ary)) {
|
if (sizeof($new_ary)) {
|
| ksort($new_ary);
|
foreach ($new_ary as $cfg) { $template->assign_block_vars('uninstalled', array(
| foreach ($new_ary as $cfg) { $template->assign_block_vars('uninstalled', array(
|
Line 716 | Line 729 |
---|
$save_changes = (isset($_POST['save'])) ? true : false;
// make sure template_file path doesn't go upwards
|
$save_changes = (isset($_POST['save'])) ? true : false;
// make sure template_file path doesn't go upwards
|
$template_file = str_replace('..', '.', $template_file);
| $template_file = preg_replace('#\.{2,}#', '.', $template_file);
|
// Retrieve some information about the template $sql = 'SELECT template_storedb, template_path, template_name
| // Retrieve some information about the template $sql = 'SELECT template_storedb, template_path, template_name
|
Line 1587 | Line 1600 |
---|
{ case 'style': $sql_from = STYLES_TABLE;
|
{ case 'style': $sql_from = STYLES_TABLE;
|
$sql_select = 'style_name';
| $sql_select = 'style_id, style_name, template_id, theme_id, imageset_id';
|
$sql_where = 'AND style_active = 1'; break;
case 'template': $sql_from = STYLES_TEMPLATE_TABLE;
|
$sql_where = 'AND style_active = 1'; break;
case 'template': $sql_from = STYLES_TEMPLATE_TABLE;
|
$sql_select = 'template_name, template_path, template_storedb';
| $sql_select = 'template_id, template_name, template_path, template_storedb';
|
break;
case 'theme': $sql_from = STYLES_THEME_TABLE;
|
break;
case 'theme': $sql_from = STYLES_THEME_TABLE;
|
$sql_select = 'theme_name, theme_path, theme_storedb';
| $sql_select = 'theme_id, theme_name, theme_path, theme_storedb';
|
break;
case 'imageset': $sql_from = STYLES_IMAGESET_TABLE;
|
break;
case 'imageset': $sql_from = STYLES_IMAGESET_TABLE;
|
$sql_select = 'imageset_name, imageset_path';
| $sql_select = 'imageset_id, imageset_name, imageset_path';
|
break; }
| break; }
|
Line 1633 | Line 1646 |
---|
trigger_error($user->lang['NO_' . $l_prefix] . adm_back_link($this->u_action), E_USER_WARNING); }
|
trigger_error($user->lang['NO_' . $l_prefix] . adm_back_link($this->u_action), E_USER_WARNING); }
|
$sql = "SELECT {$mode}_id, {$mode}_name FROM $sql_from WHERE {$mode}_id <> $style_id $sql_where ORDER BY {$mode}_name ASC"; $result = $db->sql_query($sql);
| $s_only_component = $this->display_component_options($mode, $style_row[$mode . '_id'], $style_row);
|
|
|
$s_options = '';
if ($row = $db->sql_fetchrow($result)) { do { $s_options .= '<option value="' . $row[$mode . '_id'] . '">' . $row[$mode . '_name'] . '</option>'; } while ($row = $db->sql_fetchrow($result)); } else
| if ($s_only_component)
|
{ trigger_error($user->lang['ONLY_' . $l_prefix] . adm_back_link($this->u_action), E_USER_WARNING); }
|
{ trigger_error($user->lang['ONLY_' . $l_prefix] . adm_back_link($this->u_action), E_USER_WARNING); }
|
$db->sql_freeresult($result);
| |
if ($update)
|
if ($update)
|
| { if ($mode == 'style')
|
{ $sql = "DELETE FROM $sql_from WHERE {$mode}_id = $style_id"; $db->sql_query($sql);
|
{ $sql = "DELETE FROM $sql_from WHERE {$mode}_id = $style_id"; $db->sql_query($sql);
|
if ($mode == 'style') {
| |
$sql = 'UPDATE ' . USERS_TABLE . " SET user_style = $new_id WHERE user_style = $style_id";
| $sql = 'UPDATE ' . USERS_TABLE . " SET user_style = $new_id WHERE user_style = $style_id";
|
Line 1677 | Line 1674 |
---|
if ($style_id == $config['default_style']) { set_config('default_style', $new_id);
|
if ($style_id == $config['default_style']) { 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); $component_id = $style_row[$component . '_id']; $this->remove_component($component, $component_id, $new_id, $style_id);
|
} } else {
|
} } else {
|
if ($mode == 'imageset') { $sql = 'DELETE FROM ' . STYLES_IMAGESET_DATA_TABLE . " WHERE imageset_id = $style_id"; $db->sql_query($sql); } $sql = 'UPDATE ' . STYLES_TABLE . " SET {$mode}_id = $new_id WHERE {$mode}_id = $style_id"; $db->sql_query($sql);
| $this->remove_component($mode, $style_id, $new_id);
|
}
$cache->destroy('sql', STYLES_TABLE);
| }
$cache->destroy('sql', STYLES_TABLE);
|
Line 1704 | Line 1701 |
---|
$template->assign_vars(array( 'S_DELETE' => true,
|
$template->assign_vars(array( 'S_DELETE' => true,
|
'S_REPLACE_OPTIONS' => $s_options,
| |
'L_TITLE' => $user->lang[$this->page_title], 'L_EXPLAIN' => $user->lang[$this->page_title . '_EXPLAIN'],
| 'L_TITLE' => $user->lang[$this->page_title], 'L_EXPLAIN' => $user->lang[$this->page_title . '_EXPLAIN'],
|
Line 1718 | Line 1714 |
---|
'NAME' => $style_row[$mode . '_name'], ) );
|
'NAME' => $style_row[$mode . '_name'], ) );
|
| if ($mode == 'style') { $template->assign_vars(array( 'S_DELETE_STYLE' => true, )); } }
/** * Remove template/theme/imageset entry from the database */ function remove_component($component, $component_id, $new_id, $style_id = false) { global $db;
if (($new_id == 0) || ($component === 'template' && ($conflicts = $this->check_inheritance($component, $component_id)))) { // We can not delete the template, as the user wants to keep the component or an other template is inheriting from this one. return; }
$component_in_use = array(); if ($component != 'style') { $component_in_use = $this->component_in_use($component, $component_id, $style_id); }
if (($new_id == -1) && !empty($component_in_use)) { // We can not delete the component, as it is still in use return; }
if ($component == 'imageset') { $sql = 'DELETE FROM ' . STYLES_IMAGESET_DATA_TABLE . " WHERE imageset_id = $component_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 = $component_id"; $db->sql_query($sql);
$sql = 'UPDATE ' . STYLES_TABLE . " SET {$component}_id = $new_id WHERE {$component}_id = $component_id"; $db->sql_query($sql); }
/** * Display the options which can be used to replace a style/template/theme/imageset * * @return boolean Returns true if the component is the only component and can not be deleted. */ function display_component_options($component, $component_id, $style_row = false, $style_id = false) { global $db, $template, $user;
$is_only_component = true; $component_in_use = array(); if ($component != 'style') { $component_in_use = $this->component_in_use($component, $component_id, $style_id); }
$sql_where = ''; switch ($component) { case 'style': $sql_from = STYLES_TABLE; $sql_where = 'WHERE style_active = 1'; break;
case 'template': $sql_from = STYLES_TEMPLATE_TABLE; $sql_where = 'WHERE template_inherits_id <> ' . $component_id; break;
case 'theme': $sql_from = STYLES_THEME_TABLE; break;
case 'imageset': $sql_from = STYLES_IMAGESET_TABLE; break; }
$s_options = ''; if (($component != 'style') && empty($component_in_use)) { // If it is not in use, there must be another component $is_only_component = false;
$sql = "SELECT {$component}_id, {$component}_name FROM $sql_from WHERE {$component}_id = {$component_id}"; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result);
$s_options .= '<option value="-1" selected="selected">' . $user->lang['DELETE_' . strtoupper($component)] . '</option>'; $s_options .= '<option value="0">' . sprintf($user->lang['KEEP_' . strtoupper($component)], $row[$component . '_name']) . '</option>'; } else { $sql = "SELECT {$component}_id, {$component}_name FROM $sql_from $sql_where ORDER BY {$component}_name ASC"; $result = $db->sql_query($sql);
$s_keep_option = $s_options = ''; while ($row = $db->sql_fetchrow($result)) { if ($row[$component . '_id'] != $component_id) { $is_only_component = false; $s_options .= '<option value="' . $row[$component . '_id'] . '">' . sprintf($user->lang['REPLACE_WITH_OPTION'], $row[$component . '_name']) . '</option>'; } else if ($component != 'style') { $s_keep_option = '<option value="0" selected="selected">' . sprintf($user->lang['KEEP_' . strtoupper($component)], $row[$component . '_name']) . '</option>'; } } $db->sql_freeresult($result); $s_options = $s_keep_option . $s_options; }
if (!$style_row) { $template->assign_var('S_REPLACE_' . strtoupper($component) . '_OPTIONS', $s_options); } else { $template->assign_var('S_REPLACE_OPTIONS', $s_options); if ($component == 'style') { $components = array('template', 'theme', 'imageset'); foreach ($components as $component) { $this->display_component_options($component, $style_row[$component . '_id'], false, $component_id, true); } } }
return $is_only_component; }
/** * Check whether the component is still used by another style or component */ function component_in_use($component, $component_id, $style_id = false) { global $db;
$component_in_use = array();
if ($style_id) { $sql = 'SELECT style_id, style_name FROM ' . STYLES_TABLE . " WHERE {$component}_id = {$component_id} AND style_id <> {$style_id} ORDER BY style_name ASC"; } else { $sql = 'SELECT style_id, style_name FROM ' . STYLES_TABLE . " WHERE {$component}_id = {$component_id} ORDER BY style_name ASC"; } $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $component_in_use[] = $row['style_name']; } $db->sql_freeresult($result);
if ($component === 'template' && ($conflicts = $this->check_inheritance($component, $component_id))) { foreach ($conflicts as $temp_id => $conflict_data) { $component_in_use[] = $conflict_data['template_name']; } }
return $component_in_use;
|
}
/**
| }
/**
|
Line 1850 | Line 2051 |
---|
// Export template core code if ($mode == 'template' || $inc_template) {
|
// Export template core code if ($mode == 'template' || $inc_template) {
|
$template_cfg = str_replace(array('{MODE}', '{NAME}', '{COPYRIGHT}', '{VERSION}'), array($mode, $style_row['template_name'], $style_row['template_copyright'], $config['version']), $this->template_cfg);
$use_template_name = '';
| $use_template_name = $style_row['template_name'];
|
// Add the inherit from variable, depending on it's use... if ($style_row['template_inherits_id'])
| // Add the inherit from variable, depending on it's use... if ($style_row['template_inherits_id'])
|
Line 1866 | Line 2065 |
---|
$db->sql_freeresult($result); }
|
$db->sql_freeresult($result); }
|
$template_cfg .= ($use_template_name) ? "\ninherit_from = $use_template_name" : "\n#inherit_from = ";
| $template_cfg = str_replace(array('{MODE}', '{NAME}', '{COPYRIGHT}', '{VERSION}', '{INHERIT_FROM}'), array($mode, $style_row['template_name'], $style_row['template_copyright'], $config['version'], $use_template_name), $this->template_cfg);
|
$template_cfg .= "\n\nbbcode_bitfield = {$style_row['bbcode_bitfield']}";
$data[] = array(
| $template_cfg .= "\n\nbbcode_bitfield = {$style_row['bbcode_bitfield']}";
$data[] = array(
|