Dotclear

source: admin/blog_pref.php @ 3270:7643f606453f

Revision 3270:7643f606453f, 30.4 KB checked in by franck <carnet.franck.paul@…>, 9 years ago (diff)

Add post URL sample, closes #1552

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

Sites map