diff options
author | vdigital <vdigital@piwigo.org> | 2008-07-23 21:53:15 +0000 |
---|---|---|
committer | vdigital <vdigital@piwigo.org> | 2008-07-23 21:53:15 +0000 |
commit | c48ec88ed478dc14f846efeb47091d389d09c3c0 (patch) | |
tree | f2cd0fbb9c4bc463c5456a0dde9a3a55bc519576 /plugins | |
parent | 49f337a9d8964f8ecd3c8c5eb75601ba9635df13 (diff) |
Swift Theme Creator (minor changes): Still incomplete but first functional version (5).
git-svn-id: http://piwigo.org/svn/trunk@2454 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/SwiftThemeCreator/mail-css.tpl2 | 24 | ||||
-rw-r--r-- | plugins/SwiftThemeCreator/theme.tpl | 36 | ||||
-rw-r--r-- | plugins/SwiftThemeCreator/theme_creator.php | 182 |
3 files changed, 161 insertions, 81 deletions
diff --git a/plugins/SwiftThemeCreator/mail-css.tpl2 b/plugins/SwiftThemeCreator/mail-css.tpl2 index 6bb63509c..ee9d1a836 100644 --- a/plugins/SwiftThemeCreator/mail-css.tpl2 +++ b/plugins/SwiftThemeCreator/mail-css.tpl2 @@ -1,18 +1,18 @@ /* Theme {$main.newtheme} mail css */ -body {$main.ldelim} background-color:{$main.colour1}; color:{$main.colour2};} -#the_page {$main.ldelim} background: {$main.colour1} url({ldelim}$ROOT_URL}template/{ldelim}$themeconf.template}/mail/text/html/images/mailbody-bg.png) repeat-y scroll left top;} +body {$main.ldelim} background-color:{$main.color1}; color:{$main.color2};} +#the_page {$main.ldelim} background: {$main.color1} url({ldelim}$ROOT_URL}template/{ldelim}$themeconf.template}/mail/text/html/images/mailbody-bg.png) repeat-y scroll left top;} #content {$main.ldelim} background: transparent url({ldelim}$ROOT_URL}template/{ldelim}$themeconf.template}/mail/text/html/images/header-bg.png) no-repeat scroll left top;} #copyright {$main.ldelim} background: transparent url({ldelim}$ROOT_URL}template/{ldelim}$themeconf.template}/mail/text/html/images/footer-bg.png) no-repeat scroll left bottom; -color: {$main.colour2};} -h2 {$main.ldelim} background-color: {$main.colour7};color:#eee;background-image: url({ldelim}$ROOT_URL}template/{ldelim}$themeconf.template}/theme/{ldelim}$themeconf.theme}/images/tableh1_bg.png);} +color: {$main.color2};} +h2 {$main.ldelim} background-color: {$main.color7};color:#eee;background-image: url({ldelim}$ROOT_URL}template/{ldelim}$themeconf.template}/theme/{ldelim}$themeconf.theme}/images/tableh1_bg.png);} img {$main.ldelim} margin: 16px; padding:15px;border:1px solid #eee; -moz-border-radius: 4px; border-radius: 4px 4px; } -img:hover {$main.ldelim} border:1px solid {$main.colour2}; -moz-border-radius: 4px; border-radius: 4px 4px; } -a {$main.ldelim} color: {$main.colour2}; background: transparent; } -a:hover {$main.ldelim} color: {$main.colour3}; } +img:hover {$main.ldelim} border:1px solid {$main.color2}; -moz-border-radius: 4px; border-radius: 4px 4px; } +a {$main.ldelim} color: {$main.color2}; background: transparent; } +a:hover {$main.ldelim} color: {$main.color3}; } a.PWG {$main.ldelim} border: 0px; } -a.PWG .P {$main.ldelim} color : {$main.colour3}; } -a.PWG .W {$main.ldelim} color : {$main.colour5}; } -a.PWG .G {$main.ldelim} color : {$main.colour2}; } -a.PWG:hover .P {$main.ldelim} color : {$main.colour2}; } -a.PWG:hover .G {$main.ldelim} color : {$main.colour3}; } +a.PWG .P {$main.ldelim} color : {$main.color3}; } +a.PWG .W {$main.ldelim} color : {$main.color5}; } +a.PWG .G {$main.ldelim} color : {$main.color2}; } +a.PWG:hover .P {$main.ldelim} color : {$main.color2}; } +a.PWG:hover .G {$main.ldelim} color : {$main.color3}; }
\ No newline at end of file diff --git a/plugins/SwiftThemeCreator/theme.tpl b/plugins/SwiftThemeCreator/theme.tpl new file mode 100644 index 000000000..05f8a8a03 --- /dev/null +++ b/plugins/SwiftThemeCreator/theme.tpl @@ -0,0 +1,36 @@ +BODY, H3, #imageHeaderBar, #imageToolBar A:hover, +.row1, UL.tabsheet LI.normal_tab {ldelim} background-color: {$main.color1}; } + +BODY, H1, H3, DT, +INPUT.rateButtonSelected /* <= why IE doesn't inherit this ? */ {ldelim} + color:{$main.color2}; } +#theImage IMG {ldelim} border-color: {$main.color2}; } + +H2, #menubar DT, .throw, +A, INPUT.rateButton {ldelim} color: {$main.color3}; } + +UL.tabsheet LI.normal_tab:hover {ldelim} border-color: {$main.color4}; } +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-color: {$main.color5}; background-color: {$main.color6}; } + +#menubar DL, .content, #comments DIV.comment BLOCKQUOTE, +#imageHeaderBar, H2, #menubar DT, #imageToolBar {ldelim} border-color: {$main.color5}; } + +#menubar DL, .content, #imageToolBar, .header_notes, UL.tabsheet LI.selected_tab {ldelim} + background-color: {$main.color6}; } + +FIELDSET, INPUT, SELECT, TEXTAREA, .content DIV.comment A.illustration IMG, +.content DIV.thumbnailCategory, .content UL.thumbnails SPAN.wrap2 {ldelim} + border-color: {$main.color6}; } + +#comments DIV.comment BLOCKQUOTE {ldelim} border-color: {$main.color7}; } + +H2, #menubar DT, .throw {ldelim} background-image: url(stc.png); } +#imageHeaderBar H2 {ldelim} background-image: none; background-color: transparent; border: none; } + +#imageHeaderBar {ldelim} + background: transparent url(stc.png) scroll repeat-x center top; }
\ No newline at end of file diff --git a/plugins/SwiftThemeCreator/theme_creator.php b/plugins/SwiftThemeCreator/theme_creator.php index 1c9f0d9df..7bac595ef 100644 --- a/plugins/SwiftThemeCreator/theme_creator.php +++ b/plugins/SwiftThemeCreator/theme_creator.php @@ -63,7 +63,20 @@ function darken( $r, $g, $b, $percent) $b = max(round($b-(($percent*$b)/100)),0); return sprintf('#%02X%02X%02X', $r, $g, $b); } - +/* + * stc_newfile create a new file + */ +function stc_newfile( $filename, $data ) +{ + $fp = fopen($filename, 'w'); + if ($fp) + { + $ret = fwrite($fp, $data); + fclose($fp); + return $ret; + } + return false; +} $errors = array(); $infos = array(); @@ -104,20 +117,23 @@ if (isset($_POST['submit']) and (!is_adviser())) // 2.1 - Background and text control list($r1,$g1,$b1) = 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. + // 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 )); - if ( $dif < 125 ) + if ( $dif < 65 ) array_push($errors, - l10n('Insufficient brightness difference between text and background. dif=') . $dif); + 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)); if ( $dif < 200 ) array_push($errors, - l10n('Insufficient colour difference between text and background. dif=') . $dif); + l10n('Insufficient colour difference between ' + . 'text and background. dif=') . $dif); // 2.2 - Background and Internal links control list($r1,$g1,$b1) = stc_hex2rgb($main['color'][0]); @@ -125,25 +141,28 @@ if (isset($_POST['submit']) and (!is_adviser())) // Background and Internal links "brightness" difference control: $dif = abs( ( (($r1*299)+($g1*587)+($b1*114)) / 1000 ) - ( (($r2*299)+($g2*587)+($b2*114)) / 1000 )); - if ( $dif < 125 ) + if ( $dif < 65 ) array_push($errors, - l10n('Insufficient brightness difference between Internal links and background. dif=') . $dif); + 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)); if ( $dif < 200 ) array_push($errors, - l10n('Insufficient colour difference between Internal links and background. dif=') . $dif); + 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'] . '/' . $main['newtheme']; + $themedir = $main['templatedir'] . '/theme/' . $main['newtheme']; if (is_dir( $themedir )) array_push($errors, - '['.$themedir.'] : '.l10n('Invalid theme: This theme exists already (no override available).')); + '['.$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')); @@ -179,66 +198,85 @@ if (isset($_POST['submit']) and (!is_adviser())) // Go ahead if (count($errors) == 0) { umask(0000); - // mkdir($themedir, 0777); + mkdir($themedir, 0777); if (!is_dir( $themedir )) array_push($errors, - l10n('Theme directory creation failure: it can\'t be created (for now en attendant la suite 8-) ).')); + l10n('Theme directory creation failure: ' + . 'it can\'t be created (for now en attendant la suite 8-) ).')); + else { + $main['ldelim'] = '{ldelim}'; + /* + * Build themeconf.inc.php + **/ + $plugin_tpl = new Template(); + $plugin_tpl->set_filenames(array('themeconf'=> + dirname(__FILE__) . '/themeconf.inc.tpl')); + $plugin_tpl->assign('main',$main); + $main['themeconf_inc_php'] = $plugin_tpl->parse('themeconf', true); + $r = stc_newfile( $themedir . '/themeconf.inc.php', + $main['themeconf_inc_php'] ); + /* + * Build mail-css.tpl + **/ + $plugin_tpl->set_filenames(array('mailcss'=> + dirname(__FILE__) . '/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', + $main['mail-css.tpl'] ); + /* + * Build theme.css + **/ + $plugin_tpl->set_filenames(array('theme'=> + dirname(__FILE__) . '/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'] ); + /* + * Build background image for titrePage or definition list (in #menubar) + **/ + if (function_exists('imagecreatefrompng')) + { + $img = imagecreatefrompng(dirname(__FILE__) . '/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 ); + imagedestroy ($img); + imagedestroy ($dest); + } + else @copy( dirname(__FILE__) + . '/titrePage-bg.png', $themedir . '/stc.png'); + if ($r == 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 ); + } + else { + array_push($infos, + '['.$main['newtpl'] . '/' . $main['newtheme'].'] : ' + .l10n('Congratulation! You have got(/ten) a new available theme.')); + } + } } - - $main['ldelim'] = '{ldelim}'; - /* - * Build themeconf.inc.php - **/ - $plugin_tpl = new Template(); - $plugin_tpl->set_filenames(array('themeconf'=> - dirname(__FILE__) . '/themeconf.inc.tpl')); - $plugin_tpl->assign('main',$main); - $main['themeconf_inc_php'] = $plugin_tpl->parse('themeconf', true); - /* - * Build mail-css.tpl - **/ - $plugin_tpl->set_filenames(array('mailcss'=> - dirname(__FILE__) . '/mail-css.tpl2')); - $plugin_tpl->assign('main',$main); - $main['mail-css.tpl'] = $plugin_tpl->parse('mailcss', true); - - // Smarty trace - $plugin_tpl->assign('main',$main); // Interesting Graphic Charter // http://accessites.org/site/2006/08/visual-vs-structural/ - /* - * Build background image for titrePage or definition list (in #menubar) - **/ - if (function_exists('imagecreatefrompng')) - { - $img = imagecreatefrompng(dirname(__FILE__) . '/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($i * $r1 / 255, 255), - min($i * $g1 / 255, 255), - min($i * $b1 / 255, 255)); - } - // to be tested imagecopymerge($dest,$img,0,0,0,0,1,64,33); - - // Uncomment to create the header stc.png - // imagepng( $dest, dirname(__FILE__) . '/stc.png', 9 ); - imagedestroy ($img); - imagedestroy ($dest); - } - - - /* All logic is there - * On "todo" : Create files and uncomment some previous statements. - */ - - $swift_theme_creator->save_theme_config(); } @@ -256,10 +294,13 @@ if (isset($_POST['submit']) and (!is_adviser())) $template->set_filenames(array( 'plugin_admin_content' => dirname(__FILE__) . '/theme_creator.tpl')); $template->append('head_elements', - '<script type="text/javascript" src="./plugins/SwiftThemeCreator/farbtastic/farbtastic.js"></script> -<link rel="stylesheet" href="./plugins/SwiftThemeCreator/farbtastic/farbtastic.css" type="text/css" /> + '<script type="text/javascript" + src="./plugins/SwiftThemeCreator/farbtastic/farbtastic.js"></script> +<link rel="stylesheet" type="text/css" + href="./plugins/SwiftThemeCreator/farbtastic/farbtastic.css" /> <style type="text/css" media="screen"> -.colorwell { border: 3px double #F30; width: 6em; text-align: center; cursor: pointer; } +.colorwell { border: 3px double #F30; width: 6em; + text-align: center; cursor: pointer; } body .colorwell-selected { border: 3px double #F36; font-weight: bold; } .radio { margin: 0 10px 0 50px; } </style>' @@ -306,9 +347,11 @@ if (isset($swift_theme_creator->picture_url)) $main['picture_url'] = $swift_theme_creator->picture_url; if (isset($_POST['picture_url'])) $main['picture_url'] = $_POST['picture_url']; -if (isset($_POST['picture_width'])) $main['picture_width'] = $_POST['picture_width']; +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($_POST['picture_height'])) + $main['picture_height'] = $_POST['picture_height']; if (!isset($main['picture_height'])) $main['picture_height'] = 100; if (isset($_POST['background_mode'])) @@ -321,9 +364,10 @@ $template->assign('background_mode_options', 'sized' => l10n('Resized'), )); if (count($errors) != 0) $template->assign('errors', $errors); +if (count($infos) != 0) $template->assign('infos', $infos); /* Restore Main values */ $template->assign('main', $main); $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); $swift_theme_creator->theme_config = $main; $swift_theme_creator->save_theme_config(); -?> +?>
\ No newline at end of file |