Changeset 2450
- Timestamp:
- Jul 22, 2008, 11:49:35 PM (16 years ago)
- Location:
- trunk/plugins/SwiftThemeCreator
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/SwiftThemeCreator/theme_creator.php
r2449 r2450 44 44 return array(hexdec($r), hexdec($g), hexdec($b)); 45 45 } 46 /* 47 * lighten returns array of x% of lighter RGB values 48 */ 49 function lighten( $r, $g, $b, $percent) 50 { 51 $r = min(round($r+(($percent*(255-$r))/100)),255); 52 $g = min(round($g+(($percent*(255-$g))/100)),255); 53 $b = min(round($b+(($percent*(255-$b))/100)),255); 54 return sprintf('#%02X%02X%02X', $r, $g, $b); 55 } 56 /* 57 * darken returns array of x% of darker RGB values 58 */ 59 function darken( $r, $g, $b, $percent) 60 { 61 $r = max(round($r-(($percent*$r)/100)),0); 62 $g = max(round($g-(($percent*$g)/100)),0); 63 $b = max(round($b-(($percent*$b)/100)),0); 64 return sprintf('#%02X%02X%02X', $r, $g, $b); 65 } 66 67 46 68 $errors = array(); 47 69 $infos = array(); … … 116 138 117 139 // 3 - Directory control 118 $ templatedir= PHPWG_ROOT_PATH . 'template/'140 $main['templatedir'] = PHPWG_ROOT_PATH . 'template/' 119 141 . $available_templates[$_POST['template']]; 120 $themedir = $templatedir . '/' . $main['newtheme']; 142 $main['newtpl'] = $available_templates[$_POST['template']]; 143 $themedir = $main['templatedir'] . '/' . $main['newtheme']; 121 144 if (is_dir( $themedir )) 122 145 array_push($errors, 123 146 '['.$themedir.'] : '.l10n('Invalid theme: This theme exists already (no override available).')); 124 elseif (!is_writable($ templatedir))125 array_push($errors, 126 '['.$ templatedir.'] : '.l10n('no_write_access'));147 elseif (!is_writable($main['templatedir'])) 148 array_push($errors, 149 '['.$main['templatedir'].'] : '.l10n('no_write_access')); 127 150 128 151 // 4 - Picture URL control … … 133 156 134 157 // 5 - Expected Width and Height limits control 135 if ( !( is_numeric($_POST['picture_width']) and ($_POST['picture_width'] < 12136 or $_POST['picture_width'] > 4096 )) )158 if ( !(ctype_digit($_POST['picture_width']) and $_POST['picture_width'] > 11 159 and $_POST['picture_width'] < 4097 ) ) 137 160 array_push($errors, 138 161 '['.$_POST['picture_width'].'] : ' 139 162 . l10n('incorrect width value [12-4096].')); 140 if ( !( is_numeric($_POST['picture_height']) and ($_POST['picture_height'] < 12141 or $_POST['picture_height'] > 200 )) )142 array_push($errors, 143 '['.$_POST['picture_ width'].'] : '144 . l10n('incorrect width value [12- 4096].'));163 if ( !(ctype_digit($_POST['picture_height']) and $_POST['picture_height'] > 11 164 and $_POST['picture_height'] < 201 ) ) 165 array_push($errors, 166 '['.$_POST['picture_height'].'] : ' 167 . l10n('incorrect width value [12-200].')); 145 168 146 169 // 6 - Generate missing colors values 170 list($r1,$g1,$b1) = stc_hex2rgb($main['color'][0]); 171 if ((( (($r1+1)/256)*(($g1+1)/256)*(($b1+1)/256) ) * 1000 ) < 125 ) 172 $main['color6'] = lighten( $r1, $g1, $b1, 10); 173 else $main['color6'] = darken( $r1, $g1, $b1, 10); 174 list($r1,$g1,$b1) = stc_hex2rgb($main['color'][4]); 175 if ((( (($r1+1)/256)*(($g1+1)/256)*(($b1+1)/256) ) * 1000 ) < 125 ) 176 $main['color7'] = lighten( $r1, $g1, $b1, 10); 177 else $main['color7'] = darken( $r1, $g1, $b1, 10); 178 179 /* en gros reste à faire: 180 * creation des différents fichiers 181 */ 182 183 // Go ahead 184 if (count($errors) == 0) { 185 umask(0000); 186 // mkdir($themedir, 0777); 187 if (!is_dir( $themedir )) 188 array_push($errors, 189 l10n('Theme directory creation failure: it can\'t be created (for now en attendant la suite 8-) ).')); 190 } 191 192 /* 193 * Build themeconf.inc.php 194 **/ 195 $plugin_tpl = new Template(); 196 $plugin_tpl->set_filenames(array('themeconf'=> 197 dirname(__FILE__) . '/themeconf.inc.tpl')); 198 $plugin_tpl->assign('main',$main); 199 $main['themeconf_inc_php'] = $plugin_tpl->parse('themeconf', true); 200 201 // Smarty trace 202 $plugin_tpl->assign('main',$main); 203 204 // Interesting Graphic Charter 205 // http://accessites.org/site/2006/08/visual-vs-structural/ 147 206 148 207 /* … … 170 229 imagedestroy ($dest); 171 230 } 172 /* en gros reste à faire: 173 * creation de la directory 174 * creation des différents fichiers 175 * parse pour theme.css et ecriture directe pour les autres 176 */ 177 // Lors du parse si le second arg est à true, on récupère le résultat 178 // http://www.barelyfitz.com/projects/csscolor/csscolor.zip 179 180 // Go ahead 181 if (count($errors) == 0) { 182 umask(0000); 183 // mkdir($themedir, 0777); 184 if (!is_dir( $themedir )) 185 array_push($errors, 186 l10n('Theme directory creation failure: it can\'t be created (for now en attendant la suite 8-) ).')); 187 } 231 232 233 188 234 $swift_theme_creator->save_theme_config(); 189 235 }
Note: See TracChangeset
for help on using the changeset viewer.