aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/SwiftThemeCreator/theme_creator.php
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--plugins/SwiftThemeCreator/theme_creator.php482
1 files changed, 319 insertions, 163 deletions
diff --git a/plugins/SwiftThemeCreator/theme_creator.php b/plugins/SwiftThemeCreator/theme_creator.php
index 7e9d6f006..e520eee27 100644
--- a/plugins/SwiftThemeCreator/theme_creator.php
+++ b/plugins/SwiftThemeCreator/theme_creator.php
@@ -21,10 +21,11 @@
// | USA. |
// +-----------------------------------------------------------------------+
-/* Ajouter le lien au menu de l'admin */
+/* TODO: Revoir le lien du menu de l'admin */
if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
if (!defined('IN_ADMIN') or !IN_ADMIN) die('Hacking attempt!');
-define(STC_PATH, PHPWG_PLUGINS_PATH.'SwiftThemeCreator/');
+define('STC_PATH', PHPWG_PLUGINS_PATH.'SwiftThemeCreator/');
+define('STC_INTERNAL_VERSION', '1.40');
/*
* stc_hex2rgb convert any string to array of RGB values
*/
@@ -76,127 +77,250 @@ function stc_newfile( $filename, $data )
}
return false;
}
+/*
+ * Default values
+ */
+function init_main(&$main)
+{
+ global $available_templates;
+ $main = array(
+ STC_INTERNAL_VERSION => true, /* $main version */
+ 'template_sel' => 0,
+ 'newtpl' => 'yoga',
+ 'newtheme' => '',
+ 'simulate' => true,
+ 'colorize' => false,
+ 'brightness' => false,
+ 'contrast' => false,
+ 'new_theme' => '',
+ 'color1' => '#111111',
+ 'color' => array('#111111', '#EEEEEE', '#FF7700', '#FF3333', '#FF3363', ),
+ 'templatedir' => PHPWG_ROOT_PATH . 'plugins/SwiftThemeCreator/simul',
+ 'color1' => '#111111',
+ 'color2' => '#EEEEEE',
+ 'color3' => '#FF7700',
+ 'color4' => '#FF3333',
+ 'color5' => '#FF3363',
+ 'background' => 'fixed',
+ 'picture_url' => PHPWG_ROOT_PATH . 'plugins/SwiftThemeCreator/sample.jpg',
+ 'picture_width' => 2048,
+ 'picture_height' => 100,
+ 'background_mode' => 'as',
+ 'src_category' => 0,
+ 'category' => 'header',
+ 'phase' => 'Kernel init',
+ 'subphase' => 'New version',
+ );
+}
$errors = array();
$infos = array();
-$available_templates = array();
-$template_dir = PHPWG_ROOT_PATH.'template';
-foreach (get_dirs($template_dir) as $dir)
-{
- array_push($available_templates, $dir);
-}
// +-----------------------------------------------------------------------+
-// | selected templates |
+// | Kernel init |
// +-----------------------------------------------------------------------+
if (!isset($swift_theme_creator)) $swift_theme_creator = new ThemeCreator();
$swift_theme_creator->reload();
$main = $swift_theme_creator->theme_config;
-if (isset($_POST['submit']) and (!is_adviser()))
+/*
+ * Find templates
+ */
+$available_templates = array();
+$template_dir = PHPWG_ROOT_PATH.'template';
+foreach (get_dirs($template_dir) as $dir)
+{ array_push($available_templates, $dir);
+}
+/*
+ * $main is reloaded but does template still exist?
+ * Does the fixed background still exist? Category? ...
+ */
+if (!isset($main[STC_INTERNAL_VERSION])) init_main($main);
+$flip = array_flip($available_templates);
+$main['template_sel'] = (isset($flip[$main['newtpl']])) ?
+ $flip[$main['newtpl']] : 0; /* Deleted ? First available */
+$main['subphase'] = 'Find category';
+$query = 'SELECT id,name,uppercats,global_rank
+ FROM ' . CATEGORIES_TABLE . ';';
+display_select_cat_wrapper($query,array(),'src_category');
+$available_cat = $template->get_template_vars('src_category');
+$flip = array_flip($available_cat);
+$main['src_category'] = (isset($flip[$main['category']])) ?
+ $flip[$main['category']] : max($flip); /* Deleted ? Most recent */
+
+
+// +-----------------------------------------------------------------------+
+// | $_POST controls |
+// +-----------------------------------------------------------------------+
+$main['phase'] = 'POST controls';
+if (!isset($_POST['reset']))
{
- // 1 - Theme name control
- $main['newtheme'] = strip_tags($_POST['new_theme']);
- if ( !preg_match('/^[a-z0-9-_]{1,8}$/', $main['newtheme']) )
- array_push($errors,
- l10n('Invalid theme name: 1 to 8 lowercase alphanumeric characters'
- . ' including "-" and "_".'));
+ $main['simulate'] = isset($_POST['simulate']);
+ if (!isset($_POST['submit'])) $main['simulate'] = true;
+ /*
+ * Template controls
+ */
+ $main['subphase'] = 'template controls';
+ if (isset($_POST['template'])) $main['template_sel'] = $_POST['template'];
+ $main['newtpl'] = $available_templates[$main['template_sel']];
+ if ($main['newtpl'] != 'yoga')
+ array_push($infos, l10n('Unpredictable results could be observed with '
+ . 'this template. Preview is based on yoga template only.'));
- // 2 - Colours control
- $main['color'] = array($_POST['color1'], $_POST['color2'],
- $_POST['color3'], $_POST['color4'],
- $_POST['color5']);
- $colors = $main['color'][0] . $main['color'][1] . $main['color'][2]
- . $main['color'][3] . $main['color'][4];
- if ( !preg_match('/^(#?([A-Fa-f0-9]{3}|[A-Fa-f0-9]{6})){5}$/', $colors) )
- array_push($errors,
- l10n('Invalid color code: 3 or 6 hexadecimal characters, preceded'
- . ' or not by "#"'));
+ /*
+ * Theme controls
+ */
+ $main['subphase'] = 'theme controls';
+ if (isset($_POST['new_theme'])) $main['newtheme'] = strip_tags($_POST['new_theme']);
+ if ($main['newtheme'] == '') $main['simulate'] = true; /* Empty = Simulate */
+ $cleaning = true; /* Delete files on failure */
+ if ( !$main['simulate'] and !preg_match('/^[a-z0-9-_]{1,8}$/', $main['newtheme']) )
+ array_push($errors, l10n('Invalid theme name: 1 to 8 lowercase'
+ . ' alphanumeric characters including "-" and "_".'));
+ if ($main['simulate']) { /* $main['templatedir'] != $template_dir (Smarty) */
+ $main['templatedir'] = PHPWG_ROOT_PATH . 'plugins/SwiftThemeCreator/simul';
+ $themedir = $main['templatedir'];
+ $cleaning = false; /* No delete with simulate */
+ } else {
+ $main['templatedir'] = PHPWG_ROOT_PATH . 'template/' . $main['newtpl'];
+ $themedir = $main['templatedir'] . '/theme/' . $main['newtheme'];
+ }
- // 2.1 - Background and text control
- list($r1,$g1,$b1) = stc_hex2rgb($main['color'][0]);
+ /*
+ * Directories controls
+ */
+ $main['subphase'] = 'directories controls';
+ if (is_dir( $themedir ) and !$main['simulate']) {
+ array_push($errors, '['.$themedir.'] : '.l10n('Invalid theme: This'
+ . ' theme exists already (no override available).'));
+ $cleaning = false; /* No delete on existing theme */
+ } elseif ( !is_writable($main['templatedir']) )
+ array_push($errors, '['.$main['templatedir'].'] : '.l10n('no_write_access'));
+
+ /*
+ * Colors controls
+ */
+ $main['subphase'] = 'colors controls';
+ if (isset($_POST['color1']))
+ $main['color'] = array(
+ $_POST['color1'], $_POST['color2'], $_POST['color3'], $_POST['color4'],
+ $_POST['color5']);
+ $main['color1'] = $main['color'][0];
+ $main['color2'] = $main['color'][1];
+ $main['color3'] = $main['color'][2];
+ $main['color4'] = $main['color'][3];
+ $main['color5'] = $main['color'][4];
+ $colors = $main['color1'] . $main['color2']
+ . $main['color3'] . $main['color4'] . $main['color5'];
+ if ( !preg_match('/^(#?([A-Fa-f0-9]{3}|[A-Fa-f0-9]{6})){5}$/', $colors) )
+ array_push($errors, l10n('Invalid color code: 3 or 6 hexadecimal characters,'
+ . ' preceded or not by "#"'));
+
+ /*
+ * Background and text difference control
+ */
+ $main['subphase'] = 'text difference controls';
+ list($r,$g,$b) = stc_hex2rgb($main['color'][0]);
list($r2,$g2,$b2) = stc_hex2rgb($main['color'][1]);
- // Formula for converting RGB values to YIQ values
- // as perceived brightness difference.
- // Background and text "brightness" difference control:
- $dif = abs( ( (($r1*299)+($g1*587)+($b1*114)) / 1000 )
- - ( (($r2*299)+($g2*587)+($b2*114)) / 1000 ));
+ $dif = abs( ( (($r*299)+($g*587)+($b*114)) / 1000 )
+ - ( (( $r2*299)+($g2*587)+($b2*114)) / 1000 ) );
if ( $dif < 65 )
- array_push($errors,
- l10n('Insufficient brightness difference between '
- . 'text and background. dif=') . $dif);
- // Background and text "colour" difference control:
- $dif = (max($r1, $r2) - min($r1, $r2))
- + (max($g1, $g2) - min($g1, $g2))
- + (max($b1, $b2) - min($b1, $b2));
+ array_push($errors, l10n('Insufficient brightness difference between '
+ . 'text and background. dif=') . $dif);
+ $dif = (max($r, $r2) - min($r, $r2))
+ + (max($g, $g2) - min($g, $g2)) + (max($b, $b2) - min($b, $b2));
if ( $dif < 200 )
- array_push($errors,
- l10n('Insufficient colour difference between '
- . 'text and background. dif=') . $dif);
+ array_push($errors, l10n('Insufficient colour difference between '
+ . 'text and background. dif=') . $dif);
- // 2.2 - Background and Internal links control
- if (isset($do_it))
+ /*
+ * Background and Internal links difference control
+ */
+ $main['subphase'] = 'links difference controls';
+ if (false)
{
- list($r1,$g1,$b1) = stc_hex2rgb($main['color'][0]);
+ list($r,$g,$b) = stc_hex2rgb($main['color'][0]);
list($r2,$g2,$b2) = stc_hex2rgb($main['color'][2]);
- // Background and Internal links "brightness" difference control:
- $dif = abs( ( (($r1*299)+($g1*587)+($b1*114)) / 1000 )
+ $dif = abs( ( (($r*299)+($g*587)+($b*114)) / 1000 )
- ( (($r2*299)+($g2*587)+($b2*114)) / 1000 ));
if ( $dif < 65 )
- array_push($errors,
- l10n('Insufficient brightness difference between '
- . 'Internal links and background. dif=') . $dif);
- // Background and Internal links "colour" difference control:
- $dif = (max($r1, $r2) - min($r1, $r2))
- + (max($g1, $g2) - min($g1, $g2))
- + (max($b1, $b2) - min($b1, $b2));
+ array_push($errors, l10n('Insufficient brightness difference between '
+ . 'Internal links and background. dif=') . $dif);
+ $dif = (max($r, $r2) - min($r, $r2))
+ + (max($g, $g2) - min($g, $g2)) + (max($b, $b2) - min($b, $b2));
if ( $dif < 200 )
- array_push($errors,
- l10n('Insufficient colour difference between '
- . 'Internal links and background. dif=') . $dif);
+ array_push($errors, l10n('Insufficient colour difference between '
+ . 'Internal links and background. dif=') . $dif);
}
- // 3 - Directory control
- $main['templatedir'] = PHPWG_ROOT_PATH . 'template/'
- . $available_templates[$_POST['template']];
- $main['newtpl'] = $available_templates[$_POST['template']];
- $themedir = $main['templatedir'] . '/theme/' . $main['newtheme'];
- if (is_dir( $themedir ))
- array_push($errors,
- '['.$themedir.'] : '.l10n('Invalid theme: This theme exists '
- . 'already (no override available).'));
- elseif (!is_writable($main['templatedir']))
- array_push($errors,
- '['.$main['templatedir'].'] : '.l10n('no_write_access'));
- // 4 - Picture URL control
- if ( $_POST['background'] == 'fixed' and (is_dir($_POST['picture_url'])
- or !is_file($_POST['picture_url'])) )
- array_push($errors,
- l10n('Header picture is not found, check its path and name.'));
-
- // 5 - Expected Width and Height limits control
- if ( !(ctype_digit($_POST['picture_width']) and $_POST['picture_width'] > 11
- and $_POST['picture_width'] < 4097 ) )
- array_push($errors,
- '['.$_POST['picture_width'].'] : '
- . l10n('incorrect width value [12-4096].'));
- if ( !(ctype_digit($_POST['picture_height']) and $_POST['picture_height'] > 11
- and $_POST['picture_height'] < 201 ) )
- array_push($errors,
- '['.$_POST['picture_height'].'] : '
- . l10n('incorrect width value [12-200].'));
-
- // 6 - Generate missing colors values
- list($r1,$g1,$b1) = stc_hex2rgb($main['color'][0]);
- if ((( (($r1+1)/256)*(($g1+1)/256)*(($b1+1)/256) ) * 1000 ) < 125 )
- $main['color6'] = lighten( $r1, $g1, $b1, 10);
- else $main['color6'] = darken( $r1, $g1, $b1, 10);
- list($r1,$g1,$b1) = stc_hex2rgb($main['color'][4]);
- if ((( (($r1+1)/256)*(($g1+1)/256)*(($b1+1)/256) ) * 1000 ) < 125 )
- $main['color7'] = lighten( $r1, $g1, $b1, 10);
- else $main['color7'] = darken( $r1, $g1, $b1, 10);
+ /*
+ * Header background controls
+ */
+ $main['subphase'] = 'fixed background controls';
+ if (isset($_POST['background'])) $main['background'] = $_POST['background'];
+ // Fixed
+ if ( $main['background'] == 'fixed' and isset($_POST['picture_url'])) {
+ if ( is_dir($_POST['picture_url'])
+ or !is_file($_POST['picture_url']) )
+ array_push($errors, l10n('Header picture is not found, check its path and name.'));
+ $extension = substr($_POST['picture_url'],strrpos($_POST['picture_url'],'.')+1);
+ if (!in_array($extension, array('jpg','jpeg','png')))
+ array_push($errors, l10n('Compliant extensions are .jpg, .jpeg or .png.'));
+ }
+ $main['subphase'] = 'random background controls';
+ if (isset($_POST['src_category']))
+ $main['src_category'] = (int) $_POST['src_category'];
+ $main['category'] = $available_cat[$main['src_category']];
- // Go ahead
+ /*
+ * Width and Height limits control
+ */
+ $main['subphase'] = 'width and height controls';
+ if ($main['background'] != 'off'
+ and isset($_POST['picture_width'])
+ and isset($_POST['picture_height']))
+ {
+ if( !(ctype_digit($_POST['picture_width'])
+ and $_POST['picture_width'] > 11
+ and $_POST['picture_width'] < 4097 ) )
+ array_push($errors, '['.$_POST['picture_width'].'] : '
+ . l10n('incorrect width value [12-4096].'));
+ else $main['picture_width'] = $_POST['picture_width'];
+ if ( !(ctype_digit($_POST['picture_height'])
+ and $_POST['picture_height'] > 11
+ and $_POST['picture_height'] < 201 ) )
+ array_push($errors, '['.$_POST['picture_height'].'] : '
+ . l10n('incorrect width value [12-200].'));
+ else $main['picture_height'] = $_POST['picture_height'];
+ }
+
+ /*
+ * Generate missing colors values
+ */
+ $main['subphase'] = 'complementary colors';
+ list($r,$g,$b) = stc_hex2rgb($main['color'][0]);
+ if ((( (($r+1)/256)*(($g+1)/256)*(($b+1)/256) ) * 1000 ) < 125 )
+ $main['color6'] = lighten( $r, $g, $b, 10);
+ else $main['color6'] = darken( $r, $g, $b, 10);
+ list($r,$g,$b) = stc_hex2rgb($main['color'][4]);
+ if ((( (($r+1)/256)*(($g+1)/256)*(($b+1)/256) ) * 1000 ) < 125 )
+ $main['color7'] = lighten( $r, $g, $b, 10);
+ else $main['color7'] = darken( $r, $g, $b, 10);
+ $main['colorize'] = isset($_POST['colorize']) ? true : false;
+ $main['brightness'] = isset($_POST['brightness']) ? true : false;
+ $main['contrast'] = isset($_POST['contrast']) ? true : false;
+}
+
+// +-----------------------------------------------------------------------+
+// | Build files |
+// +-----------------------------------------------------------------------+
+$main['phase'] = 'Files building';
+if ((isset($_POST['submit']) or $main['simulate'] ) and (!is_adviser()))
+{
+ /*
+ * Go ahead
+ */
+ $main['subphase'] = 'Mkdir control';
if (count($errors) == 0) {
umask(0000);
@mkdir($themedir, 0705);
@@ -209,75 +333,136 @@ if (isset($_POST['submit']) and (!is_adviser()))
/*
* Build themeconf.inc.php
**/
+ $main['subphase'] = 'Build themeconf';
$plugin_tpl = new Template();
$plugin_tpl->set_filenames(array('themeconf'=>
STC_PATH . 'themeconf.inc.tpl'));
$plugin_tpl->assign('main',$main);
$main['themeconf_inc_php'] = $plugin_tpl->parse('themeconf', true);
- $r = stc_newfile( $themedir . '/themeconf.inc.php',
+ $rfs = stc_newfile( $themedir . '/themeconf.inc.php',
$main['themeconf_inc_php'] );
/*
* Build mail-css.tpl
**/
+ $main['subphase'] = 'Build mail-css';
$plugin_tpl->set_filenames(array('mailcss'=>
STC_PATH . 'mail-css.tpl2'));
$plugin_tpl->assign('main',$main);
$main['mail-css.tpl'] = $plugin_tpl->parse('mailcss', true);
- $r = $r && stc_newfile( $themedir . '/mail-css.tpl',
+ $rfs = $rfs && stc_newfile( $themedir . '/mail-css.tpl',
$main['mail-css.tpl'] );
/*
* Build theme.css
- **/
- $plugin_tpl->set_filenames(array('theme'=>
- STC_PATH . 'theme.tpl'));
+ **/
+ $main['subphase'] = 'Build theme';
+ $plugin_tpl->set_filenames(array('theme'=> STC_PATH . 'theme.tpl'));
$plugin_tpl->assign('main',$main);
$main['theme.css'] = $plugin_tpl->parse('theme', true);
- $r = $r && stc_newfile( $themedir . '/theme.css',
- $main['theme.css'] );
+ $rfs = $rfs && stc_newfile( $themedir . '/theme.css', $main['theme.css'] );
+ $internal = stc_hex2rgb($main['color'][2]);
+ list($r,$g,$b) = $internal;
+ $background = stc_hex2rgb($main['color'][0]);
+ list($r2,$g2,$b2) = $background;
+ $delta = floor(((array_sum($internal)/3) - (array_sum($background)/3))/5.1);
+ /* Brightness is half of difference between colors of internal lnks and bkground */
+ /* but if color range is 0-255, resulting brightness range is between -50 and 50 */
+ if ($delta > 0) { /* Colorize need a darker color on a dark background */
+ $r = floor($r / 5);
+ $g = floor($g / 5);
+ $b = floor($b / 5);
+ }
+ if (isset($_POST['background']) and $_POST['background'] == 'random')
+ {
+ $main['subphase'] = 'Pick random for a pic';
+ $main['random'] = mt_rand(12, 4096);
+ $result = pwg_query('
+ SELECT i.path
+ FROM '.CATEGORIES_TABLE.' c,
+ '.IMAGES_TABLE.' i,
+ '.IMAGE_CATEGORY_TABLE.' ic
+ WHERE c.status=\'public\'
+ AND c.id = ic.category_id
+ AND c.id = ' . $main['src_category'] . '
+ AND ic.category_id = ' . $main['src_category'] . '
+ AND ic.image_id = i.id
+ ORDER BY RAND(' . $main['random'] . ')
+ LIMIT 0,1');
+ if($result) list($main['pic_path']) = mysql_fetch_array($result);
+ else $main['pic_path'] =
+ PHPWG_ROOT_PATH . 'plugins/SwiftThemeCreator/simul/header.jpg';
+ $main['pic_ext'] = substr($main['pic_path'],strrpos($main['pic_path'],'.')+1);
+ if ($main['pic_ext']=='png')
+ $img = imagecreatefrompng($main['pic_path']);
+ elseif (in_array($main['pic_ext'],array('jpg','jpeg')))
+ $img = imagecreatefromjpeg($main['pic_path']);
+ else $img = imagecreatefromjpeg(PHPWG_ROOT_PATH
+ . 'plugins/SwiftThemeCreator/simul/header.jpg');
+ imagejpeg( $img, $themedir . '/header.jpg', 90 );
+ imagedestroy ($img);
+ }
+ if (isset($_POST['background']) and $_POST['background'] == 'fixed')
+ {
+ if (function_exists('imagecreatefromjpeg'))
+ {
+ $hdr = imagecreatetruecolor ($main['picture_width'], $main['picture_height']);
+ imagecolorset ( $hdr, 0, $r2, $g2, $b2 );
+ if ($extension == 'png') $img = imagecreatefrompng($_POST['picture_url']);
+ else $img = imagecreatefromjpeg($_POST['picture_url']);
+ imagecopymerge ( $hdr, $img, 0, 0, 0, 0, $main['picture_width'], $main['picture_height'], 60 );
+ imagedestroy ($img);
+ if ($main['colorize']) imagefilter($hdr, IMG_FILTER_COLORIZE, $r, $g, $b);
+ if ($main['brightness']) imagefilter($hdr, IMG_FILTER_BRIGHTNESS, $delta);
+ if ($main['contrast']) imagefilter($hdr, IMG_FILTER_CONTRAST, 20);
+ imagejpeg( $hdr, $themedir . '/header.jpg', 90 );
+ imagedestroy ($hdr);
+ }
+ else @copy( $_POST['picture_url'], $themedir . '/header.jpg');
+ }
/*
* Build background image for titrePage or definition list (in #menubar)
**/
if (function_exists('imagecreatefrompng'))
{
+ $hdr = imagecreatetruecolor (1, 38);
+ imagecolorset ( $hdr, 0, $r2, $g2, $b2 );
$img = imagecreatefrompng(STC_PATH . '/titrePage-bg.png');
- $dest = imagecreate(1, 64);
- for ($i=0; $i<256; $i++) {
- imagecolorallocate($dest, $i, $i, $i);
- }
- imagecopy($dest, $img, 0, 0, 0, 0, 1, 64);
- list($r1,$g1,$b1) = stc_hex2rgb($main['color'][4]);
- for ($i = 0; $i < 256; $i++) {
- imagecolorset($dest, $i, min(floor($i * $r1 / 255), 255),
- min(floor($i * $g1 / 255), 255),
- min(floor($i * $b1 / 255), 255));
- }
- // to be tested imagecopymerge($dest,$img,0,0,0,0,1,64,33);
- imagepng( $dest, $themedir . '/stc.png', 9 );
+ imagecopymerge ( $hdr, $img, 0, 0, 0, 0, 1, 38, 60 );
imagedestroy ($img);
- imagedestroy ($dest);
+ if ($main['colorize']) imagefilter($hdr, IMG_FILTER_COLORIZE, $r, $g, $b);
+ if ($main['brightness']) imagefilter($hdr, IMG_FILTER_BRIGHTNESS, $delta);
+ if ($main['contrast']) imagefilter($hdr, IMG_FILTER_CONTRAST, 20);
+ imagepng( $hdr, $themedir . '/stc.png', 9 );
+ imagedestroy ($hdr);
}
else @copy( STC_PATH
. '/titrePage-bg.png', $themedir . '/stc.png');
- if ($r == false) {
+ if ($rfs == false) {
array_push($errors,
l10n('Theme files creation failure: theme should be deleted.'));
- @unlink( $themedir . '/stc.png' );
- @unlink( $themedir . '/themeconf.inc.php' );
- @unlink( $themedir . '/mail-css.tpl' );
- @unlink( $themedir . '/theme.css' );
- @rmdir( $themedir );
+ if ($cleaning) {
+ @unlink( $themedir . '/header.jpg' );
+ @unlink( $themedir . '/stc.png' );
+ @unlink( $themedir . '/themeconf.inc.php' );
+ @unlink( $themedir . '/mail-css.tpl' );
+ @unlink( $themedir . '/theme.css' );
+ @rmdir( $themedir );
+ }
}
- else {
+ elseif (!$main['simulate']) {
array_push($infos,
'['.$main['newtpl'] . '/' . $main['newtheme'].'] : '
.l10n('Congratulation! You have got(/ten) a new available theme.'));
+ @copy( $themedir . '/header.jpg', PHPWG_ROOT_PATH . 'plugins/SwiftThemeCreator/simul/header.jpg');
+ @copy( $themedir . '/stc.png', PHPWG_ROOT_PATH . 'plugins/SwiftThemeCreator/simul/stc.png');
+ @copy( $themedir . '/themeconf.inc.php', PHPWG_ROOT_PATH . 'plugins/SwiftThemeCreator/simul/themeconf.inc.php');
+ @copy( $themedir . '/mail-css.tpl', PHPWG_ROOT_PATH . 'plugins/SwiftThemeCreator/simul/mail-css.tpl');
+ @copy( $themedir . '/theme.css', PHPWG_ROOT_PATH . 'plugins/SwiftThemeCreator/simul/theme.css');
}
}
}
- // TODO ******** HEADER *********
- // Interesting Graphic Charter
- // http://accessites.org/site/2006/08/visual-vs-structural/
+ // TODO ******** theSwiftHeader itself *********
+
$swift_theme_creator->save_theme_config();
}
@@ -286,11 +471,11 @@ if (isset($_POST['submit']) and (!is_adviser()))
// +-----------------------------------------------------------------------+
if (isset($_POST['reset']) and (!is_adviser())) {
$main = array();
+ init_main($main);
$swift_theme_creator->theme_config = $main;
$swift_theme_creator->save_theme_config();
redirect( get_admin_plugin_menu_link(dirname(__FILE__).'/theme_creator.php'));
}
-// To be implemented delete $main save and redirect
// Don't forget to re-read because some statements are superfluous
@@ -311,43 +496,17 @@ body .colorwell-selected { border: 3px double #F36; font-weight: bold; }
.radio { margin: 0 10px 0 50px; }
</style>'
);
-
-/* Templates */
+$template->assign('radio_options',
+ array(
+ 'true' => l10n('Yes'),
+ 'false' => l10n('No')));
$template->assign('template_options', $available_templates);
-if (!isset($main['template_options'])) $main['template_options'] = 0;
-
-/* New theme */
-if (isset($_POST['new_theme'])) $main['new_theme'] = $_POST['new_theme'];
-
-/* Colors */
-if (isset($_POST['color1'])) $main['color1'] = $_POST['color1'];
-if (isset($_POST['color2'])) $main['color2'] = $_POST['color2'];
-if (isset($_POST['color3'])) $main['color3'] = $_POST['color3'];
-if (isset($_POST['color4'])) $main['color4'] = $_POST['color4'];
-if (isset($_POST['color5'])) $main['color5'] = $_POST['color5'];
-if (!isset($main['color1'])) $main['color1'] = '#111111';
-if (!isset($main['color2'])) $main['color2'] = '#EEEEEE';
-if (!isset($main['color3'])) $main['color3'] = '#FF7700';
-if (!isset($main['color4'])) $main['color4'] = '#FF3333';
-if (!isset($main['color5'])) $main['color5'] = '#FF3363';
-
-/* header */
-if (isset($_POST['background'])) $main['background'] = $_POST['background'];
-if (!isset($main['background'])) $main['background'] = 'off';
$template->assign('background_options',
array(
'off' => l10n('No'),
'random' => l10n('24H Random'),
'fixed' => l10n('Fixed URL'),
));
-
-$query = '
-SELECT id,name,uppercats,global_rank
- FROM ' . CATEGORIES_TABLE . ';';
-display_select_cat_wrapper($query,array(),'src_category');
-if (isset($_POST['src_category'])) $main['src_category'] =
- $_POST['src_category'];
-
$main['picture_url'] = PHPWG_ROOT_PATH . 'plugins/SwiftThemeCreator/sample.jpg';
if (isset($swift_theme_creator->picture_url))
$main['picture_url'] = $swift_theme_creator->picture_url;
@@ -355,14 +514,11 @@ if (isset($_POST['picture_url'])) $main['picture_url'] = $_POST['picture_url'];
if (isset($_POST['picture_width']))
$main['picture_width'] = $_POST['picture_width'];
-if (!isset($main['picture_width'])) $main['picture_width'] = 2048;
if (isset($_POST['picture_height']))
$main['picture_height'] = $_POST['picture_height'];
-if (!isset($main['picture_height'])) $main['picture_height'] = 100;
if (isset($_POST['background_mode']))
$main['background_mode'] = $_POST['background_mode'];
-if (!isset($main['background_mode'])) $main['background_mode'] = 'as';
$template->assign('background_mode_options',
array(
'as' => l10n('As is'),