Dotclear

source: plugins/blowupConfig/index.php @ 0:54703be25dd6

Revision 0:54703be25dd6, 17.4 KB checked in by Dsls <dsls@…>, 14 years ago (diff)

2.3 branch (trunk) first checkin

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
6# Copyright (c) 2003-2010 Olivier Meunier & Association Dotclear
7# Licensed under the GPL version 2.0 license.
8# See LICENSE file or
9# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10#
11# -- END LICENSE BLOCK -----------------------------------------
12if (!defined('DC_CONTEXT_ADMIN')) { return; }
13
14require dirname(__FILE__).'/lib/class.blowup.config.php';
15
16$can_write_images = blowupConfig::canWriteImages();
17
18if ($core->error->flag()) {
19          $notices = $core->error->toHTML();
20          $core->error->reset();
21}
22
23$blowup_base = array(
24     'body_bg_c' => null,
25     'body_bg_g' => 'light',
26     
27     'body_txt_f' => null,
28     'body_txt_s' => null,
29     'body_txt_c' => null,
30     'body_line_height' => null,
31     
32     'top_image' => 'default',
33     'top_height' => null,
34     'uploaded' => null,
35     
36     'blog_title_hide' => null,
37     'blog_title_f' => null,
38     'blog_title_s' => null,
39     'blog_title_c' => null,
40     'blog_title_a' => null,
41     'blog_title_p' => null,
42     
43     'body_link_c' => null,
44     'body_link_f_c' => null,
45     'body_link_v_c' => null,
46     
47     'sidebar_position' => null,
48     'sidebar_text_f' => null,
49     'sidebar_text_s' => null,
50     'sidebar_text_c' => null,
51     'sidebar_title_f' => null,
52     'sidebar_title_s' => null,
53     'sidebar_title_c' => null,
54     'sidebar_title2_f' => null,
55     'sidebar_title2_s' => null,
56     'sidebar_title2_c' => null,
57     'sidebar_line_c' => null,
58     'sidebar_link_c' => null,
59     'sidebar_link_f_c' => null,
60     'sidebar_link_v_c' => null,
61     
62     'date_title_f' => null,
63     'date_title_s' => null,
64     'date_title_c' => null,
65     
66     'post_title_f' => null,
67     'post_title_s' => null,
68     'post_title_c' => null,
69     'post_comment_bg_c' => null,
70     'post_comment_c' => null,
71     'post_commentmy_bg_c' => null,
72     'post_commentmy_c' => null,
73     
74     'prelude_c' => null,
75     'footer_f' => null,
76     'footer_s' => null,
77     'footer_c' => null,
78     'footer_l_c' => null,
79     'footer_bg_c' => null,
80);
81
82$blowup_user = $core->blog->settings->themes->blowup_style;
83
84$blowup_user = @unserialize($blowup_user);
85if (!is_array($blowup_user)) {
86     $blowup_user = array();
87}
88
89$blowup_user = array_merge($blowup_base,$blowup_user);
90
91$gradient_types = array(
92     __('Light linear gradient') => 'light',
93     __('Medium linear gradient') => 'medium',
94     __('Dark linear gradient') => 'dark',
95     __('Solid color') => 'solid'
96);
97
98$top_images = array(__('Custom...') => 'custom');
99$top_images = array_merge($top_images,array_flip(blowupConfig::$top_images));
100
101
102if (!empty($_POST))
103{
104     try
105     {
106          $blowup_user['body_txt_f'] = $_POST['body_txt_f'];
107          $blowup_user['body_txt_s'] = blowupConfig::adjustFontSize($_POST['body_txt_s']);
108          $blowup_user['body_txt_c'] = blowupConfig::adjustColor($_POST['body_txt_c']);
109          $blowup_user['body_line_height'] = blowupConfig::adjustFontSize($_POST['body_line_height']);
110         
111          $blowup_user['blog_title_hide'] = (integer) !empty($_POST['blog_title_hide']);
112          $update_blog_title = !$blowup_user['blog_title_hide'] && (
113               !empty($_POST['blog_title_f']) || !empty($_POST['blog_title_s']) ||
114               !empty($_POST['blog_title_c']) || !empty($_POST['blog_title_a']) ||
115               !empty($_POST['blog_title_p'])
116          );
117         
118          if ($update_blog_title)
119          {
120               $blowup_user['blog_title_f'] = $_POST['blog_title_f'];
121               $blowup_user['blog_title_s'] = blowupConfig::adjustFontSize($_POST['blog_title_s']);
122               $blowup_user['blog_title_c'] = blowupConfig::adjustColor($_POST['blog_title_c']);
123               $blowup_user['blog_title_a'] = preg_match('/^(left|center|right)$/',$_POST['blog_title_a']) ? $_POST['blog_title_a'] : null;
124               $blowup_user['blog_title_p'] = blowupConfig::adjustPosition($_POST['blog_title_p']);
125          }
126         
127          $blowup_user['body_link_c'] = blowupConfig::adjustColor($_POST['body_link_c']);
128          $blowup_user['body_link_f_c'] = blowupConfig::adjustColor($_POST['body_link_f_c']);
129          $blowup_user['body_link_v_c'] = blowupConfig::adjustColor($_POST['body_link_v_c']);
130         
131          $blowup_user['sidebar_text_f'] = $_POST['sidebar_text_f'];
132          $blowup_user['sidebar_text_s'] = blowupConfig::adjustFontSize($_POST['sidebar_text_s']);
133          $blowup_user['sidebar_text_c'] = blowupConfig::adjustColor($_POST['sidebar_text_c']);
134          $blowup_user['sidebar_title_f'] = $_POST['sidebar_title_f'];
135          $blowup_user['sidebar_title_s'] = blowupConfig::adjustFontSize($_POST['sidebar_title_s']);
136          $blowup_user['sidebar_title_c'] = blowupConfig::adjustColor($_POST['sidebar_title_c']);
137          $blowup_user['sidebar_title2_f'] = $_POST['sidebar_title2_f'];
138          $blowup_user['sidebar_title2_s'] = blowupConfig::adjustFontSize($_POST['sidebar_title2_s']);
139          $blowup_user['sidebar_title2_c'] = blowupConfig::adjustColor($_POST['sidebar_title2_c']);
140          $blowup_user['sidebar_line_c'] = blowupConfig::adjustColor($_POST['sidebar_line_c']);
141          $blowup_user['sidebar_link_c'] = blowupConfig::adjustColor($_POST['sidebar_link_c']);
142          $blowup_user['sidebar_link_f_c'] = blowupConfig::adjustColor($_POST['sidebar_link_f_c']);
143          $blowup_user['sidebar_link_v_c'] = blowupConfig::adjustColor($_POST['sidebar_link_v_c']);
144         
145          $blowup_user['sidebar_position'] = ($_POST['sidebar_position'] == 'left') ? 'left' : null;
146         
147          $blowup_user['date_title_f'] = $_POST['date_title_f'];
148          $blowup_user['date_title_s'] = blowupConfig::adjustFontSize($_POST['date_title_s']);
149          $blowup_user['date_title_c'] = blowupConfig::adjustColor($_POST['date_title_c']);
150         
151          $blowup_user['post_title_f'] = $_POST['post_title_f'];
152          $blowup_user['post_title_s'] = blowupConfig::adjustFontSize($_POST['post_title_s']);
153          $blowup_user['post_title_c'] = blowupConfig::adjustColor($_POST['post_title_c']);
154          $blowup_user['post_comment_c'] = blowupConfig::adjustColor($_POST['post_comment_c']);
155          $blowup_user['post_commentmy_c'] = blowupConfig::adjustColor($_POST['post_commentmy_c']);
156         
157         
158          $blowup_user['footer_f'] = $_POST['footer_f'];
159          $blowup_user['footer_s'] = blowupConfig::adjustFontSize($_POST['footer_s']);
160          $blowup_user['footer_c'] = blowupConfig::adjustColor($_POST['footer_c']);
161          $blowup_user['footer_l_c'] = blowupConfig::adjustColor($_POST['footer_l_c']);
162          $blowup_user['footer_bg_c'] = blowupConfig::adjustColor($_POST['footer_bg_c']);
163         
164          if ($can_write_images)
165          {
166               $uploaded = null;
167               if ($blowup_user['uploaded'] && is_file(blowupConfig::imagesPath().'/'.$blowup_user['uploaded'])) {
168                    $uploaded = blowupConfig::imagesPath().'/'.$blowup_user['uploaded'];
169               }
170               
171               if (!empty($_FILES['upfile']) && !empty($_FILES['upfile']['name'])) {
172                    files::uploadStatus($_FILES['upfile']);
173                    $uploaded = blowupConfig::uploadImage($_FILES['upfile']);
174                    $blowup_user['uploaded'] = basename($uploaded);
175               }
176               
177               $blowup_user['top_image'] = in_array($_POST['top_image'],$top_images) ? $_POST['top_image'] : 'default';
178               
179               $blowup_user['body_bg_c'] = blowupConfig::adjustColor($_POST['body_bg_c']);
180               $blowup_user['body_bg_g'] = in_array($_POST['body_bg_g'],$gradient_types) ? $_POST['body_bg_g'] : '';
181               $blowup_user['post_comment_bg_c'] = blowupConfig::adjustColor($_POST['post_comment_bg_c']);
182               $blowup_user['post_commentmy_bg_c'] = blowupConfig::adjustColor($_POST['post_commentmy_bg_c']);
183               $blowup_user['prelude_c'] = blowupConfig::adjustColor($_POST['prelude_c']);
184               blowupConfig::createImages($blowup_user,$uploaded);
185          }
186         
187          $core->blog->settings->addNamespace('themes');
188          $core->blog->settings->themes->put('blowup_style',serialize($blowup_user));
189          $core->blog->triggerBlog();
190         
191          http::redirect($p_url.'&upd=1');
192     }
193     catch (Exception $e)
194     {
195          $core->error->add($e->getMessage());
196     }
197}
198?>
199<html>
200<head>
201  <title><?php echo __('Blowup configuration'); ?></title>
202  <?php echo dcPage::jsLoad('index.php?pf=blowupConfig/config.js'); ?>
203  <?php echo dcPage::jsColorPicker(); ?>
204  <script type="text/javascript">
205  //<![CDATA[
206  <?php
207  echo dcPage::jsVar('dotclear.blowup_public_url',blowupConfig::imagesURL());
208  echo dcPage::jsVar('dotclear.msg.predefined_styles',__('Predefined styles'));
209  echo dcPage::jsVar('dotclear.msg.apply_code',__('Apply code'));
210  ?>
211  //]]>
212  </script>
213</head>
214
215<body>
216<?php
217echo
218'<h2>'.html::escapeHTML($core->blog->name).
219' &rsaquo; <a href="blog_theme.php">'.__('Blog appearance').'</a> &rsaquo; '.__('Blowup configuration').'</h2>'.
220'<p><a class="back" href="blog_theme.php">'.__('back').'</a></p>';
221
222
223if (!$can_write_images) {
224     echo '<div class="message">'.
225          __('For the following reasons, images cannot be created. You won\'t be able to change some background properties.').
226          $notices.'</div>';
227}
228
229if (!empty($_GET['upd'])) {
230     echo '<p class="message">'.__('Theme configuration has been successfully updated.').'</p>';
231}
232
233echo '<form id="theme_config" action="'.$p_url.'" method="post" enctype="multipart/form-data">';
234         
235echo '<fieldset><legend>'.__('General').'</legend>';
236
237if ($can_write_images) {
238     echo
239     '<p class="field"><label>'.__('Background color:').' '.
240     form::field('body_bg_c',7,7,$blowup_user['body_bg_c'],'colorpicker').'</label></p>'.
241     
242     '<p class="field"><label>'.__('Background color fill:').' '.
243     form::combo('body_bg_g',$gradient_types,$blowup_user['body_bg_g']).'</label></p>';
244}
245
246echo
247'<p class="field"><label>'.__('Main text font:').' '.
248form::combo('body_txt_f',blowupConfig::fontsList(),$blowup_user['body_txt_f']).'</label></p>'.
249
250'<p class="field"><label>'.__('Main text font size:').' '.
251form::field('body_txt_s',7,7,$blowup_user['body_txt_s']).'</label></p>'.
252
253'<p class="field"><label>'.__('Main text color:').' '.
254form::field('body_txt_c',7,7,$blowup_user['body_txt_c'],'colorpicker').'</label></p>'.
255
256'<p class="field"><label>'.__('Text line height:').' '.
257form::field('body_line_height',7,7,$blowup_user['body_line_height']).'</label></p>'.
258'</fieldset>'.
259
260'<fieldset><legend>'.__('Links').'</legend>'.
261'<p class="field"><label>'.__('Links color:').' '.
262form::field('body_link_c',7,7,$blowup_user['body_link_c'],'colorpicker').'</label></p>'.
263
264'<p class="field"><label>'.__('Visited links color:').' '.
265form::field('body_link_v_c',7,7,$blowup_user['body_link_v_c'],'colorpicker').'</label></p>'.
266
267'<p class="field"><label>'.__('Focus links color:').' '.
268form::field('body_link_f_c',7,7,$blowup_user['body_link_f_c'],'colorpicker').'</label></p>'.
269'</fieldset>'.
270
271'<fieldset><legend>'.__('Page top').'</legend>';
272
273if ($can_write_images) {
274     echo
275     '<p class="field"><label>'.__('Prelude color:').' '.
276     form::field('prelude_c',7,7,$blowup_user['prelude_c'],'colorpicker').'</label></p>';
277}
278
279echo
280'<p class="field"><label>'.__('Hide main title').' '.
281form::checkbox('blog_title_hide',1,$blowup_user['blog_title_hide']).'</label></p>'.
282
283'<p class="field"><label>'.__('Main title font:').' '.
284form::combo('blog_title_f',blowupConfig::fontsList(),$blowup_user['blog_title_f']).'</label></p>'.
285
286'<p class="field"><label>'.__('Main title font size:').' '.
287form::field('blog_title_s',7,7,$blowup_user['blog_title_s']).'</label></p>'.
288
289'<p class="field"><label>'.__('Main title color:').' '.
290form::field('blog_title_c',7,7,$blowup_user['blog_title_c'],'colorpicker').'</label></p>'.
291
292'<p class="field"><label>'.__('Main title alignment:').' '.
293form::combo('blog_title_a',array(__('center')=>'center',__('left')=>'left',__('right')=>'right'),$blowup_user['blog_title_a']).'</label></p>'.
294
295'<p class="field"><label>'.__('Main title position (x:y)').' '.
296form::field('blog_title_p',7,7,$blowup_user['blog_title_p']).'</label></p>'.
297'</fieldset>';
298
299if ($can_write_images) {
300     if ($blowup_user['top_image'] == 'custom' && $blowup_user['uploaded']) {
301          $preview_image = http::concatURL($core->blog->url,blowupConfig::imagesURL().'/page-t.png');
302     } else {
303          $preview_image = 'index.php?pf=blowupConfig/alpha-img/page-t/'.$blowup_user['top_image'].'.png';
304     }
305     
306     echo
307     '<fieldset><legend>'.__('Top image').'</legend>'.
308     '<p class="field"><label>'.__('Top image').
309     form::combo('top_image',$top_images,($blowup_user['top_image'] ? $blowup_user['top_image'] : 'default')).'</label></p>'.
310     '<p>'.__('Choose "Custom..." to upload your own image.').'</p>'.
311     
312     '<p id="uploader"><label>'.__('Add your image:').
313     ' ('.sprintf(__('JPEG or PNG file, 800 pixels wide, maximum size %s'),files::size(DC_MAX_UPLOAD_SIZE)).')'.
314     '<input type="file" name="upfile" size="35" />'.
315     '</label></p>'.
316     
317     '<h3>'.__('Preview').'</h3>'.
318     '<div class="grid" style="width:800px;border:1px solid #ccc;">'.
319     '<img style="display:block;" src="'.$preview_image.'" alt="" id="image-preview" />'.
320     '</div>'.
321     '</fieldset>';
322}
323
324echo
325'<fieldset><legend>'.__('Sidebar').'</legend>'.
326'<p class="field"><label>'.__('Sidebar position:').' '.
327form::combo('sidebar_position',array(__('right')=>'right',__('left')=>'left'),$blowup_user['sidebar_position']).'</label></p>'.
328
329'<p class="field"><label>'.__('Sidebar text font:').' '.
330form::combo('sidebar_text_f',blowupConfig::fontsList(),$blowup_user['sidebar_text_f']).'</label></p>'.
331
332'<p class="field"><label>'.__('Sidebar text font size:').' '.
333form::field('sidebar_text_s',7,7,$blowup_user['sidebar_text_s']).'</label></p>'.
334
335'<p class="field"><label>'.__('Sidebar text color:').' '.
336form::field('sidebar_text_c',7,7,$blowup_user['sidebar_text_c'],'colorpicker').'</label></p>'.
337
338'<p class="field"><label>'.__('Sidebar titles font:').' '.
339form::combo('sidebar_title_f',blowupConfig::fontsList(),$blowup_user['sidebar_title_f']).'</label></p>'.
340
341'<p class="field"><label>'.__('Sidebar titles font size:').' '.
342form::field('sidebar_title_s',7,7,$blowup_user['sidebar_title_s']).'</label></p>'.
343
344'<p class="field"><label>'.__('Sidebar titles color:').' '.
345form::field('sidebar_title_c',7,7,$blowup_user['sidebar_title_c'],'colorpicker').'</label></p>'.
346
347'<p class="field"><label>'.__('Sidebar 2nd level titles font:').' '.
348form::combo('sidebar_title2_f',blowupConfig::fontsList(),$blowup_user['sidebar_title2_f']).'</label></p>'.
349
350'<p class="field"><label>'.__('Sidebar 2nd level titles font size:').' '.
351form::field('sidebar_title2_s',7,7,$blowup_user['sidebar_title2_s']).'</label></p>'.
352
353'<p class="field"><label>'.__('Sidebar 2nd level titles color:').' '.
354form::field('sidebar_title2_c',7,7,$blowup_user['sidebar_title2_c'],'colorpicker').'</label></p>'.
355
356'<p class="field"><label>'.__('Sidebar lines color:').' '.
357form::field('sidebar_line_c',7,7,$blowup_user['sidebar_line_c'],'colorpicker').'</label></p>'.
358
359'<p class="field"><label>'.__('Sidebar links color:').' '.
360form::field('sidebar_link_c',7,7,$blowup_user['sidebar_link_c'],'colorpicker').'</label></p>'.
361
362'<p class="field"><label>'.__('Sidebar visited links color:').' '.
363form::field('sidebar_link_v_c',7,7,$blowup_user['sidebar_link_v_c'],'colorpicker').'</label></p>'.
364
365'<p class="field"><label>'.__('Sidebar focus links color:').' '.
366form::field('sidebar_link_f_c',7,7,$blowup_user['sidebar_link_f_c'],'colorpicker').'</label></p>'.
367'</fieldset>'.
368
369'<fieldset><legend>'.__('Entries').'</legend>'.
370'<p class="field"><label>'.__('Date title font:').' '.
371form::combo('date_title_f',blowupConfig::fontsList(),$blowup_user['date_title_f']).'</label></p>'.
372
373'<p class="field"><label>'.__('Date title font size:').' '.
374form::field('date_title_s',7,7,$blowup_user['date_title_s']).'</label></p>'.
375
376'<p class="field"><label>'.__('Date title color:').' '.
377form::field('date_title_c',7,7,$blowup_user['date_title_c'],'colorpicker').'</label></p>'.
378
379'<p class="field"><label>'.__('Entry title font:').' '.
380form::combo('post_title_f',blowupConfig::fontsList(),$blowup_user['post_title_f']).'</label></p>'.
381
382'<p class="field"><label>'.__('Entry title font size:').' '.
383form::field('post_title_s',7,7,$blowup_user['post_title_s']).'</label></p>'.
384
385'<p class="field"><label>'.__('Entry title color:').' '.
386form::field('post_title_c',7,7,$blowup_user['post_title_c'],'colorpicker').'</label></p>';
387
388if ($can_write_images) {
389     echo
390     '<p class="field"><label>'.__('Comment background color:').' '.
391     form::field('post_comment_bg_c',7,7,$blowup_user['post_comment_bg_c'],'colorpicker').'</label></p>';
392}
393
394echo
395'<p class="field"><label>'.__('Comment text color:').' '.
396form::field('post_comment_c',7,7,$blowup_user['post_comment_c'],'colorpicker').'</label></p>';
397
398if ($can_write_images) {
399     echo
400     '<p class="field"><label>'.__('My comment background color:').' '.
401     form::field('post_commentmy_bg_c',7,7,$blowup_user['post_commentmy_bg_c'],'colorpicker').'</label></p>';
402}
403
404echo
405'<p class="field"><label>'.__('My comment text color:').' '.
406form::field('post_commentmy_c',7,7,$blowup_user['post_commentmy_c'],'colorpicker').'</label></p>'.
407'</fieldset>'.
408
409'<fieldset><legend>'.__('Footer').'</legend>'.
410'<p class="field"><label>'.__('Footer font:').' '.
411form::combo('footer_f',blowupConfig::fontsList(),$blowup_user['footer_f']).'</label></p>'.
412
413'<p class="field"><label>'.__('Footer font size:').' '.
414form::field('footer_s',7,7,$blowup_user['footer_s']).'</label></p>'.
415
416'<p class="field"><label>'.__('Footer color:').' '.
417form::field('footer_c',7,7,$blowup_user['footer_c'],'colorpicker').'</label></p>'.
418
419'<p class="field"><label>'.__('Footer links color:').' '.
420form::field('footer_l_c',7,7,$blowup_user['footer_l_c'],'colorpicker').'</label></p>'.
421
422'<p class="field"><label>'.__('Footer background color:').' '.
423form::field('footer_bg_c',7,7,$blowup_user['footer_bg_c'],'colorpicker').'</label></p>'.
424'</fieldset>';
425
426// Import / Export configuration
427$tmp_array = array();
428$tmp_exclude = array('uploaded','top_height');
429if ($blowup_user['top_image'] == 'custom') {
430     $tmp_exclude[] = 'top_image';
431}
432foreach ($blowup_user as $k => $v) {
433     if (!in_array($k,$tmp_exclude)) {
434          $tmp_array[] = $k.':'.'"'.$v.'"';
435     }
436}
437echo
438'<h3 id="bu_export">'.__('Configuration import / export').'</h3><fieldset>'.
439'<p>'.__('You can share your configuration using the following code. To apply a configuration, paste the code, click on "Apply code" and save.').'</p>'.
440'<p>'.form::textarea('export_code',72,5,implode('; ',$tmp_array),'maximal').'</p>'.
441'</fieldset>';
442
443echo
444'<p class="clear"><input type="submit" value="'.__('save').'" />'.
445$core->formNonce().'</p>'.
446'</form>';
447
448dcPage::helpBlock('blowupConfig');
449?>
450</body>
451</html>
Note: See TracBrowser for help on using the repository browser.

Sites map