Dotclear

source: admin/blog_pref.php @ 3958:5e250cd51362

Revision 3958:5e250cd51362, 37.0 KB checked in by franck <carnet.franck.paul@…>, 6 years ago (diff)

No more Flash player (flv, mp3) in Dotclear \o/

Line 
1<?php
2/**
3 * @package Dotclear
4 * @subpackage Backend
5 *
6 * @copyright Olivier Meunier & Association Dotclear
7 * @copyright GPL-2.0-only
8 */
9
10$standalone = !isset($edit_blog_mode);
11
12$blog_id = false;
13
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;
23
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']);
34
35        if (!$rs) {
36            throw new Exception(__('No such blog.'));
37        }
38
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    }
48
49    $action = $core->adminurl->get("admin.blog");
50    $redir  = $core->adminurl->get("admin.blog", ['id' => "%s"], '&', true);
51}
52
53# Language codes
54$lang_combo = dcAdminCombos::getAdminLangsCombo();
55
56# Status combo
57$status_combo = dcAdminCombos::getBlogStatusescombo();
58
59# Date format combo
60$now                = time();
61$date_formats       = $blog_settings->system->date_formats;
62$time_formats       = $blog_settings->system->time_formats;
63$date_formats_combo = ['' => ''];
64foreach ($date_formats as $format) {
65    $date_formats_combo[dt::str($format, $now)] = $format;
66}
67$time_formats_combo = ['' => ''];
68foreach ($time_formats as $format) {
69    $time_formats_combo[dt::str($format, $now)] = $format;
70}
71
72# URL scan modes
73$url_scan_combo = [
74    'PATH_INFO'    => 'path_info',
75    'QUERY_STRING' => 'query_string'
76];
77
78# Post URL combo
79$post_url_combo = [
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}'
86];
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);
89}
90
91# Note title tag combo
92$note_title_tag_combo = [
93    __('H4') => 0,
94    __('H3') => 1,
95    __('P')  => 2
96];
97
98# Image title combo
99$img_title_combo = [
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(, )'
105];
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);
108}
109
110# Image default size combo
111$img_default_size_combo = [];
112try {
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    }
118} catch (Exception $e) {
119    $core->error->add($e->getMessage());
120}
121
122# Image default alignment combo
123$img_default_alignment_combo = [
124    __('None')   => 'none',
125    __('Left')   => 'left',
126    __('Right')  => 'right',
127    __('Center') => 'center'
128];
129
130# Image default legend and title combo
131$img_default_legend_combo = [
132    __('Legend and title') => 'legend',
133    __('Title')            => 'title',
134    __('None')             => 'none'
135];
136
137# Robots policy options
138$robots_policy_options = [
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.")
142];
143
144# jQuery available versions
145$jquery_root           = dirname(__FILE__) . '/../inc/js/jquery';
146$jquery_versions_combo = [__('Default') . ' (' . DC_DEFAULT_JQUERY . ')' => DC_DEFAULT_JQUERY];
147if (is_dir($jquery_root) && is_readable($jquery_root)) {
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    }
157}
158
159# Update a blog
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'];
166
167    if ($core->auth->isSuperAdmin() && in_array($_POST['blog_status'], $status_combo)) {
168        $cur->blog_status = (int) $_POST['blog_status'];
169    }
170
171    $media_img_t_size = (integer) $_POST['media_img_t_size'];
172    if ($media_img_t_size < 0) {$media_img_t_size = 100;}
173
174    $media_img_s_size = (integer) $_POST['media_img_s_size'];
175    if ($media_img_s_size < 0) {$media_img_s_size = 240;}
176
177    $media_img_m_size = (integer) $_POST['media_img_m_size'];
178    if ($media_img_m_size < 0) {$media_img_m_size = 448;}
179
180    $media_video_width = (integer) $_POST['media_video_width'];
181    if ($media_video_width < 0) {$media_video_width = 400;}
182
183    $media_video_height = (integer) $_POST['media_video_height'];
184    if ($media_video_height < 0) {$media_video_height = 300;}
185
186    $nb_post_for_home = abs((integer) $_POST['nb_post_for_home']);
187    if ($nb_post_for_home < 1) {$nb_post_for_home = 1;}
188
189    $nb_post_per_page = abs((integer) $_POST['nb_post_per_page']);
190    if ($nb_post_per_page < 1) {$nb_post_per_page = 1;}
191
192    $nb_post_per_feed = abs((integer) $_POST['nb_post_per_feed']);
193    if ($nb_post_per_feed < 1) {$nb_post_per_feed = 1;}
194
195    $nb_comment_per_feed = abs((integer) $_POST['nb_comment_per_feed']);
196    if ($nb_comment_per_feed < 1) {$nb_comment_per_feed = 1;}
197
198    try
199    {
200        if ($cur->blog_id != null && $cur->blog_id != $blog_id) {
201            $rs = $core->getBlog($cur->blog_id);
202
203            if ($rs) {
204                throw new Exception(__('This blog ID is already used.'));
205            }
206        }
207
208        # --BEHAVIOR-- adminBeforeBlogUpdate
209        $core->callBehavior('adminBeforeBlogUpdate', $cur, $blog_id);
210
211        if (!preg_match('/^[a-z]{2}(-[a-z]{2})?$/', $_POST['lang'])) {
212            throw new Exception(__('Invalid language code'));
213        }
214
215        $core->updBlog($blog_id, $cur);
216
217        # --BEHAVIOR-- adminAfterBlogUpdate
218        $core->callBehavior('adminAfterBlogUpdate', $cur, $blog_id);
219
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            }
228
229            $blog_id = $cur->blog_id;
230        }
231
232        $blog_settings->addNameSpace('system');
233
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']));
277
278        # --BEHAVIOR-- adminBeforeBlogSettingsUpdate
279        $core->callBehavior('adminBeforeBlogSettingsUpdate', $blog_settings);
280
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.'));
285
286        http::redirect(sprintf($redir, $blog_id));
287    } catch (Exception $e) {
288        $core->error->add($e->getMessage());
289    }
290}
291
292// Display
293
294if ($standalone) {
295    $breadcrumb = dcPage::breadcrumb(
296        [
297            html::escapeHTML($blog_name) => '',
298            __('Blog settings')          => ''
299        ]
300    );
301} else {
302    $breadcrumb = dcPage::breadcrumb(
303        [
304            __('System')                                               => '',
305            __('Blogs')                                                => $core->adminurl->get("admin.blogs"),
306            __('Blog settings') . ' : ' . html::escapeHTML($blog_name) => ''
307        ]);
308}
309
310$desc_editor = $core->auth->getOption('editor');
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'];
315}
316
317dcPage::open(__('Blog settings'),
318    '<script type="text/javascript">' . "\n" .
319    dcPage::jsVar('dotclear.msg.warning_path_info',
320        __('Warning: except for special configurations, it is generally advised to have a trailing "/" in your blog URL in PATH_INFO mode.')) . "\n" .
321    dcPage::jsVar('dotclear.msg.warning_query_string',
322        __('Warning: except for special configurations, it is generally advised to have a trailing "?" in your blog URL in QUERY_STRING mode.')) . "\n" .
323    "</script>" .
324    dcPage::jsConfirmClose('blog-form') .
325    ($rte_flag ? $core->callBehavior('adminPostEditor', $desc_editor['xhtml'], 'blog_desc', ['#blog_desc'], 'xhtml') : '') .
326    dcPage::jsLoad('js/_blog_pref.js') .
327
328    # --BEHAVIOR-- adminBlogPreferencesHeaders
329    $core->callBehavior('adminBlogPreferencesHeaders') .
330
331    dcPage::jsPageTabs(),
332    $breadcrumb
333);
334
335if ($blog_id) {
336    if (!empty($_GET['add'])) {
337        dcPage::success(__('Blog has been successfully created.'));
338    }
339
340    if (!empty($_GET['upd'])) {
341        dcPage::success(__('Blog has been successfully updated.'));
342    }
343
344    echo
345    '<div class="multi-part" id="params" title="' . __('Parameters') . '">' .
346    '<div id="standard-pref"><h3>' . __('Blog parameters') . '</h3>' .
347        '<form action="' . $action . '" method="post" id="blog-form">';
348
349    echo
350    '<div class="fieldset"><h4>' . __('Blog details') . '</h4>' .
351    $core->formNonce();
352
353    echo
354    '<p><label for="blog_name" class="required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Blog name:') . '</label>' .
355    form::field('blog_name', 30, 255,
356        [
357            'default'    => html::escapeHTML($blog_name),
358            'extra_html' => 'required placeholder="' . __('Blog name') . ' lang="' . $blog_settings->system->lang .
359                '" spellcheck="true"'
360        ]
361    ) . '</p>';
362
363    echo
364    '<p class="area"><label for="blog_desc">' . __('Blog description:') . '</label>' .
365    form::textarea('blog_desc', 60, 5,
366        [
367            'default'    => html::escapeHTML($blog_desc),
368            'extra_html' => 'lang="' . $blog_settings->system->lang . '" spellcheck="true"'
369        ]) . '</p>';
370
371    if ($core->auth->isSuperAdmin()) {
372        echo
373        '<p><label for="blog_status">' . __('Blog status:') . '</label>' .
374        form::combo('blog_status', $status_combo, $blog_status) . '</p>';
375
376    } else {
377        /*
378        Only super admins can change the blog ID and URL, but we need to pass
379        their values to the POST request via hidden html input values  so as
380        to allow admins to update other settings.
381        Otherwise dcCore::getBlogCursor() throws an exception.
382         */
383        echo
384        form::hidden('blog_id', html::escapeHTML($blog_id)) .
385        form::hidden('blog_url', html::escapeHTML($blog_url));
386    }
387
388    echo '</div>';
389
390    echo
391    '<div class="fieldset"><h4>' . __('Blog configuration') . '</h4>' .
392
393    '<p><label for="editor">' . __('Blog editor name:') . '</label>' .
394    form::field('editor', 30, 255, html::escapeHTML($blog_settings->system->editor)) .
395    '</p>' .
396
397    '<p><label for="lang">' . __('Default language:') . '</label>' .
398    form::combo('lang', $lang_combo, $blog_settings->system->lang, 'l10n') .
399    '</p>' .
400
401    '<p><label for="blog_timezone">' . __('Blog timezone:') . '</label>' .
402    form::combo('blog_timezone', dt::getZones(true, true), html::escapeHTML($blog_settings->system->blog_timezone)) .
403    '</p>' .
404
405    '<p><label for="copyright_notice">' . __('Copyright notice:') . '</label>' .
406    form::field('copyright_notice', 30, 255,
407        [
408            'default'    => html::escapeHTML($blog_settings->system->copyright_notice),
409            'extra_html' => 'lang="' . $blog_settings->system->lang . '" spellcheck="true"'
410        ]) .
411        '</p>' .
412
413        '</div>';
414
415    echo
416    '<div class="fieldset"><h4>' . __('Comments and trackbacks') . '</h4>' .
417
418    '<div class="two-cols">' .
419
420    '<div class="col">' .
421    '<p><label for="allow_comments" class="classic">' .
422    form::checkbox('allow_comments', '1', $blog_settings->system->allow_comments) .
423    __('Accept comments') . '</label></p>' .
424    '<p><label for="comments_pub" class="classic">' .
425    form::checkbox('comments_pub', '1', !$blog_settings->system->comments_pub) .
426    __('Moderate comments') . '</label></p>' .
427    '<p><label for="comments_ttl" class="classic">' . sprintf(__('Leave comments open for %s days') . '.',
428        form::number('comments_ttl', [
429            'min'     => 0,
430            'max'     => 999,
431            'default' => $blog_settings->system->comments_ttl]
432        )) .
433    '</label></p>' .
434    '<p class="form-note">' . __('No limit: leave blank.') . '</p>' .
435    '<p><label for="wiki_comments" class="classic">' .
436    form::checkbox('wiki_comments', '1', $blog_settings->system->wiki_comments) .
437    __('Wiki syntax for comments') . '</label></p>' .
438    '<p><label for="comment_preview_optional" class="classic">' .
439    form::checkbox('comment_preview_optional', '1', $blog_settings->system->comment_preview_optional) .
440    __('Preview of comment before submit is not mandatory') . '</label></p>' .
441    '</div>' .
442
443    '<div class="col">' .
444    '<p><label for="allow_trackbacks" class="classic">' .
445    form::checkbox('allow_trackbacks', '1', $blog_settings->system->allow_trackbacks) .
446    __('Accept trackbacks') . '</label></p>' .
447    '<p><label for="trackbacks_pub" class="classic">' .
448    form::checkbox('trackbacks_pub', '1', !$blog_settings->system->trackbacks_pub) .
449    __('Moderate trackbacks') . '</label></p>' .
450    '<p><label for="trackbacks_ttl" class="classic">' . sprintf(__('Leave trackbacks open for %s days') . '.',
451        form::number('trackbacks_ttl', [
452            'min'     => 0,
453            'max'     => 999,
454            'default' => $blog_settings->system->trackbacks_ttl]
455        )) .
456    '</label></p>' .
457    '<p class="form-note">' . __('No limit: leave blank.') . '</p>' .
458    '<p><label for="comments_nofollow" class="classic">' .
459    form::checkbox('comments_nofollow', '1', $blog_settings->system->comments_nofollow) .
460    __('Add "nofollow" relation on comments and trackbacks links') . '</label></p>' .
461    '</div>' .
462    '<br class="clear" />' . //Opera sucks
463
464    '</div>' .
465    '<br class="clear" />' . //Opera sucks
466    '</div>';
467
468    echo
469    '<div class="fieldset"><h4>' . __('Blog presentation') . '</h4>' .
470    '<div class="two-cols">' .
471    '<div class="col">' .
472    '<p><label for="date_format">' . __('Date format:') . '</label> ' .
473    form::field('date_format', 30, 255, html::escapeHTML($blog_settings->system->date_format)) .
474    form::combo('date_format_select', $date_formats_combo, ['extra_html' => 'title="' . __('Pattern of date') . '"']) .
475    '</p>' .
476    '<p class="chosen form-note">' . __('Sample:') . ' ' . dt::str(html::escapeHTML($blog_settings->system->date_format)) . '</p>' .
477
478    '<p><label for="time_format">' . __('Time format:') . '</label>' .
479    form::field('time_format', 30, 255, html::escapeHTML($blog_settings->system->time_format)) .
480    form::combo('time_format_select', $time_formats_combo, ['extra_html' => 'title="' . __('Pattern of time') . '"']) .
481    '</p>' .
482    '<p class="chosen form-note">' . __('Sample:') . ' ' . dt::str(html::escapeHTML($blog_settings->system->time_format)) . '</p>' .
483
484    '<p><label for="use_smilies" class="classic">' .
485    form::checkbox('use_smilies', '1', $blog_settings->system->use_smilies) .
486    __('Display smilies on entries and comments') . '</label></p>' .
487
488    '<p><label for="no_search" class="classic">' .
489    form::checkbox('no_search', '1', $blog_settings->system->no_search) .
490    __('Disable internal search system') . '</label></p>' .
491    '</div>' .
492
493    '<div class="col">' .
494    '<p><label for="nb_post_for_home" class="classic">' . sprintf(__('Display %s entries on home page'),
495        form::number('nb_post_for_home', [
496            'min'     => 1,
497            'max'     => 999,
498            'default' => $blog_settings->system->nb_post_for_home]
499        )) .
500    '</label></p>' .
501
502    '<p><label for="nb_post_per_page" class="classic">' . sprintf(__('Display %s entries per page'),
503        form::number('nb_post_per_page', [
504            'min'     => 1,
505            'max'     => 999,
506            'default' => $blog_settings->system->nb_post_per_page]
507        )) .
508    '</label></p>' .
509
510    '<p><label for="nb_post_per_feed" class="classic">' . sprintf(__('Display %s entries per feed'),
511        form::number('nb_post_per_feed', [
512            'min'     => 1,
513            'max'     => 999,
514            'default' => $blog_settings->system->nb_post_per_feed]
515        )) .
516    '</label></p>' .
517
518    '<p><label for="nb_comment_per_feed" class="classic">' . sprintf(__('Display %s comments per feed'),
519        form::number('nb_comment_per_feed', [
520            'min'     => 1,
521            'max'     => 999,
522            'default' => $blog_settings->system->nb_comment_per_feed]
523        )) .
524    '</label></p>' .
525
526    '<p><label for="short_feed_items" class="classic">' .
527    form::checkbox('short_feed_items', '1', $blog_settings->system->short_feed_items) .
528    __('Truncate feeds') . '</label></p>' .
529
530    '<p><label for="inc_subcats" class="classic">' .
531    form::checkbox('inc_subcats', '1', $blog_settings->system->inc_subcats) .
532    __('Include sub-categories in category page and category posts feed') . '</label></p>' .
533    '</div>' .
534    '</div>' .
535    '<br class="clear" />' . //Opera sucks
536    '</div>';
537
538    echo
539    '<div class="fieldset"><h4 id="medias-settings">' . __('Media and images') . '</h4>' .
540    '<p class="form-note warning">' .
541    __('Please note that if you change current settings bellow, they will now apply to all new images in the media manager.') .
542    ' ' . __('Be carefull if you share it with other blogs in your installation.') . '<br />' .
543    __('Set -1 to use the default size, set 0 to ignore this thumbnail size (images only).') . '</p>' .
544
545    '<div class="two-cols">' .
546    '<div class="col">' .
547    '<h5>' . __('Generated image sizes (max dimension in pixels)') . '</h5>' .
548    '<p class="field"><label for="media_img_t_size">' . __('Thumbnail') . '</label> ' .
549    form::number('media_img_t_size', [
550        'min'     => -1,
551        'max'     => 999,
552        'default' => $blog_settings->system->media_img_t_size
553    ]) .
554    '</p>' .
555
556    '<p class="field"><label for="media_img_s_size">' . __('Small') . '</label> ' .
557    form::number('media_img_s_size', [
558        'min'     => -1,
559        'max'     => 999,
560        'default' => $blog_settings->system->media_img_s_size
561    ]) .
562    '</p>' .
563
564    '<p class="field"><label for="media_img_m_size">' . __('Medium') . '</label> ' .
565    form::number('media_img_m_size', [
566        'min'     => -1,
567        'max'     => 999,
568        'default' => $blog_settings->system->media_img_m_size
569    ]) .
570    '</p>' .
571
572    '<h5>' . __('Default size of the inserted video (in pixels)') . '</h5>' .
573    '<p class="field"><label for="media_video_width">' . __('Width') . '</label> ' .
574    form::number('media_video_width', [
575        'min'     => -1,
576        'max'     => 999,
577        'default' => $blog_settings->system->media_video_width
578    ]) .
579    '</p>' .
580
581    '<p class="field"><label for="media_video_height">' . __('Height') . '</label> ' .
582    form::number('media_video_height', [
583        'min'     => -1,
584        'max'     => 999,
585        'default' => $blog_settings->system->media_video_height
586    ]) .
587    '</p>' .
588    '</div>' .
589
590    '<div class="col">' .
591    '<h5>' . __('Default image insertion attributes') . '</h5>' .
592    '<p class="vertical-separator"><label for="media_img_title_pattern">' . __('Inserted image title') . '</label>' .
593    form::combo('media_img_title_pattern', $img_title_combo, html::escapeHTML($blog_settings->system->media_img_title_pattern)) . '</p>' .
594    '<p><label for="media_img_use_dto_first" class="classic">' .
595    form::checkbox('media_img_use_dto_first', '1', $blog_settings->system->media_img_use_dto_first) .
596    __('Use original media date if possible') . '</label></p>' .
597    '<p><label for="media_img_no_date_alone" class="classic">' .
598    form::checkbox('media_img_no_date_alone', '1', $blog_settings->system->media_img_no_date_alone) .
599    __('Do not display date if alone in title') . '</label></p>' .
600    '<p class="form-note info">' . __('It is retrieved from the picture\'s metadata.') . '</p>' .
601
602    '<p class="field vertical-separator"><label for="media_img_default_size">' . __('Size of inserted image:') . '</label>' .
603    form::combo('media_img_default_size', $img_default_size_combo,
604        (html::escapeHTML($blog_settings->system->media_img_default_size) != '' ? html::escapeHTML($blog_settings->system->media_img_default_size) : 'm')) .
605    '</p>' .
606    '<p class="field"><label for="media_img_default_alignment">' . __('Image alignment:') . '</label>' .
607    form::combo('media_img_default_alignment', $img_default_alignment_combo, html::escapeHTML($blog_settings->system->media_img_default_alignment)) .
608    '</p>' .
609    '<p><label for="media_img_default_link">' .
610    form::checkbox('media_img_default_link', '1', $blog_settings->system->media_img_default_link) .
611    __('Insert a link to the original image') . '</label></p>' .
612    '<p class="field"><label for="media_img_default_legend">' . __('Image legend and title:') . '</label>' .
613    form::combo('media_img_default_legend', $img_default_legend_combo, html::escapeHTML($blog_settings->system->media_img_default_legend)) .
614    '</p>' .
615    '</div>' .
616    '</div>' .
617    '<br class="clear" />' . //Opera sucks
618
619    '</div>' .
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', [
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(['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(['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", ['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 = [
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(['redir'], $core->adminurl->get("admin.blog.pref", ['id' => $k], '&')) .
867                    form::hidden(['action'], 'perms') .
868                    form::hidden(['users[]'], $k) .
869                    form::hidden(['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