自作プラグイン/autocalendar.inc.php
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
** autocalendar.inc.php [#m76387ad]
|RIGHT:125|LEFT:360|c
|~サマリ|表示中のページに対応した月を表示するカレンダー|
|~リビジョン|080521|
|~対応バージョン|1.4.7|
|~投稿者|[[tomas3]]|
|~投稿日|&new{2008-06-09 (月) 16:33:51};|
***概要 [#cba99e5d]
[[calendar2プラグイン>PukiWiki/プラグイン/1.4#x3bbd0a5]]...
たとえば、次のようなページがあり、
-日記/2008-05-31
-日記/2008-06-01
-more...
menubarの中で
#calendar2(日記,off)
とすれば、常にカレンダーが表示できます。
そして、calendar2プラグインの変わりに、本プラグインを使用...
#autocalendar(日記)
とすると、日記/2008-05-31のページを表示している場合は、20...
mixiのカレンダーがこうなっていて、日記を順番に見ていくと...
***補足 [#nb033000]
-書式ですが、# autocalendar(ベースとなるページ名) で使用...
-受付範囲を勝手に1900年から2100年にしてあります。
-定数の定義部分のcalendar2をminicalendarにすれば、pukiwik...
-1.4.7 utf-8 でしかチェックしていません。改造したcalendar...
-私の初のPHPコードです。ダメなところがあれば、教えてくだ...
***コード [#zffa2973]
ファイルが添付できませんので、以下のコードを、pluginフォ...
calendar2プラグインをラップするように書いています。グロー...
<?php
//**********************************
// autocalendar ver.080521
// by tomas3
//
// for calendar2 plugin of Pukiwiki
//**********************************
//choose calendar2 or minicalendar(Pukiwiki Plus!).
define('PLUGIN_AUTOCALENDAR_BASEPLUGIN', 'calendar2');
function plugin_autocalendar_convert()
{
//プラグイン引数チェック
//手抜き。省略されたら、現在のページにするのが普通のはず
$args = func_get_args();
if(count($args) != 1)
return "<span style=\"color:red\">plugin autocalend...
$target = $args[0];
//同じ親か
global $title;
if(mb_substr($title, 0, mb_strlen($target) + 1) != $...
// return "debug: 同じ親じゃ無い $target ";
} else {
//子ページかどうか
$sub_title = mb_substr($title, mb_strlen($target) +...
// return "debug: " . $sub_title;
if(false) {
//ここのifに、条件を厳しくするコードが入れられま...
//現在は、孫ページがあっても、子ページ名が日付フ...
} else {
$sub_title = mb_substr($sub_title, 0, mb_strlen("y...
//日付であるかの確認 1900年から2100年としてある。(...
if(
strlen($sub_title) != mb_strlen($sub_title) ||
mb_substr($sub_title, 4, 1) != "-" ||
mb_substr($sub_title, 7, 1) != "-"
) {
// return "debug: 'yyyy-mm-*'じゃない $target ";
} else {
$year = mb_substr($sub_title, 0, 4);
$month = mb_substr($sub_title, 5, 2);
if(
(int) $year < 1900 ||
(int) $year > 2100 ||
(int) $month < 1 ||
(int) $month > 12
) {
// return "debug: 日付のレンジがおかしい $target ";
} else {
//ここまで来たら、年月を指定するべきときのはず
array_push($args, $year . $month);
}
}
}
}
//一覧表示offオプションを追加してcalendarプラグインを呼...
array_push($args, "off");
return exist_plugin_convert(PLUGIN_AUTOCALENDAR_BASEPLU...
do_plugin_convert(PLUGIN_AUTOCALENDAR_BASEPLUGIN, csv_...
}
?>
***ライセンス [#l0f10d83]
GPL(?よくわかりませんが、コピーレフトなやつで)
***コメントお願いします。 [#m6aa51a7]
- 引数にhtmlspecialchars()してませんが、calendarプラグイ...
- デフォルトのカレンダーは大きすぎて、CSSをカスタマイズで...
//#comment
終了行:
** autocalendar.inc.php [#m76387ad]
|RIGHT:125|LEFT:360|c
|~サマリ|表示中のページに対応した月を表示するカレンダー|
|~リビジョン|080521|
|~対応バージョン|1.4.7|
|~投稿者|[[tomas3]]|
|~投稿日|&new{2008-06-09 (月) 16:33:51};|
***概要 [#cba99e5d]
[[calendar2プラグイン>PukiWiki/プラグイン/1.4#x3bbd0a5]]...
たとえば、次のようなページがあり、
-日記/2008-05-31
-日記/2008-06-01
-more...
menubarの中で
#calendar2(日記,off)
とすれば、常にカレンダーが表示できます。
そして、calendar2プラグインの変わりに、本プラグインを使用...
#autocalendar(日記)
とすると、日記/2008-05-31のページを表示している場合は、20...
mixiのカレンダーがこうなっていて、日記を順番に見ていくと...
***補足 [#nb033000]
-書式ですが、# autocalendar(ベースとなるページ名) で使用...
-受付範囲を勝手に1900年から2100年にしてあります。
-定数の定義部分のcalendar2をminicalendarにすれば、pukiwik...
-1.4.7 utf-8 でしかチェックしていません。改造したcalendar...
-私の初のPHPコードです。ダメなところがあれば、教えてくだ...
***コード [#zffa2973]
ファイルが添付できませんので、以下のコードを、pluginフォ...
calendar2プラグインをラップするように書いています。グロー...
<?php
//**********************************
// autocalendar ver.080521
// by tomas3
//
// for calendar2 plugin of Pukiwiki
//**********************************
//choose calendar2 or minicalendar(Pukiwiki Plus!).
define('PLUGIN_AUTOCALENDAR_BASEPLUGIN', 'calendar2');
function plugin_autocalendar_convert()
{
//プラグイン引数チェック
//手抜き。省略されたら、現在のページにするのが普通のはず
$args = func_get_args();
if(count($args) != 1)
return "<span style=\"color:red\">plugin autocalend...
$target = $args[0];
//同じ親か
global $title;
if(mb_substr($title, 0, mb_strlen($target) + 1) != $...
// return "debug: 同じ親じゃ無い $target ";
} else {
//子ページかどうか
$sub_title = mb_substr($title, mb_strlen($target) +...
// return "debug: " . $sub_title;
if(false) {
//ここのifに、条件を厳しくするコードが入れられま...
//現在は、孫ページがあっても、子ページ名が日付フ...
} else {
$sub_title = mb_substr($sub_title, 0, mb_strlen("y...
//日付であるかの確認 1900年から2100年としてある。(...
if(
strlen($sub_title) != mb_strlen($sub_title) ||
mb_substr($sub_title, 4, 1) != "-" ||
mb_substr($sub_title, 7, 1) != "-"
) {
// return "debug: 'yyyy-mm-*'じゃない $target ";
} else {
$year = mb_substr($sub_title, 0, 4);
$month = mb_substr($sub_title, 5, 2);
if(
(int) $year < 1900 ||
(int) $year > 2100 ||
(int) $month < 1 ||
(int) $month > 12
) {
// return "debug: 日付のレンジがおかしい $target ";
} else {
//ここまで来たら、年月を指定するべきときのはず
array_push($args, $year . $month);
}
}
}
}
//一覧表示offオプションを追加してcalendarプラグインを呼...
array_push($args, "off");
return exist_plugin_convert(PLUGIN_AUTOCALENDAR_BASEPLU...
do_plugin_convert(PLUGIN_AUTOCALENDAR_BASEPLUGIN, csv_...
}
?>
***ライセンス [#l0f10d83]
GPL(?よくわかりませんが、コピーレフトなやつで)
***コメントお願いします。 [#m6aa51a7]
- 引数にhtmlspecialchars()してませんが、calendarプラグイ...
- デフォルトのカレンダーは大きすぎて、CSSをカスタマイズで...
//#comment
ページ名: