Page Top

概要 anchor.png

以前より、minidiaryモジュール をコメント統合で使いたいとは思っていましたが、D3コメントクラスを書く時間がようやく取れたので、minidiary-ver0.14をベースに手を入れてみました。

  1.  D3コメントクラスは、公開専用です。 一応、こんな風に表示されます。
    yd_d3com_class.gif
     但し、現状では閲覧権限に連動していません。。 :-(  ToDoとして、こちら(XUGJ)の記事にあるような、権限チェック~リダイレクトが必要ですが、ワタクシでは力不足なので、モジュール作者様か、どなたかのフォローを待ちます。 :hammer:

  2.  コメント統合先のd3forumディレクトリ名・フォーラムid値は、d3blogのコメント統合を参考に、minidiaryの管理画面でmodule_configに保存する方式としました。 そして、コメント統合のクラスはd3forum-0.83a以降で実装された新方式(「d3comment」で呼ぶほう)を採用しています。 また、D3commentクラス内でforum_idまで認識するため、テンプレート内に記述する必要がありません。
     こうすることで、複数サイトを共有化している場合でも、携帯用のテンプレートを共通化できますし、テンプレート配布の際にも神経を使わずに済みます。

  3.  コメント一覧ブロックは、xugj_blockで実装しています。(参考記事:thx さやさんのコメント13)
     が、残念なことに、「表示中の執筆者へのコメントを絞り込んで表示」がまだできていません。 これもToDoなのですが、XUGJで聞いてみないとどうやって実装すればよいのやら。。 :roll:


Page Top

手順と方法 anchor.png

テンプレートだけでなく、ソースの変更も必要ですので、細かく記しておきます。

なお、個別のアップロードも編集も面倒、という人のために、minidiary-0.14aとしてminidiary-0.14との差分ファイルと、d3commentのAPI、xugj_blockも同梱して固めたファイルを、ここに置いておきます。 解凍後、夫々のフォルダにアップロードして使えます。

fileminidiary014a2_diff.zip
(08/08/30訂正版:
yd_rightarea.html修正、差分パックに変更)
Page Top

xugj_blockの準備 anchor.png

 xugj_blockを使います。 入手はこちら(PEEK XOOPS)、 → 「xoops_root_path/class/smarty/plugins/」内にファイル名「function.xugj_block.php」で保存します。
 解説はこちら(XFIELD TWCHNOTE)を参照いただければわかります。

Page Top

D3commentクラス anchor.png

 D3commentクラスは、下記ファイルをダウンロード後、「minidiary/class」内にアップロードして使用します。

 当然ながら、d3forumの方にコメント統合用に掲示板を追加し、(必要があれば)過去のxoopsコメントをインポート後、「コメント統合時の参照方法」に

minidiary::minidiaryD3commentContent::

と記載します。
 なお、d3forumは0.83a以降のバージョンが必須で、D3commentの最新のAPIクラス群を忘れずにアップして下さい。

Page Top

minidiaryソースの変更 anchor.png

 4つのソースファイルに手を入れます。 こんな方法で良いのか自信はありませんが、間違いではないと思うのでご勘弁。 :-D

Page Top
xoops_version.php anchor.png

 「xoops_version.php」を編集し、管理画面にmodule_config項目を追加します。
 下記の103~119行目を追記します。

 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
$modversion['config'][] = array(
    'name'            => 'xsns_dirname' ,
    'title'            => '_MI_XSNS_DIRNAME' ,
    'description'    => '_MI_XSNS_DIRNAMEDESC' ,
    'formtype'        => 'textbox',
    'valuetype'        => 'text',
    'default'        => ''
);
 
$modversion['config'][] = array(
    'name'            => 'com_agent' ,
    'title'            => '_MI_COM_AGENT' ,
    'description'        => '_MI_COM_AGENTDSC' ,
    'formtype'        => 'textbox',
    'valuetype'        => 'text',
    'default'        => ''
);
 
$modversion['config'][]= array(
    'name'             => 'com_agent_forumid',
    'title'         => '_MI_COM_AGENTID',
    'description'        => '_MI_COM_AGENTIDDSC',
    'formtype'        => 'textbox',
    'valuetype'        => 'int',
    'default'        => '0'
);
 
$modversion['config'][] = array(
    'name'            => 'use_simplecomment' ,
Page Top
languages/japanese/modinfo.php anchor.png

 「modinfo.php」を編集し、上の作業で追加した管理画面の項目に日本語テキストを追加します。
 以下の49~53行目を追記します。

46
47
48
49
50
51
52
53
54
55
define("_MI_XSNS_DIRNAME","xsnsのディレクトリ名");
define("_MI_XSNS_DIRNAMEDESC","xsnsのディレクトリ名を変更している場合は、その名称を入力してください。<br/>空白にした場合はデフォルトのディレクトリ名になります。");
 
define("_MI_COM_AGENT","コメントシステムの設定");
define("_MI_COM_AGENTDSC","d3forumのコメント統合機能を使用する場合は<br/>フォーラムのhtml側ディレクトリ名を指定します。<br/>xoopsコメントを使用する場合やコメント機能を無効にする場合は空欄です。");
 
define("_MI_COM_AGENTID","コメントのforum_id");
define("_MI_COM_AGENTIDDSC","コメント統合を選択した場合、forum_idを必ず指定してください。");
 
define("_MI_USE_SIMPLECOMMENT","コメントの表示モード");
Page Top
header.php anchor.png

 「header.php」に、下記のように6~15行目を追記します。
 module_config設定項目を、smarty変数でテンプレートに渡すために必要です。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
<?php
// 定義ファイルのインクルード
include '../../mainfile.php';
include XOOPS_ROOT_PATH.'/modules/minidiary/functions.php';
 
        // モジュールID  // added by naao
        $module_handler =& xoops_gethandler('module');
        $this_module =& $module_handler->getByDirname('minidiary');
        $mid = $this_module->getVar('mid');
 
        // モジュールconfig  // added by naao
        $config_handler =& xoops_gethandler("config");
        $yd_config = $config_handler->getConfigsByCat(0, $mid);
        $xoopsTpl->assign("yd_moduleConfig", $yd_config);
 
?>
Page Top
blocks/b_diarylist.php anchor.png

 「b_diarylist.php」に、下記のように171~174行目を追記します。
 ブロック表示のd3コメント統合のために必要です。

166
167
168
169
170
171
172
173
174
175
176
177
178
179
        $block[$j]['other']=1;
        $j++;
        $i++;
    }
    
    // モジュールconfig  // added by naao
    $config_handler =& xoops_gethandler("config");
    $yd_config = $config_handler->getConfigsByCat(0, $mid);
    $block[0]['yd_moduleConfig']=$yd_config;
    
    return $block;
}
 
