Index: trunk/wp-content/plugins/xpressme/include/d3forum_comment_disp.php
===================================================================
--- trunk/wp-content/plugins/xpressme/include/d3forum_comment_disp.php	(revision 106)
+++ trunk/wp-content/plugins/xpressme/include/d3forum_comment_disp.php	(revision 108)
@@ -13,6 +13,22 @@
 		$forum_id = $XPressME->d3forum_forum_id;
 		$external_link_format = $XPressME->d3forum_external_link_format;
-		$db =& Database::getInstance() ;
+		if ($XPressME->is_d3forum_desc){
+			$order = 'desc';
+		} else {
+			$order = 'asc';
+		}
+		if ($XPressME->is_d3forum_desc){
+			$order = 'desc';
+		} else {
+			$order = 'asc';
+		}
 
+		if ($XPressME->is_d3forum_flat){
+			$view = 'listposts_flat';
+		} else {
+			$view = 'listtopics';
+		}
+		$posts_num = $XPressME->d3forum_views_num;
+		
 	// force UPDATE forums.forum_external_link_format "(dirname)::(classname)::(trustdirname)"
 		$xoops_db->query( "UPDATE ".get_xoops_prefix() . $dir_name."_forums SET forum_external_link_format='".$external_link_format."' WHERE forum_id= $forum_id" ) ;
@@ -33,5 +49,5 @@
         } 	
 //		$params = array("dirname" => $dir_name, "forum_id" => $forum_id, "itemname" => "p", "id" => $post_id , "subject" => $post_title);
