Dotclear

source: admin/blog_pref.php @ 2852:86651202b279

Revision 2852:86651202b279, 28.2 KB checked in by Dsls, 11 years ago (diff)

Tuned redirections and admin urls management, should work with media & attachments now
Added adminurl->redirect to avoid confusion in "when to use & and when not to"

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

Sites map