From 852f552b4af0fefcecf651c87bf0fc698ef498e4 Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Mon, 21 Jul 2003 15:44:39 +0000 Subject: add .tar, .tar.gz and .tar.bz2 support, rejiggle source, seperate compress objects extending the base class git-svn-id: file:///svn/phpbb/trunk@4305 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/adm/admin_styles.php | 145 ++++++++++++++++++++++----------------------- 1 file changed, 72 insertions(+), 73 deletions(-) (limited to 'phpBB/adm/admin_styles.php') diff --git a/phpBB/adm/admin_styles.php b/phpBB/adm/admin_styles.php index 551044712c..581e73cac0 100644 --- a/phpBB/adm/admin_styles.php +++ b/phpBB/adm/admin_styles.php @@ -19,7 +19,6 @@ if (!empty($setmodules)) define('IN_PHPBB', 1); // Include files $phpbb_root_path = '../'; -//$phpEx = substr(strrchr(basename($_SERVER['PATH_TRANSLATED']), '.'), 1); require($phpbb_root_path . 'extension.inc'); require('pagestart.' . $phpEx); @@ -703,7 +702,7 @@ switch ($mode) ?> -   +    $file_ary) { foreach ($file_ary as $file) { - if (strstr($path, 'CVS') || $file == $row['theme_path'] . '.css') + if ($file == $row['theme_path'] . '.css') { continue; } @@ -1291,8 +1290,8 @@ function viewsource(url) 'theme_copyright' => $theme_copyright, 'theme_path' => $theme_path, 'css_storedb' => $css_storedb, - 'css_data' => ($css_storedb) ? $css_data : '', - )); + 'css_data' => ($css_storedb) ? $css_data : '',) + ); } $sql = ($action == 'add' || $action == 'install') ? 'INSERT INTO ' . STYLES_CSS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary) : 'UPDATE ' . STYLES_CSS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE theme_id = ' . $theme_id; @@ -1426,7 +1425,7 @@ function viewsource(url) $map_elements = array( 'colors' => '%s', 'sizes' => '%d%s', - 'images' => 'url(\'./../%s\')', + 'images' => 'url(\'./%s\')', 'repeat' => '%s', 'other' => '%s', ); @@ -1553,10 +1552,11 @@ function viewsource(url) } else { - // We change the path to one relative to the root + // We change the path to one relative to the root rather than the theme + // folder $sql_ary = array( 'css_storedb' => 1, - 'css_data' => str_replace('./../', 'styles/themes/', $stylesheet), + 'css_data' => str_replace('./', 'styles/themes/', $stylesheet), ); $sql = 'UPDATE ' . STYLES_CSS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' @@ -1654,7 +1654,7 @@ function viewsource(url) // Grab list of potential images for class backgrounds - $imglist = filelist($phpbb_root_path . 'styles/themes'); + $imglist = filelist("{$phpbb_root_path}styles/themes/$theme_path"); $bg_imglist = ''; foreach ($imglist as $path => $img_ary) @@ -1847,20 +1847,10 @@ function csspreview()        + echo ($showcss) ? '' : ''; + echo $s_hidden_fields; + +?> @@ -1992,7 +1982,7 @@ function csspreview() ?> Delete from filesystem: - Yes   No + lang['YES']; ?>   lang['NO']; ?> '; + $theme_config = addslashes($theme_name) . "\n"; + $theme_config .= addslashes($theme_copyright) . "\n"; + $theme_config .= addslashes($config['version']) . "\n"; switch ($_POST['format']) { + case 'tar': + $ext = 'tar'; + $mimetype = 'x-tar'; + $compress = 'compress_tar'; + break; + case 'zip': if (!extension_loaded('zlib')) { - $error[] = $user->lang['NO_SUPPORT_ZIP']; - break; - } - - if (!($zip = new archive_zip('w', $phpbb_root_path . 'store/theme_' . $theme_path . '.zip'))) - { - trigger_error($user->lang['STORE_UNWRITEABLE']); - } - - // If we have the css in the DB we'll use that in preference to the one on the - // filesystem. We will also create an appropriate cfg file - if ($css_storedb) - { - $zip->add_file('styles/themes/' . $theme_path . '/', 'styles/themes/', $theme_path . '.css,theme.cfg'); - $zip->add_data($css_data, $theme_path . '/' . $theme_path . '.css'); - } - else - { - $zip->add_file('styles/themes/' . $theme_path . '/', 'styles/themes/', 'theme.cfg'); + trigger_error($user->lang['NO_SUPPORT_ZIP']); } - $zip->add_data($theme_config, $theme_path . '/theme.cfg'); - - $zip->close(); - $ext = 'zip'; $mimetype = 'zip'; + $compress = 'compress_zip'; break; - case 'tar': - $ext = 'tar'; - $mimetype = 'x-tar'; - break; - - case 'gz': + case 'tar.gz': if (!extension_loaded('zlib')) { - $error[] = $user->lang['NO_SUPPORT_GZ']; - break; + trigger_error($user->lang['NO_SUPPORT_GZ']); } $ext = 'tar.gz'; $mimetype = 'x-gzip'; + $compress = 'compress_tar'; break; - case 'bz2': - if (!extension_loaded('bzip2')) + case 'tar.bz2': + if (!extension_loaded('bz2')) { - $error[] = $user->lang['NO_SUPPORT_BZ2']; - break; + trigger_error($user->lang['NO_SUPPORT_BZ2']); } $ext = 'tar.bz2'; $mimetype = 'x-bzip2'; + $compress = 'compress_tar'; break; default: trigger_error($user->lang['NO_SUPPORT_ARCHIVE']); } + if (!($zip = new $compress('w', "{$phpbb_root_path}store/theme_$theme_path.$ext"))) + { + trigger_error($user->lang['STORE_UNWRITEABLE']); + } + + // If we have the css in the DB we'll use that in preference to the one on the + // filesystem. We will also create an appropriate cfg file + if ($css_storedb) + { + $zip->add_file("styles/themes/$theme_path/", 'styles/themes/', "$theme_path.css,theme.cfg"); + $zip->add_data($css_data, "$theme_path/$theme_path.css"); + } + else + { + $zip->add_file("styles/themes/$theme_path/", 'styles/themes/', 'theme.cfg'); + } + $zip->add_data($theme_config, "$theme_path/theme.cfg"); + + $zip->close(); + unset($theme_config); unset($css_data); @@ -2119,7 +2105,7 @@ function csspreview() } add_log('admin', 'LOG_EXPORT_THEME', $theme_name); - trigger_error(sprintf($user->lang['THEME_EXPORTED'], 'store/theme_' . $theme_path . '.zip')); + trigger_error(sprintf($user->lang['THEME_EXPORTED'], "store/theme_$theme_path.$ext")); } // Output list of themes @@ -2144,7 +2130,20 @@ function csspreview() lang['ARCHIVE_FORMAT']; ?>: - .zip   .tar   .tar.gz   .tar.bz2   + 'zlib', 'tar' => '', 'tar.gz' => 'zlib', 'tar.bz2' => 'bz2'); + + foreach ($compress_types as $type => $module) + { + if ($module && !extension_loaded($module)) + { + break; + } + echo ' .' . $type . '  '; + } + +?>    -- cgit v1.2.1