| 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 | 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_password = ''; |
|---|
| 21 | $post_url = ''; |
|---|
| 22 | $post_lang = $core->auth->getInfo('user_lang'); |
|---|
| 23 | $post_title = ''; |
|---|
| 24 | $post_excerpt = ''; |
|---|
| 25 | $post_excerpt_xhtml = ''; |
|---|
| 26 | $post_content = ''; |
|---|
| 27 | $post_content_xhtml = ''; |
|---|
| 28 | $post_notes = ''; |
|---|
| 29 | $post_status = $core->auth->getInfo('user_post_status'); |
|---|
| 30 | $post_position = 0; |
|---|
| 31 | $post_open_comment = false; |
|---|
| 32 | $post_open_tb = false; |
|---|
| 33 | |
|---|
| 34 | $post_media = array(); |
|---|
| 35 | |
|---|
| 36 | $page_title = __('New page'); |
|---|
| 37 | |
|---|
| 38 | $can_view_page = true; |
|---|
| 39 | $can_edit_page = $core->auth->check('pages,usage',$core->blog->id); |
|---|
| 40 | $can_publish = $core->auth->check('pages,publish,contentadmin',$core->blog->id); |
|---|
| 41 | $can_delete = false; |
|---|
| 42 | |
|---|
| 43 | $post_headlink = '<link rel="%s" title="%s" href="'.html::escapeURL($redir_url).'&id=%s" />'; |
|---|
| 44 | $post_link = '<a href="'.html::escapeURL($redir_url).'&id=%s" title="%s">%s</a>'; |
|---|
| 45 | |
|---|
| 46 | $next_link = $prev_link = $next_headlink = $prev_headlink = null; |
|---|
| 47 | |
|---|
| 48 | # If user can't publish |
|---|
| 49 | if (!$can_publish) { |
|---|
| 50 | $post_status = -2; |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | # Status combo |
|---|
| 54 | foreach ($core->blog->getAllPostStatus() as $k => $v) { |
|---|
| 55 | $status_combo[$v] = (string) $k; |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | # Formaters combo |
|---|
| 59 | foreach ($core->getFormaters() as $v) { |
|---|
| 60 | $formaters_combo[$v] = $v; |
|---|
| 61 | } |
|---|
| 62 | |
|---|
| 63 | # Languages combo |
|---|
| 64 | $rs = $core->blog->getLangs(array('order'=>'asc')); |
|---|
| 65 | $all_langs = l10n::getISOcodes(0,1); |
|---|
| 66 | $lang_combo = array('' => '', __('Most used') => array(), __('Available') => l10n::getISOcodes(1,1)); |
|---|
| 67 | while ($rs->fetch()) { |
|---|
| 68 | if (isset($all_langs[$rs->post_lang])) { |
|---|
| 69 | $lang_combo[__('Most used')][$all_langs[$rs->post_lang]] = $rs->post_lang; |
|---|
| 70 | unset($lang_combo[__('Available')][$all_langs[$rs->post_lang]]); |
|---|
| 71 | } else { |
|---|
| 72 | $lang_combo[__('Most used')][$rs->post_lang] = $rs->post_lang; |
|---|
| 73 | } |
|---|
| 74 | } |
|---|
| 75 | unset($all_langs); |
|---|
| 76 | unset($rs); |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | # Get page informations |
|---|
| 80 | if (!empty($_REQUEST['id'])) |
|---|
| 81 | { |
|---|
| 82 | $params['post_type'] = 'page'; |
|---|
| 83 | $params['post_id'] = $_REQUEST['id']; |
|---|
| 84 | |
|---|
| 85 | $post = $core->blog->getPosts($params); |
|---|
| 86 | |
|---|
| 87 | if ($post->isEmpty()) |
|---|
| 88 | { |
|---|
| 89 | $core->error->add(__('This page does not exist.')); |
|---|
| 90 | $can_view_page = false; |
|---|
| 91 | } |
|---|
| 92 | else |
|---|
| 93 | { |
|---|
| 94 | $post_id = $post->post_id; |
|---|
| 95 | $post_dt = date('Y-m-d H:i',strtotime($post->post_dt)); |
|---|
| 96 | $post_format = $post->post_format; |
|---|
| 97 | $post_password = $post->post_password; |
|---|
| 98 | $post_url = $post->post_url; |
|---|
| 99 | $post_lang = $post->post_lang; |
|---|
| 100 | $post_title = $post->post_title; |
|---|
| 101 | $post_excerpt = $post->post_excerpt; |
|---|
| 102 | $post_excerpt_xhtml = $post->post_excerpt_xhtml; |
|---|
| 103 | $post_content = $post->post_content; |
|---|
| 104 | $post_content_xhtml = $post->post_content_xhtml; |
|---|
| 105 | $post_notes = $post->post_notes; |
|---|
| 106 | $post_status = $post->post_status; |
|---|
| 107 | $post_position = (integer) $post->post_position; |
|---|
| 108 | $post_open_comment = (boolean) $post->post_open_comment; |
|---|
| 109 | $post_open_tb = (boolean) $post->post_open_tb; |
|---|
| 110 | |
|---|
| 111 | $page_title = __('Edit page'); |
|---|
| 112 | |
|---|
| 113 | $can_edit_page = $post->isEditable(); |
|---|
| 114 | $can_delete= $post->isDeletable(); |
|---|
| 115 | |
|---|
| 116 | $next_rs = $core->blog->getNextPost($post,1); |
|---|
| 117 | $prev_rs = $core->blog->getNextPost($post,-1); |
|---|
| 118 | |
|---|
| 119 | if ($next_rs !== null) { |
|---|
| 120 | $next_link = sprintf($post_link,$next_rs->post_id, |
|---|
| 121 | html::escapeHTML($next_rs->post_title),__('next page').' »'); |
|---|
| 122 | $next_headlink = sprintf($post_headlink,'next', |
|---|
| 123 | html::escapeHTML($next_rs->post_title),$next_rs->post_id); |
|---|
| 124 | } |
|---|
| 125 | |
|---|
| 126 | if ($prev_rs !== null) { |
|---|
| 127 | $prev_link = sprintf($post_link,$prev_rs->post_id, |
|---|
| 128 | html::escapeHTML($prev_rs->post_title),'« '.__('previous page')); |
|---|
| 129 | $prev_headlink = sprintf($post_headlink,'previous', |
|---|
| 130 | html::escapeHTML($prev_rs->post_title),$prev_rs->post_id); |
|---|
| 131 | } |
|---|
| 132 | |
|---|
| 133 | try { |
|---|
| 134 | $core->media = new dcMedia($core); |
|---|
| 135 | $post_media = $core->media->getPostMedia($post_id); |
|---|
| 136 | } catch (Exception $e) {} |
|---|
| 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 | $post_dt = strtotime($_POST['post_dt']); |
|---|
| 157 | $post_dt = date('Y-m-d H:i',$post_dt); |
|---|
| 158 | } |
|---|
| 159 | |
|---|
| 160 | $post_open_comment = !empty($_POST['post_open_comment']); |
|---|
| 161 | $post_open_tb = !empty($_POST['post_open_tb']); |
|---|
| 162 | $post_lang = $_POST['post_lang']; |
|---|
| 163 | $post_password = !empty($_POST['post_password']) ? $_POST['post_password'] : null; |
|---|
| 164 | $post_position = (integer) $_POST['post_position']; |
|---|
| 165 | |
|---|
| 166 | $post_notes = $_POST['post_notes']; |
|---|
| 167 | |
|---|
| 168 | if (isset($_POST['post_url'])) { |
|---|
| 169 | $post_url = $_POST['post_url']; |
|---|
| 170 | } |
|---|
| 171 | |
|---|
| 172 | $core->blog->setPostContent( |
|---|
| 173 | $post_id,$post_format,$post_lang, |
|---|
| 174 | $post_excerpt,$post_excerpt_xhtml,$post_content,$post_content_xhtml |
|---|
| 175 | ); |
|---|
| 176 | } |
|---|
| 177 | |
|---|
| 178 | # Create or update post |
|---|
| 179 | if (!empty($_POST) && !empty($_POST['save']) && $can_edit_page) |
|---|
| 180 | { |
|---|
| 181 | $cur = $core->con->openCursor($core->prefix.'post'); |
|---|
| 182 | |
|---|
| 183 | # Magic tweak :) |
|---|
| 184 | $core->blog->settings->system->post_url_format = $page_url_format; |
|---|
| 185 | |
|---|
| 186 | $cur->post_type = 'page'; |
|---|
| 187 | $cur->post_title = $post_title; |
|---|
| 188 | $cur->post_dt = $post_dt ? date('Y-m-d H:i:00',strtotime($post_dt)) : ''; |
|---|
| 189 | $cur->post_format = $post_format; |
|---|
| 190 | $cur->post_password = $post_password; |
|---|
| 191 | $cur->post_lang = $post_lang; |
|---|
| 192 | $cur->post_title = $post_title; |
|---|
| 193 | $cur->post_excerpt = $post_excerpt; |
|---|
| 194 | $cur->post_excerpt_xhtml = $post_excerpt_xhtml; |
|---|
| 195 | $cur->post_content = $post_content; |
|---|
| 196 | $cur->post_content_xhtml = $post_content_xhtml; |
|---|
| 197 | $cur->post_notes = $post_notes; |
|---|
| 198 | $cur->post_status = $post_status; |
|---|
| 199 | $cur->post_position = $post_position; |
|---|
| 200 | $cur->post_open_comment = (integer) $post_open_comment; |
|---|
| 201 | $cur->post_open_tb = (integer) $post_open_tb; |
|---|
| 202 | |
|---|
| 203 | if (isset($_POST['post_url'])) { |
|---|
| 204 | $cur->post_url = $post_url; |
|---|
| 205 | } |
|---|
| 206 | |
|---|
| 207 | # Update post |
|---|
| 208 | if ($post_id) |
|---|
| 209 | { |
|---|
| 210 | try |
|---|
| 211 | { |
|---|
| 212 | # --BEHAVIOR-- adminBeforePageUpdate |
|---|
| 213 | $core->callBehavior('adminBeforePageUpdate',$cur,$post_id); |
|---|
| 214 | |
|---|
| 215 | $core->blog->updPost($post_id,$cur); |
|---|
| 216 | |
|---|
| 217 | # --BEHAVIOR-- adminAfterPageUpdate |
|---|
| 218 | $core->callBehavior('adminAfterPageUpdate',$cur,$post_id); |
|---|
| 219 | |
|---|
| 220 | http::redirect($redir_url.'&id='.$post_id.'&upd=1'); |
|---|
| 221 | } |
|---|
| 222 | catch (Exception $e) |
|---|
| 223 | { |
|---|
| 224 | $core->error->add($e->getMessage()); |
|---|
| 225 | } |
|---|
| 226 | } |
|---|
| 227 | else |
|---|
| 228 | { |
|---|
| 229 | $cur->user_id = $core->auth->userID(); |
|---|
| 230 | |
|---|
| 231 | try |
|---|
| 232 | { |
|---|
| 233 | # --BEHAVIOR-- adminBeforePageCreate |
|---|
| 234 | $core->callBehavior('adminBeforePageCreate',$cur); |
|---|
| 235 | |
|---|
| 236 | $return_id = $core->blog->addPost($cur); |
|---|
| 237 | |
|---|
| 238 | # --BEHAVIOR-- adminAfterPageCreate |
|---|
| 239 | $core->callBehavior('adminAfterPageCreate',$cur,$return_id); |
|---|
| 240 | |
|---|
| 241 | http::redirect($redir_url.'&id='.$return_id.'&crea=1'); |
|---|
| 242 | } |
|---|
| 243 | catch (Exception $e) |
|---|
| 244 | { |
|---|
| 245 | $core->error->add($e->getMessage()); |
|---|
| 246 | } |
|---|
| 247 | } |
|---|
| 248 | } |
|---|
| 249 | |
|---|
| 250 | if (!empty($_POST['delete']) && $can_delete) |
|---|
| 251 | { |
|---|
| 252 | try { |
|---|
| 253 | # --BEHAVIOR-- adminBeforePageDelete |
|---|
| 254 | $core->callBehavior('adminBeforePageDelete',$post_id); |
|---|
| 255 | $core->blog->delPost($post_id); |
|---|
| 256 | http::redirect($p_url); |
|---|
| 257 | } catch (Exception $e) { |
|---|
| 258 | $core->error->add($e->getMessage()); |
|---|
| 259 | } |
|---|
| 260 | } |
|---|
| 261 | |
|---|
| 262 | /* DISPLAY |
|---|
| 263 | -------------------------------------------------------- */ |
|---|
| 264 | $default_tab = 'edit-entry'; |
|---|
| 265 | if (!$can_edit_page) { |
|---|
| 266 | $default_tab = ''; |
|---|
| 267 | } |
|---|
| 268 | if (!empty($_GET['co'])) { |
|---|
| 269 | $default_tab = 'comments'; |
|---|
| 270 | } |
|---|
| 271 | |
|---|
| 272 | ?> |
|---|
| 273 | <html> |
|---|
| 274 | <head> |
|---|
| 275 | <title><?php echo $page_title.' - '.__('Pages'); ?></title> |
|---|
| 276 | <script type="text/javascript"> |
|---|
| 277 | //<![CDATA[ |
|---|
| 278 | <?php echo dcPage::jsVar('dotclear.msg.confirm_delete_post',__("Are you sure you want to delete this page?")); ?> |
|---|
| 279 | //]]> |
|---|
| 280 | </script> |
|---|
| 281 | <?php echo |
|---|
| 282 | dcPage::jsDatePicker(). |
|---|
| 283 | dcPage::jsToolBar(). |
|---|
| 284 | dcPage::jsModal(). |
|---|
| 285 | dcPage::jsLoad('js/_post.js'). |
|---|
| 286 | dcPage::jsConfirmClose('entry-form','comment-form'). |
|---|
| 287 | # --BEHAVIOR-- adminPageHeaders |
|---|
| 288 | $core->callBehavior('adminPageHeaders'). |
|---|
| 289 | dcPage::jsPageTabs($default_tab). |
|---|
| 290 | $next_headlink."\n".$prev_headlink; |
|---|
| 291 | ?> |
|---|
| 292 | </head> |
|---|
| 293 | |
|---|
| 294 | <body> |
|---|
| 295 | |
|---|
| 296 | <?php |
|---|
| 297 | |
|---|
| 298 | if (!empty($_GET['upd'])) { |
|---|
| 299 | echo '<p class="message">'.__('Page has been successfully updated.').'</p>'; |
|---|
| 300 | } |
|---|
| 301 | elseif (!empty($_GET['crea'])) { |
|---|
| 302 | echo '<p class="message">'.__('Page has been successfully created.').'</p>'; |
|---|
| 303 | } |
|---|
| 304 | elseif (!empty($_GET['attached'])) { |
|---|
| 305 | echo '<p class="message">'.__('File has been successfully attached.').'</p>'; |
|---|
| 306 | } |
|---|
| 307 | elseif (!empty($_GET['rmattach'])) { |
|---|
| 308 | echo '<p class="message">'.__('Attachment has been successfully removed.').'</p>'; |
|---|
| 309 | } |
|---|
| 310 | |
|---|
| 311 | # XHTML conversion |
|---|
| 312 | if (!empty($_GET['xconv'])) |
|---|
| 313 | { |
|---|
| 314 | $post_excerpt = $post_excerpt_xhtml; |
|---|
| 315 | $post_content = $post_content_xhtml; |
|---|
| 316 | $post_format = 'xhtml'; |
|---|
| 317 | |
|---|
| 318 | echo '<p class="message">'.__('Don\'t forget to validate your XHTML conversion by saving your post.').'</p>'; |
|---|
| 319 | } |
|---|
| 320 | |
|---|
| 321 | echo '<h2>'.html::escapeHTML($core->blog->name). |
|---|
| 322 | ' › <a href="'.$p_url.'">'.__('Pages').'</a> › <span class="page-title">'.$page_title; |
|---|
| 323 | if ($post_id) { |
|---|
| 324 | echo ' “'.$post_title.'”'; |
|---|
| 325 | } |
|---|
| 326 | echo '</span></h2>'; |
|---|
| 327 | |
|---|
| 328 | if ($post_id && $post->post_status == 1) { |
|---|
| 329 | echo '<p><a href="'.$post->getURL().'" onclick="window.open(this.href);return false;" title="'.$post_title.' ('.__('new window').')'.'">'.__('Go to this page on the site').' <img src="images/outgoing-blue.png" alt="" /></a></p>'; |
|---|
| 330 | } |
|---|
| 331 | |
|---|
| 332 | echo ''; |
|---|
| 333 | |
|---|
| 334 | if ($post_id) |
|---|
| 335 | { |
|---|
| 336 | echo '<p>'; |
|---|
| 337 | if ($prev_link) { echo $prev_link; } |
|---|
| 338 | if ($next_link && $prev_link) { echo ' - '; } |
|---|
| 339 | if ($next_link) { echo $next_link; } |
|---|
| 340 | |
|---|
| 341 | # --BEHAVIOR-- adminPageNavLinks |
|---|
| 342 | $core->callBehavior('adminPageNavLinks',isset($post) ? $post : null); |
|---|
| 343 | |
|---|
| 344 | echo '</p>'; |
|---|
| 345 | } |
|---|
| 346 | |
|---|
| 347 | # Exit if we cannot view page |
|---|
| 348 | if (!$can_view_page) { |
|---|
| 349 | echo '</body></html>'; |
|---|
| 350 | return; |
|---|
| 351 | } |
|---|
| 352 | |
|---|
| 353 | |
|---|
| 354 | /* Post form if we can edit post |
|---|
| 355 | -------------------------------------------------------- */ |
|---|
| 356 | if ($can_edit_page) |
|---|
| 357 | { |
|---|
| 358 | echo '<div class="multi-part" title="'.__('Edit page').'" id="edit-entry">'; |
|---|
| 359 | echo '<form action="'.html::escapeURL($redir_url).'" method="post" id="entry-form">'; |
|---|
| 360 | |
|---|
| 361 | echo '<div id="entry-wrapper">'; |
|---|
| 362 | echo '<div id="entry-content"><div class="constrained">'; |
|---|
| 363 | |
|---|
| 364 | echo |
|---|
| 365 | '<p class="col"><label for="post_title" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Title:'). |
|---|
| 366 | form::field('post_title',20,255,html::escapeHTML($post_title),'maximal'). |
|---|
| 367 | '</label></p>'. |
|---|
| 368 | |
|---|
| 369 | '<p class="area" id="excerpt-area"><label for="post_excerpt">'.__('Excerpt:').'</label> '. |
|---|
| 370 | form::textarea('post_excerpt',50,5,html::escapeHTML($post_excerpt)). |
|---|
| 371 | '</p>'. |
|---|
| 372 | |
|---|
| 373 | '<p class="area"><label class="required" '. |
|---|
| 374 | 'for="post_content"><abbr title="'.__('Required field').'">*</abbr> '.__('Content:').'</label> '. |
|---|
| 375 | form::textarea('post_content',50,$core->auth->getOption('edit_size'),html::escapeHTML($post_content)). |
|---|
| 376 | '</p>'; |
|---|
| 377 | |
|---|
| 378 | echo |
|---|
| 379 | '<p class="area" id="notes-area"><label for="post_notes">'.__('Notes:').'</label>'. |
|---|
| 380 | form::textarea('post_notes',50,5,html::escapeHTML($post_notes)). |
|---|
| 381 | '</p>'; |
|---|
| 382 | |
|---|
| 383 | # --BEHAVIOR-- adminPageForm |
|---|
| 384 | $core->callBehavior('adminPageForm',isset($post) ? $post : null); |
|---|
| 385 | |
|---|
| 386 | echo |
|---|
| 387 | '<p>'. |
|---|
| 388 | ($post_id ? form::hidden('id',$post_id) : ''). |
|---|
| 389 | '<input type="submit" value="'.__('Save').' (s)" '. |
|---|
| 390 | 'accesskey="s" name="save" /> '; |
|---|
| 391 | |
|---|
| 392 | if ($post_id) { |
|---|
| 393 | $preview_url = $core->blog->url. |
|---|
| 394 | $core->url->getURLFor('pagespreview', |
|---|
| 395 | $core->auth->userID().'/'. |
|---|
| 396 | http::browserUID(DC_MASTER_KEY.$core->auth->userID().$core->auth->getInfo('user_pwd')). |
|---|
| 397 | '/'.$post->post_url); |
|---|
| 398 | echo '<a id="post-preview" href="'.$preview_url.'" class="button">'.__('Preview').'</a>'; |
|---|
| 399 | } |
|---|
| 400 | |
|---|
| 401 | echo |
|---|
| 402 | ($can_delete ? '<input type="submit" class="delete" value="'.__('Delete').'" name="delete" />' : ''). |
|---|
| 403 | $core->formNonce(). |
|---|
| 404 | '</p>'; |
|---|
| 405 | |
|---|
| 406 | echo '</div></div>'; // End #entry-content |
|---|
| 407 | echo '</div>'; // End #entry-wrapper |
|---|
| 408 | |
|---|
| 409 | echo '<div id="entry-sidebar">'; |
|---|
| 410 | |
|---|
| 411 | echo |
|---|
| 412 | '<p><label for="post_status">'.__('Page status:'). |
|---|
| 413 | form::combo('post_status',$status_combo,$post_status,'','',!$can_publish). |
|---|
| 414 | '</label></p>'. |
|---|
| 415 | |
|---|
| 416 | '<p><label for="post_dt">'.__('Published on:'). |
|---|
| 417 | form::field('post_dt',16,16,$post_dt).'</label></p>'. |
|---|
| 418 | |
|---|
| 419 | '<p><label for="post_format">'.__('Text formating:'). |
|---|
| 420 | form::combo('post_format',$formaters_combo,$post_format). |
|---|
| 421 | ($post_id && $post_format != 'xhtml' ? '<a href="'.html::escapeURL($redir_url).'&id='.$post_id.'&xconv=1">'.__('Convert to XHTML').'</a>' : ''). |
|---|
| 422 | '</label></p>'. |
|---|
| 423 | |
|---|
| 424 | '<p><label for="post_open_comment" class="classic">'.form::checkbox('post_open_comment',1,$post_open_comment).' '. |
|---|
| 425 | __('Accept comments').'</label></p>'. |
|---|
| 426 | '<p><label for="post_open_tb" class="classic">'.form::checkbox('post_open_tb',1,$post_open_tb).' '. |
|---|
| 427 | __('Accept trackbacks').'</label></p>'. |
|---|
| 428 | |
|---|
| 429 | '<p><label for="post_position" class="classic">'.__('Page position:').' '. |
|---|
| 430 | form::field('post_position',3,3,(string) $post_position). |
|---|
| 431 | '</label></p>'. |
|---|
| 432 | |
|---|
| 433 | '<p><label for="post_lang">'.__('Page lang:'). |
|---|
| 434 | form::combo('post_lang',$lang_combo,$post_lang).'</label></p>'. |
|---|
| 435 | |
|---|
| 436 | '<p><label for="post_password">'.__('Page password:'). |
|---|
| 437 | form::field('post_password',10,32,html::escapeHTML($post_password),'maximal'). |
|---|
| 438 | '</label></p>'. |
|---|
| 439 | |
|---|
| 440 | '<div class="lockable">'. |
|---|
| 441 | '<p><label for="post_url">'.__('Basename:'). |
|---|
| 442 | form::field('post_url',10,255,html::escapeHTML($post_url),'maximal'). |
|---|
| 443 | '</label></p>'. |
|---|
| 444 | '<p class="form-note warn">'. |
|---|
| 445 | __('Warning: If you set the URL manually, it may conflict with another page.'). |
|---|
| 446 | '</p>'. |
|---|
| 447 | '</div>'; |
|---|
| 448 | |
|---|
| 449 | if ($post_id) |
|---|
| 450 | { |
|---|
| 451 | echo |
|---|
| 452 | '<h3 class="clear">'.__('Attachments').'</h3>'; |
|---|
| 453 | foreach ($post_media as $f) |
|---|
| 454 | { |
|---|
| 455 | $ftitle = $f->media_title; |
|---|
| 456 | if (strlen($ftitle) > 18) { |
|---|
| 457 | $ftitle = substr($ftitle,0,16).'...'; |
|---|
| 458 | } |
|---|
| 459 | echo |
|---|
| 460 | '<div class="media-item">'. |
|---|
| 461 | '<a class="media-icon" href="media_item.php?id='.$f->media_id.'">'. |
|---|
| 462 | '<img src="'.$f->media_icon.'" alt="" title="'.$f->basename.'" /></a>'. |
|---|
| 463 | '<ul>'. |
|---|
| 464 | '<li><a class="media-link" href="media_item.php?id='.$f->media_id.'"'. |
|---|
| 465 | 'title="'.$f->basename.'">'.$ftitle.'</a></li>'. |
|---|
| 466 | '<li>'.$f->media_dtstr.'</li>'. |
|---|
| 467 | '<li>'.files::size($f->size).' - '. |
|---|
| 468 | '<a href="'.$f->file_url.'">'.__('open').'</a>'.'</li>'. |
|---|
| 469 | |
|---|
| 470 | '<li class="media-action"><a class="attachment-remove" id="attachment-'.$f->media_id.'" '. |
|---|
| 471 | 'href="post_media.php?post_id='.$post_id.'&media_id='.$f->media_id.'&remove=1">'. |
|---|
| 472 | '<img src="images/check-off.png" alt="'.__('remove').'" /></a>'. |
|---|
| 473 | '</li>'. |
|---|
| 474 | |
|---|
| 475 | '</ul>'. |
|---|
| 476 | '</div>'; |
|---|
| 477 | } |
|---|
| 478 | unset($f); |
|---|
| 479 | |
|---|
| 480 | if (empty($post_media)) { |
|---|
| 481 | echo '<p>'.__('No attachment.').'</p>'; |
|---|
| 482 | } |
|---|
| 483 | echo '<p><a href="media.php?post_id='.$post_id.'">'.__('Add files to this page').'</a></p>'; |
|---|
| 484 | } |
|---|
| 485 | |
|---|
| 486 | # --BEHAVIOR-- adminPageFormSidebar |
|---|
| 487 | $core->callBehavior('adminPageFormSidebar',isset($post) ? $post : null); |
|---|
| 488 | |
|---|
| 489 | echo '</div>'; // End #entry-sidebar |
|---|
| 490 | |
|---|
| 491 | echo '</form>'; |
|---|
| 492 | echo '</div>'; |
|---|
| 493 | |
|---|
| 494 | if ($post_id && !empty($post_media)) |
|---|
| 495 | { |
|---|
| 496 | echo |
|---|
| 497 | '<form action="post_media.php" id="attachment-remove-hide" method="post">'. |
|---|
| 498 | '<div>'.form::hidden(array('post_id'),$post_id). |
|---|
| 499 | form::hidden(array('media_id'),''). |
|---|
| 500 | form::hidden(array('remove'),1). |
|---|
| 501 | $core->formNonce().'</div></form>'; |
|---|
| 502 | } |
|---|
| 503 | } |
|---|
| 504 | |
|---|
| 505 | |
|---|
| 506 | /* Comments and trackbacks |
|---|
| 507 | -------------------------------------------------------- */ |
|---|
| 508 | if ($post_id) |
|---|
| 509 | { |
|---|
| 510 | $params = array('post_id' => $post_id, 'order' => 'comment_dt ASC'); |
|---|
| 511 | |
|---|
| 512 | $comments = $core->blog->getComments(array_merge($params,array('comment_trackback'=>0))); |
|---|
| 513 | $trackbacks = $core->blog->getComments(array_merge($params,array('comment_trackback'=>1))); |
|---|
| 514 | |
|---|
| 515 | # Actions combo box |
|---|
| 516 | $combo_action = array(); |
|---|
| 517 | if ($can_edit_page && $core->auth->check('publish,contentadmin',$core->blog->id)) |
|---|
| 518 | { |
|---|
| 519 | $combo_action[__('publish')] = 'publish'; |
|---|
| 520 | $combo_action[__('unpublish')] = 'unpublish'; |
|---|
| 521 | $combo_action[__('mark as pending')] = 'pending'; |
|---|
| 522 | $combo_action[__('mark as junk')] = 'junk'; |
|---|
| 523 | } |
|---|
| 524 | |
|---|
| 525 | if ($can_edit_page && $core->auth->check('delete,contentadmin',$core->blog->id)) |
|---|
| 526 | { |
|---|
| 527 | $combo_action[__('delete')] = 'delete'; |
|---|
| 528 | } |
|---|
| 529 | |
|---|
| 530 | $has_action = !empty($combo_action) && (!$trackbacks->isEmpty() || !$comments->isEmpty()); |
|---|
| 531 | |
|---|
| 532 | echo |
|---|
| 533 | '<div id="comments" class="multi-part" title="'.__('Comments').'">'; |
|---|
| 534 | |
|---|
| 535 | if ($has_action) { |
|---|
| 536 | echo '<form action="comments_actions.php" method="post">'; |
|---|
| 537 | } |
|---|
| 538 | |
|---|
| 539 | echo '<h3>'.__('Trackbacks').'</h3>'; |
|---|
| 540 | |
|---|
| 541 | if (!$trackbacks->isEmpty()) { |
|---|
| 542 | showComments($trackbacks,$has_action); |
|---|
| 543 | } else { |
|---|
| 544 | echo '<p>'.__('No trackback').'</p>'; |
|---|
| 545 | } |
|---|
| 546 | |
|---|
| 547 | echo '<h3>'.__('Comments').'</h3>'; |
|---|
| 548 | if (!$comments->isEmpty()) { |
|---|
| 549 | showComments($comments,$has_action); |
|---|
| 550 | } else { |
|---|
| 551 | echo '<p>'.__('No comment').'</p>'; |
|---|
| 552 | } |
|---|
| 553 | |
|---|
| 554 | if ($has_action) { |
|---|
| 555 | echo |
|---|
| 556 | '<div class="two-cols">'. |
|---|
| 557 | '<p class="col checkboxes-helpers"></p>'. |
|---|
| 558 | |
|---|
| 559 | '<p class="col right"><label for="action">'.__('Selected comments action:').'</label> '. |
|---|
| 560 | form::combo('action',$combo_action). |
|---|
| 561 | form::hidden('redir',html::escapeURL($redir_url).'&id='.$post_id.'&co=1'). |
|---|
| 562 | $core->formNonce(). |
|---|
| 563 | '<input type="submit" value="'.__('ok').'" /></p>'. |
|---|
| 564 | '</div>'. |
|---|
| 565 | '</form>'; |
|---|
| 566 | } |
|---|
| 567 | |
|---|
| 568 | echo '</div>'; |
|---|
| 569 | } |
|---|
| 570 | |
|---|
| 571 | /* Add a comment |
|---|
| 572 | -------------------------------------------------------- */ |
|---|
| 573 | if ($post_id) |
|---|
| 574 | { |
|---|
| 575 | echo |
|---|
| 576 | '<div class="multi-part" id="add-comment" title="'.__('Add a comment').'">'. |
|---|
| 577 | '<h3>'.__('Add a comment').'</h3>'. |
|---|
| 578 | |
|---|
| 579 | '<form action="comment.php" method="post" id="comment-form">'. |
|---|
| 580 | '<div class="constrained">'. |
|---|
| 581 | '<p><label for="comment_author" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Name:'). |
|---|
| 582 | form::field('comment_author',30,255,html::escapeHTML($core->auth->getInfo('user_cn'))). |
|---|
| 583 | '</label></p>'. |
|---|
| 584 | |
|---|
| 585 | '<p><label for="comment_email">'.__('Email:'). |
|---|
| 586 | form::field('comment_email',30,255,html::escapeHTML($core->auth->getInfo('user_email'))). |
|---|
| 587 | '</label></p>'. |
|---|
| 588 | |
|---|
| 589 | '<p><label for="comment_site">'.__('Web site:'). |
|---|
| 590 | form::field('comment_site',30,255,html::escapeHTML($core->auth->getInfo('user_url'))). |
|---|
| 591 | '</label></p>'. |
|---|
| 592 | |
|---|
| 593 | '<p class="area"><label for="comment_content" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Comment:').'</label> '. |
|---|
| 594 | form::textarea('comment_content',50,8,html::escapeHTML('')). |
|---|
| 595 | '</p>'. |
|---|
| 596 | |
|---|
| 597 | '<p>'.form::hidden('post_id',$post_id). |
|---|
| 598 | $core->formNonce(). |
|---|
| 599 | '<input type="submit" name="add" value="'.__('Save').'" /></p>'. |
|---|
| 600 | '</div>'. |
|---|
| 601 | '</form>'. |
|---|
| 602 | '</div>'; |
|---|
| 603 | } |
|---|
| 604 | |
|---|
| 605 | |
|---|
| 606 | # Show comments or trackbacks |
|---|
| 607 | function showComments($rs,$has_action) |
|---|
| 608 | { |
|---|
| 609 | echo |
|---|
| 610 | '<table class="comments-list"><tr>'. |
|---|
| 611 | '<th colspan="2">'.__('Author').'</th>'. |
|---|
| 612 | '<th>'.__('Date').'</th>'. |
|---|
| 613 | '<th class="nowrap">'.__('IP address').'</th>'. |
|---|
| 614 | '<th>'.__('Status').'</th>'. |
|---|
| 615 | '<th> </th>'. |
|---|
| 616 | '</tr>'; |
|---|
| 617 | |
|---|
| 618 | while($rs->fetch()) |
|---|
| 619 | { |
|---|
| 620 | $comment_url = 'comment.php?id='.$rs->comment_id; |
|---|
| 621 | |
|---|
| 622 | $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; |
|---|
| 623 | switch ($rs->comment_status) { |
|---|
| 624 | case 1: |
|---|
| 625 | $img_status = sprintf($img,__('published'),'check-on.png'); |
|---|
| 626 | break; |
|---|
| 627 | case 0: |
|---|
| 628 | $img_status = sprintf($img,__('unpublished'),'check-off.png'); |
|---|
| 629 | break; |
|---|
| 630 | case -1: |
|---|
| 631 | $img_status = sprintf($img,__('pending'),'check-wrn.png'); |
|---|
| 632 | break; |
|---|
| 633 | case -2: |
|---|
| 634 | $img_status = sprintf($img,__('junk'),'junk.png'); |
|---|
| 635 | break; |
|---|
| 636 | } |
|---|
| 637 | |
|---|
| 638 | echo |
|---|
| 639 | '<tr class="line'.($rs->comment_status != 1 ? ' offline' : '').'"'. |
|---|
| 640 | ' id="c'.$rs->comment_id.'">'. |
|---|
| 641 | |
|---|
| 642 | '<td class="nowrap">'. |
|---|
| 643 | ($has_action ? form::checkbox(array('comments[]'),$rs->comment_id,'','','',0,'title="'.__('select this comment').'"') : '').'</td>'. |
|---|
| 644 | '<td class="maximal">'.$rs->comment_author.'</td>'. |
|---|
| 645 | '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$rs->comment_dt).'</td>'. |
|---|
| 646 | '<td class="nowrap"><a href="comments.php?ip='.$rs->comment_ip.'">'.$rs->comment_ip.'</a></td>'. |
|---|
| 647 | '<td class="nowrap status">'.$img_status.'</td>'. |
|---|
| 648 | '<td class="nowrap status"><a href="'.$comment_url.'">'. |
|---|
| 649 | '<img src="images/edit-mini.png" alt="" title="'.__('Edit this comment').'" /></a></td>'. |
|---|
| 650 | |
|---|
| 651 | '</tr>'; |
|---|
| 652 | } |
|---|
| 653 | |
|---|
| 654 | echo '</table>'; |
|---|
| 655 | } |
|---|
| 656 | dcPage::helpBlock('page'); |
|---|
| 657 | ?> |
|---|
| 658 | </body> |
|---|
| 659 | </html> |
|---|