Dotclear

source: admin/blog_pref.php @ 1846:033d8732c119

Revision 1846:033d8732c119, 23.7 KB checked in by franck <carnet.franck.paul@…>, 12 years ago (diff)

Some refinements to the blog prefs

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>'.__('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          # Test URL of blog by testing it's ATOM feed
329          $file = $blog_url.$core->url->getURLFor('feed','atom');
330          $path = '';
331          $status = '404';
332          $content = '';
333          $client = netHttp::initClient($file,$path);
334          if ($client !== false) {
335               $client->setTimeout(4);
336               $client->setUserAgent($_SERVER['HTTP_USER_AGENT']);
337               $client->get($path);
338               $status = $client->getStatus();
339               $content = $client->getContent();
340          }
341          if ($status != '200') {
342               // Might be 404 (URL not found), 670 (blog not online), ...
343               echo
344               '<p class="form-note warn">'.
345               sprintf(__('The URL of blog or the URL scan method might not be well set (<code>%s</code> return a <strong>%s</strong> status).'),
346                         $file,$status).
347               '</p>';
348          } else {
349               if (substr($content,0,6) != '<?xml ') {
350                    // Not well formed XML feed
351                    echo
352                    '<p class="form-note warn">'.
353                    sprintf(__('The URL of blog or the URL scan method might not be well set (<code>%s</code> does not return an ATOM feed).'),
354                              $file).
355                    '</p>';
356               }
357          }
358
359          echo
360          '<p><label for="blog_status">'.__('Blog status:').'</label>'.
361          form::combo('blog_status',$status_combo,$blog_status).'</p>';
362     }
363     
364     echo
365     '<p class="area"><label for="blog_desc">'.__('Blog description:').'</label>'.
366     form::textarea('blog_desc',60,5,html::escapeHTML($blog_desc)).'</p>'.
367     '</div>';
368     
369     
370     echo
371     '<div class="fieldset"><h4>'.__('Blog configuration').'</h4>'.
372     '<div class="two-cols">'.
373     '<div class="col">'.
374     '<p><label for="editor">'.__('Blog editor name:').'</label>'.
375     form::field('editor',30,255,html::escapeHTML($blog_settings->system->editor)).
376     '</p>'.
377     
378     '<p><label for="lang">'.__('Default language:').'</label>'.
379     form::combo('lang',$lang_combo,$blog_settings->system->lang,'l10n').
380     '</p>'.
381     
382     '<p><label for="blog_timezone">'.__('Blog timezone:').'</label>'.
383     form::combo('blog_timezone',dt::getZones(true,true),html::escapeHTML($blog_settings->system->blog_timezone)).
384     '</p>'.
385
386     '<p><label for="copyright_notice">'.__('Copyright notice:').'</label>'.
387     form::field('copyright_notice',30,255,html::escapeHTML($blog_settings->system->copyright_notice)).
388     '</p>'.
389     '</div>'.
390     
391     '<div class="col">'.
392     '<p><label for="post_url_format">'.__('New post URL format:').'</label>'.
393     form::combo('post_url_format',$post_url_combo,html::escapeHTML($blog_settings->system->post_url_format)).
394     '</p>'.
395
396     '<p><label for="note_title_tag">'.__('Note title HTML tag:').'</label>'.
397     form::combo('note_title_tag',$note_title_tag_combo,$blog_settings->system->note_title_tag).
398     '</p>'.
399         
400     '<p><label for="enable_xmlrpc" class="classic">'.'</label>'.
401     form::checkbox('enable_xmlrpc','1',$blog_settings->system->enable_xmlrpc).
402     __('Enable XML/RPC interface').'</p>';
403
404     echo
405          '<p class="form-note">'.__('XML/RPC interface allows you to edit your blog with an external client.').'</p>'; 
406
407     if ($blog_settings->system->enable_xmlrpc) {
408          echo
409          '<p>'.__('XML/RPC interface is active. You should set the following parameters on your XML/RPC client:').'</p>'.
410          '<ul>'.
411          '<li>'.__('Server URL:').' <strong><code>'.
412          sprintf(DC_XMLRPC_URL,$core->blog->url,$core->blog->id).
413          '</code></strong></li>'.
414          '<li>'.__('Blogging system:').' <strong><code>Movable Type</code></strong></li>'.
415          '<li>'.__('User name:').' <strong><code>'.$core->auth->userID().'</code></strong></li>'.
416          '<li>'.__('Password:').' <strong><code>&lt;'.__('your password').'&gt;</code></strong></li>'.
417          '<li>'.__('Blog ID:').' <strong><code>1</code></strong></li>'.
418          '</ul>';
419     }
420
421     echo
422     '</div>'.
423     '</div>'.
424     '<br class="clear" />'. //Opera sucks
425     '</div>';
426     
427     echo
428     '<div class="fieldset"><h4>'.__('Comments and trackbacks').'</h4>'.
429
430     '<div class="two-cols">'.
431
432     '<div class="col">'.
433     '<p><label for="allow_comments" class="classic">'.
434     form::checkbox('allow_comments','1',$blog_settings->system->allow_comments).
435     __('Accept comments').'</label></p>'.   
436     '<p><label for="comments_pub" class="classic">'.
437     form::checkbox('comments_pub','1',!$blog_settings->system->comments_pub).
438     __('Moderate comments').'</label></p>'. 
439     '<p><label for="comments_ttl" class="classic">'.sprintf(__('Leave comments open for %s days'),
440     form::field('comments_ttl',2,3,$blog_settings->system->comments_ttl)).
441     '</label></p>'.
442     '<p class="form-note">'.__('Leave blank to disable this feature.').'</p>'. 
443     '<p><label for="wiki_comments" class="classic">'.
444     form::checkbox('wiki_comments','1',$blog_settings->system->wiki_comments).
445     __('Wiki syntax for comments').'</label></p>'.
446     '</div>'.
447     
448     '<div class="col">'.
449     '<p><label for="allow_trackbacks" class="classic">'.
450     form::checkbox('allow_trackbacks','1',$blog_settings->system->allow_trackbacks).
451     __('Accept trackbacks').'</label></p>'. 
452     '<p><label for="trackbacks_pub" class="classic">'.
453     form::checkbox('trackbacks_pub','1',!$blog_settings->system->trackbacks_pub).
454     __('Moderate trackbacks').'</label></p>'.   
455     '<p><label for="trackbacks_ttl" class="classic">'.sprintf(__('Leave trackbacks open for %s days'),
456     form::field('trackbacks_ttl',2,3,$blog_settings->system->trackbacks_ttl)).'</label></p>'.
457     '<p class="form-note">'.__('Leave blank to disable this feature.').'</p>'. 
458     '<p><label for="comments_nofollow" class="classic">'.
459     form::checkbox('comments_nofollow','1',$blog_settings->system->comments_nofollow).
460     __('Add "nofollow" relation on comments and trackbacks links').'</label></p>'.
461     '</div>'.
462     '<br class="clear" />'. //Opera sucks
463
464     '</div>'.
465     '<br class="clear" />'. //Opera sucks
466     '</div>';
467     
468     echo
469     '<div class="fieldset"><h4>'.__('Blog presentation').'</h4>'.
470     '<div class="two-cols">'.
471     '<div class="col">'.
472     '<p><label for="date_format">'.__('Date format:').'</label>'.
473     form::field('date_format',30,255,html::escapeHTML($blog_settings->system->date_format)).
474     '</p>'.
475     
476     '<p><label for="time_format">'.__('Time format:').'</label>'.
477     form::field('time_format',30,255,html::escapeHTML($blog_settings->system->time_format)).
478     '</p>'.
479     
480     '<p><label for="use_smilies" class="classic">'.
481     form::checkbox('use_smilies','1',$blog_settings->system->use_smilies).
482     __('Display smilies on entries and comments').'</label></p>'.
483     '</div>'.
484     
485     '<div class="col">'.
486     '<p><label for="nb_post_per_page" class="classic">'.sprintf(__('Display %s entries per page'),
487     form::field('nb_post_per_page',2,3,$blog_settings->system->nb_post_per_page)).
488     '</label></p>'.
489     
490     '<p><label for="nb_post_per_feed" class="classic">'.sprintf(__('Display %s entries per feed'),
491     form::field('nb_post_per_feed',2,3,$blog_settings->system->nb_post_per_feed)).
492     '</label></p>'.
493     
494     '<p><label for="nb_comment_per_feed" class="classic">'.sprintf(__('Display %s comments per feed'),
495     form::field('nb_comment_per_feed',2,3,$blog_settings->system->nb_comment_per_feed)).
496     '</label></p>'.
497     
498     '<p><label for="short_feed_items" class="classic">'.
499     form::checkbox('short_feed_items','1',$blog_settings->system->short_feed_items).
500     __('Truncate feeds').'</label></p>'.
501     '</div>'.
502    '</div>'.
503     '<br class="clear" />'. //Opera sucks
504     '</div>';
505     
506     echo
507     '<div class="fieldset"><h4>'.__('Media and images').'</h4>'.
508     '<div class="two-cols">'.
509     '<div class="col">'.
510     '<h5>'.__('Generated image sizes (in pixels)').'</h5>'.
511     '<p class="field"><label for="media_img_t_size">'.__('Thumbnails:').'</label> '.
512     form::field('media_img_t_size',3,3,$blog_settings->system->media_img_t_size).'</p>'.
513     
514     '<p class="field"><label for="media_img_s_size">'.__('Small:').'</label> '.
515     form::field('media_img_s_size',3,3,$blog_settings->system->media_img_s_size).'</p>'.
516     
517     '<p class="field"><label for="media_img_m_size">'.__('Medium:').'</label> '.
518     form::field('media_img_m_size',3,3,$blog_settings->system->media_img_m_size).'</p>'.
519     '</div>'.
520     
521     '<div class="col">'.
522     '<h5>'.__('Default image insertion attributes').'</h5>'.
523     '<p class="field"><label for="media_img_title_pattern">'.__('Inserted image title').'</label>'.
524     form::combo('media_img_title_pattern',$img_title_combo,html::escapeHTML($blog_settings->system->media_img_title_pattern)).'</p>'.
525     '<p class="form-note">'.__('This defines image tag title when you insert it in a post from the media manager. It is retrieved from the picture\'s metadata.').'</p>'.
526     '<p><label for="media_img_use_dto_first" class="classic">'.
527     form::checkbox('media_img_use_dto_first','1',$blog_settings->system->media_img_use_dto_first).
528     __('Use original media date if possible').'</label></p>'.
529
530     '<p class="field"><label for="media_img_default_size">'.__('Image size:').'</label>'.
531     form::combo('media_img_default_size',$img_default_size_combo,
532          (html::escapeHTML($blog_settings->system->media_img_default_size) != '' ? html::escapeHTML($blog_settings->system->media_img_default_size) : 'm')).
533     '</p>'.
534     '<p class="field"><label for="media_img_default_alignment">'.__('Image alignment:').'</label>'.
535     form::combo('media_img_default_alignment',$img_default_alignment_combo,html::escapeHTML($blog_settings->system->media_img_default_alignment)).
536     '</p>'.
537     '<p><label for="media_img_default_link">'.
538     form::checkbox('media_img_default_link','1',$blog_settings->system->media_img_default_link).
539     __('Insert a link to the original image').'</label></p>'.
540     '</div>'.
541     '</div>'.
542     '<br class="clear" />'. //Opera sucks
543
544     '</div>';
545     
546     echo
547     '<div class="fieldset"><h4>'.__('Search engines robots policy').'</h4>';
548     
549     $i = 0;
550     foreach ($robots_policy_options as $k => $v)
551     {
552          echo '<p><label for="robots_policy-'.$i.'" class="classic">'.
553          form::radio(array('robots_policy','robots_policy-'.$i),$k,$blog_settings->system->robots_policy == $k).' '.$v.'</label></p>';
554          $i++;
555     }
556     
557     echo '</div>';
558     
559     
560     # --BEHAVIOR-- adminBlogPreferencesForm
561     $core->callBehavior('adminBlogPreferencesForm',$core,$blog_settings);
562     
563     echo
564     '<p><input type="submit" accesskey="s" value="'.__('Save').'" />'.
565     (!$standalone ? form::hidden('id',$blog_id) : '').
566     '</p>'.
567     '</form>';
568     
569     if ($core->auth->isSuperAdmin() && $blog_id != $core->blog->id)
570     {
571          echo
572          '<form action="blog_del.php" method="post">'.
573          '<p><input type="submit" class="delete" value="'.__('Delete this blog').'" />'.
574          form::hidden(array('blog_id'),$blog_id).
575          $core->formNonce().'</p>'.
576          '</form>';
577     } else {
578          if ($blog_id == $core->blog->id) {
579               echo '<p class="message">'.__('The current blog cannot be deleted.').'</p>';
580          } else {
581               echo '<p class="message">'.__('Only superadmin can delete a blog.').'</p>';
582          }
583     }
584     
585     echo '</div>';
586     
587     #
588     # Users on the blog (with permissions)
589     
590     $blog_users = $core->getBlogPermissions($blog_id,$core->auth->isSuperAdmin());
591     $perm_types = $core->auth->getPermissionsTypes();
592     
593     echo
594     '<div class="multi-part" id="users" title="'.__('Users').'">'.
595     '<h3>'.__('Users on this blog').'</h3>';
596     
597     if (empty($blog_users))
598     {
599          echo '<p>'.__('No users').'</p>';
600     }
601     else
602     {
603          if ($core->auth->isSuperAdmin()) {
604               $user_url_p = '<a href="user.php?id=%1$s">%1$s</a>';
605          } else {
606               $user_url_p = '%1$s';
607          }
608
609          # Sort users list on user_id key
610          ksort($blog_users);
611
612          $post_type = $core->getPostTypes();
613          $current_blog_id = $core->blog->id;
614          if ($blog_id != $core->blog->id) {
615               $core->setBlog($blog_id);
616          }
617
618          foreach ($blog_users as $k => $v)
619          {
620               if (count($v['p']) > 0)
621               {
622                    echo
623                    '<div class="user-perm">'.
624                    '<h4>'.sprintf($user_url_p,html::escapeHTML($k)).
625                    ' ('.html::escapeHTML(dcUtils::getUserCN(
626                         $k, $v['name'], $v['firstname'], $v['displayname']
627                    )).')</h4>';
628
629                    if ($core->auth->isSuperAdmin()) {
630                         echo 
631                         '<p>'.__('Email:').' '.
632                         ($v['email'] != '' ? '<a href="mailto:'.$v['email'].'">'.$v['email'].'</a>' : __('(none)')).
633                         '</p>';
634                    }
635
636                    echo
637                    '<h5>'.__('Publications on this blog:').'</h5>'.
638                    '<ul>';
639                    foreach ($post_type as $type => $pt_info) {
640                         $params = array(
641                              'post_type' => $type,
642                              'user_id' => $k
643                              );
644                         echo '<li>'.sprintf(__('%1$s: %2$s'),__($pt_info['label']),$core->blog->getPosts($params,true)->f(0)).'</li>';
645                    }
646                    echo
647                    '</ul>';
648
649                    echo
650                    '<h5>'.__('Permissions:').'</h5>'.
651                    '<ul>';
652                    if ($v['super']) {
653                         echo '<li class="user_super">'.__('Super administrator').'</li>';
654                    } else {
655                         foreach ($v['p'] as $p => $V) {
656                              echo '<li '.($p == 'admin' ? 'class="user_admin"' : '').'>'.__($perm_types[$p]).'</li>';
657                         }
658                    }
659                    echo 
660                    '</ul>';
661                   
662                    if (!$v['super'] && $core->auth->isSuperAdmin()) {
663                         echo 
664                         '<form action="users_actions.php" method="post">'.
665                         '<p class="change-user-perm"><input type="submit" class="reset" value="'.__('Change permissions').'" />'.
666                         form::hidden(array('redir'),'blog_pref.php?id='.$k).
667                         form::hidden(array('action'),'perms').
668                         form::hidden(array('users[]'),$k).
669                         form::hidden(array('blogs[]'),$blog_id).
670                         $core->formNonce().
671                         '</p>'.
672                         '</form>';
673                    }
674                    echo '</div>';
675               }
676          }
677          if ($current_blog_id != $core->blog->id) {
678               $core->setBlog($current_blog_id);
679          }
680     }
681     
682     echo '</div>';
683}
684
685dcPage::helpBlock('core_blog_pref');
686dcPage::close();
687?>
Note: See TracBrowser for help on using the repository browser.

Sites map