1 |
wakaba |
1.1 |
#?SuikaWikiConfig/2.0 |
2 |
|
|
|
3 |
|
|
Plugin: |
4 |
|
|
@Name: Calender |
5 |
|
|
@Description: |
6 |
|
|
@@@: Calender |
7 |
|
|
@@lang:en |
8 |
wakaba |
1.2 |
@License: %%Perl%% |
9 |
wakaba |
1.1 |
@Author: |
10 |
|
|
@@Name: |
11 |
|
|
@@@@: Wakaba |
12 |
|
|
@@@lang:ja |
13 |
|
|
@@@script:Latn |
14 |
|
|
@@Mail[list]: w@suika.fam.cx |
15 |
|
|
@Date.RCS: |
16 |
wakaba |
1.3 |
$Date: 2004/02/18 07:22:11 $ |
17 |
wakaba |
1.1 |
@RequiredPlugin[list]: |
18 |
|
|
Phrase |
19 |
|
|
WikiResource |
20 |
|
|
WikiStructure |
21 |
|
|
WikiLinking |
22 |
|
|
@Use: |
23 |
|
|
my $WIKILINKING; |
24 |
|
|
my $WIKIRESOURCE; |
25 |
|
|
|
26 |
|
|
PluginConst: |
27 |
|
|
@NS_XHTML1: |
28 |
|
|
http://www.w3.org/1999/xhtml |
29 |
|
|
@WIKILINKING: |
30 |
|
|
{($WIKILINKING ||= SuikaWiki::Plugin->module_package ('WikiLinking'))} |
31 |
|
|
@WIKIRESOURCE: |
32 |
|
|
{($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))} |
33 |
|
|
|
34 |
|
|
FormattingRule: |
35 |
|
|
@Category[list]: |
36 |
|
|
view |
37 |
|
|
view-resource |
38 |
|
|
form-input |
39 |
|
|
@Name: if-calender |
40 |
|
|
@Description: |
41 |
|
|
@@@: Test whether the WikiPage is part of calender or not |
42 |
|
|
@@lang: en |
43 |
|
|
@Parameter: |
44 |
|
|
@@Name: day |
45 |
|
|
@@Type: CDATA |
46 |
|
|
@@Default: (none) |
47 |
|
|
@@Description: |
48 |
|
|
@@@@: |
49 |
|
|
Template to be evaluated when it is part of calender and has |
50 |
|
|
"day" information. |
51 |
|
|
@@@lang: en |
52 |
|
|
@Parameter: |
53 |
|
|
@@Name: false |
54 |
|
|
@@Type: CDATA |
55 |
|
|
@@Default: (none) |
56 |
|
|
@@Description: |
57 |
|
|
@@@@: |
58 |
|
|
Template to be evaluated when it is part of calender |
59 |
|
|
@@@lang: en |
60 |
|
|
@Parameter: |
61 |
|
|
@@Name: month |
62 |
|
|
@@Type: CDATA |
63 |
|
|
@@Default: (none) |
64 |
|
|
@@Description: |
65 |
|
|
@@@@: |
66 |
|
|
Template to be evaluated when it is part of calender and has |
67 |
|
|
"month" part. This template will not be used if "day" template |
68 |
|
|
is used. |
69 |
|
|
@@@lang: en |
70 |
|
|
@Parameter: |
71 |
|
|
@@Name: page |
72 |
|
|
@@Type: WikiName |
73 |
|
|
@@Default: (auto) |
74 |
|
|
@@Description: |
75 |
|
|
@@@@: |
76 |
|
|
WikiPage to be tested |
77 |
|
|
@@lang: en |
78 |
|
|
@Parameter: |
79 |
|
|
@@Name: true |
80 |
|
|
@@Type: CDATA |
81 |
|
|
@@Default: (none) |
82 |
|
|
@@Description: |
83 |
|
|
@@@@: |
84 |
|
|
Template to be evaluated when it is part of calender. |
85 |
|
|
This template will not be used if "year", "month" or "day" |
86 |
|
|
template is used. |
87 |
|
|
@@@lang: en |
88 |
|
|
@Parameter: |
89 |
|
|
@@Name: year |
90 |
|
|
@@Type: CDATA |
91 |
|
|
@@Default: (none) |
92 |
|
|
@@Description: |
93 |
|
|
@@@@: |
94 |
|
|
Template to be evaluated when it is part of calender. |
95 |
|
|
This template will not be used if "month" or "day" template |
96 |
|
|
is used. |
97 |
|
|
@@lang: en |
98 |
|
|
@Formatting: |
99 |
|
|
my $page = $o->{wiki}->name ($p->{page} or $o->{wiki}->{var}->{page}); |
100 |
|
|
my $date = __FUNCPACK__->wikiname_to_date (name => $page, o => $o); |
101 |
|
|
if ($date->{year}) { |
102 |
|
|
if ($date->{day} and $p->{day}) { |
103 |
|
|
__ATTRNODE:%day->{$p->{-parent}}__; |
104 |
|
|
} elsif ($date->{month} and $p->{month}) { |
105 |
|
|
__ATTRNODE:%month->{$p->{-parent}}__; |
106 |
|
|
} elsif ($p->{year}) { |
107 |
|
|
__ATTRNODE:%year->{$p->{-parent}}__; |
108 |
|
|
} else { |
109 |
|
|
__ATTRNODE:%true->{$p->{-parent}}__; |
110 |
|
|
} |
111 |
|
|
} else { |
112 |
|
|
__ATTRNODE:%false->{$p->{-parent}}__; |
113 |
|
|
} |
114 |
|
|
|
115 |
|
|
FormattingRule: |
116 |
|
|
@Category[list]: |
117 |
|
|
form-input |
118 |
|
|
view |
119 |
|
|
view-resource |
120 |
|
|
@Name: calender |
121 |
|
|
@Description: |
122 |
|
|
@@@: List of months in the year |
123 |
|
|
@@lang: en |
124 |
|
|
@Parameter: |
125 |
|
|
@@Name: label |
126 |
|
|
@@Type: template |
127 |
|
|
@@Default: (auto) |
128 |
|
|
@@Description: |
129 |
|
|
@@@@: Template to be used to construct day item |
130 |
|
|
@@@lang: en |
131 |
|
|
@Parameter: |
132 |
|
|
@@Name: month |
133 |
|
|
@@Type: <<1*2DIGIT>> |
134 |
|
|
@@Default: (auto) |
135 |
|
|
@@Description: |
136 |
|
|
@@@@: Month |
137 |
|
|
@@@lang: en |
138 |
|
|
@Parameter: |
139 |
|
|
@@Name: year |
140 |
|
|
@@Type: <<4*DIGIT>> |
141 |
|
|
@@Default: (auto) |
142 |
|
|
@@Description: |
143 |
|
|
@@@@: Year |
144 |
|
|
@@@lang: en |
145 |
|
|
@Formatting: |
146 |
|
|
require Time::Local; |
147 |
|
|
my $date = __FUNCPACK__->wikiname_to_date |
148 |
|
|
(name => $o->{wiki}->name ($p->{page} || |
149 |
|
|
$o->{wiki}->{var}->{page}), |
150 |
|
|
o => $o); |
151 |
|
|
my $year = $p->{year} || $date->{year} || (gmtime)[5] + 1900; |
152 |
|
|
my $month = $p->{month} || $date->{month} || (gmtime)[4] + 1; |
153 |
|
|
|
154 |
|
|
my $dow = 0; |
155 |
|
|
eval q{$dow = (gmtime (Time::Local::timegm_nocheck |
156 |
|
|
(0,0,0,1, $month-1, $year)))[6]}; |
157 |
|
|
my $lom = 0; |
158 |
|
|
eval {$lom = (gmtime (Time::Local::timegm_nocheck |
159 |
|
|
(0,0,0,0, $month==12?0:$month, $year)))[3]}; |
160 |
|
|
|
161 |
|
|
my $tbl = $p->{-parent}->append_new_node |
162 |
|
|
(type => '#element', |
163 |
|
|
namespace_uri => $NS_XHTML1, |
164 |
|
|
local_name => 'table'); |
165 |
|
|
$tbl->set_attribute (class => 'calender'); |
166 |
|
|
$tbl->set_attribute (summary => $WIKIRESOURCE->get_op |
167 |
|
|
('Calender:Table:Summary', $o) |
168 |
|
|
->inner_text); |
169 |
|
|
|
170 |
|
|
__ATTRTEXT:%nocaption__; |
171 |
|
|
unless ($p->{nocaption}) { |
172 |
|
|
my $caption = $tbl->append_new_node (type => '#element', |
173 |
|
|
namespace_uri => $NS_XHTML1, |
174 |
|
|
local_name => 'caption'); |
175 |
|
|
local $o->{link}->{option} = {-cal__year => $year, -cal__month => $month}; |
176 |
|
|
if ($p->{caption}) { |
177 |
|
|
__ATTRNODE:%caption->{$caption}__; |
178 |
|
|
} else { |
179 |
|
|
$WIKIRESOURCE->get_op ('Calender:Table:Caption', $o, $caption); |
180 |
|
|
} |
181 |
|
|
} |
182 |
|
|
|
183 |
|
|
my @dayname = qw(sun mon tue wed thu fri sat); |
184 |
|
|
for (@dayname) { |
185 |
|
|
$tbl->append_new_node (type => '#element', |
186 |
|
|
namespace_uri => $NS_XHTML1, |
187 |
|
|
local_name => 'col') |
188 |
|
|
->set_attribute (class => $_); |
189 |
|
|
} |
190 |
|
|
|
191 |
|
|
__ATTRTEXT:%noheader__; |
192 |
|
|
unless ($p->{noheader}) { |
193 |
|
|
my @wname = map {$WIKIRESOURCE->get_op |
194 |
|
|
('Calender:Weekday:Label:'.$_, $o)} @dayname; |
195 |
|
|
my $row = $tbl->append_new_node |
196 |
|
|
(type => '#element', |
197 |
|
|
namespace_uri => $NS_XHTML1, |
198 |
|
|
local_name => 'thead') |
199 |
|
|
->append_new_node |
200 |
|
|
(type => '#element', |
201 |
|
|
namespace_uri => $NS_XHTML1, |
202 |
|
|
local_name => 'tr'); |
203 |
|
|
for my $i (0..6) { |
204 |
|
|
my $cell = $row->append_new_node |
205 |
|
|
(type => '#element', |
206 |
|
|
namespace_uri => $NS_XHTML1, |
207 |
|
|
local_name => 'th'); |
208 |
|
|
$cell->set_attribute (class => $dayname[$i]); |
209 |
|
|
$cell->set_attribute (scope => 'col'); |
210 |
|
|
$cell->append_node ($wname[$i]); |
211 |
|
|
} |
212 |
|
|
} |
213 |
|
|
|
214 |
|
|
my $tb = $tbl->append_new_node |
215 |
|
|
(type => '#element', |
216 |
|
|
namespace_uri => $NS_XHTML1, |
217 |
|
|
local_name => 'tbody'); |
218 |
|
|
my $e_week; |
219 |
|
|
unless ($dow == 0) { ## 1st day is not sunday |
220 |
|
|
$e_week = $tb->append_new_node |
221 |
|
|
(type => '#element', |
222 |
|
|
namespace_uri => $NS_XHTML1, |
223 |
|
|
local_name => 'tr'); |
224 |
|
|
for (1..$dow) { |
225 |
|
|
$e_week->append_new_node |
226 |
|
|
(type => '#element', |
227 |
|
|
namespace_uri => $NS_XHTML1, |
228 |
|
|
local_name => 'td'); |
229 |
|
|
} |
230 |
|
|
} |
231 |
|
|
|
232 |
|
|
__ATTRTEXT:%day_label__; |
233 |
|
|
my $label = $p->{day_label} || $WIKIRESOURCE->get |
234 |
|
|
(name => 'Calender:Day:Label', |
235 |
|
|
o => $o, wiki => $o->{wiki}); |
236 |
|
|
__ATTRTEXT:%mode__; |
237 |
|
|
for my $day (1..$lom) { |
238 |
|
|
$e_week = $tb->append_new_node |
239 |
|
|
(type => '#element', |
240 |
|
|
namespace_uri => $NS_XHTML1, |
241 |
|
|
local_name => 'tr') |
242 |
|
|
if $dow == 0; ## New week |
243 |
|
|
my $e_day = $e_week->append_new_node |
244 |
|
|
(type => '#element', |
245 |
|
|
namespace_uri => $NS_XHTML1, |
246 |
|
|
local_name => 'td'); |
247 |
|
|
$e_day->set_attribute (class => $dayname[$dow]); |
248 |
|
|
$WIKILINKING->to_wikipage_in_html ({ |
249 |
|
|
label => $label, |
250 |
|
|
} => { |
251 |
|
|
base => $o->{wiki}->{var}->{page}, |
252 |
|
|
page_name_relative => __FUNCPACK__->date_to_wikiname |
253 |
|
|
(year => $year, |
254 |
|
|
month => $month, |
255 |
|
|
day => $day, |
256 |
|
|
base => $date->{base}, |
257 |
|
|
o => $o), |
258 |
|
|
wiki_mode => $p->{mode}, |
259 |
|
|
}, { |
260 |
|
|
o => $o, |
261 |
|
|
parent => $e_day, |
262 |
|
|
-cal__year => $year, |
263 |
|
|
-cal__month => $month, |
264 |
|
|
-cal__day => $day, |
265 |
|
|
}); |
266 |
|
|
$dow++; $dow = 0 if $dow == 7; |
267 |
|
|
} |
268 |
|
|
|
269 |
|
|
FormattingRule: |
270 |
|
|
@Category[list]: |
271 |
|
|
form-input |
272 |
|
|
view |
273 |
|
|
view-resource |
274 |
|
|
@Name: calender-months |
275 |
|
|
@Description: |
276 |
|
|
@@@: List of months in the year |
277 |
|
|
@@lang: en |
278 |
|
|
@Parameter: |
279 |
|
|
@@Name: label |
280 |
|
|
@@Type: template |
281 |
|
|
@@Default: (auto) |
282 |
|
|
@@Description: |
283 |
|
|
@@@@: Template to be used to construct month item |
284 |
|
|
@@@lang: en |
285 |
|
|
@Parameter: |
286 |
|
|
@@Name: year |
287 |
|
|
@@Type: <<4*DIGIT>> |
288 |
|
|
@@Default: (auto) |
289 |
|
|
@@Description: |
290 |
|
|
@@@@: Year |
291 |
|
|
@@@lang: en |
292 |
|
|
@Formatting: |
293 |
|
|
__ATTRTEXT:%year__; |
294 |
|
|
my $date = __FUNCPACK__->wikiname_to_date |
295 |
|
|
(name => $o->{wiki}->name ($p->{page} || |
296 |
|
|
$o->{wiki}->{var}->{page}), |
297 |
|
|
o => $o); |
298 |
|
|
my $year = $p->{year} || $date->{year} || (gmtime)[5] + 1900; |
299 |
|
|
my $list = $p->{-parent}->append_new_node |
300 |
|
|
(type => '#element', |
301 |
|
|
namespace_uri => $NS_XHTML1, |
302 |
|
|
local_name => 'ol'); |
303 |
|
|
$list->set_attribute (class => 'calender year'); |
304 |
|
|
|
305 |
|
|
__ATTRTEXT:%label__; |
306 |
|
|
my $label = $p->{label} || $WIKIRESOURCE->get |
307 |
|
|
(name => 'Calender:MonthList:Item', |
308 |
|
|
wiki => $o->{wiki}, o => $o); |
309 |
|
|
for (1..12) { |
310 |
|
|
$WIKILINKING->to_wikipage_in_html ({ |
311 |
|
|
label => $label, |
312 |
|
|
} => { |
313 |
|
|
base => $o->{wiki}->{var}->{page}, |
314 |
|
|
page_name_relative => __FUNCPACK__->date_to_wikiname |
315 |
|
|
(year => $year, |
316 |
|
|
month => $_, |
317 |
|
|
base => $date->{base}, |
318 |
|
|
o => $o), |
319 |
|
|
}, { |
320 |
|
|
o => $o, |
321 |
|
|
parent => $list->append_new_node |
322 |
|
|
(type => '#element', |
323 |
|
|
namespace_uri => $NS_XHTML1, |
324 |
|
|
local_name => 'li'), |
325 |
|
|
-cal__year => $year, |
326 |
|
|
-cal__month => $_, |
327 |
|
|
}); |
328 |
|
|
$list->append_text ("\n"); |
329 |
|
|
} |
330 |
|
|
|
331 |
|
|
FormattingRule: |
332 |
|
|
@Category[list]: |
333 |
|
|
page-link |
334 |
|
|
view-resource |
335 |
|
|
@Name: calender--year |
336 |
|
|
@Description: |
337 |
|
|
@@@: Year number |
338 |
|
|
@@lang: en |
339 |
|
|
@Formatting: |
340 |
|
|
$p->{-parent}->append_text ($o->{link}->{option}->{-cal__year} + 0); |
341 |
|
|
|
342 |
|
|
FormattingRule: |
343 |
|
|
@Category[list]: |
344 |
|
|
page-link |
345 |
|
|
view-resource |
346 |
|
|
@Name: calender--month |
347 |
|
|
@Description: |
348 |
|
|
@@@: Month number |
349 |
|
|
@@lang: en |
350 |
|
|
@Formatting: |
351 |
|
|
$p->{-parent}->append_text ($o->{link}->{option}->{-cal__month} + 0); |
352 |
|
|
|
353 |
|
|
FormattingRule: |
354 |
|
|
@Category[list]: |
355 |
|
|
page-link |
356 |
|
|
view-resource |
357 |
|
|
@Name: |
358 |
|
|
calender--day |
359 |
|
|
@Description: |
360 |
|
|
@@@: Day number |
361 |
|
|
@@lang: en |
362 |
|
|
@Formatting: |
363 |
|
|
$p->{-parent}->append_text ($o->{link}->{option}->{-cal__day} + 0); |
364 |
|
|
|
365 |
|
|
FormattingRule: |
366 |
|
|
@Category[list]: |
367 |
|
|
view |
368 |
|
|
view-resource |
369 |
|
|
form-input |
370 |
|
|
@Name: cal--year-page |
371 |
|
|
@Description: |
372 |
|
|
@@@: Year WikiPage name |
373 |
|
|
@@lang: en |
374 |
|
|
@Parameter: |
375 |
|
|
@@Name: page |
376 |
|
|
@@Type: WikiName |
377 |
|
|
@@Default: (auto) |
378 |
|
|
@@Description: |
379 |
|
|
@@@@: Some WikiPage in calender |
380 |
|
|
@@@lang: en |
381 |
|
|
@Parameter: |
382 |
|
|
@@Name: year |
383 |
|
|
@@Type: <<4*DIGIT>> |
384 |
|
|
@@Default: (auto) |
385 |
|
|
@@Description: |
386 |
|
|
@@@@: Year number |
387 |
|
|
@@@lang: en |
388 |
|
|
@Formatting: |
389 |
|
|
my $page = $o->{wiki}->name ($p->{page} or $o->{wiki}->{var}->{page}); |
390 |
|
|
my $date = __FUNCPACK__->wikiname_to_date (name => $page, o => $o); |
391 |
|
|
$p->{-parent}->append_text (__FUNCPACK__->date_to_wikiname |
392 |
|
|
(base => $date->{base}, |
393 |
|
|
year => $date->{year}, |
394 |
|
|
o => $o)->stringify (wiki => $o->{wiki})); |
395 |
|
|
|
396 |
|
|
FormattingRule: |
397 |
|
|
@Category[list]: |
398 |
|
|
view |
399 |
|
|
view-resource |
400 |
|
|
form-input |
401 |
|
|
@Name: cal--month-page |
402 |
|
|
@Description: |
403 |
|
|
@@@: Year-month WikiPage name |
404 |
|
|
@@lang: en |
405 |
|
|
@Parameter: |
406 |
|
|
@@Name: month |
407 |
|
|
@@Type: <<1*2DIGIT>> |
408 |
|
|
@@Default: (auto) |
409 |
|
|
@@Description: |
410 |
|
|
@@@@: Month number |
411 |
|
|
@@@lang: en |
412 |
|
|
@Parameter: |
413 |
|
|
@@Name: page |
414 |
|
|
@@Type: WikiName |
415 |
|
|
@@Default: (auto) |
416 |
|
|
@@Description: |
417 |
|
|
@@@@: Some WikiPage in calender |
418 |
|
|
@@@lang: en |
419 |
|
|
@Parameter: |
420 |
|
|
@@Name: year |
421 |
|
|
@@Type: <<4*DIGIT>> |
422 |
|
|
@@Default: (auto) |
423 |
|
|
@@Description: |
424 |
|
|
@@@@: Year number |
425 |
|
|
@@@lang: en |
426 |
|
|
@Formatting: |
427 |
|
|
my $page = $o->{wiki}->name ($p->{page} or $o->{wiki}->{var}->{page}); |
428 |
|
|
my $date = __FUNCPACK__->wikiname_to_date (name => $page, o => $o); |
429 |
|
|
$p->{-parent}->append_text (__FUNCPACK__->date_to_wikiname |
430 |
|
|
(base => $date->{base}, |
431 |
|
|
year => $p->{year} || $date->{year}, |
432 |
|
|
month => $p->{month} || $date->{month}, |
433 |
|
|
o => $o)->stringify (wiki => $o->{wiki})); |
434 |
|
|
|
435 |
|
|
FormattingRule: |
436 |
|
|
@Category[list]: |
437 |
|
|
view |
438 |
|
|
view-resource |
439 |
|
|
form-input |
440 |
|
|
@Name: cal--day-page |
441 |
|
|
@Description: |
442 |
|
|
@@@: Year-month-day WikiPage name |
443 |
|
|
@@lang: en |
444 |
|
|
@Parameter: |
445 |
|
|
@@Name: day |
446 |
|
|
@@Type: <<1*2DIGIT>> |
447 |
|
|
@@Default: (auto) |
448 |
|
|
@@Description: |
449 |
|
|
@@@@: Day number |
450 |
|
|
@@@lang: en |
451 |
|
|
@Parameter: |
452 |
|
|
@@Name: month |
453 |
|
|
@@Type: <<1*2DIGIT>> |
454 |
|
|
@@Default: (auto) |
455 |
|
|
@@Description: |
456 |
|
|
@@@@: Month number |
457 |
|
|
@@@lang: en |
458 |
|
|
@Parameter: |
459 |
|
|
@@Name: page |
460 |
|
|
@@Type: WikiName |
461 |
|
|
@@Default: (auto) |
462 |
|
|
@@Description: |
463 |
|
|
@@@@: Some WikiPage in calender |
464 |
|
|
@@@lang: en |
465 |
|
|
@Parameter: |
466 |
|
|
@@Name: year |
467 |
|
|
@@Type: <<4*DIGIT>> |
468 |
|
|
@@Default: (auto) |
469 |
|
|
@@Description: |
470 |
|
|
@@@@: Year number |
471 |
|
|
@@@lang: en |
472 |
|
|
@Formatting: |
473 |
|
|
my $page = $o->{wiki}->name ($p->{page} or $o->{wiki}->{var}->{page}); |
474 |
|
|
my $date = __FUNCPACK__->wikiname_to_date (name => $page, o => $o); |
475 |
|
|
$p->{-parent}->append_text (__FUNCPACK__->date_to_wikiname |
476 |
|
|
(base => $date->{base}, |
477 |
|
|
year => $p->{year} || $date->{year}, |
478 |
|
|
month => $p->{month} || $date->{month}, |
479 |
|
|
day => $p->{day} || $date->{day}, |
480 |
|
|
o => $o)->stringify (wiki => $o->{wiki})); |
481 |
|
|
|
482 |
|
|
FormattingRule: |
483 |
|
|
@Category[list]: |
484 |
|
|
view |
485 |
|
|
@Name: |
486 |
|
|
link-calender-date |
487 |
|
|
@Description: |
488 |
|
|
@@@: Link to previous/next calender WikiPage |
489 |
|
|
@@lang: en |
490 |
|
|
@Formatting: |
491 |
|
|
my $page = $o->{wiki}->name ($p->{page} or $o->{wiki}->{var}->{page}); |
492 |
|
|
my $date = __FUNCPACK__->wikiname_to_date (name => $page, o => $o); |
493 |
|
|
my $year = $p->{year} || $date->{year} || return; |
494 |
|
|
my $month = $p->{month} || $date->{month}; |
495 |
|
|
my $day = $p->{day} || $date->{day}; |
496 |
|
|
|
497 |
|
|
my ($Year, $Month, $Day) = (0, 0, 0); |
498 |
|
|
my ($yeaR, $montH, $daY) = (0, 0, 0); |
499 |
|
|
my %page; |
500 |
|
|
if ($day) { ## 2003-04-01 |
501 |
|
|
require Time::Local; |
502 |
|
|
(undef, undef, undef, $Day, $Month, $Year) |
503 |
|
|
= gmtime (Time::Local::timegm_nocheck (0,0,0,$day, $month - 1, $year) |
504 |
|
|
- 24 * 3600); |
505 |
|
|
$Month++; $Year += 1900; |
506 |
|
|
$page{prev} = {year => $Year, month => $Month, day => $Day}; |
507 |
|
|
(undef, undef, undef, $daY, $montH, $yeaR) |
508 |
|
|
= gmtime (Time::Local::timegm_nocheck (0,0,0,$day, $month - 1, $year) |
509 |
|
|
+ 25 * 3600); |
510 |
|
|
$montH++; $yeaR += 1900; |
511 |
|
|
$page{next} = {year => $yeaR, month => $montH, day => $daY}; |
512 |
|
|
$page{up} = {year => $year, month => $month}; |
513 |
|
|
(undef, undef, undef, $Day, $Month, $Year) |
514 |
|
|
= gmtime (Time::Local::timegm_nocheck (0,0,0,$day, $month - 1, $year) |
515 |
|
|
- 7 * 24 * 3600); |
516 |
|
|
$Month++; $Year += 1900; |
517 |
|
|
$page{'prev-week'} = {year => $Year, month => $Month, day => $Day}; |
518 |
|
|
(undef, undef, undef, $daY, $montH, $yeaR) |
519 |
|
|
= gmtime (Time::Local::timegm_nocheck (0,0,0,$day, $month - 1, $year) |
520 |
|
|
+ 7 * 25 * 3600); |
521 |
|
|
$montH++; $yeaR += 1900; |
522 |
|
|
$page{'next-week'} = {year => $yeaR, month => $montH, day => $daY}; |
523 |
|
|
} elsif ($month) { ## 2003-04 |
524 |
|
|
($Year, $Month) = ($year, $month - 1); |
525 |
|
|
($Month = 12, $Year--) if $Month == 0; |
526 |
|
|
$page{prev} = {year => $Year, month => $Month}; |
527 |
|
|
($yeaR, $montH) = ($year, $month + 1); |
528 |
|
|
($montH = 1, $yeaR++) if $montH == 13; |
529 |
|
|
$page{next} = {year => $yeaR, month => $montH}; |
530 |
|
|
$page{up} = {year => $year}; |
531 |
|
|
} else { ## 2003 |
532 |
|
|
$Year = $year - 1; |
533 |
|
|
$page{prev} = {year => $Year}; |
534 |
|
|
$yeaR = $year + 1; |
535 |
|
|
$page{next} = {year => $yeaR}; |
536 |
|
|
} |
537 |
|
|
|
538 |
|
|
__ATTRTEXT:%mode__;__ATTRTEXT:%with_lm__;__ATTRTEXT:%up_to_date__; |
539 |
|
|
for my $rel (qw/prev next up prev-week next-week/) { |
540 |
|
|
next unless $page{$rel}; |
541 |
|
|
$WIKILINKING->to_wikipage_in_html ({ |
542 |
|
|
label => qq(%html-link;\n), |
543 |
|
|
-ht__alt_description |
544 |
|
|
=> $WIKIRESOURCE->get |
545 |
|
|
(name => 'Calender:Link:'.$rel |
546 |
|
|
.($page{$rel}->{day}?':ymd': |
547 |
|
|
$page{$rel}->{month}?':ym':':y') |
548 |
|
|
.':Description', |
549 |
|
|
o => $o, wiki => $o->{wiki}), |
550 |
|
|
} => { |
551 |
|
|
base => $page, |
552 |
|
|
page_name_relative => __FUNCPACK__->date_to_wikiname |
553 |
|
|
(base => $date->{base}, o => $o, |
554 |
|
|
%{$page{$rel}}), |
555 |
|
|
wiki_mode => $p->{mode}, |
556 |
|
|
_with_lm => $p->{with_lm}, |
557 |
|
|
_up_to_date => $p->{up_to_date}, |
558 |
|
|
}, { |
559 |
|
|
o => $o, |
560 |
|
|
parent => $p->{-parent}, |
561 |
|
|
-rel => $rel, |
562 |
|
|
-cal__year => $page{$rel}->{year}, |
563 |
|
|
-cal__month => $page{$rel}->{month}, |
564 |
|
|
-cal__day => $page{$rel}->{day}, |
565 |
|
|
}); |
566 |
|
|
} |
567 |
|
|
|
568 |
|
|
|
569 |
|
|
Function: |
570 |
|
|
@Name: wikiname_to_date |
571 |
|
|
@Description: |
572 |
|
|
@@@: |
573 |
|
|
Return what time is the WikiPage means, if it is part of calender. |
574 |
|
|
@@lang: en |
575 |
|
|
@Main: |
576 |
|
|
my (undef, %opt) = @_; |
577 |
|
|
if ($opt{name}->[$#{$opt{name}}] |
578 |
|
|
=~ /^([0-9]{4,})(?:-([0-9][0-9])(?:-([0-9][0-9]))?)?$/) { |
579 |
|
|
{year => $1, month => $2, day => $3, |
580 |
|
|
base => $opt{o}->{wiki}->name |
581 |
|
|
([@{$opt{name}}[0..$#{$opt{name}}-1]])}; |
582 |
|
|
} else { |
583 |
|
|
{base => $opt{name}}; |
584 |
|
|
} |
585 |
|
|
|
586 |
|
|
Function: |
587 |
|
|
@Name: date_to_wikiname |
588 |
wakaba |
1.3 |
@Description: |
589 |
|
|
@@@: Generates WikiName from date |
590 |
|
|
@@lang: en |
591 |
wakaba |
1.1 |
@Main: |
592 |
|
|
my (undef, %opt) = @_; |
593 |
|
|
my $date = sprintf '%04d', $opt{year}; |
594 |
wakaba |
1.3 |
if ($opt{month}) { |
595 |
|
|
$date .= sprintf '-%02d', $opt{month}; |
596 |
|
|
$date .= sprintf '-%02d', $opt{day} if $opt{day}; |
597 |
|
|
} |
598 |
wakaba |
1.1 |
my $clone = $opt{base}->clone; |
599 |
|
|
$clone->append_component ($date); |
600 |
|
|
$clone; |
601 |
|
|
|
602 |
|
|
ViewFragment: |
603 |
|
|
@Template[list]:wr--read-body |
604 |
|
|
@Order: -10 |
605 |
|
|
@Description: |
606 |
|
|
@@@: "Read" mode body -- Calender |
607 |
|
|
@@lang:en |
608 |
|
|
@Formatting: |
609 |
|
|
%if-calender ( |
610 |
|
|
month => {%calender;}p, |
611 |
|
|
year => {%calender-months;}p, |
612 |
|
|
); |
613 |
|
|
|
614 |
|
|
ViewFragment: |
615 |
|
|
@Template[list]: links |
616 |
|
|
@Order: -100 |
617 |
|
|
@Description: |
618 |
|
|
@@@: Link to previous/next WikiPage in calender |
619 |
|
|
@@lang:en |
620 |
|
|
@Formatting: |
621 |
|
|
%link-calender-date; |
622 |
|
|
|
623 |
|
|
Resource: |
624 |
|
|
@Calender:Day:Label: |
625 |
|
|
%link-to-it ( |
626 |
|
|
label => {%calender--day;}p, |
627 |
|
|
description=>{%page-name(absolute);; %if-linked-wikipage-exist( |
628 |
|
|
true=>{%page-headline;}, |
629 |
|
|
false=>{(%res(name=>{Link:toWikiPage:NotExist:Description});)}, |
630 |
|
|
);}p, |
631 |
|
|
class=>{%if-linked-wikipage-exist(false=>{not-exist});}p, |
632 |
|
|
); |
633 |
|
|
@Calender:Link:prev:y:Description: |
634 |
|
|
%calender--year; (%page-name;) |
635 |
|
|
@Calender:Link:next:y:Description: |
636 |
|
|
%calender--year; (%page-name;) |
637 |
|
|
@Calender:Link:up:y:Description: |
638 |
|
|
%calender--year; (%page-name;) |
639 |
|
|
@Calender:Link:prev:ym:Description: |
640 |
|
|
%calender--year;-%calender--month; (%page-name;) |
641 |
|
|
@Calender:Link:next:ym:Description: |
642 |
|
|
%calender--year;-%calender--month; (%page-name;) |
643 |
|
|
@Calender:Link:up:ym:Description: |
644 |
|
|
%calender--year;-%calender--month; (%page-name;) |
645 |
|
|
@Calender:Link:prev:ymd:Description: |
646 |
|
|
%calender--year;-%calender--month;-%calender--day; (%page-name;) |
647 |
|
|
@Calender:Link:next:ymd:Description: |
648 |
|
|
%calender--year;-%calender--month;-%calender--day; (%page-name;) |
649 |
|
|
@Calender:Link:prev-week:ymd:Description: |
650 |
|
|
%calender--year;-%calender--month;-%calender--day; (%page-name;) |
651 |
|
|
@Calender:Link:next-week:ymd:Description: |
652 |
|
|
%calender--year;-%calender--month;-%calender--day; (%page-name;) |
653 |
|
|
@Calender:MonthList:Item: |
654 |
|
|
%link-to-it ( |
655 |
|
|
label => {%calender--month;}p, |
656 |
|
|
description=>{%page-name(absolute);; %if-linked-wikipage-exist( |
657 |
|
|
true=>{%page-headline;}, |
658 |
|
|
false=>{(%res(name=>{Link:toWikiPage:NotExist:Description});)}, |
659 |
|
|
);}p, |
660 |
|
|
class=>{%if-linked-wikipage-exist(false=>{not-exist});}p, |
661 |
|
|
); |
662 |
|
|
@Calender:Table:Caption: |
663 |
|
|
%link-to-wikipage ( |
664 |
|
|
label => {%percent;link-to-it (label => {%calender--year;});}p, |
665 |
|
|
page => {%cal--year-page;}p, |
666 |
|
|
rel => {up up}, |
667 |
|
|
);-%link-to-wikipage ( |
668 |
|
|
label => {%percent;link-to-it (label => {%calender--month;});}p, |
669 |
|
|
page => {%cal--month-page;}p, |
670 |
|
|
rel => {up}, |
671 |
|
|
); |
672 |
|
|
@Calender:Table:Summary: |
673 |
|
|
@@@: |
674 |
|
|
A calender. Days are listed with columns assigned to days in week |
675 |
|
|
(i.e. Sunday, Monday, ..., and Saturday) |
676 |
|
|
@@lang: en |
677 |
|
|
@Calender:Weekday:Long:sun: |
678 |
|
|
@@@: Sunday |
679 |
|
|
@@lang: en |
680 |
|
|
@Calender:Weekday:Long:mon: |
681 |
|
|
@@@: Monday |
682 |
|
|
@@lang: en |
683 |
|
|
@Calender:Weekday:Long:tue: |
684 |
|
|
@@@: Tuesday |
685 |
|
|
@@lang: en |
686 |
|
|
@Calender:Weekday:Long:wed: |
687 |
|
|
@@@: Wednesday |
688 |
|
|
@@lang: en |
689 |
|
|
@Calender:Weekday:Long:thu: |
690 |
|
|
@@@: Thursday |
691 |
|
|
@@lang: en |
692 |
|
|
@Calender:Weekday:Long:fri: |
693 |
|
|
@@@: Friday |
694 |
|
|
@@lang: en |
695 |
|
|
@Calender:Weekday:Long:sat: |
696 |
|
|
@@@: Saturday |
697 |
|
|
@@lang: en |
698 |
|
|
@Calender:Weekday:Short:sun: |
699 |
|
|
@@@: Sun |
700 |
|
|
@@lang: en |
701 |
|
|
@Calender:Weekday:Short:mon: |
702 |
|
|
@@@: Mon |
703 |
|
|
@@lang: en |
704 |
|
|
@Calender:Weekday:Short:tue: |
705 |
|
|
@@@: Tue |
706 |
|
|
@@lang: en |
707 |
|
|
@Calender:Weekday:Short:wed: |
708 |
|
|
@@@: Wed |
709 |
|
|
@@lang: en |
710 |
|
|
@Calender:Weekday:Short:thu: |
711 |
|
|
@@@: Thu |
712 |
|
|
@@lang: en |
713 |
|
|
@Calender:Weekday:Short:fri: |
714 |
|
|
@@@: Fri |
715 |
|
|
@@lang: en |
716 |
|
|
@Calender:Weekday:Short:sat: |
717 |
|
|
@@@: Sat |
718 |
|
|
@@lang: en |
719 |
|
|
@Calender:Weekday:Label:sun: |
720 |
|
|
%abbr ( |
721 |
|
|
short => {%res (name => {Calender:Weekday:Short:sun});}p, |
722 |
|
|
long => {%res (name => {Calender:Weekday:Long:sun});}p, |
723 |
|
|
); |
724 |
|
|
@Calender:Weekday:Label:mon: |
725 |
|
|
%abbr ( |
726 |
|
|
short => {%res (name => {Calender:Weekday:Short:mon});}p, |
727 |
|
|
long => {%res (name => {Calender:Weekday:Long:mon});}p, |
728 |
|
|
); |
729 |
|
|
@Calender:Weekday:Label:tue: |
730 |
|
|
%abbr ( |
731 |
|
|
short => {%res (name => {Calender:Weekday:Short:tue});}p, |
732 |
|
|
long => {%res (name => {Calender:Weekday:Long:tue});}p, |
733 |
|
|
); |
734 |
|
|
@Calender:Weekday:Label:wed: |
735 |
|
|
%abbr ( |
736 |
|
|
short => {%res (name => {Calender:Weekday:Short:wed});}p, |
737 |
|
|
long => {%res (name => {Calender:Weekday:Long:wed});}p, |
738 |
|
|
); |
739 |
|
|
@Calender:Weekday:Label:thu: |
740 |
|
|
%abbr ( |
741 |
|
|
short => {%res (name => {Calender:Weekday:Short:thu});}p, |
742 |
|
|
long => {%res (name => {Calender:Weekday:Long:thu});}p, |
743 |
|
|
); |
744 |
|
|
@Calender:Weekday:Label:fri: |
745 |
|
|
%abbr ( |
746 |
|
|
short => {%res (name => {Calender:Weekday:Short:fri});}p, |
747 |
|
|
long => {%res (name => {Calender:Weekday:Long:fri});}p, |
748 |
|
|
); |
749 |
|
|
@Calender:Weekday:Label:sat: |
750 |
|
|
%abbr ( |
751 |
|
|
short => {%res (name => {Calender:Weekday:Short:sat});}p, |
752 |
|
|
long => {%res (name => {Calender:Weekday:Long:sat});}p, |
753 |
|
|
); |
754 |
|
|
|
755 |
|
|
|
756 |
|
|
|