*minicalendar_viewer.inc.phpの改造 [#vdd75700]
|SIZE(12):RIGHT:100|LEFT:360|c
|~目的|minicalendar_viewer.inc.phpをブログ風にコメントを追加する|
|~対応バージョン|1.4.7plus-i18n|
|~改造者|taru|
|~公開日|&new{2006-8-31 (木) 19:05:43};|
&include_in(diary/2006-08-18,comment);
#contentsx
*使用するプラグイン [#sec07885]
|plugin名|改造|h
|minicalendar.inc.php|無し|
|minicalendar_viewer.inc.php|有り|
|wikinote.inc.php|有り|
|diary_opt.inc.php|新規|
*minicalendar_viewer.inc.phpの改造部分 [#v6f98232]
***define部 [#q9f2a071]
#expand(470){{{
#code(diff){{
define('PLUGIN_MINICALENDAR_VIEWER_USAGE',
'#calendar_viewer(pagename,this|yyyy-mm|n|x*y[,mode[,separater]])');
define('PLUGIN_MINICALENDAR_MAX_VIEWS', 6);
define('PLUGIN_MINICALENDAR_VIEWER_HOLIDAYVIEW',TRUE);
define('PLUGIN_MINICALENDAR_VIEWER_COMMENT',TRUE);
+define('PLUGIN_MINICALENDAR_VIEWER_COMMENT_COUNT_CHANGE',TRUE); //コメントのカウント方法変更。TRUE=ページソースを読込んで数える:FALSE=ページ変更回数を取得する
+define('PLUGIN_MINICALENDAR_VIEWER_COMMENT_PAGE_NAME','Note/'); //コメントを作成するページ。 taru 06.08.28
define('PLUGIN_MINICALENDAR_VIEWER_TRACKBACK',TRUE);
+define('PLUGIN_MINICALENDAR_VIEWER_CUT',TRUE); //ソース内に//cutが存在すれば、それ以降表示しない。taru 06.08.19
+define('PLUGIN_MINICALENDAR_VIEWER_WIKINOTE_OPTION','noauto'); //wikinote.inc.phpに引き渡すオプション-'noauto'。taru 06.08.23
}}
}}}
-define('PLUGIN_MINICALENDAR_VIEWER_COMMENT',TRUE);
>コメントページの作成を有効にします。minicalendar_viewerの表示でComment(0)を追加します。~
※初期値がFALSEになっています。TRUEに変更しなければコメントが有効になりません。
-define('PLUGIN_MINICALENDAR_VIEWER_COMMENT_COUNT_CHANGE',TRUE);
>コメントのカウント方法変更。TRUE=ページソースを読込んで数える。FALSE=ページ変更回数を取得する。
-define('PLUGIN_MINICALENDAR_VIEWER_COMMENT_PAGE_NAME','Note/');
>コメントを作成するページ名。この場合''Note''の下層にコメントページが作られます。
-define('PLUGIN_MINICALENDAR_VIEWER_TRACKBACK',TRUE);
>Trackbackを有効にします。minicalendar_viewerの表示でTrackback(0)を追加します。
-define('PLUGIN_MINICALENDAR_VIEWER_CUT',TRUE);
>日記の中に//cutの記述があれば、minicalendar_viewerの表示で「…続きを見る」を追加し、それ以降の記述を表示しない。
-define('PLUGIN_MINICALENDAR_VIEWER_WIKINOTE_OPTION','noauto');
>wikinote.inc.phpに引き渡すオプションです。 '' とすると日記ページ作成と同時にコメントページが作成されます。'noauto'とするとComment(0)のリンクをクリックしたときにコメントページの作成を行います。
***任意の位置で「…続きを見る」を表示させる。 [#mb0e2a18]
-ソースを一行づつチェックして//cutの文字が見つかればソースの読み込みを終了する
#expand(470){{{
#code(diff){{
// 現状で閲覧許可がある場合だけ表示する
if (check_readable($page, FALSE, FALSE)) {
+ $source_in = get_source($page); //taru 06.08.19
+ $source = ''; //taru 06.08.19
+ $source_cut_find = FALSE;
+ if (PLUGIN_MINICALENDAR_VIEWER_CUT === TRUE) { //taru 06.08.19
+ foreach ($source_in as $line_s) {
+ if (preg_match('/^(\/\/)(cut)/', $line_s)){
+ $source_cut_find = TRUE;
+ break;
+ }
+ $source .=$line_s;
+ }
+ }
if (function_exists('convert_filter')) {
- $body = convert_html(convert_filter(get_source($page)));
+ $body = convert_html(convert_filter($source));
} else {
- $body = convert_html(get_source($page));
+ $body = convert_html($source);
}
}}
}}}
***270行目付近 [#b689b147]
-comment,Trackbackを別functionに移動(関数化)。
-上の追加コードでソースに//cutが見つかれば「…続きを見る」を表示する。
#region(←クリックして頂ければ、コードを展開します。)
#code(diff){{
- if (PLUGIN_MINICALENDAR_VIEWER_COMMENT === TRUE) {
- if (is_page(':config/plugin/addline/comment') && exist_plugin_inline('addline')) {
- $comm = convert_html(array('&addline(comment,above){comment};'));
- $comm = preg_replace(array("'<p>'si","'</p>'si"), array("",""), $comm );
- $tail .= str_replace('>comment','><img src="'.IMAGE_URI.'plus/comment.png" width="15" height="15" alt="Comment" title="Comment" />Comment',$comm);
- }
- }
- if (PLUGIN_MINICALENDAR_VIEWER_TRACKBACK === TRUE) {
- if ($trackback) {
- $tb_id = tb_get_id($page);
- $tail .= '<a href="' . $script . '?plugin=tb&__mode=view&tb_id=' . $tb_id . '">'
- . '<img src="' . IMAGE_URI . 'plus/trackback.png" width="15" height="15" alt="" title="" />Trackback(' . tb_count($page) . ')'
- . '</a>' . "\n";
- }
- }
+ $tail = comment_and_trackback($page,$trackback); //taru 06.08.24
+ if ($source_cut_find === TRUE) { //taru 06.08.19
+ $tail = '<font size="-1"><a href="' . $script . '?' . $r_page . '">…続きを見る</a></font><br />' . $tail;
+ }
if ($tail != '') { $tail = '<div class="trackback">'. $tail . '</div>'; };
$return_body .= $head . '<div class="minicalendar_viewer">' . $body . '</div>' . $tail;
++$tmp;
}
}}
#endregion
***最終行''}''の後ろに下記コードを追加する。 [#h7367dcd]
-注意''?>''は必ず一番最後になるようにして下さい。(''?>''の後ろにコードを追加しても実行しません)
-commentとtrackbackを表示するための処理です。
#region(←クリックして頂ければ、コードを展開します。)
#geshi{{{
function comment_and_trackback($page,$trackback,$br_on_off = 0)
{
if (PLUGIN_MINICALENDAR_VIEWER_COMMENT === TRUE) {
if (exist_plugin_inline('wikinote')) { //taru 06.08.18 if~
$wikinotepage = PLUGIN_MINICALENDAR_VIEWER_COMMENT_PAGE_NAME . $page;
$r_wikinotepage = rawurlencode($wikinotepage);
$comment_count = 0;
if(is_page($wikinotepage,$reload=FALSE)){ //taru 06.08.23 if~
if(PLUGIN_MINICALENDAR_VIEWER_COMMENT_COUNT_CHANGE === TRUE) {
$note_source = get_source($wikinotepage);
foreach ($note_source as $line_chk) {
if (preg_match('/\&new\{.*?\}\;$/', $line_chk)) $comment_count++; // '07.01.23 &new{}をカウントするように変更
}
} else {
$comment_count = log_count('update',$wikinotepage);
}
}
$search_r = array ('@<ul[^>]*?>(.+?)</ul>@si', // ul タグを削除
'@<li[^>]*?>(.+?)</li>@si', // li タグを削除
'@<a href="[^>]*?>Article</a>@si', // Article リンクを削除
'@>Comment@si'); // Comment文字の前に画像、後ろにカウント数を差し込む
$replace_r = array ('$1',
'$1',
'',
'><img src="'.IMAGE_URI.'plus/comment.png" width="15" height="15" alt="Comment" title="Comment" />Comment' . "(" . $comment_count . ")"
);
if (PLUGIN_MINICALENDAR_VIEWER_WIKINOTE_OPTION === 'noauto') { //taru 06.08.26
if(is_page($wikinotepage)){
$tail = '<a href="' . $script . '?' . $r_wikinotepage . '"' . $replace_r[3] . '</a>';
} else {
$r_page = rawurlencode($page);
$tail = '<a href="' . $script . '?cmd=diary_opt&page=' . $r_wikinotepage . '"' . $replace_r[3] . '</a>';
}
} else {
$comm = call_user_func(array(new PluginWikinote(array('templink',PLUGIN_MINICALENDAR_VIEWER_WIKINOTE_OPTION)), 'convert'));
$comm = preg_replace(array("'<p>'si","'</p>'si"), array("",""), $comm );
$tail .= preg_replace($search_r, $replace_r, $comm);
}
}
}
if ($br_on_off) $tail .= '<br />';
if (PLUGIN_MINICALENDAR_VIEWER_TRACKBACK === TRUE) {
if ($trackback) {
$tb_id = tb_get_id($page);
$tail .= '<a href="' . $script . '?plugin=tb&__mode=view&tb_id=' . $tb_id . '">'
. '<img src="' . IMAGE_URI . 'plus/trackback.png" width="15" height="15" alt="" title="" />Trackback(' . tb_count($page) . ')'
. '</a>' . "\n";
}
}
return $tail;
}
}}}
#endregion
*wikinote.inc.phpの改造部分 [#h801fb60]
-大幅な改良が行われたようなので、旧バージョンRevision 96を[[履歴ファイル>https://opensvn.csie.org/viewcvs.cgi/pukiwikiplugin/wikinote.inc.php?root=sonots&view=log]]からダウンロードする必要があります。
-作成元ページへのリンクを作れるようにする
***options['templink']を追加する [#w50fa2a7]
#code(diff){{
// Modify here for default values
$this->options['prefix'] = 'Note/';
$this->options['mainlabel'] = 'Article';
$this->options['notelabel'] = 'Comment';
$this->options['except'] = '^$';
$this->options['noauto'] = FALSE;
+ $this->options['templink'] = FALSE; //taru 06.08.22
}}
***ページ情報を付加する [#q5627a7c]
#expand(470){{{
#code(diff){{
// do not touch, users
global $vars;
$this->parse_options($args);
list($page, $notepage) = $this->parse_current($vars['page']);
$is_none = $this->is_none($page);
if ($is_none) {
$this->inline = '1';
$this->convert = '';
} else {
- $this->autocreate_wikinote($notepage);
+ $this->autocreate_wikinote($notepage,$page); //taru 06.08.18
if ($this->error != '') { return "<p>#$this->plugin(): $this->error.</p>"; }
$this->inline = '0';
$this->convert = $this->make_switchlink($page, $notepage, $vars['page']);
}
}}
}}}
***templateにリンクを追加 [#x22beede]
#expand(470){{{
#code(diff){{
- function autocreate_wikinote($notepage)
+ function autocreate_wikinote($notepage,$page)
{
if ($this->options['noauto']) return;
if ($this->is_page($notepage)) return;
$contents = auto_template($notepage);
if ($contents == '') {
+ if ($this->options['templink']){ //taru 06.08.22
+ $contents = $this->default_template_contents . '[[' . $page . ']]'; //taru 06.08.18
+ } else {
$contents = $this->default_template_contents;
+ }
}
}}
}}}
*diary_opt.inc.phpのダウンロード [#qc94613f]
#table_edit2(textarea){{{
|SIZE(12):|SIZE(12):|SIZE(12):|SIZE(12):|c
|~ファイル|~バージョン|~日付|~コメント|
|&ref(diary_opt.inc.php.0.6);|0.6|07/01/30|コメントページで本文へのリンクを表示する機能を追加|
|&ref(diary_opt.inc.php);|0.5|06/08/30|minicalendar_viewer.inc.php,&br;補助プラグイン|
}}}
>minicalendar_viewer.inc.phpでページを見ている時はcomment,trackbackが表示されています。しかし、直接日記ページを見る場合は、表示しません。そこでこのプラグインをSideBarページもしくはFootareaページに書き込む事でminicalendar_viewerを通さずにcomment,trackbackを表示する事が出来ます。
**使用方法 [#xe4f78b3]
#diary_opt(カレンダー作成ページ名)
このサイトの様に作っている場合は#diary_opt(diary)と指定する事で、diary/xxxxx形式のページ名だけ表示されます。
**define部 [#ta9725fc]
define('PLUGIN_DIARY_OPT_COMMENT_PAGE_NAME','Note/');
>コメントページの名前。wikinote,minicalendar_viewerと統一して下さい。
define('PLUGIN_DIARY_OPT_JOIN_FORM_CHECK','-');
>日記名XXXX-XX-XXの「-」なんとなくdefineにしただけ。変えないで下さい。
define('PLUGIN_DIARY_OPT_DATE_LIMIT',2); //month
>minicalendar_viewer.inc.phpでnoautoに設定した時に、この数字がコメントページの作成期限になります。&br;この場合2ヶ月前の日記ページからはコメントページの作成を禁止します。&br;0を設定した場合は制限無しとなります。
*コメント [#y487ea8e]
#block(wholewidth:95%,width:50%,border:solid 1px #D3D3FF,backcolor:#E6E6FF)
- ページの修正と補助プラグインバージョンアップをしました。&br; [[最終行}の後ろに下記コードを追加する。>PukiWiki/hack/minicalendar_viewer.inc.php#h7367dcd]]のセクションで#expandプラグインが展開できない状態だったので#regionプラグインに変えました。又、記入しているコードを一部変更しました。('07.01.23の部分です)&br; &ref(diary_opt.inc.php.0.6);をアップしました。コメントページで本文へのリンクを表示します。 -- [[taru]] &new{2007-01-30 (火) 23:42:35};
#comment
#block(end)