• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisiónf9c56c546e812b5d567c36862985c55b58a26619 (tree)
Tiempo2004-08-10 22:39:25
Autorhenoheno <henoheno>
Commiterhenoheno

Log Message

Cleanup. Added comments

Cambiar Resumen

Diferencia incremental

--- a/plugin/calendar_viewer.inc.php
+++ b/plugin/calendar_viewer.inc.php
@@ -1,17 +1,20 @@
11 <?php
22 /*
33 * PukiWiki calendar_viewerプラグイン
4- * $Id: calendar_viewer.inc.php,v 1.20 2004/08/10 13:18:05 henoheno Exp $
4+ * $Id: calendar_viewer.inc.php,v 1.21 2004/08/10 13:39:25 henoheno Exp $
55 * calendarrecentプラグインを元に作成
66 */
77
88 /**
99 * 概要
1010 calendarプラグインやcalendar2プラグインで作成したページを一覧表示するためのプラグインです。
11+
1112 * 使い方
1213 #calendar_viewer(pagename,(yyyy-mm|n|this),[mode],[separater])
14+
1315 ** pagename
1416 calendar or calendar2プラグインを記述してるページ名
17+
1518 ** (yyyy-mm|n|this)
1619 - yyyy-mm
1720 -- yyyy-mmで指定した年月のページを一覧表示
@@ -19,6 +22,7 @@
1922 -- n件の一覧表示
2023 - this
2124 -- 今月のページを一覧表示
25+
2226 ** [mode]
2327 省略可能です。省略時のデフォルトはpast
2428 - past
@@ -27,6 +31,7 @@
2731 -- 今日以降のページの一覧表示モード。イベント予定やスケジュール向き
2832 - view
2933 -- 過去から未来への一覧表示モード。表示抑止するページはありません。
34+
3035 ** [separater]
3136 - 年月日を区切るセパレータを指定。
3237 - 省略可能。デフォルトは-。(calendar2なら省略でOK)
@@ -48,7 +53,7 @@ function plugin_calendar_viewer_convert()
4853 $limit_page = 7; // 表示する件数制限
4954 $date_YM = ''; // 一覧表示する年月
5055 $mode = 'past'; // 動作モード
51- $date_sep = '-'; // 日付のセパレータ calendar2なら'-' calendarなら''
56+ $date_sep = '-'; // 日付のセパレータ calendar2なら '-', calendarなら ''
5257
5358
5459 // 引数の確認
@@ -63,22 +68,22 @@ function plugin_calendar_viewer_convert()
6368 }
6469 if (preg_match('/[0-9]{4}' . $date_sep . '[0-9]{2}/', $func_vars_array[1])) {
6570 // 指定年月の一覧表示
66- $page_YM = $func_vars_array[1];
67- $limit_base = 0;
68- $limit_page = 31; // 手抜き。31日分をリミットとする。
71+ $page_YM = $func_vars_array[1];
72+ $limit_base = 0;
73+ $limit_page = 31; // 手抜き。31日分をリミットとする。
6974 } else if (preg_match('/this/si', $func_vars_array[1])) {
7075 // 今月の一覧表示
71- $page_YM = get_date('Y' . $date_sep . 'm');
72- $limit_base = 0;
73- $limit_page = 31;
76+ $page_YM = get_date('Y' . $date_sep . 'm');
77+ $limit_base = 0;
78+ $limit_page = 31;
7479 } else if (preg_match('/^[0-9]+$/', $func_vars_array[1])) {
7580 // n日分表示
76- $page_YM = '';
81+ $page_YM = '';
7782 $limit_page = $func_vars_array[1];
7883 $limit_base = 0;
7984 $limit_pitch = $func_vars_array[1];
8085 } else if (preg_match('/([0-9]+)\*([0-9]+)/', $func_vars_array[1], $reg_array)) {
81- $page_YM = '';
86+ $page_YM = '';
8287 $limit_base = $reg_array[1];
8388 $limit_page = $reg_array[1] + $reg_array[2];
8489 $limit_pitch = $reg_array[2];
@@ -86,7 +91,8 @@ function plugin_calendar_viewer_convert()
8691 return $_err_calendar_viewer_param2;
8792 }
8893
89- if (isset($func_vars_array[2]) && preg_match('/^(past|view|future)$/si', $func_vars_array[2])) {
94+ if (isset($func_vars_array[2]) &&
95+ preg_match('/^(past|view|future)$/si', $func_vars_array[2])) {
9096 // モード指定
9197 $mode = $func_vars_array[2];
9298 }
@@ -95,14 +101,14 @@ function plugin_calendar_viewer_convert()
95101 // 一覧表示するページ名とファイル名のパターン ファイル名には年月を含む
96102 if ($pagename == '') {
97103 // pagename無しのyyyy-mm-ddに対応するための処理
98- $pagepattern = '';
104+ $pagepattern = '';
99105 $pagepattern_len = 0;
100- $filepattern = encode($page_YM);
106+ $filepattern = encode($page_YM);
101107 $filepattern_len = strlen($filepattern);
102108 } else {
103- $pagepattern = strip_bracket($pagename) . '/';
109+ $pagepattern = strip_bracket($pagename) . '/';
104110 $pagepattern_len = strlen($pagepattern);
105- $filepattern = encode($pagepattern . $page_YM);
111+ $filepattern = encode($pagepattern . $page_YM);
106112 $filepattern_len = strlen($filepattern);
107113 }
108114
@@ -114,38 +120,43 @@ function plugin_calendar_viewer_convert()
114120 $pagelist = array();
115121 if ($dir = @opendir(DATA_DIR)) {
116122 $_date = get_date('Y' . $date_sep . 'm' . $date_sep . 'd');
117- while($file = readdir($dir))
118- {
123+ while($file = readdir($dir)) {
119124 if ($file == '..' || $file == '.') continue;
120125 if (substr($file, 0, $filepattern_len) != $filepattern) continue;
126+
121127 //echo "OK";
122128 $page = decode(trim(preg_replace('/\.txt$/', ' ', $file)));
129+
123130 // $pageがカレンダー形式なのかチェック デフォルトでは、 yyyy-mm-dd
124131 $page = strip_bracket($page);
125132 if (plugin_calendar_viewer_isValidDate(substr($page, $pagepattern_len), $date_sep) == false) continue;
126133
127134 // mode毎に別条件ではじく
135+
128136 // past modeでは未来のページはNG
129- if (((substr($page, $pagepattern_len)) > $_date) && ($mode == 'past'))continue;
137+ if (((substr($page, $pagepattern_len)) > $_date) &&
138+ ($mode == 'past')) continue;
139+
130140 // future modeでは過去のページはNG
131- if (((substr($page, $pagepattern_len)) < $_date) && ($mode == 'future'))continue;
141+ if (((substr($page, $pagepattern_len)) < $_date) &&
142+ ($mode == 'future')) continue;
143+
132144 // view modeならall OK
133145 $pagelist[] = $page;
134146 }
135147 }
136148 closedir($dir);
137149 //echo count($pagelist);
138- // ここからインクルード開始
139150
151+ // ここからインクルード開始
140152 $tmppage = $vars['page'];
141153 $return_body = '';
154+
142155 // まずソート
143156 if ($mode == 'past') {
144- // past modeでは新→旧
145- rsort ($pagelist);
157+ rsort($pagelist); // past modeでは新→旧
146158 } else {
147- // view mode と future mode では、旧→新
148- sort ($pagelist);
159+ sort($pagelist); // view mode と future mode では、旧→新
149160 }
150161
151162 // $limit_pageの件数までインクルード
@@ -156,17 +167,17 @@ function plugin_calendar_viewer_convert()
156167
157168 $get['page'] = $post['page'] = $vars['page'] = $page;
158169
159- // 現状で閲覧許可がある場合だけ表示する
160- if (check_readable($page, false, false)) {
161- $body = convert_html(get_source($page));
162- } else {
163- $body = str_replace('$1', $page, $_msg_calendar_viewer_restrict);
164- }
170+ // 現状で閲覧許可がある場合だけ表示する
171+ if (check_readable($page, false, false)) {
172+ $body = convert_html(get_source($page));
173+ } else {
174+ $body = str_replace('$1', $page, $_msg_calendar_viewer_restrict);
175+ }
165176
166177 $r_page = rawurlencode($page);
167178 $s_page = htmlspecialchars($page);
168- $link = "<a href=\"$script?cmd=edit&amp;page=$r_page\">$s_page</a>";
169- $head = "<h1>$link</h1>\n";
179+ $link = "<a href=\"$script?cmd=edit&amp;page=$r_page\">$s_page</a>";
180+ $head = "<h1>$link</h1>\n";
170181 $return_body .= $head . $body;
171182
172183 ++$tmp;
@@ -179,10 +190,11 @@ function plugin_calendar_viewer_convert()
179190 if ($page_YM != '') {
180191 // 年月表示時
181192 $date_sep_len = strlen($date_sep);
182- $this_year = substr($page_YM, 0, 4);
183- $this_month = substr($page_YM, 4 + $date_sep_len, 2);
193+ $this_year = substr($page_YM, 0, 4);
194+ $this_month = substr($page_YM, 4 + $date_sep_len, 2);
195+
184196 // 次月
185- $next_year = $this_year;
197+ $next_year = $this_year;
186198 $next_month = $this_month + 1;
187199 if ($next_month > 12) {
188200 ++$next_year;
@@ -199,15 +211,15 @@ function plugin_calendar_viewer_convert()
199211 }
200212 $prev_YM = sprintf('%04d%s%02d', $prev_year, $date_sep, $prev_month);
201213 if ($mode == 'past') {
202- $right_YM = $prev_YM;
203- $right_text = $prev_YM . '&gt;&gt;';
204- $left_YM = $next_YM;
205- $left_text = '&lt;&lt;' . $next_YM;
214+ $right_YM = $prev_YM;
215+ $right_text = $prev_YM . '&gt;&gt;'; // >>
216+ $left_YM = $next_YM;
217+ $left_text = '&lt;&lt;' . $next_YM; // <<
206218 } else {
207- $left_YM = $prev_YM;
208- $left_text = '&lt;&lt;' . $prev_YM;
209- $right_YM = $next_YM;
210- $right_text = $next_YM . '&gt;&gt;';
219+ $left_YM = $prev_YM;
220+ $left_text = '&lt;&lt;' . $prev_YM; // <<
221+ $right_YM = $next_YM;
222+ $right_text = $next_YM . '&gt;&gt;'; // >>
211223 }
212224 } else {
213225 // n件表示時
@@ -215,12 +227,12 @@ function plugin_calendar_viewer_convert()
215227 $right_YM = '';
216228 } else {
217229 $right_base = $limit_base + $limit_pitch;
218- $right_YM = $right_base . '*' . $limit_pitch;
230+ $right_YM = $right_base . '*' . $limit_pitch;
219231 $right_text = sprintf($_msg_calendar_viewer_right, $limit_pitch);
220232 }
221233 $left_base = $limit_base - $limit_pitch;
222234 if ($left_base >= 0) {
223- $left_YM = $left_base . '*' . $limit_pitch;
235+ $left_YM = $left_base . '*' . $limit_pitch;
224236 $left_text = sprintf($_msg_calendar_viewer_left, $limit_pitch);
225237
226238 } else {