Dotclear

source: admin/blog_pref.php @ 3898:a9b1e7de8211

Revision 3898:a9b1e7de8211, 37.5 KB checked in by franck <carnet.franck.paul@…>, 7 years ago (diff)

Add spellcheck="true" attribute on input/textarea

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_flash_fallback', !empty($_POST['media_flash_fallback']));
263        $blog_settings->system->put('media_img_title_pattern', $_POST['media_img_title_pattern']);
264        $blog_settings->system->put('media_img_use_dto_first', !empty($_POST['media_img_use_dto_first']));
265        $blog_settings->system->put('media_img_no_date_alone', !empty($_POST['media_img_no_date_alone']));
266        $blog_settings->system->put('media_img_default_size', $_POST['media_img_default_size']);
267        $blog_settings->system->put('media_img_default_alignment', $_POST['media_img_default_alignment']);
268        $blog_settings->system->put('media_img_default_link', !empty($_POST['media_img_default_link']));
269        $blog_settings->system->put('media_img_default_legend', $_POST['media_img_default_legend']);
270        $blog_settings->system->put('nb_post_per_feed', $nb_post_per_feed);
271        $blog_settings->system->put('nb_comment_per_feed', $nb_comment_per_feed);
272        $blog_settings->system->put('short_feed_items', !empty($_POST['short_feed_items']));
273        if (isset($_POST['robots_policy'])) {
274            $blog_settings->system->put('robots_policy', $_POST['robots_policy']);
275        }
276        $blog_settings->system->put('jquery_version', $_POST['jquery_version']);
277        $blog_settings->system->put('prevents_clickjacking', !empty($_POST['prevents_clickjacking']));
[2566]278
[3703]279        # --BEHAVIOR-- adminBeforeBlogSettingsUpdate
280        $core->callBehavior('adminBeforeBlogSettingsUpdate', $blog_settings);
[2566]281
[3703]282        if ($core->auth->isSuperAdmin() && in_array($_POST['url_scan'], $url_scan_combo)) {
283            $blog_settings->system->put('url_scan', $_POST['url_scan']);
284        }
285        dcPage::addSuccessNotice(__('Blog has been successfully updated.'));
[2566]286
[3703]287        http::redirect(sprintf($redir, $blog_id));
288    } catch (Exception $e) {
289        $core->error->add($e->getMessage());
290    }
[0]291}
292
[3444]293// Display
294
[1358]295if ($standalone) {
[3703]296    $breadcrumb = dcPage::breadcrumb(
[3874]297        [
[3703]298            html::escapeHTML($blog_name) => '',
299            __('Blog settings')          => ''
[3874]300        ]
[3703]301    );
[1358]302} else {
[3703]303    $breadcrumb = dcPage::breadcrumb(
[3874]304        [
[3703]305            __('System')                                               => '',
306            __('Blogs')                                                => $core->adminurl->get("admin.blogs"),
307            __('Blog settings') . ' : ' . html::escapeHTML($blog_name) => ''
[3874]308        ]);
[1358]309}
310
[3227]311$desc_editor = $core->auth->getOption('editor');
[3703]312$rte_flag    = true;
313$rte_flags   = @$core->auth->user_prefs->interface->rte_flags;
314if (is_array($rte_flags) && in_array('blog_descr', $rte_flags)) {
315    $rte_flag = $rte_flags['blog_descr'];
[3330]316}
[3227]317
[0]318dcPage::open(__('Blog settings'),
[3703]319    '<script type="text/javascript">' . "\n" .
320    dcPage::jsVar('dotclear.msg.warning_path_info',
321        __('Warning: except for special configurations, it is generally advised to have a trailing "/" in your blog URL in PATH_INFO mode.')) . "\n" .
322    dcPage::jsVar('dotclear.msg.warning_query_string',
323        __('Warning: except for special configurations, it is generally advised to have a trailing "?" in your blog URL in QUERY_STRING mode.')) . "\n" .
324    "</script>" .
325    dcPage::jsConfirmClose('blog-form') .
[3874]326    ($rte_flag ? $core->callBehavior('adminPostEditor', $desc_editor['xhtml'], 'blog_desc', ['#blog_desc'], 'xhtml') : '') .
[3703]327    dcPage::jsLoad('js/_blog_pref.js') .
[2566]328
[3703]329    # --BEHAVIOR-- adminBlogPreferencesHeaders
330    $core->callBehavior('adminBlogPreferencesHeaders') .
[2566]331
[3703]332    dcPage::jsPageTabs(),
333    $breadcrumb
[0]334);
335
[3703]336if ($blog_id) {
337    if (!empty($_GET['add'])) {
338        dcPage::success(__('Blog has been successfully created.'));
339    }
[2566]340
[3703]341    if (!empty($_GET['upd'])) {
342        dcPage::success(__('Blog has been successfully updated.'));
343    }
[2566]344
[3703]345    echo
346    '<div class="multi-part" id="params" title="' . __('Parameters') . '">' .
[3851]347    '<div id="standard-pref"><h3>' . __('Blog parameters') . '</h3>' .
[3703]348        '<form action="' . $action . '" method="post" id="blog-form">';
[2566]349
[3703]350    echo
351    '<div class="fieldset"><h4>' . __('Blog details') . '</h4>' .
352    $core->formNonce();
[2566]353
[3703]354    echo
355    '<p><label for="blog_name" class="required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Blog name:') . '</label>' .
[3725]356    form::field('blog_name', 30, 255,
[3874]357        [
[3725]358            'default'    => html::escapeHTML($blog_name),
[3898]359            'extra_html' => 'required placeholder="' . __('Blog name') . ' lang="' . $blog_settings->system->lang .
360                '" spellcheck="true"'
[3874]361        ]
[3725]362    ) . '</p>';
[3444]363
[3703]364    echo
365    '<p class="area"><label for="blog_desc">' . __('Blog description:') . '</label>' .
[3898]366    form::textarea('blog_desc', 60, 5,
367        [
368            'default'    => html::escapeHTML($blog_desc),
369            'extra_html' => 'lang="' . $blog_settings->system->lang . '" spellcheck="true"'
370        ]) . '</p>';
[3444]371
[3703]372    if ($core->auth->isSuperAdmin()) {
373        echo
374        '<p><label for="blog_status">' . __('Blog status:') . '</label>' .
375        form::combo('blog_status', $status_combo, $blog_status) . '</p>';
[3444]376
[3703]377    } else {
378        /*
379        Only super admins can change the blog ID and URL, but we need to pass
380        their values to the POST request via hidden html input values  so as
381        to allow admins to update other settings.
382        Otherwise dcCore::getBlogCursor() throws an exception.
383         */
[3725]384        echo
385        form::hidden('blog_id', html::escapeHTML($blog_id)) .
386        form::hidden('blog_url', html::escapeHTML($blog_url));
[3703]387    }
[2566]388
[3703]389    echo '</div>';
[2566]390
[3703]391    echo
392    '<div class="fieldset"><h4>' . __('Blog configuration') . '</h4>' .
[3444]393
[3703]394    '<p><label for="editor">' . __('Blog editor name:') . '</label>' .
395    form::field('editor', 30, 255, html::escapeHTML($blog_settings->system->editor)) .
396    '</p>' .
[2566]397
[3703]398    '<p><label for="lang">' . __('Default language:') . '</label>' .
399    form::combo('lang', $lang_combo, $blog_settings->system->lang, 'l10n') .
400    '</p>' .
[2566]401
[3703]402    '<p><label for="blog_timezone">' . __('Blog timezone:') . '</label>' .
403    form::combo('blog_timezone', dt::getZones(true, true), html::escapeHTML($blog_settings->system->blog_timezone)) .
404    '</p>' .
[970]405
[3703]406    '<p><label for="copyright_notice">' . __('Copyright notice:') . '</label>' .
[3898]407    form::field('copyright_notice', 30, 255,
408        [
409            'default'    => html::escapeHTML($blog_settings->system->copyright_notice),
410            'extra_html' => 'lang="' . $blog_settings->system->lang . '" spellcheck="true"'
411        ]) .
[3703]412        '</p>' .
[2566]413
[3703]414        '</div>';
[2566]415
[3703]416    echo
417    '<div class="fieldset"><h4>' . __('Comments and trackbacks') . '</h4>' .
[1499]418
[3703]419    '<div class="two-cols">' .
[1499]420
[3703]421    '<div class="col">' .
422    '<p><label for="allow_comments" class="classic">' .
423    form::checkbox('allow_comments', '1', $blog_settings->system->allow_comments) .
424    __('Accept comments') . '</label></p>' .
425    '<p><label for="comments_pub" class="classic">' .
426    form::checkbox('comments_pub', '1', !$blog_settings->system->comments_pub) .
427    __('Moderate comments') . '</label></p>' .
428    '<p><label for="comments_ttl" class="classic">' . sprintf(__('Leave comments open for %s days') . '.',
[3874]429        form::number('comments_ttl', [
[3725]430            'min'     => 0,
431            'max'     => 999,
[3874]432            'default' => $blog_settings->system->comments_ttl]
[3725]433        )) .
[3703]434    '</label></p>' .
435    '<p class="form-note">' . __('No limit: leave blank.') . '</p>' .
436    '<p><label for="wiki_comments" class="classic">' .
437    form::checkbox('wiki_comments', '1', $blog_settings->system->wiki_comments) .
438    __('Wiki syntax for comments') . '</label></p>' .
439    '<p><label for="comment_preview_optional" class="classic">' .
440    form::checkbox('comment_preview_optional', '1', $blog_settings->system->comment_preview_optional) .
441    __('Preview of comment before submit is not mandatory') . '</label></p>' .
442    '</div>' .
[2566]443
[3703]444    '<div class="col">' .
445    '<p><label for="allow_trackbacks" class="classic">' .
446    form::checkbox('allow_trackbacks', '1', $blog_settings->system->allow_trackbacks) .
447    __('Accept trackbacks') . '</label></p>' .
448    '<p><label for="trackbacks_pub" class="classic">' .
449    form::checkbox('trackbacks_pub', '1', !$blog_settings->system->trackbacks_pub) .
450    __('Moderate trackbacks') . '</label></p>' .
451    '<p><label for="trackbacks_ttl" class="classic">' . sprintf(__('Leave trackbacks open for %s days') . '.',
[3874]452        form::number('trackbacks_ttl', [
[3725]453            'min'     => 0,
454            'max'     => 999,
[3874]455            'default' => $blog_settings->system->trackbacks_ttl]
[3725]456        )) .
457    '</label></p>' .
[3703]458    '<p class="form-note">' . __('No limit: leave blank.') . '</p>' .
459    '<p><label for="comments_nofollow" class="classic">' .
460    form::checkbox('comments_nofollow', '1', $blog_settings->system->comments_nofollow) .
461    __('Add "nofollow" relation on comments and trackbacks links') . '</label></p>' .
462    '</div>' .
463    '<br class="clear" />' . //Opera sucks
[1499]464
[3703]465    '</div>' .
466    '<br class="clear" />' . //Opera sucks
467    '</div>';
[2566]468
[3703]469    echo
470    '<div class="fieldset"><h4>' . __('Blog presentation') . '</h4>' .
471    '<div class="two-cols">' .
472    '<div class="col">' .
473    '<p><label for="date_format">' . __('Date format:') . '</label> ' .
474    form::field('date_format', 30, 255, html::escapeHTML($blog_settings->system->date_format)) .
[3874]475    form::combo('date_format_select', $date_formats_combo, ['extra_html' => 'title="' . __('Pattern of date') . '"']) .
[3703]476    '</p>' .
477    '<p class="chosen form-note">' . __('Sample:') . ' ' . dt::str(html::escapeHTML($blog_settings->system->date_format)) . '</p>' .
[2019]478
[3703]479    '<p><label for="time_format">' . __('Time format:') . '</label>' .
480    form::field('time_format', 30, 255, html::escapeHTML($blog_settings->system->time_format)) .
[3874]481    form::combo('time_format_select', $time_formats_combo, ['extra_html' => 'title="' . __('Pattern of time') . '"']) .
[3703]482    '</p>' .
483    '<p class="chosen form-note">' . __('Sample:') . ' ' . dt::str(html::escapeHTML($blog_settings->system->time_format)) . '</p>' .
[2566]484
[3703]485    '<p><label for="use_smilies" class="classic">' .
486    form::checkbox('use_smilies', '1', $blog_settings->system->use_smilies) .
487    __('Display smilies on entries and comments') . '</label></p>' .
[3030]488
[3703]489    '<p><label for="no_search" class="classic">' .
490    form::checkbox('no_search', '1', $blog_settings->system->no_search) .
491    __('Disable internal search system') . '</label></p>' .
492    '</div>' .
[2566]493
[3703]494    '<div class="col">' .
495    '<p><label for="nb_post_for_home" class="classic">' . sprintf(__('Display %s entries on home page'),
[3874]496        form::number('nb_post_for_home', [
[3725]497            'min'     => 1,
498            'max'     => 999,
[3874]499            'default' => $blog_settings->system->nb_post_for_home]
[3725]500        )) .
[3703]501    '</label></p>' .
[2577]502
[3703]503    '<p><label for="nb_post_per_page" class="classic">' . sprintf(__('Display %s entries per page'),
[3874]504        form::number('nb_post_per_page', [
[3725]505            'min'     => 1,
506            'max'     => 999,
[3874]507            'default' => $blog_settings->system->nb_post_per_page]
[3725]508        )) .
[3703]509    '</label></p>' .
[2566]510
[3703]511    '<p><label for="nb_post_per_feed" class="classic">' . sprintf(__('Display %s entries per feed'),
[3874]512        form::number('nb_post_per_feed', [
[3725]513            'min'     => 1,
514            'max'     => 999,
[3874]515            'default' => $blog_settings->system->nb_post_per_feed]
[3725]516        )) .
[3703]517    '</label></p>' .
[2566]518
[3703]519    '<p><label for="nb_comment_per_feed" class="classic">' . sprintf(__('Display %s comments per feed'),
[3874]520        form::number('nb_comment_per_feed', [
[3725]521            'min'     => 1,
522            'max'     => 999,
[3874]523            'default' => $blog_settings->system->nb_comment_per_feed]
[3725]524        )) .
[3703]525    '</label></p>' .
[2566]526
[3703]527    '<p><label for="short_feed_items" class="classic">' .
528    form::checkbox('short_feed_items', '1', $blog_settings->system->short_feed_items) .
529    __('Truncate feeds') . '</label></p>' .
[2566]530
[3703]531    '<p><label for="inc_subcats" class="classic">' .
532    form::checkbox('inc_subcats', '1', $blog_settings->system->inc_subcats) .
533    __('Include sub-categories in category page and category posts feed') . '</label></p>' .
534    '</div>' .
535    '</div>' .
536    '<br class="clear" />' . //Opera sucks
537    '</div>';
[2566]538
[3703]539    echo
540    '<div class="fieldset"><h4 id="medias-settings">' . __('Media and images') . '</h4>' .
541    '<p class="form-note warning">' .
542    __('Please note that if you change current settings bellow, they will now apply to all new images in the media manager.') .
[3725]543    ' ' . __('Be carefull if you share it with other blogs in your installation.') . '<br />' .
544    __('Set -1 to use the default size, set 0 to ignore this thumbnail size (images only).') . '</p>' .
[1979]545
[3703]546    '<div class="two-cols">' .
547    '<div class="col">' .
548    '<h5>' . __('Generated image sizes (max dimension in pixels)') . '</h5>' .
549    '<p class="field"><label for="media_img_t_size">' . __('Thumbnail') . '</label> ' .
[3874]550    form::number('media_img_t_size', [
[3725]551        'min'     => -1,
552        'max'     => 999,
553        'default' => $blog_settings->system->media_img_t_size
[3874]554    ]) .
[3725]555    '</p>' .
[2566]556
[3703]557    '<p class="field"><label for="media_img_s_size">' . __('Small') . '</label> ' .
[3874]558    form::number('media_img_s_size', [
[3725]559        'min'     => -1,
560        'max'     => 999,
561        'default' => $blog_settings->system->media_img_s_size
[3874]562    ]) .
[3725]563    '</p>' .
[2566]564
[3703]565    '<p class="field"><label for="media_img_m_size">' . __('Medium') . '</label> ' .
[3874]566    form::number('media_img_m_size', [
[3725]567        'min'     => -1,
568        'max'     => 999,
569        'default' => $blog_settings->system->media_img_m_size
[3874]570    ]) .
[3725]571    '</p>' .
[3112]572
[3703]573    '<h5>' . __('Default size of the inserted video (in pixels)') . '</h5>' .
574    '<p class="field"><label for="media_video_width">' . __('Width') . '</label> ' .
[3874]575    form::number('media_video_width', [
[3725]576        'min'     => -1,
577        'max'     => 999,
578        'default' => $blog_settings->system->media_video_width
[3874]579    ]) .
[3725]580    '</p>' .
[3112]581
[3703]582    '<p class="field"><label for="media_video_height">' . __('Height') . '</label> ' .
[3874]583    form::number('media_video_height', [
[3725]584        'min'     => -1,
585        'max'     => 999,
586        'default' => $blog_settings->system->media_video_height
[3874]587    ]) .
[3725]588    '</p>' .
[3138]589
[3703]590    '<h5>' . __('Flash player') . '</h5>' .
591    '<p><label for="media_flash_fallback">' .
592    form::checkbox('media_flash_fallback', '1', $blog_settings->system->media_flash_fallback) .
593    __('Insert Flash player fallback for video (mp4 or m4v) and audio (mp3) media') . '</label></p>' .
594    '<p class="form-note info">' . __('For flv video, the Flash player will be anyway inserted.') . '</p>' .
595    '</div>' .
[2566]596
[3703]597    '<div class="col">' .
598    '<h5>' . __('Default image insertion attributes') . '</h5>' .
599    '<p class="vertical-separator"><label for="media_img_title_pattern">' . __('Inserted image title') . '</label>' .
600    form::combo('media_img_title_pattern', $img_title_combo, html::escapeHTML($blog_settings->system->media_img_title_pattern)) . '</p>' .
601    '<p><label for="media_img_use_dto_first" class="classic">' .
602    form::checkbox('media_img_use_dto_first', '1', $blog_settings->system->media_img_use_dto_first) .
603    __('Use original media date if possible') . '</label></p>' .
604    '<p><label for="media_img_no_date_alone" class="classic">' .
605    form::checkbox('media_img_no_date_alone', '1', $blog_settings->system->media_img_no_date_alone) .
606    __('Do not display date if alone in title') . '</label></p>' .
607    '<p class="form-note info">' . __('It is retrieved from the picture\'s metadata.') . '</p>' .
[887]608
[3703]609    '<p class="field vertical-separator"><label for="media_img_default_size">' . __('Size of inserted image:') . '</label>' .
610    form::combo('media_img_default_size', $img_default_size_combo,
611        (html::escapeHTML($blog_settings->system->media_img_default_size) != '' ? html::escapeHTML($blog_settings->system->media_img_default_size) : 'm')) .
612    '</p>' .
613    '<p class="field"><label for="media_img_default_alignment">' . __('Image alignment:') . '</label>' .
614    form::combo('media_img_default_alignment', $img_default_alignment_combo, html::escapeHTML($blog_settings->system->media_img_default_alignment)) .
615    '</p>' .
616    '<p><label for="media_img_default_link">' .
617    form::checkbox('media_img_default_link', '1', $blog_settings->system->media_img_default_link) .
618    __('Insert a link to the original image') . '</label></p>' .
619    '<p class="field"><label for="media_img_default_legend">' . __('Image legend and title:') . '</label>' .
620    form::combo('media_img_default_legend', $img_default_legend_combo, html::escapeHTML($blog_settings->system->media_img_default_legend)) .
621    '</p>' .
622    '</div>' .
623    '</div>' .
624    '<br class="clear" />' . //Opera sucks
[887]625
[3851]626    '</div>' .
[3898]627        '</div>';
[2566]628
[3703]629    echo '<div id="advanced-pref"><h3>' . __('Advanced parameters') . '</h3>';
[3444]630
[3703]631    if ($core->auth->isSuperAdmin()) {
632        echo '<div class="fieldset"><h4>' . __('Blog details') . '</h4>';
633        echo
634        '<p><label for="blog_id" class="required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Blog ID:') . '</label>' .
635        form::field('blog_id', 30, 32, html::escapeHTML($blog_id), '', '', false, 'required placeholder="' . __('Blog ID') . '"') . '</p>' .
636        '<p class="form-note">' . __('At least 2 characters using letters, numbers or symbols.') . '</p> ' .
637        '<p class="form-note warn">' . __('Please note that changing your blog ID may require changes in your public index.php file.') . '</p>';
[3444]638
[3703]639        echo
640        '<p><label for="blog_url" class="required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Blog URL:') . '</label>' .
[3874]641        form::url('blog_url', [
[3725]642            'size'       => 50,
643            'max'        => 255,
644            'default'    => html::escapeHTML($blog_url),
645            'extra_html' => 'required placeholder="' . __('Blog URL') . '"'
[3874]646        ]) .
[3725]647        '</p>' .
[3444]648
[3703]649        '<p><label for="url_scan">' . __('URL scan method:') . '</label>' .
650        form::combo('url_scan', $url_scan_combo, $blog_settings->system->url_scan) . '</p>';
[3444]651
[3703]652        try
653        {
654            # Test URL of blog by testing it's ATOM feed
655            $file    = $blog_url . $core->url->getURLFor('feed', 'atom');
656            $path    = '';
657            $status  = '404';
658            $content = '';
[3444]659
[3703]660            $client = netHttp::initClient($file, $path);
661            if ($client !== false) {
662                $client->setTimeout(4);
663                $client->setUserAgent($_SERVER['HTTP_USER_AGENT']);
664                $client->get($path);
665                $status  = $client->getStatus();
666                $content = $client->getContent();
667            }
668            if ($status != '200') {
669                // Might be 404 (URL not found), 670 (blog not online), ...
670                echo
671                '<p class="form-note warn">' .
672                sprintf(__('The URL of blog or the URL scan method might not be well set (<code>%s</code> return a <strong>%s</strong> status).'),
673                    html::escapeHTML($file), $status) .
674                    '</p>';
675            } else {
676                if (substr($content, 0, 6) != '<?xml ') {
677                    // Not well formed XML feed
678                    echo
679                    '<p class="form-note warn">' .
680                    sprintf(__('The URL of blog or the URL scan method might not be well set (<code>%s</code> does not return an ATOM feed).'),
681                        html::escapeHTML($file)) .
682                        '</p>';
683                }
684            }
685        } catch (Exception $e) {
686            $core->error->add($e->getMessage());
687        }
688        echo '</div>';
689    }
[3444]690
[3703]691    echo
692    '<div class="fieldset"><h4>' . __('Blog configuration') . '</h4>' .
[3444]693
[3703]694    '<p><label for="post_url_format">' . __('New post URL format:') . '</label>' .
695    form::combo('post_url_format', $post_url_combo, html::escapeHTML($blog_settings->system->post_url_format)) .
696    '</p>' .
697    '<p class="chosen form-note">' . __('Sample:') . ' ' . $core->blog->getPostURL('', date('Y-m-d H:i:00', $now), __('Dotclear'), 42) . '</p>' .
698    '</p>' .
[3444]699
[3703]700    '<p><label for="note_title_tag">' . __('HTML tag for the title of the notes on the blog:') . '</label>' .
701    form::combo('note_title_tag', $note_title_tag_combo, $blog_settings->system->note_title_tag) .
702    '</p>' .
[3444]703
[3703]704    '<p><label for="enable_xmlrpc" class="classic">' .
705    form::checkbox('enable_xmlrpc', '1', $blog_settings->system->enable_xmlrpc) .
706    __('Enable XML/RPC interface') . '</label>' . '</p>' .
707    '<p class="form-note info">' . __('XML/RPC interface allows you to edit your blog with an external client.') . '</p>';
[3444]708
[3703]709    if ($blog_settings->system->enable_xmlrpc) {
710        echo
711        '<p>' . __('XML/RPC interface is active. You should set the following parameters on your XML/RPC client:') . '</p>' .
712        '<ul>' .
713        '<li>' . __('Server URL:') . ' <strong><code>' .
714        sprintf(DC_XMLRPC_URL, $core->blog->url, $core->blog->id) .
715        '</code></strong></li>' .
716        '<li>' . __('Blogging system:') . ' <strong><code>Movable Type</code></strong></li>' .
717        '<li>' . __('User name:') . ' <strong><code>' . $core->auth->userID() . '</code></strong></li>' .
718        '<li>' . __('Password:') . ' <strong><code>&lt;' . __('your password') . '&gt;</code></strong></li>' .
719        '<li>' . __('Blog ID:') . ' <strong><code>1</code></strong></li>' .
720            '</ul>';
721    }
[3444]722
[3703]723    echo
724        '</div>';
[3444]725
[3703]726    // Search engines policies
727    echo '<div class="fieldset"><h4>' . __('Search engines robots policy') . '</h4>';
[2566]728
[3703]729    $i = 0;
730    foreach ($robots_policy_options as $k => $v) {
731        echo '<p><label for="robots_policy-' . $i . '" class="classic">' .
[3874]732        form::radio(['robots_policy', 'robots_policy-' . $i], $k, $blog_settings->system->robots_policy == $k) . ' ' . $v . '</label></p>';
[3703]733        $i++;
734    }
[2566]735
[3703]736    echo '</div>';
[2566]737
[3703]738    echo '<div class="fieldset"><h4>' . __('jQuery javascript library') . '</h4>' .
[3444]739
[3703]740    '<p><label for="jquery_version" class="classic">' . __('jQuery version to be loaded for this blog:') . '</label>' . ' ' .
741    form::combo('jquery_version', $jquery_versions_combo, $blog_settings->system->jquery_version) .
742    '</p>' .
743    '<br class="clear" />' . //Opera sucks
[3444]744
[3703]745    '</div>';
[2800]746
[3703]747    echo '<div class="fieldset"><h4>' . __('Blog security') . '</h4>' .
[3444]748
[3703]749    '<p><label for="prevents_clickjacking" class="classic">' .
750    form::checkbox('prevents_clickjacking', '1', $blog_settings->system->prevents_clickjacking) .
751    __('Protect the blog from Clickjacking (see <a href="https://en.wikipedia.org/wiki/Clickjacking">Wikipedia</a>)') . '</label></p>' .
752    '<br class="clear" />' . //Opera sucks
[3444]753
[3703]754    '</div>';
[2566]755
[3703]756    echo '</div>'; // End advanced
[3444]757
[3703]758    echo '<div id="plugins-pref"><h3>' . __('Plugins parameters') . '</h3>';
[3444]759
[3703]760    # --BEHAVIOR-- adminBlogPreferencesForm
761    $core->callBehavior('adminBlogPreferencesForm', $core, $blog_settings);
[2566]762
[3703]763    echo '</div>'; // End 3rd party, aka plugins
[3444]764
[3703]765    echo
766    '<p><input type="submit" accesskey="s" value="' . __('Save') . '" />' .
767        (!$standalone ? form::hidden('id', $blog_id) : '') .
768        '</p>' .
769        '</form>';
[2566]770
[3703]771    if ($core->auth->isSuperAdmin() && $blog_id != $core->blog->id) {
772        echo
773        '<form action="' . $core->adminurl->get("admin.blog.del") . '" method="post">' .
774        '<p><input type="submit" class="delete" value="' . __('Delete this blog') . '" />' .
[3874]775        form::hidden(['blog_id'], $blog_id) .
[3703]776        $core->formNonce() . '</p>' .
777            '</form>';
778    } else {
779        if ($blog_id == $core->blog->id) {
780            echo '<p class="message">' . __('The current blog cannot be deleted.') . '</p>';
781        } else {
782            echo '<p class="message">' . __('Only superadmin can delete a blog.') . '</p>';
783        }
784    }
[2566]785
[3703]786    echo '</div>';
[2566]787
[3703]788    #
789    # Users on the blog (with permissions)
[2566]790
[3703]791    $blog_users = $core->getBlogPermissions($blog_id, $core->auth->isSuperAdmin());
792    $perm_types = $core->auth->getPermissionsTypes();
[2566]793
[3703]794    echo
795    '<div class="multi-part" id="users" title="' . __('Users') . '">' .
796    '<h3 class="out-of-screen-if-js">' . __('Users on this blog') . '</h3>';
[2566]797
[3703]798    if (empty($blog_users)) {
799        echo '<p>' . __('No users') . '</p>';
800    } else {
801        if ($core->auth->isSuperAdmin()) {
[3874]802            $user_url_p = '<a href="' . $core->adminurl->get("admin.user", ['id' => '%1$s'], '&amp;', true) . '">%1$s</a>';
[3703]803        } else {
804            $user_url_p = '%1$s';
805        }
[1696]806
[3703]807        # Sort users list on user_id key
808        dcUtils::lexicalKeySort($blog_users);
[1696]809
[3703]810        $post_type       = $core->getPostTypes();
811        $current_blog_id = $core->blog->id;
812        if ($blog_id != $core->blog->id) {
813            $core->setBlog($blog_id);
814        }
[1694]815
[3703]816        echo '<div>';
817        foreach ($blog_users as $k => $v) {
818            if (count($v['p']) > 0) {
819                echo
820                '<div class="user-perm' . ($v['super'] ? ' user_super' : '') . '">' .
821                '<h4>' . sprintf($user_url_p, html::escapeHTML($k)) .
822                ' (' . html::escapeHTML(dcUtils::getUserCN(
823                    $k, $v['name'], $v['firstname'], $v['displayname']
824                )) . ')</h4>';
[1698]825
[3703]826                if ($core->auth->isSuperAdmin()) {
827                    echo
828                    '<p>' . __('Email:') . ' ' .
829                        ($v['email'] != '' ? '<a href="mailto:' . $v['email'] . '">' . $v['email'] . '</a>' : __('(none)')) .
830                        '</p>';
831                }
[1698]832
[3703]833                echo
834                '<h5>' . __('Publications on this blog:') . '</h5>' .
835                    '<ul>';
836                foreach ($post_type as $type => $pt_info) {
[3874]837                    $params = [
[3703]838                        'post_type' => $type,
839                        'user_id'   => $k
[3874]840                    ];
[3703]841                    echo '<li>' . sprintf(__('%1$s: %2$s'), __($pt_info['label']), $core->blog->getPosts($params, true)->f(0)) . '</li>';
842                }
843                echo
844                    '</ul>';
[1698]845
[3703]846                echo
847                '<h5>' . __('Permissions:') . '</h5>' .
848                    '<ul>';
849                if ($v['super']) {
850                    echo '<li class="user_super">' . __('Super administrator') . '<br />' .
851                    '<span class="form-note">' . __('All rights on all blogs.') . '</span></li>';
852                } else {
853                    foreach ($v['p'] as $p => $V) {
854                        if (isset($perm_types[$p])) {
855                            echo '<li ' . ($p == 'admin' ? 'class="user_admin"' : '') . '>' . __($perm_types[$p]);
856                        } else {
857                            echo '<li>' . sprintf(__('[%s] (unreferenced permission)'), $p);
858                        }
[1979]859
[3703]860                        if ($p == 'admin') {
861                            echo '<br /><span class="form-note">' . __('All rights on this blog.') . '</span>';
862                        }
863                        echo '</li>';
864                    }
865                }
866                echo
867                    '</ul>';
[2566]868
[3703]869                if (!$v['super'] && $core->auth->isSuperAdmin()) {
870                    echo
871                    '<form action="' . $core->adminurl->get('admin.user.actions') . '" method="post">' .
872                    '<p class="change-user-perm"><input type="submit" class="reset" value="' . __('Change permissions') . '" />' .
[3874]873                    form::hidden(['redir'], $core->adminurl->get("admin.blog.pref", ['id' => $k], '&')) .
874                    form::hidden(['action'], 'perms') .
875                    form::hidden(['users[]'], $k) .
876                    form::hidden(['blogs[]'], $blog_id) .
[3703]877                    $core->formNonce() .
878                        '</p>' .
879                        '</form>';
880                }
881                echo '</div>';
882            }
883        }
884        echo '</div>';
885        if ($current_blog_id != $core->blog->id) {
886            $core->setBlog($current_blog_id);
887        }
888    }
[2566]889
[3703]890    echo '</div>';
[0]891}
892
893dcPage::helpBlock('core_blog_pref');
894dcPage::close();
Note: See TracBrowser for help on using the repository browser.

Sites map