Dotclear

source: themes/ductile/_config.php @ 628:62834254cb9a

Revision 628:62834254cb9a, 15.0 KB checked in by Franck <carnet.franck.paul@…>, 14 years ago (diff)

Ajout de l'aide contextuelle - page html à écrire

RevLine 
[345]1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
6# Copyright (c) 2003-2011 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
[421]14l10n::set(dirname(__FILE__).'/locales/'.$_lang.'/admin');
[357]15
[604]16$img_url = $core->blog->settings->system->themes_url.'/'.$core->blog->settings->system->theme.'/img/';
[627]17$img_url = http::concatURL($core->blog->url,$img_url);
[604]18$img_path = dirname(__FILE__).'/img/';
19
[611]20$standalone_config = (boolean) $core->themes->moduleInfo($core->blog->settings->system->theme,'standalone_config');
21
[563]22$list_types = array(
23     __('Title') => 'title',
24     __('Short') => 'short',
25     __('Full') => 'full'
26);
27
28$contexts = array(
29     'default' => __('Home (first page)'),
30     'default-page' => __('Home (other pages)'),
31     'category' => __('Entries for a category'),
32     'tag' => __('Entries for a tag'),
33     'search' => __('Search result entries'),
[564]34     'archive' => __('Month archive entries')
[563]35);
36
[376]37$fonts = array(
38     __('default') => '',
39     __('Ductile primary') => 'Ductile body',
40     __('Ductile secondary') => 'Ductile alternate',
41     __('Times New Roman') => 'Times New Roman',
42     __('Georgia') => 'Georgia',
43     __('Garamond') => 'Garamond',
44     __('Helvetica/Arial') => 'Helvetica/Arial',
45     __('Verdana') => 'Verdana',
46     __('Trebuchet MS') => 'Trebuchet MS',
47     __('Impact') => 'Impact',
48     __('Monospace') => 'Monospace'
49);
50
[387]51function adjustFontSize($s)
52{
53     if (preg_match('/^([0-9.]+)\s*(%|pt|px|em|ex)?$/',$s,$m)) {
54          if (empty($m[2])) {
55               $m[2] = 'em';
56          }
57          return $m[1].$m[2];
58     }
59
60     return null;
61}
62
[357]63function adjustColor($c)
64{
65     if ($c === '') {
66          return '';
67     }
68
69     $c = strtoupper($c);
70
71     if (preg_match('/^[A-F0-9]{3,6}$/',$c)) {
72          $c = '#'.$c;
73     }
74
75     if (preg_match('/^#[A-F0-9]{6}$/',$c)) {
76          return $c;
77     }
78
79     if (preg_match('/^#[A-F0-9]{3,}$/',$c)) {
80          return '#'.substr($c,1,1).substr($c,1,1).substr($c,2,1).substr($c,2,1).substr($c,3,1).substr($c,3,1);
81     }
82
83     return '';
84}
85
86$ductile_base = array(
[389]87     // HTML
88     'subtitle_hidden' => null,
89     // CSS
[376]90     'body_font' => null,
[387]91     'alternate_font' => null,
92     'blog_title_w' => null,
93     'blog_title_s' => null,
94     'blog_title_c' => null,
95     'post_title_w' => null,
96     'post_title_s' => null,
97     'post_title_c' => null,
98     'post_link_w' => null,
99     'post_link_v_c' => null,
100     'post_link_f_c' => null,
101     'blog_title_w_m' => null,
102     'blog_title_s_m' => null,
103     'blog_title_c_m' => null,
104     'post_title_w_m' => null,
105     'post_title_s_m' => null,
[515]106     'post_title_c_m' => null,
107     'post_simple_title_c' => null
[357]108);
109
[563]110$ductile_lists_base = array(
111     'default' => null,
112     'default-page' => null,
113     'category' => null,
114     'tag' => null,
115     'search' => null,
[564]116     'archive' => null
[563]117);
118
[583]119$ductile_counts_base = array(
120     'default' => null,
121     'category' => null,
122     'tag' => null,
123     'search' => null
124);
125
[605]126$ductile_user = $core->blog->settings->themes->get($core->blog->settings->system->theme.'_style');
127$ductile_user = @unserialize($ductile_user);
128if (!is_array($ductile_user)) {
129     $ductile_user = array();
130}
131$ductile_user = array_merge($ductile_base,$ductile_user);
132
133$ductile_lists = $core->blog->settings->themes->get($core->blog->settings->system->theme.'_entries_lists');
134$ductile_lists = @unserialize($ductile_lists);
135if (!is_array($ductile_lists)) {
136     $ductile_lists = $ductile_lists_base;
137}
138
139$ductile_counts = $core->blog->settings->themes->get($core->blog->settings->system->theme.'_entries_counts');
140$ductile_counts = @unserialize($ductile_counts);
141if (!is_array($ductile_counts)) {
142     $ductile_counts = $ductile_counts_base;
143}
144
145$ductile_stickers = $core->blog->settings->themes->get($core->blog->settings->system->theme.'_stickers');
146$ductile_stickers = @unserialize($ductile_stickers);
147
[614]148// If no stickers defined, add feed Atom one
149if (!is_array($ductile_stickers)) {
150     $ductile_stickers = array(array(
151          'label' => __('Subscribe'),
152          'url' => $core->blog->url.$core->url->getBase('feed').'/atom',
153          'image' => 'sticker-feed.png'
154          ));
155}
156
[605]157$ductile_stickers_full = array();
158// Get all sticker images already used
159if (is_array($ductile_stickers)) {
160     foreach ($ductile_stickers as $v) {
161          $ductile_stickers_full[] = $v['image'];
162     }
163}
164// Get all sticker-*.png in img folder of theme
165$ductile_stickers_images = files::scandir($img_path);
166if (is_array($ductile_stickers_images)) {
167     foreach ($ductile_stickers_images as $v) {
168          if (preg_match('/^sticker\-(.*)\.png$/',$v)) {
169               if (!in_array($v,$ductile_stickers_full)) {
170                    // image not already used
171                    $ductile_stickers[] = array(
172                         'label' => null,
173                         'url' => null,
174                         'image' => $v);
175               }
176          }
177     }
178}
179
[390]180$conf_tab = isset($_POST['conf_tab']) ? $_POST['conf_tab'] : 'html';
181
[357]182if (!empty($_POST))
183{
184     try
185     {
[389]186          # HTML
[390]187          if ($conf_tab == 'html') {
188               $ductile_user['subtitle_hidden'] = (integer) !empty($_POST['subtitle_hidden']);
[605]189
[604]190               $ductile_stickers = array();
[605]191               for ($i = 0; $i < count($_POST['sticker_image']); $i++) {
192                    $ductile_stickers[] = array(
193                         'label' => $_POST['sticker_label'][$i],
194                         'url' => $_POST['sticker_url'][$i],
195                         'image' => $_POST['sticker_image'][$i]
196                    );
197               }
198
199               $order = array();
200               if (empty($_POST['ds_order']) && !empty($_POST['order'])) {
201                    $order = $_POST['order'];
202                    asort($order);
203                    $order = array_keys($order);
204               }
205               if (!empty($order)) {
206                    $new_ductile_stickers = array();
207                    foreach ($order as $i => $k) {
208                         $new_ductile_stickers[] = array(
209                              'label' => $ductile_stickers[$k]['label'],
210                              'url' => $ductile_stickers[$k]['url'],
211                              'image' => $ductile_stickers[$k]['image']
[604]212                         );
213                    }
[605]214                    $ductile_stickers = $new_ductile_stickers;
[419]215               }
[605]216               
[563]217               for ($i = 0; $i < count($_POST['list_type']); $i++) {
218                    $ductile_lists[$_POST['list_ctx'][$i]] = $_POST['list_type'][$i];
219               }
220               
[583]221               for ($i = 0; $i < count($_POST['count_nb']); $i++) {
222                    $ductile_counts[$_POST['count_ctx'][$i]] = $_POST['count_nb'][$i];
223               }
224               
[390]225          }
[389]226         
227          # CSS
[390]228          if ($conf_tab == 'css') {
229               $ductile_user['body_font'] = $_POST['body_font'];
230               $ductile_user['alternate_font'] = $_POST['alternate_font'];
231
232               $ductile_user['blog_title_w'] = (integer) !empty($_POST['blog_title_w']);
233               $ductile_user['blog_title_s'] = adjustFontSize($_POST['blog_title_s']);
234               $ductile_user['blog_title_c'] = adjustColor($_POST['blog_title_c']);
[389]235         
[390]236               $ductile_user['post_title_w'] = (integer) !empty($_POST['post_title_w']);
237               $ductile_user['post_title_s'] = adjustFontSize($_POST['post_title_s']);
238               $ductile_user['post_title_c'] = adjustColor($_POST['post_title_c']);
[387]239         
[390]240               $ductile_user['post_link_w'] = (integer) !empty($_POST['post_link_w']);
241               $ductile_user['post_link_v_c'] = adjustColor($_POST['post_link_v_c']);
242               $ductile_user['post_link_f_c'] = adjustColor($_POST['post_link_f_c']);
[387]243         
[515]244               $ductile_user['post_simple_title_c'] = adjustColor($_POST['post_simple_title_c']);
245         
[390]246               $ductile_user['blog_title_w_m'] = (integer) !empty($_POST['blog_title_w_m']);
247               $ductile_user['blog_title_s_m'] = adjustFontSize($_POST['blog_title_s_m']);
248               $ductile_user['blog_title_c_m'] = adjustColor($_POST['blog_title_c_m']);
[387]249         
[390]250               $ductile_user['post_title_w_m'] = (integer) !empty($_POST['post_title_w_m']);
251               $ductile_user['post_title_s_m'] = adjustFontSize($_POST['post_title_s_m']);
252               $ductile_user['post_title_c_m'] = adjustColor($_POST['post_title_c_m']);
253          }
[376]254         
[357]255          $core->blog->settings->addNamespace('themes');
[394]256          $core->blog->settings->themes->put($core->blog->settings->system->theme.'_style',serialize($ductile_user));
[419]257          $core->blog->settings->themes->put($core->blog->settings->system->theme.'_stickers',serialize($ductile_stickers));
[563]258          $core->blog->settings->themes->put($core->blog->settings->system->theme.'_entries_lists',serialize($ductile_lists));
[583]259          $core->blog->settings->themes->put($core->blog->settings->system->theme.'_entries_counts',serialize($ductile_counts));
[572]260
261          // Blog refresh
[357]262          $core->blog->triggerBlog();
263
[572]264          // Template cache reset
265          $core->emptyTemplatesCache();
266         
[357]267          echo
268          '<div class="message"><p>'.
[389]269          __('Theme configuration upgraded.').
[357]270          '</p></div>';
271     }
272     catch (Exception $e)
273     {
274          $core->error->add($e->getMessage());
275     }
276}
277
[613]278// Legacy mode
279if (!$standalone_config) echo '</form>';
280
[389]281# HTML Tab
282
[390]283echo '<div class="multi-part" id="themes-list'.($conf_tab == 'html' ? '' : '-html').'" title="'.__('Content').'">';
284
285echo '<form id="theme_config" action="blog_theme.php?conf=1" method="post" enctype="multipart/form-data">';
[389]286
287echo '<fieldset><legend>'.__('Header').'</legend>'.
288'<p class="field"><label for="subtitle_hidden">'.__('Hide blog description:').' '.
[612]289form::checkbox('subtitle_hidden',1,$ductile_user['subtitle_hidden']).'</label>'.'</p>';
290if ($core->plugins->moduleExists('simpleMenu'))
291{
292     echo '<p>'.sprintf(__('To configure the top menu go to the <a href="%s">Simple Menu administration page</a>.'),'plugin.php?p=simpleMenu').'</p>';
293}
294echo '</fieldset>';
[389]295
[425]296echo '<fieldset><legend>'.__('Stickers').'</legend>';
[419]297
[605]298echo '<table class="dragable">'.'<caption>'.__('Stickers (footer)').'</caption>'.
[419]299'<thead>'.
300'<tr>'.
[605]301'<th scope="col">'.'</th>'.
[604]302'<th scope="col">'.__('Image').'</th>'.
[419]303'<th scope="col">'.__('Label').'</th>'.
304'<th scope="col">'.__('URL').'</th>'.
305'</tr>'.
306'</thead>'.
[605]307'<tbody id="stickerslist">';
308$count = 0;
309foreach ($ductile_stickers as $i => $v) {
310     $count++;
[604]311     echo 
[605]312     '<tr class="line" id="l_'.$i.'">'.
313     '<td class="handle minimal">'.form::field(array('order['.$i.']'),2,3,$count,'position','',false).
314          form::hidden(array('dynorder[]','dynorder-'.$i),$i).'</td>'.
315     '<td>'.form::hidden(array('sticker_image[]'),$v['image']).'<img src="'.$img_url.$v['image'].'" /> '.'</td>'.
316     '<td scope="raw">'.form::field(array('sticker_label[]','dsl-'.$i),20,255,$v['label']).'</td>'.
317     '<td>'.form::field(array('sticker_url[]','dsu-'.$i),40,255,$v['url']).'</td>'.
[604]318     '</tr>';
319}
320echo
[419]321'</tbody>'.
322'</table>';
323
[425]324echo '</fieldset>';
[419]325
[583]326echo '<fieldset><legend>'.__('Entries list types and limits').'</legend>';
[563]327
328echo '<table id="entrieslist">'.'<caption>'.__('Entries lists').'</caption>'.
329'<thead>'.
330'<tr>'.
331'<th scope="col">'.__('Context').'</th>'.
332'<th scope="col">'.__('Entries list type').'</th>'.
[583]333'<th scope="col">'.__('Number of entries').'</th>'.
[563]334'</tr>'.
335'</thead>'.
336'<tbody>';
337foreach ($ductile_lists as $k => $v) {
338     echo 
339          '<tr>'.
340          '<td scope="raw">'.$contexts[$k].'</td>'.
[583]341          '<td>'.form::hidden(array('list_ctx[]'),$k).form::combo(array('list_type[]'),$list_types,$v).'</td>';
342     if (array_key_exists($k,$ductile_counts)) {
343          echo '<td>'.form::hidden(array('count_ctx[]'),$k).form::field(array('count_nb[]'),2,3,$ductile_counts[$k]).'</td>';
344     } else {
345          echo '<td></td>';
346     }
347     echo
[563]348          '</tr>';
349}
350echo
351'</tbody>'.
352'</table>';
353
354echo '</fieldset>';
355
[390]356echo '<input type="hidden" name="conf_tab" value="html">';
[605]357echo '<p class="clear">'.form::hidden('ds_order','').'<input type="submit" value="'.__('Save').'" />'.$core->formNonce().'</p>';
[390]358echo '</form>';
359
[389]360echo '</div>'; // Close tab
361
362# CSS tab
363
[390]364echo '<div class="multi-part" id="themes-list'.($conf_tab == 'css' ? '' : '-css').'" title="'.__('Presentation').'">';
365
366echo '<form id="theme_config" action="blog_theme.php?conf=1" method="post" enctype="multipart/form-data">';
[389]367
[387]368echo '<h3>'.__('General settings').'</h3>';
369
[376]370echo '<fieldset><legend>'.__('Fonts').'</legend>'.
[388]371'<p class="field"><label for="body_font">'.__('Main:').' '.
[376]372form::combo('body_font',$fonts,$ductile_user['body_font']).'</label></p>'.
373
[388]374'<p class="field"><label for="alternate_font">'.__('Secondary:').' '.
[376]375form::combo('alternate_font',$fonts,$ductile_user['alternate_font']).'</label></p>'.
376'</fieldset>';
377
[387]378echo '<div class="two-cols">';
379echo '<div class="col">';
380
381echo '<fieldset><legend>'.__('Blog title').'</legend>'.
[388]382'<p class="field"><label for="blog_title_w">'.__('In bold:').' '.
[387]383form::checkbox('blog_title_w',1,$ductile_user['blog_title_w']).'</label>'.'</p>'.
384
[395]385'<p class="field"><label for="blog_title_s">'.__('Font size (in em by default):').'</label> '.
386form::field('blog_title_s',7,7,$ductile_user['blog_title_s']).'</p>'.
[387]387
[389]388'<p class="field picker"><label for="blog_title_c">'.__('Color:').'</label> '.
[387]389form::field('blog_title_c',7,7,$ductile_user['blog_title_c'],'colorpicker').'</p>'.
390'</fieldset>';
391
392echo '</div>';
393echo '<div class="col">';
394
395echo '<fieldset><legend>'.__('Post title').'</legend>'.
[388]396'<p class="field"><label for="post_title_w">'.__('In bold:').' '.
[387]397form::checkbox('post_title_w',1,$ductile_user['post_title_w']).'</label>'.'</p>'.
398
[395]399'<p class="field"><label for="post_title_s">'.__('Font size (in em by default):').'</label> '.
400form::field('post_title_s',7,7,$ductile_user['post_title_s']).'</p>'.
[387]401
[389]402'<p class="field picker"><label for="post_title_c">'.__('Color:').'</label> '.
[387]403form::field('post_title_c',7,7,$ductile_user['post_title_c'],'colorpicker').'</p>'.
404'</fieldset>';
405
406echo '</div>';
407echo '</div>';
408
[515]409echo '<fieldset><legend>'.__('Titles without link').'</legend>'.
410
411'<p class="field picker"><label for="post_simple_title_c">'.__('Color:').'</label> '.
412form::field('post_simple_title_c',7,7,$ductile_user['post_simple_title_c'],'colorpicker').'</p>'.
413'</fieldset>';
414
[378]415echo '<fieldset><legend>'.__('Inside posts links').'</legend>'.
[388]416'<p class="field"><label for="post_link_w">'.__('In bold:').' '.
[387]417form::checkbox('post_link_w',1,$ductile_user['post_link_w']).'</label>'.'</p>'.
[357]418
[389]419'<p class="field picker"><label for="post_link_v_c">'.__('Normal and visited links color:').'</label> '.
[387]420form::field('post_link_v_c',7,7,$ductile_user['post_link_v_c'],'colorpicker').'</p>'.
[357]421
[389]422'<p class="field picker"><label for="body_link_f_c">'.__('Active, hover and focus links color:').'</label> '.
[387]423form::field('post_link_f_c',7,7,$ductile_user['post_link_f_c'],'colorpicker').'</p>'.
[357]424'</fieldset>';
425
[387]426echo '<h3>'.__('Mobile specific settings').'</h3>';
427
428echo '<div class="two-cols">';
429echo '<div class="col">';
430
431echo '<fieldset><legend>'.__('Blog title').'</legend>'.
[388]432'<p class="field"><label for="blog_title_w_m">'.__('In bold:').' '.
[387]433form::checkbox('blog_title_w_m',1,$ductile_user['blog_title_w_m']).'</label>'.'</p>'.
434
[395]435'<p class="field"><label for="blog_title_s_m">'.__('Font size (in em by default):').'</label> '.
436form::field('blog_title_s_m',7,7,$ductile_user['blog_title_s_m']).'</p>'.
[387]437
[389]438'<p class="field picker"><label for="blog_title_c_m">'.__('Color:').'</label> '.
[387]439form::field('blog_title_c_m',7,7,$ductile_user['blog_title_c_m'],'colorpicker').'</p>'.
440'</fieldset>';
441
442echo '</div>';
443echo '<div class="col">';
444
445echo '<fieldset><legend>'.__('Post title').'</legend>'.
[388]446'<p class="field"><label for="post_title_w_m">'.__('In bold:').' '.
[387]447form::checkbox('post_title_w_m',1,$ductile_user['post_title_w_m']).'</label>'.'</p>'.
448
[395]449'<p class="field"><label for="post_title_s_m">'.__('Font size (in em by default):').'</label> '.
450form::field('post_title_s_m',7,7,$ductile_user['post_title_s_m']).'</p>'.
[387]451
[389]452'<p class="field picker"><label for="post_title_c_m">'.__('Color:').'</label> '.
[387]453form::field('post_title_c_m',7,7,$ductile_user['post_title_c_m'],'colorpicker').'</p>'.
454'</fieldset>';
455
456echo '</div>';
457echo '</div>';
458
[390]459echo '<input type="hidden" name="conf_tab" value="css">';
460echo '<p class="clear"><input type="submit" value="'.__('Save').'" />'.$core->formNonce().'</p>';
461echo '</form>';
462
[389]463echo '</div>'; // Close tab
464
[613]465// Legacy mode
466if (!$standalone_config) echo '<form style="display:none">';
467
[628]468dcPage::helpBlock('ductile');
[622]469?>
Note: See TracBrowser for help on using the repository browser.

Sites map