[0] | 1 | <?php |
---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
| 3 | # |
---|
| 4 | # This file is part of Dotclear 2. |
---|
| 5 | # |
---|
[270] | 6 | # Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear |
---|
[0] | 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::check('usage,contentadmin'); |
---|
| 16 | |
---|
[1053] | 17 | function savePost($form) { |
---|
[1056] | 18 | global $_ctx; |
---|
[1089] | 19 | $_ctx->setAlert('save'); |
---|
[1053] | 20 | |
---|
| 21 | } |
---|
| 22 | |
---|
| 23 | function deletePost($form) { |
---|
| 24 | print_r($form); exit; |
---|
| 25 | } |
---|
[0] | 26 | |
---|
[195] | 27 | $page_title = __('New entry'); |
---|
[0] | 28 | |
---|
| 29 | $can_view_page = true; |
---|
| 30 | $can_edit_post = $core->auth->check('usage,contentadmin',$core->blog->id); |
---|
| 31 | $can_publish = $core->auth->check('publish,contentadmin',$core->blog->id); |
---|
| 32 | $can_delete = false; |
---|
| 33 | |
---|
| 34 | $post_headlink = '<link rel="%s" title="%s" href="post.php?id=%s" />'; |
---|
| 35 | $post_link = '<a href="post.php?id=%s" title="%s">%s</a>'; |
---|
| 36 | |
---|
| 37 | $next_link = $prev_link = $next_headlink = $prev_headlink = null; |
---|
| 38 | |
---|
| 39 | # If user can't publish |
---|
| 40 | if (!$can_publish) { |
---|
[992] | 41 | $form->post_status = -2; |
---|
[0] | 42 | } |
---|
| 43 | |
---|
| 44 | # Getting categories |
---|
| 45 | $categories_combo = array(' ' => ''); |
---|
| 46 | try { |
---|
| 47 | $categories = $core->blog->getCategories(array('post_type'=>'post')); |
---|
| 48 | while ($categories->fetch()) { |
---|
[1053] | 49 | $categories_combo[$categories->cat_id] = |
---|
| 50 | str_repeat(' ',$categories->level-1). |
---|
| 51 | ($categories->level-1 == 0 ? '' : '• '). |
---|
| 52 | html::escapeHTML($categories->cat_title); |
---|
[0] | 53 | } |
---|
| 54 | } catch (Exception $e) { } |
---|
| 55 | |
---|
| 56 | # Status combo |
---|
| 57 | foreach ($core->blog->getAllPostStatus() as $k => $v) { |
---|
[992] | 58 | $status_combo[$k] = $v; |
---|
[0] | 59 | } |
---|
| 60 | |
---|
| 61 | # Formaters combo |
---|
| 62 | foreach ($core->getFormaters() as $v) { |
---|
| 63 | $formaters_combo[$v] = $v; |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | # Languages combo |
---|
| 67 | $rs = $core->blog->getLangs(array('order'=>'asc')); |
---|
| 68 | $all_langs = l10n::getISOcodes(0,1); |
---|
| 69 | $lang_combo = array('' => '', __('Most used') => array(), __('Available') => l10n::getISOcodes(1,1)); |
---|
| 70 | while ($rs->fetch()) { |
---|
| 71 | if (isset($all_langs[$rs->post_lang])) { |
---|
| 72 | $lang_combo[__('Most used')][$all_langs[$rs->post_lang]] = $rs->post_lang; |
---|
| 73 | unset($lang_combo[__('Available')][$all_langs[$rs->post_lang]]); |
---|
| 74 | } else { |
---|
| 75 | $lang_combo[__('Most used')][$rs->post_lang] = $rs->post_lang; |
---|
| 76 | } |
---|
| 77 | } |
---|
| 78 | unset($all_langs); |
---|
| 79 | unset($rs); |
---|
| 80 | |
---|
[992] | 81 | $form = new dcForm($core,'post','post.php'); |
---|
| 82 | $form |
---|
| 83 | ->addField( |
---|
| 84 | new dcFieldText('post_title','', array( |
---|
| 85 | 'size' => 20, |
---|
| 86 | 'required' => true, |
---|
| 87 | 'label' => __('Title')))) |
---|
| 88 | ->addField( |
---|
| 89 | new dcFieldTextArea('post_excerpt','', array( |
---|
| 90 | 'cols' => 50, |
---|
| 91 | 'rows' => 5, |
---|
| 92 | 'label' => __("Excerpt:")))) |
---|
| 93 | ->addField( |
---|
| 94 | new dcFieldTextArea('post_content','', array( |
---|
| 95 | 'required' => true, |
---|
| 96 | 'label' => __("Content:")))) |
---|
| 97 | ->addField( |
---|
| 98 | new dcFieldTextArea('post_notes','', array( |
---|
| 99 | 'label' => __("Notes")))) |
---|
| 100 | ->addField( |
---|
[1053] | 101 | new dcFieldSubmit('save',__('Save'),array( |
---|
| 102 | 'action' => 'savePost'))) |
---|
[992] | 103 | ->addField( |
---|
[1053] | 104 | new dcFieldSubmit('delete',__('Delete'),array( |
---|
| 105 | 'action' => 'deletePost'))) |
---|
[1001] | 106 | ->addField( |
---|
[992] | 107 | new dcFieldCombo('post_status',$core->auth->getInfo('user_post_status'),$status_combo,array( |
---|
| 108 | 'disabled' => !$can_publish, |
---|
| 109 | 'label' => __('Entry status:')))) |
---|
| 110 | ->addField( |
---|
| 111 | new dcFieldCombo('cat_id','',$categories_combo,array( |
---|
| 112 | "label" => __('Category:')))) |
---|
| 113 | ->addField( |
---|
| 114 | new dcFieldText('post_dt','',array( |
---|
| 115 | "label" => __('Published on:')))) |
---|
| 116 | ->addField( |
---|
| 117 | new dcFieldCombo('post_format',$core->auth->getOption('post_format'),$formaters_combo,array( |
---|
| 118 | "label" => __('Text formating:')))) |
---|
| 119 | ->addField( |
---|
| 120 | new dcFieldCheckbox ('post_open_comment',$core->blog->settings->system->allow_comments,array( |
---|
| 121 | "label" => __('Accept comments')))) |
---|
| 122 | ->addField( |
---|
| 123 | new dcFieldCheckbox ('post_open_tb',$core->blog->settings->system->allow_trackbacks,array( |
---|
| 124 | "label" => __('Accept trackbacks')))) |
---|
| 125 | ->addField( |
---|
| 126 | new dcFieldCheckbox ('post_selected',false,array( |
---|
| 127 | "label" => __('Selected entry')))) |
---|
| 128 | ->addField( |
---|
| 129 | new dcFieldCombo ('post_lang',$core->auth->getInfo('user_lang'),$lang_combo, array( |
---|
| 130 | "label" => __('Entry lang:')))) |
---|
[1053] | 131 | ->addField( |
---|
| 132 | new dcFieldHidden ('id','')) |
---|
[992] | 133 | ; |
---|
[0] | 134 | # Get entry informations |
---|
| 135 | if (!empty($_REQUEST['id'])) |
---|
| 136 | { |
---|
| 137 | $params['post_id'] = $_REQUEST['id']; |
---|
| 138 | |
---|
| 139 | $post = $core->blog->getPosts($params); |
---|
| 140 | |
---|
| 141 | if ($post->isEmpty()) |
---|
| 142 | { |
---|
| 143 | $core->error->add(__('This entry does not exist.')); |
---|
| 144 | $can_view_page = false; |
---|
| 145 | } |
---|
| 146 | else |
---|
| 147 | { |
---|
[1053] | 148 | $form->id = $post->post_id; |
---|
[992] | 149 | $form->cat_id = $post->cat_id; |
---|
| 150 | $form->post_dt = date('Y-m-d H:i',strtotime($post->post_dt)); |
---|
| 151 | $form->post_format = $post->post_format; |
---|
| 152 | $form->post_password = $post->post_password; |
---|
| 153 | $form->post_url = $post->post_url; |
---|
| 154 | $form->post_lang = $post->post_lang; |
---|
| 155 | $form->post_title = $post->post_title; |
---|
| 156 | $form->post_excerpt = $post->post_excerpt; |
---|
[1053] | 157 | $form->post_excerpt_xhtml = $post->post_excerpt_xhtml; |
---|
[992] | 158 | $form->post_content = $post->post_content; |
---|
[1053] | 159 | $form->post_content_xhtml = $post->post_content_xhtml; |
---|
[992] | 160 | $form->post_notes = $post->post_notes; |
---|
| 161 | $form->post_status = $post->post_status; |
---|
| 162 | $form->post_selected = (boolean) $post->post_selected; |
---|
| 163 | $form->post_open_comment = (boolean) $post->post_open_comment; |
---|
| 164 | $form->post_open_tb = (boolean) $post->post_open_tb; |
---|
[1053] | 165 | $form->can_edit_post = $post->isEditable(); |
---|
| 166 | $form->can_delete= $post->isDeletable(); |
---|
[0] | 167 | |
---|
| 168 | } |
---|
| 169 | } |
---|
| 170 | |
---|
[1053] | 171 | $form->setup(); |
---|
[0] | 172 | |
---|
| 173 | /* DISPLAY |
---|
| 174 | -------------------------------------------------------- */ |
---|
| 175 | $default_tab = 'edit-entry'; |
---|
| 176 | if (!$can_edit_post) { |
---|
| 177 | $default_tab = ''; |
---|
| 178 | } |
---|
| 179 | if (!empty($_GET['co'])) { |
---|
| 180 | $default_tab = 'comments'; |
---|
| 181 | } |
---|
[1089] | 182 | |
---|
| 183 | $_ctx |
---|
| 184 | ->fillPageTitle(__('Entries'),'posts.php') |
---|
| 185 | ->fillPageTitle($page_title) |
---|
| 186 | ->default_tab = $default_tab; |
---|
[0] | 187 | |
---|
[1056] | 188 | $core->tpl->display('post.html.twig'); |
---|
[0] | 189 | ?> |
---|