Dotclear

source: admin/blog_pref.php @ 2858:6f06ad9c208a

Revision 2858:6f06ad9c208a, 28.2 KB checked in by franck <carnet.franck.paul@…>, 11 years ago (diff)

Less dirty hack for URLs used as format with (s)printf() functions.

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

Sites map