3: 2008-10-13 (月) 10:48:41 なーお[3] [4] [5] | 現: - no date - [6] [7] | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | *myalbumモジュールで、d3コメント統合の簡単化 [#yca26094] | ||
- | **概要 [#wfc715cf] | ||
- | 以前より、[[myalbum-Pモジュール:http://xoops.peak.ne.jp/md/mydownloads/singlefile.php?lid=61&cid=1]] をコメント統合で使ってはいましたが、携帯用テンプレートの共有化を行う際に、テンプレートにサイト毎に異なるd3forum_dirnameとforum_idを記述する部分で支障があり、何とかしたいと考え、myalbumP-ver2.88をベースに手を入れてみました。 | ||
- | + D3コメントクラスは、[[photositeさん配布のもの:http://www.photositelinks.com/modules/mydownloads/index.php?page=singlefile&cid=1&lid=1]](ver0.5)をベースにして手を入れています。 | ||
- | &br; | ||
- | + コメント統合先のd3forumディレクトリ名・フォーラムid値は、%%d3blog%% d3pipes のコメント統合を参考に、myalbum-Pの管理画面でmodule_configに保存する方式としました。 そして、コメント統合のクラスはd3forum-0.83a以降で実装された新方式(「d3comment」で呼ぶほう)を採用しています。 また、D3commentクラス内でforum_idまで認識するため、テンプレート内に記述する必要がありません。 | ||
- | こうすることで、複数サイトを共有化している場合でも、携帯用のテンプレートを共通化できますし、テンプレート配布の際にも神経を使わずに済みます。&br;&br; | ||
- | |||
- | **手順と方法 [#fd25e32c] | ||
- | テンプレートだけでなく、ソースの変更も必要ですので、細かく記しておきます。 | ||
- | |||
- | なお、個別のアップロードも編集も面倒、という人のために、myalbumP-ver2.88との差分ファイルパックを、ここに置いておきます。 解凍後、夫々のフォルダに上書きアップロードして使えます。 | ||
- | |&ref(myalbum_288a4_diff.zip);| | ||
- | |||
- | ***D3commentクラス [#h5e6f661] | ||
- | D3commentクラスは、下記ファイルをダウンロード後、「(myalbum)/class」内にアップロードして使用します。 | ||
- | |&ref(myalbumD3commentContent.class_1.php);| | ||
- | |&font(Red){(081013)&br; 参照元の、photositeさんの不具合修正版に差し替えました。&br; お手数ですが、以前のバージョンをお使いの方は差し替え願います。};| | ||
- | |||
- | 当然ながら、d3forumの方にコメント統合用に掲示板を追加し、(必要があれば)過去のxoopsコメントをインポート後、「コメント統合時の参照方法」に | ||
- | myalbum::myalbumD3commentContent:: | ||
- | と記載します。(最初の「myalbum」の部分は、インストールディレクトリ名に合わせて変更します。) | ||
- | なお、&font(Red){d3forumは0.83a以降のバージョンが必須};で、D3commentの最新のAPIクラス群を忘れずにアップして下さい。 | ||
- | |||
- | ***myalbumソースの変更 [#k9614b16] | ||
- | 5つのソースファイルに手を入れます。 こんな方法で良いのか自信はありませんが、間違いではないと思うのでご勘弁。 :-D &br; | ||
- | (&font(Red){08/09/01:config変数名を、d3pipesなどと同様の標準的なものに変更しました};) | ||
- | |||
- | ****xoops_version.php [#z422d409] | ||
- | 「xoops_version.php」を編集し、管理画面にmodule_config項目を追加します。 | ||
- | 下記の393~421行目を追記します。 | ||
- | #code(php,383){{ | ||
- | $modversion['config'][] = array( | ||
- | 'name' => 'myalbum_usesiteimg' , | ||
- | 'title' => '_ALBM_CFG_USESITEIMG' , | ||
- | 'description' => '_ALBM_CFG_DESCUSESITEIMG' , | ||
- | 'formtype' => 'yesno' , | ||
- | 'valuetype' => 'int' , | ||
- | 'default' => '0' , | ||
- | 'options' => array() | ||
- | ) ; | ||
- | |||
- | $modversion['config'][] = array( | ||
- | 'name' => 'comment_dirname' , | ||
- | 'title' => '_MI_COM_AGENT' , | ||
- | 'description' => '_MI_COM_AGENTDSC' , | ||
- | 'formtype' => 'textbox', | ||
- | 'valuetype' => 'text', | ||
- | 'default' => '', | ||
- | 'options' => array() | ||
- | ); | ||
- | |||
- | $modversion['config'][]= array( | ||
- | 'name' => 'comment_forum_id', | ||
- | 'title' => '_MI_COM_AGENTID', | ||
- | 'description' => '_MI_COM_AGENTIDDSC', | ||
- | 'formtype' => 'textbox', | ||
- | 'valuetype' => 'int', | ||
- | 'default' => '0', | ||
- | 'options' => array() | ||
- | ); | ||
- | |||
- | $modversion['config'][] = array( | ||
- | 'name' => 'comment_view' , | ||
- | 'title' => '_MI_COM_VIEW' , | ||
- | 'description' => '_MI_COM_VIEWDSC' , | ||
- | 'formtype' => 'select' , | ||
- | 'valuetype' => 'text' , | ||
- | 'default' => 'listposts_flat' , | ||
- | 'options' => array( '_FLAT' => 'listposts_flat' , '_THREADED' => 'listtopics' ) | ||
- | ) ; | ||
- | |||
- | // Search | ||
- | }} | ||
- | |||
- | ****languages/japanese/modinfo.php [#f8f54d7d] | ||
- | 「modinfo.php」を編集し、上の作業で追加した管理画面の項目に日本語テキストを追加します。 | ||
- | 以下の117~行目を追記します。 | ||
- | |||
- | #code(php,117-){{ | ||
- | //d3comment integration | ||
- | define("_MI_COM_AGENT","コメント統合するd3forumのdirname"); | ||
- | define("_MI_COM_AGENTDSC","d3forumのコメント統合機能を使用する場合は<br/>フォーラムのhtml側ディレクトリ名を指定します。<br/>xoopsコメントを使用する場合やコメント機能を無効にする場合は空欄です。"); | ||
- | define("_MI_COM_AGENTID","コメント統合するフォーラムの番号"); | ||
- | define("_MI_COM_AGENTIDDSC","コメント統合を選択した場合、forum_idを必ず指定してください。"); | ||
- | define("_MI_COM_VIEW","コメント統合の表示方法"); | ||
- | define("_MI_COM_VIEWDSC","フラット表示かスレッド表示化かを選択します。"); | ||
- | } | ||
- | |||
- | ?> | ||
- | }} | ||
- | |||
- | ****%%header.php%% [#r46e501f] | ||
- | 08/09/01 このファイル「header.php」の編集では、xoops2.0.16a-JPで問題がありましたので、訂正します。 | ||
- | |||
- | ****index.php [#x7e8ad42] | ||
- | 「index.php」の、54行目以降を以下のように編集します。 | ||
- | #code(php,54-){{ | ||
- | while( $fetched_result_array = $xoopsDB->fetchArray( $prs ) ) { | ||
- | $xoopsTpl->append( 'photos' , myalbum_get_array_for_photo_assign( $fetched_result_array , true ) ) ; | ||
- | } | ||
- | |||
- | // モジュール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); | ||
- | |||
- | include( XOOPS_ROOT_PATH . "/footer.php" ) ; | ||
- | |||
- | ?> | ||
- | }} | ||
- | |||
- | ****photo.php [#l82bec49] | ||
- | 「photo.php」の、117行目以降を以下のように編集します。 | ||
- | #code(php,115-){{ | ||
- | $xoopsTpl->assign( 'photo_nav' , $photo_nav ) ; | ||
- | |||
- | // comments | ||
- | // モジュール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); | ||
- | |||
- | include XOOPS_ROOT_PATH.'/include/comment_view.php'; | ||
- | |||
- | include( XOOPS_ROOT_PATH . "/footer.php" ) ; | ||
- | |||
- | ?> | ||
- | }} | ||
- | |||
- | ****viewcat.php [#h1306c9f] | ||
- | 「viewcat.php」の、139行目以降を以下のように編集します。 | ||
- | #code(php,136-){{ | ||
- | $xoopsTpl->append( 'photos' , $photo ) ; | ||
- | } | ||
- | } | ||
- | // モジュール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); | ||
- | |||
- | include( XOOPS_ROOT_PATH . "/footer.php" ) ; | ||
- | |||
- | ?> | ||
- | }} | ||
- | ***テンプレートの編集 [#l180e8e9] | ||
- | 続いて、テンプレートを2つ、Altsysなどで編集します。 | ||
- | |||
- | ****myalbum_photo.html [#bec2f707] | ||
- | 「myalbum_photo.html」の、97行目付近を以下のように編集します。 | ||
- | |||
- | #code(html,98-){{ | ||
- | <{* COMMENT COUNTS *}> | ||
- | <img src='<{$mod_url}>/images/comments.gif' width='16' height='16' alt='<{$lang_commentsc}>' title='<{$lang_commentsc}>' /><{$photo.comments}> | ||
- | |||
- | <{* RANK & RATING *}> | ||
- | }} | ||
- | |||
- | ↓ ここを変更 | ||
- | |||
- | #code(html,98-){{ | ||
- | <{* COMMENT COUNTS *}> | ||
- | <img src='<{$mod_url}>/images/comments.gif' width='16' height='16' alt='<{$lang_commentsc}>' title='<{$lang_commentsc}>' /> | ||
- | <{if $moduleConfig.comment_dirname}> | ||
- | <{d3comment mode="count" var="comcount" mydirname=$xoops_dirname id=$photo.lid class="myalbumD3commentContent"}> | ||
- | <{if $comcount}> | ||
- | (<{$comcount}>) | ||
- | <{else}> | ||
- | (0) | ||
- | <{/if}> | ||
- | <{else}> | ||
- | <{$photo.comments}> | ||
- | <{/if}> | ||
- | <{* RANK & RATING *}> | ||
- | }} | ||
- | |||
- | そして、153行目付近を変更 | ||
- | |||
- | #code(html,153-){{ | ||
- | <div style="margin: 3px; padding: 3px;"> | ||
- | <{if $moduleConfig.comment_dirname}> | ||
- | <{d3comment mydirname=$xoops_dirname id=$photo.lid subject=$photo.title class="myalbumD3commentContent"}> | ||
- | |||
- | <{else}> | ||
- | <div style="text-align: center; padding: 3px; margin: 3px;"> | ||
- | <{$commentsnav}> | ||
- | <{$lang_notice}> | ||
- | </div> | ||
- | |||
- | <!-- 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 --> | ||
- | <{/if}> | ||
- | </div> | ||
- | }} | ||
- | |||
- | ****myalbum_photo_in_list.html [#rd3a488b] | ||
- | 「myalbum_photo_in_list.html」の、97行目付近を以下のように編集します。 | ||
- | |||
- | #code(html,89-){{ | ||
- | <{* COMMENT COUNTS *}> | ||
- | <img src='<{$mod_url}>/images/comments.gif' width='16' height='16' alt='<{$lang_commentsc}>' title='<{$lang_commentsc}>' /><{$photo.comments}> | ||
- | |||
- | <{* RANK & RATING *}> | ||
- | }} | ||
- | |||
- | ↓ ここを変更 | ||
- | |||
- | #code(html,89-){{ | ||
- | <{* COMMENT COUNTS *}> | ||
- | <img src='<{$mod_url}>/images/comments.gif' width='16' height='16' alt='<{$lang_commentsc}>' title='<{$lang_commentsc}>' /> | ||
- | <{if $moduleConfig.comment_dirname}> | ||
- | <{d3comment mode="count" var="comcount" mydirname=$xoops_dirname id=$photo.lid class="myalbumD3commentContent"}> | ||
- | <{if $comcount}> | ||
- | (<{$comcount}>) | ||
- | <{else}> | ||
- | (0) | ||
- | <{/if}> | ||
- | <{else}> | ||
- | <{$photo.comments}> | ||
- | <{/if}> | ||
- | |||
- | <{* RANK & RATING *}> | ||
- | }} | ||
- | |||
- | ***モバイル用テンプレート [#f4145bb4] | ||
- | モバイルテンプハウスで、[[作成・公開中:http://www.mc8.jp/HD/modules/xpwiki?Templates/myalbum]]。 | ||
- | |||
- | **インストールと設定 [#m6eb5c64] | ||
- | xoops管理画面の「モジュールの管理」で、''&font(Maroon){「myalbum」をモジュールアップデート};''します。 これで、「myalbum」の管理画面に、3つの項目が追加されます。 | ||
- | |||
- | &ref(myalbum_config.gif,mw:200,mh:200); | ||
- | |||
- | ここで、 | ||
- | +コメント統合するd3forumのdirname : d3forumのコメント統合機能を使用する場合はd3forumのhtml側ディレクトリ名を指定します。xoopsコメントを使用する場合やコメント機能を無効にする場合は空欄です。 | ||
- | +コメント統合するフォーラムの番 : コメント統合を選択した場合、統合先のforum_id値を必ず指定してください。 | ||
- | +コメント統合の表示方法 : フラット表示かスレッド表示かを選択します。 | ||
- | |||
- | これらを設定すれば完了です。(この編集を行うまでは、xoopsコメントシステムが有効です。) | ||
- | |||
- | **その他 [#e7c4b4e1] | ||
- | ***関連情報 [#o63d5f41] | ||
- | - [[minidiary+D3コメント統合へのお知恵を:http://www.xugj.org/modules/d3forum/index.php?topic_id=757#post_id4643]] (XUGJ) | ||
- | - [[D3comment統合と、コメント元のイベント通知:http://www.xugj.org/modules/QandA/index.php?post_id=4875]] (XUGJ) | ||
- | |||
- | ***ライセンス [#h11ff29b] | ||
- | -myalbumソース、d3forumソース、photositeさんのd3commentクラス:GPL |
(This host) = http://motioncafe.naaon.com