1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* You may not change or alter any portion of this comment or credits |
4
|
|
|
* of supporting developers from this source code or any supporting source code |
5
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
6
|
|
|
* |
7
|
|
|
* This program is distributed in the hope that it will be useful, |
8
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
9
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @copyright {@link http://xoops.org/ XOOPS Project} |
14
|
|
|
* @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license} |
15
|
|
|
* @package |
16
|
|
|
* @since |
17
|
|
|
* @author XOOPS Development Team, |
18
|
|
|
* @author Antiques Promotion (http://www.antiquespromotion.ca) |
19
|
|
|
* @author GIJ=CHECKMATE (PEAK Corp. http://www.peak.ne.jp/) |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
if (!defined('APCAL_BLOCK_MINI_CALENDAR_INCLUDED')) { |
23
|
|
|
define('APCAL_BLOCK_MINI_CALENDAR_INCLUDED', 1); |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @param $options |
27
|
|
|
* @return array |
28
|
|
|
*/ |
29
|
|
|
function apcal_mini_calendar_show($options) |
30
|
|
|
{ |
31
|
|
|
global $xoopsConfig, $xoopsDB, $xoopsUser; |
32
|
|
|
|
33
|
|
|
$moduleDirName = empty($options[0]) ? basename(dirname(__DIR__)) : $options[0]; |
34
|
|
|
|
35
|
|
|
// caldate ¤äÆüÉÕ¥¸¥ã¥ó¥×¤Î»ØÄ̵꤬¤¯¡ÊÅö·î¤Î¥Ç¥Õ¥©¥ë¥È¥ß¥Ë¥«¥ì¥ó¥À¡¼É½¼¨¡Ë |
36
|
|
|
// ¤«¤Ä¡¢¥æ¡¼¥¶¤ÎTimezone¤¬defaultTZ¤È°ì½ï¡Ê°ìÈÖ¿¤½¤¦¤Ê¥·¥Á¥å¥¨¡¼¥·¥ç¥ó¡Ë¤Î |
37
|
|
|
// ¾ì¹ç¤Ë¤Ï¡¢¥¥ã¥Ã¥·¥å¤ò»È¤¦ |
38
|
|
|
if (empty($_GET['caldate']) && empty($_POST['apcal_jumpcaldate']) |
39
|
|
|
&& (!is_object($xoopsUser) |
40
|
|
|
|| $xoopsUser->timezone() == $xoopsConfig['default_TZ']) |
41
|
|
|
) { |
42
|
|
|
$use_cache = true; |
43
|
|
|
$cachefile = XOOPS_CACHE_PATH . "/{$moduleDirName }_minical_cache_{$xoopsConfig['language']}.html"; |
44
|
|
|
// 5 minutes |
45
|
|
|
if (file_exists($cachefile) && filemtime($cachefile) > time() - 300) { |
46
|
|
|
if (false !== $fp = fopen($cachefile, 'r')) { |
47
|
|
|
$block['content'] = ''; |
|
|
|
|
48
|
|
|
while (!feof($fp)) { |
49
|
|
|
$block['content'] .= fgets($fp, 4096); |
50
|
|
|
} |
51
|
|
|
fclose($fp); |
52
|
|
|
|
53
|
|
|
return $block; |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
} else { |
57
|
|
|
$use_cache = false; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
// setting physical & virtual paths |
61
|
|
|
$mod_path = XOOPS_ROOT_PATH . "/modules/$moduleDirName"; |
62
|
|
|
$mod_url = XOOPS_URL . "/modules/$moduleDirName"; |
63
|
|
|
|
64
|
|
|
// defining class of APCal |
65
|
|
|
if (!class_exists('APCal_xoops')) { |
66
|
|
|
require_once "$mod_path/class/APCal.php"; |
67
|
|
|
require_once "$mod_path/class/APCal_xoops.php"; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
// creating an instance of APCal |
71
|
|
|
$cal = new APCal_xoops('', $xoopsConfig['language'], true); |
72
|
|
|
|
73
|
|
|
// ignoring cid from GET |
74
|
|
|
$cal->now_cid = 0; |
75
|
|
|
|
76
|
|
|
// setting properties of APCal |
77
|
|
|
$cal->conn = $GLOBALS['xoopsDB']->conn; |
78
|
|
|
include "$mod_path/include/read_configs.php"; |
79
|
|
|
$cal->base_url = $mod_url; |
80
|
|
|
$cal->base_path = $mod_path; |
81
|
|
|
$cal->images_url = "$mod_url/assets/images/$skin_folder"; |
|
|
|
|
82
|
|
|
$cal->images_path = "$mod_path/assets/images/$skin_folder"; |
83
|
|
|
|
84
|
|
|
switch ($mini_calendar_target) { |
|
|
|
|
85
|
|
|
case 'MONTHLY': |
86
|
|
|
$get_target = "$mod_url/index.php"; |
87
|
|
|
$query_string = 'smode=Monthly'; |
88
|
|
|
break; |
89
|
|
|
case 'WEEKLY': |
90
|
|
|
$get_target = "$mod_url/index.php"; |
91
|
|
|
$query_string = 'smode=Weekly'; |
92
|
|
|
break; |
93
|
|
|
case 'DAILY': |
94
|
|
|
$get_target = "$mod_url/index.php"; |
95
|
|
|
$query_string = 'smode=Daily'; |
96
|
|
|
break; |
97
|
|
|
case 'LIST': |
98
|
|
|
$get_target = "$mod_url/index.php"; |
99
|
|
|
$query_string = 'smode=List'; |
100
|
|
|
break; |
101
|
|
|
default: |
102
|
|
|
case 'PHP_SELF': |
|
|
|
|
103
|
|
|
$get_target = ''; |
104
|
|
|
$query_string = ''; |
105
|
|
|
break; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
$block = array(); |
109
|
|
|
$block['content'] = $cal->get_mini_calendar_html($get_target, $query_string); |
110
|
|
|
|
111
|
|
|
// ¥¥ã¥Ã¥·¥å¤Î½ñ¤½Ð¤· |
112
|
|
|
if ($use_cache && $mini_calendar_target !== 'PHP_SELF') { |
113
|
|
|
if (false !== $fp = fopen($cachefile, 'w')) { |
|
|
|
|
114
|
|
|
fwrite($fp, $block['content']); |
115
|
|
|
fclose($fp); |
116
|
|
|
} |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
return $block; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @param $options |
124
|
|
|
* @return string |
125
|
|
|
*/ |
126
|
|
|
function apcal_mini_calendar_edit($options) |
|
|
|
|
127
|
|
|
{ |
128
|
|
|
return ''; |
129
|
|
|
} |
130
|
|
|
} |
131
|
|
|
|
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.
Let’s take a look at an example:
As you can see in this example, the array
$myArray
is initialized the first time when the foreach loop is entered. You can also see that the value of thebar
key is only written conditionally; thus, its value might result from a previous iteration.This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.