| 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 | if (!defined('DC_CONTEXT_ADMIN')) { return; } | 
|---|
| 13 | dcPage::check('pages,contentadmin'); | 
|---|
| 14 |  | 
|---|
| 15 | $redir_url = $p_url.'&act=page'; | 
|---|
| 16 |  | 
|---|
| 17 | $post_id = ''; | 
|---|
| 18 | $post_dt = ''; | 
|---|
| 19 | $post_format = $core->auth->getOption('post_format'); | 
|---|
| 20 | $post_editor = $core->auth->getOption('editor'); | 
|---|
| 21 | $post_password = ''; | 
|---|
| 22 | $post_url = ''; | 
|---|
| 23 | $post_lang = $core->auth->getInfo('user_lang'); | 
|---|
| 24 | $post_title = ''; | 
|---|
| 25 | $post_excerpt = ''; | 
|---|
| 26 | $post_excerpt_xhtml = ''; | 
|---|
| 27 | $post_content = ''; | 
|---|
| 28 | $post_content_xhtml = ''; | 
|---|
| 29 | $post_notes = ''; | 
|---|
| 30 | $post_status = $core->auth->getInfo('user_post_status'); | 
|---|
| 31 | $post_position = 0; | 
|---|
| 32 | $post_open_comment = false; | 
|---|
| 33 | $post_open_tb = false; | 
|---|
| 34 | $post_selected = false; | 
|---|
| 35 |  | 
|---|
| 36 | $post_media = array(); | 
|---|
| 37 |  | 
|---|
| 38 | $page_title = __('New page'); | 
|---|
| 39 |  | 
|---|
| 40 | $can_view_page = true; | 
|---|
| 41 | $can_edit_page = $core->auth->check('pages,usage',$core->blog->id); | 
|---|
| 42 | $can_publish = $core->auth->check('pages,publish,contentadmin',$core->blog->id); | 
|---|
| 43 | $can_delete = false; | 
|---|
| 44 |  | 
|---|
| 45 | $post_headlink = '<link rel="%s" title="%s" href="'.html::escapeURL($redir_url).'&id=%s" />'; | 
|---|
| 46 | $post_link = '<a href="'.html::escapeURL($redir_url).'&id=%s" title="%s">%s</a>'; | 
|---|
| 47 |  | 
|---|
| 48 | $next_link = $prev_link = $next_headlink = $prev_headlink = null; | 
|---|
| 49 |  | 
|---|
| 50 | # If user can't publish | 
|---|
| 51 | if (!$can_publish) { | 
|---|
| 52 | $post_status = -2; | 
|---|
| 53 | } | 
|---|
| 54 |  | 
|---|
| 55 | # Status combo | 
|---|
| 56 | $status_combo = dcAdminCombos::getPostStatusesCombo(); | 
|---|
| 57 |  | 
|---|
| 58 | $img_status_pattern = '<img class="img_select_option" alt="%1$s" title="%1$s" src="images/%2$s" />'; | 
|---|
| 59 |  | 
|---|
| 60 | # Formaters combo | 
|---|
| 61 | $core_formaters = $core->getFormaters(); | 
|---|
| 62 | $available_formats = array('' => ''); | 
|---|
| 63 | foreach ($core_formaters as $editor => $formats) { | 
|---|
| 64 | foreach ($formats as $format) { | 
|---|
| 65 | $available_formats[$format] = $format; | 
|---|
| 66 | } | 
|---|
| 67 | } | 
|---|
| 68 |  | 
|---|
| 69 | # Languages combo | 
|---|
| 70 | $rs = $core->blog->getLangs(array('order'=>'asc')); | 
|---|
| 71 | $lang_combo = dcAdminCombos::getLangsCombo($rs,true); | 
|---|
| 72 |  | 
|---|
| 73 | # Validation flag | 
|---|
| 74 | $bad_dt = false; | 
|---|
| 75 |  | 
|---|
| 76 | # Get page informations | 
|---|
| 77 | if (!empty($_REQUEST['id'])) | 
|---|
| 78 | { | 
|---|
| 79 | $params['post_type'] = 'page'; | 
|---|
| 80 | $params['post_id'] = $_REQUEST['id']; | 
|---|
| 81 |  | 
|---|
| 82 | $post = $core->blog->getPosts($params); | 
|---|
| 83 |  | 
|---|
| 84 | if ($post->isEmpty()) | 
|---|
| 85 | { | 
|---|
| 86 | $core->error->add(__('This page does not exist.')); | 
|---|
| 87 | $can_view_page = false; | 
|---|
| 88 | } | 
|---|
| 89 | else | 
|---|
| 90 | { | 
|---|
| 91 | $post_id = $post->post_id; | 
|---|
| 92 | $post_dt = date('Y-m-d H:i',strtotime($post->post_dt)); | 
|---|
| 93 | $post_format = $post->post_format; | 
|---|
| 94 | $post_password = $post->post_password; | 
|---|
| 95 | $post_url = $post->post_url; | 
|---|
| 96 | $post_lang = $post->post_lang; | 
|---|
| 97 | $post_title = $post->post_title; | 
|---|
| 98 | $post_excerpt = $post->post_excerpt; | 
|---|
| 99 | $post_excerpt_xhtml = $post->post_excerpt_xhtml; | 
|---|
| 100 | $post_content = $post->post_content; | 
|---|
| 101 | $post_content_xhtml = $post->post_content_xhtml; | 
|---|
| 102 | $post_notes = $post->post_notes; | 
|---|
| 103 | $post_status = $post->post_status; | 
|---|
| 104 | $post_position = (integer) $post->post_position; | 
|---|
| 105 | $post_open_comment = (boolean) $post->post_open_comment; | 
|---|
| 106 | $post_open_tb = (boolean) $post->post_open_tb; | 
|---|
| 107 | $post_selected = (boolean) $post->post_selected; | 
|---|
| 108 |  | 
|---|
| 109 | $page_title = __('Edit page'); | 
|---|
| 110 |  | 
|---|
| 111 | $can_edit_page = $post->isEditable(); | 
|---|
| 112 | $can_delete= $post->isDeletable(); | 
|---|
| 113 |  | 
|---|
| 114 | $next_rs = $core->blog->getNextPost($post,1); | 
|---|
| 115 | $prev_rs = $core->blog->getNextPost($post,-1); | 
|---|
| 116 |  | 
|---|
| 117 | if ($next_rs !== null) { | 
|---|
| 118 | $next_link = sprintf($post_link,$next_rs->post_id, | 
|---|
| 119 | html::escapeHTML($next_rs->post_title),__('Next page').' »'); | 
|---|
| 120 | $next_headlink = sprintf($post_headlink,'next', | 
|---|
| 121 | html::escapeHTML($next_rs->post_title),$next_rs->post_id); | 
|---|
| 122 | } | 
|---|
| 123 |  | 
|---|
| 124 | if ($prev_rs !== null) { | 
|---|
| 125 | $prev_link = sprintf($post_link,$prev_rs->post_id, | 
|---|
| 126 | html::escapeHTML($prev_rs->post_title),'« '.__('Previous page')); | 
|---|
| 127 | $prev_headlink = sprintf($post_headlink,'previous', | 
|---|
| 128 | html::escapeHTML($prev_rs->post_title),$prev_rs->post_id); | 
|---|
| 129 | } | 
|---|
| 130 |  | 
|---|
| 131 | try { | 
|---|
| 132 | $core->media = new dcMedia($core); | 
|---|
| 133 | $post_media = $core->media->getPostMedia($post_id); | 
|---|
| 134 | } catch (Exception $e) { | 
|---|
| 135 | $core->error->add($e->getMessage()); | 
|---|
| 136 | } | 
|---|
| 137 | } | 
|---|
| 138 | } | 
|---|
| 139 |  | 
|---|
| 140 | # Format content | 
|---|
| 141 | if (!empty($_POST) && $can_edit_page) | 
|---|
| 142 | { | 
|---|
| 143 | $post_format = $_POST['post_format']; | 
|---|
| 144 | $post_excerpt = $_POST['post_excerpt']; | 
|---|
| 145 | $post_content = $_POST['post_content']; | 
|---|
| 146 |  | 
|---|
| 147 | $post_title = $_POST['post_title']; | 
|---|
| 148 |  | 
|---|
| 149 | if (isset($_POST['post_status'])) { | 
|---|
| 150 | $post_status = (integer) $_POST['post_status']; | 
|---|
| 151 | } | 
|---|
| 152 |  | 
|---|
| 153 | if (empty($_POST['post_dt'])) { | 
|---|
| 154 | $post_dt = ''; | 
|---|
| 155 | } else { | 
|---|
| 156 | try | 
|---|
| 157 | { | 
|---|
| 158 | $post_dt = strtotime($_POST['post_dt']); | 
|---|
| 159 | if ($post_dt == false || $post_dt == -1) { | 
|---|
| 160 | $bad_dt = true; | 
|---|
| 161 | throw new Exception(__('Invalid publication date')); | 
|---|
| 162 | } | 
|---|
| 163 | $post_dt = date('Y-m-d H:i',$post_dt); | 
|---|
| 164 | } | 
|---|
| 165 | catch (Exception $e) | 
|---|
| 166 | { | 
|---|
| 167 | $core->error->add($e->getMessage()); | 
|---|
| 168 | } | 
|---|
| 169 | } | 
|---|
| 170 |  | 
|---|
| 171 | $post_open_comment = !empty($_POST['post_open_comment']); | 
|---|
| 172 | $post_open_tb = !empty($_POST['post_open_tb']); | 
|---|
| 173 | $post_selected = !empty($_POST['post_selected']); | 
|---|
| 174 | $post_lang = $_POST['post_lang']; | 
|---|
| 175 | $post_password = !empty($_POST['post_password']) ? $_POST['post_password'] : null; | 
|---|
| 176 | $post_position = (integer) $_POST['post_position']; | 
|---|
| 177 |  | 
|---|
| 178 | $post_notes = $_POST['post_notes']; | 
|---|
| 179 |  | 
|---|
| 180 | if (isset($_POST['post_url'])) { | 
|---|
| 181 | $post_url = $_POST['post_url']; | 
|---|
| 182 | } | 
|---|
| 183 |  | 
|---|
| 184 | $core->blog->setPostContent( | 
|---|
| 185 | $post_id,$post_format,$post_lang, | 
|---|
| 186 | $post_excerpt,$post_excerpt_xhtml,$post_content,$post_content_xhtml | 
|---|
| 187 | ); | 
|---|
| 188 | } | 
|---|
| 189 |  | 
|---|
| 190 | # Delete page | 
|---|
| 191 | if (!empty($_POST['delete']) && $can_delete) | 
|---|
| 192 | { | 
|---|
| 193 | try { | 
|---|
| 194 | # --BEHAVIOR-- adminBeforePageDelete | 
|---|
| 195 | $core->callBehavior('adminBeforePageDelete',$post_id); | 
|---|
| 196 | $core->blog->delPost($post_id); | 
|---|
| 197 | http::redirect($p_url); | 
|---|
| 198 | } catch (Exception $e) { | 
|---|
| 199 | $core->error->add($e->getMessage()); | 
|---|
| 200 | } | 
|---|
| 201 | } | 
|---|
| 202 |  | 
|---|
| 203 | # Create or update page | 
|---|
| 204 | if (!empty($_POST) && !empty($_POST['save']) && $can_edit_page && !$bad_dt) | 
|---|
| 205 | { | 
|---|
| 206 | $cur = $core->con->openCursor($core->prefix.'post'); | 
|---|
| 207 |  | 
|---|
| 208 | # Magic tweak :) | 
|---|
| 209 | $core->blog->settings->system->post_url_format = $page_url_format; | 
|---|
| 210 |  | 
|---|
| 211 | $cur->post_type = 'page'; | 
|---|
| 212 | $cur->post_title = $post_title; | 
|---|
| 213 | $cur->post_dt = $post_dt ? date('Y-m-d H:i:00',strtotime($post_dt)) : ''; | 
|---|
| 214 | $cur->post_format = $post_format; | 
|---|
| 215 | $cur->post_password = $post_password; | 
|---|
| 216 | $cur->post_lang = $post_lang; | 
|---|
| 217 | $cur->post_title = $post_title; | 
|---|
| 218 | $cur->post_excerpt = $post_excerpt; | 
|---|
| 219 | $cur->post_excerpt_xhtml = $post_excerpt_xhtml; | 
|---|
| 220 | $cur->post_content = $post_content; | 
|---|
| 221 | $cur->post_content_xhtml = $post_content_xhtml; | 
|---|
| 222 | $cur->post_notes = $post_notes; | 
|---|
| 223 | $cur->post_status = $post_status; | 
|---|
| 224 | $cur->post_position = $post_position; | 
|---|
| 225 | $cur->post_open_comment = (integer) $post_open_comment; | 
|---|
| 226 | $cur->post_open_tb = (integer) $post_open_tb; | 
|---|
| 227 | $cur->post_selected = (integer) $post_selected; | 
|---|
| 228 |  | 
|---|
| 229 | if (isset($_POST['post_url'])) { | 
|---|
| 230 | $cur->post_url = $post_url; | 
|---|
| 231 | } | 
|---|
| 232 |  | 
|---|
| 233 | # Update post | 
|---|
| 234 | if ($post_id) | 
|---|
| 235 | { | 
|---|
| 236 | try | 
|---|
| 237 | { | 
|---|
| 238 | # --BEHAVIOR-- adminBeforePageUpdate | 
|---|
| 239 | $core->callBehavior('adminBeforePageUpdate',$cur,$post_id); | 
|---|
| 240 |  | 
|---|
| 241 | $core->blog->updPost($post_id,$cur); | 
|---|
| 242 |  | 
|---|
| 243 | # --BEHAVIOR-- adminAfterPageUpdate | 
|---|
| 244 | $core->callBehavior('adminAfterPageUpdate',$cur,$post_id); | 
|---|
| 245 |  | 
|---|
| 246 | http::redirect($redir_url.'&id='.$post_id.'&upd=1'); | 
|---|
| 247 | } | 
|---|
| 248 | catch (Exception $e) | 
|---|
| 249 | { | 
|---|
| 250 | $core->error->add($e->getMessage()); | 
|---|
| 251 | } | 
|---|
| 252 | } | 
|---|
| 253 | else | 
|---|
| 254 | { | 
|---|
| 255 | $cur->user_id = $core->auth->userID(); | 
|---|
| 256 |  | 
|---|
| 257 | try | 
|---|
| 258 | { | 
|---|
| 259 | # --BEHAVIOR-- adminBeforePageCreate | 
|---|
| 260 | $core->callBehavior('adminBeforePageCreate',$cur); | 
|---|
| 261 |  | 
|---|
| 262 | $return_id = $core->blog->addPost($cur); | 
|---|
| 263 |  | 
|---|
| 264 | # --BEHAVIOR-- adminAfterPageCreate | 
|---|
| 265 | $core->callBehavior('adminAfterPageCreate',$cur,$return_id); | 
|---|
| 266 |  | 
|---|
| 267 | http::redirect($redir_url.'&id='.$return_id.'&crea=1'); | 
|---|
| 268 | } | 
|---|
| 269 | catch (Exception $e) | 
|---|
| 270 | { | 
|---|
| 271 | $core->error->add($e->getMessage()); | 
|---|
| 272 | } | 
|---|
| 273 | } | 
|---|
| 274 | } | 
|---|
| 275 |  | 
|---|
| 276 | /* DISPLAY | 
|---|
| 277 | -------------------------------------------------------- */ | 
|---|
| 278 | $default_tab = 'edit-entry'; | 
|---|
| 279 | if (!$can_edit_page) { | 
|---|
| 280 | $default_tab = ''; | 
|---|
| 281 | } | 
|---|
| 282 | if (!empty($_GET['co'])) { | 
|---|
| 283 | $default_tab = 'comments'; | 
|---|
| 284 | } | 
|---|
| 285 |  | 
|---|
| 286 | $admin_post_behavior = ''; | 
|---|
| 287 | if ($post_editor) { | 
|---|
| 288 | $p_edit = $c_edit = ''; | 
|---|
| 289 | if (!empty($post_editor[$post_format])) { | 
|---|
| 290 | $p_edit = $post_editor[$post_format]; | 
|---|
| 291 | } | 
|---|
| 292 | if (!empty($post_editor['xhtml'])) { | 
|---|
| 293 | $c_edit = $post_editor['xhtml']; | 
|---|
| 294 | } | 
|---|
| 295 | if ($p_edit == $c_edit) { | 
|---|
| 296 | $admin_post_behavior .= $core->callBehavior('adminPostEditor', | 
|---|
| 297 | $p_edit,'page',array('#post_excerpt','#post_content','#comment_content'),$post_format); | 
|---|
| 298 | } else { | 
|---|
| 299 | $admin_post_behavior .= $core->callBehavior('adminPostEditor', | 
|---|
| 300 | $p_edit,'page',array('#post_excerpt','#post_content'),$post_format); | 
|---|
| 301 | $admin_post_behavior .= $core->callBehavior('adminPostEditor', | 
|---|
| 302 | $c_edit,'comment',array('#comment_content'),'xhtml'); | 
|---|
| 303 | } | 
|---|
| 304 | } | 
|---|
| 305 |  | 
|---|
| 306 | dcPage::setXFrameOptions($core->blog->url); | 
|---|
| 307 | ?> | 
|---|
| 308 | <html> | 
|---|
| 309 | <head> | 
|---|
| 310 | <title><?php echo $page_title.' - '.__('Pages'); ?></title> | 
|---|
| 311 | <script type="text/javascript"> | 
|---|
| 312 | //<![CDATA[ | 
|---|
| 313 | <?php echo dcPage::jsVar('dotclear.msg.confirm_delete_post',__("Are you sure you want to delete this page?")); ?> | 
|---|
| 314 | //]]> | 
|---|
| 315 | </script> | 
|---|
| 316 | <?php echo | 
|---|
| 317 | dcPage::jsDatePicker(). | 
|---|
| 318 | dcPage::jsModal(). | 
|---|
| 319 | dcPage::jsLoad('js/_post.js'). | 
|---|
| 320 | $admin_post_behavior. | 
|---|
| 321 | dcPage::jsConfirmClose('entry-form','comment-form'). | 
|---|
| 322 | # --BEHAVIOR-- adminPageHeaders | 
|---|
| 323 | $core->callBehavior('adminPageHeaders'). | 
|---|
| 324 | dcPage::jsPageTabs($default_tab). | 
|---|
| 325 | $next_headlink."\n".$prev_headlink; | 
|---|
| 326 | ?> | 
|---|
| 327 | </head> | 
|---|
| 328 |  | 
|---|
| 329 | <body> | 
|---|
| 330 |  | 
|---|
| 331 | <?php | 
|---|
| 332 |  | 
|---|
| 333 | if ($post_id) { | 
|---|
| 334 | switch ($post_status) { | 
|---|
| 335 | case 1: | 
|---|
| 336 | $img_status = sprintf($img_status_pattern,__('Published'),'check-on.png'); | 
|---|
| 337 | break; | 
|---|
| 338 | case 0: | 
|---|
| 339 | $img_status = sprintf($img_status_pattern,__('Unpublished'),'check-off.png'); | 
|---|
| 340 | break; | 
|---|
| 341 | case -1: | 
|---|
| 342 | $img_status = sprintf($img_status_pattern,__('Scheduled'),'scheduled.png'); | 
|---|
| 343 | break; | 
|---|
| 344 | case -2: | 
|---|
| 345 | $img_status = sprintf($img_status_pattern,__('Pending'),'check-wrn.png'); | 
|---|
| 346 | break; | 
|---|
| 347 | default: | 
|---|
| 348 | $img_status = ''; | 
|---|
| 349 | } | 
|---|
| 350 | $edit_entry_title = '“'.html::escapeHTML($post_title).'”'.' '.$img_status; | 
|---|
| 351 | } else { | 
|---|
| 352 | $edit_entry_title = $page_title; | 
|---|
| 353 | } | 
|---|
| 354 | echo dcPage::breadcrumb( | 
|---|
| 355 | array( | 
|---|
| 356 | html::escapeHTML($core->blog->name) => '', | 
|---|
| 357 | __('Pages') => $p_url, | 
|---|
| 358 | $edit_entry_title => '' | 
|---|
| 359 | )); | 
|---|
| 360 |  | 
|---|
| 361 | if (!empty($_GET['upd'])) { | 
|---|
| 362 | dcPage::success(__('Page has been successfully updated.')); | 
|---|
| 363 | } | 
|---|
| 364 | elseif (!empty($_GET['crea'])) { | 
|---|
| 365 | dcPage::success(__('Page has been successfully created.')); | 
|---|
| 366 | } | 
|---|
| 367 | elseif (!empty($_GET['attached'])) { | 
|---|
| 368 | dcPage::success(__('File has been successfully attached.')); | 
|---|
| 369 | } | 
|---|
| 370 | elseif (!empty($_GET['rmattach'])) { | 
|---|
| 371 | dcPage::success(__('Attachment has been successfully removed.')); | 
|---|
| 372 | } | 
|---|
| 373 |  | 
|---|
| 374 | # XHTML conversion | 
|---|
| 375 | if (!empty($_GET['xconv'])) | 
|---|
| 376 | { | 
|---|
| 377 | $post_excerpt = $post_excerpt_xhtml; | 
|---|
| 378 | $post_content = $post_content_xhtml; | 
|---|
| 379 | $post_format = 'xhtml'; | 
|---|
| 380 |  | 
|---|
| 381 | dcPage::message(__('Don\'t forget to validate your XHTML conversion by saving your post.')); | 
|---|
| 382 | } | 
|---|
| 383 |  | 
|---|
| 384 | if ($post_id && $post->post_status == 1) { | 
|---|
| 385 | echo '<p><a class="onblog_link outgoing" href="'.$post->getURL().'" title="'.html::escapeHTML($post_title).'">'.__('Go to this page on the site').' <img src="images/outgoing-blue.png" alt="" /></a></p>'; | 
|---|
| 386 | } | 
|---|
| 387 |  | 
|---|
| 388 | echo ''; | 
|---|
| 389 |  | 
|---|
| 390 | if ($post_id) | 
|---|
| 391 | { | 
|---|
| 392 | echo '<p class="nav_prevnext">'; | 
|---|
| 393 | if ($prev_link) { echo $prev_link; } | 
|---|
| 394 | if ($next_link && $prev_link) { echo ' | '; } | 
|---|
| 395 | if ($next_link) { echo $next_link; } | 
|---|
| 396 |  | 
|---|
| 397 | # --BEHAVIOR-- adminPageNavLinks | 
|---|
| 398 | $core->callBehavior('adminPageNavLinks',isset($post) ? $post : null); | 
|---|
| 399 |  | 
|---|
| 400 | echo '</p>'; | 
|---|
| 401 | } | 
|---|
| 402 |  | 
|---|
| 403 | # Exit if we cannot view page | 
|---|
| 404 | if (!$can_view_page) { | 
|---|
| 405 | echo '</body></html>'; | 
|---|
| 406 | return; | 
|---|
| 407 | } | 
|---|
| 408 |  | 
|---|
| 409 |  | 
|---|
| 410 | /* Post form if we can edit page | 
|---|
| 411 | -------------------------------------------------------- */ | 
|---|
| 412 | if ($can_edit_page) | 
|---|
| 413 | { | 
|---|
| 414 | $sidebar_items = new ArrayObject(array( | 
|---|
| 415 | 'status-box' => array( | 
|---|
| 416 | 'title' => __('Status'), | 
|---|
| 417 | 'items' => array( | 
|---|
| 418 | 'post_status' => | 
|---|
| 419 | '<p><label for="post_status">'.__('Page status').'</label> '. | 
|---|
| 420 | form::combo('post_status',$status_combo,$post_status,'','',!$can_publish). | 
|---|
| 421 | '</p>', | 
|---|
| 422 | 'post_dt' => | 
|---|
| 423 | '<p><label for="post_dt">'.__('Publication date and hour').'</label>'. | 
|---|
| 424 | form::field('post_dt',16,16,$post_dt,($bad_dt ? 'invalid' : '')). | 
|---|
| 425 | '</p>', | 
|---|
| 426 | 'post_lang' => | 
|---|
| 427 | '<p><label for="post_lang">'.__('Page language').'</label>'. | 
|---|
| 428 | form::combo('post_lang',$lang_combo,$post_lang). | 
|---|
| 429 | '</p>', | 
|---|
| 430 | 'post_format' => | 
|---|
| 431 | '<div>'. | 
|---|
| 432 | '<h5 id="label_format"><label for="post_format" class="classic">'.__('Text formatting').'</label></h5>'. | 
|---|
| 433 | '<p>'.form::combo('post_format',$available_formats,$post_format,'maximal').'</p>'. | 
|---|
| 434 | '<p class="format_control control_wiki">'. | 
|---|
| 435 | '<a id="convert-xhtml" class="button'.($post_id && $post_format != 'wiki' ? ' hide' : ''). | 
|---|
| 436 | '" href="'.html::escapeURL($redir_url).'&id='.$post_id.'&xconv=1">'. | 
|---|
| 437 | __('Convert to XHTML').'</a></p></div>')), | 
|---|
| 438 | 'metas-box' => array( | 
|---|
| 439 | 'title' => __('Filing'), | 
|---|
| 440 | 'items' => array( | 
|---|
| 441 | 'post_position' => | 
|---|
| 442 | '<p><label for="post_position" class="classic">'.__('Page position').'</label> '. | 
|---|
| 443 | form::field('post_position',3,3,(string) $post_position). | 
|---|
| 444 | '</p>')), | 
|---|
| 445 | 'options-box' => array( | 
|---|
| 446 | 'title' => __('Options'), | 
|---|
| 447 | 'items' => array( | 
|---|
| 448 | 'post_open_comment_tb' => | 
|---|
| 449 | '<div>'. | 
|---|
| 450 | '<h5 id="label_comment_tb">'.__('Comments and trackbacks list').'</h5>'. | 
|---|
| 451 | '<p><label for="post_open_comment" class="classic">'. | 
|---|
| 452 | form::checkbox('post_open_comment',1,$post_open_comment).' '. | 
|---|
| 453 | __('Accept comments').'</label></p>'. | 
|---|
| 454 | ($core->blog->settings->system->allow_comments ? | 
|---|
| 455 | (isContributionAllowed($post_id,strtotime($post_dt),true) ? | 
|---|
| 456 | '' : | 
|---|
| 457 | '<p class="form-note warn">'. | 
|---|
| 458 | __('Warning: Comments are not more accepted for this entry.').'</p>') : | 
|---|
| 459 | '<p class="form-note warn">'. | 
|---|
| 460 | __('Comments are not accepted on this blog so far.').'</p>'). | 
|---|
| 461 | '<p><label for="post_open_tb" class="classic">'. | 
|---|
| 462 | form::checkbox('post_open_tb',1,$post_open_tb).' '. | 
|---|
| 463 | __('Accept trackbacks').'</label></p>'. | 
|---|
| 464 | ($core->blog->settings->system->allow_trackbacks ? | 
|---|
| 465 | (isContributionAllowed($post_id,strtotime($post_dt),false) ? | 
|---|
| 466 | '' : | 
|---|
| 467 | '<p class="form-note warn">'. | 
|---|
| 468 | __('Warning: Trackbacks are not more accepted for this entry.').'</p>') : | 
|---|
| 469 | '<p class="form-note warn">'.__('Trackbacks are not accepted on this blog so far.').'</p>'). | 
|---|
| 470 | '</div>', | 
|---|
| 471 | 'post_hide' => | 
|---|
| 472 | '<p><label for="post_selected" class="classic">'.form::checkbox('post_selected',1,$post_selected).' '. | 
|---|
| 473 | __('Hide in widget Pages').'</label>'. | 
|---|
| 474 | '</p>', | 
|---|
| 475 | 'post_password' => | 
|---|
| 476 | '<p><label for="post_password">'.__('Password').'</label>'. | 
|---|
| 477 | form::field('post_password',10,32,html::escapeHTML($post_password),'maximal'). | 
|---|
| 478 | '</p>', | 
|---|
| 479 | 'post_url' => | 
|---|
| 480 | '<div class="lockable">'. | 
|---|
| 481 | '<p><label for="post_url">'.__('Edit basename').'</label>'. | 
|---|
| 482 | form::field('post_url',10,255,html::escapeHTML($post_url),'maximal'). | 
|---|
| 483 | '</p>'. | 
|---|
| 484 | '<p class="form-note warn">'. | 
|---|
| 485 | __('Warning: If you set the URL manually, it may conflict with another page.'). | 
|---|
| 486 | '</p></div>' | 
|---|
| 487 | )))); | 
|---|
| 488 | $main_items = new ArrayObject(array( | 
|---|
| 489 | "post_title" => | 
|---|
| 490 | '<p class="col">'. | 
|---|
| 491 | '<label class="required no-margin bold" for="post_title"><abbr title="'.__('Required field').'">*</abbr> '.__('Title:').'</label>'. | 
|---|
| 492 | form::field('post_title',20,255,html::escapeHTML($post_title),'maximal'). | 
|---|
| 493 | '</p>', | 
|---|
| 494 |  | 
|---|
| 495 | "post_excerpt" => | 
|---|
| 496 | '<p class="area" id="excerpt-area"><label for="post_excerpt" class="bold">'.__('Excerpt:').' <span class="form-note">'. | 
|---|
| 497 | __('Introduction to the page.').'</span></label> '. | 
|---|
| 498 | form::textarea('post_excerpt',50,5,html::escapeHTML($post_excerpt)). | 
|---|
| 499 | '</p>', | 
|---|
| 500 |  | 
|---|
| 501 | "post_content" => | 
|---|
| 502 | '<p class="area" id="content-area"><label class="required bold" '. | 
|---|
| 503 | 'for="post_content"><abbr title="'.__('Required field').'">*</abbr> '.__('Content:').'</label> '. | 
|---|
| 504 | form::textarea('post_content',50,$core->auth->getOption('edit_size'),html::escapeHTML($post_content)). | 
|---|
| 505 | '</p>', | 
|---|
| 506 |  | 
|---|
| 507 | "post_notes" => | 
|---|
| 508 | '<p class="area" id="notes-area"><label for="post_notes" class="bold">'.__('Personal notes:').' <span class="form-note">'. | 
|---|
| 509 | __('Unpublished notes.').'</span></label>'. | 
|---|
| 510 | form::textarea('post_notes',50,5,html::escapeHTML($post_notes)). | 
|---|
| 511 | '</p>' | 
|---|
| 512 | ) | 
|---|
| 513 | ); | 
|---|
| 514 |  | 
|---|
| 515 | # --BEHAVIOR-- adminPostFormItems | 
|---|
| 516 | $core->callBehavior('adminPageFormItems',$main_items,$sidebar_items, isset($post) ? $post : null); | 
|---|
| 517 |  | 
|---|
| 518 | echo '<div class="multi-part" title="'.($post_id ? __('Edit page') : __('New page')). | 
|---|
| 519 | sprintf(' › %s',$post_format).'" id="edit-entry">'; | 
|---|
| 520 | echo '<form action="'.html::escapeURL($redir_url).'" method="post" id="entry-form">'; | 
|---|
| 521 |  | 
|---|
| 522 | echo '<div id="entry-wrapper">'; | 
|---|
| 523 | echo '<div id="entry-content"><div class="constrained">'; | 
|---|
| 524 | echo '<h3 class="out-of-screen-if-js">'.__('Edit page').'</h3>'; | 
|---|
| 525 |  | 
|---|
| 526 |  | 
|---|
| 527 | foreach ($main_items as $id => $item) { | 
|---|
| 528 | echo $item; | 
|---|
| 529 | } | 
|---|
| 530 |  | 
|---|
| 531 | # --BEHAVIOR-- adminPageForm | 
|---|
| 532 | $core->callBehavior('adminPageForm',isset($post) ? $post : null); | 
|---|
| 533 |  | 
|---|
| 534 | echo | 
|---|
| 535 | '<p class="border-top">'. | 
|---|
| 536 | ($post_id ? form::hidden('id',$post_id) : ''). | 
|---|
| 537 | '<input type="submit" value="'.__('Save').' (s)" '. | 
|---|
| 538 | 'accesskey="s" name="save" /> '; | 
|---|
| 539 |  | 
|---|
| 540 | if ($post_id) { | 
|---|
| 541 | $preview_url = $core->blog->url. | 
|---|
| 542 | $core->url->getURLFor('pagespreview', | 
|---|
| 543 | $core->auth->userID().'/'. | 
|---|
| 544 | http::browserUID(DC_MASTER_KEY.$core->auth->userID().$core->auth->getInfo('user_pwd')). | 
|---|
| 545 | '/'.$post->post_url); | 
|---|
| 546 | echo '<a id="post-preview" href="'.$preview_url.'" class="button" accesskey="p">'.__('Preview').' (p)'.'</a>'; | 
|---|
| 547 | } else { | 
|---|
| 548 | echo | 
|---|
| 549 | '<a id="post-cancel" href="'.$core->adminurl->get('admin.home').'" class="button" accesskey="c">'.__('Cancel').' (c)</a>'; | 
|---|
| 550 | } | 
|---|
| 551 |  | 
|---|
| 552 | echo | 
|---|
| 553 | ($can_delete ? '<input type="submit" class="delete" value="'.__('Delete').'" name="delete" />' : ''). | 
|---|
| 554 | $core->formNonce(). | 
|---|
| 555 | '</p>'; | 
|---|
| 556 |  | 
|---|
| 557 | echo '</div></div>';          // End #entry-content | 
|---|
| 558 | echo '</div>';      // End #entry-wrapper | 
|---|
| 559 |  | 
|---|
| 560 | echo '<div id="entry-sidebar" role="complementary">'; | 
|---|
| 561 |  | 
|---|
| 562 | foreach ($sidebar_items as $id => $c) { | 
|---|
| 563 | echo '<div id="'.$id.'" class="sb-box">'. | 
|---|
| 564 | '<h4>'.$c['title'].'</h4>'; | 
|---|
| 565 | foreach ($c['items'] as $e_name=>$e_content) { | 
|---|
| 566 | echo $e_content; | 
|---|
| 567 | } | 
|---|
| 568 | echo '</div>'; | 
|---|
| 569 | } | 
|---|
| 570 |  | 
|---|
| 571 | # --BEHAVIOR-- adminPageFormSidebar | 
|---|
| 572 | $core->callBehavior('adminPageFormSidebar',isset($post) ? $post : null); | 
|---|
| 573 |  | 
|---|
| 574 | echo '</div>';      // End #entry-sidebar | 
|---|
| 575 |  | 
|---|
| 576 | echo '</form>'; | 
|---|
| 577 |  | 
|---|
| 578 | # --BEHAVIOR-- adminPostForm | 
|---|
| 579 | $core->callBehavior('adminPageAfterForm',isset($post) ? $post : null); | 
|---|
| 580 |  | 
|---|
| 581 | echo '</div>';      // End | 
|---|
| 582 |  | 
|---|
| 583 | if ($post_id && !empty($post_media)) | 
|---|
| 584 | { | 
|---|
| 585 | echo | 
|---|
| 586 | '<form action="'.$core->adminurl->get('admin.post.media').'" id="attachment-remove-hide" method="post">'. | 
|---|
| 587 | '<div>'.form::hidden(array('post_id'),$post_id). | 
|---|
| 588 | form::hidden(array('media_id'),''). | 
|---|
| 589 | form::hidden(array('remove'),1). | 
|---|
| 590 | $core->formNonce().'</div></form>'; | 
|---|
| 591 | } | 
|---|
| 592 | } | 
|---|
| 593 |  | 
|---|
| 594 |  | 
|---|
| 595 | /* Comments and trackbacks | 
|---|
| 596 | -------------------------------------------------------- */ | 
|---|
| 597 | if ($post_id) | 
|---|
| 598 | { | 
|---|
| 599 | $params = array('post_id' => $post_id, 'order' => 'comment_dt ASC'); | 
|---|
| 600 |  | 
|---|
| 601 | $comments = $core->blog->getComments(array_merge($params,array('comment_trackback'=>0))); | 
|---|
| 602 | $trackbacks = $core->blog->getComments(array_merge($params,array('comment_trackback'=>1))); | 
|---|
| 603 |  | 
|---|
| 604 | # Actions combo box | 
|---|
| 605 | $combo_action = array(); | 
|---|
| 606 | if ($can_edit_page && $core->auth->check('publish,contentadmin',$core->blog->id)) | 
|---|
| 607 | { | 
|---|
| 608 | $combo_action[__('Publish')] = 'publish'; | 
|---|
| 609 | $combo_action[__('Unpublish')] = 'unpublish'; | 
|---|
| 610 | $combo_action[__('Mark as pending')] = 'pending'; | 
|---|
| 611 | $combo_action[__('Mark as junk')] = 'junk'; | 
|---|
| 612 | } | 
|---|
| 613 |  | 
|---|
| 614 | if ($can_edit_page && $core->auth->check('delete,contentadmin',$core->blog->id)) | 
|---|
| 615 | { | 
|---|
| 616 | $combo_action[__('Delete')] = 'delete'; | 
|---|
| 617 | } | 
|---|
| 618 |  | 
|---|
| 619 | $has_action = !empty($combo_action) && (!$trackbacks->isEmpty() || !$comments->isEmpty()); | 
|---|
| 620 |  | 
|---|
| 621 | echo | 
|---|
| 622 | '<div id="comments" class="multi-part" title="'.__('Comments').'">'; | 
|---|
| 623 |  | 
|---|
| 624 | echo | 
|---|
| 625 | '<p class="top-add"><a class="button add" href="#comment-form">'.__('Add a comment').'</a></p>'; | 
|---|
| 626 |  | 
|---|
| 627 | if ($has_action) { | 
|---|
| 628 | echo '<form action="comments_actions.php" method="post">'; | 
|---|
| 629 | } | 
|---|
| 630 |  | 
|---|
| 631 | echo '<h3>'.__('Trackbacks').'</h3>'; | 
|---|
| 632 |  | 
|---|
| 633 | if (!$trackbacks->isEmpty()) { | 
|---|
| 634 | showComments($trackbacks,$has_action); | 
|---|
| 635 | } else { | 
|---|
| 636 | echo '<p>'.__('No trackback').'</p>'; | 
|---|
| 637 | } | 
|---|
| 638 |  | 
|---|
| 639 | echo '<h3>'.__('Comments').'</h3>'; | 
|---|
| 640 | if (!$comments->isEmpty()) { | 
|---|
| 641 | showComments($comments,$has_action); | 
|---|
| 642 | } else { | 
|---|
| 643 | echo '<p>'.__('No comments').'</p>'; | 
|---|
| 644 | } | 
|---|
| 645 |  | 
|---|
| 646 | if ($has_action) { | 
|---|
| 647 | echo | 
|---|
| 648 | '<div class="two-cols">'. | 
|---|
| 649 | '<p class="col checkboxes-helpers"></p>'. | 
|---|
| 650 |  | 
|---|
| 651 | '<p class="col right"><label for="action" class="classic">'.__('Selected comments action:').'</label> '. | 
|---|
| 652 | form::combo('action',$combo_action). | 
|---|
| 653 | form::hidden('redir',html::escapeURL($redir_url).'&id='.$post_id.'&co=1'). | 
|---|
| 654 | $core->formNonce(). | 
|---|
| 655 | '<input type="submit" value="'.__('ok').'" /></p>'. | 
|---|
| 656 | '</div>'. | 
|---|
| 657 | '</form>'; | 
|---|
| 658 | } | 
|---|
| 659 | /* Add a comment | 
|---|
| 660 | -------------------------------------------------------- */ | 
|---|
| 661 |  | 
|---|
| 662 | echo | 
|---|
| 663 | '<div class="fieldset clear">'. | 
|---|
| 664 | '<h3>'.__('Add a comment').'</h3>'. | 
|---|
| 665 |  | 
|---|
| 666 | '<form action="'.$core->adminurl->get('admin.comment').'" method="post" id="comment-form">'. | 
|---|
| 667 | '<div class="constrained">'. | 
|---|
| 668 | '<p><label for="comment_author" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Name:').'</label>'. | 
|---|
| 669 | form::field('comment_author',30,255,html::escapeHTML($core->auth->getInfo('user_cn'))). | 
|---|
| 670 | '</p>'. | 
|---|
| 671 |  | 
|---|
| 672 | '<p><label for="comment_email">'.__('Email:').'</label>'. | 
|---|
| 673 | form::field('comment_email',30,255,html::escapeHTML($core->auth->getInfo('user_email'))). | 
|---|
| 674 | '</p>'. | 
|---|
| 675 |  | 
|---|
| 676 | '<p><label for="comment_site">'.__('Web site:').'</label>'. | 
|---|
| 677 | form::field('comment_site',30,255,html::escapeHTML($core->auth->getInfo('user_url'))). | 
|---|
| 678 | '</p>'. | 
|---|
| 679 |  | 
|---|
| 680 | '<p class="area"><label for="comment_content" class="required"><abbr title="'.__('Required field').'">*</abbr> '. | 
|---|
| 681 | __('Comment:').'</label> '. | 
|---|
| 682 | form::textarea('comment_content',50,8,html::escapeHTML('')). | 
|---|
| 683 | '</p>'. | 
|---|
| 684 |  | 
|---|
| 685 | '<p>'.form::hidden('post_id',$post_id). | 
|---|
| 686 | $core->formNonce(). | 
|---|
| 687 | '<input type="submit" name="add" value="'.__('Save').'" /></p>'. | 
|---|
| 688 | '</div>'. #constrained | 
|---|
| 689 |  | 
|---|
| 690 | '</form>'. | 
|---|
| 691 | '</div>'. #add comment | 
|---|
| 692 | '</div>'; #comments | 
|---|
| 693 | } | 
|---|
| 694 |  | 
|---|
| 695 | # Controls comments or trakbacks capabilities | 
|---|
| 696 | function isContributionAllowed($id,$dt,$com=true) | 
|---|
| 697 | { | 
|---|
| 698 | global $core; | 
|---|
| 699 |  | 
|---|
| 700 | if (!$id) { | 
|---|
| 701 | return true; | 
|---|
| 702 | } | 
|---|
| 703 | if ($com) { | 
|---|
| 704 | if (($core->blog->settings->system->comments_ttl == 0) || | 
|---|
| 705 | (time() - $core->blog->settings->system->comments_ttl*86400 < $dt)) { | 
|---|
| 706 | return true; | 
|---|
| 707 | } | 
|---|
| 708 | } else { | 
|---|
| 709 | if (($core->blog->settings->system->trackbacks_ttl == 0) || | 
|---|
| 710 | (time() - $core->blog->settings->system->trackbacks_ttl*86400 < $dt)) { | 
|---|
| 711 | return true; | 
|---|
| 712 | } | 
|---|
| 713 | } | 
|---|
| 714 | return false; | 
|---|
| 715 | } | 
|---|
| 716 |  | 
|---|
| 717 | # Show comments or trackbacks | 
|---|
| 718 | function showComments($rs,$has_action) | 
|---|
| 719 | { | 
|---|
| 720 | global $core; | 
|---|
| 721 |  | 
|---|
| 722 | echo | 
|---|
| 723 | '<table class="comments-list"><tr>'. | 
|---|
| 724 | '<th colspan="2" class="nowrap first">'.__('Author').'</th>'. | 
|---|
| 725 | '<th>'.__('Date').'</th>'. | 
|---|
| 726 | '<th class="nowrap">'.__('IP address').'</th>'. | 
|---|
| 727 | '<th>'.__('Status').'</th>'. | 
|---|
| 728 | '<th>'.__('Edit').'</th>'. | 
|---|
| 729 | '</tr>'; | 
|---|
| 730 |  | 
|---|
| 731 | while($rs->fetch()) | 
|---|
| 732 | { | 
|---|
| 733 | $comment_url = $core->adminurl->get('admin.comment',array('id' => $rs->comment_id)); | 
|---|
| 734 |  | 
|---|
| 735 | $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; | 
|---|
| 736 | switch ($rs->comment_status) { | 
|---|
| 737 | case 1: | 
|---|
| 738 | $img_status = sprintf($img,__('Published'),'check-on.png'); | 
|---|
| 739 | break; | 
|---|
| 740 | case 0: | 
|---|
| 741 | $img_status = sprintf($img,__('Unpublished'),'check-off.png'); | 
|---|
| 742 | break; | 
|---|
| 743 | case -1: | 
|---|
| 744 | $img_status = sprintf($img,__('Pending'),'check-wrn.png'); | 
|---|
| 745 | break; | 
|---|
| 746 | case -2: | 
|---|
| 747 | $img_status = sprintf($img,__('Junk'),'junk.png'); | 
|---|
| 748 | break; | 
|---|
| 749 | } | 
|---|
| 750 |  | 
|---|
| 751 | echo | 
|---|
| 752 | '<tr class="line'.($rs->comment_status != 1 ? ' offline' : '').'"'. | 
|---|
| 753 | ' id="c'.$rs->comment_id.'">'. | 
|---|
| 754 |  | 
|---|
| 755 | '<td class="nowrap">'. | 
|---|
| 756 | ($has_action ? form::checkbox(array('comments[]'),$rs->comment_id,'','','',0,'title="'.__('Select this comment').'"') : '').'</td>'. | 
|---|
| 757 | '<td class="maximal">'.$rs->comment_author.'</td>'. | 
|---|
| 758 | '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$rs->comment_dt).'</td>'. | 
|---|
| 759 | '<td class="nowrap"><a href="'.$core->adminurl->get('admin.comment',array('ip' => $rs->comment_ip)).'">'.$rs->comment_ip.'</a></td>'. | 
|---|
| 760 | '<td class="nowrap status">'.$img_status.'</td>'. | 
|---|
| 761 | '<td class="nowrap status"><a href="'.$comment_url.'">'. | 
|---|
| 762 | '<img src="images/edit-mini.png" alt="" title="'.__('Edit this comment').'" /> '.__('Edit').'</a></td>'. | 
|---|
| 763 |  | 
|---|
| 764 | '</tr>'; | 
|---|
| 765 | } | 
|---|
| 766 |  | 
|---|
| 767 | echo '</table>'; | 
|---|
| 768 | } | 
|---|
| 769 | dcPage::helpBlock('page','core_wiki'); | 
|---|
| 770 | ?> | 
|---|
| 771 | </body> | 
|---|
| 772 | </html> | 
|---|