- xwordsモジュールで、d3コメント統合
- 概要
- 手順と方法
- D3commentクラス
- Xwordsソースの変更
- xoops_version.php
- languages/japanese/modinfo.php
- header.php
- テンプレートの編集
- モバイル用テンプレート
- インストールと設定
- その他
xwordsモジュールで、d3コメント統合 [2]
以前より、Xwordsモジュール[4] をコメント統合で使ってはいましたが、携帯用テンプレートの共有化を行う際に、テンプレートにサイト毎に異なるd3forum_dirnameとforum_idを記述する部分で支障があり、何とかしたいと考え、Xwords-ver0.46をベースに手を入れてみました。
- D3コメントクラスは、公開専用です。 一応、こんな風に表示されます。
[5]
- コメント統合先のd3forumディレクトリ名・フォーラムid値は、
d3blogのpicalのコメント統合を参考に、Xwordsの管理画面でmodule_configに保存する方式としました。 そして、コメント統合のクラスはd3forum-0.83a以降で実装された新方式(「d3comment」で呼ぶほう)を採用しています。 また、D3commentクラス内でforum_idまで認識するため、テンプレート内に記述する必要がありません。
こうすることで、複数サイトを共有化している場合でも、携帯用のテンプレートを共通化できますし、テンプレート配布の際にも神経を使わずに済みます。
テンプレートだけでなく、ソースの変更も必要ですので、細かく記しておきます。
なお、個別のアップロードも編集も面倒、という人のために、Xwords-ver0.46との差分ファイルパックを、ここに置いておきます。 解凍後、夫々のフォルダに上書きアップロードして使えます。
(09/03/21:d3forum-0.85に合わせて管理画面での設定項目追加、ほか) |
(08/08/31:xwordsD3commentContent.class.php を変更) |
D3commentクラス [9]
D3commentクラスは、下記ファイルをダウンロード後、「xwords/class」内にアップロードして使用します。
(09/03/21:config変数の変更) |
(08/08/31:用語の属性(html,smiley,xcodes,br)を引いてサニタイズ処理に反映するようにした |
当然ながら、d3forumの方にコメント統合用に掲示板を追加し、(必要があれば)過去のxoops[12]コメントをインポート後、「コメント統合時の参照方法」に
xwords::xwordsD3commentContent
と記載します。(最初の「xwords」の部分は、インストールディレクトリ名に合わせて変更します。)
なお、d3forumは0.83a以降のバージョンが必須で、D3commentの最新のAPIクラス群を忘れずにアップして下さい。
Xwordsソースの変更 [13]
(以下、ver-a2までの情報です。 ver-b以降の情報は、追って編集します。)
3つのソースファイルに手を入れます。 こんな方法で良いのか自信はありませんが、間違いではないと思うのでご勘弁。
xoops_version.php [14]
「xoops_version.php」を編集し、管理画面にmodule_config項目を追加します。
下記の388~402行目を追記します。
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
| $cf++;
$modversion['config'][$cf]['name'] = 'blocksperpage';
$modversion['config'][$cf]['title'] = "_MI_{$MYDIRNAME}_BLOCKSPERPAGE";
$modversion['config'][$cf]['description'] = "_MI_{$MYDIRNAME}_BLOCKSPERPAGEDSC";
$modversion['config'][$cf]['formtype'] = 'select';
$modversion['config'][$cf]['valuetype'] = 'int';
$modversion['config'][$cf]['default'] = 5;
$modversion['config'][$cf]['options'] = array( '0' => 0,'5' => 5, '10' => 10, '15' => 15, '20' => 20, '25' => 25, '30' => 30, '50' => 50 );
$cf++;
$modversion['config'][$cf]['name'] = 'com_agent';
$modversion['config'][$cf]['title'] = "_MI_{$MYDIRNAME}_COM_AGENT";
$modversion['config'][$cf]['description'] = "_MI_XWORDS_COM_AGENTDSC";
$modversion['config'][$cf]['formtype'] = 'textbox';
$modversion['config'][$cf]['valuetype'] = 'text';
$modversion['config'][$cf]['default'] = '';
$cf++;
$modversion['config'][$cf]['name'] = 'com_agent_forumid';
$modversion['config'][$cf]['title'] = "_MI_{$MYDIRNAME}_COM_AGENTID";
$modversion['config'][$cf]['description'] = "_MI_XWORDS_COM_AGENTIDDSC";
$modversion['config'][$cf]['formtype'] = 'textbox';
$modversion['config'][$cf]['valuetype'] = 'int';
$modversion['config'][$cf]['default'] = 0;
// On Install
if( ! empty( $_POST['fct'] ) && ! empty( $_POST['op'] ) && $_POST['fct'] == 'modulesadmin' && $_POST['op'] == 'install_ok' && $_POST['module'] != 'xwords' && $_POST['module'] == $mydirname && file_exists( XOOPS_ROOT_PATH . "/modules/{$mydirname}/include/oninstall.inc.php" ) )
{
include XOOPS_ROOT_PATH . "/modules/{$mydirname}/include/oninstall.inc.php" ;
}
|
languages/japanese/modinfo.php [15]
「modinfo.php」を編集し、上の作業で追加した管理画面の項目に日本語テキストを追加します。
以下の158~162行目を追記します。
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
| //Names of Blocks and Block information
define("_MI_{$MYDIRNAME}_ENTRIESNEW", "新着ブロック");
define("_MI_{$MYDIRNAME}_ENTRIESTOP", "人気ブロック");
define("_MI_{$MYDIRNAME}_RANDOMTERM", "ランダムブロック");
define("_MI_{$MYDIRNAME}_TERMINITIAL", "頭文字ブロック");
//define("_MI_{$MYDIRNAME}_NOTUJIS", "MYSQLの環境が default-character-set = %s です。<br />XOOPS[12]を使用する上で支障があるかもしれません。");
define("_MI_{$MYDIRNAME}_COM_AGENT","コメントシステムの設定");
define("_MI_{$MYDIRNAME}_COM_AGENTDSC","d3forumのコメント統合機能を使用する場合は<br/>フォーラムのhtml側ディレクトリ名を指定します。<br/>xoops[12]コメントを使用する場合やコメント機能を無効にする場合は空欄です。");
define("_MI_{$MYDIRNAME}_COM_AGENTID","コメントのforum_id");
define("_MI_{$MYDIRNAME}_COM_AGENTIDDSC","コメント統合を選択した場合、forum_idを必ず指定してください。");
?>
|
header.php [16]
「header.php」に、下記のように56~65行目を追記します。
module_config設定項目を、smarty変数でテンプレートに渡すために必要です。
54
55
56
57
58
59
60
61
62
63
64
65
66
67
| $myts = & XwordsTextSanitizer::getInstance();
// モジュールID // added by naao
$module_handler =& xoops_gethandler('module');
$this_module =& $module_handler->getByDirname($mydirname);
$mid = $this_module->getVar('mid');
// モジュールconfig // added by naao
$config_handler =& xoops_gethandler("config");
$mod_config = $config_handler->getConfigsByCat(0, $mid);
$xoopsTpl->assign("moduleConfig", $mod_config);
?>
|
テンプレートの編集 [17]
続いて、テンプレートを1つ、Altsysなどで編集します。
xwords_entry.html [18]
「xwords_entry.html」の、105~125行目 を以下のように編集します。
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
| <{if $moduleConfig.com_agent}>
<{d3comment mydirname='xwords' id=$thisterm.id subject=$thisterm.term class="xwordsD3commentContent}>
<{else}>
<{* comment nav block *}>
<{if $commentsnav}>
<div style="clear:both;margin:0.1em 0em;padding:0em;">
<fieldset class="item" style="border:1px solid #778;margin:1em 0em;background-color:transparent;">
<legend class="itemHead"><{$lang_comment}></legend>
<div style="margin:1em 0em;padding:0em;text-align:center;line-height:1.3em;">
<{$commentsnav}>
<{$lang_notice}>
<!-- start comments loop -->
<{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}>
<!-- end comments loop -->
</div>
</fieldset>
</div>
<{/if}>
<{/if}>
|
インストールと設定 [21]
xoops[12]管理画面の「モジュールの管理」で、「xwords」をモジュールアップデートします。 これで、「xwords」の管理画面に、2つの項目が追加されます。
[22]
ここで、
- コメントシステムの設定 : d3forumのコメント統合機能を使用する場合はd3forumのhtml側ディレクトリ名を指定します。xoops[12]コメントを使用する場合やコメント機能を無効にする場合は空欄です。
- コメントのforum_id : コメント統合を選択した場合、統合先のforum_id値を必ず指定してください。
これらを設定すれば完了です。(この編集を行うまでは、xoops[12]コメントシステムが有効です。)
- xwordsソース、d3forumソース、xugj_blockソース:GPL