Dotclear

source: admin/blog_pref.php @ 2900:d12215a1a1e7

Revision 2900:d12215a1a1e7, 31.1 KB checked in by Dsls, 11 years ago (diff)

First shot for per_blog settings for plugins, see #2041

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 && $core->auth->check('admin',$blog_id))
163{
164     if (isset($_POST['save_blog'])) {
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               exit;
284          }
285          catch (Exception $e)
286          {
287               $core->error->add($e->getMessage());
288          }
289     } elseif (isset($_POST['enable']) && is_array($_POST['enable'])) {
290          $blog_settings->addNamespace('pluginsactivated');
291          foreach ($_POST['enable'] as $id => $desc) {
292               if ($core->plugins->moduleExists($id) && 
293                    ($blog_settings->pluginsactivated->get($id) !== null) &&
294                    $core->plugins->moduleInfo($id,'perblog_activation')) {
295                    $blog_settings->pluginsactivated->put($id,true);
296               }
297          }
298          dcPage::addSuccessNotice(__('Plugin successfully enabled.'));
299          http::redirect(sprintf($redir,$blog_id)."#plugins");
300          exit;
301     } elseif (isset($_POST['disable']) && is_array($_POST['disable'])) {
302          $blog_settings->addNamespace('pluginsactivated');
303          foreach ($_POST['disable'] as $id => $desc) {
304               if ($core->plugins->moduleExists($id) && 
305                    ($blog_settings->pluginsactivated->get($id) !== null) &&
306                    $core->plugins->moduleInfo($id,'perblog_activation')) {
307                    $blog_settings->pluginsactivated->put($id,false);
308               }
309          }
310          dcPage::addSuccessNotice(__('Plugin successfully disabled.'));
311          http::redirect(sprintf($redir,$blog_id)."#plugins");
312          exit;
313     }
314}
315
316if ($standalone) {
317     $breadcrumb = dcPage::breadcrumb(
318          array(
319               html::escapeHTML($blog_name) => '',
320               __('Blog settings') => ''
321          )
322     );
323} else {
324     $breadcrumb = dcPage::breadcrumb(
325          array(
326               __('System') => '',
327               __('Blogs') => $core->adminurl->get("admin.blogs"),
328               __('Blog settings').' : '.html::escapeHTML($blog_name) => ''
329          ));
330}
331
332dcPage::open(__('Blog settings'),
333     '<script type="text/javascript">'."\n".
334     "//<![CDATA["."\n".
335     dcPage::jsVar('dotclear.msg.warning_path_info',
336          __('Warning: except for special configurations, it is generally advised to have a trailing "/" in your blog URL in PATH_INFO mode.'))."\n".
337     dcPage::jsVar('dotclear.msg.warning_query_string',
338          __('Warning: except for special configurations, it is generally advised to have a trailing "?" in your blog URL in QUERY_STRING mode.'))."\n".
339     "//]]>".
340     "</script>".
341     dcPage::jsConfirmClose('blog-form').
342     $core->callBehavior('adminPostEditor').
343     dcPage::jsLoad('js/_blog_pref.js').
344
345
346     # --BEHAVIOR-- adminBlogPreferencesHeaders
347     $core->callBehavior('adminBlogPreferencesHeaders').
348
349     dcPage::jsPageTabs(),
350     $breadcrumb
351);
352
353if ($blog_id)
354{
355     if (!empty($_GET['add'])) {
356          dcPage::success(__('Blog has been successfully created.'));
357     }
358
359     if (!empty($_GET['upd'])) {
360          dcPage::success(__('Blog has been successfully updated.'));
361     }
362
363     echo
364     '<div class="multi-part" id="params" title="'.__('Parameters').'">'.
365     '<h3 class="out-of-screen-if-js">'.__('Parameters').'</h3>'.
366     '<form action="'.$action.'" method="post" id="blog-form">';
367
368     echo
369     '<div class="fieldset"><h4>'.__('Blog details').'</h4>';
370
371     if ($core->auth->isSuperAdmin())
372     {
373          echo
374          '<p><label for="blog_id" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Blog ID:').'</label>'.
375          form::field('blog_id',30,32,html::escapeHTML($blog_id)).'</p>'.
376          '<p class="form-note">'.__('At least 2 characters using letters, numbers or symbols.').'</p> '.
377          '<p class="form-note warn">'.__('Please note that changing your blog ID may require changes in your public index.php file.').'</p>';
378     }
379
380     echo
381     '<p><label for="blog_name" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Blog name:').'</label>'.
382     form::field('blog_name',30,255,html::escapeHTML($blog_name)).'</p>';
383
384     if ($core->auth->isSuperAdmin())
385     {
386          echo
387          '<p><label for="blog_url" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Blog URL:').'</label>'.
388          form::field('blog_url',50,255,html::escapeHTML($blog_url)).'</p>'.
389
390          '<p><label for="url_scan">'.__('URL scan method:').'</label>'.
391          form::combo('url_scan',$url_scan_combo,$blog_settings->system->url_scan).'</p>';
392
393          try
394          {
395               # Test URL of blog by testing it's ATOM feed
396               $file = $blog_url.$core->url->getURLFor('feed','atom');
397               $path = '';
398               $status = '404';
399               $content = '';
400
401               $client = netHttp::initClient($file,$path);
402               if ($client !== false) {
403                    $client->setTimeout(4);
404                    $client->setUserAgent($_SERVER['HTTP_USER_AGENT']);
405                    $client->get($path);
406                    $status = $client->getStatus();
407                    $content = $client->getContent();
408               }
409               if ($status != '200') {
410                    // Might be 404 (URL not found), 670 (blog not online), ...
411                    echo
412                    '<p class="form-note warn">'.
413                    sprintf(__('The URL of blog or the URL scan method might not be well set (<code>%s</code> return a <strong>%s</strong> status).'),
414                              $file,$status).
415                    '</p>';
416               } else {
417                    if (substr($content,0,6) != '<?xml ') {
418                         // Not well formed XML feed
419                         echo
420                         '<p class="form-note warn">'.
421                         sprintf(__('The URL of blog or the URL scan method might not be well set (<code>%s</code> does not return an ATOM feed).'),
422                                   $file).
423                         '</p>';
424                    }
425               }
426          }
427          catch (Exception $e)
428          {
429               $core->error->add($e->getMessage());
430          }
431          echo
432          '<p><label for="blog_status">'.__('Blog status:').'</label>'.
433          form::combo('blog_status',$status_combo,$blog_status).'</p>';
434     }
435
436     echo
437     '<p class="area"><label for="blog_desc">'.__('Blog description:').'</label>'.
438     form::textarea('blog_desc',60,5,html::escapeHTML($blog_desc)).'</p>'.
439     '</div>';
440
441
442     echo
443     '<div class="fieldset"><h4>'.__('Blog configuration').'</h4>'.
444     '<div class="two-cols">'.
445     '<div class="col">'.
446     '<p><label for="editor">'.__('Blog editor name:').'</label>'.
447     form::field('editor',30,255,html::escapeHTML($blog_settings->system->editor)).
448     '</p>'.
449
450     '<p><label for="lang">'.__('Default language:').'</label>'.
451     form::combo('lang',$lang_combo,$blog_settings->system->lang,'l10n').
452     '</p>'.
453
454     '<p><label for="blog_timezone">'.__('Blog timezone:').'</label>'.
455     form::combo('blog_timezone',dt::getZones(true,true),html::escapeHTML($blog_settings->system->blog_timezone)).
456     '</p>'.
457
458     '<p><label for="copyright_notice">'.__('Copyright notice:').'</label>'.
459     form::field('copyright_notice',30,255,html::escapeHTML($blog_settings->system->copyright_notice)).
460     '</p>'.
461     '</div>'.
462
463     '<div class="col">'.
464     '<p><label for="post_url_format">'.__('New post URL format:').'</label>'.
465     form::combo('post_url_format',$post_url_combo,html::escapeHTML($blog_settings->system->post_url_format)).
466     '</p>'.
467
468     '<p><label for="note_title_tag">'.__('HTML tag for the title of the notes on the blog:').'</label>'.
469     form::combo('note_title_tag',$note_title_tag_combo,$blog_settings->system->note_title_tag).
470     '</p>'.
471
472     '<p><label for="enable_xmlrpc" class="classic">'.'</label>'.
473     form::checkbox('enable_xmlrpc','1',$blog_settings->system->enable_xmlrpc).
474     __('Enable XML/RPC interface').'</p>';
475
476     echo
477          '<p class="form-note info">'.__('XML/RPC interface allows you to edit your blog with an external client.').'</p>';
478
479     if ($blog_settings->system->enable_xmlrpc) {
480          echo
481          '<p>'.__('XML/RPC interface is active. You should set the following parameters on your XML/RPC client:').'</p>'.
482          '<ul>'.
483          '<li>'.__('Server URL:').' <strong><code>'.
484          sprintf(DC_XMLRPC_URL,$core->blog->url,$core->blog->id).
485          '</code></strong></li>'.
486          '<li>'.__('Blogging system:').' <strong><code>Movable Type</code></strong></li>'.
487          '<li>'.__('User name:').' <strong><code>'.$core->auth->userID().'</code></strong></li>'.
488          '<li>'.__('Password:').' <strong><code>&lt;'.__('your password').'&gt;</code></strong></li>'.
489          '<li>'.__('Blog ID:').' <strong><code>1</code></strong></li>'.
490          '</ul>';
491     }
492
493     echo
494     '</div>'.
495     '</div>'.
496     '<br class="clear" />'. //Opera sucks
497     '</div>';
498
499     echo
500     '<div class="fieldset"><h4>'.__('Comments and trackbacks').'</h4>'.
501
502     '<div class="two-cols">'.
503
504     '<div class="col">'.
505     '<p><label for="allow_comments" class="classic">'.
506     form::checkbox('allow_comments','1',$blog_settings->system->allow_comments).
507     __('Accept comments').'</label></p>'.
508     '<p><label for="comments_pub" class="classic">'.
509     form::checkbox('comments_pub','1',!$blog_settings->system->comments_pub).
510     __('Moderate comments').'</label></p>'.
511     '<p><label for="comments_ttl" class="classic">'.sprintf(__('Leave comments open for %s days').'.',
512     form::field('comments_ttl',2,3,$blog_settings->system->comments_ttl)).
513     '</label></p>'.
514     '<p class="form-note">'.__('No limit: leave blank.').'</p>'.
515     '<p><label for="wiki_comments" class="classic">'.
516     form::checkbox('wiki_comments','1',$blog_settings->system->wiki_comments).
517     __('Wiki syntax for comments').'</label></p>'.
518     '<p><label for="comment_preview_optional" class="classic">'.
519     form::checkbox('comment_preview_optional','1',$blog_settings->system->comment_preview_optional).
520     __('Preview of comment before submit is not mandatory').'</label></p>'.
521     '</div>'.
522
523     '<div class="col">'.
524     '<p><label for="allow_trackbacks" class="classic">'.
525     form::checkbox('allow_trackbacks','1',$blog_settings->system->allow_trackbacks).
526     __('Accept trackbacks').'</label></p>'.
527     '<p><label for="trackbacks_pub" class="classic">'.
528     form::checkbox('trackbacks_pub','1',!$blog_settings->system->trackbacks_pub).
529     __('Moderate trackbacks').'</label></p>'.
530     '<p><label for="trackbacks_ttl" class="classic">'.sprintf(__('Leave trackbacks open for %s days').'.',
531     form::field('trackbacks_ttl',2,3,$blog_settings->system->trackbacks_ttl)).'</label></p>'.
532     '<p class="form-note">'.__('No limit: leave blank.').'</p>'.
533     '<p><label for="comments_nofollow" class="classic">'.
534     form::checkbox('comments_nofollow','1',$blog_settings->system->comments_nofollow).
535     __('Add "nofollow" relation on comments and trackbacks links').'</label></p>'.
536     '</div>'.
537     '<br class="clear" />'. //Opera sucks
538
539     '</div>'.
540     '<br class="clear" />'. //Opera sucks
541     '</div>';
542
543     echo
544     '<div class="fieldset"><h4>'.__('Blog presentation').'</h4>'.
545     '<div class="two-cols">'.
546     '<div class="col">'.
547     '<p><label for="date_format">'.__('Date format:').'</label> '.
548     form::field('date_format',30,255,html::escapeHTML($blog_settings->system->date_format)).
549     form::combo('date_format_select',$date_formats_combo,'','','',false,'title="'.__('Pattern of date').'"').
550     '</p>'.
551     '<p class="chosen form-note">'.__('Sample:').' '.dt::str(html::escapeHTML($blog_settings->system->date_format)).'</p>'.
552
553     '<p><label for="time_format">'.__('Time format:').'</label>'.
554     form::field('time_format',30,255,html::escapeHTML($blog_settings->system->time_format)).
555     form::combo('time_format_select',$time_formats_combo,'','','',false,'title="'.__('Pattern of time').'"').
556     '</p>'.
557     '<p class="chosen form-note">'.__('Sample:').' '.dt::str(html::escapeHTML($blog_settings->system->time_format)).'</p>'.
558
559     '<p><label for="use_smilies" class="classic">'.
560     form::checkbox('use_smilies','1',$blog_settings->system->use_smilies).
561     __('Display smilies on entries and comments').'</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     '</div>'.
611
612     '<div class="col">'.
613     '<h5>'.__('Default image insertion attributes').'</h5>'.
614     '<p class="vertical-separator"><label for="media_img_title_pattern">'.__('Inserted image title').'</label>'.
615     form::combo('media_img_title_pattern',$img_title_combo,html::escapeHTML($blog_settings->system->media_img_title_pattern)).'</p>'.
616     '<p><label for="media_img_use_dto_first" class="classic">'.
617     form::checkbox('media_img_use_dto_first','1',$blog_settings->system->media_img_use_dto_first).
618     __('Use original media date if possible').'</label></p>'.
619     '<p><label for="media_img_no_date_alone" class="classic">'.
620     form::checkbox('media_img_no_date_alone','1',$blog_settings->system->media_img_no_date_alone).
621     __('Do not display date if alone in title').'</label></p>'.
622     '<p class="form-note info">'.__('It is retrieved from the picture\'s metadata.').'</p>'.
623
624     '<p class="field vertical-separator"><label for="media_img_default_size">'.__('Size of inserted image:').'</label>'.
625     form::combo('media_img_default_size',$img_default_size_combo,
626          (html::escapeHTML($blog_settings->system->media_img_default_size) != '' ? html::escapeHTML($blog_settings->system->media_img_default_size) : 'm')).
627     '</p>'.
628     '<p class="field"><label for="media_img_default_alignment">'.__('Image alignment:').'</label>'.
629     form::combo('media_img_default_alignment',$img_default_alignment_combo,html::escapeHTML($blog_settings->system->media_img_default_alignment)).
630     '</p>'.
631     '<p><label for="media_img_default_link">'.
632     form::checkbox('media_img_default_link','1',$blog_settings->system->media_img_default_link).
633     __('Insert a link to the original image').'</label></p>'.
634     '</div>'.
635     '</div>'.
636     '<br class="clear" />'. //Opera sucks
637
638     '</div>';
639
640     echo
641     '<div class="fieldset"><h4>'.__('Search engines robots policy').'</h4>';
642
643     $i = 0;
644     foreach ($robots_policy_options as $k => $v)
645     {
646          echo '<p><label for="robots_policy-'.$i.'" class="classic">'.
647          form::radio(array('robots_policy','robots_policy-'.$i),$k,$blog_settings->system->robots_policy == $k).' '.$v.'</label></p>';
648          $i++;
649     }
650
651     echo '</div>';
652
653     echo
654     '<div class="fieldset"><h4>'.__('jQuery javascript library').'</h4>'.
655     '<p><label for="jquery_version" class="classic">'.__('jQuery version to be loaded for this blog:').'</label>'.' '.
656     form::combo('jquery_version',$jquery_versions_combo,$blog_settings->system->jquery_version).
657     '</p>'.
658     '<br class="clear" />'. //Opera sucks
659     '</div>';
660
661     echo
662     '<div class="fieldset"><h4>'.__('Blog security').'</h4>'.
663     '<p><label for="prevents_clickjacking" class="classic">'.
664     form::checkbox('prevents_clickjacking','1',$blog_settings->system->prevents_clickjacking).
665     __('Protect the blog from Clickjacking (see <a href="https://en.wikipedia.org/wiki/Clickjacking">Wikipedia</a>)').'</label></p>'.
666     '<br class="clear" />'. //Opera sucks
667     '</div>';
668
669     # --BEHAVIOR-- adminBlogPreferencesForm
670     $core->callBehavior('adminBlogPreferencesForm',$core,$blog_settings);
671
672     echo
673     '<p><input type="submit" accesskey="s" name="save_blog" value="'.__('Save').'" />'.
674     (!$standalone ? form::hidden('id',$blog_id) : '').
675     $core->formNonce().
676     '</p>'.
677     '</form>';
678
679     if ($core->auth->isSuperAdmin() && $blog_id != $core->blog->id)
680     {
681          echo
682          '<form action="'.$core->adminurl->get("admin.blog.del").'" method="post">'.
683          '<p><input type="submit" class="delete" value="'.__('Delete this blog').'" />'.
684          form::hidden(array('blog_id'),$blog_id).
685          $core->formNonce().'</p>'.
686          '</form>';
687     } else {
688          if ($blog_id == $core->blog->id) {
689               echo '<p class="message">'.__('The current blog cannot be deleted.').'</p>';
690          } else {
691               echo '<p class="message">'.__('Only superadmin can delete a blog.').'</p>';
692          }
693     }
694
695     echo '</div>';
696
697     #
698     # Users on the blog (with permissions)
699
700     $blog_users = $core->getBlogPermissions($blog_id,$core->auth->isSuperAdmin());
701     $perm_types = $core->auth->getPermissionsTypes();
702
703     echo
704     '<div class="multi-part" id="users" title="'.__('Users').'">'.
705     '<h3 class="out-of-screen-if-js">'.__('Users on this blog').'</h3>';
706
707     if (empty($blog_users))
708     {
709          echo '<p>'.__('No users').'</p>';
710     }
711     else
712     {
713          if ($core->auth->isSuperAdmin()) {
714               $user_url_p = '<a href="'.$core->adminurl->get("admin.user",array('id' => '%1$s')).'">%1$s</a>';
715          } else {
716               $user_url_p = '%1$s';
717          }
718
719          # Sort users list on user_id key
720          ksort($blog_users);
721
722          $post_type = $core->getPostTypes();
723          $current_blog_id = $core->blog->id;
724          if ($blog_id != $core->blog->id) {
725               $core->setBlog($blog_id);
726          }
727
728          foreach ($blog_users as $k => $v)
729          {
730               if (count($v['p']) > 0)
731               {
732                    echo
733                    '<div class="user-perm">'.
734                    '<h4>'.sprintf($user_url_p,html::escapeHTML($k)).
735                    ' ('.html::escapeHTML(dcUtils::getUserCN(
736                         $k, $v['name'], $v['firstname'], $v['displayname']
737                    )).')</h4>';
738
739                    if ($core->auth->isSuperAdmin()) {
740                         echo
741                         '<p>'.__('Email:').' '.
742                         ($v['email'] != '' ? '<a href="mailto:'.$v['email'].'">'.$v['email'].'</a>' : __('(none)')).
743                         '</p>';
744                    }
745
746                    echo
747                    '<h5>'.__('Publications on this blog:').'</h5>'.
748                    '<ul>';
749                    foreach ($post_type as $type => $pt_info) {
750                         $params = array(
751                              'post_type' => $type,
752                              'user_id' => $k
753                              );
754                         echo '<li>'.sprintf(__('%1$s: %2$s'),__($pt_info['label']),$core->blog->getPosts($params,true)->f(0)).'</li>';
755                    }
756                    echo
757                    '</ul>';
758
759                    echo
760                    '<h5>'.__('Permissions:').'</h5>'.
761                    '<ul>';
762                    if ($v['super']) {
763                         echo '<li class="user_super">'.__('Super administrator').'<br />'.
764                         '<span class="form-note">'.__('All rights on all blogs.').'</span></li>';
765                    } else {
766                         foreach ($v['p'] as $p => $V) {
767                              if (isset($perm_types[$p])) {
768                                   echo '<li '.($p == 'admin' ? 'class="user_admin"' : '').'>'.__($perm_types[$p]);
769                              } else {
770                                   echo '<li>'.sprintf(__('[%s] (unreferenced permission)'),$p);
771                              }
772
773                              if($p == 'admin') {
774                                   echo '<br /><span class="form-note">'.__('All rights on this blog.').'</span>';
775                              }
776                              echo '</li>';
777                         }
778                    }
779                    echo
780                    '</ul>';
781
782                    if (!$v['super'] && $core->auth->isSuperAdmin()) {
783                         echo
784                         '<form action="'.$core->adminurl->get('admin.user.actions').'" method="post">'.
785                         '<p class="change-user-perm"><input type="submit" class="reset" value="'.__('Change permissions').'" />'.
786                         form::hidden(array('redir'),$core->adminurl->get("admin.blog.pref",array('id' => $k),'&')).
787                         form::hidden(array('action'),'perms').
788                         form::hidden(array('users[]'),$k).
789                         form::hidden(array('blogs[]'),$blog_id).
790                         $core->formNonce().
791                         '</p>'.
792                         '</form>';
793                    }
794                    echo '</div>';
795               }
796          }
797          if ($current_blog_id != $core->blog->id) {
798               $core->setBlog($current_blog_id);
799          }
800     }
801
802
803     echo '</div>';
804
805     #
806     # Per-blog activated plugins
807     $plugins = $core->plugins->getModules();
808     $plugins_activation = array();
809
810     foreach ($plugins as $id => $p) {
811          if ($core->plugins->moduleInfo($id,'perblog_activation')) {
812               $plugins_activation[$id]=$core->blog->settings->pluginsactivated->get($id);
813          }
814     }
815     echo
816     '<div class="multi-part" id="plugins" title="'.__('Plugins').'">'.
817     '<h3 class="out-of-screen-if-js">'.__('Plugins').'</h3>'.
818     '<div class="fieldset"><h4>'.__('Plugins activation for this blog').'</h4>';
819     if (!count($plugins_activation)) {
820          echo '<p>'.__('No per-blog plugins configured for this blog').'</p>';
821     } else {
822          echo
823               '<form action="'.$core->adminurl->getBase('admin.blog.pref').'" method="POST">'.
824               '<table><thead>'.
825               '<th class="first nowrap">'.__('Plugin').'</th>'.
826               '<th class="first nowrap maximal">'.__('Description').'</th>'.
827               '<th class="nowrap">'.__('Status').'</th>'.
828               '<th class="minimal nowrap">'.__('Action').'</th>'.
829               '</thead>';
830          foreach ($plugins_activation as $id => $enabled) {
831               echo 
832                    '<tr><td>'.$core->plugins->moduleInfo($id,'name').'</td>'.
833                    '<td>'.$core->plugins->moduleInfo($id,'desc').'</td>';
834
835               if ($enabled) {
836                    echo
837                         '<td>'.__('Enabled').'</td>'.
838                         '<td><input type="submit" class="reset" name="disable['.$id.']" value="'.__('Disable for this blog').'"/></td>';
839               } else {
840                    echo
841                         '<td>'.__('Disabled').'</td>'.
842                         '<td><input type="submit" name="enable['.$id.']" value="'.__('Enable for this blog').'"/></td>';
843               }
844               '</tr>';
845          }
846
847          echo 
848               '</table>'.
849               '<p><input type="submit" accesskey="s" name="save_plugins" value="'.__('Save').'" />'.
850                    (!$standalone ? form::hidden('id',$blog_id) : '').
851                    $core->formNonce().
852                    $core->adminurl->getHiddenFormFields('admin.blog');
853               '</p>'.
854               '</form>';
855     }
856     echo '</div>';
857     echo '</div>';
858
859}
860
861dcPage::helpBlock('core_blog_pref');
862dcPage::close();
Note: See TracBrowser for help on using the repository browser.

Sites map