?>
Page Top

テンプレートの編集 anchor.png

 続いて、テンプレートを5つ、Altsysなどで編集します。 

Page Top
b_diarylist.html anchor.png

 「b_diarylist.html」の、30~49行目 を編集します。

Everything is expanded.Everything is shortened.
29
30
31
32
33
34
35
36
37
38
39
40
 
 
 
 
 
 
 
 
 
 
 
 
    <tr><td colspan=2><{$block[num2].diary}>
    <{if $block[num2].com_num > 0}>
    <br />
    <a href="<{$xoops_url}>/modules/minidiary/detail.php?bid=<{$block[num2].bid}>#viewcomment">
    <img src="<{$xoops_url}>/modules/minidiary/images/comments.png" border=0 style="vertical-align:middle;" title="コメントあり" alt="コメントあり" /> <{$block[num2].com_num}></a>
        <{if $block[num2].newcom > 0}>
            <img src="<{$xoops_url}>/modules/minidiary/images/new.gif" border=0 style="vertical-align:middle;" title="new" alt="new" />
            [<{$block[num2].newcom_y}>年<{$block[num2].newcom_m}>月<{$block[num2].newcom_d}>日 <{$block[num2].newcom_h}>:<{$block[num2].newcom_i}>]
        <{/if}>
    &nbsp;&nbsp;
    <{/if}>
    </td></tr>

 ↓ 以下のように変更。

