Dotclear

source: admin/blog_pref.php @ 2014:d0613b4b66d5

Revision 2014:d0613b4b66d5, 24.3 KB checked in by franck <carnet.franck.paul@…>, 12 years ago (diff)

Should fixes #1709

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

Sites map