-		$params = array("forum_id" => $forum_id,  "id" => $post_id , "subject" => $post_title);
+		$params = array("forum_id" => $forum_id,  "id" => $post_id , "subject" => $post_title , "order" => $order , "view" => $view , "posts_num" => $posts_num);
 		if(file_exists($xoops_trust_path .'/modules/d3forum/')) {
 			if(file_exists($xoops_root_path .'/modules/' . $dir_name . '/')) {
Index: trunk/wp-content/plugins/xpressme/include/d3forum_comment_synchro.php
===================================================================
--- trunk/wp-content/plugins/xpressme/include/d3forum_comment_synchro.php	(revision 106)
+++ trunk/wp-content/plugins/xpressme/include/d3forum_comment_synchro.php	(revision 108)
@@ -179,5 +179,5 @@
 
 // All comments of WordPress are exported to the D3Forum comment. 
-function wp_to_d3forum($forum_id = 1, $d3f_prefix = 'd3forum' ,$wp_prefix = 'wp'){
+function wp_to_d3forum($forum_id = 1, $d3f_prefix = 'd3forum'){
 	global $XPressME,$xoops_db;
 
@@ -185,5 +185,5 @@
 	
 	$d3forum_prefix = get_xoops_prefix() . $d3f_prefix . '_';
-	$xpress_prefix = get_xoops_prefix() . $wp_prefix . '_';
+	$xpress_prefix = get_wp_prefix();
 	
 	$wp_comments = $xpress_prefix . 'comments';
@@ -239,5 +239,5 @@
 
 	$comment_count = 0;
-	$comments = $xoops_db->get_results($post_sql);
+	$comments = $xoops_db->get_results($sql);
 	foreach($comments as $comment){
 		$comment_ID = $comment->comment_ID;
@@ -253,10 +253,10 @@
 
 // All comments of D3Forum are import to the WordPress comment. 
-function d3forum_to_wp($forum_id = 1, $d3f_prefix = 'd3forum' ,$wp_prefix = 'wordpress'){
+function d3forum_to_wp($forum_id = 1, $d3f_prefix = 'd3forum'){
 	global $XPressME,$xoops_db;
 	if (!is_d3forum_setting()) die('The setting of the D3Forum comment integration is wrong. ');
 	
 	$d3forum_prefix = get_xoops_prefix() . $d3f_prefix . '_';
-	$xpress_prefix = get_xoops_prefix() . $wp_prefix . '_';
+	$xpress_prefix = get_wp_prefix() ;
 	
 	$wp_comments = $xpress_prefix . 'comments';
@@ -297,5 +297,4 @@
 
 	$d3f_res = $xoops_db->get_results($d3f_sql);
-	if (empty($d3f_res )) die( '...Err. OPEN D3Forum Data (' .  $d3f_sql . ')');
 	$import_count = 0;
 	foreach($d3f_res as $d3f_row){
@@ -429,5 +428,5 @@
 				$wp_sql .=    "($comment_ID, $post_id)";		
 				$xoops_db->query($wp_sql);				
-				if ($comment_approved ==0)	do_CommentWaiting($commentID, $post_id);
+				if ($comment_approved ==0)	do_CommentWaiting($comment_ID, $post_id);
 				break;
 			case 'edit':
Index: trunk/wp-content/plugins/xpressme/language/xpressme-ja.po
===================================================================
--- trunk/wp-content/plugins/xpressme/language/xpressme-ja.po	(revision 106)
+++ trunk/wp-content/plugins/xpressme/language/xpressme-ja.po	(revision 108)
@@ -3,5 +3,5 @@
 "Project-Id-Version: XPressME Plugin\n"
 "POT-Creation-Date: \n"
-"PO-Revision-Date: 2009-03-07 16:29+0900\n"
+"PO-Revision-Date: 2009-03-15 18:39+0900\n"
 "Last-Translator: toemon <toychee@toemon.com>\n"
 "Language-Team: \n"
@@ -15,143 +15,187 @@
 "X-Poedit-SearchPath-0: .\n"
 
-#: xpressme_class.php:30
+#: xpressme_class.php:33
 msgid "XPressME Settings"
 msgstr "XPressME設定"
 
-#: xpressme_class.php:47
-#: xpressme_class.php:141
+#: xpressme_class.php:50
+#: xpressme_class.php:152
 msgid "to Old Post"
 msgstr "前の投稿へ"
 
-#: xpressme_class.php:48
-#: xpressme_class.php:143
+#: xpressme_class.php:51
+#: xpressme_class.php:154
 msgid "to Newer Post"
 msgstr "次の投稿へ"
 
-#: xpressme_class.php:170
-#: xpressme_class.php:337
-#: xpressme_class.php:342
-#: xpressme_class.php:363
-#: xpressme_class.php:368
+#: xpressme_class.php:195
+#: xpressme_class.php:390
+#: xpressme_class.php:395
+#: xpressme_class.php:416
+#: xpressme_class.php:421
 msgid "YES"
 msgstr "はい"
 
-#: xpressme_class.php:171
-#: xpressme_class.php:338
-#: xpressme_class.php:343
-#: xpressme_class.php:364
-#: xpressme_class.php:369
+#: xpressme_class.php:196
+#: xpressme_class.php:391
+#: xpressme_class.php:396
+#: xpressme_class.php:417
+#: xpressme_class.php:422
 msgid "NO"
 msgstr "いいえ"
 
-#: xpressme_class.php:211
+#: xpressme_class.php:236
 msgid "Role Setting at Login"
 msgstr "ログイン時の権限設定"
 
-#: xpressme_class.php:214
+#: xpressme_class.php:239
 msgid "XOOPS Groupe"
 msgstr "XOOPSグループ名"
 
-#: xpressme_class.php:214
+#: xpressme_class.php:239
 msgid "WordPress Role"
 msgstr "WordPressでの権限"
 
-#: xpressme_class.php:214
+#: xpressme_class.php:239
 msgid "Role is set at each login"
 msgstr "ログイン時、常に権限を更新する"
 
-#: xpressme_class.php:235
-#: xpressme_class.php:239
-#: xpressme_class.php:242
+#: xpressme_class.php:260
+#: xpressme_class.php:264
+#: xpressme_class.php:267
 msgid "Default Role of WordPress"
 msgstr "WordPressのデフォルト権限"
 
-#: xpressme_class.php:236
-#: xpressme_class.php:240
-#: xpressme_class.php:243
+#: xpressme_class.php:261
+#: xpressme_class.php:265
+#: xpressme_class.php:268
 msgid "Group User Doesn't Register"
 msgstr "ユーザ登録しない"
 
-#: xpressme_class.php:266
+#: xpressme_class.php:296
 msgid "Do Not Comment Integration."
 msgstr "コメント統合しません。"
 
-#: xpressme_class.php:302
+#: xpressme_class.php:330
 msgid "Comment integration with D3Forum"
 msgstr "D3Forumとのコメント統合"
 
-#: xpressme_class.php:304
+#: xpressme_class.php:332
 msgid "Select the forum of D3Forum that does the comment integration from the following lists."
 msgstr "以下のリストからコメント統合をするD3Forumのフォーラムを選択してください。"
 
-#: xpressme_class.php:327
+#: xpressme_class.php:335
+msgid "Select the Type of display of D3Forum comment."
+msgstr "D3Forumの表示タイプを選択"
+
+#: xpressme_class.php:337
+#: xpressme_class.php:340
+msgid "Flat"
+msgstr "フラット"
+
+#: xpressme_class.php:338
+#: xpressme_class.php:341
+msgid "Threaded"
+msgstr "スレッド"
+
+#: xpressme_class.php:344
+msgid "Select the order of display of D3Forum comment."
+msgstr "D3Forumコメントの表示順を選択"
+
+#: xpressme_class.php:346
+#: xpressme_class.php:349
+msgid "DESC"
+msgstr "降順"
+
+#: xpressme_class.php:347
+#: xpressme_class.php:350
+msgid "ASC"
+msgstr "昇順"
+
+#: xpressme_class.php:353
+msgid "Number of displays of D3Forum comments."
+msgstr "D3Forumのコメント表示数"
+
+#: xpressme_class.php:357
+msgid "The import and the export between Wordpress Comments and the D3Forum Posts can be done. "
+msgstr "WordPressコメントとD3Forumポスト間の一括転送（エクスポート・インポート）"
+
+#: xpressme_class.php:358
+msgid "Export to D3Forum"
+msgstr "D3Forumへ一括エクスポート"
+
+#: xpressme_class.php:359
+msgid "Import from D3Forum"
+msgstr "D3Forumから一括インポート"
+
+#: xpressme_class.php:380
 msgid "XPressME Configuration Page"
 msgstr "XPressMEの設定ページ"
 
-#: xpressme_class.php:331
+#: xpressme_class.php:384
 msgid "Media Upload Base Path"
 msgstr "メディアアップロードのベースパス設定"
 
-#: xpressme_class.php:332
+#: xpressme_class.php:385
 msgid "Use XOOPS UPLOAD PATH"
 msgstr "XOOPSのアップロードパスを使用する。"
 
-#: xpressme_class.php:333
+#: xpressme_class.php:386
 msgid "USE WordPress BASE_PATH"
 msgstr "WordPressのベースパスを使用する。"
 
-#: xpressme_class.php:336
+#: xpressme_class.php:389
 msgid "Thema Sidebar Display"
 msgstr "テーマ表示時にサイドバー表示する。"
 
-#: xpressme_class.php:341
+#: xpressme_class.php:394
 msgid "The change tracking of the post is preserved"
 msgstr "投稿の変更履歴を有効にする。"
 
-#: xpressme_class.php:346
+#: xpressme_class.php:399
 msgid "Display Navi Title of Old Post Link"
 msgstr "古い記事へのナビタイトルを設定"
 
-#: xpressme_class.php:349
+#: xpressme_class.php:402
 msgid "Display Navi Title of Newer Post Link"
 msgstr "新しい記事へのナビタイトルを設定"
 
-#: xpressme_class.php:352
+#: xpressme_class.php:405
 msgid "Select Display name of PostNavi Link"
 msgstr "投稿記事リンクナビのタイトル設定"
 
-#: xpressme_class.php:353
+#: xpressme_class.php:406
 msgid "Title of post"
 msgstr "投稿記事のタイトルを表示"
 
-#: xpressme_class.php:354
+#: xpressme_class.php:407
 msgid "Title of Navi"
 msgstr "ナビタイトルを表示"
 
-#: xpressme_class.php:357
+#: xpressme_class.php:410
 msgid "Adjustment of Navi link display position"
 msgstr "投稿記事ナビリンクの表示位置設定"
 
-#: xpressme_class.php:358
+#: xpressme_class.php:411
 msgid "'Old Post Link' is displayed in the left, and 'Newer Post Link' is displayed in the right"
 msgstr "古い記事へのリンクを左に、より新しい記事へのリンクを右に表示"
 
-#: xpressme_class.php:359
+#: xpressme_class.php:412
 msgid "'Newer Post Link' is displayed in the left, and 'Old Post Link' is displayed in the right"
 msgstr "より新しい記事へのリンクを左に、古い記事へのリンクを右に表示"
 
-#: xpressme_class.php:362
+#: xpressme_class.php:415
 msgid "Is the posts author views counted?"
 msgstr "投稿者の閲覧をカウントしますか？"
 
-#: xpressme_class.php:367
+#: xpressme_class.php:420
 msgid "Is SQL debugging window displayed?"
 msgstr "SQLデバッグウィンドを表示しますか？"
 
-#: xpressme_class.php:379
+#: xpressme_class.php:432
 msgid "Update Config"
 msgstr "更新"
 
-#: xpressme_class.php:380
+#: xpressme_class.php:433
 msgid "Preset Config"
 msgstr "プリセット"
Index: trunk/wp-content/plugins/xpressme/xpressme_class.php
===================================================================
--- trunk/wp-content/plugins/xpressme/xpressme_class.php	(revision 106)
+++ trunk/wp-content/plugins/xpressme/xpressme_class.php	(revision 108)
@@ -56,4 +56,7 @@
 		$this->d3forum_forum_id = '';
 		$this->d3forum_external_link_format = get_xpress_dir_name() . '::xpressD3commentContent';
+		$this->is_d3forum_flat = true;
+		$this->is_d3forum_desc = true;
+		$this->d3forum_views_num = 10;
 	}
 	
@@ -90,5 +93,8 @@
 			'd3forum_module_dir' => $this->d3forum_module_dir,
 			'd3forum_forum_id' => $this->d3forum_forum_id,
-			'd3forum_external_link_format' => $this->d3forum_external_link_format
+			'd3forum_external_link_format' => $this->d3forum_external_link_format,
+			'is_d3forum_flat' => $this->is_d3forum_flat,
+			'is_d3forum_desc' => $this->is_d3forum_desc,
+			'd3forum_views_num' =>$this->d3forum_views_num
 		);
 		if ($mode == 'add_new') {
@@ -169,4 +175,7 @@
 			$this->d3forum_external_link_format = get_xpress_dir_name() . '::xpressD3commentContent';
 		}
+		$this->is_d3forum_flat = stripslashes(trim($_POST['ch_d3forum_type']));
+		$this->is_d3forum_desc = stripslashes(trim($_POST['ch_d3forum_order']));
+		$this->d3forum_views_num = stripslashes(trim($_POST['ch_d3forum_view_num']));
 		
 		global $xoops_db;
@@ -282,5 +291,5 @@
 	}
 	
-	function d3forum_option(){
+	function d3forum_option($do_message = ''){
 		global $xoops_db;
 		
@@ -306,5 +315,5 @@
 			// It is checked whether there is character string "$mytrustdirname ='d3forum'"in the file.
 			foreach ($array_files as $aeey_file){
-				if( preg_match( "/\s*($mytrustdirname)\s*(=)\s*([\"'])(d3forum)([\"'])/", $aeey_file ) ) {
+				if( preg_match( "/\s*(mytrustdirname)\s*(=)\s*([\"'])(d3forum)([\"'])/", $aeey_file ) ) {
 					$forums_tb = get_xoops_prefix() . $module->dirname . '_forums';
 					$cat_tb = get_xoops_prefix() . $module->dirname . '_categories';
@@ -323,5 +332,5 @@
 				}
 			}
-			$form .= '<br>';			
+			$forum_list .= '<br>';			
 		}
 		$forum_list .= '</select>' . "\n";
@@ -332,5 +341,35 @@
 		$form .=  __('Select the forum of D3Forum that does the comment integration from the following lists.', 'xpressme') ."<br />\n";
 		$form .=  $forum_list."\n";
-		$form .= '<br /><br /><br /><br /><br /><br /><br />';
+		$form .= '<br /><br />';
+		if ($this->is_use_d3forum)  $disible = ''; else $disible = 'disabled';
+		$form .=  __('Select the Type of display of D3Forum comment.', 'xpressme') . " \n&emsp";
+		if ($this->is_d3forum_flat){
+			$form .= "&ensp<label><input type='radio' name='ch_d3forum_type' value='1' checked='checked' />" . __('Flat','xpressme') ."</label>\n";
+			$form .= "&ensp<label><input type='radio' name='ch_d3forum_type' value='0' />". __('Threaded','xpressme') . "</label>\n";
+		}else{
+			$form .= "&ensp<label><input type='radio' name='ch_d3forum_type' value='1' />" . __('Flat','xpressme') . "</label>\n";
+			$form .= "&ensp<label><input type='radio' name='ch_d3forum_type' value='0' checked='checked' />". __('Threaded','xpressme') ."</label>\n";
+		}
+		$form .= '<br />';
+		$form .=  __('Select the order of display of D3Forum comment.', 'xpressme') . " \n&emsp";
+		if ($this->is_d3forum_desc){
+			$form .= "&ensp<label><input type='radio' name='ch_d3forum_order' value='1' checked='checked' />" . __('DESC','xpressme') ."</label>\n";
+			$form .= "&ensp<label><input type='radio' name='ch_d3forum_order' value='0' />". __('ASC','xpressme') . "</label>\n";
+		}else{
+			$form .= "&ensp<label><input type='radio' name='ch_d3forum_order' value='1' />" . __('DESC','xpressme') . "</label>\n";
+			$form .= "&ensp<label><input type='radio' name='ch_d3forum_order' value='0' checked='checked' />". __('ASC','xpressme') ."</label>\n";
+		}
+		$form .= '<br />';
+		$form .=  __('Number of displays of D3Forum comments.', 'xpressme') ." \n";
+		$form .= '&emsp<label> <input name="ch_d3forum_view_num" type="text" size="3" maxlength="3" value="'  . $this->d3forum_views_num . '" /></label>'."\n";
+
+		$form .= '<div class="submit">'."\n";		
+		$form .=  __('The import and the export between Wordpress Comments and the D3Forum Posts can be done. ', 'xpressme') ."<br />\n";
+		$form .= '<input type="submit" value= "' . __('Export to D3Forum', 'xpressme') . '" name="export_d3f" ' . $disible . ' >' ."\n";
+		$form .= '<input type="submit" value= "' . __('Import from D3Forum', 'xpressme') . '" name="inport_d3f" ' . $disible . ' >' ."<br />\n";
+		$form .= '</div>'."\n";
+		if (!empty($do_message)){
+			$form .= '<div>' . $do_message . '</div>';
+		}
 		$form .=  "</td>\n";
 		$form .=  "</tr><tr>\n";
@@ -340,5 +379,5 @@
 	function option_page()
 	{
-
+		$do_message ='';
 		if (!empty($_POST['submit_update'])) {
 			$this->ReadPostData();
@@ -347,6 +386,13 @@
 			$this->fck_setDefault();
 			$this->SettingValueWrite('update');
-		} 
-
+		} else if (isset($_POST['export_d3f'])) {
+			$do_message  = 'export(' . $this->d3forum_module_dir . '--ID=' . $this->d3forum_forum_id . ')................';
+			$do_message .= wp_to_d3forum($this->d3forum_forum_id, $this->d3forum_module_dir);
+			$do_message .= '....END';
+		} else if (isset($_POST['inport_d3f'])) {
+			$do_message  = 'Import(' . $this->d3forum_module_dir . '--ID=' . $this->d3forum_forum_id . ')................';
+			$do_message .= d3forum_to_wp($this->d3forum_forum_id, $this->d3forum_module_dir);
+			$do_message .= '....END';
+		} 		
 		
 		echo	'<div class="wrap">'."\n";
@@ -399,5 +445,5 @@
 		echo				$this->groupe_role_option();		
 		
-		echo				$this->d3forum_option();		
+		echo				$this->d3forum_option($do_message);		
 //		$this->is_use_xoops_upload_path_html();
 		echo			"</table>\n";
