Dotclear

source: admin/blog_pref.php @ 3444:2d5cdb51c7b2

Revision 3444:2d5cdb51c7b2, 30.9 KB checked in by franck <carnet.franck.paul@…>, 9 years ago (diff)

Move advanced and plugins blog’s prefs in two separate foldable sections, closes #2056

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

Sites map