Index: admin/post.php
===================================================================
--- admin/post.php	(revision 2708)
+++ admin/post.php	(revision 2711)
@@ -19,5 +19,5 @@
 $post_dt = '';
 $post_format = $core->auth->getOption('post_format');
-$editor = $core->auth->getOption('editor');
+$post_editor = $core->auth->getOption('editor');
 $post_password = '';
 $post_url = '';
@@ -61,5 +61,10 @@
 
 # Formaters combo
-$formaters_combo = dcAdminCombos::getFormatersCombo($editor);
+$formaters_combo = dcAdminCombos::getFormatersCombo();
+foreach ($formaters_combo as $editor => $formats) {
+	foreach ($formats as $format) {
+		$formaters_combo[$editor][$format] = "$editor:$format";
+	}
+}
 
 # Languages combo
@@ -75,6 +80,6 @@
 
 if (count($formaters_combo)==0 || !$core->auth->getOption('editor') || $core->auth->getOption('editor')=='') {
-	dcPage::addNotice("message",
-					  sprintf(__('Choose an active editor in %s.'),
+	dcPage::addNotice("message", 
+					  sprintf(__('Choose an active editor in %s.'), 
 								  '<a href="preferences.php#user-options">'.__('your preferences').'</a>'
 								  )
@@ -83,6 +88,5 @@
 
 # Get entry informations
-if (!empty($_REQUEST['id']))
-{
+if (!empty($_REQUEST['id'])) {
 	$page_title = __('Edit entry');
 
@@ -91,15 +95,17 @@
 	$post = $core->blog->getPosts($params);
 
-	if ($post->isEmpty())
-	{
+	if ($post->isEmpty()) {
 		$core->error->add(__('This entry does not exist.'));
 		$can_view_page = false;
-	}
-	else
-	{
+	} else {
 		$post_id = $post->post_id;
 		$cat_id = $post->cat_id;
 		$post_dt = date('Y-m-d H:i',strtotime($post->post_dt));
 		$post_format = $post->post_format;
+        # try to retrieve editor from post meta
+        $meta_editor = $core->meta->getMetaStr($post->post_meta,'editor');
+        if (!empty($meta_editor)) {
+            $post_editor = $meta_editor;
+        }
 		$post_password = $post->post_password;
 		$post_url = $post->post_url;
@@ -193,7 +199,13 @@
 
 # Format excerpt and content
-elseif (!empty($_POST) && $can_edit_post)
-{
-	$post_format = $_POST['post_format'];
+elseif (!empty($_POST) && $can_edit_post) {
+
+	if (strpos($_POST['post_format'], ':')!==false) {
+		list($post_editor, $post_format) = explode(':', $_POST['post_format']);
+	} else {
+		$post_format = $_POST['post_format'];
+		$post_editor = '';
+	}
+
 	$post_excerpt = $_POST['post_excerpt'];
 	$post_content = $_POST['post_content'];
@@ -283,4 +295,5 @@
 	$cur->post_dt = $post_dt ? date('Y-m-d H:i:00',strtotime($post_dt)) : '';
 	$cur->post_format = $post_format;
+	$cur->post_meta = serialize(array('editor' => $post_editor));
 	$cur->post_password = $post_password;
 	$cur->post_lang = $post_lang;
@@ -301,8 +314,10 @@
 
 	# Update post
-	if ($post_id)
-	{
-		try
-		{
+	if ($post_id) {
+		try {
+            $meta = $core->meta;
+            $meta->delPostMeta($post_id,'editor');
+            $meta->setPostMeta($post_id,'editor',$post_editor);
+
 			# --BEHAVIOR-- adminBeforePostUpdate
 			$core->callBehavior('adminBeforePostUpdate',$cur,$post_id);
@@ -317,20 +332,19 @@
 				array('id' => $post_id)
 			));
-		}
-		catch (Exception $e)
-		{
+		} catch (Exception $e) {
 			$core->error->add($e->getMessage());
 		}
-	}
-	else
-	{
+	} else {
 		$cur->user_id = $core->auth->userID();
 
-		try
-		{
+		try {
 			# --BEHAVIOR-- adminBeforePostCreate
 			$core->callBehavior('adminBeforePostCreate',$cur);
 
 			$return_id = $core->blog->addPost($cur);
+
+            $meta = $core->meta;
+            $meta->delPostMeta($return_id,'editor');
+            $meta->setPostMeta($return_id,'editor',$post_editor);
 
 			# --BEHAVIOR-- adminAfterPostCreate
@@ -342,7 +356,5 @@
 				array('id' => $return_id)
 			));
-		}
-		catch (Exception $e)
-		{
+		} catch (Exception $e) {
 			$core->error->add($e->getMessage());
 		}
@@ -390,4 +402,9 @@
 }
 
+$admin_post_behavior = '';
+if (($core->auth->getOption('editor')==$post_editor) 
+    && in_array($post_format, $core->getFormaters($core->auth->getOption('editor')))) {
+    $admin_post_behavior = $core->callBehavior('adminPostEditor');
+}
 
 dcPage::open($page_title.' - '.__('Entries'),
@@ -395,6 +412,6 @@
 	dcPage::jsModal().
 	dcPage::jsMetaEditor().
+    $admin_post_behavior.
 	dcPage::jsLoad('js/_post.js').
-	$core->callBehavior('adminPostEditor').
 	dcPage::jsConfirmClose('entry-form','comment-form').
 	# --BEHAVIOR-- adminPostHeaders
@@ -464,12 +481,16 @@
 /* Post form if we can edit post
 -------------------------------------------------------- */
-if ($can_edit_post)
-{
+if ($can_edit_post) {
 	if (count($formaters_combo)>0 && ($core->auth->getOption('editor') && $core->auth->getOption('editor')!='')) {
-		$post_format_field = form::combo('post_format',$formaters_combo,$post_format,'maximal');
+		// temporay removed until we can switch easily editor
+        // $post_format_field = form::combo('post_format',$formaters_combo,"$post_editor:$post_format",'maximal');
+
+        $post_format_field = sprintf('%s (%s)', $post_format, $post_editor);
+ 		$post_format_field .= form::hidden('post_format',"$post_editor:$post_format");
 	} else {
-		$post_format_field = sprintf(__('Choose an active editor in %s.'),
+		$post_format_field = sprintf(__('Choose an active editor in %s.'), 
 		'<a href="preferences.php#user-options">'.__('your preferences').'</a>'
 		);
+		$post_format_field .= form::hidden('post_format','xhtml');
 	}
 
