Changeset 3703:53c8bef8608a for admin/post.php
- Timestamp:
- 02/15/18 16:39:52 (8 years ago)
- Branch:
- default
- File:
-
- 1 edited
-
admin/post.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
admin/post.php
r3640 r3703 11 11 # -- END LICENSE BLOCK ----------------------------------------- 12 12 13 require dirname(__FILE__) .'/../inc/admin/prepend.php';13 require dirname(__FILE__) . '/../inc/admin/prepend.php'; 14 14 15 15 dcPage::check('usage,contentadmin'); 16 16 17 $post_id = '';18 $cat_id = '';19 $post_dt = '';20 $post_format = $core->auth->getOption('post_format');21 $post_editor = $core->auth->getOption('editor');22 $post_password = '';23 $post_url = '';24 $post_lang = $core->auth->getInfo('user_lang');25 $post_title = '';26 $post_excerpt = '';17 $post_id = ''; 18 $cat_id = ''; 19 $post_dt = ''; 20 $post_format = $core->auth->getOption('post_format'); 21 $post_editor = $core->auth->getOption('editor'); 22 $post_password = ''; 23 $post_url = ''; 24 $post_lang = $core->auth->getInfo('user_lang'); 25 $post_title = ''; 26 $post_excerpt = ''; 27 27 $post_excerpt_xhtml = ''; 28 $post_content = '';28 $post_content = ''; 29 29 $post_content_xhtml = ''; 30 $post_notes = '';31 $post_status = $core->auth->getInfo('user_post_status');32 $post_selected = false;33 $post_open_comment = $core->blog->settings->system->allow_comments;34 $post_open_tb = $core->blog->settings->system->allow_trackbacks;30 $post_notes = ''; 31 $post_status = $core->auth->getInfo('user_post_status'); 32 $post_selected = false; 33 $post_open_comment = $core->blog->settings->system->allow_comments; 34 $post_open_tb = $core->blog->settings->system->allow_trackbacks; 35 35 36 36 $page_title = __('New entry'); 37 37 38 38 $can_view_page = true; 39 $can_edit_post = $core->auth->check('usage,contentadmin', $core->blog->id);40 $can_publish = $core->auth->check('publish,contentadmin',$core->blog->id);41 $can_delete = false;42 43 $post_headlink = '<link rel="%s" title="%s" href="' .$core->adminurl->get('admin.post',array('id' => "%s"),'&',true).'" />';44 $post_link = '<a href="'.$core->adminurl->get('admin.post',array('id' => "%s"),'&',true).'" title="%s">%s</a>';45 $next_link = $prev_link = $next_headlink = $prev_headlink= null;39 $can_edit_post = $core->auth->check('usage,contentadmin', $core->blog->id); 40 $can_publish = $core->auth->check('publish,contentadmin', $core->blog->id); 41 $can_delete = false; 42 43 $post_headlink = '<link rel="%s" title="%s" href="' . $core->adminurl->get('admin.post', array('id' => "%s"), '&', true) . '" />'; 44 $post_link = '<a href="' . $core->adminurl->get('admin.post', array('id' => "%s"), '&', true) . '" title="%s">%s</a>'; 45 $next_link = $prev_link = $next_headlink = $prev_headlink = null; 46 46 47 47 # If user can't publish 48 48 if (!$can_publish) { 49 $post_status = -2;49 $post_status = -2; 50 50 } 51 51 52 52 # Getting categories 53 53 $categories_combo = dcAdminCombos::getCategoriesCombo( 54 $core->blog->getCategories()54 $core->blog->getCategories() 55 55 ); 56 56 … … 60 60 61 61 # Formats combo 62 $core_formaters = $core->getFormaters();62 $core_formaters = $core->getFormaters(); 63 63 $available_formats = array('' => ''); 64 64 foreach ($core_formaters as $editor => $formats) { 65 foreach ($formats as $format) {66 $available_formats[$format] = $format;67 }65 foreach ($formats as $format) { 66 $available_formats[$format] = $format; 67 } 68 68 } 69 69 70 70 # Languages combo 71 $rs = $core->blog->getLangs(array('order'=>'asc'));72 $lang_combo = dcAdminCombos::getLangsCombo($rs, true);71 $rs = $core->blog->getLangs(array('order' => 'asc')); 72 $lang_combo = dcAdminCombos::getLangsCombo($rs, true); 73 73 74 74 # Validation flag … … 76 76 77 77 # Trackbacks 78 $TB = new dcTrackback($core);78 $TB = new dcTrackback($core); 79 79 $tb_urls = $tb_excerpt = ''; 80 80 81 81 # Get entry informations 82 82 if (!empty($_REQUEST['id'])) { 83 $page_title = __('Edit entry');84 85 $params['post_id'] = $_REQUEST['id'];86 87 $post = $core->blog->getPosts($params);88 89 if ($post->isEmpty()) {90 $core->error->add(__('This entry does not exist.'));91 $can_view_page = false;92 } else {93 $post_id= $post->post_id;94 $cat_id= $post->cat_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_selected= (boolean) $post->post_selected;108 $post_open_comment= (boolean) $post->post_open_comment;109 $post_open_tb= (boolean) $post->post_open_tb;110 111 $can_edit_post = $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 entry').' »');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 entry'));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 } catch (Exception $e) {134 $core->error->add($e->getMessage());135 }136 137 # Sanitize trackbacks excerpt138 $tb_excerpt = empty($_POST['tb_excerpt']) ?139 $post_excerpt_xhtml.' '.$post_content_xhtml :140 $_POST['tb_excerpt'];141 $tb_excerpt = html::decodeEntities(html::clean($tb_excerpt));142 $tb_excerpt = text::cutString(html::escapeHTML($tb_excerpt), 255);143 $tb_excerpt = preg_replace('/\s+/ms', ' ', $tb_excerpt);144 }145 } 146 if (isset($_REQUEST['section']) && $_REQUEST['section'] =='trackbacks') {147 $anchor = 'trackbacks';83 $page_title = __('Edit entry'); 84 85 $params['post_id'] = $_REQUEST['id']; 86 87 $post = $core->blog->getPosts($params); 88 89 if ($post->isEmpty()) { 90 $core->error->add(__('This entry does not exist.')); 91 $can_view_page = false; 92 } else { 93 $post_id = $post->post_id; 94 $cat_id = $post->cat_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_selected = (boolean) $post->post_selected; 108 $post_open_comment = (boolean) $post->post_open_comment; 109 $post_open_tb = (boolean) $post->post_open_tb; 110 111 $can_edit_post = $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 entry') . ' »'); 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 entry')); 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 } catch (Exception $e) { 134 $core->error->add($e->getMessage()); 135 } 136 137 # Sanitize trackbacks excerpt 138 $tb_excerpt = empty($_POST['tb_excerpt']) ? 139 $post_excerpt_xhtml . ' ' . $post_content_xhtml : 140 $_POST['tb_excerpt']; 141 $tb_excerpt = html::decodeEntities(html::clean($tb_excerpt)); 142 $tb_excerpt = text::cutString(html::escapeHTML($tb_excerpt), 255); 143 $tb_excerpt = preg_replace('/\s+/ms', ' ', $tb_excerpt); 144 } 145 } 146 if (isset($_REQUEST['section']) && $_REQUEST['section'] == 'trackbacks') { 147 $anchor = 'trackbacks'; 148 148 } else { 149 $anchor = 'comments';150 } 151 152 $comments_actions_page = new dcCommentsActionsPage($core, $core->adminurl->get('admin.post'),array('id' => $post_id, '_ANCHOR'=>$anchor,'section' => $anchor));149 $anchor = 'comments'; 150 } 151 152 $comments_actions_page = new dcCommentsActionsPage($core, $core->adminurl->get('admin.post'), array('id' => $post_id, '_ANCHOR' => $anchor, 'section' => $anchor)); 153 153 154 154 if ($comments_actions_page->process()) { 155 return;155 return; 156 156 } 157 157 158 158 # Ping blogs 159 if (!empty($_POST['ping'])) 160 { 161 if (!empty($_POST['tb_urls']) && $post_id && $post_status == 1 && $can_edit_post) 162 { 163 $tb_urls = $_POST['tb_urls']; 164 $tb_urls = str_replace("\r", '', $tb_urls); 165 $tb_post_title = html::escapeHTML(trim(html::clean($post_title))); 166 $tb_post_url = $post->getURL(); 167 168 foreach (explode("\n", $tb_urls) as $tb_url) 169 { 170 try { 171 # --BEHAVIOR-- adminBeforePingTrackback 172 $core->callBehavior('adminBeforePingTrackback',$tb_url,$post_id,$tb_post_title,$tb_excerpt,$tb_post_url); 173 174 $TB->ping($tb_url, $post_id, $tb_post_title, $tb_excerpt, $tb_post_url); 175 } catch (Exception $e) { 176 $core->error->add($e->getMessage()); 177 } 178 } 179 180 if (!$core->error->flag()) { 181 dcPage::addSuccessNotice(__('All pings sent.')); 182 $core->adminurl->redirect( 183 'admin.post', 184 array('id' => $post_id, 'tb'=> '1') 185 ); 186 } 187 } 159 if (!empty($_POST['ping'])) { 160 if (!empty($_POST['tb_urls']) && $post_id && $post_status == 1 && $can_edit_post) { 161 $tb_urls = $_POST['tb_urls']; 162 $tb_urls = str_replace("\r", '', $tb_urls); 163 $tb_post_title = html::escapeHTML(trim(html::clean($post_title))); 164 $tb_post_url = $post->getURL(); 165 166 foreach (explode("\n", $tb_urls) as $tb_url) { 167 try { 168 # --BEHAVIOR-- adminBeforePingTrackback 169 $core->callBehavior('adminBeforePingTrackback', $tb_url, $post_id, $tb_post_title, $tb_excerpt, $tb_post_url); 170 171 $TB->ping($tb_url, $post_id, $tb_post_title, $tb_excerpt, $tb_post_url); 172 } catch (Exception $e) { 173 $core->error->add($e->getMessage()); 174 } 175 } 176 177 if (!$core->error->flag()) { 178 dcPage::addSuccessNotice(__('All pings sent.')); 179 $core->adminurl->redirect( 180 'admin.post', 181 array('id' => $post_id, 'tb' => '1') 182 ); 183 } 184 } 188 185 } 189 186 190 187 # Format excerpt and content 191 188 elseif (!empty($_POST) && $can_edit_post) { 192 $post_format = $_POST['post_format']; 193 $post_excerpt = $_POST['post_excerpt']; 194 $post_content = $_POST['post_content']; 195 196 $post_title = $_POST['post_title']; 197 198 $cat_id = (integer) $_POST['cat_id']; 199 200 if (isset($_POST['post_status'])) { 201 $post_status = (integer) $_POST['post_status']; 202 } 203 204 if (empty($_POST['post_dt'])) { 205 $post_dt = ''; 206 } else { 207 try 208 { 209 $post_dt = strtotime($_POST['post_dt']); 210 if ($post_dt == false || $post_dt == -1) { 211 $bad_dt = true; 212 throw new Exception(__('Invalid publication date')); 213 } 214 $post_dt = date('Y-m-d H:i',$post_dt); 215 } 216 catch (Exception $e) 217 { 218 $core->error->add($e->getMessage()); 219 } 220 } 221 222 $post_open_comment = !empty($_POST['post_open_comment']); 223 $post_open_tb = !empty($_POST['post_open_tb']); 224 $post_selected = !empty($_POST['post_selected']); 225 $post_lang = $_POST['post_lang']; 226 $post_password = !empty($_POST['post_password']) ? $_POST['post_password'] : null; 227 228 $post_notes = $_POST['post_notes']; 229 230 if (isset($_POST['post_url'])) { 231 $post_url = $_POST['post_url']; 232 } 233 234 $core->blog->setPostContent( 235 $post_id,$post_format,$post_lang, 236 $post_excerpt,$post_excerpt_xhtml,$post_content,$post_content_xhtml 237 ); 189 $post_format = $_POST['post_format']; 190 $post_excerpt = $_POST['post_excerpt']; 191 $post_content = $_POST['post_content']; 192 193 $post_title = $_POST['post_title']; 194 195 $cat_id = (integer) $_POST['cat_id']; 196 197 if (isset($_POST['post_status'])) { 198 $post_status = (integer) $_POST['post_status']; 199 } 200 201 if (empty($_POST['post_dt'])) { 202 $post_dt = ''; 203 } else { 204 try 205 { 206 $post_dt = strtotime($_POST['post_dt']); 207 if ($post_dt == false || $post_dt == -1) { 208 $bad_dt = true; 209 throw new Exception(__('Invalid publication date')); 210 } 211 $post_dt = date('Y-m-d H:i', $post_dt); 212 } catch (Exception $e) { 213 $core->error->add($e->getMessage()); 214 } 215 } 216 217 $post_open_comment = !empty($_POST['post_open_comment']); 218 $post_open_tb = !empty($_POST['post_open_tb']); 219 $post_selected = !empty($_POST['post_selected']); 220 $post_lang = $_POST['post_lang']; 221 $post_password = !empty($_POST['post_password']) ? $_POST['post_password'] : null; 222 223 $post_notes = $_POST['post_notes']; 224 225 if (isset($_POST['post_url'])) { 226 $post_url = $_POST['post_url']; 227 } 228 229 $core->blog->setPostContent( 230 $post_id, $post_format, $post_lang, 231 $post_excerpt, $post_excerpt_xhtml, $post_content, $post_content_xhtml 232 ); 238 233 } 239 234 240 235 # Delete post 241 if (!empty($_POST['delete']) && $can_delete) 242 { 243 try { 244 # --BEHAVIOR-- adminBeforePostDelete 245 $core->callBehavior('adminBeforePostDelete',$post_id); 246 $core->blog->delPost($post_id); 247 $core->adminurl->redirect("admin.posts"); 248 } catch (Exception $e) { 249 $core->error->add($e->getMessage()); 250 } 236 if (!empty($_POST['delete']) && $can_delete) { 237 try { 238 # --BEHAVIOR-- adminBeforePostDelete 239 $core->callBehavior('adminBeforePostDelete', $post_id); 240 $core->blog->delPost($post_id); 241 $core->adminurl->redirect("admin.posts"); 242 } catch (Exception $e) { 243 $core->error->add($e->getMessage()); 244 } 251 245 } 252 246 253 247 # Create or update post 254 if (!empty($_POST) && !empty($_POST['save']) && $can_edit_post && !$bad_dt) 255 { 256 # Create category 257 if (!empty($_POST['new_cat_title']) && $core->auth->check('categories', $core->blog->id)) { 258 259 $cur_cat = $core->con->openCursor($core->prefix.'category'); 260 $cur_cat->cat_title = $_POST['new_cat_title']; 261 $cur_cat->cat_url = ''; 262 263 $parent_cat = !empty($_POST['new_cat_parent']) ? $_POST['new_cat_parent'] : ''; 264 265 # --BEHAVIOR-- adminBeforeCategoryCreate 266 $core->callBehavior('adminBeforeCategoryCreate', $cur_cat); 267 268 $cat_id = $core->blog->addCategory($cur_cat, (integer) $parent_cat); 269 270 # --BEHAVIOR-- adminAfterCategoryCreate 271 $core->callBehavior('adminAfterCategoryCreate', $cur_cat, $cat_id); 272 } 273 274 $cur = $core->con->openCursor($core->prefix.'post'); 275 276 $cur->post_title = $post_title; 277 $cur->cat_id = ($cat_id ?: null); 278 $cur->post_dt = $post_dt ? date('Y-m-d H:i:00',strtotime($post_dt)) : ''; 279 $cur->post_format = $post_format; 280 $cur->post_password = $post_password; 281 $cur->post_lang = $post_lang; 282 $cur->post_title = $post_title; 283 $cur->post_excerpt = $post_excerpt; 284 $cur->post_excerpt_xhtml = $post_excerpt_xhtml; 285 $cur->post_content = $post_content; 286 $cur->post_content_xhtml = $post_content_xhtml; 287 $cur->post_notes = $post_notes; 288 $cur->post_status = $post_status; 289 $cur->post_selected = (integer) $post_selected; 290 $cur->post_open_comment = (integer) $post_open_comment; 291 $cur->post_open_tb = (integer) $post_open_tb; 292 293 if (isset($_POST['post_url'])) { 294 $cur->post_url = $post_url; 295 } 296 297 # Update post 298 if ($post_id) { 299 try { 300 # --BEHAVIOR-- adminBeforePostUpdate 301 $core->callBehavior('adminBeforePostUpdate',$cur,$post_id); 302 303 $core->blog->updPost($post_id,$cur); 304 305 # --BEHAVIOR-- adminAfterPostUpdate 306 $core->callBehavior('adminAfterPostUpdate',$cur,$post_id); 307 dcPage::addSuccessNotice (sprintf(__('The post "%s" has been successfully updated'),html::escapeHTML($cur->post_title))); 308 $core->adminurl->redirect( 309 'admin.post', 310 array('id' => $post_id) 311 ); 312 } catch (Exception $e) { 313 $core->error->add($e->getMessage()); 314 } 315 } else { 316 $cur->user_id = $core->auth->userID(); 317 318 try { 319 # --BEHAVIOR-- adminBeforePostCreate 320 $core->callBehavior('adminBeforePostCreate',$cur); 321 322 $return_id = $core->blog->addPost($cur); 323 324 # --BEHAVIOR-- adminAfterPostCreate 325 $core->callBehavior('adminAfterPostCreate',$cur,$return_id); 326 327 dcPage::addSuccessNotice(__('Entry has been successfully created.')); 328 $core->adminurl->redirect( 329 'admin.post', 330 array('id' => $return_id) 331 ); 332 } catch (Exception $e) { 333 $core->error->add($e->getMessage()); 334 } 335 } 248 if (!empty($_POST) && !empty($_POST['save']) && $can_edit_post && !$bad_dt) { 249 # Create category 250 if (!empty($_POST['new_cat_title']) && $core->auth->check('categories', $core->blog->id)) { 251 252 $cur_cat = $core->con->openCursor($core->prefix . 'category'); 253 $cur_cat->cat_title = $_POST['new_cat_title']; 254 $cur_cat->cat_url = ''; 255 256 $parent_cat = !empty($_POST['new_cat_parent']) ? $_POST['new_cat_parent'] : ''; 257 258 # --BEHAVIOR-- adminBeforeCategoryCreate 259 $core->callBehavior('adminBeforeCategoryCreate', $cur_cat); 260 261 $cat_id = $core->blog->addCategory($cur_cat, (integer) $parent_cat); 262 263 # --BEHAVIOR-- adminAfterCategoryCreate 264 $core->callBehavior('adminAfterCategoryCreate', $cur_cat, $cat_id); 265 } 266 267 $cur = $core->con->openCursor($core->prefix . 'post'); 268 269 $cur->post_title = $post_title; 270 $cur->cat_id = ($cat_id ?: null); 271 $cur->post_dt = $post_dt ? date('Y-m-d H:i:00', strtotime($post_dt)) : ''; 272 $cur->post_format = $post_format; 273 $cur->post_password = $post_password; 274 $cur->post_lang = $post_lang; 275 $cur->post_title = $post_title; 276 $cur->post_excerpt = $post_excerpt; 277 $cur->post_excerpt_xhtml = $post_excerpt_xhtml; 278 $cur->post_content = $post_content; 279 $cur->post_content_xhtml = $post_content_xhtml; 280 $cur->post_notes = $post_notes; 281 $cur->post_status = $post_status; 282 $cur->post_selected = (integer) $post_selected; 283 $cur->post_open_comment = (integer) $post_open_comment; 284 $cur->post_open_tb = (integer) $post_open_tb; 285 286 if (isset($_POST['post_url'])) { 287 $cur->post_url = $post_url; 288 } 289 290 # Update post 291 if ($post_id) { 292 try { 293 # --BEHAVIOR-- adminBeforePostUpdate 294 $core->callBehavior('adminBeforePostUpdate', $cur, $post_id); 295 296 $core->blog->updPost($post_id, $cur); 297 298 # --BEHAVIOR-- adminAfterPostUpdate 299 $core->callBehavior('adminAfterPostUpdate', $cur, $post_id); 300 dcPage::addSuccessNotice(sprintf(__('The post "%s" has been successfully updated'), html::escapeHTML($cur->post_title))); 301 $core->adminurl->redirect( 302 'admin.post', 303 array('id' => $post_id) 304 ); 305 } catch (Exception $e) { 306 $core->error->add($e->getMessage()); 307 } 308 } else { 309 $cur->user_id = $core->auth->userID(); 310 311 try { 312 # --BEHAVIOR-- adminBeforePostCreate 313 $core->callBehavior('adminBeforePostCreate', $cur); 314 315 $return_id = $core->blog->addPost($cur); 316 317 # --BEHAVIOR-- adminAfterPostCreate 318 $core->callBehavior('adminAfterPostCreate', $cur, $return_id); 319 320 dcPage::addSuccessNotice(__('Entry has been successfully created.')); 321 $core->adminurl->redirect( 322 'admin.post', 323 array('id' => $return_id) 324 ); 325 } catch (Exception $e) { 326 $core->error->add($e->getMessage()); 327 } 328 } 336 329 } 337 330 338 331 # Getting categories 339 332 $categories_combo = dcAdminCombos::getCategoriesCombo( 340 $core->blog->getCategories()333 $core->blog->getCategories() 341 334 ); 342 335 /* DISPLAY … … 344 337 $default_tab = 'edit-entry'; 345 338 if (!$can_edit_post) { 346 $default_tab = '';339 $default_tab = ''; 347 340 } 348 341 if (!empty($_GET['co'])) { 349 $default_tab = 'comments'; 350 } 351 elseif (!empty($_GET['tb'])) { 352 $default_tab = 'trackbacks'; 342 $default_tab = 'comments'; 343 } elseif (!empty($_GET['tb'])) { 344 $default_tab = 'trackbacks'; 353 345 } 354 346 355 347 if ($post_id) { 356 switch ($post_status) {357 case 1:358 $img_status = sprintf($img_status_pattern,__('Published'),'check-on.png');359 break;360 case 0:361 $img_status = sprintf($img_status_pattern,__('Unpublished'),'check-off.png');362 break;363 case -1:364 $img_status = sprintf($img_status_pattern,__('Scheduled'),'scheduled.png');365 break;366 case -2:367 $img_status = sprintf($img_status_pattern,__('Pending'),'check-wrn.png');368 break;369 default:370 $img_status = '';371 }372 $edit_entry_str= __('“%s”');373 $page_title_edit = sprintf($edit_entry_str, html::escapeHTML($post_title)).' '.$img_status;348 switch ($post_status) { 349 case 1: 350 $img_status = sprintf($img_status_pattern, __('Published'), 'check-on.png'); 351 break; 352 case 0: 353 $img_status = sprintf($img_status_pattern, __('Unpublished'), 'check-off.png'); 354 break; 355 case -1: 356 $img_status = sprintf($img_status_pattern, __('Scheduled'), 'scheduled.png'); 357 break; 358 case -2: 359 $img_status = sprintf($img_status_pattern, __('Pending'), 'check-wrn.png'); 360 break; 361 default: 362 $img_status = ''; 363 } 364 $edit_entry_str = __('“%s”'); 365 $page_title_edit = sprintf($edit_entry_str, html::escapeHTML($post_title)) . ' ' . $img_status; 374 366 } else { 375 $img_status = ''; 376 } 377 367 $img_status = ''; 368 } 378 369 379 370 $admin_post_behavior = ''; … … 388 379 if ($p_edit == $c_edit) { 389 380 $admin_post_behavior .= $core->callBehavior('adminPostEditor', 390 $p_edit, 'post',array('#post_excerpt','#post_content','#comment_content'),$post_format);381 $p_edit, 'post', array('#post_excerpt', '#post_content', '#comment_content'), $post_format); 391 382 } else { 392 383 $admin_post_behavior .= $core->callBehavior('adminPostEditor', 393 $p_edit, 'post',array('#post_excerpt','#post_content'),$post_format);384 $p_edit, 'post', array('#post_excerpt', '#post_content'), $post_format); 394 385 $admin_post_behavior .= $core->callBehavior('adminPostEditor', 395 $c_edit, 'comment',array('#comment_content'),'xhtml');396 } 397 } 398 399 dcPage::open($page_title .' - '.__('Entries'),400 dcPage::jsDatePicker().401 dcPage::jsModal().402 dcPage::jsMetaEditor().403 $admin_post_behavior.404 dcPage::jsLoad('js/_post.js').405 dcPage::jsConfirmClose('entry-form','comment-form').406 # --BEHAVIOR-- adminPostHeaders407 $core->callBehavior('adminPostHeaders').408 dcPage::jsPageTabs($default_tab).409 $next_headlink."\n".$prev_headlink,410 dcPage::breadcrumb(411 array(412 html::escapeHTML($core->blog->name)=> '',413 __('Entries')=> $core->adminurl->get("admin.posts"),414 ($post_id ? $page_title_edit : $page_title) => ''415 ))416 , array(417 'x-frame-allow' => $core->blog->url418 )386 $c_edit, 'comment', array('#comment_content'), 'xhtml'); 387 } 388 } 389 390 dcPage::open($page_title . ' - ' . __('Entries'), 391 dcPage::jsDatePicker() . 392 dcPage::jsModal() . 393 dcPage::jsMetaEditor() . 394 $admin_post_behavior . 395 dcPage::jsLoad('js/_post.js') . 396 dcPage::jsConfirmClose('entry-form', 'comment-form') . 397 # --BEHAVIOR-- adminPostHeaders 398 $core->callBehavior('adminPostHeaders') . 399 dcPage::jsPageTabs($default_tab) . 400 $next_headlink . "\n" . $prev_headlink, 401 dcPage::breadcrumb( 402 array( 403 html::escapeHTML($core->blog->name) => '', 404 __('Entries') => $core->adminurl->get("admin.posts"), 405 ($post_id ? $page_title_edit : $page_title) => '' 406 )) 407 , array( 408 'x-frame-allow' => $core->blog->url 409 ) 419 410 ); 420 411 421 412 if (!empty($_GET['upd'])) { 422 dcPage::success(__('Entry has been successfully updated.')); 423 } 424 elseif (!empty($_GET['crea'])) { 425 dcPage::success(__('Entry has been successfully created.')); 426 } 427 elseif (!empty($_GET['attached'])) { 428 dcPage::success(__('File has been successfully attached.')); 429 } 430 elseif (!empty($_GET['rmattach'])) { 431 dcPage::success(__('Attachment has been successfully removed.')); 413 dcPage::success(__('Entry has been successfully updated.')); 414 } elseif (!empty($_GET['crea'])) { 415 dcPage::success(__('Entry has been successfully created.')); 416 } elseif (!empty($_GET['attached'])) { 417 dcPage::success(__('File has been successfully attached.')); 418 } elseif (!empty($_GET['rmattach'])) { 419 dcPage::success(__('Attachment has been successfully removed.')); 432 420 } 433 421 434 422 if (!empty($_GET['creaco'])) { 435 dcPage::success(__('Comment has been successfully created.'));423 dcPage::success(__('Comment has been successfully created.')); 436 424 } 437 425 if (!empty($_GET['tbsent'])) { 438 dcPage::success(__('All pings sent.'));426 dcPage::success(__('All pings sent.')); 439 427 } 440 428 441 429 # XHTML conversion 442 if (!empty($_GET['xconv'])) 443 { 444 $post_excerpt = $post_excerpt_xhtml; 445 $post_content = $post_content_xhtml; 446 $post_format = 'xhtml'; 447 448 dcPage::message(__('Don\'t forget to validate your XHTML conversion by saving your post.')); 430 if (!empty($_GET['xconv'])) { 431 $post_excerpt = $post_excerpt_xhtml; 432 $post_content = $post_content_xhtml; 433 $post_format = 'xhtml'; 434 435 dcPage::message(__('Don\'t forget to validate your XHTML conversion by saving your post.')); 449 436 } 450 437 451 438 if ($post_id && $post->post_status == 1) { 452 echo '<p><a class="onblog_link outgoing" href="'.$post->getURL().'" title="'.html::escapeHTML($post_title).'">'.__('Go to this entry on the site').' <img src="images/outgoing-blue.png" alt="" /></a></p>'; 453 } 454 if ($post_id) 455 { 456 echo '<p class="nav_prevnext">'; 457 if ($prev_link) { echo $prev_link; } 458 if ($next_link && $prev_link) { echo ' | '; } 459 if ($next_link) { echo $next_link; } 460 461 # --BEHAVIOR-- adminPostNavLinks 462 $core->callBehavior('adminPostNavLinks',isset($post) ? $post : null,'post'); 463 464 echo '</p>'; 439 echo '<p><a class="onblog_link outgoing" href="' . $post->getURL() . '" title="' . html::escapeHTML($post_title) . '">' . __('Go to this entry on the site') . ' <img src="images/outgoing-blue.png" alt="" /></a></p>'; 440 } 441 if ($post_id) { 442 echo '<p class="nav_prevnext">'; 443 if ($prev_link) {echo $prev_link;} 444 if ($next_link && $prev_link) {echo ' | ';} 445 if ($next_link) {echo $next_link;} 446 447 # --BEHAVIOR-- adminPostNavLinks 448 $core->callBehavior('adminPostNavLinks', isset($post) ? $post : null, 'post'); 449 450 echo '</p>'; 465 451 } 466 452 467 453 # Exit if we cannot view page 468 454 if (!$can_view_page) { 469 dcPage::helpBlock('core_post');470 dcPage::close();471 exit;455 dcPage::helpBlock('core_post'); 456 dcPage::close(); 457 exit; 472 458 } 473 459 474 460 # Controls comments or trakbacks capabilities 475 $isContributionAllowed = function ($id,$dt,$com=true) 476 { 477 global $core; 478 479 if (!$id) { 480 return true; 481 } 482 if ($com) { 483 if (($core->blog->settings->system->comments_ttl == 0) || 484 (time() - $core->blog->settings->system->comments_ttl*86400 < $dt)) { 485 return true; 486 } 487 } else { 488 if (($core->blog->settings->system->trackbacks_ttl == 0) || 489 (time() - $core->blog->settings->system->trackbacks_ttl*86400 < $dt)) { 490 return true; 491 } 492 } 493 return false; 461 $isContributionAllowed = function ($id, $dt, $com = true) { 462 global $core; 463 464 if (!$id) { 465 return true; 466 } 467 if ($com) { 468 if (($core->blog->settings->system->comments_ttl == 0) || 469 (time() - $core->blog->settings->system->comments_ttl * 86400 < $dt)) { 470 return true; 471 } 472 } else { 473 if (($core->blog->settings->system->trackbacks_ttl == 0) || 474 (time() - $core->blog->settings->system->trackbacks_ttl * 86400 < $dt)) { 475 return true; 476 } 477 } 478 return false; 494 479 }; 495 480 496 481 # Show comments or trackbacks 497 $showComments = function($rs,$has_action,$tb=false) 498 { 499 global $core; 500 echo 501 '<div class="table-outer">'. 502 '<table class="comments-list"><tr>'. 503 '<th colspan="2" class="first">'.__('Author').'</th>'. 504 '<th>'.__('Date').'</th>'. 505 '<th class="nowrap">'.__('IP address').'</th>'. 506 '<th>'.__('Status').'</th>'. 507 '<th>'.__('Edit').'</th>'. 508 '</tr>'; 509 $comments = array(); 510 if (isset($_REQUEST['comments'])) { 511 foreach ($_REQUEST['comments'] as $v) { 512 $comments[(integer)$v]=true; 513 } 514 } 515 516 while($rs->fetch()) 517 { 518 $comment_url = $core->adminurl->get("admin.comment",array('id' => $rs->comment_id)); 519 520 $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; 521 switch ($rs->comment_status) { 522 case 1: 523 $img_status = sprintf($img,__('Published'),'check-on.png'); 524 break; 525 case 0: 526 $img_status = sprintf($img,__('Unpublished'),'check-off.png'); 527 break; 528 case -1: 529 $img_status = sprintf($img,__('Pending'),'check-wrn.png'); 530 break; 531 case -2: 532 $img_status = sprintf($img,__('Junk'),'junk.png'); 533 break; 534 } 535 536 echo 537 '<tr class="line'.($rs->comment_status != 1 ? ' offline' : '').'"'. 538 ' id="c'.$rs->comment_id.'">'. 539 540 '<td class="nowrap">'. 541 ($has_action ? form::checkbox(array('comments[]'),$rs->comment_id,isset($comments[$rs->comment_id]),'','',0,'title="'.($tb ? __('select this trackback') : __('select this comment')).'"') : '').'</td>'. 542 '<td class="maximal">'.html::escapeHTML($rs->comment_author).'</td>'. 543 '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$rs->comment_dt).'</td>'. 544 '<td class="nowrap"><a href="'.$core->adminurl->get("admin.comments",array('ip' => $rs->comment_ip)).'">'.$rs->comment_ip.'</a></td>'. 545 '<td class="nowrap status">'.$img_status.'</td>'. 546 '<td class="nowrap status"><a href="'.$comment_url.'">'. 547 '<img src="images/edit-mini.png" alt="" title="'.__('Edit this comment').'" /> '.__('Edit').'</a></td>'. 548 549 '</tr>'; 550 } 551 552 echo '</table></div>'; 482 $showComments = function ($rs, $has_action, $tb = false) { 483 global $core; 484 echo 485 '<div class="table-outer">' . 486 '<table class="comments-list"><tr>' . 487 '<th colspan="2" class="first">' . __('Author') . '</th>' . 488 '<th>' . __('Date') . '</th>' . 489 '<th class="nowrap">' . __('IP address') . '</th>' . 490 '<th>' . __('Status') . '</th>' . 491 '<th>' . __('Edit') . '</th>' . 492 '</tr>'; 493 $comments = array(); 494 if (isset($_REQUEST['comments'])) { 495 foreach ($_REQUEST['comments'] as $v) { 496 $comments[(integer) $v] = true; 497 } 498 } 499 500 while ($rs->fetch()) { 501 $comment_url = $core->adminurl->get("admin.comment", array('id' => $rs->comment_id)); 502 503 $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; 504 switch ($rs->comment_status) { 505 case 1: 506 $img_status = sprintf($img, __('Published'), 'check-on.png'); 507 break; 508 case 0: 509 $img_status = sprintf($img, __('Unpublished'), 'check-off.png'); 510 break; 511 case -1: 512 $img_status = sprintf($img, __('Pending'), 'check-wrn.png'); 513 break; 514 case -2: 515 $img_status = sprintf($img, __('Junk'), 'junk.png'); 516 break; 517 } 518 519 echo 520 '<tr class="line' . ($rs->comment_status != 1 ? ' offline' : '') . '"' . 521 ' id="c' . $rs->comment_id . '">' . 522 523 '<td class="nowrap">' . 524 ($has_action ? form::checkbox(array('comments[]'), $rs->comment_id, isset($comments[$rs->comment_id]), '', '', 0, 'title="' . ($tb ? __('select this trackback') : __('select this comment')) . '"') : '') . '</td>' . 525 '<td class="maximal">' . html::escapeHTML($rs->comment_author) . '</td>' . 526 '<td class="nowrap">' . dt::dt2str(__('%Y-%m-%d %H:%M'), $rs->comment_dt) . '</td>' . 527 '<td class="nowrap"><a href="' . $core->adminurl->get("admin.comments", array('ip' => $rs->comment_ip)) . '">' . $rs->comment_ip . '</a></td>' . 528 '<td class="nowrap status">' . $img_status . '</td>' . 529 '<td class="nowrap status"><a href="' . $comment_url . '">' . 530 '<img src="images/edit-mini.png" alt="" title="' . __('Edit this comment') . '" /> ' . __('Edit') . '</a></td>' . 531 532 '</tr>'; 533 } 534 535 echo '</table></div>'; 553 536 }; 554 537 … … 556 539 -------------------------------------------------------- */ 557 540 if ($can_edit_post) { 558 $sidebar_items = new ArrayObject(array( 559 'status-box' => array( 560 'title' => __('Status'), 561 'items' => array( 562 'post_status' => 563 '<p class="entry-status"><label for="post_status">'.__('Entry status').' '.$img_status.'</label>'. 564 form::combo('post_status',$status_combo,$post_status,'maximal','',!$can_publish). 565 '</p>', 566 'post_dt' => 567 '<p><label for="post_dt">'.__('Publication date and hour').'</label>'. 568 form::field('post_dt',16,16,$post_dt,($bad_dt ? 'invalid' : '')). 569 '</p>', 570 'post_lang' => 571 '<p><label for="post_lang">'.__('Entry language').'</label>'. 572 form::combo('post_lang',$lang_combo,$post_lang). 573 '</p>', 574 'post_format' => 575 '<div>'. 576 '<h5 id="label_format"><label for="post_format" class="classic">'.__('Text formatting').'</label></h5>'. 577 '<p>'.form::combo('post_format',$available_formats,$post_format,'maximal').'</p>'. 578 '<p class="format_control control_no_xhtml">'. 579 '<a id="convert-xhtml" class="button'.($post_id && $post_format != 'wiki' ? ' hide' : '').'" href="'. 580 $core->adminurl->get('admin.post',array('id'=> $post_id,'xconv'=> '1')). 581 '">'. 582 __('Convert to XHTML').'</a></p></div>')), 583 'metas-box' => array( 584 'title' => __('Filing'), 585 'items' => array( 586 'post_selected' => 587 '<p><label for="post_selected" class="classic">'. 588 form::checkbox('post_selected',1,$post_selected).' '. 589 __('Selected entry').'</label></p>', 590 'cat_id' => 591 '<div>'. 592 '<h5 id="label_cat_id">'.__('Category').'</h5>'. 593 '<p><label for="cat_id">'.__('Category:').'</label>'. 594 form::combo('cat_id',$categories_combo,$cat_id,'maximal'). 595 '</p>'. 596 ($core->auth->check('categories', $core->blog->id) ? 597 '<div>'. 598 '<h5 id="create_cat">'.__('Add a new category').'</h5>'. 599 '<p><label for="new_cat_title">'.__('Title:').' '. 600 form::field('new_cat_title',30,255,'','maximal').'</label></p>'. 601 '<p><label for="new_cat_parent">'.__('Parent:').' '. 602 form::combo('new_cat_parent',$categories_combo,'','maximal'). 603 '</label></p>'. 604 '</div>' 605 : ''). 606 '</div>')), 607 'options-box' => array( 608 'title' => __('Options'), 609 'items' => array( 610 'post_open_comment_tb' => 611 '<div>'. 612 '<h5 id="label_comment_tb">'.__('Comments and trackbacks list').'</h5>'. 613 '<p><label for="post_open_comment" class="classic">'. 614 form::checkbox('post_open_comment',1,$post_open_comment).' '. 615 __('Accept comments').'</label></p>'. 616 ($core->blog->settings->system->allow_comments ? 617 ($isContributionAllowed($post_id,strtotime($post_dt),true) ? 618 '' : 619 '<p class="form-note warn">'. 620 __('Warning: Comments are not more accepted for this entry.').'</p>') : 621 '<p class="form-note warn">'. 622 __('Comments are not accepted on this blog so far.').'</p>'). 623 '<p><label for="post_open_tb" class="classic">'. 624 form::checkbox('post_open_tb',1,$post_open_tb).' '. 625 __('Accept trackbacks').'</label></p>'. 626 ($core->blog->settings->system->allow_trackbacks ? 627 ($isContributionAllowed($post_id,strtotime($post_dt),false) ? 628 '' : 629 '<p class="form-note warn">'. 630 __('Warning: Trackbacks are not more accepted for this entry.').'</p>') : 631 '<p class="form-note warn">'.__('Trackbacks are not accepted on this blog so far.').'</p>'). 632 '</div>', 633 'post_password' => 634 '<p><label for="post_password">'.__('Password').'</label>'. 635 form::field('post_password',10,32,html::escapeHTML($post_password),'maximal'). 636 '</p>', 637 'post_url' => 638 '<div class="lockable">'. 639 '<p><label for="post_url">'.__('Edit basename').'</label>'. 640 form::field('post_url',10,255,html::escapeHTML($post_url),'maximal'). 641 '</p>'. 642 '<p class="form-note warn">'. 643 __('Warning: If you set the URL manually, it may conflict with another entry.'). 644 '</p></div>' 645 )))); 646 647 $main_items = new ArrayObject(array( 648 "post_title" => 649 '<p class="col">'. 650 '<label class="required no-margin bold" for="post_title"><abbr title="'.__('Required field').'">*</abbr> '.__('Title:').'</label>'. 651 form::field('post_title',20,255,html::escapeHTML($post_title),'maximal','',false,'required placeholder="'.__('Title').'"'). 652 '</p>', 653 654 "post_excerpt" => 655 '<p class="area" id="excerpt-area"><label for="post_excerpt" class="bold">'.__('Excerpt:').' <span class="form-note">'. 656 __('Introduction to the post.').'</span></label> '. 657 form::textarea('post_excerpt',50,5,html::escapeHTML($post_excerpt)). 658 '</p>', 659 660 "post_content" => 661 '<p class="area" id="content-area"><label class="required bold" '. 662 'for="post_content"><abbr title="'.__('Required field').'">*</abbr> '.__('Content:').'</label> '. 663 form::textarea('post_content',50,$core->auth->getOption('edit_size'),html::escapeHTML($post_content), 664 '','',false,'required placeholder="'.__('Content').'"'). 665 '</p>', 666 667 "post_notes" => 668 '<p class="area" id="notes-area"><label for="post_notes" class="bold">'.__('Personal notes:').' <span class="form-note">'. 669 __('Unpublished notes.').'</span></label>'. 670 form::textarea('post_notes',50,5,html::escapeHTML($post_notes)). 671 '</p>' 672 ) 673 ); 674 675 # --BEHAVIOR-- adminPostFormItems 676 $core->callBehavior('adminPostFormItems',$main_items,$sidebar_items,isset($post) ? $post : null,'post'); 677 678 echo '<div class="multi-part" title="'.($post_id ? __('Edit entry') : __('New entry')). 679 sprintf(' › %s',$post_format).'" id="edit-entry">'; 680 echo '<form action="'.$core->adminurl->get('admin.post').'" method="post" id="entry-form">'; 681 echo '<div id="entry-wrapper">'; 682 echo '<div id="entry-content"><div class="constrained">'; 683 684 echo '<h3 class="out-of-screen-if-js">'.__('Edit post').'</h3>'; 685 686 foreach ($main_items as $id => $item) { 687 echo $item; 688 } 689 690 # --BEHAVIOR-- adminPostForm (may be deprecated) 691 $core->callBehavior('adminPostForm',isset($post) ? $post : null,'post'); 692 693 echo 694 '<p class="border-top">'. 695 ($post_id ? form::hidden('id',$post_id) : ''). 696 '<input type="submit" value="'.__('Save').' (s)" '. 697 'accesskey="s" name="save" /> '; 698 if ($post_id) { 699 $preview_url = 700 $core->blog->url.$core->url->getURLFor('preview',$core->auth->userID().'/'. 701 http::browserUID(DC_MASTER_KEY.$core->auth->userID().$core->auth->cryptLegacy($core->auth->userID())). 702 '/'.$post->post_url); 703 echo '<a id="post-preview" href="'.$preview_url.'" class="button modal" accesskey="p">'.__('Preview').' (p)'.'</a>'; 704 } else { 705 echo 706 '<a id="post-cancel" href="'.$core->adminurl->get("admin.home").'" class="button" accesskey="c">'.__('Cancel').' (c)</a>'; 707 } 708 709 echo 710 ($can_delete ? ' <input type="submit" class="delete" value="'.__('Delete').'" name="delete" />' : ''). 711 $core->formNonce(). 712 '</p>'; 713 714 echo '</div></div>'; // End #entry-content 715 echo '</div>'; // End #entry-wrapper 716 717 echo '<div id="entry-sidebar" role="complementary">'; 718 719 foreach ($sidebar_items as $id => $c) { 720 echo '<div id="'.$id.'" class="sb-box">'. 721 '<h4>'.$c['title'].'</h4>'; 722 foreach ($c['items'] as $e_name=>$e_content) { 723 echo $e_content; 724 } 725 echo '</div>'; 726 } 727 728 729 # --BEHAVIOR-- adminPostFormSidebar (may be deprecated) 730 $core->callBehavior('adminPostFormSidebar',isset($post) ? $post : null,'post'); 731 echo '</div>'; // End #entry-sidebar 732 733 echo '</form>'; 734 735 # --BEHAVIOR-- adminPostForm 736 $core->callBehavior('adminPostAfterForm',isset($post) ? $post : null,'post'); 737 738 echo '</div>'; 739 } 740 741 if ($post_id) 742 { 743 /* Comments 744 -------------------------------------------------------- */ 745 746 $params = array('post_id' => $post_id, 'order' => 'comment_dt ASC'); 747 748 $comments = $core->blog->getComments(array_merge($params,array('comment_trackback'=>0))); 749 750 echo 751 '<div id="comments" class="clear multi-part" title="'.__('Comments').'">'; 752 $combo_action = $comments_actions_page->getCombo(); 753 $has_action = !empty($combo_action) && !$comments->isEmpty(); 754 echo 755 '<p class="top-add"><a class="button add" href="#comment-form">'.__('Add a comment').'</a></p>'; 756 757 if ($has_action) { 758 echo '<form action="'.$core->adminurl->get('admin.post').'" id="form-comments" method="post">'; 759 } 760 761 echo '<h3>'.__('Comments').'</h3>'; 762 if (!$comments->isEmpty()) { 763 $showComments($comments,$has_action); 764 } else { 765 echo '<p>'.__('No comments').'</p>'; 766 } 767 768 if ($has_action) { 769 echo 770 '<div class="two-cols">'. 771 '<p class="col checkboxes-helpers"></p>'. 772 773 '<p class="col right"><label for="action" class="classic">'.__('Selected comments action:').'</label> '. 774 form::combo('action',$combo_action). 775 form::hidden(array('section'),'comments'). 776 form::hidden(array('id'),$post_id). 777 $core->formNonce(). 778 '<input type="submit" value="'.__('ok').'" /></p>'. 779 '</div>'. 780 '</form>'; 781 } 782 /* Add a comment 783 -------------------------------------------------------- */ 784 785 echo 786 '<div class="fieldset clear">'. 787 '<h3>'.__('Add a comment').'</h3>'. 788 789 '<form action="'.$core->adminurl->get("admin.comment").'" method="post" id="comment-form">'. 790 '<div class="constrained">'. 791 '<p><label for="comment_author" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Name:').'</label>'. 792 form::field('comment_author',30,255,html::escapeHTML($core->auth->getInfo('user_cn')), 793 '','',false,'required placeholder="'.__('Author').'"'). 794 '</p>'. 795 796 '<p><label for="comment_email">'.__('Email:').'</label>'. 797 form::field('comment_email',30,255,html::escapeHTML($core->auth->getInfo('user_email'))). 798 '</p>'. 799 800 '<p><label for="comment_site">'.__('Web site:').'</label>'. 801 form::field('comment_site',30,255,html::escapeHTML($core->auth->getInfo('user_url'))). 802 '</p>'. 803 804 '<p class="area"><label for="comment_content" class="required"><abbr title="'.__('Required field').'">*</abbr> '. 805 __('Comment:').'</label> '. 806 form::textarea('comment_content',50,8,'','','',false,'required placeholder="'.__('Comment').'"'). 807 '</p>'. 808 809 '<p>'. 810 form::hidden('post_id',$post_id). 811 $core->formNonce(). 812 '<input type="submit" name="add" value="'.__('Save').'" /></p>'. 813 '</div>'. #constrained 814 815 '</form>'. 816 '</div>'. #add comment 817 '</div>'; #comments 818 } 819 820 if ($post_id && $post_status == 1) 821 { 822 /* Trackbacks 823 -------------------------------------------------------- */ 824 825 $params = array('post_id' => $post_id, 'order' => 'comment_dt ASC'); 826 $trackbacks = $core->blog->getComments(array_merge($params, array('comment_trackback' => 1))); 827 828 # Actions combo box 829 $combo_action = $comments_actions_page->getCombo(); 830 $has_action = !empty($combo_action) && !$trackbacks->isEmpty(); 831 832 if (!empty($_GET['tb_auto'])) { 833 $tb_urls = implode("\n", $TB->discover($post_excerpt_xhtml.' '.$post_content_xhtml)); 834 } 835 836 # Display tab 837 echo 838 '<div id="trackbacks" class="clear multi-part" title="'.__('Trackbacks').'">'; 839 840 # tracbacks actions 841 if ($has_action) { 842 echo '<form action="'.$core->adminurl->get("admin.post").'" id="form-trackbacks" method="post">'; 843 } 844 845 echo '<h3>'.__('Trackbacks received').'</h3>'; 846 847 if (!$trackbacks->isEmpty()) { 848 $showComments($trackbacks, $has_action, true); 849 } else { 850 echo '<p>'.__('No trackback').'</p>'; 851 } 852 853 if ($has_action) { 854 echo 855 '<div class="two-cols">'. 856 '<p class="col checkboxes-helpers"></p>'. 857 858 '<p class="col right"><label for="action" class="classic">'.__('Selected trackbacks action:').'</label> '. 859 form::combo('action', $combo_action). 860 form::hidden('id',$post_id). 861 form::hidden(array('section'),'trackbacks'). 862 $core->formNonce(). 863 '<input type="submit" value="'.__('ok').'" /></p>'. 864 '</div>'. 865 '</form>'; 866 } 867 868 /* Add trackbacks 869 -------------------------------------------------------- */ 870 if ($can_edit_post && $post->post_status) { 871 echo 872 '<div class="fieldset clear">'; 873 874 echo 875 '<h3>'.__('Ping blogs').'</h3>'. 876 '<form action="'.$core->adminurl->get("admin.post",array('id' => $post_id)).'" id="trackback-form" method="post">'. 877 '<p><label for="tb_urls" class="area">'.__('URLs to ping:').'</label>'. 878 form::textarea('tb_urls', 60, 5, $tb_urls). 879 '</p>'. 880 881 '<p><label for="tb_excerpt" class="area">'.__('Excerpt to send:').'</label>'. 882 form::textarea('tb_excerpt', 60, 5, $tb_excerpt).'</p>'. 883 884 '<p>'. 885 $core->formNonce(). 886 '<input type="submit" name="ping" value="'.__('Ping blogs').'" />'. 887 (empty($_GET['tb_auto']) ? 888 ' <a class="button" href="'. 889 $core->adminurl->get("admin.post",array('id'=> $post_id,'tb_auto' => 1,'tb' => 1)). 890 '">'.__('Auto discover ping URLs').'</a>' 891 : ''). 892 '</p>'. 893 '</form>'; 894 895 $pings = $TB->getPostPings($post_id); 896 897 if (!$pings->isEmpty()) 898 { 899 echo '<h3>'.__('Previously sent pings').'</h3>'; 900 901 echo '<ul class="nice">'; 902 while ($pings->fetch()) { 903 echo 904 '<li>'.dt::dt2str(__('%Y-%m-%d %H:%M'), $pings->ping_dt).' - '. 905 $pings->ping_url.'</li>'; 906 } 907 echo '</ul>'; 908 } 909 910 echo '</div>'; 911 } 912 913 echo '</div>'; #trackbacks 914 } 915 916 dcPage::helpBlock('core_post','core_trackbacks','core_wiki'); 541 $sidebar_items = new ArrayObject(array( 542 'status-box' => array( 543 'title' => __('Status'), 544 'items' => array( 545 'post_status' => 546 '<p class="entry-status"><label for="post_status">' . __('Entry status') . ' ' . $img_status . '</label>' . 547 form::combo('post_status', $status_combo, 548 array('default' => $post_status, 'class' => 'maximal', 'disabled' => !$can_publish)) . 549 '</p>', 550 'post_dt' => 551 '<p><label for="post_dt">' . __('Publication date and hour') . '</label>' . 552 form::field('post_dt', 16, 16, $post_dt, ($bad_dt ? 'invalid' : '')) . 553 '</p>', 554 'post_lang' => 555 '<p><label for="post_lang">' . __('Entry language') . '</label>' . 556 form::combo('post_lang', $lang_combo, $post_lang) . 557 '</p>', 558 'post_format' => 559 '<div>' . 560 '<h5 id="label_format"><label for="post_format" class="classic">' . __('Text formatting') . '</label></h5>' . 561 '<p>' . form::combo('post_format', $available_formats, $post_format, 'maximal') . '</p>' . 562 '<p class="format_control control_no_xhtml">' . 563 '<a id="convert-xhtml" class="button' . ($post_id && $post_format != 'wiki' ? ' hide' : '') . '" href="' . 564 $core->adminurl->get('admin.post', array('id' => $post_id, 'xconv' => '1')) . 565 '">' . 566 __('Convert to XHTML') . '</a></p></div>')), 567 'metas-box' => array( 568 'title' => __('Filing'), 569 'items' => array( 570 'post_selected' => 571 '<p><label for="post_selected" class="classic">' . 572 form::checkbox('post_selected', 1, $post_selected) . ' ' . 573 __('Selected entry') . '</label></p>', 574 'cat_id' => 575 '<div>' . 576 '<h5 id="label_cat_id">' . __('Category') . '</h5>' . 577 '<p><label for="cat_id">' . __('Category:') . '</label>' . 578 form::combo('cat_id', $categories_combo, $cat_id, 'maximal') . 579 '</p>' . 580 ($core->auth->check('categories', $core->blog->id) ? 581 '<div>' . 582 '<h5 id="create_cat">' . __('Add a new category') . '</h5>' . 583 '<p><label for="new_cat_title">' . __('Title:') . ' ' . 584 form::field('new_cat_title', 30, 255, '', 'maximal') . '</label></p>' . 585 '<p><label for="new_cat_parent">' . __('Parent:') . ' ' . 586 form::combo('new_cat_parent', $categories_combo, '', 'maximal') . 587 '</label></p>' . 588 '</div>' 589 : '') . 590 '</div>')), 591 'options-box' => array( 592 'title' => __('Options'), 593 'items' => array( 594 'post_open_comment_tb' => 595 '<div>' . 596 '<h5 id="label_comment_tb">' . __('Comments and trackbacks list') . '</h5>' . 597 '<p><label for="post_open_comment" class="classic">' . 598 form::checkbox('post_open_comment', 1, $post_open_comment) . ' ' . 599 __('Accept comments') . '</label></p>' . 600 ($core->blog->settings->system->allow_comments ? 601 ($isContributionAllowed($post_id, strtotime($post_dt), true) ? 602 '' : 603 '<p class="form-note warn">' . 604 __('Warning: Comments are not more accepted for this entry.') . '</p>') : 605 '<p class="form-note warn">' . 606 __('Comments are not accepted on this blog so far.') . '</p>') . 607 '<p><label for="post_open_tb" class="classic">' . 608 form::checkbox('post_open_tb', 1, $post_open_tb) . ' ' . 609 __('Accept trackbacks') . '</label></p>' . 610 ($core->blog->settings->system->allow_trackbacks ? 611 ($isContributionAllowed($post_id, strtotime($post_dt), false) ? 612 '' : 613 '<p class="form-note warn">' . 614 __('Warning: Trackbacks are not more accepted for this entry.') . '</p>') : 615 '<p class="form-note warn">' . __('Trackbacks are not accepted on this blog so far.') . '</p>') . 616 '</div>', 617 'post_password' => 618 '<p><label for="post_password">' . __('Password') . '</label>' . 619 form::field('post_password', 10, 32, html::escapeHTML($post_password), 'maximal') . 620 '</p>', 621 'post_url' => 622 '<div class="lockable">' . 623 '<p><label for="post_url">' . __('Edit basename') . '</label>' . 624 form::field('post_url', 10, 255, html::escapeHTML($post_url), 'maximal') . 625 '</p>' . 626 '<p class="form-note warn">' . 627 __('Warning: If you set the URL manually, it may conflict with another entry.') . 628 '</p></div>' 629 )))); 630 631 $main_items = new ArrayObject(array( 632 "post_title" => 633 '<p class="col">' . 634 '<label class="required no-margin bold" for="post_title"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Title:') . '</label>' . 635 form::field('post_title', 20, 255, html::escapeHTML($post_title), 'maximal', '', false, 'required placeholder="' . __('Title') . '"') . 636 '</p>', 637 638 "post_excerpt" => 639 '<p class="area" id="excerpt-area"><label for="post_excerpt" class="bold">' . __('Excerpt:') . ' <span class="form-note">' . 640 __('Introduction to the post.') . '</span></label> ' . 641 form::textarea('post_excerpt', 50, 5, html::escapeHTML($post_excerpt)) . 642 '</p>', 643 644 "post_content" => 645 '<p class="area" id="content-area"><label class="required bold" ' . 646 'for="post_content"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Content:') . '</label> ' . 647 form::textarea('post_content', 50, $core->auth->getOption('edit_size'), html::escapeHTML($post_content), 648 '', '', false, 'required placeholder="' . __('Content') . '"') . 649 '</p>', 650 651 "post_notes" => 652 '<p class="area" id="notes-area"><label for="post_notes" class="bold">' . __('Personal notes:') . ' <span class="form-note">' . 653 __('Unpublished notes.') . '</span></label>' . 654 form::textarea('post_notes', 50, 5, html::escapeHTML($post_notes)) . 655 '</p>' 656 ) 657 ); 658 659 # --BEHAVIOR-- adminPostFormItems 660 $core->callBehavior('adminPostFormItems', $main_items, $sidebar_items, isset($post) ? $post : null, 'post'); 661 662 echo '<div class="multi-part" title="' . ($post_id ? __('Edit entry') : __('New entry')) . 663 sprintf(' › %s', $post_format) . '" id="edit-entry">'; 664 echo '<form action="' . $core->adminurl->get('admin.post') . '" method="post" id="entry-form">'; 665 echo '<div id="entry-wrapper">'; 666 echo '<div id="entry-content"><div class="constrained">'; 667 668 echo '<h3 class="out-of-screen-if-js">' . __('Edit post') . '</h3>'; 669 670 foreach ($main_items as $id => $item) { 671 echo $item; 672 } 673 674 # --BEHAVIOR-- adminPostForm (may be deprecated) 675 $core->callBehavior('adminPostForm', isset($post) ? $post : null, 'post'); 676 677 echo 678 '<p class="border-top">' . 679 ($post_id ? form::hidden('id', $post_id) : '') . 680 '<input type="submit" value="' . __('Save') . ' (s)" ' . 681 'accesskey="s" name="save" /> '; 682 if ($post_id) { 683 $preview_url = 684 $core->blog->url . $core->url->getURLFor('preview', $core->auth->userID() . '/' . 685 http::browserUID(DC_MASTER_KEY . $core->auth->userID() . $core->auth->cryptLegacy($core->auth->userID())) . 686 '/' . $post->post_url); 687 echo '<a id="post-preview" href="' . $preview_url . '" class="button modal" accesskey="p">' . __('Preview') . ' (p)' . '</a>'; 688 } else { 689 echo 690 '<a id="post-cancel" href="' . $core->adminurl->get("admin.home") . '" class="button" accesskey="c">' . __('Cancel') . ' (c)</a>'; 691 } 692 693 echo 694 ($can_delete ? ' <input type="submit" class="delete" value="' . __('Delete') . '" name="delete" />' : '') . 695 $core->formNonce() . 696 '</p>'; 697 698 echo '</div></div>'; // End #entry-content 699 echo '</div>'; // End #entry-wrapper 700 701 echo '<div id="entry-sidebar" role="complementary">'; 702 703 foreach ($sidebar_items as $id => $c) { 704 echo '<div id="' . $id . '" class="sb-box">' . 705 '<h4>' . $c['title'] . '</h4>'; 706 foreach ($c['items'] as $e_name => $e_content) { 707 echo $e_content; 708 } 709 echo '</div>'; 710 } 711 712 # --BEHAVIOR-- adminPostFormSidebar (may be deprecated) 713 $core->callBehavior('adminPostFormSidebar', isset($post) ? $post : null, 'post'); 714 echo '</div>'; // End #entry-sidebar 715 716 echo '</form>'; 717 718 # --BEHAVIOR-- adminPostForm 719 $core->callBehavior('adminPostAfterForm', isset($post) ? $post : null, 'post'); 720 721 echo '</div>'; 722 } 723 724 if ($post_id) { 725 /* Comments 726 -------------------------------------------------------- */ 727 728 $params = array('post_id' => $post_id, 'order' => 'comment_dt ASC'); 729 730 $comments = $core->blog->getComments(array_merge($params, array('comment_trackback' => 0))); 731 732 echo 733 '<div id="comments" class="clear multi-part" title="' . __('Comments') . '">'; 734 $combo_action = $comments_actions_page->getCombo(); 735 $has_action = !empty($combo_action) && !$comments->isEmpty(); 736 echo 737 '<p class="top-add"><a class="button add" href="#comment-form">' . __('Add a comment') . '</a></p>'; 738 739 if ($has_action) { 740 echo '<form action="' . $core->adminurl->get('admin.post') . '" id="form-comments" method="post">'; 741 } 742 743 echo '<h3>' . __('Comments') . '</h3>'; 744 if (!$comments->isEmpty()) { 745 $showComments($comments, $has_action); 746 } else { 747 echo '<p>' . __('No comments') . '</p>'; 748 } 749 750 if ($has_action) { 751 echo 752 '<div class="two-cols">' . 753 '<p class="col checkboxes-helpers"></p>' . 754 755 '<p class="col right"><label for="action" class="classic">' . __('Selected comments action:') . '</label> ' . 756 form::combo('action', $combo_action) . 757 form::hidden(array('section'), 'comments') . 758 form::hidden(array('id'), $post_id) . 759 $core->formNonce() . 760 '<input type="submit" value="' . __('ok') . '" /></p>' . 761 '</div>' . 762 '</form>'; 763 } 764 /* Add a comment 765 -------------------------------------------------------- */ 766 767 echo 768 '<div class="fieldset clear">' . 769 '<h3>' . __('Add a comment') . '</h3>' . 770 771 '<form action="' . $core->adminurl->get("admin.comment") . '" method="post" id="comment-form">' . 772 '<div class="constrained">' . 773 '<p><label for="comment_author" class="required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Name:') . '</label>' . 774 form::field('comment_author', 30, 255, html::escapeHTML($core->auth->getInfo('user_cn')), 775 '', '', false, 'required placeholder="' . __('Author') . '"') . 776 '</p>' . 777 778 '<p><label for="comment_email">' . __('Email:') . '</label>' . 779 form::field('comment_email', 30, 255, html::escapeHTML($core->auth->getInfo('user_email'))) . 780 '</p>' . 781 782 '<p><label for="comment_site">' . __('Web site:') . '</label>' . 783 form::field('comment_site', 30, 255, html::escapeHTML($core->auth->getInfo('user_url'))) . 784 '</p>' . 785 786 '<p class="area"><label for="comment_content" class="required"><abbr title="' . __('Required field') . '">*</abbr> ' . 787 __('Comment:') . '</label> ' . 788 form::textarea('comment_content', 50, 8, '', '', '', false, 'required placeholder="' . __('Comment') . '"') . 789 '</p>' . 790 791 '<p>' . 792 form::hidden('post_id', $post_id) . 793 $core->formNonce() . 794 '<input type="submit" name="add" value="' . __('Save') . '" /></p>' . 795 '</div>' . #constrained 796 797 '</form>' . 798 '</div>' . #add comment 799 '</div>'; #comments 800 } 801 802 if ($post_id && $post_status == 1) { 803 /* Trackbacks 804 -------------------------------------------------------- */ 805 806 $params = array('post_id' => $post_id, 'order' => 'comment_dt ASC'); 807 $trackbacks = $core->blog->getComments(array_merge($params, array('comment_trackback' => 1))); 808 809 # Actions combo box 810 $combo_action = $comments_actions_page->getCombo(); 811 $has_action = !empty($combo_action) && !$trackbacks->isEmpty(); 812 813 if (!empty($_GET['tb_auto'])) { 814 $tb_urls = implode("\n", $TB->discover($post_excerpt_xhtml . ' ' . $post_content_xhtml)); 815 } 816 817 # Display tab 818 echo 819 '<div id="trackbacks" class="clear multi-part" title="' . __('Trackbacks') . '">'; 820 821 # tracbacks actions 822 if ($has_action) { 823 echo '<form action="' . $core->adminurl->get("admin.post") . '" id="form-trackbacks" method="post">'; 824 } 825 826 echo '<h3>' . __('Trackbacks received') . '</h3>'; 827 828 if (!$trackbacks->isEmpty()) { 829 $showComments($trackbacks, $has_action, true); 830 } else { 831 echo '<p>' . __('No trackback') . '</p>'; 832 } 833 834 if ($has_action) { 835 echo 836 '<div class="two-cols">' . 837 '<p class="col checkboxes-helpers"></p>' . 838 839 '<p class="col right"><label for="action" class="classic">' . __('Selected trackbacks action:') . '</label> ' . 840 form::combo('action', $combo_action) . 841 form::hidden('id', $post_id) . 842 form::hidden(array('section'), 'trackbacks') . 843 $core->formNonce() . 844 '<input type="submit" value="' . __('ok') . '" /></p>' . 845 '</div>' . 846 '</form>'; 847 } 848 849 /* Add trackbacks 850 -------------------------------------------------------- */ 851 if ($can_edit_post && $post->post_status) { 852 echo 853 '<div class="fieldset clear">'; 854 855 echo 856 '<h3>' . __('Ping blogs') . '</h3>' . 857 '<form action="' . $core->adminurl->get("admin.post", array('id' => $post_id)) . '" id="trackback-form" method="post">' . 858 '<p><label for="tb_urls" class="area">' . __('URLs to ping:') . '</label>' . 859 form::textarea('tb_urls', 60, 5, $tb_urls) . 860 '</p>' . 861 862 '<p><label for="tb_excerpt" class="area">' . __('Excerpt to send:') . '</label>' . 863 form::textarea('tb_excerpt', 60, 5, $tb_excerpt) . '</p>' . 864 865 '<p>' . 866 $core->formNonce() . 867 '<input type="submit" name="ping" value="' . __('Ping blogs') . '" />' . 868 (empty($_GET['tb_auto']) ? 869 ' <a class="button" href="' . 870 $core->adminurl->get("admin.post", array('id' => $post_id, 'tb_auto' => 1, 'tb' => 1)) . 871 '">' . __('Auto discover ping URLs') . '</a>' 872 : '') . 873 '</p>' . 874 '</form>'; 875 876 $pings = $TB->getPostPings($post_id); 877 878 if (!$pings->isEmpty()) { 879 echo '<h3>' . __('Previously sent pings') . '</h3>'; 880 881 echo '<ul class="nice">'; 882 while ($pings->fetch()) { 883 echo 884 '<li>' . dt::dt2str(__('%Y-%m-%d %H:%M'), $pings->ping_dt) . ' - ' . 885 $pings->ping_url . '</li>'; 886 } 887 echo '</ul>'; 888 } 889 890 echo '</div>'; 891 } 892 893 echo '</div>'; #trackbacks 894 } 895 896 dcPage::helpBlock('core_post', 'core_trackbacks', 'core_wiki'); 917 897 dcPage::close();
Note: See TracChangeset
for help on using the changeset viewer.
