1 | <?php |
---|
2 | /** |
---|
3 | * @brief blowupConfig, a plugin for Dotclear 2 |
---|
4 | * |
---|
5 | * @package Dotclear |
---|
6 | * @subpackage Plugins |
---|
7 | * |
---|
8 | * @copyright Olivier Meunier & Association Dotclear |
---|
9 | * @copyright GPL-2.0-only |
---|
10 | */ |
---|
11 | |
---|
12 | if (!defined('DC_RC_PATH')) {return;} |
---|
13 | |
---|
14 | class blowupConfig |
---|
15 | { |
---|
16 | protected static $css_folder = 'blowup-css'; |
---|
17 | protected static $img_folder = 'blowup-images'; |
---|
18 | |
---|
19 | protected static $fonts = [ |
---|
20 | 'sans-serif' => [ |
---|
21 | 'ss1' => 'Arial, Helvetica, sans-serif', |
---|
22 | 'ss2' => 'Verdana,Geneva, Arial, Helvetica, sans-serif', |
---|
23 | 'ss3' => '"Lucida Grande", "Lucida Sans Unicode", sans-serif', |
---|
24 | 'ss4' => '"Trebuchet MS", Helvetica, sans-serif', |
---|
25 | 'ss5' => 'Impact, Charcoal, sans-serif' |
---|
26 | ], |
---|
27 | |
---|
28 | 'serif' => [ |
---|
29 | 's1' => 'Times, "Times New Roman", serif', |
---|
30 | 's2' => 'Georgia, serif', |
---|
31 | 's3' => 'Baskerville, "Palatino Linotype", serif' |
---|
32 | ], |
---|
33 | |
---|
34 | 'monospace' => [ |
---|
35 | 'm1' => '"Andale Mono", "Courier New", monospace', |
---|
36 | 'm2' => '"Courier New", Courier, mono, monospace' |
---|
37 | ] |
---|
38 | ]; |
---|
39 | |
---|
40 | protected static $fonts_combo = []; |
---|
41 | protected static $fonts_list = []; |
---|
42 | |
---|
43 | public static $top_images = [ |
---|
44 | 'default' => 'Default', |
---|
45 | 'blank' => 'Blank', |
---|
46 | 'light-trails-1' => 'Light Trails 1', |
---|
47 | 'light-trails-2' => 'Light Trails 2', |
---|
48 | 'light-trails-3' => 'Light Trails 3', |
---|
49 | 'light-trails-4' => 'Light Trails 4', |
---|
50 | 'butterflies' => 'Butterflies', |
---|
51 | 'flourish-1' => 'Flourished 1', |
---|
52 | 'flourish-2' => 'Flourished 2', |
---|
53 | 'animals' => 'Animals', |
---|
54 | 'plumetis' => 'Plumetis', |
---|
55 | 'flamingo' => 'Flamingo', |
---|
56 | 'rabbit' => 'Rabbit', |
---|
57 | 'roadrunner-1' => 'Road Runner 1', |
---|
58 | 'roadrunner-2' => 'Road Runner 2', |
---|
59 | 'typo' => 'Typo' |
---|
60 | ]; |
---|
61 | |
---|
62 | public static function fontsList() |
---|
63 | { |
---|
64 | if (empty(self::$fonts_combo)) { |
---|
65 | self::$fonts_combo[__('default')] = ''; |
---|
66 | foreach (self::$fonts as $family => $g) { |
---|
67 | $fonts = []; |
---|
68 | foreach ($g as $code => $font) { |
---|
69 | $fonts[str_replace('"', '', $font)] = $code; |
---|
70 | } |
---|
71 | self::$fonts_combo[$family] = $fonts; |
---|
72 | } |
---|
73 | } |
---|
74 | |
---|
75 | return self::$fonts_combo; |
---|
76 | } |
---|
77 | |
---|
78 | public static function fontDef($c) |
---|
79 | { |
---|
80 | if (empty(self::$fonts_list)) { |
---|
81 | foreach (self::$fonts as $family => $g) { |
---|
82 | foreach ($g as $code => $font) { |
---|
83 | self::$fonts_list[$code] = $font; |
---|
84 | } |
---|
85 | } |
---|
86 | } |
---|
87 | |
---|
88 | return isset(self::$fonts_list[$c]) ? self::$fonts_list[$c] : null; |
---|
89 | } |
---|
90 | |
---|
91 | public static function cssPath() |
---|
92 | { |
---|
93 | return dcThemeConfig::cssPath(self::$css_folder); |
---|
94 | } |
---|
95 | |
---|
96 | public static function cssURL() |
---|
97 | { |
---|
98 | return dcThemeConfig::cssURL(self::$css_folder); |
---|
99 | } |
---|
100 | |
---|
101 | public static function canWriteCss($create = false) |
---|
102 | { |
---|
103 | return dcThemeConfig::canWriteCss(self::$css_folder, $create); |
---|
104 | } |
---|
105 | |
---|
106 | protected static function backgroundImg(&$css, $selector, $value, $image) |
---|
107 | { |
---|
108 | dcThemeConfig::backgroundImg(self::$img_folder, $css, $selector, $value, $image); |
---|
109 | } |
---|
110 | |
---|
111 | private static function writeCss($theme, $css) |
---|
112 | { |
---|
113 | dcThemeConfig::writeCSS(self::$css_folder, $theme, $css); |
---|
114 | } |
---|
115 | |
---|
116 | public static function dropCss($theme) |
---|
117 | { |
---|
118 | dcThemeConfig::dropCss(self::$css_folder, $theme); |
---|
119 | } |
---|
120 | |
---|
121 | public static function publicCssUrlHelper() |
---|
122 | { |
---|
123 | return dcThemeConfig::publicCssUrlHelper(self::$css_folder); |
---|
124 | } |
---|
125 | |
---|
126 | public static function imagesPath() |
---|
127 | { |
---|
128 | return dcThemeConfig::imagesPath(self::$img_folder); |
---|
129 | } |
---|
130 | |
---|
131 | public static function imagesURL() |
---|
132 | { |
---|
133 | return dcThemeConfig::imagesURL(self::$img_folder); |
---|
134 | } |
---|
135 | |
---|
136 | public static function canWriteImages($create = false) |
---|
137 | { |
---|
138 | return dcThemeConfig::canWriteImages(self::$img_folder, $create); |
---|
139 | } |
---|
140 | |
---|
141 | public static function uploadImage($f) |
---|
142 | { |
---|
143 | return dcThemeConfig::uploadImage(self::$img_folder, $f, 800); |
---|
144 | } |
---|
145 | |
---|
146 | public static function dropImage($img) |
---|
147 | { |
---|
148 | dcThemeConfig::dropImage(self::$img_folder, $img); |
---|
149 | } |
---|
150 | |
---|
151 | public static function createCss($s) |
---|
152 | { |
---|
153 | global $core; |
---|
154 | |
---|
155 | if ($s === null) { |
---|
156 | return; |
---|
157 | } |
---|
158 | |
---|
159 | $css = []; |
---|
160 | |
---|
161 | /* Sidebar position |
---|
162 | ---------------------------------------------- */ |
---|
163 | if ($s['sidebar_position'] == 'left') { |
---|
164 | $css['#wrapper']['background-position'] = '-300px 0'; |
---|
165 | $css['#main']['float'] = 'right'; |
---|
166 | $css['#sidebar']['float'] = 'left'; |
---|
167 | } |
---|
168 | |
---|
169 | /* Properties |
---|
170 | ---------------------------------------------- */ |
---|
171 | dcThemeConfig::prop($css, 'body', 'background-color', $s['body_bg_c']); |
---|
172 | |
---|
173 | dcThemeConfig::prop($css, 'body', 'color', $s['body_txt_c']); |
---|
174 | dcThemeConfig::prop($css, '.post-tags li a:link, .post-tags li a:visited, .post-info-co a:link, .post-info-co a:visited', 'color', $s['body_txt_c']); |
---|
175 | dcThemeConfig::prop($css, '#page', 'font-size', $s['body_txt_s']); |
---|
176 | dcThemeConfig::prop($css, 'body', 'font-family', self::fontDef($s['body_txt_f'])); |
---|
177 | |
---|
178 | dcThemeConfig::prop($css, '.post-content, .post-excerpt, #comments dd, #pings dd, dd.comment-preview', 'line-height', $s['body_line_height']); |
---|
179 | |
---|
180 | if (!$s['blog_title_hide']) { |
---|
181 | dcThemeConfig::prop($css, '#top h1 a', 'color', $s['blog_title_c']); |
---|
182 | dcThemeConfig::prop($css, '#top h1', 'font-size', $s['blog_title_s']); |
---|
183 | dcThemeConfig::prop($css, '#top h1', 'font-family', self::fontDef($s['blog_title_f'])); |
---|
184 | |
---|
185 | if ($s['blog_title_a'] == 'right' || $s['blog_title_a'] == 'left') { |
---|
186 | $css['#top h1'][$s['blog_title_a']] = '0px'; |
---|
187 | $css['#top h1']['width'] = 'auto'; |
---|
188 | } |
---|
189 | |
---|
190 | if ($s['blog_title_p']) { |
---|
191 | $_p = explode(':', $s['blog_title_p']); |
---|
192 | $css['#top h1']['top'] = $_p[1] . 'px'; |
---|
193 | if ($s['blog_title_a'] != 'center') { |
---|
194 | $_a = $s['blog_title_a'] == 'right' ? 'right' : 'left'; |
---|
195 | $css['#top h1'][$_a] = $_p[0] . 'px'; |
---|
196 | } |
---|
197 | } |
---|
198 | } else { |
---|
199 | dcThemeConfig::prop($css, '#top h1 span', 'text-indent', '-5000px'); |
---|
200 | dcThemeConfig::prop($css, '#top h1', 'top', '0px'); |
---|
201 | $css['#top h1 a'] = [ |
---|
202 | 'display' => 'block', |
---|
203 | 'height' => $s['top_height'] ? ($s['top_height'] - 10) . 'px' : '120px', |
---|
204 | 'width' => '800px' |
---|
205 | ]; |
---|
206 | } |
---|
207 | dcThemeConfig::prop($css, '#top', 'height', $s['top_height']); |
---|
208 | |
---|
209 | dcThemeConfig::prop($css, '.day-date', 'color', $s['date_title_c']); |
---|
210 | dcThemeConfig::prop($css, '.day-date', 'font-family', self::fontDef($s['date_title_f'])); |
---|
211 | dcThemeConfig::prop($css, '.day-date', 'font-size', $s['date_title_s']); |
---|
212 | |
---|
213 | dcThemeConfig::prop($css, 'a', 'color', $s['body_link_c']); |
---|
214 | dcThemeConfig::prop($css, 'a:visited', 'color', $s['body_link_v_c']); |
---|
215 | dcThemeConfig::prop($css, 'a:hover, a:focus, a:active', 'color', $s['body_link_f_c']); |
---|
216 | |
---|
217 | dcThemeConfig::prop($css, '#comment-form input, #comment-form textarea', 'color', $s['body_link_c']); |
---|
218 | dcThemeConfig::prop($css, '#comment-form input.preview', 'color', $s['body_link_c']); |
---|
219 | dcThemeConfig::prop($css, '#comment-form input.preview:hover', 'background', $s['body_link_f_c']); |
---|
220 | dcThemeConfig::prop($css, '#comment-form input.preview:hover', 'border-color', $s['body_link_f_c']); |
---|
221 | dcThemeConfig::prop($css, '#comment-form input.submit', 'color', $s['body_link_c']); |
---|
222 | dcThemeConfig::prop($css, '#comment-form input.submit:hover', 'background', $s['body_link_f_c']); |
---|
223 | dcThemeConfig::prop($css, '#comment-form input.submit:hover', 'border-color', $s['body_link_f_c']); |
---|
224 | |
---|
225 | dcThemeConfig::prop($css, '#sidebar', 'font-family', self::fontDef($s['sidebar_text_f'])); |
---|
226 | dcThemeConfig::prop($css, '#sidebar', 'font-size', $s['sidebar_text_s']); |
---|
227 | dcThemeConfig::prop($css, '#sidebar', 'color', $s['sidebar_text_c']); |
---|
228 | |
---|
229 | dcThemeConfig::prop($css, '#sidebar h2', 'font-family', self::fontDef($s['sidebar_title_f'])); |
---|
230 | dcThemeConfig::prop($css, '#sidebar h2', 'font-size', $s['sidebar_title_s']); |
---|
231 | dcThemeConfig::prop($css, '#sidebar h2', 'color', $s['sidebar_title_c']); |
---|
232 | |
---|
233 | dcThemeConfig::prop($css, '#sidebar h3', 'font-family', self::fontDef($s['sidebar_title2_f'])); |
---|
234 | dcThemeConfig::prop($css, '#sidebar h3', 'font-size', $s['sidebar_title2_s']); |
---|
235 | dcThemeConfig::prop($css, '#sidebar h3', 'color', $s['sidebar_title2_c']); |
---|
236 | |
---|
237 | dcThemeConfig::prop($css, '#sidebar ul', 'border-top-color', $s['sidebar_line_c']); |
---|
238 | dcThemeConfig::prop($css, '#sidebar li', 'border-bottom-color', $s['sidebar_line_c']); |
---|
239 | dcThemeConfig::prop($css, '#topnav ul', 'border-bottom-color', $s['sidebar_line_c']); |
---|
240 | |
---|
241 | dcThemeConfig::prop($css, '#sidebar li a', 'color', $s['sidebar_link_c']); |
---|
242 | dcThemeConfig::prop($css, '#sidebar li a:visited', 'color', $s['sidebar_link_v_c']); |
---|
243 | dcThemeConfig::prop($css, '#sidebar li a:hover, #sidebar li a:focus, #sidebar li a:active', 'color', $s['sidebar_link_f_c']); |
---|
244 | dcThemeConfig::prop($css, '#search input', 'color', $s['sidebar_link_c']); |
---|
245 | dcThemeConfig::prop($css, '#search .submit', 'color', $s['sidebar_link_c']); |
---|
246 | dcThemeConfig::prop($css, '#search .submit:hover', 'background', $s['sidebar_link_f_c']); |
---|
247 | dcThemeConfig::prop($css, '#search .submit:hover', 'border-color', $s['sidebar_link_f_c']); |
---|
248 | |
---|
249 | dcThemeConfig::prop($css, '.post-title', 'color', $s['post_title_c']); |
---|
250 | dcThemeConfig::prop($css, '.post-title a, .post-title a:visited', 'color', $s['post_title_c']); |
---|
251 | dcThemeConfig::prop($css, '.post-title', 'font-family', self::fontDef($s['post_title_f'])); |
---|
252 | dcThemeConfig::prop($css, '.post-title', 'font-size', $s['post_title_s']); |
---|
253 | |
---|
254 | dcThemeConfig::prop($css, '#comments dd', 'background-color', $s['post_comment_bg_c']); |
---|
255 | dcThemeConfig::prop($css, '#comments dd', 'color', $s['post_comment_c']); |
---|
256 | dcThemeConfig::prop($css, '#comments dd.me', 'background-color', $s['post_commentmy_bg_c']); |
---|
257 | dcThemeConfig::prop($css, '#comments dd.me', 'color', $s['post_commentmy_c']); |
---|
258 | |
---|
259 | dcThemeConfig::prop($css, '#prelude, #prelude a', 'color', $s['prelude_c']); |
---|
260 | |
---|
261 | dcThemeConfig::prop($css, '#footer p', 'background-color', $s['footer_bg_c']); |
---|
262 | dcThemeConfig::prop($css, '#footer p', 'color', $s['footer_c']); |
---|
263 | dcThemeConfig::prop($css, '#footer p', 'font-size', $s['footer_s']); |
---|
264 | dcThemeConfig::prop($css, '#footer p', 'font-family', self::fontDef($s['footer_f'])); |
---|
265 | dcThemeConfig::prop($css, '#footer p a', 'color', $s['footer_l_c']); |
---|
266 | |
---|
267 | /* Images |
---|
268 | ------------------------------------------------------ */ |
---|
269 | self::backgroundImg($css, 'body', $s['body_bg_c'], 'body-bg.png'); |
---|
270 | self::backgroundImg($css, 'body', $s['body_bg_g'] != 'light', 'body-bg.png'); |
---|
271 | self::backgroundImg($css, 'body', $s['prelude_c'], 'body-bg.png'); |
---|
272 | self::backgroundImg($css, '#top', $s['body_bg_c'], 'page-t.png'); |
---|
273 | self::backgroundImg($css, '#top', $s['body_bg_g'] != 'light', 'page-t.png'); |
---|
274 | self::backgroundImg($css, '#top', $s['uploaded'] || $s['top_image'], 'page-t.png'); |
---|
275 | self::backgroundImg($css, '#footer', $s['body_bg_c'], 'page-b.png'); |
---|
276 | self::backgroundImg($css, '#comments dt', $s['post_comment_bg_c'], 'comment-t.png'); |
---|
277 | self::backgroundImg($css, '#comments dd', $s['post_comment_bg_c'], 'comment-b.png'); |
---|
278 | self::backgroundImg($css, '#comments dt.me', $s['post_commentmy_bg_c'], 'commentmy-t.png'); |
---|
279 | self::backgroundImg($css, '#comments dd.me', $s['post_commentmy_bg_c'], 'commentmy-b.png'); |
---|
280 | |
---|
281 | $res = ''; |
---|
282 | foreach ($css as $selector => $values) { |
---|
283 | $res .= $selector . " {\n"; |
---|
284 | foreach ($values as $k => $v) { |
---|
285 | $res .= $k . ':' . $v . ";\n"; |
---|
286 | } |
---|
287 | $res .= "}\n"; |
---|
288 | } |
---|
289 | |
---|
290 | $res .= $s['extra_css']; |
---|
291 | |
---|
292 | if (!self::canWriteCss(true)) { |
---|
293 | throw new Exception(__('Unable to create css file.')); |
---|
294 | } |
---|
295 | |
---|
296 | # erase old css file |
---|
297 | self::dropCss($core->blog->settings->system->theme); |
---|
298 | |
---|
299 | # create new css file into public blowup-css subdirectory |
---|
300 | self::writeCss($core->blog->settings->system->theme, $res); |
---|
301 | |
---|
302 | return $res; |
---|
303 | } |
---|
304 | |
---|
305 | public static function createImages(&$config, $uploaded) |
---|
306 | { |
---|
307 | $body_color = $config['body_bg_c']; |
---|
308 | $prelude_color = $config['prelude_c']; |
---|
309 | $gradient = $config['body_bg_g']; |
---|
310 | $comment_color = $config['post_comment_bg_c']; |
---|
311 | $comment_color_my = $config['post_commentmy_bg_c']; |
---|
312 | $top_image = $config['top_image']; |
---|
313 | |
---|
314 | $config['top_height'] = null; |
---|
315 | |
---|
316 | if ($top_image != 'custom' && !isset(self::$top_images[$top_image])) { |
---|
317 | $top_image = 'default'; |
---|
318 | } |
---|
319 | if ($uploaded && !is_file($uploaded)) { |
---|
320 | $uploaded = null; |
---|
321 | } |
---|
322 | |
---|
323 | if (!self::canWriteImages(true)) { |
---|
324 | throw new Exception(__('Unable to create images.')); |
---|
325 | } |
---|
326 | |
---|
327 | $body_fill = [ |
---|
328 | 'light' => dirname(__FILE__) . '/../alpha-img/gradient-l.png', |
---|
329 | 'medium' => dirname(__FILE__) . '/../alpha-img/gradient-m.png', |
---|
330 | 'dark' => dirname(__FILE__) . '/../alpha-img/gradient-d.png' |
---|
331 | ]; |
---|
332 | |
---|
333 | $body_g = isset($body_fill[$gradient]) ? $body_fill[$gradient] : false; |
---|
334 | |
---|
335 | if ($top_image == 'custom' && $uploaded) { |
---|
336 | $page_t = $uploaded; |
---|
337 | } else { |
---|
338 | $page_t = dirname(__FILE__) . '/../alpha-img/page-t/' . $top_image . '.png'; |
---|
339 | } |
---|
340 | |
---|
341 | $body_bg = dirname(__FILE__) . '/../alpha-img/body-bg.png'; |
---|
342 | $page_t_mask = dirname(__FILE__) . '/../alpha-img/page-t/image-mask.png'; |
---|
343 | $page_b = dirname(__FILE__) . '/../alpha-img/page-b.png'; |
---|
344 | $comment_t = dirname(__FILE__) . '/../alpha-img/comment-t.png'; |
---|
345 | $comment_b = dirname(__FILE__) . '/../alpha-img/comment-b.png'; |
---|
346 | $default_bg = '#e0e0e0'; |
---|
347 | $default_prelude = '#ededed'; |
---|
348 | |
---|
349 | self::dropImage(basename($body_bg)); |
---|
350 | self::dropImage('page-t.png'); |
---|
351 | self::dropImage(basename($page_b)); |
---|
352 | self::dropImage(basename($comment_t)); |
---|
353 | self::dropImage(basename($comment_b)); |
---|
354 | |
---|
355 | $body_color = dcThemeConfig::adjustColor($body_color); |
---|
356 | $prelude_color = dcThemeConfig::adjustColor($prelude_color); |
---|
357 | $comment_color = dcThemeConfig::adjustColor($comment_color); |
---|
358 | |
---|
359 | if ($top_image || $body_color || $gradient != 'light' || $prelude_color || $uploaded) { |
---|
360 | if (!$body_color) { |
---|
361 | $body_color = $default_bg; |
---|
362 | } |
---|
363 | $body_color = sscanf($body_color, '#%2X%2X%2X'); |
---|
364 | |
---|
365 | # Create body gradient with color |
---|
366 | $d_body_bg = imagecreatetruecolor(50, 180); |
---|
367 | $fill = imagecolorallocate($d_body_bg, $body_color[0], $body_color[1], $body_color[2]); |
---|
368 | imagefill($d_body_bg, 0, 0, $fill); |
---|
369 | |
---|
370 | # User choosed a gradient |
---|
371 | if ($body_g) { |
---|
372 | $s_body_bg = imagecreatefrompng($body_g); |
---|
373 | imagealphablending($s_body_bg, true); |
---|
374 | imagecopy($d_body_bg, $s_body_bg, 0, 0, 0, 0, 50, 180); |
---|
375 | imagedestroy($s_body_bg); |
---|
376 | } |
---|
377 | |
---|
378 | if (!$prelude_color) { |
---|
379 | $prelude_color = $default_prelude; |
---|
380 | } |
---|
381 | $prelude_color = sscanf($prelude_color, '#%2X%2X%2X'); |
---|
382 | |
---|
383 | $s_prelude = imagecreatetruecolor(50, 30); |
---|
384 | $fill = imagecolorallocate($s_prelude, $prelude_color[0], $prelude_color[1], $prelude_color[2]); |
---|
385 | imagefill($s_prelude, 0, 0, $fill); |
---|
386 | imagecopy($d_body_bg, $s_prelude, 0, 0, 0, 0, 50, 30); |
---|
387 | |
---|
388 | imagepng($d_body_bg, self::imagesPath() . '/' . basename($body_bg)); |
---|
389 | } |
---|
390 | |
---|
391 | if ($top_image || $body_color || $gradient != 'light') { |
---|
392 | # Create top image from uploaded image |
---|
393 | $size = getimagesize($page_t); |
---|
394 | $size = $size[1]; |
---|
395 | $type = files::getMimeType($page_t); |
---|
396 | |
---|
397 | $d_page_t = imagecreatetruecolor(800, $size); |
---|
398 | |
---|
399 | if ($type == 'image/png') { |
---|
400 | $s_page_t = @imagecreatefrompng($page_t); |
---|
401 | } else { |
---|
402 | $s_page_t = @imagecreatefromjpeg($page_t); |
---|
403 | } |
---|
404 | |
---|
405 | if (!$s_page_t) { |
---|
406 | throw new exception(__('Unable to open image.')); |
---|
407 | } |
---|
408 | |
---|
409 | $fill = imagecolorallocate($d_page_t, $body_color[0], $body_color[1], $body_color[2]); |
---|
410 | imagefill($d_page_t, 0, 0, $fill); |
---|
411 | |
---|
412 | if ($type == 'image/png') { |
---|
413 | # PNG, we only add body gradient and image |
---|
414 | imagealphablending($s_page_t, true); |
---|
415 | imagecopyresized($d_page_t, $d_body_bg, 0, 0, 0, 50, 800, 130, 50, 130); |
---|
416 | imagecopy($d_page_t, $s_page_t, 0, 0, 0, 0, 800, $size); |
---|
417 | } else { |
---|
418 | # JPEG, we add image and a frame with rounded corners |
---|
419 | imagecopy($d_page_t, $s_page_t, 0, 0, 0, 0, 800, $size); |
---|
420 | |
---|
421 | imagecopy($d_page_t, $d_body_bg, 0, 0, 0, 50, 8, 4); |
---|
422 | imagecopy($d_page_t, $d_body_bg, 0, 4, 0, 54, 4, 4); |
---|
423 | imagecopy($d_page_t, $d_body_bg, 792, 0, 0, 50, 8, 4); |
---|
424 | imagecopy($d_page_t, $d_body_bg, 796, 4, 0, 54, 4, 4); |
---|
425 | |
---|
426 | $mask = imagecreatefrompng($page_t_mask); |
---|
427 | imagealphablending($mask, true); |
---|
428 | imagecopy($d_page_t, $mask, 0, 0, 0, 0, 800, 11); |
---|
429 | imagedestroy($mask); |
---|
430 | |
---|
431 | $fill = imagecolorallocate($d_page_t, 255, 255, 255); |
---|
432 | imagefilledrectangle($d_page_t, 0, 11, 3, $size - 1, $fill); |
---|
433 | imagefilledrectangle($d_page_t, 796, 11, 799, $size - 1, $fill); |
---|
434 | imagefilledrectangle($d_page_t, 0, $size - 9, 799, $size - 1, $fill); |
---|
435 | } |
---|
436 | |
---|
437 | $config['top_height'] = ($size) . 'px'; |
---|
438 | |
---|
439 | imagepng($d_page_t, self::imagesPath() . '/page-t.png'); |
---|
440 | |
---|
441 | imagedestroy($d_body_bg); |
---|
442 | imagedestroy($d_page_t); |
---|
443 | imagedestroy($s_page_t); |
---|
444 | |
---|
445 | # Create bottom image with color |
---|
446 | $d_page_b = imagecreatetruecolor(800, 8); |
---|
447 | $fill = imagecolorallocate($d_page_b, $body_color[0], $body_color[1], $body_color[2]); |
---|
448 | imagefill($d_page_b, 0, 0, $fill); |
---|
449 | |
---|
450 | $s_page_b = imagecreatefrompng($page_b); |
---|
451 | imagealphablending($s_page_b, true); |
---|
452 | imagecopy($d_page_b, $s_page_b, 0, 0, 0, 0, 800, 160); |
---|
453 | |
---|
454 | imagepng($d_page_b, self::imagesPath() . '/' . basename($page_b)); |
---|
455 | |
---|
456 | imagedestroy($d_page_b); |
---|
457 | imagedestroy($s_page_b); |
---|
458 | } |
---|
459 | |
---|
460 | if ($comment_color) { |
---|
461 | self::commentImages($comment_color, $comment_t, $comment_b, basename($comment_t), basename($comment_b)); |
---|
462 | } |
---|
463 | if ($comment_color_my) { |
---|
464 | self::commentImages($comment_color_my, $comment_t, $comment_b, 'commentmy-t.png', 'commentmy-b.png'); |
---|
465 | } |
---|
466 | } |
---|
467 | |
---|
468 | protected static function commentImages($comment_color, $comment_t, $comment_b, $dest_t, $dest_b) |
---|
469 | { |
---|
470 | $comment_color = sscanf($comment_color, '#%2X%2X%2X'); |
---|
471 | |
---|
472 | $d_comment_t = imagecreatetruecolor(500, 25); |
---|
473 | $fill = imagecolorallocate($d_comment_t, $comment_color[0], $comment_color[1], $comment_color[2]); |
---|
474 | imagefill($d_comment_t, 0, 0, $fill); |
---|
475 | |
---|
476 | $s_comment_t = imagecreatefrompng($comment_t); |
---|
477 | imagealphablending($s_comment_t, true); |
---|
478 | imagecopy($d_comment_t, $s_comment_t, 0, 0, 0, 0, 500, 25); |
---|
479 | |
---|
480 | imagepng($d_comment_t, self::imagesPath() . '/' . $dest_t); |
---|
481 | imagedestroy($d_comment_t); |
---|
482 | imagedestroy($s_comment_t); |
---|
483 | |
---|
484 | $d_comment_b = imagecreatetruecolor(500, 7); |
---|
485 | $fill = imagecolorallocate($d_comment_b, $comment_color[0], $comment_color[1], $comment_color[2]); |
---|
486 | imagefill($d_comment_b, 0, 0, $fill); |
---|
487 | |
---|
488 | $s_comment_b = imagecreatefrompng($comment_b); |
---|
489 | imagealphablending($s_comment_b, true); |
---|
490 | imagecopy($d_comment_b, $s_comment_b, 0, 0, 0, 0, 500, 7); |
---|
491 | |
---|
492 | imagepng($d_comment_b, self::imagesPath() . '/' . $dest_b); |
---|
493 | imagedestroy($d_comment_b); |
---|
494 | imagedestroy($s_comment_b); |
---|
495 | } |
---|
496 | |
---|
497 | } |
---|