diff --git a/phpBB/admin/admin_styles.php b/phpBB/admin/admin_styles.php index eacdfa33e7..bd83b593de 100644 --- a/phpBB/admin/admin_styles.php +++ b/phpBB/admin/admin_styles.php @@ -24,8 +24,9 @@ if($setmodules == 1) { $file = basename(__FILE__); $module['Styles']['Add_new'] = "$file?mode=addnew"; - $module['Styles']['Create_new'] = "$file?mode=addnew"; + $module['Styles']['Create_new'] = "$file?mode=create"; $module['Styles']['Manage'] = "$file"; + $module['Styles']['Export'] = "$file?mode=export"; return; } @@ -33,9 +34,24 @@ if($setmodules == 1) // Load default header // $phpbb_root_dir = "./../"; -require('pagestart.inc'); -if( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) ) +// +// Check if the user has cancled a confirmation message. +// +$confirm = ( $HTTP_POST_VARS['confirm'] ) ? TRUE : FALSE; +$cancel = ( $HTTP_POST_VARS['cancel'] ) ? TRUE : FALSE; + +if($cancel) +{ + header("Location: $PHP_SELF"); +} + +if(!$HTTP_POST_VARS['send_file']) +{ + require('pagestart.inc'); +} + +if(isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) ) { $mode = ($HTTP_GET_VARS['mode']) ? $HTTP_GET_VARS['mode'] : $HTTP_POST_VARS['mode']; } @@ -44,6 +60,352 @@ else $mode = ""; } -include('page_footer_admin.'.$phpEx); +switch($mode) +{ + case "addnew": + $install_to = ($HTTP_GET_VARS['install_to']) ? urldecode($HTTP_GET_VARS['install_to']) : $HTTP_POST_VARS['install_to']; + $style_name = ($HTTP_GET_VARS['style']) ? urldecode($HTTP_GET_VARS['style']) : $HTTP_POST_VARS['style']; + + if(isset($install_to)) + { + include($phpbb_root_dir . "templates/" . $install_to . "/theme_info.cfg"); + $template_name = $$install_to; + $found = FALSE; + + for($i = 0; $i < count($template_name) && !$found; $i++) + { + if($template_name[$i]['style_name'] == $style_name) + { + while(list($key, $val) = each($template_name[$i])) + { + $db_fields[] = $key; + $db_values[] = $val; + } + } + } + + $sql = "INSERT INTO " . THEMES_TABLE . " ("; + for($i = 0; $i < count($db_fields); $i++) + { + $sql .= $db_fields[$i]; + if($i != (count($db_fields) - 1)) + { + $sql .= ", "; + } + + } + $sql .= ") VALUES ("; + for($i = 0; $i < count($db_values); $i++) + { + $sql .= "'" . $db_values[$i] . "'"; + if($i != (count($db_values) - 1)) + { + $sql .= ", "; + } + } + $sql .= ")"; + + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Could not insert theme data!", "Error", __LINE__, __FILE__, $sql); + } + + message_die(GENERAL_MESSAGE, $lang['Theme_installed'], $lang['Success']); + + } + else + { + + $installable_themes = array(); + + if($dir = opendir($phpbb_root_dir . "templates/")) + { + while($sub_dir = readdir($dir)) + { + if($sub_dir != "." && $sub_dir != ".." && $sub_dir != "CVS") + { + if(file_exists($phpbb_root_dir . "templates/" . $sub_dir . "/theme_info.cfg")) + { + include($phpbb_root_dir . "templates/" . $sub_dir . "/theme_info.cfg"); + + for($i = 0; $i < count($$sub_dir); $i++) + { + $working_data = $$sub_dir; + + $style_name = $working_data[$i]['style_name']; + + $sql = "SELECT themes_id FROM " . THEMES_TABLE . " WHERE style_name = '$style_name'"; + if(!$result = $db->sql_query($sql)) + { + message_die(GENREAL_ERROR, "Could not query themes table!", "Error", __LINE__, __FILE__, $sql); + } + if(!$db->sql_numrows($result)) + { + $installable_themes[] = $working_data[$i]; + } + } + } + } + } + + $template->set_filenames(array( + "body" => "admin/styles_addnew_body.tpl") + ); + + $template->assign_vars(array( + "L_STYLES_TITLE" => $lang['Styles_admin'], + "L_STYLES_ADD_TEXT" => $lang['Styles_addnew_explain'], + "L_STYLE" => $lang['Style'], + "L_TEMPLATE" => $lang['Template'], + "L_INSTALL" => $lang['Install'], + "L_ACTION" => $lang['Action']) + ); + + for($i = 0; $i < count($installable_themes); $i++) + { + $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2']; + $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; + + $template->assign_block_vars("styles", array( + "STYLE_NAME" => $installable_themes[$i]['style_name'], + "TEMPLATE_NAME" => $installable_themes[$i]['template_name'], + "ROW_CLASS" => $row_class, + "ROW_COLOR" => $row_color, + "U_STYLES_INSTALL" => append_sid("admin_styles.$phpEx?mode=addnew&style=" . urlencode($installable_themes[$i]['style_name']) . "&install_to=" . urlencode($installable_themes[$i]['template_name']))) + ); + + } + $template->pparse("body"); + + } + closedir($dir); + } + + + break; + + case "create": + case "edit": + + + break; + case "export"; + + if($HTTP_POST_VARS['export_template']) + { + $template_name = $HTTP_POST_VARS['export_template']; + $sql = "SELECT * FROM " . THEMES_TABLE . " WHERE template_name = '$template_name'"; + + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Could not get theme data for selected template", "Error", __LINE__, __FILE__, $sql); + } + + $theme_rowset = $db->sql_fetchrowset($result); + + if(count($theme_rowset) == 0) + { + message_die(GENERAL_MESSAGE, $lang['No_themes'], $lang['Export_themes']); + } + + $theme_data = ''; // Done this to prevent highlighting editors getting confused! + + + @umask(0111); + + $fp = @fopen($phpbb_root_path . 'templates/' . $template_name . '/theme_info.cfg', 'w'); + if( !$fp ) + { + // + // Unable to open the file writeable do something here as an attempt + // to get around that... + // + $s_hidden_fields = ''; + $s_hidden_fields .= ''; + + $download_form = '
diff --git a/phpBB/templates/subSilver/admin/styles_exporter.tpl b/phpBB/templates/subSilver/admin/styles_exporter.tpl new file mode 100755 index 0000000000..2056260b7e --- /dev/null +++ b/phpBB/templates/subSilver/admin/styles_exporter.tpl @@ -0,0 +1,14 @@ + +{L_EXPORTER_EXPLAIN}
+ + diff --git a/phpBB/templates/subSilver/admin/styles_list_body.tpl b/phpBB/templates/subSilver/admin/styles_list_body.tpl new file mode 100755 index 0000000000..915fe49312 --- /dev/null +++ b/phpBB/templates/subSilver/admin/styles_list_body.tpl @@ -0,0 +1,21 @@ + +{L_STYLES_TEXT}
+ +{L_STYLE} | +{L_TEMPLATE} | +{L_EDIT} | +{L_DELETE} | +|
---|---|---|---|---|
{styles.STYLE_NAME} | +{styles.TEMPLATE_NAME} | +{L_EDIT} | +{L_DELETE} | +