aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvdigital <vdigital@piwigo.org>2008-08-26 14:18:42 +0000
committervdigital <vdigital@piwigo.org>2008-08-26 14:18:42 +0000
commit7f956e71b91f32ff6ca87ea6a0f56cc0f02c7005 (patch)
tree2123313a00e1432a340ac2206845bfc3278e180a
parentebe89e0a28b14f845b5be83766597f1db3cfb970 (diff)
Swift Theme Creator (minor changes): partly functional version.
git-svn-id: http://piwigo.org/svn/trunk@2487 68402e56-0260-453c-a942-63ccdbb3a9ee
-rw-r--r--plugins/SwiftThemeCreator/sample.jpgbin55215 -> 47132 bytes
-rw-r--r--plugins/SwiftThemeCreator/simul/.cvsignore1
-rw-r--r--plugins/SwiftThemeCreator/simul/index.php30
-rw-r--r--plugins/SwiftThemeCreator/theme.tpl6
-rw-r--r--plugins/SwiftThemeCreator/theme_creator.php482
-rw-r--r--plugins/SwiftThemeCreator/theme_creator.tpl146
-rw-r--r--plugins/SwiftThemeCreator/themeconf.inc.tpl6
-rw-r--r--plugins/SwiftThemeCreator/titrePage-bg.pngbin201 -> 179 bytes
-rw-r--r--template/yoga/header.tpl7
9 files changed, 465 insertions, 213 deletions
diff --git a/plugins/SwiftThemeCreator/sample.jpg b/plugins/SwiftThemeCreator/sample.jpg
index e2763c879..e5686d9b7 100644
--- a/plugins/SwiftThemeCreator/sample.jpg
+++ b/plugins/SwiftThemeCreator/sample.jpg
Binary files differ
diff --git a/plugins/SwiftThemeCreator/simul/.cvsignore b/plugins/SwiftThemeCreator/simul/.cvsignore
new file mode 100644
index 000000000..72e8ffc0d
--- /dev/null
+++ b/plugins/SwiftThemeCreator/simul/.cvsignore
@@ -0,0 +1 @@
+*
diff --git a/plugins/SwiftThemeCreator/simul/index.php b/plugins/SwiftThemeCreator/simul/index.php
new file mode 100644
index 000000000..c15b15795
--- /dev/null
+++ b/plugins/SwiftThemeCreator/simul/index.php
@@ -0,0 +1,30 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based picture gallery |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
+// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify |
+// | it under the terms of the GNU General Public License as published by |
+// | the Free Software Foundation |
+// | |
+// | This program is distributed in the hope that it will be useful, but |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+// | General Public License for more details. |
+// | |
+// | You should have received a copy of the GNU General Public License |
+// | along with this program; if not, write to the Free Software |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA. |
+// +-----------------------------------------------------------------------+
+
+// Recursive call
+$url = '../';
+header( 'Request-URI: '.$url );
+header( 'Content-Location: '.$url );
+header( 'Location: '.$url );
+exit();
+?>
diff --git a/plugins/SwiftThemeCreator/theme.tpl b/plugins/SwiftThemeCreator/theme.tpl
index b56d2e217..09511ba38 100644
--- a/plugins/SwiftThemeCreator/theme.tpl
+++ b/plugins/SwiftThemeCreator/theme.tpl
@@ -9,16 +9,16 @@ INPUT.rateButtonSelected /* <= why IE doesn't inherit this ? */ {ldelim}
H2, #menubar DT, .throw,
A, INPUT.rateButton {ldelim} color: {$main.color3}; }
-UL.tabsheet LI.normal_tab:hover {ldelim} border: 1px solid {$main.color4}; }
+UL.tabsheet LI.normal_tab:hover {ldelim} border: 1px solid {$main.color3}; }
A:hover {ldelim} color: {$main.color4}; }
.content UL.thumbnails SPAN.wrap2:hover,
.content UL.thumbnailCategories DIV.thumbnailCategory:hover,
.content UL.thumbnailCategories DIV.thumbnailCategory:hover A {ldelim}
- color: {$main.color4}; border: 1px solid {$main.color5}; background-color: {$main.color6}; }
+ color: {$main.color4}; border: 1px solid {$main.color4}; background-color: {$main.color6}; }
#menubar DL, .content, #comments DIV.comment BLOCKQUOTE,
-#imageHeaderBar, H2, #menubar DT, #imageToolBar {ldelim} border: 1px solid {$main.color5}; }
+#imageHeaderBar, H2, #menubar DT, #imageToolBar {ldelim} border: 1px solid {$main.color4}; }
#menubar DL, .content, #imageToolBar, .header_notes, UL.tabsheet LI.selected_tab {ldelim}
background-color: {$main.color6}; }
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'),
diff --git a/plugins/SwiftThemeCreator/theme_creator.tpl b/plugins/SwiftThemeCreator/theme_creator.tpl
index bc8604e85..14bbd26ec 100644
--- a/plugins/SwiftThemeCreator/theme_creator.tpl
+++ b/plugins/SwiftThemeCreator/theme_creator.tpl
@@ -14,12 +14,12 @@ You can update later the result as you need.'|@translate}
<table><tr><td style="padding-right:20px;">
{'Template'|@translate}
</td><td>
- {html_options name=template options=$template_options selected=$main.template_options}
+ {html_options name=template options=$template_options selected=$main.template_sel}
</td></tr>
<tr><td style="padding-right:20px;">
{'New theme to be created'|@translate}
</td><td>
- <input type="text" maxlength="8" size="8" name="new_theme" id="new_theme" value="{$main.new_theme}" />
+ <input type="text" maxlength="8" size="8" name="new_theme" id="new_theme" value="{$main.newtheme}" />
</td></tr>
</table>
</fieldset>
@@ -77,55 +77,58 @@ You can update later the result as you need.'|@translate}
<legend>{'Header background selection '|@translate}</legend>
<table>
<tr>
- <td style="padding-right:20px;">
- {'Use of a picture background'|@translate} {* No / 24H Random public picture / Fixed RRL *}
- </td>
-
- <td colspan="2">
- <label>
- <input class="radio" type="radio" value="off" name="background"
- {if ($main.background == 'off')}
- checked="checked"
- {/if}/>
- {$background_options.off}
- </label>
+ <td style="padding-right:120px;">
+ <label><input class="radio" type="radio" value="off" name="background"
+ {if ($main.background == 'off')} checked="checked" {/if}/>
+ {'No picture'|@translate}</label> {* No / 24H Random public picture / Fixed URL *}
</td>
+ <td colspan="2"></td>
</tr>
<tr>
- <td style="padding-right:20px;">
- {'Source category'|@translate}
- </td><td>
- <label>
- <input class="radio" type="radio" value="random" name="background"
- {if ($main.background == 'random')}
- checked="checked"
- {/if}/>
- {$background_options.random}
- </label>
- </td><td>
- {html_options style="margin: 0 0 0 10px;" name=src_category options=$src_category select=$main.src_category}
+ <td style="padding-right:120px;">
+ <label> <input class="radio" type="radio" value="random" name="background"
+ {if ($main.background == 'random')} checked="checked" {/if}/>
+ {'Random source'|@translate}</label>
+ </td>
+ <td colspan="2">
+ {html_options style="margin: 0 0 0 10px;" name=src_category options=$src_category selected=$main.src_category}
</td>
</tr>
+
<tr>
- <td style="padding-right:20px;">
- {'Picture relative local path'|@translate}
- </td><td>
- <label>
- <input class="radio" type="radio" value="fixed" name="background"
- {if ($main.background == 'fixed')}
- checked="checked"
- {/if}/>
- {$background_options.fixed}
- </label>
- </td><td>
+ <td style="padding-right:120px;">
+ <label> <input class="radio" type="radio" value="fixed" name="background"
+ {if ($main.background == 'fixed')} checked="checked" {/if}/>
+ {'Fixed path'|@translate}</label>
+ </td>
+ <td colspan="2">
<input style="margin: 0 0 0 10px;" type="text" maxlength="255" size="70" name="picture_url" id="picture_url" value="{$main.picture_url}" />
</td>
</tr>
<tr>
<td style="padding-right:20px;">
+ &nbsp;
+ </td><td colspan="2" style="padding-left:20px;">
+ <label style="padding-right:50px;">
+ <input type="checkbox" name="colorize" {if ($main.colorize)}checked="checked"{/if} />
+ {'Colorize'|@translate} {* Colorize / Enhance Brightness / Reduce contrast *}
+ </label>
+ <label style="padding-right:50px;">
+ <input type="checkbox" name="brightness" {if ($main.brightness)}checked="checked"{/if} />
+ {'Enhance brightness'|@translate}
+ </label>
+ <label>
+ <input type="checkbox" name="contrast" {if ($main.contrast)}checked="checked"{/if} />
+ {'Reduce contrast'|@translate}
+ </label>
+ </td>
+ </tr>
+
+ <tr>
+ <td style="padding-right:5px; text-align: right;">
{'Width limit in pixels'|@translate}
</td><td colspan="2">
<input style="margin: 0 10px 0 50px;" type="text" maxlength="5" size="8" name="picture_width" id="picture_width" value="{$main.picture_width}" />
@@ -136,7 +139,7 @@ You can update later the result as you need.'|@translate}
</tr>
<tr>
- <td style="padding-right:20px;">
+ <td style="padding-right:5px; text-align: right;">
{'Display mode'|@translate} {* As is / truncated / resized *}
</td><td colspan="2">
{html_radios name='background_mode' class="radio" options=$background_mode_options selected=$main.background_mode}
@@ -146,7 +149,68 @@ You can update later the result as you need.'|@translate}
</fieldset>
<p>
-<input name="reset" class="submit" type="submit" value="{'Reset'|@translate}" /> &nbsp;
-<input name="submit" class="submit" type="submit" value="{'Submit'|@translate}" />
+<input name="reset" class="submit" type="submit" value="{'Reset'|@translate}" style="margin-right:250px;" /> &nbsp;
+<input name="submit" class="submit" type="submit" value="{'Generate'|@translate}" style="margin-right:50px;" /> &nbsp;
+<input name="simulate" class="submit" type="submit" value="{'Simulate'|@translate}" />
</p>
-</form> \ No newline at end of file
+</form>
+<fieldset>
+ <legend>{'Just a yoga preview... '|@translate}</legend>
+<div style="background-color:{$main.color1}; width: 600px; overflow: hidden; margin: 5px auto 5px auto;
+font-family:Univers,Helvetica,Optima,'Bitstream Vera Sans',sans-serif;">
+ {* Preview header *}<div style="width: 600px; height: 80px; overflow: hidden;">
+ {if ($main.background=='fixed')}
+ <img src="{$main.templatedir}/header.jpg">
+ <h2 style="position:relative;color:{$main.color2};top:-75px;left:5px;text-align:left;margin:0 auto 0 auto;">{'"Fixed header" preview'|@translate}</h2>
+ {/if}
+ {if ($main.background=='random')}
+ <img src="{$main.templatedir}/header.jpg">
+ <h2 style="position:relative;color:{$main.color2};top:-75px;left:5px;text-align:left;margin:0 auto 0 auto;">{'"Random header" preview'|@translate}</h2>
+ {/if}
+ {if ($main.background=='off')}
+ <h2 style="position:relative;color:{$main.color2};top:25px;left:5px;text-align:left;margin:0 auto 0 auto;">{'"No header" preview'|@translate}</h2>
+ {/if}
+ </div>
+ {* Preview menubar *}<div style="border:1px solid {$main.color3}; margin:2px 4px 0px 2px;
+text-decoration:none; width: 120px; display:inline; background-color:{$main.color6};
+float:left; padding:0pt; text-align:left; color:{$main.color2}; font-size:1em;">
+ <dl style="margin: 0;">
+ <dt style="background-image:url({$main.templatedir}/stc.png); text-align: center; height:18px;
+font-weight:bold; font-style:normal; color:{$main.color3}; padding: 6px 0 0 0;">{'Preview'|@translate}</dt>
+ <dd>
+ <ul style="padding-left: 14px; font-size: 0.9em;">
+ <li><a style="color:{$main.color3}; border:0;">{'Preview'|@translate}</a></li>
+ <li>...</li>
+ </ul>
+ <p style="font-size: 0.9em;">{'Preview'|@translate}</p>
+ </dd>
+ </dl>
+ </div>
+ {* Preview content *}<div style="border:1px solid {$main.color3}; padding:0px;
+background-color:{$main.color6}; margin: 2px 2px 0 132px; color:{$main.color2}; font-size:1em; width:462px;">
+<h2 style="background-image:url({$main.templatedir}/stc.png); display:block; padding: 6px 0 0 20px;
+font-size:1em; height:18px; letter-spacing:-1px; margin:0; position:relative; text-align: left;
+font-style:normal; color:{$main.color2}; width: 442px; font-weight: normal;">{'home'|@translate}</h2>
+ <ul style="padding-left:4px; padding-right:130px;">
+ <li style="list-style:none;">
+ <div style="border:1px solid {$main.color3}; margin:3px; padding:2px 0px 0px 2px;">
+ <div style="width:114px; float:left; margin:2px 0pt 0pt 2px; text-align:left; color:{$main.color1};">
+ <a style="border:0;">
+ <img title="{'Preview'|@translate}" alt="{'Preview'|@translate}" src="{$main.templatedir}/header.jpg" style="width: 106px; height: 80px;"/>
+ </a>
+ </div>
+ <div style="height:94px; font-size:90%; overflow:hidden;">
+ <h3 style="background-image:url({$main.templatedir}/stc.png); text-align:center; height: 14px; margin-right: 0px; margin-bottom: 0px; line-height: 7px;">
+ <a style="font-size: 10px; font-style:normal; border:0;">{'Preview'|@translate}</a>
+ </h3>
+ <p style="">{'Preview'|@translate}</p>
+ <p/>
+ </div>
+ </div>
+ </li>
+ </ul>
+ </div>
+</div>
+<span style='display:block;font-style:italic;color:#777;text-align:right;margin-right:25px;'>
+{'...to get an idea of the expected result. Preview is based on yoga-like template only.'|@translate}</span>
+</fieldset> \ No newline at end of file
diff --git a/plugins/SwiftThemeCreator/themeconf.inc.tpl b/plugins/SwiftThemeCreator/themeconf.inc.tpl
index 4b1d65723..138516ef7 100644
--- a/plugins/SwiftThemeCreator/themeconf.inc.tpl
+++ b/plugins/SwiftThemeCreator/themeconf.inc.tpl
@@ -14,6 +14,12 @@ $themeconf = array(
'admin_icon_dir' => 'template/{$main.newtpl}/icon/admin',
'mime_icon_dir' => 'template/{$main.newtpl}/icon/mimetypes/',
'local_head' => '<!-- coming soon -->',
+ /* Swift Theme Creator parameters */
+ 'stc_category' => {$main.src_category},
+ 'stc_background' => '{$main.background}',
+ 'stc_background_mode' => '{$main.background_mode}',
+ 'stc_width' => '{$main.picture_width}',
+ 'stc_height' => '{$main.picture_height}',
);
if ( !isset($lang['Theme: {$main.newtheme}']) )
diff --git a/plugins/SwiftThemeCreator/titrePage-bg.png b/plugins/SwiftThemeCreator/titrePage-bg.png
index ad7a740a3..65a718024 100644
--- a/plugins/SwiftThemeCreator/titrePage-bg.png
+++ b/plugins/SwiftThemeCreator/titrePage-bg.png
Binary files differ
diff --git a/template/yoga/header.tpl b/template/yoga/header.tpl
index a7ebf22b6..dc1b6a799 100644
--- a/template/yoga/header.tpl
+++ b/template/yoga/header.tpl
@@ -67,12 +67,7 @@
{/if}
<div id="theHeader">{$PAGE_BANNER}</div>
-{if isset($pwgmenu)}
-<ul class="pwgmenu">
- <li><a href="{$pwgmenu.WIKI}" onclick="window.open(this.href, ''); return false;"><span class="bg">{'WIKI / DOC'|@translate}</span></a></li>
- <li><a href="{$pwgmenu.FORUM}" onclick="window.open(this.href, ''); return false;"><span class="bg">{'FORUM'|@translate}</span></a></li>
-</ul>
-{/if}
+{if isset($theSwiftHeader)}{$theSwiftHeader}{/if}
{if not empty($header_notes)}
<div class="header_notes">
{foreach from=$header_notes item=elt}