Changeset 2705:bac24f5c42ae
- Timestamp:
- 05/04/14 18:03:29 (11 years ago)
- Branch:
- default
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
admin/post.php
r2694 r2705 19 19 $post_dt = ''; 20 20 $post_format = $core->auth->getOption('post_format'); 21 $ editor = $core->auth->getOption('editor');21 $post_editor = $core->auth->getOption('editor'); 22 22 $post_password = ''; 23 23 $post_url = ''; … … 61 61 62 62 # Formaters combo 63 $formaters_combo = dcAdminCombos::getFormatersCombo($editor); 63 $formaters_combo = dcAdminCombos::getFormatersCombo(); 64 foreach ($formaters_combo as $editor => $formats) { 65 foreach ($formats as $format) { 66 $formaters_combo[$editor][$format] = "$editor:$format"; 67 } 68 } 64 69 65 70 # Languages combo … … 83 88 84 89 # Get entry informations 85 if (!empty($_REQUEST['id'])) 86 { 90 if (!empty($_REQUEST['id'])) { 87 91 $page_title = __('Edit entry'); 88 92 … … 91 95 $post = $core->blog->getPosts($params); 92 96 93 if ($post->isEmpty()) 94 { 97 if ($post->isEmpty()) { 95 98 $core->error->add(__('This entry does not exist.')); 96 99 $can_view_page = false; 97 } 98 else 99 { 100 } else { 100 101 $post_id = $post->post_id; 101 102 $cat_id = $post->cat_id; 102 103 $post_dt = date('Y-m-d H:i',strtotime($post->post_dt)); 103 104 $post_format = $post->post_format; 105 # try to retrieve editor from post meta 106 $meta_editor = $core->meta->getMetaStr($post->post_meta,'editor'); 107 if (!empty($meta_editor)) { 108 $post_editor = $meta_editor; 109 } 104 110 $post_password = $post->post_password; 105 111 $post_url = $post->post_url; … … 190 196 191 197 # Format excerpt and content 192 elseif (!empty($_POST) && $can_edit_post) 193 { 194 $post_format = $_POST['post_format']; 198 elseif (!empty($_POST) && $can_edit_post) { 199 200 if (strpos($_POST['post_format'], ':')!==false) { 201 list($post_editor, $post_format) = explode(':', $_POST['post_format']); 202 } else { 203 $post_format = $_POST['post_format']; 204 $post_editor = ''; 205 } 206 195 207 $post_excerpt = $_POST['post_excerpt']; 196 208 $post_content = $_POST['post_content']; … … 280 292 $cur->post_dt = $post_dt ? date('Y-m-d H:i:00',strtotime($post_dt)) : ''; 281 293 $cur->post_format = $post_format; 294 $cur->post_meta = serialize(array('editor' => $post_editor)); 282 295 $cur->post_password = $post_password; 283 296 $cur->post_lang = $post_lang; … … 298 311 299 312 # Update post 300 if ($post_id) 301 { 302 try 303 { 313 if ($post_id) { 314 try { 315 $meta = $core->meta; 316 $meta->delPostMeta($post_id,'editor'); 317 $meta->setPostMeta($post_id,'editor',$post_editor); 318 304 319 # --BEHAVIOR-- adminBeforePostUpdate 305 320 $core->callBehavior('adminBeforePostUpdate',$cur,$post_id); … … 311 326 dcPage::addSuccessNotice (sprintf(__('The post "%s" has been successfully updated'),html::escapeHTML($cur->post_title))); 312 327 http::redirect('post.php?id='.$post_id); 313 } 314 catch (Exception $e) 315 { 328 } catch (Exception $e) { 316 329 $core->error->add($e->getMessage()); 317 330 } 318 } 319 else 320 { 331 } else { 321 332 $cur->user_id = $core->auth->userID(); 322 333 323 try 324 { 334 try { 325 335 # --BEHAVIOR-- adminBeforePostCreate 326 336 $core->callBehavior('adminBeforePostCreate',$cur); … … 328 338 $return_id = $core->blog->addPost($cur); 329 339 340 $meta = $core->meta; 341 $meta->delPostMeta($return_id,'editor'); 342 $meta->setPostMeta($return_id,'editor',$post_editor); 343 330 344 # --BEHAVIOR-- adminAfterPostCreate 331 345 $core->callBehavior('adminAfterPostCreate',$cur,$return_id); … … 333 347 dcPage::addSuccessNotice(__('Entry has been successfully created.')); 334 348 http::redirect('post.php?id='.$return_id); 335 } 336 catch (Exception $e) 337 { 349 } catch (Exception $e) { 338 350 $core->error->add($e->getMessage()); 339 351 } … … 381 393 } 382 394 395 $admin_post_behavior = ''; 396 if (($core->auth->getOption('editor')==$post_editor) 397 && in_array($post_format, $core->getFormaters($core->auth->getOption('editor')))) { 398 $admin_post_behavior = $core->callBehavior('adminPostEditor'); 399 } 383 400 384 401 dcPage::open($page_title.' - '.__('Entries'), … … 386 403 dcPage::jsModal(). 387 404 dcPage::jsMetaEditor(). 405 $admin_post_behavior. 388 406 dcPage::jsLoad('js/_post.js'). 389 $core->callBehavior('adminPostEditor').390 407 dcPage::jsConfirmClose('entry-form','comment-form'). 391 408 # --BEHAVIOR-- adminPostHeaders … … 455 472 /* Post form if we can edit post 456 473 -------------------------------------------------------- */ 457 if ($can_edit_post) 458 { 474 if ($can_edit_post) { 459 475 if (count($formaters_combo)>0 && ($core->auth->getOption('editor') && $core->auth->getOption('editor')!='')) { 460 $post_format_field = form::combo('post_format',$formaters_combo,$post_format,'maximal'); 476 // temporay removed until we can switch easily editor 477 // $post_format_field = form::combo('post_format',$formaters_combo,"$post_editor:$post_format",'maximal'); 478 479 $post_format_field = sprintf('%s (%s)', $post_format, $post_editor); 480 $post_format_field .= form::hidden('post_format',"$post_editor:$post_format"); 461 481 } else { 462 482 $post_format_field = sprintf(__('Choose an active editor in %s.'), 463 483 '<a href="preferences.php#user-options">'.__('your preferences').'</a>' 464 484 ); 485 $post_format_field .= form::hidden('post_format','xhtml'); 465 486 } 466 487 -
plugins/dcLegacyEditor/js/_post_editor.js
r2614 r2705 1 1 $(function() { 2 2 if ($('#edit-entry').length==0) {return;} 3 4 // remove editor prefix 5 var getPostFormat = function getPostFormat(post_format) { 6 return post_format.replace(/[^:]*:/,''); 7 }; 8 var getPostEditor = function getPostEditor(post_format) { 9 return post_format.replace(/:.*/,''); 10 }; 3 11 4 12 // Get document format and prepare toolbars … … 6 14 var last_post_format = $(formatField).val(); 7 15 $(formatField).change(function() { 16 if (getPostEditor(this.value)!='dcLegacyEditor') { return;} 17 18 var post_format = getPostFormat(this.value); 19 8 20 // Confirm post format change 9 if (window.confirm(dotclear.msg.confirm_change_post_format_noconvert)){10 excerptTb.switchMode( this.value);11 contentTb.switchMode( this.value);21 if (window.confirm(dotclear.msg.confirm_change_post_format_noconvert)) { 22 excerptTb.switchMode(post_format); 23 contentTb.switchMode(post_format); 12 24 last_post_format = $(this).val(); 13 } else{25 } else { 14 26 // Restore last format if change cancelled 15 27 $(this).val(last_post_format); … … 17 29 18 30 $('.format_control > *').addClass('hide'); 19 $('.format_control:not(.control_no_'+ $(this).val()+') > *').removeClass('hide');31 $('.format_control:not(.control_no_'+post_format+') > *').removeClass('hide'); 20 32 }); 21 33 … … 25 37 26 38 $('.format_control > *').addClass('hide'); 27 $('.format_control:not(.control_no_'+ last_post_format+') > *').removeClass('hide');39 $('.format_control:not(.control_no_'+getPostFormat(last_post_format)+') > *').removeClass('hide'); 28 40 29 41 if ($('#comment_content').length>0) { … … 49 61 excerpt: excerpt_content, 50 62 content: post_content, 51 format: $('#post_format').get(0).value,63 format: getPostFormat($('#post_format').get(0).value), 52 64 lang: $('#post_lang').get(0).value 53 65 }; … … 99 111 100 112 // Load toolbars 101 contentTb.switchMode( formatField.value);102 excerptTb.switchMode( formatField.value);113 contentTb.switchMode(getPostFormat(formatField.value)); 114 excerptTb.switchMode(getPostFormat(formatField.value)); 103 115 104 116 // Check unsaved changes before XHTML conversion
Note: See TracChangeset
for help on using the changeset viewer.