Everything is expanded.Everything is shortened.
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
    <tr><td colspan=2><{$block[num2].diary}>
   <{if $block.0.yd_moduleConfig.com_agent}>
    <br />
     <{d3comment mode="count" var="comcount" mydirname='minidiary' id=$block[num2].bid class="minidiaryD3commentContent"}>
     <{if $comcount}>
         <a href="<{$xoops_url}>/modules/minidiary/detail.php?bid=<{$block[num2].bid}>#comment" title="コメントあり">
         <img src="<{$xoops_url}>/modules/minidiary/images/comments.png" border=0 style="vertical-align:middle;" title="コメントあり" alt="コメントあり" /> (<{$comcount}>)</a>
     <{/if}>
   <{else}>
    <{if $block[num2].com_num > 0}>
    <br />
    <a href="<{$xoops_url}>/modules/minidiary/detail.php?bid=<{$block[num2].bid}>#viewcomment">
    <img src="<{$xoops_url}>/modules/minidiary/images/comments.png" border=0 style="vertical-align:middle;" title="コメントあり" alt="コメントあり" /> <{$block[num2].com_num}></a>
        <{if $block[num2].newcom > 0}>
            <img src="<{$xoops_url}>/modules/minidiary/images/new.gif" border=0 style="vertical-align:middle;" title="new" alt="new" />
            [<{$block[num2].newcom_y}>年<{$block[num2].newcom_m}>月<{$block[num2].newcom_d}>日 <{$block[num2].newcom_h}>:<{$block[num2].newcom_i}>]
        <{/if}>
    &nbsp;&nbsp;
    <{/if}>
   <{/if}>
    </td></tr>
Page Top
yd_detail.html anchor.png

 「yd_detail.html」の、82~124行目 を編集します。

Everything is expanded.Everything is shortened.
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
<{if $yd_use_simplecomment == 0}>
<{$commentsnav}>
<center><{$lang_notice}></center>
<{if $comment_mode == "flat"}>
  <{include file="db:system_comments_flat.html"}>
<{elseif $comment_mode == "thread"}>
  <{include file="db:system_comments_thread.html"}>
<{elseif $comment_mode == "nest"}>
  <{include file="db:system_comments_nest.html"}>
<{/if}>
 
<{else}>
 
<!-- start comment area -->
<{if $comments.0.id >0}>
<a name="viewcomment"></a>
<table class="outer"><tr><th>
コメント
</th></tr><tr><td>
<div style="margin: 1px; padding: 1px;">
<!-- start comments loop -->
<{include file="db:system_comments_flat.html"}>
<!-- end comments loop -->
</div>
</td></tr></table>
<br />
<{/if}>
<!-- start comment form -->
<table class="outer"><tr><th>
コメントを書く
</th></tr><tr><td>
<{if $xoops_isuser==1}>
<{$yr_comment_form}>
<{else}>
コメントを書くには<a href="<{$xoops_url}>/user.php">ログイン</a>が必要です。<br />
<{/if}>
</td></tr></table>
<!-- end comment form -->
<!-- end comment area -->
 
<{/if}>

 ↓ 以下のように変更。(08/08/28 84行目の未修正箇所を修正。)

