Dotclear

source: admin/blog_pref.php @ 3115:8a553212c2d3

Revision 3115:8a553212c2d3, 29.7 KB checked in by franck <carnet.franck.paul@…>, 10 years ago (diff)

New settings (video insertion default sizes) should be initialized in db, addresses #2129

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
6# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear
7# Licensed under the GPL version 2.0 license.
8# See LICENSE file or
9# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10#
11# -- END LICENSE BLOCK -----------------------------------------
12
13$standalone = !isset($edit_blog_mode);
14
15$blog_id = false;
16
17if ($standalone)
18{
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;
27
28     $action = $core->adminurl->get("admin.blog.pref");
29     $redir = $core->adminurl->get("admin.blog.pref");
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']);
40
41          if (!$rs) {
42               throw new Exception(__('No such blog.'));
43          }
44
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);
50          $blog_url = $rs->blog_url ;
51     }
52     catch (Exception $e)
53     {
54          $core->error->add($e->getMessage());
55     }
56
57     $action = $core->adminurl->get("admin.blog");
58     $redir = $core->adminurl->get("admin.blog",array('id' => "%s"),'&',true);
59}
60
61# Language codes
62$lang_combo = dcAdminCombos::getAdminLangsCombo();
63
64# Status combo
65$status_combo = dcAdminCombos::getBlogStatusescombo();
66
67# Date format combo
68$now = time();
69$date_formats = unserialize($blog_settings->system->date_formats);
70$time_formats = unserialize($blog_settings->system->time_formats);
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
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}',
92     __('title') => '{t}',
93     __('post id/title') => '{id}/{t}',
94     __('post id') => '{id}'
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
100# Note title tag combo
101$note_title_tag_combo = array(
102     __('H4') => 0,
103     __('H3') => 1,
104     __('P') => 2
105);
106
107# Image title combo
108$img_title_combo = array(
109     __('(none)') => '',
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
119# Image default size combo
120$img_default_size_combo = array();
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());
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
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
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
161# Update a blog
162if ($blog_id && !empty($_POST) && $core->auth->check('admin',$blog_id))
163{
164     $cur = $core->con->openCursor($core->prefix.'blog');
165     $cur->blog_id = $_POST['blog_id'];
166     $cur->blog_url = preg_replace('/\?+$/','?', $_POST['blog_url']);
167     $cur->blog_name = $_POST['blog_name'];
168     $cur->blog_desc = $_POST['blog_desc'];
169
170     if ($core->auth->isSuperAdmin() && in_array($_POST['blog_status'], $status_combo)) {
171          $cur->blog_status = (int) $_POST['blog_status'];
172     }
173
174     $media_img_t_size = abs((integer) $_POST['media_img_t_size']);
175     if ($media_img_t_size < 0) { $media_img_t_size = 100; }
176
177     $media_img_s_size = abs((integer) $_POST['media_img_s_size']);
178     if ($media_img_s_size < 0) { $media_img_s_size = 240; }
179
180     $media_img_m_size = abs((integer) $_POST['media_img_m_size']);
181     if ($media_img_m_size < 0) { $media_img_m_size = 448; }
182
183     $media_video_width = abs((integer) $_POST['media_video_width']);
184     if ($media_video_width < 0) { $media_video_width = 400; }
185
186     $media_video_height = abs((integer) $_POST['media_video_height']);
187     if ($media_video_height < 0) { $media_video_height = 300; }
188
189     $nb_post_for_home = abs((integer) $_POST['nb_post_for_home']);
190     if ($nb_post_for_home <= 1) { $nb_post_for_home = 1; }
191
192     $nb_post_per_page = abs((integer) $_POST['nb_post_per_page']);
193     if ($nb_post_per_page <= 1) { $nb_post_per_page = 1; }
194
195     $nb_post_per_feed = abs((integer) $_POST['nb_post_per_feed']);
196     if ($nb_post_per_feed <= 1) { $nb_post_per_feed = 1; }
197
198     $nb_comment_per_feed = abs((integer) $_POST['nb_comment_per_feed']);
199     if ($nb_comment_per_feed <= 1) { $nb_comment_per_feed = 1; }
200
201     try
202     {
203          if ($cur->blog_id != null && $cur->blog_id != $blog_id) {
204               $rs = $core->getBlog($cur->blog_id);
205
206               if ($rs) {
207                    throw new Exception(__('This blog ID is already used.'));
208               }
209          }
210
211          # --BEHAVIOR-- adminBeforeBlogUpdate
212          $core->callBehavior('adminBeforeBlogUpdate',$cur,$blog_id);
213
214          if (!preg_match('/^[a-z]{2}(-[a-z]{2})?$/',$_POST['lang'])) {
215               throw new Exception(__('Invalid language code'));
216          }
217
218          $core->updBlog($blog_id,$cur);
219
220          # --BEHAVIOR-- adminAfterBlogUpdate
221          $core->callBehavior('adminAfterBlogUpdate',$cur,$blog_id);
222
223          if ($cur->blog_id != null && $cur->blog_id != $blog_id) {
224               if ($blog_id == $core->blog->id) {
225                    $core->setBlog($cur->blog_id);
226                    $_SESSION['sess_blog_id'] = $cur->blog_id;
227                    $blog_settings = $core->blog->settings;
228               } else {
229                    $blog_settings = new dcSettings($core,$cur->blog_id);
230               }
231
232               $blog_id = $cur->blog_id;
233          }
234
235
236          $blog_settings->addNameSpace('system');
237
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']));
253          $blog_settings->system->put('comment_preview_optional',!empty($_POST['comment_preview_optional']));
254          $blog_settings->system->put('enable_xmlrpc',!empty($_POST['enable_xmlrpc']));
255          $blog_settings->system->put('note_title_tag',$_POST['note_title_tag']);
256          $blog_settings->system->put('nb_post_for_home',$nb_post_for_home);
257          $blog_settings->system->put('nb_post_per_page',$nb_post_per_page);
258          $blog_settings->system->put('use_smilies',!empty($_POST['use_smilies']));
259          $blog_settings->system->put('no_search',!empty($_POST['no_search']));
260          $blog_settings->system->put('inc_subcats',!empty($_POST['inc_subcats']));
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);
264          $blog_settings->system->put('media_video_width',$media_video_width);
265          $blog_settings->system->put('media_video_height',$media_video_height);
266          $blog_settings->system->put('media_img_title_pattern',$_POST['media_img_title_pattern']);
267          $blog_settings->system->put('media_img_use_dto_first',!empty($_POST['media_img_use_dto_first']));
268          $blog_settings->system->put('media_img_no_date_alone',!empty($_POST['media_img_no_date_alone']));
269          $blog_settings->system->put('media_img_default_size',$_POST['media_img_default_size']);
270          $blog_settings->system->put('media_img_default_alignment',$_POST['media_img_default_alignment']);
271          $blog_settings->system->put('media_img_default_link',!empty($_POST['media_img_default_link']));
272          $blog_settings->system->put('nb_post_per_feed',$nb_post_per_feed);
273          $blog_settings->system->put('nb_comment_per_feed',$nb_comment_per_feed);
274          $blog_settings->system->put('short_feed_items',!empty($_POST['short_feed_items']));
275          if (isset($_POST['robots_policy'])) {
276               $blog_settings->system->put('robots_policy',$_POST['robots_policy']);
277          }
278          $blog_settings->system->put('jquery_version',$_POST['jquery_version']);
279          $blog_settings->system->put('prevents_clickjacking',!empty($_POST['prevents_clickjacking']));
280
281          # --BEHAVIOR-- adminBeforeBlogSettingsUpdate
282          $core->callBehavior('adminBeforeBlogSettingsUpdate',$blog_settings);
283
284          if ($core->auth->isSuperAdmin() && in_array($_POST['url_scan'],$url_scan_combo)) {
285               $blog_settings->system->put('url_scan',$_POST['url_scan']);
286          }
287          dcPage::addSuccessNotice(__('Blog has been successfully updated.'));
288
289          http::redirect(sprintf($redir,$blog_id));
290     }
291     catch (Exception $e)
292     {
293          $core->error->add($e->getMessage());
294     }
295}
296
297if ($standalone) {
298     $breadcrumb = dcPage::breadcrumb(
299          array(
300               html::escapeHTML($blog_name) => '',
301               __('Blog settings') => ''
302          )
303     );
304} else {
305     $breadcrumb = dcPage::breadcrumb(
306          array(
307               __('System') => '',
308               __('Blogs') => $core->adminurl->get("admin.blogs"),
309               __('Blog settings').' : '.html::escapeHTML($blog_name) => ''
310          ));
311}
312
313dcPage::open(__('Blog settings'),
314     '<script type="text/javascript">'."\n".
315     "//<![CDATA["."\n".
316     dcPage::jsVar('dotclear.msg.warning_path_info',
317          __('Warning: except for special configurations, it is generally advised to have a trailing "/" in your blog URL in PATH_INFO mode.'))."\n".
318     dcPage::jsVar('dotclear.msg.warning_query_string',
319          __('Warning: except for special configurations, it is generally advised to have a trailing "?" in your blog URL in QUERY_STRING mode.'))."\n".
320     "//]]>".
321     "</script>".
322     dcPage::jsConfirmClose('blog-form').
323     $core->callBehavior('adminPostEditor').
324     dcPage::jsLoad('js/_blog_pref.js').
325
326
327     # --BEHAVIOR-- adminBlogPreferencesHeaders
328     $core->callBehavior('adminBlogPreferencesHeaders').
329
330     dcPage::jsPageTabs(),
331     $breadcrumb
332);
333
334if ($blog_id)
335{
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     '<h3 class="out-of-screen-if-js">'.__('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     if ($core->auth->isSuperAdmin())
354     {
355          echo
356          '<p><label for="blog_id" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Blog ID:').'</label>'.
357          form::field('blog_id',30,32,html::escapeHTML($blog_id)).'</p>'.
358          '<p class="form-note">'.__('At least 2 characters using letters, numbers or symbols.').'</p> '.
359          '<p class="form-note warn">'.__('Please note that changing your blog ID may require changes in your public index.php file.').'</p>';
360     } else {
361          /*
362          Only super admins can change the blog ID and URL, but we need to pass
363          their values to the POST request via hidden html input values  so as
364          to allow admins to update other settings.
365          Otherwise dcCore::getBlogCursor() throws an exception.
366          */
367          echo form::field('blog_id', 30, 32, html::escapeHTML($blog_id), '', '', false, 'hidden="hidden"');
368          echo form::field('blog_url', 50, 255, html::escapeHTML($blog_url), '', '', false, 'hidden="hidden"');
369     }
370
371     echo
372     '<p><label for="blog_name" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Blog name:').'</label>'.
373     form::field('blog_name',30,255,html::escapeHTML($blog_name)).'</p>';
374
375     if ($core->auth->isSuperAdmin())
376     {
377          echo
378          '<p><label for="blog_url" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Blog URL:').'</label>'.
379          form::field('blog_url',50,255,html::escapeHTML($blog_url)).'</p>'.
380
381          '<p><label for="url_scan">'.__('URL scan method:').'</label>'.
382          form::combo('url_scan',$url_scan_combo,$blog_settings->system->url_scan).'</p>';
383
384          try
385          {
386               # Test URL of blog by testing it's ATOM feed
387               $file = $blog_url.$core->url->getURLFor('feed','atom');
388               $path = '';
389               $status = '404';
390               $content = '';
391
392               $client = netHttp::initClient($file,$path);
393               if ($client !== false) {
394                    $client->setTimeout(4);
395                    $client->setUserAgent($_SERVER['HTTP_USER_AGENT']);
396                    $client->get($path);
397                    $status = $client->getStatus();
398                    $content = $client->getContent();
399               }
400               if ($status != '200') {
401                    // Might be 404 (URL not found), 670 (blog not online), ...
402                    echo
403                    '<p class="form-note warn">'.
404                    sprintf(__('The URL of blog or the URL scan method might not be well set (<code>%s</code> return a <strong>%s</strong> status).'),
405                              $file,$status).
406                    '</p>';
407               } else {
408                    if (substr($content,0,6) != '<?xml ') {
409                         // Not well formed XML feed
410                         echo
411                         '<p class="form-note warn">'.
412                         sprintf(__('The URL of blog or the URL scan method might not be well set (<code>%s</code> does not return an ATOM feed).'),
413                                   $file).
414                         '</p>';
415                    }
416               }
417          }
418          catch (Exception $e)
419          {
420               $core->error->add($e->getMessage());
421          }
422          echo
423          '<p><label for="blog_status">'.__('Blog status:').'</label>'.
424          form::combo('blog_status',$status_combo,$blog_status).'</p>';
425     }
426
427     echo
428     '<p class="area"><label for="blog_desc">'.__('Blog description:').'</label>'.
429     form::textarea('blog_desc',60,5,html::escapeHTML($blog_desc)).'</p>'.
430     '</div>';
431
432
433     echo
434     '<div class="fieldset"><h4>'.__('Blog configuration').'</h4>'.
435     '<div class="two-cols">'.
436     '<div class="col">'.
437     '<p><label for="editor">'.__('Blog editor name:').'</label>'.
438     form::field('editor',30,255,html::escapeHTML($blog_settings->system->editor)).
439     '</p>'.
440
441     '<p><label for="lang">'.__('Default language:').'</label>'.
442     form::combo('lang',$lang_combo,$blog_settings->system->lang,'l10n').
443     '</p>'.
444
445     '<p><label for="blog_timezone">'.__('Blog timezone:').'</label>'.
446     form::combo('blog_timezone',dt::getZones(true,true),html::escapeHTML($blog_settings->system->blog_timezone)).
447     '</p>'.
448
449     '<p><label for="copyright_notice">'.__('Copyright notice:').'</label>'.
450     form::field('copyright_notice',30,255,html::escapeHTML($blog_settings->system->copyright_notice)).
451     '</p>'.
452     '</div>'.
453
454     '<div class="col">'.
455     '<p><label for="post_url_format">'.__('New post URL format:').'</label>'.
456     form::combo('post_url_format',$post_url_combo,html::escapeHTML($blog_settings->system->post_url_format)).
457     '</p>'.
458
459     '<p><label for="note_title_tag">'.__('HTML tag for the title of the notes on the blog:').'</label>'.
460     form::combo('note_title_tag',$note_title_tag_combo,$blog_settings->system->note_title_tag).
461     '</p>'.
462
463     '<p><label for="enable_xmlrpc" class="classic">'.
464     form::checkbox('enable_xmlrpc','1',$blog_settings->system->enable_xmlrpc).
465     __('Enable XML/RPC interface').'</label>'.'</p>';
466
467     echo
468          '<p class="form-note info">'.__('XML/RPC interface allows you to edit your blog with an external client.').'</p>';
469
470     if ($blog_settings->system->enable_xmlrpc) {
471          echo
472          '<p>'.__('XML/RPC interface is active. You should set the following parameters on your XML/RPC client:').'</p>'.
473          '<ul>'.
474          '<li>'.__('Server URL:').' <strong><code>'.
475          sprintf(DC_XMLRPC_URL,$core->blog->url,$core->blog->id).
476          '</code></strong></li>'.
477          '<li>'.__('Blogging system:').' <strong><code>Movable Type</code></strong></li>'.
478          '<li>'.__('User name:').' <strong><code>'.$core->auth->userID().'</code></strong></li>'.
479          '<li>'.__('Password:').' <strong><code>&lt;'.__('your password').'&gt;</code></strong></li>'.
480          '<li>'.__('Blog ID:').' <strong><code>1</code></strong></li>'.
481          '</ul>';
482     }
483
484     echo
485     '</div>'.
486     '</div>'.
487     '<br class="clear" />'. //Opera sucks
488     '</div>';
489
490     echo
491     '<div class="fieldset"><h4>'.__('Comments and trackbacks').'</h4>'.
492
493     '<div class="two-cols">'.
494
495     '<div class="col">'.
496     '<p><label for="allow_comments" class="classic">'.
497     form::checkbox('allow_comments','1',$blog_settings->system->allow_comments).
498     __('Accept comments').'</label></p>'.
499     '<p><label for="comments_pub" class="classic">'.
500     form::checkbox('comments_pub','1',!$blog_settings->system->comments_pub).
501     __('Moderate comments').'</label></p>'.
502     '<p><label for="comments_ttl" class="classic">'.sprintf(__('Leave comments open for %s days').'.',
503     form::field('comments_ttl',2,3,$blog_settings->system->comments_ttl)).
504     '</label></p>'.
505     '<p class="form-note">'.__('No limit: leave blank.').'</p>'.
506     '<p><label for="wiki_comments" class="classic">'.
507     form::checkbox('wiki_comments','1',$blog_settings->system->wiki_comments).
508     __('Wiki syntax for comments').'</label></p>'.
509     '<p><label for="comment_preview_optional" class="classic">'.
510     form::checkbox('comment_preview_optional','1',$blog_settings->system->comment_preview_optional).
511     __('Preview of comment before submit is not mandatory').'</label></p>'.
512     '</div>'.
513
514     '<div class="col">'.
515     '<p><label for="allow_trackbacks" class="classic">'.
516     form::checkbox('allow_trackbacks','1',$blog_settings->system->allow_trackbacks).
517     __('Accept trackbacks').'</label></p>'.
518     '<p><label for="trackbacks_pub" class="classic">'.
519     form::checkbox('trackbacks_pub','1',!$blog_settings->system->trackbacks_pub).
520     __('Moderate trackbacks').'</label></p>'.
521     '<p><label for="trackbacks_ttl" class="classic">'.sprintf(__('Leave trackbacks open for %s days').'.',
522     form::field('trackbacks_ttl',2,3,$blog_settings->system->trackbacks_ttl)).'</label></p>'.
523     '<p class="form-note">'.__('No limit: leave blank.').'</p>'.
524     '<p><label for="comments_nofollow" class="classic">'.
525     form::checkbox('comments_nofollow','1',$blog_settings->system->comments_nofollow).
526     __('Add "nofollow" relation on comments and trackbacks links').'</label></p>'.
527     '</div>'.
528     '<br class="clear" />'. //Opera sucks
529
530     '</div>'.
531     '<br class="clear" />'. //Opera sucks
532     '</div>';
533
534     echo
535     '<div class="fieldset"><h4>'.__('Blog presentation').'</h4>'.
536     '<div class="two-cols">'.
537     '<div class="col">'.
538     '<p><label for="date_format">'.__('Date format:').'</label> '.
539     form::field('date_format',30,255,html::escapeHTML($blog_settings->system->date_format)).
540     form::combo('date_format_select',$date_formats_combo,'','','',false,'title="'.__('Pattern of date').'"').
541     '</p>'.
542     '<p class="chosen form-note">'.__('Sample:').' '.dt::str(html::escapeHTML($blog_settings->system->date_format)).'</p>'.
543
544     '<p><label for="time_format">'.__('Time format:').'</label>'.
545     form::field('time_format',30,255,html::escapeHTML($blog_settings->system->time_format)).
546     form::combo('time_format_select',$time_formats_combo,'','','',false,'title="'.__('Pattern of time').'"').
547     '</p>'.
548     '<p class="chosen form-note">'.__('Sample:').' '.dt::str(html::escapeHTML($blog_settings->system->time_format)).'</p>'.
549
550     '<p><label for="use_smilies" class="classic">'.
551     form::checkbox('use_smilies','1',$blog_settings->system->use_smilies).
552     __('Display smilies on entries and comments').'</label></p>'.
553
554     '<p><label for="no_search" class="classic">'.
555     form::checkbox('no_search','1',$blog_settings->system->no_search).
556     __('Disable internal search system').'</label></p>'.
557     '</div>'.
558
559     '<div class="col">'.
560     '<p><label for="nb_post_for_home" class="classic">'.sprintf(__('Display %s entries on home page'),
561     form::field('nb_post_for_home',2,3,$blog_settings->system->nb_post_for_home)).
562     '</label></p>'.
563
564     '<p><label for="nb_post_per_page" class="classic">'.sprintf(__('Display %s entries per page'),
565     form::field('nb_post_per_page',2,3,$blog_settings->system->nb_post_per_page)).
566     '</label></p>'.
567
568     '<p><label for="nb_post_per_feed" class="classic">'.sprintf(__('Display %s entries per feed'),
569     form::field('nb_post_per_feed',2,3,$blog_settings->system->nb_post_per_feed)).
570     '</label></p>'.
571
572     '<p><label for="nb_comment_per_feed" class="classic">'.sprintf(__('Display %s comments per feed'),
573     form::field('nb_comment_per_feed',2,3,$blog_settings->system->nb_comment_per_feed)).
574     '</label></p>'.
575
576     '<p><label for="short_feed_items" class="classic">'.
577     form::checkbox('short_feed_items','1',$blog_settings->system->short_feed_items).
578     __('Truncate feeds').'</label></p>'.
579
580     '<p><label for="inc_subcats" class="classic">'.
581     form::checkbox('inc_subcats','1',$blog_settings->system->inc_subcats).
582     __('Include sub-categories in category page and category posts feed').'</label></p>'.
583     '</div>'.
584    '</div>'.
585     '<br class="clear" />'. //Opera sucks
586     '</div>';
587
588     echo
589     '<div class="fieldset"><h4 id="medias-settings">'.__('Media and images').'</h4>'.
590          '<p class="form-note warning">'.
591     __('Please note that if you change current settings bellow, they will now apply to all new images in the media manager.').
592     ' '.__('Be carefull if you share it with other blogs in your installation.').'</p>'.
593
594     '<div class="two-cols">'.
595     '<div class="col">'.
596     '<h5>'.__('Generated image sizes (in pixels)').'</h5>'.
597     '<p class="field"><label for="media_img_t_size">'.__('Thumbnail').'</label> '.
598     form::field('media_img_t_size',3,3,$blog_settings->system->media_img_t_size).'</p>'.
599
600     '<p class="field"><label for="media_img_s_size">'.__('Small').'</label> '.
601     form::field('media_img_s_size',3,3,$blog_settings->system->media_img_s_size).'</p>'.
602
603     '<p class="field"><label for="media_img_m_size">'.__('Medium').'</label> '.
604     form::field('media_img_m_size',3,3,$blog_settings->system->media_img_m_size).'</p>'.
605
606     '<h5>'.__('Default size of the inserted video (in pixels)').'</h5>'.
607     '<p class="field"><label for="media_video_width">'.__('Width').'</label> '.
608     form::field('media_video_width',3,3,$blog_settings->system->media_video_width).'</p>'.
609
610     '<p class="field"><label for="media_video_height">'.__('Height').'</label> '.
611     form::field('media_video_height',3,3,$blog_settings->system->media_video_height).'</p>'.
612     '</div>'.
613
614     '<div class="col">'.
615     '<h5>'.__('Default image insertion attributes').'</h5>'.
616     '<p class="vertical-separator"><label for="media_img_title_pattern">'.__('Inserted image title').'</label>'.
617     form::combo('media_img_title_pattern',$img_title_combo,html::escapeHTML($blog_settings->system->media_img_title_pattern)).'</p>'.
618     '<p><label for="media_img_use_dto_first" class="classic">'.
619     form::checkbox('media_img_use_dto_first','1',$blog_settings->system->media_img_use_dto_first).
620     __('Use original media date if possible').'</label></p>'.
621     '<p><label for="media_img_no_date_alone" class="classic">'.
622     form::checkbox('media_img_no_date_alone','1',$blog_settings->system->media_img_no_date_alone).
623     __('Do not display date if alone in title').'</label></p>'.
624     '<p class="form-note info">'.__('It is retrieved from the picture\'s metadata.').'</p>'.
625
626     '<p class="field vertical-separator"><label for="media_img_default_size">'.__('Size of inserted image:').'</label>'.
627     form::combo('media_img_default_size',$img_default_size_combo,
628          (html::escapeHTML($blog_settings->system->media_img_default_size) != '' ? html::escapeHTML($blog_settings->system->media_img_default_size) : 'm')).
629     '</p>'.
630     '<p class="field"><label for="media_img_default_alignment">'.__('Image alignment:').'</label>'.
631     form::combo('media_img_default_alignment',$img_default_alignment_combo,html::escapeHTML($blog_settings->system->media_img_default_alignment)).
632     '</p>'.
633     '<p><label for="media_img_default_link">'.
634     form::checkbox('media_img_default_link','1',$blog_settings->system->media_img_default_link).
635     __('Insert a link to the original image').'</label></p>'.
636     '</div>'.
637     '</div>'.
638     '<br class="clear" />'. //Opera sucks
639
640     '</div>';
641
642     echo
643     '<div class="fieldset"><h4>'.__('Search engines robots policy').'</h4>';
644
645     $i = 0;
646     foreach ($robots_policy_options as $k => $v)
647     {
648          echo '<p><label for="robots_policy-'.$i.'" class="classic">'.
649          form::radio(array('robots_policy','robots_policy-'.$i),$k,$blog_settings->system->robots_policy == $k).' '.$v.'</label></p>';
650          $i++;
651     }
652
653     echo '</div>';
654
655     echo
656     '<div class="fieldset"><h4>'.__('jQuery javascript library').'</h4>'.
657     '<p><label for="jquery_version" class="classic">'.__('jQuery version to be loaded for this blog:').'</label>'.' '.
658     form::combo('jquery_version',$jquery_versions_combo,$blog_settings->system->jquery_version).
659     '</p>'.
660     '<br class="clear" />'. //Opera sucks
661     '</div>';
662
663     echo
664     '<div class="fieldset"><h4>'.__('Blog security').'</h4>'.
665     '<p><label for="prevents_clickjacking" class="classic">'.
666     form::checkbox('prevents_clickjacking','1',$blog_settings->system->prevents_clickjacking).
667     __('Protect the blog from Clickjacking (see <a href="https://en.wikipedia.org/wiki/Clickjacking">Wikipedia</a>)').'</label></p>'.
668     '<br class="clear" />'. //Opera sucks
669     '</div>';
670
671     # --BEHAVIOR-- adminBlogPreferencesForm
672     $core->callBehavior('adminBlogPreferencesForm',$core,$blog_settings);
673
674     echo
675     '<p><input type="submit" accesskey="s" value="'.__('Save').'" />'.
676     (!$standalone ? form::hidden('id',$blog_id) : '').
677     '</p>'.
678     '</form>';
679
680     if ($core->auth->isSuperAdmin() && $blog_id != $core->blog->id)
681     {
682          echo
683          '<form action="'.$core->adminurl->get("admin.blog.del").'" method="post">'.
684          '<p><input type="submit" class="delete" value="'.__('Delete this blog').'" />'.
685          form::hidden(array('blog_id'),$blog_id).
686          $core->formNonce().'</p>'.
687          '</form>';
688     } else {
689          if ($blog_id == $core->blog->id) {
690               echo '<p class="message">'.__('The current blog cannot be deleted.').'</p>';
691          } else {
692               echo '<p class="message">'.__('Only superadmin can delete a blog.').'</p>';
693          }
694     }
695
696     echo '</div>';
697
698     #
699     # Users on the blog (with permissions)
700
701     $blog_users = $core->getBlogPermissions($blog_id,$core->auth->isSuperAdmin());
702     $perm_types = $core->auth->getPermissionsTypes();
703
704     echo
705     '<div class="multi-part" id="users" title="'.__('Users').'">'.
706     '<h3 class="out-of-screen-if-js">'.__('Users on this blog').'</h3>';
707
708     if (empty($blog_users))
709     {
710          echo '<p>'.__('No users').'</p>';
711     }
712     else
713     {
714          if ($core->auth->isSuperAdmin()) {
715               $user_url_p = '<a href="'.$core->adminurl->get("admin.user",array('id' => '%1$s'),'&amp;',true).'">%1$s</a>';
716          } else {
717               $user_url_p = '%1$s';
718          }
719
720          # Sort users list on user_id key
721          dcUtils::lexicalKeySort($blog_users);
722
723          $post_type = $core->getPostTypes();
724          $current_blog_id = $core->blog->id;
725          if ($blog_id != $core->blog->id) {
726               $core->setBlog($blog_id);
727          }
728
729          foreach ($blog_users as $k => $v)
730          {
731               if (count($v['p']) > 0)
732               {
733                    echo
734                    '<div class="user-perm">'.
735                    '<h4>'.sprintf($user_url_p,html::escapeHTML($k)).
736                    ' ('.html::escapeHTML(dcUtils::getUserCN(
737                         $k, $v['name'], $v['firstname'], $v['displayname']
738                    )).')</h4>';
739
740                    if ($core->auth->isSuperAdmin()) {
741                         echo
742                         '<p>'.__('Email:').' '.
743                         ($v['email'] != '' ? '<a href="mailto:'.$v['email'].'">'.$v['email'].'</a>' : __('(none)')).
744                         '</p>';
745                    }
746
747                    echo
748                    '<h5>'.__('Publications on this blog:').'</h5>'.
749                    '<ul>';
750                    foreach ($post_type as $type => $pt_info) {
751                         $params = array(
752                              'post_type' => $type,
753                              'user_id' => $k
754                              );
755                         echo '<li>'.sprintf(__('%1$s: %2$s'),__($pt_info['label']),$core->blog->getPosts($params,true)->f(0)).'</li>';
756                    }
757                    echo
758                    '</ul>';
759
760                    echo
761                    '<h5>'.__('Permissions:').'</h5>'.
762                    '<ul>';
763                    if ($v['super']) {
764                         echo '<li class="user_super">'.__('Super administrator').'<br />'.
765                         '<span class="form-note">'.__('All rights on all blogs.').'</span></li>';
766                    } else {
767                         foreach ($v['p'] as $p => $V) {
768                              if (isset($perm_types[$p])) {
769                                   echo '<li '.($p == 'admin' ? 'class="user_admin"' : '').'>'.__($perm_types[$p]);
770                              } else {
771                                   echo '<li>'.sprintf(__('[%s] (unreferenced permission)'),$p);
772                              }
773
774                              if($p == 'admin') {
775                                   echo '<br /><span class="form-note">'.__('All rights on this blog.').'</span>';
776                              }
777                              echo '</li>';
778                         }
779                    }
780                    echo
781                    '</ul>';
782
783                    if (!$v['super'] && $core->auth->isSuperAdmin()) {
784                         echo
785                         '<form action="'.$core->adminurl->get('admin.user.actions').'" method="post">'.
786                         '<p class="change-user-perm"><input type="submit" class="reset" value="'.__('Change permissions').'" />'.
787                         form::hidden(array('redir'),$core->adminurl->get("admin.blog.pref",array('id' => $k),'&')).
788                         form::hidden(array('action'),'perms').
789                         form::hidden(array('users[]'),$k).
790                         form::hidden(array('blogs[]'),$blog_id).
791                         $core->formNonce().
792                         '</p>'.
793                         '</form>';
794                    }
795                    echo '</div>';
796               }
797          }
798          if ($current_blog_id != $core->blog->id) {
799               $core->setBlog($current_blog_id);
800          }
801     }
802
803     echo '</div>';
804}
805
806dcPage::helpBlock('core_blog_pref');
807dcPage::close();
Note: See TracBrowser for help on using the repository browser.

Sites map