Dotclear

source: themes/ductile/_config.php @ 612:abde022052b4

Revision 612:abde022052b4, 15.5 KB checked in by Franck <carnet.franck.paul@…>, 14 years ago (diff)

Ajout d'un lien vers l'admin du plugin simpleMenu s'il est présent et actif

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

Sites map