Everything is expanded.Everything is shortened.
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
<!-- start comment area -->
<a name="viewcomment"></a>
<{if $yd_moduleConfig.com_agent}>
    <{d3comment mydirname='minidiary' id=$yd_data.bid subject=$yd_data.title class="minidiaryD3commentContent}>
<{else}>
  <{if $yd_use_simplecomment == 0}>
	<{$commentsnav}>
	<center><{$lang_notice}></center>
	<{if $comment_mode == "flat"}>
	  <{include file="db:system_comments_flat.html"}>
	<{elseif $comment_mode == "thread"}>
	  <{include file="db:system_comments_thread.html"}>
	<{elseif $comment_mode == "nest"}>
	  <{include file="db:system_comments_nest.html"}>
	<{/if}>
 
  <{else}>
	<{if $comments.0.id >0}>
	<table class="outer"><tr><th>
	コメント
	</th></tr><tr><td>
	<div style="margin: 1px; padding: 1px;">
	<!-- start comments loop -->
	<{include file="db:system_comments_flat.html"}>
	<!-- end comments loop -->
	</div>
	</td></tr></table>
	<br />
	<{/if}>
	<!-- start comment form -->
	<table class="outer"><tr><th>
	コメントを書く
	</th></tr><tr><td>
	<{if $xoops_isuser==1}>
	<{$yr_comment_form}>
	<{else}>
	コメントを書くには<a href="<{$xoops_url}>/user.php">ログイン</a>が必要です。<br />
	<{/if}>
	</td></tr></table>
	<!-- end comment form -->
	<!-- end comment area -->
  <{/if}>
Page Top
yd_diarylist.html anchor.png

 「yd_diarylist.html」の、56~66行目 を編集します。

Everything is expanded.Everything is shortened.
55
56
57
58
59
60
61
62
63
64
65
66
 
 
 
 
 
 
 
 
 
 
 
 
    <tr><td colspan=2><{$yd_data[num2].diary}>
    <{if $yd_data[num2].com_num > 0}>
    <br />
    <a href="<{$xoops_url}>/modules/minidiary/detail.php?bid=<{$yd_data[num2].bid}>#viewcomment">
    <img src="images/comments.png" border=0 style="vertical-align:middle;" title="コメントあり" alt="コメントあり" /> <{$yd_data[num2].com_num}></a>
        <{if $yd_data[num2].newcom > 0}>
            <img src="images/new.gif" border=0 style="vertical-align:middle;" title="new" alt="new" />
            [<{$yd_data[num2].newcom_y}>年<{$yd_data[num2].newcom_m}>月<{$yd_data[num2].newcom_d}>日 <{$yd_data[num2].newcom_h}>:<{$yd_data[num2].newcom_i}>]
        <{/if}>
    &nbsp;&nbsp;
    <{/if}>
    </td></tr>

 ↓ 以下のように変更。

Everything is expanded.Everything is shortened.
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
    <tr><td colspan=2><{$yd_data[num2].diary}>
 
  <{if $yd_moduleConfig.com_agent}>
    <{d3comment mode="count" var="comcount" mydirname='minidiary' id=$yd_data[num2].bid class="minidiaryD3commentContent"}>
     <{if $comcount}>
         <a href="<{$xoops_url}>/modules/minidiary/detail.php?bid=<{$yd_data[num2].bid}>#comment" title="コメントあり">
         <img src="images/comments.png" border=0 style="vertical-align:middle;" title="コメントあり" alt="コメントあり" /> (<{$comcount}>)</a>
     <{/if}>
  <{else}>
    <{if $yd_data[num2].com_num > 0}>
    <br />
    <a href="<{$xoops_url}>/modules/minidiary/detail.php?bid=<{$yd_data[num2].bid}>#viewcomment">
    <img src="images/comments.png" border=0 style="vertical-align:middle;" title="コメントあり" alt="コメントあり" /> <{$yd_data[num2].com_num}></a>
        <{if $yd_data[num2].newcom > 0}>
            <img src="images/new.gif" border=0 style="vertical-align:middle;" title="new" alt="new" />
            [<{$yd_data[num2].newcom_y}>年<{$yd_data[num2].newcom_m}>月<{$yd_data[num2].newcom_d}>日 <{$yd_data[num2].newcom_h}>:<{$yd_data[num2].newcom_i}>]
        <{/if}>
    &nbsp;&nbsp;
    <{/if}>
 
  <{/if}>
    </td></tr>
Page Top
yd_index.html anchor.png

 「yd_index.html」の、60~64行目 を編集します。

Everything is expanded.Everything is shortened.
59
60
61
62
63
64
65
 
 
 
 
 
 
 
<td style="border:1px gray solid;border-bottom:2px gray solid;text-align:right;">
<a href="<{$xoops_url}>/modules/minidiary/detail.php?bid=<{$yd_data[num].bid}>#viewcomment">
コメント(<{$yd_data[num].comment_num}>)
</a> | 
<a href="<{$xoops_url}>/modules/minidiary/detail.php?bid=<{$yd_data[num].bid}>">
続きを読む</a> 
<{if $yd_editperm==1}>

 ↓ 以下のように変更。

Everything is expanded.Everything is shortened.
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
<td style="border:1px gray solid;border-bottom:2px gray solid;text-align:right;">
 
<{if $yd_moduleConfig.com_agent}>
 <{d3comment mode="count" var="comcount" mydirname='minidiary' id=$yd_data[num].bid class="minidiaryD3commentContent"}>
     <{if $comcount}>
         <a href="<{$xoops_url}>/modules/minidiary/detail.php?bid=<{$yd_data[num].bid}>#comment" title="コメント">コメント (<{$comcount}>)</a>
     <{else}>コメント (0)
     <{/if}>
<{else}>
 <a href="<{$xoops_url}>/modules/minidiary/detail.php?bid=<{$yd_data[num].bid}>#viewcomment">
コメント <{$yd_data[num].comment_num}>
 </a> 
<{/if}>
 | 
<a href="<{$xoops_url}>/modules/minidiary/detail.php?bid=<{$yd_data[num].bid}>">
続きを読む</a> 
<{if $yd_editperm==1}>
Page Top
yd_rightarea.html anchor.png

 「yd_rightarea.html」の、50~57行目 を編集します。

Everything is expanded.Everything is shortened.
49
50
51
52
53
54
55
56
57
58
59
 
 
 
 
 
 
 
 
 
 
 
<th>最近のコメント</th></tr>
<{section name=num loop=$yd_comment max=3}>
<tr>
<td><img src="<{$xoops_url}>/modules/minidiary/images/enum1.png" border=0 /><a href="<{$xoops_url}>/modules/minidiary/detail.php?bid=<{$yd_comment[num].bid}>#viewcomment"><{$yd_comment[num].title}></a> <{$yd_comment[num].uname}>[<{$yd_comment[num].month}>/<{$yd_comment[num].day}> <{$yd_comment[num].time}>]</td>
</tr>
<{/section}>
<tr>
<td style="border-top:1px gray solid;text-align:right;">
<img src="<{$xoops_url}>/modules/minidiary/images/arrow1.png" border=0 style="vertical-align:middle;" /> <a href="<{$xoops_url}>/modules/minidiary/viewcomment.php?req_uid=<{$yd_uid}>">コメント一覧へ</a></td>
</tr>
</table>

 ↓ 以下のように変更。 (08/08.30 XUGJ_blockの指定が変数になっていない分を修正)

Everything is expanded.Everything is shortened.
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
<th>最近のコメント</th></tr>
<tr><td>
 
<{if $yd_moduleConfig.com_agent}>
    <{xugj_block file=modules/`$yd_moduleConfig.com_agent`/blocks/blocks.php func="b_d3forum_list_posts_show" opt="`$yd_moduleConfig.com_agent`,10,time,,,`$yd_moduleConfig.com_agent_forumid`" item="block"}>
    <{section name=num max=3}>
    <ol style="padding:3px;margin:0;">
    <{foreach item=post from=$block.posts}>
      <li style="margin:1px;"><a href="<{$block.mod_url}>/index.php?post_id=<{$post.id}>"><{$post.subject}></a> <{$post.uname}> <{$post.post_time_formatted}></li>
    <{/foreach}>
    </ol>
    <{/section}>
    <img src="<{$xoops_url}>/modules/minidiary/images/arrow1.png" border=0 style="vertical-align:middle;" /> <a href="<{$block.mod_url}>/index.php?forum_id=17">コメント一覧へ</a></td>
<{else}>
    <{section name=num loop=$yd_comment max=3}>
    <tr>
    <td><img src="<{$xoops_url}>/modules/minidiary/images/enum1.png" border=0 /><a href="<{$xoops_url}>/modules/minidiary/detail.php?bid=<{$yd_comment[num].bid}>#comment"><{$yd_comment[num].title}></a> <{$yd_comment[num].uname}>[<{$yd_comment[num].month}>/<{$yd_comment[num].day}> <{$yd_comment[num].time}>]</td>
    </tr>
    <{/section}>
    <tr>
    <td style="border-top:1px gray solid;text-align:right;">
    <img src="<{$xoops_url}>/modules/minidiary/images/arrow1.png" border=0 style="vertical-align:middle;" /> <a href="<{$xoops_url}>/modules/minidiary/viewcomment.php?req_uid=<{$yd_uid}>">コメント一覧へ</a></td>
<{/if}>
</tr>
</table>
Page Top

モバイル用テンプレート anchor.png

 モバイルテンプハウスで、作成・公開済。 

Page Top

インストールと設定 anchor.png

 xoops管理画面の「モジュールの管理」で、「minidiary」をモジュールアップデートします。 これで、「minidiary」の管理画面に、2つの項目が追加されます。

yd_confiig.gif

ここで、

  1. コメントシステムの設定 : d3forumのコメント統合機能を使用する場合はd3forumのhtml側ディレクトリ名を指定します。xoopsコメントを使用する場合やコメント機能を無効にする場合は空欄です。
  2. コメントのforum_id : コメント統合を選択した場合、統合先のforum_id値を必ず指定してください。

これらを設定すれば完了です。(この編集を行うまでは、xoopsコメントシステムが有効です。)

Page Top

その他 anchor.png

Page Top

ライセンス anchor.png

  • minidiaryソース、d3forumソース、xugj_blockソース:GPL
  • アイコン画像について
    minidiaryモジュールでは以下のサイトのアイコンや画像ファイルを利用しています。

famfamfam.com: Silk Icons
http://www.famfamfam.com/lab/icons/silk/


トップ   凍結 差分 バックアップ 複製 名前変更 リロード印刷に適した表示   ページ新規作成 全ページ一覧 単語検索 最新ページの一覧   ヘルプ   最新ページのRSS 1.0 最新ページのRSS 2.0 最新ページのRSS Atom Powered by xpWiki
Counter: 1993, today: 1, yesterday: 0
初版日時: 2008-08-25 (月) 10:09:06
最終更新: 2019-08-17 (土) 07:11:56 (JST) (1707d) by なーお