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