Dotclear

source: admin/blog_pref.php @ 3725:b47f38c701ee

Revision 3725:b47f38c701ee, 37.6 KB checked in by franck <carnet.franck.paul@…>, 7 years ago (diff)

Use specialized input fields (color, email, url, number, …) where is relevant

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
6# Copyright (c) 2003-2013 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 -----------------------------------------
12
13$standalone = !isset($edit_blog_mode);
14
15$blog_id = false;
16
17if ($standalone) {
18    require dirname(__FILE__) . '/../inc/admin/prepend.php';
19    dcPage::check('admin');
20    $blog_id       = $core->blog->id;
21    $blog_status   = $core->blog->status;
22    $blog_name     = $core->blog->name;
23    $blog_desc     = $core->blog->desc;
24    $blog_settings = $core->blog->settings;
25    $blog_url      = $core->blog->url;
26
27    $action = $core->adminurl->get("admin.blog.pref");
28    $redir  = $core->adminurl->get("admin.blog.pref");
29} else {
30    dcPage::checkSuper();
31    try
32    {
33        if (empty($_REQUEST['id'])) {
34            throw new Exception(__('No given blog id.'));
35        }
36        $rs = $core->getBlog($_REQUEST['id']);
37
38        if (!$rs) {
39            throw new Exception(__('No such blog.'));
40        }
41
42        $blog_id       = $rs->blog_id;
43        $blog_status   = $rs->blog_status;
44        $blog_name     = $rs->blog_name;
45        $blog_desc     = $rs->blog_desc;
46        $blog_settings = new dcSettings($core, $blog_id);
47        $blog_url      = $rs->blog_url;
48    } catch (Exception $e) {
49        $core->error->add($e->getMessage());
50    }
51
52    $action = $core->adminurl->get("admin.blog");
53    $redir  = $core->adminurl->get("admin.blog", array('id' => "%s"), '&', true);
54}
55
56# Language codes
57$lang_combo = dcAdminCombos::getAdminLangsCombo();
58
59# Status combo
60$status_combo = dcAdminCombos::getBlogStatusescombo();
61
62# Date format combo
63$now                = time();
64$date_formats       = $blog_settings->system->date_formats;
65$time_formats       = $blog_settings->system->time_formats;
66$date_formats_combo = array('' => '');
67foreach ($date_formats as $format) {
68    $date_formats_combo[dt::str($format, $now)] = $format;
69}
70$time_formats_combo = array('' => '');
71foreach ($time_formats as $format) {
72    $time_formats_combo[dt::str($format, $now)] = $format;
73}
74
75# URL scan modes
76$url_scan_combo = array(
77    'PATH_INFO'    => 'path_info',
78    'QUERY_STRING' => 'query_string'
79);
80
81# Post URL combo
82$post_url_combo = array(
83    __('year/month/day/title') => '{y}/{m}/{d}/{t}',
84    __('year/month/title')     => '{y}/{m}/{t}',
85    __('year/title')           => '{y}/{t}',
86    __('title')                => '{t}',
87    __('post id/title')        => '{id}/{t}',
88    __('post id')              => '{id}'
89);
90if (!in_array($blog_settings->system->post_url_format, $post_url_combo)) {
91    $post_url_combo[html::escapeHTML($blog_settings->system->post_url_format)] = html::escapeHTML($blog_settings->system->post_url_format);
92}
93
94# Note title tag combo
95$note_title_tag_combo = array(
96    __('H4') => 0,
97    __('H3') => 1,
98    __('P')  => 2
99);
100
101# Image title combo
102$img_title_combo = array(
103    __('(none)')                     => '',
104    __('Title')                      => 'Title ;; separator(, )',
105    __('Title, Date')                => 'Title ;; Date(%b %Y) ;; separator(, )',
106    __('Title, Country, Date')       => 'Title ;; Country ;; Date(%b %Y) ;; separator(, )',
107    __('Title, City, Country, Date') => 'Title ;; City ;; Country ;; Date(%b %Y) ;; separator(, )'
108);
109if (!in_array($blog_settings->system->media_img_title_pattern, $img_title_combo)) {
110    $img_title_combo[html::escapeHTML($blog_settings->system->media_img_title_pattern)] = html::escapeHTML($blog_settings->system->media_img_title_pattern);
111}
112
113# Image default size combo
114$img_default_size_combo = array();
115try {
116    $media                                  = new dcMedia($core);
117    $img_default_size_combo[__('original')] = 'o';
118    foreach ($media->thumb_sizes as $code => $size) {
119        $img_default_size_combo[__($size[2])] = $code;
120    }
121} catch (Exception $e) {
122    $core->error->add($e->getMessage());
123}
124
125# Image default alignment combo
126$img_default_alignment_combo = array(
127    __('None')   => 'none',
128    __('Left')   => 'left',
129    __('Right')  => 'right',
130    __('Center') => 'center'
131);
132
133# Image default legend and title combo
134$img_default_legend_combo = array(
135    __('Legend and title') => 'legend',
136    __('Title')            => 'title',
137    __('None')             => 'none'
138);
139
140# Robots policy options
141$robots_policy_options = array(
142    'INDEX,FOLLOW'               => __("I would like search engines and archivers to index and archive my blog's content."),
143    'INDEX,FOLLOW,NOARCHIVE'     => __("I would like search engines and archivers to index but not archive my blog's content."),
144    'NOINDEX,NOFOLLOW,NOARCHIVE' => __("I would like to prevent search engines and archivers from indexing or archiving my blog's content.")
145);
146
147# jQuery available versions
148$jquery_root           = dirname(__FILE__) . '/../inc/js/jquery';
149$jquery_versions_combo = array(__('Default') . ' (' . DC_DEFAULT_JQUERY . ')' => DC_DEFAULT_JQUERY);
150if (is_dir($jquery_root) && is_readable($jquery_root)) {
151    if (($d = @dir($jquery_root)) !== false) {
152        while (($entry = $d->read()) !== false) {
153            if ($entry != '.' && $entry != '..' && substr($entry, 0, 1) != '.' && is_dir($jquery_root . '/' . $entry)) {
154                if ($entry != DC_DEFAULT_JQUERY) {
155                    $jquery_versions_combo[$entry] = $entry;
156                }
157            }
158        }
159    }
160}
161
162# Update a blog
163if ($blog_id && !empty($_POST) && $core->auth->check('admin', $blog_id)) {
164    $cur            = $core->con->openCursor($core->prefix . 'blog');
165    $cur->blog_id   = $_POST['blog_id'];
166    $cur->blog_url  = preg_replace('/\?+$/', '?', $_POST['blog_url']);
167    $cur->blog_name = $_POST['blog_name'];
168    $cur->blog_desc = $_POST['blog_desc'];
169
170    if ($core->auth->isSuperAdmin() && in_array($_POST['blog_status'], $status_combo)) {
171        $cur->blog_status = (int) $_POST['blog_status'];
172    }
173
174    $media_img_t_size = (integer) $_POST['media_img_t_size'];
175    if ($media_img_t_size < 0) {$media_img_t_size = 100;}
176
177    $media_img_s_size = (integer) $_POST['media_img_s_size'];
178    if ($media_img_s_size < 0) {$media_img_s_size = 240;}
179
180    $media_img_m_size = (integer) $_POST['media_img_m_size'];
181    if ($media_img_m_size < 0) {$media_img_m_size = 448;}
182
183    $media_video_width = (integer) $_POST['media_video_width'];
184    if ($media_video_width < 0) {$media_video_width = 400;}
185
186    $media_video_height = (integer) $_POST['media_video_height'];
187    if ($media_video_height < 0) {$media_video_height = 300;}
188
189    $nb_post_for_home = abs((integer) $_POST['nb_post_for_home']);
190    if ($nb_post_for_home < 1) {$nb_post_for_home = 1;}
191
192    $nb_post_per_page = abs((integer) $_POST['nb_post_per_page']);
193    if ($nb_post_per_page < 1) {$nb_post_per_page = 1;}
194
195    $nb_post_per_feed = abs((integer) $_POST['nb_post_per_feed']);
196    if ($nb_post_per_feed < 1) {$nb_post_per_feed = 1;}
197
198    $nb_comment_per_feed = abs((integer) $_POST['nb_comment_per_feed']);
199    if ($nb_comment_per_feed < 1) {$nb_comment_per_feed = 1;}
200
201    try
202    {
203        if ($cur->blog_id != null && $cur->blog_id != $blog_id) {
204            $rs = $core->getBlog($cur->blog_id);
205
206            if ($rs) {
207                throw new Exception(__('This blog ID is already used.'));
208            }
209        }
210
211        # --BEHAVIOR-- adminBeforeBlogUpdate
212        $core->callBehavior('adminBeforeBlogUpdate', $cur, $blog_id);
213
214        if (!preg_match('/^[a-z]{2}(-[a-z]{2})?$/', $_POST['lang'])) {
215            throw new Exception(__('Invalid language code'));
216        }
217
218        $core->updBlog($blog_id, $cur);
219
220        # --BEHAVIOR-- adminAfterBlogUpdate
221        $core->callBehavior('adminAfterBlogUpdate', $cur, $blog_id);
222
223        if ($cur->blog_id != null && $cur->blog_id != $blog_id) {
224            if ($blog_id == $core->blog->id) {
225                $core->setBlog($cur->blog_id);
226                $_SESSION['sess_blog_id'] = $cur->blog_id;
227                $blog_settings            = $core->blog->settings;
228            } else {
229                $blog_settings = new dcSettings($core, $cur->blog_id);
230            }
231
232            $blog_id = $cur->blog_id;
233        }
234
235        $blog_settings->addNameSpace('system');
236
237        $blog_settings->system->put('editor', $_POST['editor']);
238        $blog_settings->system->put('copyright_notice', $_POST['copyright_notice']);
239        $blog_settings->system->put('post_url_format', $_POST['post_url_format']);
240        $blog_settings->system->put('lang', $_POST['lang']);
241        $blog_settings->system->put('blog_timezone', $_POST['blog_timezone']);
242        $blog_settings->system->put('date_format', $_POST['date_format']);
243        $blog_settings->system->put('time_format', $_POST['time_format']);
244        $blog_settings->system->put('comments_ttl', abs((integer) $_POST['comments_ttl']));
245        $blog_settings->system->put('trackbacks_ttl', abs((integer) $_POST['trackbacks_ttl']));
246        $blog_settings->system->put('allow_comments', !empty($_POST['allow_comments']));
247        $blog_settings->system->put('allow_trackbacks', !empty($_POST['allow_trackbacks']));
248        $blog_settings->system->put('comments_pub', empty($_POST['comments_pub']));
249        $blog_settings->system->put('trackbacks_pub', empty($_POST['trackbacks_pub']));
250        $blog_settings->system->put('comments_nofollow', !empty($_POST['comments_nofollow']));
251        $blog_settings->system->put('wiki_comments', !empty($_POST['wiki_comments']));
252        $blog_settings->system->put('comment_preview_optional', !empty($_POST['comment_preview_optional']));
253        $blog_settings->system->put('enable_xmlrpc', !empty($_POST['enable_xmlrpc']));
254        $blog_settings->system->put('note_title_tag', $_POST['note_title_tag']);
255        $blog_settings->system->put('nb_post_for_home', $nb_post_for_home);
256        $blog_settings->system->put('nb_post_per_page', $nb_post_per_page);
257        $blog_settings->system->put('use_smilies', !empty($_POST['use_smilies']));
258        $blog_settings->system->put('no_search', !empty($_POST['no_search']));
259        $blog_settings->system->put('inc_subcats', !empty($_POST['inc_subcats']));
260        $blog_settings->system->put('media_img_t_size', $media_img_t_size);
261        $blog_settings->system->put('media_img_s_size', $media_img_s_size);
262        $blog_settings->system->put('media_img_m_size', $media_img_m_size);
263        $blog_settings->system->put('media_video_width', $media_video_width);
264        $blog_settings->system->put('media_video_height', $media_video_height);
265        $blog_settings->system->put('media_flash_fallback', !empty($_POST['media_flash_fallback']));
266        $blog_settings->system->put('media_img_title_pattern', $_POST['media_img_title_pattern']);
267        $blog_settings->system->put('media_img_use_dto_first', !empty($_POST['media_img_use_dto_first']));
268        $blog_settings->system->put('media_img_no_date_alone', !empty($_POST['media_img_no_date_alone']));
269        $blog_settings->system->put('media_img_default_size', $_POST['media_img_default_size']);
270        $blog_settings->system->put('media_img_default_alignment', $_POST['media_img_default_alignment']);
271        $blog_settings->system->put('media_img_default_link', !empty($_POST['media_img_default_link']));
272        $blog_settings->system->put('media_img_default_legend', $_POST['media_img_default_legend']);
273        $blog_settings->system->put('nb_post_per_feed', $nb_post_per_feed);
274        $blog_settings->system->put('nb_comment_per_feed', $nb_comment_per_feed);
275        $blog_settings->system->put('short_feed_items', !empty($_POST['short_feed_items']));
276        if (isset($_POST['robots_policy'])) {
277            $blog_settings->system->put('robots_policy', $_POST['robots_policy']);
278        }
279        $blog_settings->system->put('jquery_version', $_POST['jquery_version']);
280        $blog_settings->system->put('prevents_clickjacking', !empty($_POST['prevents_clickjacking']));
281
282        # --BEHAVIOR-- adminBeforeBlogSettingsUpdate
283        $core->callBehavior('adminBeforeBlogSettingsUpdate', $blog_settings);
284
285        if ($core->auth->isSuperAdmin() && in_array($_POST['url_scan'], $url_scan_combo)) {
286            $blog_settings->system->put('url_scan', $_POST['url_scan']);
287        }
288        dcPage::addSuccessNotice(__('Blog has been successfully updated.'));
289
290        http::redirect(sprintf($redir, $blog_id));
291    } catch (Exception $e) {
292        $core->error->add($e->getMessage());
293    }
294}
295
296// Display
297
298if ($standalone) {
299    $breadcrumb = dcPage::breadcrumb(
300        array(
301            html::escapeHTML($blog_name) => '',
302            __('Blog settings')          => ''
303        )
304    );
305} else {
306    $breadcrumb = dcPage::breadcrumb(
307        array(
308            __('System')                                               => '',
309            __('Blogs')                                                => $core->adminurl->get("admin.blogs"),
310            __('Blog settings') . ' : ' . html::escapeHTML($blog_name) => ''
311        ));
312}
313
314$desc_editor = $core->auth->getOption('editor');
315$rte_flag    = true;
316$rte_flags   = @$core->auth->user_prefs->interface->rte_flags;
317if (is_array($rte_flags) && in_array('blog_descr', $rte_flags)) {
318    $rte_flag = $rte_flags['blog_descr'];
319}
320
321dcPage::open(__('Blog settings'),
322    '<script type="text/javascript">' . "\n" .
323    dcPage::jsVar('dotclear.msg.warning_path_info',
324        __('Warning: except for special configurations, it is generally advised to have a trailing "/" in your blog URL in PATH_INFO mode.')) . "\n" .
325    dcPage::jsVar('dotclear.msg.warning_query_string',
326        __('Warning: except for special configurations, it is generally advised to have a trailing "?" in your blog URL in QUERY_STRING mode.')) . "\n" .
327    "</script>" .
328    dcPage::jsConfirmClose('blog-form') .
329    ($rte_flag ? $core->callBehavior('adminPostEditor', $desc_editor['xhtml'], 'blog_desc', array('#blog_desc'), 'xhtml') : '') .
330    dcPage::jsLoad('js/_blog_pref.js') .
331
332    # --BEHAVIOR-- adminBlogPreferencesHeaders
333    $core->callBehavior('adminBlogPreferencesHeaders') .
334
335    dcPage::jsPageTabs(),
336    $breadcrumb
337);
338
339if ($blog_id) {
340    if (!empty($_GET['add'])) {
341        dcPage::success(__('Blog has been successfully created.'));
342    }
343
344    if (!empty($_GET['upd'])) {
345        dcPage::success(__('Blog has been successfully updated.'));
346    }
347
348    echo
349    '<div class="multi-part" id="params" title="' . __('Parameters') . '">' .
350    '<h3 class="out-of-screen-if-js">' . __('Parameters') . '</h3>' .
351        '<form action="' . $action . '" method="post" id="blog-form">';
352
353    echo
354    '<div class="fieldset"><h4>' . __('Blog details') . '</h4>' .
355    $core->formNonce();
356
357    echo
358    '<p><label for="blog_name" class="required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Blog name:') . '</label>' .
359    form::field('blog_name', 30, 255,
360        array(
361            'default'    => html::escapeHTML($blog_name),
362            'extra_html' => 'required placeholder="' . __('Blog name') . '"'
363        )
364    ) . '</p>';
365
366    echo
367    '<p class="area"><label for="blog_desc">' . __('Blog description:') . '</label>' .
368    form::textarea('blog_desc', 60, 5, html::escapeHTML($blog_desc)) . '</p>';
369
370    if ($core->auth->isSuperAdmin()) {
371        echo
372        '<p><label for="blog_status">' . __('Blog status:') . '</label>' .
373        form::combo('blog_status', $status_combo, $blog_status) . '</p>';
374
375    } else {
376        /*
377        Only super admins can change the blog ID and URL, but we need to pass
378        their values to the POST request via hidden html input values  so as
379        to allow admins to update other settings.
380        Otherwise dcCore::getBlogCursor() throws an exception.
381         */
382        echo
383        form::hidden('blog_id', html::escapeHTML($blog_id)) .
384        form::hidden('blog_url', html::escapeHTML($blog_url));
385    }
386
387    echo '</div>';
388
389    echo
390    '<div class="fieldset"><h4>' . __('Blog configuration') . '</h4>' .
391
392    '<p><label for="editor">' . __('Blog editor name:') . '</label>' .
393    form::field('editor', 30, 255, html::escapeHTML($blog_settings->system->editor)) .
394    '</p>' .
395
396    '<p><label for="lang">' . __('Default language:') . '</label>' .
397    form::combo('lang', $lang_combo, $blog_settings->system->lang, 'l10n') .
398    '</p>' .
399
400    '<p><label for="blog_timezone">' . __('Blog timezone:') . '</label>' .
401    form::combo('blog_timezone', dt::getZones(true, true), html::escapeHTML($blog_settings->system->blog_timezone)) .
402    '</p>' .
403
404    '<p><label for="copyright_notice">' . __('Copyright notice:') . '</label>' .
405    form::field('copyright_notice', 30, 255, html::escapeHTML($blog_settings->system->copyright_notice)) .
406        '</p>' .
407
408        '</div>';
409
410    echo
411    '<div class="fieldset"><h4>' . __('Comments and trackbacks') . '</h4>' .
412
413    '<div class="two-cols">' .
414
415    '<div class="col">' .
416    '<p><label for="allow_comments" class="classic">' .
417    form::checkbox('allow_comments', '1', $blog_settings->system->allow_comments) .
418    __('Accept comments') . '</label></p>' .
419    '<p><label for="comments_pub" class="classic">' .
420    form::checkbox('comments_pub', '1', !$blog_settings->system->comments_pub) .
421    __('Moderate comments') . '</label></p>' .
422    '<p><label for="comments_ttl" class="classic">' . sprintf(__('Leave comments open for %s days') . '.',
423        form::number('comments_ttl', array(
424            'min'     => 0,
425            'max'     => 999,
426            'default' => $blog_settings->system->comments_ttl)
427        )) .
428    '</label></p>' .
429    '<p class="form-note">' . __('No limit: leave blank.') . '</p>' .
430    '<p><label for="wiki_comments" class="classic">' .
431    form::checkbox('wiki_comments', '1', $blog_settings->system->wiki_comments) .
432    __('Wiki syntax for comments') . '</label></p>' .
433    '<p><label for="comment_preview_optional" class="classic">' .
434    form::checkbox('comment_preview_optional', '1', $blog_settings->system->comment_preview_optional) .
435    __('Preview of comment before submit is not mandatory') . '</label></p>' .
436    '</div>' .
437
438    '<div class="col">' .
439    '<p><label for="allow_trackbacks" class="classic">' .
440    form::checkbox('allow_trackbacks', '1', $blog_settings->system->allow_trackbacks) .
441    __('Accept trackbacks') . '</label></p>' .
442    '<p><label for="trackbacks_pub" class="classic">' .
443    form::checkbox('trackbacks_pub', '1', !$blog_settings->system->trackbacks_pub) .
444    __('Moderate trackbacks') . '</label></p>' .
445    '<p><label for="trackbacks_ttl" class="classic">' . sprintf(__('Leave trackbacks open for %s days') . '.',
446        form::number('trackbacks_ttl', array(
447            'min'     => 0,
448            'max'     => 999,
449            'default' => $blog_settings->system->trackbacks_ttl)
450        )) .
451    '</label></p>' .
452    '<p class="form-note">' . __('No limit: leave blank.') . '</p>' .
453    '<p><label for="comments_nofollow" class="classic">' .
454    form::checkbox('comments_nofollow', '1', $blog_settings->system->comments_nofollow) .
455    __('Add "nofollow" relation on comments and trackbacks links') . '</label></p>' .
456    '</div>' .
457    '<br class="clear" />' . //Opera sucks
458
459    '</div>' .
460    '<br class="clear" />' . //Opera sucks
461    '</div>';
462
463    echo
464    '<div class="fieldset"><h4>' . __('Blog presentation') . '</h4>' .
465    '<div class="two-cols">' .
466    '<div class="col">' .
467    '<p><label for="date_format">' . __('Date format:') . '</label> ' .
468    form::field('date_format', 30, 255, html::escapeHTML($blog_settings->system->date_format)) .
469    form::combo('date_format_select', $date_formats_combo, array('extra_html' => 'title="' . __('Pattern of date') . '"')) .
470    '</p>' .
471    '<p class="chosen form-note">' . __('Sample:') . ' ' . dt::str(html::escapeHTML($blog_settings->system->date_format)) . '</p>' .
472
473    '<p><label for="time_format">' . __('Time format:') . '</label>' .
474    form::field('time_format', 30, 255, html::escapeHTML($blog_settings->system->time_format)) .
475    form::combo('time_format_select', $time_formats_combo, array('extra_html' => 'title="' . __('Pattern of time') . '"')) .
476    '</p>' .
477    '<p class="chosen form-note">' . __('Sample:') . ' ' . dt::str(html::escapeHTML($blog_settings->system->time_format)) . '</p>' .
478
479    '<p><label for="use_smilies" class="classic">' .
480    form::checkbox('use_smilies', '1', $blog_settings->system->use_smilies) .
481    __('Display smilies on entries and comments') . '</label></p>' .
482
483    '<p><label for="no_search" class="classic">' .
484    form::checkbox('no_search', '1', $blog_settings->system->no_search) .
485    __('Disable internal search system') . '</label></p>' .
486    '</div>' .
487
488    '<div class="col">' .
489    '<p><label for="nb_post_for_home" class="classic">' . sprintf(__('Display %s entries on home page'),
490        form::number('nb_post_for_home', array(
491            'min'     => 1,
492            'max'     => 999,
493            'default' => $blog_settings->system->nb_post_for_home)
494        )) .
495    '</label></p>' .
496
497    '<p><label for="nb_post_per_page" class="classic">' . sprintf(__('Display %s entries per page'),
498        form::number('nb_post_per_page', array(
499            'min'     => 1,
500            'max'     => 999,
501            'default' => $blog_settings->system->nb_post_per_page)
502        )) .
503    '</label></p>' .
504
505    '<p><label for="nb_post_per_feed" class="classic">' . sprintf(__('Display %s entries per feed'),
506        form::number('nb_post_per_feed', array(
507            'min'     => 1,
508            'max'     => 999,
509            'default' => $blog_settings->system->nb_post_per_feed)
510        )) .
511    '</label></p>' .
512
513    '<p><label for="nb_comment_per_feed" class="classic">' . sprintf(__('Display %s comments per feed'),
514        form::number('nb_comment_per_feed', array(
515            'min'     => 1,
516            'max'     => 999,
517            'default' => $blog_settings->system->nb_comment_per_feed)
518        )) .
519    '</label></p>' .
520
521    '<p><label for="short_feed_items" class="classic">' .
522    form::checkbox('short_feed_items', '1', $blog_settings->system->short_feed_items) .
523    __('Truncate feeds') . '</label></p>' .
524
525    '<p><label for="inc_subcats" class="classic">' .
526    form::checkbox('inc_subcats', '1', $blog_settings->system->inc_subcats) .
527    __('Include sub-categories in category page and category posts feed') . '</label></p>' .
528    '</div>' .
529    '</div>' .
530    '<br class="clear" />' . //Opera sucks
531    '</div>';
532
533    echo
534    '<div class="fieldset"><h4 id="medias-settings">' . __('Media and images') . '</h4>' .
535    '<p class="form-note warning">' .
536    __('Please note that if you change current settings bellow, they will now apply to all new images in the media manager.') .
537    ' ' . __('Be carefull if you share it with other blogs in your installation.') . '<br />' .
538    __('Set -1 to use the default size, set 0 to ignore this thumbnail size (images only).') . '</p>' .
539
540    '<div class="two-cols">' .
541    '<div class="col">' .
542    '<h5>' . __('Generated image sizes (max dimension in pixels)') . '</h5>' .
543    '<p class="field"><label for="media_img_t_size">' . __('Thumbnail') . '</label> ' .
544    form::number('media_img_t_size', array(
545        'min'     => -1,
546        'max'     => 999,
547        'default' => $blog_settings->system->media_img_t_size
548    )) .
549    '</p>' .
550
551    '<p class="field"><label for="media_img_s_size">' . __('Small') . '</label> ' .
552    form::number('media_img_s_size', array(
553        'min'     => -1,
554        'max'     => 999,
555        'default' => $blog_settings->system->media_img_s_size
556    )) .
557    '</p>' .
558
559    '<p class="field"><label for="media_img_m_size">' . __('Medium') . '</label> ' .
560    form::number('media_img_m_size', array(
561        'min'     => -1,
562        'max'     => 999,
563        'default' => $blog_settings->system->media_img_m_size
564    )) .
565    '</p>' .
566
567    '<h5>' . __('Default size of the inserted video (in pixels)') . '</h5>' .
568    '<p class="field"><label for="media_video_width">' . __('Width') . '</label> ' .
569    form::number('media_video_width', array(
570        'min'     => -1,
571        'max'     => 999,
572        'default' => $blog_settings->system->media_video_width
573    )) .
574    '</p>' .
575
576    '<p class="field"><label for="media_video_height">' . __('Height') . '</label> ' .
577    form::number('media_video_height', array(
578        'min'     => -1,
579        'max'     => 999,
580        'default' => $blog_settings->system->media_video_height
581    )) .
582    '</p>' .
583
584    '<h5>' . __('Flash player') . '</h5>' .
585    '<p><label for="media_flash_fallback">' .
586    form::checkbox('media_flash_fallback', '1', $blog_settings->system->media_flash_fallback) .
587    __('Insert Flash player fallback for video (mp4 or m4v) and audio (mp3) media') . '</label></p>' .
588    '<p class="form-note info">' . __('For flv video, the Flash player will be anyway inserted.') . '</p>' .
589    '</div>' .
590
591    '<div class="col">' .
592    '<h5>' . __('Default image insertion attributes') . '</h5>' .
593    '<p class="vertical-separator"><label for="media_img_title_pattern">' . __('Inserted image title') . '</label>' .
594    form::combo('media_img_title_pattern', $img_title_combo, html::escapeHTML($blog_settings->system->media_img_title_pattern)) . '</p>' .
595    '<p><label for="media_img_use_dto_first" class="classic">' .
596    form::checkbox('media_img_use_dto_first', '1', $blog_settings->system->media_img_use_dto_first) .
597    __('Use original media date if possible') . '</label></p>' .
598    '<p><label for="media_img_no_date_alone" class="classic">' .
599    form::checkbox('media_img_no_date_alone', '1', $blog_settings->system->media_img_no_date_alone) .
600    __('Do not display date if alone in title') . '</label></p>' .
601    '<p class="form-note info">' . __('It is retrieved from the picture\'s metadata.') . '</p>' .
602
603    '<p class="field vertical-separator"><label for="media_img_default_size">' . __('Size of inserted image:') . '</label>' .
604    form::combo('media_img_default_size', $img_default_size_combo,
605        (html::escapeHTML($blog_settings->system->media_img_default_size) != '' ? html::escapeHTML($blog_settings->system->media_img_default_size) : 'm')) .
606    '</p>' .
607    '<p class="field"><label for="media_img_default_alignment">' . __('Image alignment:') . '</label>' .
608    form::combo('media_img_default_alignment', $img_default_alignment_combo, html::escapeHTML($blog_settings->system->media_img_default_alignment)) .
609    '</p>' .
610    '<p><label for="media_img_default_link">' .
611    form::checkbox('media_img_default_link', '1', $blog_settings->system->media_img_default_link) .
612    __('Insert a link to the original image') . '</label></p>' .
613    '<p class="field"><label for="media_img_default_legend">' . __('Image legend and title:') . '</label>' .
614    form::combo('media_img_default_legend', $img_default_legend_combo, html::escapeHTML($blog_settings->system->media_img_default_legend)) .
615    '</p>' .
616    '</div>' .
617    '</div>' .
618    '<br class="clear" />' . //Opera sucks
619
620    '</div>';
621
622    echo '<div id="advanced-pref"><h3>' . __('Advanced parameters') . '</h3>';
623
624    if ($core->auth->isSuperAdmin()) {
625        echo '<div class="fieldset"><h4>' . __('Blog details') . '</h4>';
626        echo
627        '<p><label for="blog_id" class="required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Blog ID:') . '</label>' .
628        form::field('blog_id', 30, 32, html::escapeHTML($blog_id), '', '', false, 'required placeholder="' . __('Blog ID') . '"') . '</p>' .
629        '<p class="form-note">' . __('At least 2 characters using letters, numbers or symbols.') . '</p> ' .
630        '<p class="form-note warn">' . __('Please note that changing your blog ID may require changes in your public index.php file.') . '</p>';
631
632        echo
633        '<p><label for="blog_url" class="required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Blog URL:') . '</label>' .
634        form::url('blog_url', array(
635            'size'       => 50,
636            'max'        => 255,
637            'default'    => html::escapeHTML($blog_url),
638            'extra_html' => 'required placeholder="' . __('Blog URL') . '"'
639        )) .
640        '</p>' .
641
642        '<p><label for="url_scan">' . __('URL scan method:') . '</label>' .
643        form::combo('url_scan', $url_scan_combo, $blog_settings->system->url_scan) . '</p>';
644
645        try
646        {
647            # Test URL of blog by testing it's ATOM feed
648            $file    = $blog_url . $core->url->getURLFor('feed', 'atom');
649            $path    = '';
650            $status  = '404';
651            $content = '';
652
653            $client = netHttp::initClient($file, $path);
654            if ($client !== false) {
655                $client->setTimeout(4);
656                $client->setUserAgent($_SERVER['HTTP_USER_AGENT']);
657                $client->get($path);
658                $status  = $client->getStatus();
659                $content = $client->getContent();
660            }
661            if ($status != '200') {
662                // Might be 404 (URL not found), 670 (blog not online), ...
663                echo
664                '<p class="form-note warn">' .
665                sprintf(__('The URL of blog or the URL scan method might not be well set (<code>%s</code> return a <strong>%s</strong> status).'),
666                    html::escapeHTML($file), $status) .
667                    '</p>';
668            } else {
669                if (substr($content, 0, 6) != '<?xml ') {
670                    // Not well formed XML feed
671                    echo
672                    '<p class="form-note warn">' .
673                    sprintf(__('The URL of blog or the URL scan method might not be well set (<code>%s</code> does not return an ATOM feed).'),
674                        html::escapeHTML($file)) .
675                        '</p>';
676                }
677            }
678        } catch (Exception $e) {
679            $core->error->add($e->getMessage());
680        }
681        echo '</div>';
682    }
683
684    echo
685    '<div class="fieldset"><h4>' . __('Blog configuration') . '</h4>' .
686
687    '<p><label for="post_url_format">' . __('New post URL format:') . '</label>' .
688    form::combo('post_url_format', $post_url_combo, html::escapeHTML($blog_settings->system->post_url_format)) .
689    '</p>' .
690    '<p class="chosen form-note">' . __('Sample:') . ' ' . $core->blog->getPostURL('', date('Y-m-d H:i:00', $now), __('Dotclear'), 42) . '</p>' .
691    '</p>' .
692
693    '<p><label for="note_title_tag">' . __('HTML tag for the title of the notes on the blog:') . '</label>' .
694    form::combo('note_title_tag', $note_title_tag_combo, $blog_settings->system->note_title_tag) .
695    '</p>' .
696
697    '<p><label for="enable_xmlrpc" class="classic">' .
698    form::checkbox('enable_xmlrpc', '1', $blog_settings->system->enable_xmlrpc) .
699    __('Enable XML/RPC interface') . '</label>' . '</p>' .
700    '<p class="form-note info">' . __('XML/RPC interface allows you to edit your blog with an external client.') . '</p>';
701
702    if ($blog_settings->system->enable_xmlrpc) {
703        echo
704        '<p>' . __('XML/RPC interface is active. You should set the following parameters on your XML/RPC client:') . '</p>' .
705        '<ul>' .
706        '<li>' . __('Server URL:') . ' <strong><code>' .
707        sprintf(DC_XMLRPC_URL, $core->blog->url, $core->blog->id) .
708        '</code></strong></li>' .
709        '<li>' . __('Blogging system:') . ' <strong><code>Movable Type</code></strong></li>' .
710        '<li>' . __('User name:') . ' <strong><code>' . $core->auth->userID() . '</code></strong></li>' .
711        '<li>' . __('Password:') . ' <strong><code>&lt;' . __('your password') . '&gt;</code></strong></li>' .
712        '<li>' . __('Blog ID:') . ' <strong><code>1</code></strong></li>' .
713            '</ul>';
714    }
715
716    echo
717        '</div>';
718
719    // Search engines policies
720    echo '<div class="fieldset"><h4>' . __('Search engines robots policy') . '</h4>';
721
722    $i = 0;
723    foreach ($robots_policy_options as $k => $v) {
724        echo '<p><label for="robots_policy-' . $i . '" class="classic">' .
725        form::radio(array('robots_policy', 'robots_policy-' . $i), $k, $blog_settings->system->robots_policy == $k) . ' ' . $v . '</label></p>';
726        $i++;
727    }
728
729    echo '</div>';
730
731    echo '<div class="fieldset"><h4>' . __('jQuery javascript library') . '</h4>' .
732
733    '<p><label for="jquery_version" class="classic">' . __('jQuery version to be loaded for this blog:') . '</label>' . ' ' .
734    form::combo('jquery_version', $jquery_versions_combo, $blog_settings->system->jquery_version) .
735    '</p>' .
736    '<br class="clear" />' . //Opera sucks
737
738    '</div>';
739
740    echo '<div class="fieldset"><h4>' . __('Blog security') . '</h4>' .
741
742    '<p><label for="prevents_clickjacking" class="classic">' .
743    form::checkbox('prevents_clickjacking', '1', $blog_settings->system->prevents_clickjacking) .
744    __('Protect the blog from Clickjacking (see <a href="https://en.wikipedia.org/wiki/Clickjacking">Wikipedia</a>)') . '</label></p>' .
745    '<br class="clear" />' . //Opera sucks
746
747    '</div>';
748
749    echo '</div>'; // End advanced
750
751    echo '<div id="plugins-pref"><h3>' . __('Plugins parameters') . '</h3>';
752
753    # --BEHAVIOR-- adminBlogPreferencesForm
754    $core->callBehavior('adminBlogPreferencesForm', $core, $blog_settings);
755
756    echo '</div>'; // End 3rd party, aka plugins
757
758    echo
759    '<p><input type="submit" accesskey="s" value="' . __('Save') . '" />' .
760        (!$standalone ? form::hidden('id', $blog_id) : '') .
761        '</p>' .
762        '</form>';
763
764    if ($core->auth->isSuperAdmin() && $blog_id != $core->blog->id) {
765        echo
766        '<form action="' . $core->adminurl->get("admin.blog.del") . '" method="post">' .
767        '<p><input type="submit" class="delete" value="' . __('Delete this blog') . '" />' .
768        form::hidden(array('blog_id'), $blog_id) .
769        $core->formNonce() . '</p>' .
770            '</form>';
771    } else {
772        if ($blog_id == $core->blog->id) {
773            echo '<p class="message">' . __('The current blog cannot be deleted.') . '</p>';
774        } else {
775            echo '<p class="message">' . __('Only superadmin can delete a blog.') . '</p>';
776        }
777    }
778
779    echo '</div>';
780
781    #
782    # Users on the blog (with permissions)
783
784    $blog_users = $core->getBlogPermissions($blog_id, $core->auth->isSuperAdmin());
785    $perm_types = $core->auth->getPermissionsTypes();
786
787    echo
788    '<div class="multi-part" id="users" title="' . __('Users') . '">' .
789    '<h3 class="out-of-screen-if-js">' . __('Users on this blog') . '</h3>';
790
791    if (empty($blog_users)) {
792        echo '<p>' . __('No users') . '</p>';
793    } else {
794        if ($core->auth->isSuperAdmin()) {
795            $user_url_p = '<a href="' . $core->adminurl->get("admin.user", array('id' => '%1$s'), '&amp;', true) . '">%1$s</a>';
796        } else {
797            $user_url_p = '%1$s';
798        }
799
800        # Sort users list on user_id key
801        dcUtils::lexicalKeySort($blog_users);
802
803        $post_type       = $core->getPostTypes();
804        $current_blog_id = $core->blog->id;
805        if ($blog_id != $core->blog->id) {
806            $core->setBlog($blog_id);
807        }
808
809        echo '<div>';
810        foreach ($blog_users as $k => $v) {
811            if (count($v['p']) > 0) {
812                echo
813                '<div class="user-perm' . ($v['super'] ? ' user_super' : '') . '">' .
814                '<h4>' . sprintf($user_url_p, html::escapeHTML($k)) .
815                ' (' . html::escapeHTML(dcUtils::getUserCN(
816                    $k, $v['name'], $v['firstname'], $v['displayname']
817                )) . ')</h4>';
818
819                if ($core->auth->isSuperAdmin()) {
820                    echo
821                    '<p>' . __('Email:') . ' ' .
822                        ($v['email'] != '' ? '<a href="mailto:' . $v['email'] . '">' . $v['email'] . '</a>' : __('(none)')) .
823                        '</p>';
824                }
825
826                echo
827                '<h5>' . __('Publications on this blog:') . '</h5>' .
828                    '<ul>';
829                foreach ($post_type as $type => $pt_info) {
830                    $params = array(
831                        'post_type' => $type,
832                        'user_id'   => $k
833                    );
834                    echo '<li>' . sprintf(__('%1$s: %2$s'), __($pt_info['label']), $core->blog->getPosts($params, true)->f(0)) . '</li>';
835                }
836                echo
837                    '</ul>';
838
839                echo
840                '<h5>' . __('Permissions:') . '</h5>' .
841                    '<ul>';
842                if ($v['super']) {
843                    echo '<li class="user_super">' . __('Super administrator') . '<br />' .
844                    '<span class="form-note">' . __('All rights on all blogs.') . '</span></li>';
845                } else {
846                    foreach ($v['p'] as $p => $V) {
847                        if (isset($perm_types[$p])) {
848                            echo '<li ' . ($p == 'admin' ? 'class="user_admin"' : '') . '>' . __($perm_types[$p]);
849                        } else {
850                            echo '<li>' . sprintf(__('[%s] (unreferenced permission)'), $p);
851                        }
852
853                        if ($p == 'admin') {
854                            echo '<br /><span class="form-note">' . __('All rights on this blog.') . '</span>';
855                        }
856                        echo '</li>';
857                    }
858                }
859                echo
860                    '</ul>';
861
862                if (!$v['super'] && $core->auth->isSuperAdmin()) {
863                    echo
864                    '<form action="' . $core->adminurl->get('admin.user.actions') . '" method="post">' .
865                    '<p class="change-user-perm"><input type="submit" class="reset" value="' . __('Change permissions') . '" />' .
866                    form::hidden(array('redir'), $core->adminurl->get("admin.blog.pref", array('id' => $k), '&')) .
867                    form::hidden(array('action'), 'perms') .
868                    form::hidden(array('users[]'), $k) .
869                    form::hidden(array('blogs[]'), $blog_id) .
870                    $core->formNonce() .
871                        '</p>' .
872                        '</form>';
873                }
874                echo '</div>';
875            }
876        }
877        echo '</div>';
878        if ($current_blog_id != $core->blog->id) {
879            $core->setBlog($current_blog_id);
880        }
881    }
882
883    echo '</div>';
884}
885
886dcPage::helpBlock('core_blog_pref');
887dcPage::close();
Note: See TracBrowser for help on using the repository browser.

Sites map