Dotclear

source: admin/blog_pref.php @ 3982:2e148694914d

Revision 3982:2e148694914d, 36.9 KB checked in by franck <carnet.franck.paul@…>, 6 years ago (diff)

Switching from inline JS variables to JSON script, blog parameters page

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

Sites map