| 1 | <?php |
|---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
|---|
| 3 | # |
|---|
| 4 | # This file is part of Dotclear 2. |
|---|
| 5 | # |
|---|
| 6 | # Copyright (c) 2003-2011 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 | require dirname(__FILE__).'/../inc/admin/prepend.php'; |
|---|
| 14 | |
|---|
| 15 | dcPage::checkSuper(); |
|---|
| 16 | |
|---|
| 17 | $blog_id = ''; |
|---|
| 18 | $blog_url = ''; |
|---|
| 19 | $blog_name = ''; |
|---|
| 20 | $blog_desc = ''; |
|---|
| 21 | |
|---|
| 22 | # Create a blog |
|---|
| 23 | if (!isset($_POST['id']) && !empty($_POST['blog_id'])) |
|---|
| 24 | { |
|---|
| 25 | $cur = $core->con->openCursor($core->prefix.'blog'); |
|---|
| 26 | $blog_id = $cur->blog_id = $_POST['blog_id']; |
|---|
| 27 | $blog_url = $cur->blog_url = $_POST['blog_url']; |
|---|
| 28 | $blog_name = $cur->blog_name = $_POST['blog_name']; |
|---|
| 29 | $blog_desc = $cur->blog_desc = $_POST['blog_desc']; |
|---|
| 30 | |
|---|
| 31 | try |
|---|
| 32 | { |
|---|
| 33 | # --BEHAVIOR-- adminBeforeBlogCreate |
|---|
| 34 | $core->callBehavior('adminBeforeBlogCreate',$cur,$blog_id); |
|---|
| 35 | |
|---|
| 36 | $core->addBlog($cur); |
|---|
| 37 | |
|---|
| 38 | # Default settings and override some |
|---|
| 39 | $core->blogDefaults($cur->blog_id); |
|---|
| 40 | $blog_settings = new dcSettings($core,$cur->blog_id); |
|---|
| 41 | $blog_settings->addNamespace('system'); |
|---|
| 42 | $blog_settings->system->put('lang',$core->auth->getInfo('user_lang')); |
|---|
| 43 | $blog_settings->system->put('blog_timezone',$core->auth->getInfo('user_tz')); |
|---|
| 44 | |
|---|
| 45 | if (substr($blog_url,-1) == '?') { |
|---|
| 46 | $blog_settings->system->put('url_scan','query_string'); |
|---|
| 47 | } else { |
|---|
| 48 | $blog_settings->system->put('url_scan','path_info'); |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | # --BEHAVIOR-- adminAfterBlogCreate |
|---|
| 52 | $core->callBehavior('adminAfterBlogCreate',$cur,$blog_id,$blog_settings); |
|---|
| 53 | |
|---|
| 54 | http::redirect('blog.php?id='.$cur->blog_id.'&add=1'); |
|---|
| 55 | } |
|---|
| 56 | catch (Exception $e) |
|---|
| 57 | { |
|---|
| 58 | $core->error->add($e->getMessage()); |
|---|
| 59 | } |
|---|
| 60 | } |
|---|
| 61 | |
|---|
| 62 | if (!empty($_REQUEST['id'])) |
|---|
| 63 | { |
|---|
| 64 | $edit_blog_mode = true; |
|---|
| 65 | include dirname(__FILE__).'/blog_pref.php'; |
|---|
| 66 | } |
|---|
| 67 | else |
|---|
| 68 | { |
|---|
| 69 | dcPage::open(__('New blog'),dcPage::jsConfirmClose('blog-form')); |
|---|
| 70 | |
|---|
| 71 | echo |
|---|
| 72 | '<h2><a href="blogs.php">'.__('Blogs').'</a> › <span class="page-title">'.__('New blog').'</span></h2>'. |
|---|
| 73 | |
|---|
| 74 | '<form action="blog.php" method="post" id="blog-form" class="fieldset">'. |
|---|
| 75 | |
|---|
| 76 | $core->formNonce(). |
|---|
| 77 | '<p><label class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Blog ID:').' '. |
|---|
| 78 | form::field('blog_id',30,32,html::escapeHTML($blog_id)).'</label></p>'. |
|---|
| 79 | '<p class="form-note">'.__('At least 2 characters using letters, numbers or symbols.').'</p> '. |
|---|
| 80 | '<p class="form-note warn">'.__('Please note that changing your blog ID may require changes in your public index.php file.').'</p>'. |
|---|
| 81 | |
|---|
| 82 | '<p><label class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Blog name:').' '. |
|---|
| 83 | form::field('blog_name',30,255,html::escapeHTML($blog_name)).'</label></p>'. |
|---|
| 84 | |
|---|
| 85 | '<p><label class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Blog URL:').' '. |
|---|
| 86 | form::field('blog_url',30,255,html::escapeHTML($blog_url)).'</label></p>'. |
|---|
| 87 | |
|---|
| 88 | '<p class="area"><label for="blog_desc">'.__('Blog description:').'</label> '. |
|---|
| 89 | form::textarea('blog_desc',60,5,html::escapeHTML($blog_desc)).'</p>'. |
|---|
| 90 | |
|---|
| 91 | '<p><input type="submit" accesskey="s" value="'.__('Create').'" /></p>'. |
|---|
| 92 | '</form>'; |
|---|
| 93 | |
|---|
| 94 | dcPage::close(); |
|---|
| 95 | } |
|---|
| 96 | ?> |
|---|