Changeset 2454
- Timestamp:
- Jul 23, 2008, 11:53:15 PM (16 years ago)
- Location:
- trunk/plugins/SwiftThemeCreator
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/SwiftThemeCreator/mail-css.tpl2
r2453 r2454 1 1 /* Theme {$main.newtheme} mail css */ 2 2 3 body {$main.ldelim} background-color:{$main.colo ur1}; color:{$main.colour2};}4 #the_page {$main.ldelim} background: {$main.colo ur1} url({ldelim}$ROOT_URL}template/{ldelim}$themeconf.template}/mail/text/html/images/mailbody-bg.png) repeat-y scroll left top;}3 body {$main.ldelim} background-color:{$main.color1}; color:{$main.color2};} 4 #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;} 5 5 #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;} 6 6 #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; 7 color: {$main.colo ur2};}8 h2 {$main.ldelim} background-color: {$main.colo ur7};color:#eee;background-image: url({ldelim}$ROOT_URL}template/{ldelim}$themeconf.template}/theme/{ldelim}$themeconf.theme}/images/tableh1_bg.png);}7 color: {$main.color2};} 8 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);} 9 9 img {$main.ldelim} margin: 16px; padding:15px;border:1px solid #eee; -moz-border-radius: 4px; border-radius: 4px 4px; } 10 img:hover {$main.ldelim} border:1px solid {$main.colo ur2}; -moz-border-radius: 4px; border-radius: 4px 4px; }11 a {$main.ldelim} color: {$main.colo ur2}; background: transparent; }12 a:hover {$main.ldelim} color: {$main.colo ur3}; }10 img:hover {$main.ldelim} border:1px solid {$main.color2}; -moz-border-radius: 4px; border-radius: 4px 4px; } 11 a {$main.ldelim} color: {$main.color2}; background: transparent; } 12 a:hover {$main.ldelim} color: {$main.color3}; } 13 13 a.PWG {$main.ldelim} border: 0px; } 14 a.PWG .P {$main.ldelim} color : {$main.colo ur3}; }15 a.PWG .W {$main.ldelim} color : {$main.colo ur5}; }16 a.PWG .G {$main.ldelim} color : {$main.colo ur2}; }17 a.PWG:hover .P {$main.ldelim} color : {$main.colo ur2}; }18 a.PWG:hover .G {$main.ldelim} color : {$main.colo ur3}; }14 a.PWG .P {$main.ldelim} color : {$main.color3}; } 15 a.PWG .W {$main.ldelim} color : {$main.color5}; } 16 a.PWG .G {$main.ldelim} color : {$main.color2}; } 17 a.PWG:hover .P {$main.ldelim} color : {$main.color2}; } 18 a.PWG:hover .G {$main.ldelim} color : {$main.color3}; } -
trunk/plugins/SwiftThemeCreator/theme_creator.php
r2453 r2454 64 64 return sprintf('#%02X%02X%02X', $r, $g, $b); 65 65 } 66 66 /* 67 * stc_newfile create a new file 68 */ 69 function stc_newfile( $filename, $data ) 70 { 71 $fp = fopen($filename, 'w'); 72 if ($fp) 73 { 74 $ret = fwrite($fp, $data); 75 fclose($fp); 76 return $ret; 77 } 78 return false; 79 } 67 80 68 81 $errors = array(); … … 105 118 list($r1,$g1,$b1) = stc_hex2rgb($main['color'][0]); 106 119 list($r2,$g2,$b2) = stc_hex2rgb($main['color'][1]); 107 // Formula for converting RGB values to YIQ values as perceived brightness difference. 120 // Formula for converting RGB values to YIQ values 121 // as perceived brightness difference. 108 122 // Background and text "brightness" difference control: 109 123 $dif = abs( ( (($r1*299)+($g1*587)+($b1*114)) / 1000 ) 110 124 - ( (($r2*299)+($g2*587)+($b2*114)) / 1000 )); 111 if ( $dif < 125 )125 if ( $dif < 65 ) 112 126 array_push($errors, 113 l10n('Insufficient brightness difference between text and background. dif=') . $dif); 127 l10n('Insufficient brightness difference between ' 128 . 'text and background. dif=') . $dif); 114 129 // Background and text "colour" difference control: 115 130 $dif = (max($r1, $r2) - min($r1, $r2)) … … 118 133 if ( $dif < 200 ) 119 134 array_push($errors, 120 l10n('Insufficient colour difference between text and background. dif=') . $dif); 135 l10n('Insufficient colour difference between ' 136 . 'text and background. dif=') . $dif); 121 137 122 138 // 2.2 - Background and Internal links control … … 126 142 $dif = abs( ( (($r1*299)+($g1*587)+($b1*114)) / 1000 ) 127 143 - ( (($r2*299)+($g2*587)+($b2*114)) / 1000 )); 128 if ( $dif < 125 )144 if ( $dif < 65 ) 129 145 array_push($errors, 130 l10n('Insufficient brightness difference between Internal links and background. dif=') . $dif); 146 l10n('Insufficient brightness difference between ' 147 . 'Internal links and background. dif=') . $dif); 131 148 // Background and Internal links "colour" difference control: 132 149 $dif = (max($r1, $r2) - min($r1, $r2)) … … 135 152 if ( $dif < 200 ) 136 153 array_push($errors, 137 l10n('Insufficient colour difference between Internal links and background. dif=') . $dif); 154 l10n('Insufficient colour difference between ' 155 . 'Internal links and background. dif=') . $dif); 138 156 139 157 // 3 - Directory control … … 141 159 . $available_templates[$_POST['template']]; 142 160 $main['newtpl'] = $available_templates[$_POST['template']]; 143 $themedir = $main['templatedir'] . '/ ' . $main['newtheme'];161 $themedir = $main['templatedir'] . '/theme/' . $main['newtheme']; 144 162 if (is_dir( $themedir )) 145 163 array_push($errors, 146 '['.$themedir.'] : '.l10n('Invalid theme: This theme exists already (no override available).')); 164 '['.$themedir.'] : '.l10n('Invalid theme: This theme exists ' 165 . 'already (no override available).')); 147 166 elseif (!is_writable($main['templatedir'])) 148 167 array_push($errors, … … 180 199 if (count($errors) == 0) { 181 200 umask(0000); 182 //mkdir($themedir, 0777);201 mkdir($themedir, 0777); 183 202 if (!is_dir( $themedir )) 184 203 array_push($errors, 185 l10n('Theme directory creation failure: it can\'t be created (for now en attendant la suite 8-) ).')); 204 l10n('Theme directory creation failure: ' 205 . 'it can\'t be created (for now en attendant la suite 8-) ).')); 206 else { 207 $main['ldelim'] = '{ldelim}'; 208 /* 209 * Build themeconf.inc.php 210 **/ 211 $plugin_tpl = new Template(); 212 $plugin_tpl->set_filenames(array('themeconf'=> 213 dirname(__FILE__) . '/themeconf.inc.tpl')); 214 $plugin_tpl->assign('main',$main); 215 $main['themeconf_inc_php'] = $plugin_tpl->parse('themeconf', true); 216 $r = stc_newfile( $themedir . '/themeconf.inc.php', 217 $main['themeconf_inc_php'] ); 218 /* 219 * Build mail-css.tpl 220 **/ 221 $plugin_tpl->set_filenames(array('mailcss'=> 222 dirname(__FILE__) . '/mail-css.tpl2')); 223 $plugin_tpl->assign('main',$main); 224 $main['mail-css.tpl'] = $plugin_tpl->parse('mailcss', true); 225 $r = $r && stc_newfile( $themedir . '/mail-css.tpl', 226 $main['mail-css.tpl'] ); 227 /* 228 * Build theme.css 229 **/ 230 $plugin_tpl->set_filenames(array('theme'=> 231 dirname(__FILE__) . '/theme.tpl')); 232 $plugin_tpl->assign('main',$main); 233 $main['theme.css'] = $plugin_tpl->parse('theme', true); 234 $r = $r && stc_newfile( $themedir . '/theme.css', 235 $main['theme.css'] ); 236 /* 237 * Build background image for titrePage or definition list (in #menubar) 238 **/ 239 if (function_exists('imagecreatefrompng')) 240 { 241 $img = imagecreatefrompng(dirname(__FILE__) . '/titrePage-bg.png'); 242 $dest = imagecreate(1, 64); 243 for ($i=0; $i<256; $i++) { 244 imagecolorallocate($dest, $i, $i, $i); 245 } 246 imagecopy($dest, $img, 0, 0, 0, 0, 1, 64); 247 list($r1,$g1,$b1) = stc_hex2rgb($main['color'][4]); 248 for ($i = 0; $i < 256; $i++) { 249 imagecolorset($dest, $i, min(floor($i * $r1 / 255), 255), 250 min(floor($i * $g1 / 255), 255), 251 min(floor($i * $b1 / 255), 255)); 252 } 253 // to be tested imagecopymerge($dest,$img,0,0,0,0,1,64,33); 254 imagepng( $dest, $themedir . '/stc.png', 9 ); 255 imagedestroy ($img); 256 imagedestroy ($dest); 257 } 258 else @copy( dirname(__FILE__) 259 . '/titrePage-bg.png', $themedir . '/stc.png'); 260 if ($r == false) { 261 array_push($errors, 262 l10n('Theme files creation failure: theme should be deleted.')); 263 @unlink( $themedir . '/stc.png' ); 264 @unlink( $themedir . '/themeconf.inc.php' ); 265 @unlink( $themedir . '/mail-css.tpl' ); 266 @unlink( $themedir . '/theme.css' ); 267 @rmdir( $themedir ); 268 } 269 else { 270 array_push($infos, 271 '['.$main['newtpl'] . '/' . $main['newtheme'].'] : ' 272 .l10n('Congratulation! You have got(/ten) a new available theme.')); 273 } 274 } 186 275 } 187 188 $main['ldelim'] = '{ldelim}';189 /*190 * Build themeconf.inc.php191 **/192 $plugin_tpl = new Template();193 $plugin_tpl->set_filenames(array('themeconf'=>194 dirname(__FILE__) . '/themeconf.inc.tpl'));195 $plugin_tpl->assign('main',$main);196 $main['themeconf_inc_php'] = $plugin_tpl->parse('themeconf', true);197 /*198 * Build mail-css.tpl199 **/200 $plugin_tpl->set_filenames(array('mailcss'=>201 dirname(__FILE__) . '/mail-css.tpl2'));202 $plugin_tpl->assign('main',$main);203 $main['mail-css.tpl'] = $plugin_tpl->parse('mailcss', true);204 205 // Smarty trace206 $plugin_tpl->assign('main',$main);207 276 208 277 // Interesting Graphic Charter 209 278 // http://accessites.org/site/2006/08/visual-vs-structural/ 210 279 211 /*212 * Build background image for titrePage or definition list (in #menubar)213 **/214 if (function_exists('imagecreatefrompng'))215 {216 $img = imagecreatefrompng(dirname(__FILE__) . '/titrePage-bg.png');217 $dest = imagecreate(1, 64);218 for ($i=0; $i<256; $i++) {219 imagecolorallocate($dest, $i, $i, $i);220 }221 imagecopy($dest, $img, 0, 0, 0, 0, 1, 64);222 list($r1,$g1,$b1) = stc_hex2rgb($main['color'][4]);223 for ($i = 0; $i < 256; $i++) {224 imagecolorset($dest, $i, min($i * $r1 / 255, 255),225 min($i * $g1 / 255, 255),226 min($i * $b1 / 255, 255));227 }228 // to be tested imagecopymerge($dest,$img,0,0,0,0,1,64,33);229 230 // Uncomment to create the header stc.png231 // imagepng( $dest, dirname(__FILE__) . '/stc.png', 9 );232 imagedestroy ($img);233 imagedestroy ($dest);234 }235 236 237 /* All logic is there238 * On "todo" : Create files and uncomment some previous statements.239 */240 241 242 280 $swift_theme_creator->save_theme_config(); 243 281 } … … 257 295 'plugin_admin_content' => dirname(__FILE__) . '/theme_creator.tpl')); 258 296 $template->append('head_elements', 259 '<script type="text/javascript" src="./plugins/SwiftThemeCreator/farbtastic/farbtastic.js"></script> 260 <link rel="stylesheet" href="./plugins/SwiftThemeCreator/farbtastic/farbtastic.css" type="text/css" /> 297 '<script type="text/javascript" 298 src="./plugins/SwiftThemeCreator/farbtastic/farbtastic.js"></script> 299 <link rel="stylesheet" type="text/css" 300 href="./plugins/SwiftThemeCreator/farbtastic/farbtastic.css" /> 261 301 <style type="text/css" media="screen"> 262 .colorwell { border: 3px double #F30; width: 6em; text-align: center; cursor: pointer; } 302 .colorwell { border: 3px double #F30; width: 6em; 303 text-align: center; cursor: pointer; } 263 304 body .colorwell-selected { border: 3px double #F36; font-weight: bold; } 264 305 .radio { margin: 0 10px 0 50px; } … … 307 348 if (isset($_POST['picture_url'])) $main['picture_url'] = $_POST['picture_url']; 308 349 309 if (isset($_POST['picture_width'])) $main['picture_width'] = $_POST['picture_width']; 350 if (isset($_POST['picture_width'])) 351 $main['picture_width'] = $_POST['picture_width']; 310 352 if (!isset($main['picture_width'])) $main['picture_width'] = 2048; 311 if (isset($_POST['picture_height'])) $main['picture_height'] = $_POST['picture_height']; 353 if (isset($_POST['picture_height'])) 354 $main['picture_height'] = $_POST['picture_height']; 312 355 if (!isset($main['picture_height'])) $main['picture_height'] = 100; 313 356 … … 322 365 )); 323 366 if (count($errors) != 0) $template->assign('errors', $errors); 367 if (count($infos) != 0) $template->assign('infos', $infos); 324 368 /* Restore Main values */ 325 369 $template->assign('main', $main);
Note: See TracChangeset
for help on using the changeset viewer.