@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | |
20 | 20 | function xoops_module_pre_uninstall_newbb(\XoopsModule $module) |
21 | 21 | { |
22 | - // Do some synchronization |
|
23 | - return true; |
|
22 | + // Do some synchronization |
|
23 | + return true; |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
@@ -32,36 +32,36 @@ discard block |
||
32 | 32 | */ |
33 | 33 | function xoops_module_uninstall_newbb(\XoopsModule $module) |
34 | 34 | { |
35 | - // return true; |
|
35 | + // return true; |
|
36 | 36 | |
37 | - $moduleDirName = basename(dirname(__DIR__)); |
|
38 | - $moduleDirNameUpper = strtoupper($moduleDirName); |
|
39 | - /** @var \XoopsModules\Newbb\Helper $helper */ |
|
40 | - $helper = \XoopsModules\Newbb\Helper::getInstance(); |
|
37 | + $moduleDirName = basename(dirname(__DIR__)); |
|
38 | + $moduleDirNameUpper = strtoupper($moduleDirName); |
|
39 | + /** @var \XoopsModules\Newbb\Helper $helper */ |
|
40 | + $helper = \XoopsModules\Newbb\Helper::getInstance(); |
|
41 | 41 | |
42 | - /** @var Newbb\Utility $utility */ |
|
43 | - $utility = new \XoopsModules\Newbb\Utility(); |
|
42 | + /** @var Newbb\Utility $utility */ |
|
43 | + $utility = new \XoopsModules\Newbb\Utility(); |
|
44 | 44 | |
45 | - $success = true; |
|
46 | - $helper->loadLanguage('admin'); |
|
45 | + $success = true; |
|
46 | + $helper->loadLanguage('admin'); |
|
47 | 47 | |
48 | - //------------------------------------------------------------------ |
|
49 | - // Remove uploads folder (and all subfolders) if they exist |
|
50 | - //------------------------------------------------------------------ |
|
48 | + //------------------------------------------------------------------ |
|
49 | + // Remove uploads folder (and all subfolders) if they exist |
|
50 | + //------------------------------------------------------------------ |
|
51 | 51 | |
52 | - $old_directories = [$GLOBALS['xoops']->path("uploads/{$moduleDirName}")]; |
|
53 | - foreach ($old_directories as $old_dir) { |
|
54 | - $dirInfo = new \SplFileInfo($old_dir); |
|
55 | - if ($dirInfo->isDir()) { |
|
56 | - // The directory exists so delete it |
|
57 | - if (false === $utility::rrmdir($old_dir)) { |
|
58 | - $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_DEL_PATH'), $old_dir)); |
|
59 | - $success = false; |
|
60 | - } |
|
61 | - } |
|
62 | - unset($dirInfo); |
|
63 | - } |
|
64 | - /* |
|
52 | + $old_directories = [$GLOBALS['xoops']->path("uploads/{$moduleDirName}")]; |
|
53 | + foreach ($old_directories as $old_dir) { |
|
54 | + $dirInfo = new \SplFileInfo($old_dir); |
|
55 | + if ($dirInfo->isDir()) { |
|
56 | + // The directory exists so delete it |
|
57 | + if (false === $utility::rrmdir($old_dir)) { |
|
58 | + $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_DEL_PATH'), $old_dir)); |
|
59 | + $success = false; |
|
60 | + } |
|
61 | + } |
|
62 | + unset($dirInfo); |
|
63 | + } |
|
64 | + /* |
|
65 | 65 | //------------ START ---------------- |
66 | 66 | //------------------------------------------------------------------ |
67 | 67 | // Remove xsitemap.xml from XOOPS root folder if it exists |
@@ -75,6 +75,6 @@ discard block |
||
75 | 75 | // return $success && $delOk; // use this if you're using this routine |
76 | 76 | */ |
77 | 77 | |
78 | - return $success; |
|
79 | - //------------ END ---------------- |
|
78 | + return $success; |
|
79 | + //------------ END ---------------- |
|
80 | 80 | } |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | { |
35 | 35 | // return true; |
36 | 36 | |
37 | - $moduleDirName = basename(dirname(__DIR__)); |
|
38 | - $moduleDirNameUpper = strtoupper($moduleDirName); |
|
37 | + $moduleDirName = basename(dirname(__DIR__)); |
|
38 | + $moduleDirNameUpper = strtoupper($moduleDirName); |
|
39 | 39 | /** @var \XoopsModules\Newbb\Helper $helper */ |
40 | 40 | $helper = \XoopsModules\Newbb\Helper::getInstance(); |
41 | 41 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | if ($dirInfo->isDir()) { |
56 | 56 | // The directory exists so delete it |
57 | 57 | if (false === $utility::rrmdir($old_dir)) { |
58 | - $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_DEL_PATH'), $old_dir)); |
|
58 | + $module->setErrors(sprintf(constant('CO_'.$moduleDirNameUpper.'_ERROR_BAD_DEL_PATH'), $old_dir)); |
|
59 | 59 | $success = false; |
60 | 60 | } |
61 | 61 | } |
@@ -17,101 +17,101 @@ |
||
17 | 17 | define('NEWBB_FUNCTIONS_SESSION_LOADED', true); |
18 | 18 | |
19 | 19 | if (!defined('NEWBB_FUNCTIONS_SESSION')) { |
20 | - define('NEWBB_FUNCTIONS_SESSION', 1); |
|
20 | + define('NEWBB_FUNCTIONS_SESSION', 1); |
|
21 | 21 | |
22 | - /* |
|
22 | + /* |
|
23 | 23 | * Currently the newbb session/cookie handlers are limited to: |
24 | 24 | * -- one dimension |
25 | 25 | * -- "," and "|" are preserved |
26 | 26 | * |
27 | 27 | */ |
28 | - /** |
|
29 | - * @param $name |
|
30 | - * @param string|array $string |
|
31 | - */ |
|
32 | - function newbbSetSession($name, $string = '') |
|
33 | - { |
|
34 | - if (is_array($string)) { |
|
35 | - $value = []; |
|
36 | - foreach ($string as $key => $val) { |
|
37 | - $value[] = $key . '|' . $val; |
|
38 | - } |
|
39 | - $string = implode(',', $value); |
|
40 | - } |
|
41 | - $_SESSION['newbb_' . $name] = $string; |
|
42 | - } |
|
28 | + /** |
|
29 | + * @param $name |
|
30 | + * @param string|array $string |
|
31 | + */ |
|
32 | + function newbbSetSession($name, $string = '') |
|
33 | + { |
|
34 | + if (is_array($string)) { |
|
35 | + $value = []; |
|
36 | + foreach ($string as $key => $val) { |
|
37 | + $value[] = $key . '|' . $val; |
|
38 | + } |
|
39 | + $string = implode(',', $value); |
|
40 | + } |
|
41 | + $_SESSION['newbb_' . $name] = $string; |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * @param $name |
|
46 | - * @param bool $isArray |
|
47 | - * @return array|bool |
|
48 | - */ |
|
49 | - function newbbGetSession($name, $isArray = false) |
|
50 | - { |
|
51 | - $value = !empty($_SESSION['newbb_' . $name]) ? $_SESSION['newbb_' . $name] : false; |
|
52 | - if ($isArray) { |
|
53 | - $_value = $value ? explode(',', $value) : []; |
|
54 | - $value = []; |
|
55 | - if (count($_value) > 0) { |
|
56 | - foreach ($_value as $string) { |
|
57 | - $key = substr($string, 0, strpos($string, '|')); |
|
58 | - $val = substr($string, strpos($string, '|') + 1); |
|
59 | - $value[$key] = $val; |
|
60 | - } |
|
61 | - } |
|
62 | - unset($_value); |
|
63 | - } |
|
44 | + /** |
|
45 | + * @param $name |
|
46 | + * @param bool $isArray |
|
47 | + * @return array|bool |
|
48 | + */ |
|
49 | + function newbbGetSession($name, $isArray = false) |
|
50 | + { |
|
51 | + $value = !empty($_SESSION['newbb_' . $name]) ? $_SESSION['newbb_' . $name] : false; |
|
52 | + if ($isArray) { |
|
53 | + $_value = $value ? explode(',', $value) : []; |
|
54 | + $value = []; |
|
55 | + if (count($_value) > 0) { |
|
56 | + foreach ($_value as $string) { |
|
57 | + $key = substr($string, 0, strpos($string, '|')); |
|
58 | + $val = substr($string, strpos($string, '|') + 1); |
|
59 | + $value[$key] = $val; |
|
60 | + } |
|
61 | + } |
|
62 | + unset($_value); |
|
63 | + } |
|
64 | 64 | |
65 | - return $value; |
|
66 | - } |
|
65 | + return $value; |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * @param $name |
|
70 | - * @param string|array $string |
|
71 | - * @param int $expire |
|
72 | - */ |
|
73 | - function newbbSetCookie($name, $string = '', $expire = 0) |
|
74 | - { |
|
75 | - global $forumCookie; |
|
76 | - if (is_array($string)) { |
|
77 | - $value = []; |
|
78 | - foreach ($string as $key => $val) { |
|
79 | - $value[] = $key . '|' . $val; |
|
80 | - } |
|
81 | - $string = implode(',', $value); |
|
82 | - } |
|
83 | - setcookie($forumCookie['prefix'] . $name, $string, (int)$expire, $forumCookie['path'], $forumCookie['domain'], $forumCookie['secure']); |
|
84 | - } |
|
68 | + /** |
|
69 | + * @param $name |
|
70 | + * @param string|array $string |
|
71 | + * @param int $expire |
|
72 | + */ |
|
73 | + function newbbSetCookie($name, $string = '', $expire = 0) |
|
74 | + { |
|
75 | + global $forumCookie; |
|
76 | + if (is_array($string)) { |
|
77 | + $value = []; |
|
78 | + foreach ($string as $key => $val) { |
|
79 | + $value[] = $key . '|' . $val; |
|
80 | + } |
|
81 | + $string = implode(',', $value); |
|
82 | + } |
|
83 | + setcookie($forumCookie['prefix'] . $name, $string, (int)$expire, $forumCookie['path'], $forumCookie['domain'], $forumCookie['secure']); |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * @param $name |
|
88 | - * @param bool $isArray |
|
89 | - * @return array|null |
|
90 | - */ |
|
91 | - function newbbGetCookie($name, $isArray = false) |
|
92 | - { |
|
93 | - global $forumCookie; |
|
94 | - // $value = !empty($_COOKIE[$forumCookie['prefix'] . $name]) ? $_COOKIE[$forumCookie['prefix'] . $name] : null; |
|
95 | - $value = Request::getString($forumCookie['prefix'] . $name, null, 'COOKIE'); |
|
86 | + /** |
|
87 | + * @param $name |
|
88 | + * @param bool $isArray |
|
89 | + * @return array|null |
|
90 | + */ |
|
91 | + function newbbGetCookie($name, $isArray = false) |
|
92 | + { |
|
93 | + global $forumCookie; |
|
94 | + // $value = !empty($_COOKIE[$forumCookie['prefix'] . $name]) ? $_COOKIE[$forumCookie['prefix'] . $name] : null; |
|
95 | + $value = Request::getString($forumCookie['prefix'] . $name, null, 'COOKIE'); |
|
96 | 96 | |
97 | - if ($isArray) { |
|
98 | - $_value = $value ? explode(',', $value) : []; |
|
99 | - $value = []; |
|
100 | - if (count($_value) > 0) { |
|
101 | - foreach ($_value as $string) { |
|
102 | - $sep = strpos($string, '|'); |
|
103 | - if (false === $sep) { |
|
104 | - $value[] = $string; |
|
105 | - } else { |
|
106 | - $key = substr($string, 0, $sep); |
|
107 | - $val = substr($string, $sep + 1); |
|
108 | - $value[$key] = $val; |
|
109 | - } |
|
110 | - } |
|
111 | - } |
|
112 | - unset($_value); |
|
113 | - } |
|
97 | + if ($isArray) { |
|
98 | + $_value = $value ? explode(',', $value) : []; |
|
99 | + $value = []; |
|
100 | + if (count($_value) > 0) { |
|
101 | + foreach ($_value as $string) { |
|
102 | + $sep = strpos($string, '|'); |
|
103 | + if (false === $sep) { |
|
104 | + $value[] = $string; |
|
105 | + } else { |
|
106 | + $key = substr($string, 0, $sep); |
|
107 | + $val = substr($string, $sep + 1); |
|
108 | + $value[$key] = $val; |
|
109 | + } |
|
110 | + } |
|
111 | + } |
|
112 | + unset($_value); |
|
113 | + } |
|
114 | 114 | |
115 | - return $value; |
|
116 | - } |
|
115 | + return $value; |
|
116 | + } |
|
117 | 117 | } |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | |
14 | 14 | // defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
15 | 15 | |
16 | -defined('NEWBB_FUNCTIONS_INI') || require_once __DIR__ . '/functions.ini.php'; |
|
16 | +defined('NEWBB_FUNCTIONS_INI') || require_once __DIR__.'/functions.ini.php'; |
|
17 | 17 | define('NEWBB_FUNCTIONS_SESSION_LOADED', true); |
18 | 18 | |
19 | 19 | if (!defined('NEWBB_FUNCTIONS_SESSION')) { |
@@ -34,11 +34,11 @@ discard block |
||
34 | 34 | if (is_array($string)) { |
35 | 35 | $value = []; |
36 | 36 | foreach ($string as $key => $val) { |
37 | - $value[] = $key . '|' . $val; |
|
37 | + $value[] = $key.'|'.$val; |
|
38 | 38 | } |
39 | 39 | $string = implode(',', $value); |
40 | 40 | } |
41 | - $_SESSION['newbb_' . $name] = $string; |
|
41 | + $_SESSION['newbb_'.$name] = $string; |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | function newbbGetSession($name, $isArray = false) |
50 | 50 | { |
51 | - $value = !empty($_SESSION['newbb_' . $name]) ? $_SESSION['newbb_' . $name] : false; |
|
51 | + $value = !empty($_SESSION['newbb_'.$name]) ? $_SESSION['newbb_'.$name] : false; |
|
52 | 52 | if ($isArray) { |
53 | 53 | $_value = $value ? explode(',', $value) : []; |
54 | 54 | $value = []; |
@@ -76,11 +76,11 @@ discard block |
||
76 | 76 | if (is_array($string)) { |
77 | 77 | $value = []; |
78 | 78 | foreach ($string as $key => $val) { |
79 | - $value[] = $key . '|' . $val; |
|
79 | + $value[] = $key.'|'.$val; |
|
80 | 80 | } |
81 | 81 | $string = implode(',', $value); |
82 | 82 | } |
83 | - setcookie($forumCookie['prefix'] . $name, $string, (int)$expire, $forumCookie['path'], $forumCookie['domain'], $forumCookie['secure']); |
|
83 | + setcookie($forumCookie['prefix'].$name, $string, (int) $expire, $forumCookie['path'], $forumCookie['domain'], $forumCookie['secure']); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | { |
93 | 93 | global $forumCookie; |
94 | 94 | // $value = !empty($_COOKIE[$forumCookie['prefix'] . $name]) ? $_COOKIE[$forumCookie['prefix'] . $name] : null; |
95 | - $value = Request::getString($forumCookie['prefix'] . $name, null, 'COOKIE'); |
|
95 | + $value = Request::getString($forumCookie['prefix'].$name, null, 'COOKIE'); |
|
96 | 96 | |
97 | 97 | if ($isArray) { |
98 | 98 | $_value = $value ? explode(',', $value) : []; |
@@ -69,161 +69,161 @@ |
||
69 | 69 | // uncomment to show text link instead of images (set to true) |
70 | 70 | $displayText[''] = //$displayText['blank'] = |
71 | 71 | |
72 | - //$displayText['attachment'] = |
|
73 | - //$displayText['whosonline'] = |
|
74 | - //$displayText['statistik'] = |
|
75 | - //$displayText['lastposticon'] = |
|
76 | - |
|
77 | - //$displayText['plus'] = |
|
78 | - //$displayText['minus'] = |
|
79 | - |
|
80 | - //$displayText['forum'] = |
|
81 | - //$displayText['forum_new'] = |
|
82 | - |
|
83 | - //$displayText['topic'] = |
|
84 | - //$displayText['topic_hot'] = |
|
85 | - //$displayText['topic_sticky'] = |
|
86 | - //$displayText['topic_digest'] = |
|
87 | - //$displayText['topic_locked'] = |
|
88 | - //$displayText['topic_new'] = |
|
89 | - //$displayText['topic_hot_new'] = |
|
90 | - //$displayText['topic_my'] = |
|
91 | - |
|
92 | - //$displayText['post'] = |
|
93 | - |
|
94 | - //$displayText['poll'] = |
|
95 | - //$displayText['rss'] = |
|
96 | - //$displayText['pdf'] = |
|
97 | - //$displayText['subforum'] = |
|
98 | - |
|
99 | - //$displayText['admin_move'] = |
|
100 | - //$displayText['admin_merge'] = |
|
101 | - //$displayText['admin_edit'] = |
|
102 | - //$displayText['admin_delete'] = |
|
103 | - |
|
104 | - //$displayText['document'] = |
|
105 | - |
|
106 | - //$displayText['previous'] = |
|
107 | - //$displayText['next'] = |
|
108 | - //$displayText['right'] = |
|
109 | - //$displayText['down'] = |
|
110 | - //$displayText['up'] = |
|
111 | - //$displayText['printer'] = |
|
112 | - //$displayText['new_forum'] = |
|
113 | - |
|
114 | - //$displayText['facebook'] = |
|
115 | - //$displayText['twitter'] = |
|
116 | - //$displayText['linkedin'] = |
|
117 | - //$displayText['googleplus'] = |
|
118 | - //$displayText['stumbleupon'] = |
|
119 | - //$displayText['friendfeed'] = |
|
120 | - //$displayText['digg'] = |
|
121 | - //$displayText['reddit'] = |
|
122 | - //$displayText['delicious'] = |
|
123 | - //$displayText['technorati'] = |
|
124 | - //$displayText['wong'] = |
|
125 | - //$displayText['anonym'] = |
|
126 | - //$displayText['more'] = |
|
127 | - //$displayText['less'] = |
|
72 | + //$displayText['attachment'] = |
|
73 | + //$displayText['whosonline'] = |
|
74 | + //$displayText['statistik'] = |
|
75 | + //$displayText['lastposticon'] = |
|
76 | + |
|
77 | + //$displayText['plus'] = |
|
78 | + //$displayText['minus'] = |
|
79 | + |
|
80 | + //$displayText['forum'] = |
|
81 | + //$displayText['forum_new'] = |
|
82 | + |
|
83 | + //$displayText['topic'] = |
|
84 | + //$displayText['topic_hot'] = |
|
85 | + //$displayText['topic_sticky'] = |
|
86 | + //$displayText['topic_digest'] = |
|
87 | + //$displayText['topic_locked'] = |
|
88 | + //$displayText['topic_new'] = |
|
89 | + //$displayText['topic_hot_new'] = |
|
90 | + //$displayText['topic_my'] = |
|
91 | + |
|
92 | + //$displayText['post'] = |
|
93 | + |
|
94 | + //$displayText['poll'] = |
|
95 | + //$displayText['rss'] = |
|
96 | + //$displayText['pdf'] = |
|
97 | + //$displayText['subforum'] = |
|
98 | + |
|
99 | + //$displayText['admin_move'] = |
|
100 | + //$displayText['admin_merge'] = |
|
101 | + //$displayText['admin_edit'] = |
|
102 | + //$displayText['admin_delete'] = |
|
103 | + |
|
104 | + //$displayText['document'] = |
|
105 | + |
|
106 | + //$displayText['previous'] = |
|
107 | + //$displayText['next'] = |
|
108 | + //$displayText['right'] = |
|
109 | + //$displayText['down'] = |
|
110 | + //$displayText['up'] = |
|
111 | + //$displayText['printer'] = |
|
112 | + //$displayText['new_forum'] = |
|
113 | + |
|
114 | + //$displayText['facebook'] = |
|
115 | + //$displayText['twitter'] = |
|
116 | + //$displayText['linkedin'] = |
|
117 | + //$displayText['googleplus'] = |
|
118 | + //$displayText['stumbleupon'] = |
|
119 | + //$displayText['friendfeed'] = |
|
120 | + //$displayText['digg'] = |
|
121 | + //$displayText['reddit'] = |
|
122 | + //$displayText['delicious'] = |
|
123 | + //$displayText['technorati'] = |
|
124 | + //$displayText['wong'] = |
|
125 | + //$displayText['anonym'] = |
|
126 | + //$displayText['more'] = |
|
127 | + //$displayText['less'] = |
|
128 | 128 | |
129 | 129 | $displayText['p_delete'] = $displayText['p_reply'] = $displayText['p_quote'] = $displayText['p_edit'] = $displayText['p_report'] = $displayText['t_new'] = $displayText['t_poll'] = $displayText['t_qr'] = $displayText['t_qr_expand'] = $displayText['t_reply'] = |
130 | 130 | |
131 | - //$displayText['online'] = |
|
132 | - //$displayText['offline'] = |
|
131 | + //$displayText['online'] = |
|
132 | + //$displayText['offline'] = |
|
133 | 133 | |
134 | - //$displayText['new_subforum'] = |
|
134 | + //$displayText['new_subforum'] = |
|
135 | 135 | |
136 | 136 | $displayText['p_bann'] = |
137 | 137 | |
138 | - true; |
|
138 | + true; |
|
139 | 139 | |
140 | 140 | for ($i = 1; $i <= 5; ++$i) { |
141 | - //$displayText['rate'.$i] = true; |
|
141 | + //$displayText['rate'.$i] = true; |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | // uncomment to show images instead of text links (set to false) |
145 | 145 | $displayText[''] = //$displayText['blank'] = |
146 | 146 | |
147 | - //$displayText['attachment'] = |
|
148 | - //$displayText['whosonline'] = |
|
149 | - //$displayText['statistik'] = |
|
150 | - //$displayText['lastposticon'] = |
|
151 | - |
|
152 | - //$displayText['plus'] = |
|
153 | - //$displayText['minus'] = |
|
154 | - |
|
155 | - //$displayText['forum'] = |
|
156 | - //$displayText['forum_new'] = |
|
157 | - |
|
158 | - //$displayText['topic'] = |
|
159 | - //$displayText['topic_hot'] = |
|
160 | - //$displayText['topic_sticky'] = |
|
161 | - //$displayText['topic_digest'] = |
|
162 | - //$displayText['topic_locked'] = |
|
163 | - //$displayText['topic_new'] = |
|
164 | - //$displayText['topic_hot_new'] = |
|
165 | - //$displayText['topic_my'] = |
|
166 | - |
|
167 | - //$displayText['post'] = |
|
168 | - |
|
169 | - //$displayText['poll'] = |
|
170 | - //$displayText['rss'] = |
|
171 | - //$displayText['pdf'] = |
|
172 | - //$displayText['subforum'] = |
|
173 | - |
|
174 | - //$displayText['admin_move'] = |
|
175 | - //$displayText['admin_merge'] = |
|
176 | - //$displayText['admin_edit'] = |
|
177 | - //$displayText['admin_delete'] = |
|
178 | - |
|
179 | - //$displayText['document'] = |
|
180 | - |
|
181 | - //$displayText['previous'] = |
|
182 | - //$displayText['next'] = |
|
183 | - //$displayText['right'] = |
|
184 | - //$displayText['down'] = |
|
185 | - //$displayText['up'] = |
|
186 | - //$displayText['printer'] = |
|
187 | - //$displayText['new_forum'] = |
|
188 | - |
|
189 | - //$displayText['facebook'] = |
|
190 | - //$displayText['twitter'] = |
|
191 | - //$displayText['linkedin'] = |
|
192 | - //$displayText['googleplus'] = |
|
193 | - //$displayText['stumbleupon'] = |
|
194 | - //$displayText['friendfeed'] = |
|
195 | - //$displayText['digg'] = |
|
196 | - //$displayText['reddit'] = |
|
197 | - //$displayText['delicious'] = |
|
198 | - //$displayText['technorati'] = |
|
199 | - //$displayText['wong'] = |
|
200 | - //$displayText['anonym'] = |
|
201 | - //$displayText['more'] = |
|
202 | - //$displayText['less'] = |
|
203 | - |
|
204 | - //$displayText['p_delete'] = |
|
205 | - //$displayText['p_reply'] = |
|
206 | - //$displayText['p_quote'] = |
|
207 | - //$displayText['p_edit'] = |
|
208 | - //$displayText['p_report'] = |
|
209 | - |
|
210 | - //$displayText['t_new'] = |
|
211 | - //$displayText['t_poll'] = |
|
212 | - //$displayText['t_qr'] = |
|
213 | - //$displayText['t_qr_expand'] = |
|
214 | - //$displayText['t_reply'] = |
|
215 | - |
|
216 | - //$displayText['online'] = |
|
217 | - //$displayText['offline'] = |
|
218 | - |
|
219 | - //$displayText['new_subforum'] = |
|
220 | - |
|
221 | - //$displayText['p_bann'] = |
|
222 | - |
|
223 | - false; |
|
147 | + //$displayText['attachment'] = |
|
148 | + //$displayText['whosonline'] = |
|
149 | + //$displayText['statistik'] = |
|
150 | + //$displayText['lastposticon'] = |
|
151 | + |
|
152 | + //$displayText['plus'] = |
|
153 | + //$displayText['minus'] = |
|
154 | + |
|
155 | + //$displayText['forum'] = |
|
156 | + //$displayText['forum_new'] = |
|
157 | + |
|
158 | + //$displayText['topic'] = |
|
159 | + //$displayText['topic_hot'] = |
|
160 | + //$displayText['topic_sticky'] = |
|
161 | + //$displayText['topic_digest'] = |
|
162 | + //$displayText['topic_locked'] = |
|
163 | + //$displayText['topic_new'] = |
|
164 | + //$displayText['topic_hot_new'] = |
|
165 | + //$displayText['topic_my'] = |
|
166 | + |
|
167 | + //$displayText['post'] = |
|
168 | + |
|
169 | + //$displayText['poll'] = |
|
170 | + //$displayText['rss'] = |
|
171 | + //$displayText['pdf'] = |
|
172 | + //$displayText['subforum'] = |
|
173 | + |
|
174 | + //$displayText['admin_move'] = |
|
175 | + //$displayText['admin_merge'] = |
|
176 | + //$displayText['admin_edit'] = |
|
177 | + //$displayText['admin_delete'] = |
|
178 | + |
|
179 | + //$displayText['document'] = |
|
180 | + |
|
181 | + //$displayText['previous'] = |
|
182 | + //$displayText['next'] = |
|
183 | + //$displayText['right'] = |
|
184 | + //$displayText['down'] = |
|
185 | + //$displayText['up'] = |
|
186 | + //$displayText['printer'] = |
|
187 | + //$displayText['new_forum'] = |
|
188 | + |
|
189 | + //$displayText['facebook'] = |
|
190 | + //$displayText['twitter'] = |
|
191 | + //$displayText['linkedin'] = |
|
192 | + //$displayText['googleplus'] = |
|
193 | + //$displayText['stumbleupon'] = |
|
194 | + //$displayText['friendfeed'] = |
|
195 | + //$displayText['digg'] = |
|
196 | + //$displayText['reddit'] = |
|
197 | + //$displayText['delicious'] = |
|
198 | + //$displayText['technorati'] = |
|
199 | + //$displayText['wong'] = |
|
200 | + //$displayText['anonym'] = |
|
201 | + //$displayText['more'] = |
|
202 | + //$displayText['less'] = |
|
203 | + |
|
204 | + //$displayText['p_delete'] = |
|
205 | + //$displayText['p_reply'] = |
|
206 | + //$displayText['p_quote'] = |
|
207 | + //$displayText['p_edit'] = |
|
208 | + //$displayText['p_report'] = |
|
209 | + |
|
210 | + //$displayText['t_new'] = |
|
211 | + //$displayText['t_poll'] = |
|
212 | + //$displayText['t_qr'] = |
|
213 | + //$displayText['t_qr_expand'] = |
|
214 | + //$displayText['t_reply'] = |
|
215 | + |
|
216 | + //$displayText['online'] = |
|
217 | + //$displayText['offline'] = |
|
218 | + |
|
219 | + //$displayText['new_subforum'] = |
|
220 | + |
|
221 | + //$displayText['p_bann'] = |
|
222 | + |
|
223 | + false; |
|
224 | 224 | |
225 | 225 | for ($i = 1; $i <= 5; ++$i) { |
226 | - //$displayText['rate'.$i] = false; |
|
226 | + //$displayText['rate'.$i] = false; |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | return $displayText; |
@@ -30,192 +30,192 @@ |
||
30 | 30 | // ------------------------------------------------------------------------ // |
31 | 31 | |
32 | 32 | if (!defined('NEWBB_FUNCTIONS_IMAGE')) { |
33 | - define('NEWBB_FUNCTIONS_IMAGE', true); |
|
34 | - |
|
35 | - /** |
|
36 | - * @param $source |
|
37 | - * @return string |
|
38 | - */ |
|
39 | - function newbbAttachmentImage($source) |
|
40 | - { |
|
41 | - $img_path = $GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments']); |
|
42 | - $img_url = XOOPS_URL . '/' . $GLOBALS['xoopsModuleConfig']['dir_attachments']; |
|
43 | - $thumb_path = $img_path . '/thumbs'; |
|
44 | - $thumb_url = $img_url . '/thumbs'; |
|
45 | - |
|
46 | - $thumb = $thumb_path . '/' . $source; |
|
47 | - $image = $img_path . '/' . $source; |
|
48 | - $thumb_url = $thumb_url . '/' . $source; |
|
49 | - $image_url = $img_url . '/' . $source; |
|
50 | - |
|
51 | - $imginfo = @getimagesize($image); |
|
52 | - $img_info = (count($imginfo) > 0) ? $imginfo[0] . 'X' . $imginfo[1] . ' px' : ''; |
|
53 | - |
|
54 | - if ($GLOBALS['xoopsModuleConfig']['max_image_width'] > 0 |
|
55 | - && $GLOBALS['xoopsModuleConfig']['max_image_height'] > 0) { |
|
56 | - if ($imginfo[0] > $GLOBALS['xoopsModuleConfig']['max_image_width'] |
|
57 | - || $imginfo[1] > $GLOBALS['xoopsModuleConfig']['max_image_height']) { |
|
58 | - //if (!file_exists($thumb_path.'/'.$source) && $imginfo[0] > $GLOBALS['xoopsModuleConfig']['max_img_width']) { |
|
59 | - if (!file_exists($thumb_path . '/' . $source)) { |
|
60 | - newbbCreateThumbnail($source, $GLOBALS['xoopsModuleConfig']['max_image_width']); |
|
61 | - } |
|
62 | - } |
|
63 | - |
|
64 | - if ($imginfo[0] > $GLOBALS['xoopsModuleConfig']['max_image_width'] |
|
65 | - || $imginfo[1] > $GLOBALS['xoopsModuleConfig']['max_image_height']) { |
|
66 | - $pseudo_width = $GLOBALS['xoopsModuleConfig']['max_image_width']; |
|
67 | - $pseudo_height = $GLOBALS['xoopsModuleConfig']['max_image_width'] * ($imginfo[1] / $imginfo[0]); |
|
68 | - $pseudo_size = "width='" . $pseudo_width . "px' height='" . $pseudo_height . "px'"; |
|
69 | - } |
|
70 | - // irmtfan to fix Undefined variable: pseudo_height |
|
71 | - if (!empty($pseudo_height) && $GLOBALS['xoopsModuleConfig']['max_image_height'] > 0 |
|
72 | - && $pseudo_height > $GLOBALS['xoopsModuleConfig']['max_image_height']) { |
|
73 | - $pseudo_height = $GLOBALS['xoopsModuleConfig']['max_image_height']; |
|
74 | - $pseudo_width = $GLOBALS['xoopsModuleConfig']['max_image_height'] * ($imginfo[0] / $imginfo[1]); |
|
75 | - $pseudo_size = "width='" . $pseudo_width . "px' height='" . $pseudo_height . "px'"; |
|
76 | - } |
|
77 | - } |
|
78 | - |
|
79 | - if (file_exists($thumb)) { |
|
80 | - $attachmentImage = '<a href="' . $image_url . '" title="' . $source . ' ' . $img_info . '" target="_blank">'; |
|
81 | - // $attachmentImage .= '<img src="' . $thumb_url . '" alt="' . $source . ' ' . $img_info . '" />'; |
|
82 | - $attachmentImage .= '<img src="' . $image_url . '" ' . $pseudo_size . ' alt="' . $source . ' ' . $img_info . '" />'; |
|
83 | - $attachmentImage .= '</a>'; |
|
84 | - } elseif (!empty($pseudo_size)) { |
|
85 | - $attachmentImage = '<a href="' . $image_url . '" title="' . $source . ' ' . $img_info . '" target="_blank">'; |
|
86 | - $attachmentImage .= '<img src="' . $image_url . '" ' . $pseudo_size . ' alt="' . $source . ' ' . $img_info . '" />'; |
|
87 | - $attachmentImage .= '</a>'; |
|
88 | - } elseif (file_exists($image)) { |
|
89 | - $attachmentImage = '<img src="' . $image_url . '" alt="' . $source . ' ' . $img_info . '" />'; |
|
90 | - } else { |
|
91 | - $attachmentImage = ''; |
|
92 | - } |
|
93 | - |
|
94 | - return $attachmentImage; |
|
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * @param $source |
|
99 | - * @param $thumb_width |
|
100 | - * @return bool |
|
101 | - */ |
|
102 | - function newbbCreateThumbnail($source, $thumb_width) |
|
103 | - { |
|
104 | - $cmd = ''; |
|
105 | - $img_path = $GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments']); |
|
106 | - $thumb_path = $img_path . '/thumbs'; |
|
107 | - $src_file = $img_path . '/' . $source; |
|
108 | - $new_file = $thumb_path . '/' . $source; |
|
109 | - //$imageLibs = newbb_getImageLibs(); |
|
110 | - |
|
111 | - if (!filesize($src_file) || !is_readable($src_file)) { |
|
112 | - return false; |
|
113 | - } |
|
114 | - |
|
115 | - if (!is_dir($thumb_path) || !is_writable($thumb_path)) { |
|
116 | - return false; |
|
117 | - } |
|
118 | - |
|
119 | - $imginfo = @getimagesize($src_file); |
|
120 | - |
|
121 | - if (null === $imginfo) { |
|
122 | - return false; |
|
123 | - } |
|
124 | - if ($imginfo[0] < $thumb_width) { |
|
125 | - return false; |
|
126 | - } |
|
127 | - |
|
128 | - $newWidth = (int)min($imginfo[0], $thumb_width); |
|
129 | - $newHeight = (int)($imginfo[1] * $newWidth / $imginfo[0]); |
|
130 | - |
|
131 | - if (1 == $GLOBALS['xoopsModuleConfig']['image_lib'] || 0 == $GLOBALS['xoopsModuleConfig']['image_lib']) { |
|
132 | - if (preg_match("#[A-Z]:|\\\\#Ai", __FILE__)) { |
|
133 | - $cur_dir = __DIR__; |
|
134 | - $src_file_im = '"' . $cur_dir . '\\' . str_replace('/', '\\', $src_file) . '"'; |
|
135 | - $new_file_im = '"' . $cur_dir . '\\' . str_replace('/', '\\', $new_file) . '"'; |
|
136 | - } else { |
|
137 | - $src_file_im = @escapeshellarg($src_file); |
|
138 | - $new_file_im = @escapeshellarg($new_file); |
|
139 | - } |
|
140 | - $path = empty($GLOBALS['xoopsModuleConfig']['path_magick']) ? '' : $GLOBALS['xoopsModuleConfig']['path_magick'] . '/'; |
|
141 | - $magick_command = $path . 'convert -quality 85 -antialias -sample ' . $newWidth . 'x' . $newHeight . ' ' . $src_file_im . ' +profile "*" ' . str_replace('\\', '/', $new_file_im) . ''; |
|
142 | - |
|
143 | - @passthru($magick_command); |
|
144 | - if (file_exists($new_file)) { |
|
145 | - return true; |
|
146 | - } |
|
147 | - } |
|
148 | - |
|
149 | - if (2 == $GLOBALS['xoopsModuleConfig']['image_lib'] || 0 == $GLOBALS['xoopsModuleConfig']['image_lib']) { |
|
150 | - $path = empty($GLOBALS['xoopsModuleConfig']['path_netpbm']) ? '' : $GLOBALS['xoopsModuleConfig']['path_netpbm'] . '/'; |
|
151 | - if (preg_match("/\.png/", $source)) { |
|
152 | - $cmd = $path . "pngtopnm $src_file | " . $path . "pnmscale -xysize $newWidth $newHeight | " . $path . "pnmtopng > $new_file"; |
|
153 | - } elseif (preg_match("/\.(jpg|jpeg)/", $source)) { |
|
154 | - $cmd = $path . "jpegtopnm $src_file | " . $path . "pnmscale -xysize $newWidth $newHeight | " . $path . "ppmtojpeg -quality=90 > $new_file"; |
|
155 | - } elseif (preg_match("/\.gif/", $source)) { |
|
156 | - $cmd = $path . "giftopnm $src_file | " . $path . "pnmscale -xysize $newWidth $newHeight | ppmquant 256 | " . $path . "ppmtogif > $new_file"; |
|
157 | - } |
|
158 | - |
|
159 | - @exec($cmd, $output, $retval); |
|
160 | - if (file_exists($new_file)) { |
|
161 | - return true; |
|
162 | - } |
|
163 | - } |
|
164 | - |
|
165 | - $type = $imginfo[2]; |
|
166 | - $supported_types = []; |
|
167 | - |
|
168 | - if (!extension_loaded('gd')) { |
|
169 | - return false; |
|
170 | - } |
|
171 | - if (function_exists('imagegif')) { |
|
172 | - $supported_types[] = 1; |
|
173 | - } |
|
174 | - if (function_exists('imagejpeg')) { |
|
175 | - $supported_types[] = 2; |
|
176 | - } |
|
177 | - if (function_exists('imagepng')) { |
|
178 | - $supported_types[] = 3; |
|
179 | - } |
|
180 | - |
|
181 | - $imageCreateFunction = function_exists('imagecreatetruecolor') ? 'imagecreatetruecolor' : 'imagecreate'; |
|
182 | - |
|
183 | - if (in_array($type, $supported_types)) { |
|
184 | - switch ($type) { |
|
185 | - case 1: |
|
186 | - if (!function_exists('imagecreatefromgif')) { |
|
187 | - return false; |
|
188 | - } |
|
189 | - $im = imagecreatefromgif($src_file); |
|
190 | - $new_im = imagecreate($newWidth, $newHeight); |
|
191 | - imagecopyresized($new_im, $im, 0, 0, 0, 0, $newWidth, $newHeight, $imginfo[0], $imginfo[1]); |
|
192 | - imagegif($new_im, $new_file); |
|
193 | - imagedestroy($im); |
|
194 | - imagedestroy($new_im); |
|
195 | - break; |
|
196 | - case 2: |
|
197 | - $im = imagecreatefromjpeg($src_file); |
|
198 | - $new_im = $imageCreateFunction($newWidth, $newHeight); |
|
199 | - imagecopyresized($new_im, $im, 0, 0, 0, 0, $newWidth, $newHeight, $imginfo[0], $imginfo[1]); |
|
200 | - imagejpeg($new_im, $new_file, 90); |
|
201 | - imagedestroy($im); |
|
202 | - imagedestroy($new_im); |
|
203 | - break; |
|
204 | - case 3: |
|
205 | - $im = imagecreatefrompng($src_file); |
|
206 | - $new_im = $imageCreateFunction($newWidth, $newHeight); |
|
207 | - imagecopyresized($new_im, $im, 0, 0, 0, 0, $newWidth, $newHeight, $imginfo[0], $imginfo[1]); |
|
208 | - imagepng($new_im, $new_file); |
|
209 | - imagedestroy($im); |
|
210 | - imagedestroy($new_im); |
|
211 | - break; |
|
212 | - } |
|
213 | - } |
|
214 | - |
|
215 | - if (file_exists($new_file)) { |
|
216 | - return true; |
|
217 | - } else { |
|
218 | - return false; |
|
219 | - } |
|
220 | - } |
|
33 | + define('NEWBB_FUNCTIONS_IMAGE', true); |
|
34 | + |
|
35 | + /** |
|
36 | + * @param $source |
|
37 | + * @return string |
|
38 | + */ |
|
39 | + function newbbAttachmentImage($source) |
|
40 | + { |
|
41 | + $img_path = $GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments']); |
|
42 | + $img_url = XOOPS_URL . '/' . $GLOBALS['xoopsModuleConfig']['dir_attachments']; |
|
43 | + $thumb_path = $img_path . '/thumbs'; |
|
44 | + $thumb_url = $img_url . '/thumbs'; |
|
45 | + |
|
46 | + $thumb = $thumb_path . '/' . $source; |
|
47 | + $image = $img_path . '/' . $source; |
|
48 | + $thumb_url = $thumb_url . '/' . $source; |
|
49 | + $image_url = $img_url . '/' . $source; |
|
50 | + |
|
51 | + $imginfo = @getimagesize($image); |
|
52 | + $img_info = (count($imginfo) > 0) ? $imginfo[0] . 'X' . $imginfo[1] . ' px' : ''; |
|
53 | + |
|
54 | + if ($GLOBALS['xoopsModuleConfig']['max_image_width'] > 0 |
|
55 | + && $GLOBALS['xoopsModuleConfig']['max_image_height'] > 0) { |
|
56 | + if ($imginfo[0] > $GLOBALS['xoopsModuleConfig']['max_image_width'] |
|
57 | + || $imginfo[1] > $GLOBALS['xoopsModuleConfig']['max_image_height']) { |
|
58 | + //if (!file_exists($thumb_path.'/'.$source) && $imginfo[0] > $GLOBALS['xoopsModuleConfig']['max_img_width']) { |
|
59 | + if (!file_exists($thumb_path . '/' . $source)) { |
|
60 | + newbbCreateThumbnail($source, $GLOBALS['xoopsModuleConfig']['max_image_width']); |
|
61 | + } |
|
62 | + } |
|
63 | + |
|
64 | + if ($imginfo[0] > $GLOBALS['xoopsModuleConfig']['max_image_width'] |
|
65 | + || $imginfo[1] > $GLOBALS['xoopsModuleConfig']['max_image_height']) { |
|
66 | + $pseudo_width = $GLOBALS['xoopsModuleConfig']['max_image_width']; |
|
67 | + $pseudo_height = $GLOBALS['xoopsModuleConfig']['max_image_width'] * ($imginfo[1] / $imginfo[0]); |
|
68 | + $pseudo_size = "width='" . $pseudo_width . "px' height='" . $pseudo_height . "px'"; |
|
69 | + } |
|
70 | + // irmtfan to fix Undefined variable: pseudo_height |
|
71 | + if (!empty($pseudo_height) && $GLOBALS['xoopsModuleConfig']['max_image_height'] > 0 |
|
72 | + && $pseudo_height > $GLOBALS['xoopsModuleConfig']['max_image_height']) { |
|
73 | + $pseudo_height = $GLOBALS['xoopsModuleConfig']['max_image_height']; |
|
74 | + $pseudo_width = $GLOBALS['xoopsModuleConfig']['max_image_height'] * ($imginfo[0] / $imginfo[1]); |
|
75 | + $pseudo_size = "width='" . $pseudo_width . "px' height='" . $pseudo_height . "px'"; |
|
76 | + } |
|
77 | + } |
|
78 | + |
|
79 | + if (file_exists($thumb)) { |
|
80 | + $attachmentImage = '<a href="' . $image_url . '" title="' . $source . ' ' . $img_info . '" target="_blank">'; |
|
81 | + // $attachmentImage .= '<img src="' . $thumb_url . '" alt="' . $source . ' ' . $img_info . '" />'; |
|
82 | + $attachmentImage .= '<img src="' . $image_url . '" ' . $pseudo_size . ' alt="' . $source . ' ' . $img_info . '" />'; |
|
83 | + $attachmentImage .= '</a>'; |
|
84 | + } elseif (!empty($pseudo_size)) { |
|
85 | + $attachmentImage = '<a href="' . $image_url . '" title="' . $source . ' ' . $img_info . '" target="_blank">'; |
|
86 | + $attachmentImage .= '<img src="' . $image_url . '" ' . $pseudo_size . ' alt="' . $source . ' ' . $img_info . '" />'; |
|
87 | + $attachmentImage .= '</a>'; |
|
88 | + } elseif (file_exists($image)) { |
|
89 | + $attachmentImage = '<img src="' . $image_url . '" alt="' . $source . ' ' . $img_info . '" />'; |
|
90 | + } else { |
|
91 | + $attachmentImage = ''; |
|
92 | + } |
|
93 | + |
|
94 | + return $attachmentImage; |
|
95 | + } |
|
96 | + |
|
97 | + /** |
|
98 | + * @param $source |
|
99 | + * @param $thumb_width |
|
100 | + * @return bool |
|
101 | + */ |
|
102 | + function newbbCreateThumbnail($source, $thumb_width) |
|
103 | + { |
|
104 | + $cmd = ''; |
|
105 | + $img_path = $GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments']); |
|
106 | + $thumb_path = $img_path . '/thumbs'; |
|
107 | + $src_file = $img_path . '/' . $source; |
|
108 | + $new_file = $thumb_path . '/' . $source; |
|
109 | + //$imageLibs = newbb_getImageLibs(); |
|
110 | + |
|
111 | + if (!filesize($src_file) || !is_readable($src_file)) { |
|
112 | + return false; |
|
113 | + } |
|
114 | + |
|
115 | + if (!is_dir($thumb_path) || !is_writable($thumb_path)) { |
|
116 | + return false; |
|
117 | + } |
|
118 | + |
|
119 | + $imginfo = @getimagesize($src_file); |
|
120 | + |
|
121 | + if (null === $imginfo) { |
|
122 | + return false; |
|
123 | + } |
|
124 | + if ($imginfo[0] < $thumb_width) { |
|
125 | + return false; |
|
126 | + } |
|
127 | + |
|
128 | + $newWidth = (int)min($imginfo[0], $thumb_width); |
|
129 | + $newHeight = (int)($imginfo[1] * $newWidth / $imginfo[0]); |
|
130 | + |
|
131 | + if (1 == $GLOBALS['xoopsModuleConfig']['image_lib'] || 0 == $GLOBALS['xoopsModuleConfig']['image_lib']) { |
|
132 | + if (preg_match("#[A-Z]:|\\\\#Ai", __FILE__)) { |
|
133 | + $cur_dir = __DIR__; |
|
134 | + $src_file_im = '"' . $cur_dir . '\\' . str_replace('/', '\\', $src_file) . '"'; |
|
135 | + $new_file_im = '"' . $cur_dir . '\\' . str_replace('/', '\\', $new_file) . '"'; |
|
136 | + } else { |
|
137 | + $src_file_im = @escapeshellarg($src_file); |
|
138 | + $new_file_im = @escapeshellarg($new_file); |
|
139 | + } |
|
140 | + $path = empty($GLOBALS['xoopsModuleConfig']['path_magick']) ? '' : $GLOBALS['xoopsModuleConfig']['path_magick'] . '/'; |
|
141 | + $magick_command = $path . 'convert -quality 85 -antialias -sample ' . $newWidth . 'x' . $newHeight . ' ' . $src_file_im . ' +profile "*" ' . str_replace('\\', '/', $new_file_im) . ''; |
|
142 | + |
|
143 | + @passthru($magick_command); |
|
144 | + if (file_exists($new_file)) { |
|
145 | + return true; |
|
146 | + } |
|
147 | + } |
|
148 | + |
|
149 | + if (2 == $GLOBALS['xoopsModuleConfig']['image_lib'] || 0 == $GLOBALS['xoopsModuleConfig']['image_lib']) { |
|
150 | + $path = empty($GLOBALS['xoopsModuleConfig']['path_netpbm']) ? '' : $GLOBALS['xoopsModuleConfig']['path_netpbm'] . '/'; |
|
151 | + if (preg_match("/\.png/", $source)) { |
|
152 | + $cmd = $path . "pngtopnm $src_file | " . $path . "pnmscale -xysize $newWidth $newHeight | " . $path . "pnmtopng > $new_file"; |
|
153 | + } elseif (preg_match("/\.(jpg|jpeg)/", $source)) { |
|
154 | + $cmd = $path . "jpegtopnm $src_file | " . $path . "pnmscale -xysize $newWidth $newHeight | " . $path . "ppmtojpeg -quality=90 > $new_file"; |
|
155 | + } elseif (preg_match("/\.gif/", $source)) { |
|
156 | + $cmd = $path . "giftopnm $src_file | " . $path . "pnmscale -xysize $newWidth $newHeight | ppmquant 256 | " . $path . "ppmtogif > $new_file"; |
|
157 | + } |
|
158 | + |
|
159 | + @exec($cmd, $output, $retval); |
|
160 | + if (file_exists($new_file)) { |
|
161 | + return true; |
|
162 | + } |
|
163 | + } |
|
164 | + |
|
165 | + $type = $imginfo[2]; |
|
166 | + $supported_types = []; |
|
167 | + |
|
168 | + if (!extension_loaded('gd')) { |
|
169 | + return false; |
|
170 | + } |
|
171 | + if (function_exists('imagegif')) { |
|
172 | + $supported_types[] = 1; |
|
173 | + } |
|
174 | + if (function_exists('imagejpeg')) { |
|
175 | + $supported_types[] = 2; |
|
176 | + } |
|
177 | + if (function_exists('imagepng')) { |
|
178 | + $supported_types[] = 3; |
|
179 | + } |
|
180 | + |
|
181 | + $imageCreateFunction = function_exists('imagecreatetruecolor') ? 'imagecreatetruecolor' : 'imagecreate'; |
|
182 | + |
|
183 | + if (in_array($type, $supported_types)) { |
|
184 | + switch ($type) { |
|
185 | + case 1: |
|
186 | + if (!function_exists('imagecreatefromgif')) { |
|
187 | + return false; |
|
188 | + } |
|
189 | + $im = imagecreatefromgif($src_file); |
|
190 | + $new_im = imagecreate($newWidth, $newHeight); |
|
191 | + imagecopyresized($new_im, $im, 0, 0, 0, 0, $newWidth, $newHeight, $imginfo[0], $imginfo[1]); |
|
192 | + imagegif($new_im, $new_file); |
|
193 | + imagedestroy($im); |
|
194 | + imagedestroy($new_im); |
|
195 | + break; |
|
196 | + case 2: |
|
197 | + $im = imagecreatefromjpeg($src_file); |
|
198 | + $new_im = $imageCreateFunction($newWidth, $newHeight); |
|
199 | + imagecopyresized($new_im, $im, 0, 0, 0, 0, $newWidth, $newHeight, $imginfo[0], $imginfo[1]); |
|
200 | + imagejpeg($new_im, $new_file, 90); |
|
201 | + imagedestroy($im); |
|
202 | + imagedestroy($new_im); |
|
203 | + break; |
|
204 | + case 3: |
|
205 | + $im = imagecreatefrompng($src_file); |
|
206 | + $new_im = $imageCreateFunction($newWidth, $newHeight); |
|
207 | + imagecopyresized($new_im, $im, 0, 0, 0, 0, $newWidth, $newHeight, $imginfo[0], $imginfo[1]); |
|
208 | + imagepng($new_im, $new_file); |
|
209 | + imagedestroy($im); |
|
210 | + imagedestroy($new_im); |
|
211 | + break; |
|
212 | + } |
|
213 | + } |
|
214 | + |
|
215 | + if (file_exists($new_file)) { |
|
216 | + return true; |
|
217 | + } else { |
|
218 | + return false; |
|
219 | + } |
|
220 | + } |
|
221 | 221 | } |
@@ -39,24 +39,24 @@ discard block |
||
39 | 39 | function newbbAttachmentImage($source) |
40 | 40 | { |
41 | 41 | $img_path = $GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments']); |
42 | - $img_url = XOOPS_URL . '/' . $GLOBALS['xoopsModuleConfig']['dir_attachments']; |
|
43 | - $thumb_path = $img_path . '/thumbs'; |
|
44 | - $thumb_url = $img_url . '/thumbs'; |
|
42 | + $img_url = XOOPS_URL.'/'.$GLOBALS['xoopsModuleConfig']['dir_attachments']; |
|
43 | + $thumb_path = $img_path.'/thumbs'; |
|
44 | + $thumb_url = $img_url.'/thumbs'; |
|
45 | 45 | |
46 | - $thumb = $thumb_path . '/' . $source; |
|
47 | - $image = $img_path . '/' . $source; |
|
48 | - $thumb_url = $thumb_url . '/' . $source; |
|
49 | - $image_url = $img_url . '/' . $source; |
|
46 | + $thumb = $thumb_path.'/'.$source; |
|
47 | + $image = $img_path.'/'.$source; |
|
48 | + $thumb_url = $thumb_url.'/'.$source; |
|
49 | + $image_url = $img_url.'/'.$source; |
|
50 | 50 | |
51 | 51 | $imginfo = @getimagesize($image); |
52 | - $img_info = (count($imginfo) > 0) ? $imginfo[0] . 'X' . $imginfo[1] . ' px' : ''; |
|
52 | + $img_info = (count($imginfo) > 0) ? $imginfo[0].'X'.$imginfo[1].' px' : ''; |
|
53 | 53 | |
54 | 54 | if ($GLOBALS['xoopsModuleConfig']['max_image_width'] > 0 |
55 | 55 | && $GLOBALS['xoopsModuleConfig']['max_image_height'] > 0) { |
56 | 56 | if ($imginfo[0] > $GLOBALS['xoopsModuleConfig']['max_image_width'] |
57 | 57 | || $imginfo[1] > $GLOBALS['xoopsModuleConfig']['max_image_height']) { |
58 | 58 | //if (!file_exists($thumb_path.'/'.$source) && $imginfo[0] > $GLOBALS['xoopsModuleConfig']['max_img_width']) { |
59 | - if (!file_exists($thumb_path . '/' . $source)) { |
|
59 | + if (!file_exists($thumb_path.'/'.$source)) { |
|
60 | 60 | newbbCreateThumbnail($source, $GLOBALS['xoopsModuleConfig']['max_image_width']); |
61 | 61 | } |
62 | 62 | } |
@@ -65,28 +65,28 @@ discard block |
||
65 | 65 | || $imginfo[1] > $GLOBALS['xoopsModuleConfig']['max_image_height']) { |
66 | 66 | $pseudo_width = $GLOBALS['xoopsModuleConfig']['max_image_width']; |
67 | 67 | $pseudo_height = $GLOBALS['xoopsModuleConfig']['max_image_width'] * ($imginfo[1] / $imginfo[0]); |
68 | - $pseudo_size = "width='" . $pseudo_width . "px' height='" . $pseudo_height . "px'"; |
|
68 | + $pseudo_size = "width='".$pseudo_width."px' height='".$pseudo_height."px'"; |
|
69 | 69 | } |
70 | 70 | // irmtfan to fix Undefined variable: pseudo_height |
71 | 71 | if (!empty($pseudo_height) && $GLOBALS['xoopsModuleConfig']['max_image_height'] > 0 |
72 | 72 | && $pseudo_height > $GLOBALS['xoopsModuleConfig']['max_image_height']) { |
73 | 73 | $pseudo_height = $GLOBALS['xoopsModuleConfig']['max_image_height']; |
74 | 74 | $pseudo_width = $GLOBALS['xoopsModuleConfig']['max_image_height'] * ($imginfo[0] / $imginfo[1]); |
75 | - $pseudo_size = "width='" . $pseudo_width . "px' height='" . $pseudo_height . "px'"; |
|
75 | + $pseudo_size = "width='".$pseudo_width."px' height='".$pseudo_height."px'"; |
|
76 | 76 | } |
77 | 77 | } |
78 | 78 | |
79 | 79 | if (file_exists($thumb)) { |
80 | - $attachmentImage = '<a href="' . $image_url . '" title="' . $source . ' ' . $img_info . '" target="_blank">'; |
|
80 | + $attachmentImage = '<a href="'.$image_url.'" title="'.$source.' '.$img_info.'" target="_blank">'; |
|
81 | 81 | // $attachmentImage .= '<img src="' . $thumb_url . '" alt="' . $source . ' ' . $img_info . '" />'; |
82 | - $attachmentImage .= '<img src="' . $image_url . '" ' . $pseudo_size . ' alt="' . $source . ' ' . $img_info . '" />'; |
|
82 | + $attachmentImage .= '<img src="'.$image_url.'" '.$pseudo_size.' alt="'.$source.' '.$img_info.'" />'; |
|
83 | 83 | $attachmentImage .= '</a>'; |
84 | 84 | } elseif (!empty($pseudo_size)) { |
85 | - $attachmentImage = '<a href="' . $image_url . '" title="' . $source . ' ' . $img_info . '" target="_blank">'; |
|
86 | - $attachmentImage .= '<img src="' . $image_url . '" ' . $pseudo_size . ' alt="' . $source . ' ' . $img_info . '" />'; |
|
85 | + $attachmentImage = '<a href="'.$image_url.'" title="'.$source.' '.$img_info.'" target="_blank">'; |
|
86 | + $attachmentImage .= '<img src="'.$image_url.'" '.$pseudo_size.' alt="'.$source.' '.$img_info.'" />'; |
|
87 | 87 | $attachmentImage .= '</a>'; |
88 | 88 | } elseif (file_exists($image)) { |
89 | - $attachmentImage = '<img src="' . $image_url . '" alt="' . $source . ' ' . $img_info . '" />'; |
|
89 | + $attachmentImage = '<img src="'.$image_url.'" alt="'.$source.' '.$img_info.'" />'; |
|
90 | 90 | } else { |
91 | 91 | $attachmentImage = ''; |
92 | 92 | } |
@@ -103,9 +103,9 @@ discard block |
||
103 | 103 | { |
104 | 104 | $cmd = ''; |
105 | 105 | $img_path = $GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments']); |
106 | - $thumb_path = $img_path . '/thumbs'; |
|
107 | - $src_file = $img_path . '/' . $source; |
|
108 | - $new_file = $thumb_path . '/' . $source; |
|
106 | + $thumb_path = $img_path.'/thumbs'; |
|
107 | + $src_file = $img_path.'/'.$source; |
|
108 | + $new_file = $thumb_path.'/'.$source; |
|
109 | 109 | //$imageLibs = newbb_getImageLibs(); |
110 | 110 | |
111 | 111 | if (!filesize($src_file) || !is_readable($src_file)) { |
@@ -125,20 +125,20 @@ discard block |
||
125 | 125 | return false; |
126 | 126 | } |
127 | 127 | |
128 | - $newWidth = (int)min($imginfo[0], $thumb_width); |
|
129 | - $newHeight = (int)($imginfo[1] * $newWidth / $imginfo[0]); |
|
128 | + $newWidth = (int) min($imginfo[0], $thumb_width); |
|
129 | + $newHeight = (int) ($imginfo[1] * $newWidth / $imginfo[0]); |
|
130 | 130 | |
131 | 131 | if (1 == $GLOBALS['xoopsModuleConfig']['image_lib'] || 0 == $GLOBALS['xoopsModuleConfig']['image_lib']) { |
132 | 132 | if (preg_match("#[A-Z]:|\\\\#Ai", __FILE__)) { |
133 | 133 | $cur_dir = __DIR__; |
134 | - $src_file_im = '"' . $cur_dir . '\\' . str_replace('/', '\\', $src_file) . '"'; |
|
135 | - $new_file_im = '"' . $cur_dir . '\\' . str_replace('/', '\\', $new_file) . '"'; |
|
134 | + $src_file_im = '"'.$cur_dir.'\\'.str_replace('/', '\\', $src_file).'"'; |
|
135 | + $new_file_im = '"'.$cur_dir.'\\'.str_replace('/', '\\', $new_file).'"'; |
|
136 | 136 | } else { |
137 | 137 | $src_file_im = @escapeshellarg($src_file); |
138 | 138 | $new_file_im = @escapeshellarg($new_file); |
139 | 139 | } |
140 | - $path = empty($GLOBALS['xoopsModuleConfig']['path_magick']) ? '' : $GLOBALS['xoopsModuleConfig']['path_magick'] . '/'; |
|
141 | - $magick_command = $path . 'convert -quality 85 -antialias -sample ' . $newWidth . 'x' . $newHeight . ' ' . $src_file_im . ' +profile "*" ' . str_replace('\\', '/', $new_file_im) . ''; |
|
140 | + $path = empty($GLOBALS['xoopsModuleConfig']['path_magick']) ? '' : $GLOBALS['xoopsModuleConfig']['path_magick'].'/'; |
|
141 | + $magick_command = $path.'convert -quality 85 -antialias -sample '.$newWidth.'x'.$newHeight.' '.$src_file_im.' +profile "*" '.str_replace('\\', '/', $new_file_im).''; |
|
142 | 142 | |
143 | 143 | @passthru($magick_command); |
144 | 144 | if (file_exists($new_file)) { |
@@ -147,13 +147,13 @@ discard block |
||
147 | 147 | } |
148 | 148 | |
149 | 149 | if (2 == $GLOBALS['xoopsModuleConfig']['image_lib'] || 0 == $GLOBALS['xoopsModuleConfig']['image_lib']) { |
150 | - $path = empty($GLOBALS['xoopsModuleConfig']['path_netpbm']) ? '' : $GLOBALS['xoopsModuleConfig']['path_netpbm'] . '/'; |
|
150 | + $path = empty($GLOBALS['xoopsModuleConfig']['path_netpbm']) ? '' : $GLOBALS['xoopsModuleConfig']['path_netpbm'].'/'; |
|
151 | 151 | if (preg_match("/\.png/", $source)) { |
152 | - $cmd = $path . "pngtopnm $src_file | " . $path . "pnmscale -xysize $newWidth $newHeight | " . $path . "pnmtopng > $new_file"; |
|
152 | + $cmd = $path."pngtopnm $src_file | ".$path."pnmscale -xysize $newWidth $newHeight | ".$path."pnmtopng > $new_file"; |
|
153 | 153 | } elseif (preg_match("/\.(jpg|jpeg)/", $source)) { |
154 | - $cmd = $path . "jpegtopnm $src_file | " . $path . "pnmscale -xysize $newWidth $newHeight | " . $path . "ppmtojpeg -quality=90 > $new_file"; |
|
154 | + $cmd = $path."jpegtopnm $src_file | ".$path."pnmscale -xysize $newWidth $newHeight | ".$path."ppmtojpeg -quality=90 > $new_file"; |
|
155 | 155 | } elseif (preg_match("/\.gif/", $source)) { |
156 | - $cmd = $path . "giftopnm $src_file | " . $path . "pnmscale -xysize $newWidth $newHeight | ppmquant 256 | " . $path . "ppmtogif > $new_file"; |
|
156 | + $cmd = $path."giftopnm $src_file | ".$path."pnmscale -xysize $newWidth $newHeight | ppmquant 256 | ".$path."ppmtogif > $new_file"; |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | @exec($cmd, $output, $retval); |
@@ -15,35 +15,35 @@ |
||
15 | 15 | define('NEWBB_FUNCTIONS_TOPIC_LOADED', true); |
16 | 16 | |
17 | 17 | if (!defined('NEWBB_FUNCTIONS_TOPIC')) { |
18 | - define('NEWBB_FUNCTIONS_TOPIC', 1); |
|
18 | + define('NEWBB_FUNCTIONS_TOPIC', 1); |
|
19 | 19 | |
20 | - /** |
|
21 | - * Create full title of a topic |
|
22 | - * |
|
23 | - * the title is composed of [type_name] if type_id is greater than 0 plus topic Title |
|
24 | - * @param $topicTitle |
|
25 | - * @param null $prefixName |
|
26 | - * @param null $prefixColor |
|
27 | - * @return string |
|
28 | - */ |
|
29 | - function newbbGetTopicTitle($topicTitle, $prefixName = null, $prefixColor = null) |
|
30 | - { |
|
31 | - return getTopicTitle($topicTitle, $prefixName = null, $prefixColor = null); |
|
32 | - } |
|
20 | + /** |
|
21 | + * Create full title of a topic |
|
22 | + * |
|
23 | + * the title is composed of [type_name] if type_id is greater than 0 plus topic Title |
|
24 | + * @param $topicTitle |
|
25 | + * @param null $prefixName |
|
26 | + * @param null $prefixColor |
|
27 | + * @return string |
|
28 | + */ |
|
29 | + function newbbGetTopicTitle($topicTitle, $prefixName = null, $prefixColor = null) |
|
30 | + { |
|
31 | + return getTopicTitle($topicTitle, $prefixName = null, $prefixColor = null); |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * @param $topicTitle |
|
36 | - * @param null $prefixName |
|
37 | - * @param null $prefixColor |
|
38 | - * @return string |
|
39 | - */ |
|
40 | - function getTopicTitle($topicTitle, $prefixName = null, $prefixColor = null) |
|
41 | - { |
|
42 | - if (empty($prefixName)) { |
|
43 | - return $topicTitle; |
|
44 | - } |
|
45 | - $topicPrefix = $prefixColor ? '<em style="font-style: normal; color: ' . $prefixColor . ';">[' . $prefixName . ']</em> ' : '[' . $prefixName . '] '; |
|
34 | + /** |
|
35 | + * @param $topicTitle |
|
36 | + * @param null $prefixName |
|
37 | + * @param null $prefixColor |
|
38 | + * @return string |
|
39 | + */ |
|
40 | + function getTopicTitle($topicTitle, $prefixName = null, $prefixColor = null) |
|
41 | + { |
|
42 | + if (empty($prefixName)) { |
|
43 | + return $topicTitle; |
|
44 | + } |
|
45 | + $topicPrefix = $prefixColor ? '<em style="font-style: normal; color: ' . $prefixColor . ';">[' . $prefixName . ']</em> ' : '[' . $prefixName . '] '; |
|
46 | 46 | |
47 | - return $topicPrefix . $topicTitle; |
|
48 | - } |
|
47 | + return $topicPrefix . $topicTitle; |
|
48 | + } |
|
49 | 49 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | // defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
13 | 13 | |
14 | -defined('NEWBB_FUNCTIONS_INI') || require_once __DIR__ . '/functions.ini.php'; |
|
14 | +defined('NEWBB_FUNCTIONS_INI') || require_once __DIR__.'/functions.ini.php'; |
|
15 | 15 | define('NEWBB_FUNCTIONS_TOPIC_LOADED', true); |
16 | 16 | |
17 | 17 | if (!defined('NEWBB_FUNCTIONS_TOPIC')) { |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | if (empty($prefixName)) { |
43 | 43 | return $topicTitle; |
44 | 44 | } |
45 | - $topicPrefix = $prefixColor ? '<em style="font-style: normal; color: ' . $prefixColor . ';">[' . $prefixName . ']</em> ' : '[' . $prefixName . '] '; |
|
45 | + $topicPrefix = $prefixColor ? '<em style="font-style: normal; color: '.$prefixColor.';">['.$prefixName.']</em> ' : '['.$prefixName.'] '; |
|
46 | 46 | |
47 | - return $topicPrefix . $topicTitle; |
|
47 | + return $topicPrefix.$topicTitle; |
|
48 | 48 | } |
49 | 49 | } |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | |
14 | 14 | // defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
15 | 15 | |
16 | -defined('NEWBB_FUNCTIONS_INI') || require_once __DIR__ . '/functions.ini.php'; |
|
16 | +defined('NEWBB_FUNCTIONS_INI') || require_once __DIR__.'/functions.ini.php'; |
|
17 | 17 | define('NEWBB_FUNCTIONS_FORUM_LOADED', true); |
18 | 18 | |
19 | 19 | if (!defined('NEWBB_FUNCTIONS_FORUM')) { |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | $groups = $xoopsUser->getGroups(); |
41 | 41 | } |
42 | 42 | sort($groups); |
43 | - $groupKey = 'forumselect_' . $permission . '_' . md5(implode(',', $groups)); |
|
44 | - $forums = $cacheHelper->cacheRead($groupKey, function () use ($categories, $permission) { |
|
43 | + $groupKey = 'forumselect_'.$permission.'_'.md5(implode(',', $groups)); |
|
44 | + $forums = $cacheHelper->cacheRead($groupKey, function() use ($categories, $permission) { |
|
45 | 45 | /** @var Newbb\CategoryHandler $categoryHandler */ |
46 | 46 | $categoryHandler = Newbb\Helper::getInstance()->getHandler('Category'); |
47 | 47 | $categories = $categoryHandler->getByPermission($permission, ['cat_id', 'cat_order', 'cat_title'], false); |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | if ($categoryDelimiter) { |
62 | 62 | $box .= "<option value=0> </option>\n"; |
63 | 63 | } |
64 | - $box .= "<option value='" . (-1 * $key) . "'>[" . $categories[$key]['cat_title'] . "]</option>\n"; |
|
64 | + $box .= "<option value='".(-1 * $key)."'>[".$categories[$key]['cat_title']."]</option>\n"; |
|
65 | 65 | if (empty($forums[$key])) { |
66 | 66 | continue; |
67 | 67 | } |
@@ -69,11 +69,11 @@ discard block |
||
69 | 69 | if ($see && in_array($f, $value)) { |
70 | 70 | continue; |
71 | 71 | } |
72 | - $box .= "<option value='{$f}' " . (in_array($f, $value) ? ' selected' : '') . '>' . $forum['prefix'] . $forum['forum_name'] . "</option>\n"; |
|
72 | + $box .= "<option value='{$f}' ".(in_array($f, $value) ? ' selected' : '').'>'.$forum['prefix'].$forum['forum_name']."</option>\n"; |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | } else { |
76 | - $box .= '<option value=0>' . _MD_NEWBB_NOFORUMINDB . "</option>\n"; |
|
76 | + $box .= '<option value=0>'._MD_NEWBB_NOFORUMINDB."</option>\n"; |
|
77 | 77 | } |
78 | 78 | unset($forums, $categories); |
79 | 79 | |
@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | */ |
87 | 87 | function newbbMakeJumpbox($forum_id = 0) |
88 | 88 | { |
89 | - $box = '<form name="forum_jumpbox" method="get" action="' . XOOPS_URL . '/modules/newbb/viewforum.php" onsubmit="javascript: if (document.forum_jumpbox.forum.value < 1) {return false;}">'; |
|
89 | + $box = '<form name="forum_jumpbox" method="get" action="'.XOOPS_URL.'/modules/newbb/viewforum.php" onsubmit="javascript: if (document.forum_jumpbox.forum.value < 1) {return false;}">'; |
|
90 | 90 | $box .= '<select class="select" name="forum" onchange="if (this.options[this.selectedIndex].value >0) { document.forms.forum_jumpbox.submit();}">'; |
91 | - $box .= '<option value=0>-- ' . _MD_NEWBB_SELFORUM . ' --</option>'; |
|
91 | + $box .= '<option value=0>-- '._MD_NEWBB_SELFORUM.' --</option>'; |
|
92 | 92 | $box .= newbbForumSelectBox($forum_id); |
93 | - $box .= "</select> <input type='submit' class='button' value='" . _GO . "' /></form>"; |
|
93 | + $box .= "</select> <input type='submit' class='button' value='"._GO."' /></form>"; |
|
94 | 94 | unset($forums, $categories); |
95 | 95 | |
96 | 96 | return $box; |
@@ -17,198 +17,198 @@ |
||
17 | 17 | define('NEWBB_FUNCTIONS_FORUM_LOADED', true); |
18 | 18 | |
19 | 19 | if (!defined('NEWBB_FUNCTIONS_FORUM')) { |
20 | - define('NEWBB_FUNCTIONS_FORUM', 1); |
|
21 | - |
|
22 | - /** |
|
23 | - * @param null|array $value selected forum id |
|
24 | - * @param string $permission permission (access, all, etc.) |
|
25 | - * @param bool $categoryDelimiter show delimiter between categories |
|
26 | - * @param bool $see |
|
27 | - * @return string |
|
28 | - */ |
|
29 | - function newbbForumSelectBox($value = null, $permission = 'access', $categoryDelimiter = true, $see = false) |
|
30 | - { |
|
31 | - global $xoopsUser; |
|
32 | - /** @var Newbb\CategoryHandler $categoryHandler */ |
|
33 | - $categoryHandler = Newbb\Helper::getInstance()->getHandler('Category'); |
|
34 | - $categories = $categoryHandler->getByPermission($permission, ['cat_id', 'cat_order', 'cat_title'], false); |
|
35 | - |
|
36 | - $cacheHelper = new \Xmf\Module\Helper\Cache('newbb'); |
|
37 | - |
|
38 | - $groups = [XOOPS_GROUP_ANONYMOUS]; |
|
39 | - if (is_object($xoopsUser)) { |
|
40 | - $groups = $xoopsUser->getGroups(); |
|
41 | - } |
|
42 | - sort($groups); |
|
43 | - $groupKey = 'forumselect_' . $permission . '_' . md5(implode(',', $groups)); |
|
44 | - $forums = $cacheHelper->cacheRead($groupKey, function () use ($categories, $permission) { |
|
45 | - /** @var Newbb\CategoryHandler $categoryHandler */ |
|
46 | - $categoryHandler = Newbb\Helper::getInstance()->getHandler('Category'); |
|
47 | - $categories = $categoryHandler->getByPermission($permission, ['cat_id', 'cat_order', 'cat_title'], false); |
|
48 | - |
|
49 | - /** @var Newbb\ForumHandler $forumHandler */ |
|
50 | - $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
|
51 | - $forums = $forumHandler->getTree(array_keys($categories), 0, 'all'); |
|
52 | - |
|
53 | - return $forums; |
|
54 | - }, 300); |
|
55 | - |
|
56 | - $value = is_array($value) ? $value : [$value]; |
|
57 | - //$see = is_array($see) ? $see : array($see); |
|
58 | - $box = ''; |
|
59 | - if (count($forums) > 0) { |
|
60 | - foreach (array_keys($categories) as $key) { |
|
61 | - if ($categoryDelimiter) { |
|
62 | - $box .= "<option value=0> </option>\n"; |
|
63 | - } |
|
64 | - $box .= "<option value='" . (-1 * $key) . "'>[" . $categories[$key]['cat_title'] . "]</option>\n"; |
|
65 | - if (empty($forums[$key])) { |
|
66 | - continue; |
|
67 | - } |
|
68 | - foreach ($forums[$key] as $f => $forum) { |
|
69 | - if ($see && in_array($f, $value)) { |
|
70 | - continue; |
|
71 | - } |
|
72 | - $box .= "<option value='{$f}' " . (in_array($f, $value) ? ' selected' : '') . '>' . $forum['prefix'] . $forum['forum_name'] . "</option>\n"; |
|
73 | - } |
|
74 | - } |
|
75 | - } else { |
|
76 | - $box .= '<option value=0>' . _MD_NEWBB_NOFORUMINDB . "</option>\n"; |
|
77 | - } |
|
78 | - unset($forums, $categories); |
|
79 | - |
|
80 | - return $box; |
|
81 | - } |
|
82 | - |
|
83 | - /** |
|
84 | - * @param int $forum_id |
|
85 | - * @return string |
|
86 | - */ |
|
87 | - function newbbMakeJumpbox($forum_id = 0) |
|
88 | - { |
|
89 | - $box = '<form name="forum_jumpbox" method="get" action="' . XOOPS_URL . '/modules/newbb/viewforum.php" onsubmit="javascript: if (document.forum_jumpbox.forum.value < 1) {return false;}">'; |
|
90 | - $box .= '<select class="select" name="forum" onchange="if (this.options[this.selectedIndex].value >0) { document.forms.forum_jumpbox.submit();}">'; |
|
91 | - $box .= '<option value=0>-- ' . _MD_NEWBB_SELFORUM . ' --</option>'; |
|
92 | - $box .= newbbForumSelectBox($forum_id); |
|
93 | - $box .= "</select> <input type='submit' class='button' value='" . _GO . "' /></form>"; |
|
94 | - unset($forums, $categories); |
|
95 | - |
|
96 | - return $box; |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * Get structured forums |
|
101 | - * |
|
102 | - * This is a temporary solution |
|
103 | - * To be substituted with a new tree handler |
|
104 | - * |
|
105 | - * @int integer $pid parent forum ID |
|
106 | - * |
|
107 | - * @param int $pid |
|
108 | - * @param bool $refresh |
|
109 | - * @return array |
|
110 | - */ |
|
111 | - function newbbGetSubForum($pid = 0, $refresh = false) |
|
112 | - { |
|
113 | - static $list; |
|
114 | - if (null === $list) { |
|
115 | - $cacheHelper = new \Xmf\Module\Helper\Cache('newbb'); |
|
116 | - $list = $cacheHelper->read('forum_sub'); |
|
117 | - } |
|
118 | - |
|
119 | - if (!is_array($list) || $refresh) { |
|
120 | - $list = newbbCreateSubForumList(); |
|
121 | - } |
|
122 | - if (0 == $pid) { |
|
123 | - return $list; |
|
124 | - } else { |
|
125 | - return @$list[$pid]; |
|
126 | - } |
|
127 | - } |
|
128 | - |
|
129 | - /** |
|
130 | - * @return array |
|
131 | - */ |
|
132 | - function newbbCreateSubForumList() |
|
133 | - { |
|
134 | - /** @var Newbb\ForumHandler $forumHandler */ |
|
20 | + define('NEWBB_FUNCTIONS_FORUM', 1); |
|
21 | + |
|
22 | + /** |
|
23 | + * @param null|array $value selected forum id |
|
24 | + * @param string $permission permission (access, all, etc.) |
|
25 | + * @param bool $categoryDelimiter show delimiter between categories |
|
26 | + * @param bool $see |
|
27 | + * @return string |
|
28 | + */ |
|
29 | + function newbbForumSelectBox($value = null, $permission = 'access', $categoryDelimiter = true, $see = false) |
|
30 | + { |
|
31 | + global $xoopsUser; |
|
32 | + /** @var Newbb\CategoryHandler $categoryHandler */ |
|
33 | + $categoryHandler = Newbb\Helper::getInstance()->getHandler('Category'); |
|
34 | + $categories = $categoryHandler->getByPermission($permission, ['cat_id', 'cat_order', 'cat_title'], false); |
|
35 | + |
|
36 | + $cacheHelper = new \Xmf\Module\Helper\Cache('newbb'); |
|
37 | + |
|
38 | + $groups = [XOOPS_GROUP_ANONYMOUS]; |
|
39 | + if (is_object($xoopsUser)) { |
|
40 | + $groups = $xoopsUser->getGroups(); |
|
41 | + } |
|
42 | + sort($groups); |
|
43 | + $groupKey = 'forumselect_' . $permission . '_' . md5(implode(',', $groups)); |
|
44 | + $forums = $cacheHelper->cacheRead($groupKey, function () use ($categories, $permission) { |
|
45 | + /** @var Newbb\CategoryHandler $categoryHandler */ |
|
46 | + $categoryHandler = Newbb\Helper::getInstance()->getHandler('Category'); |
|
47 | + $categories = $categoryHandler->getByPermission($permission, ['cat_id', 'cat_order', 'cat_title'], false); |
|
48 | + |
|
49 | + /** @var Newbb\ForumHandler $forumHandler */ |
|
50 | + $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
|
51 | + $forums = $forumHandler->getTree(array_keys($categories), 0, 'all'); |
|
52 | + |
|
53 | + return $forums; |
|
54 | + }, 300); |
|
55 | + |
|
56 | + $value = is_array($value) ? $value : [$value]; |
|
57 | + //$see = is_array($see) ? $see : array($see); |
|
58 | + $box = ''; |
|
59 | + if (count($forums) > 0) { |
|
60 | + foreach (array_keys($categories) as $key) { |
|
61 | + if ($categoryDelimiter) { |
|
62 | + $box .= "<option value=0> </option>\n"; |
|
63 | + } |
|
64 | + $box .= "<option value='" . (-1 * $key) . "'>[" . $categories[$key]['cat_title'] . "]</option>\n"; |
|
65 | + if (empty($forums[$key])) { |
|
66 | + continue; |
|
67 | + } |
|
68 | + foreach ($forums[$key] as $f => $forum) { |
|
69 | + if ($see && in_array($f, $value)) { |
|
70 | + continue; |
|
71 | + } |
|
72 | + $box .= "<option value='{$f}' " . (in_array($f, $value) ? ' selected' : '') . '>' . $forum['prefix'] . $forum['forum_name'] . "</option>\n"; |
|
73 | + } |
|
74 | + } |
|
75 | + } else { |
|
76 | + $box .= '<option value=0>' . _MD_NEWBB_NOFORUMINDB . "</option>\n"; |
|
77 | + } |
|
78 | + unset($forums, $categories); |
|
79 | + |
|
80 | + return $box; |
|
81 | + } |
|
82 | + |
|
83 | + /** |
|
84 | + * @param int $forum_id |
|
85 | + * @return string |
|
86 | + */ |
|
87 | + function newbbMakeJumpbox($forum_id = 0) |
|
88 | + { |
|
89 | + $box = '<form name="forum_jumpbox" method="get" action="' . XOOPS_URL . '/modules/newbb/viewforum.php" onsubmit="javascript: if (document.forum_jumpbox.forum.value < 1) {return false;}">'; |
|
90 | + $box .= '<select class="select" name="forum" onchange="if (this.options[this.selectedIndex].value >0) { document.forms.forum_jumpbox.submit();}">'; |
|
91 | + $box .= '<option value=0>-- ' . _MD_NEWBB_SELFORUM . ' --</option>'; |
|
92 | + $box .= newbbForumSelectBox($forum_id); |
|
93 | + $box .= "</select> <input type='submit' class='button' value='" . _GO . "' /></form>"; |
|
94 | + unset($forums, $categories); |
|
95 | + |
|
96 | + return $box; |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * Get structured forums |
|
101 | + * |
|
102 | + * This is a temporary solution |
|
103 | + * To be substituted with a new tree handler |
|
104 | + * |
|
105 | + * @int integer $pid parent forum ID |
|
106 | + * |
|
107 | + * @param int $pid |
|
108 | + * @param bool $refresh |
|
109 | + * @return array |
|
110 | + */ |
|
111 | + function newbbGetSubForum($pid = 0, $refresh = false) |
|
112 | + { |
|
113 | + static $list; |
|
114 | + if (null === $list) { |
|
115 | + $cacheHelper = new \Xmf\Module\Helper\Cache('newbb'); |
|
116 | + $list = $cacheHelper->read('forum_sub'); |
|
117 | + } |
|
118 | + |
|
119 | + if (!is_array($list) || $refresh) { |
|
120 | + $list = newbbCreateSubForumList(); |
|
121 | + } |
|
122 | + if (0 == $pid) { |
|
123 | + return $list; |
|
124 | + } else { |
|
125 | + return @$list[$pid]; |
|
126 | + } |
|
127 | + } |
|
128 | + |
|
129 | + /** |
|
130 | + * @return array |
|
131 | + */ |
|
132 | + function newbbCreateSubForumList() |
|
133 | + { |
|
134 | + /** @var Newbb\ForumHandler $forumHandler */ |
|
135 | 135 | // $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
136 | - $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
|
137 | - $criteria = new \CriteriaCompo(null, 1); |
|
138 | - $criteria->setSort('cat_id ASC, parent_forum ASC, forum_order'); |
|
139 | - $criteria->setOrder('ASC'); |
|
140 | - $forumsObject = $forumHandler->getObjects($criteria); |
|
136 | + $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
|
137 | + $criteria = new \CriteriaCompo(null, 1); |
|
138 | + $criteria->setSort('cat_id ASC, parent_forum ASC, forum_order'); |
|
139 | + $criteria->setOrder('ASC'); |
|
140 | + $forumsObject = $forumHandler->getObjects($criteria); |
|
141 | 141 | // require_once $GLOBALS['xoops']->path('modules/newbb/class/Tree.php'); |
142 | - $tree = new Newbb\ObjectTree($forumsObject, 'forum_id', 'parent_forum'); |
|
143 | - $forum_array = []; |
|
144 | - foreach (array_keys($forumsObject) as $key) { |
|
145 | - if (!$child = array_keys($tree->getAllChild($forumsObject[$key]->getVar('forum_id')))) { |
|
146 | - continue; |
|
147 | - } |
|
148 | - $forum_array[$forumsObject[$key]->getVar('forum_id')] = $child; |
|
149 | - } |
|
150 | - unset($forumsObject, $tree, $criteria); |
|
151 | - |
|
152 | - $cacheHelper = new \Xmf\Module\Helper\Cache('newbb'); |
|
153 | - $cacheHelper->write('forum_sub', $forum_array); |
|
154 | - |
|
155 | - return $forum_array; |
|
156 | - } |
|
157 | - |
|
158 | - /** |
|
159 | - * @param int $forum_id |
|
160 | - * @param bool $refresh |
|
161 | - * @return array|mixed|null |
|
162 | - */ |
|
163 | - function newbbGetParentForum($forum_id = 0, $refresh = false) |
|
164 | - { |
|
165 | - static $list = null; |
|
166 | - |
|
167 | - if (null === $list) { |
|
168 | - $cacheHelper = new \Xmf\Module\Helper\Cache('newbb'); |
|
169 | - $list = $cacheHelper->read('forum_parent'); |
|
170 | - } |
|
171 | - if (!is_array($list) || $refresh) { |
|
172 | - $list = newbbCreateParentForumList(); |
|
173 | - } |
|
174 | - if (0 == $forum_id) { |
|
175 | - return $list; |
|
176 | - } else { |
|
177 | - return @$list[$forum_id]; |
|
178 | - } |
|
179 | - } |
|
180 | - |
|
181 | - /** |
|
182 | - * @return array |
|
183 | - */ |
|
184 | - function newbbCreateParentForumList() |
|
185 | - { |
|
186 | - /** @var Newbb\ForumHandler $forumHandler */ |
|
187 | - $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
|
188 | - $criteria = new \Criteria('1', 1); |
|
189 | - $criteria->setSort('parent_forum'); |
|
190 | - $criteria->setOrder('ASC'); |
|
191 | - $forumsObject = $forumHandler->getObjects($criteria); |
|
142 | + $tree = new Newbb\ObjectTree($forumsObject, 'forum_id', 'parent_forum'); |
|
143 | + $forum_array = []; |
|
144 | + foreach (array_keys($forumsObject) as $key) { |
|
145 | + if (!$child = array_keys($tree->getAllChild($forumsObject[$key]->getVar('forum_id')))) { |
|
146 | + continue; |
|
147 | + } |
|
148 | + $forum_array[$forumsObject[$key]->getVar('forum_id')] = $child; |
|
149 | + } |
|
150 | + unset($forumsObject, $tree, $criteria); |
|
151 | + |
|
152 | + $cacheHelper = new \Xmf\Module\Helper\Cache('newbb'); |
|
153 | + $cacheHelper->write('forum_sub', $forum_array); |
|
154 | + |
|
155 | + return $forum_array; |
|
156 | + } |
|
157 | + |
|
158 | + /** |
|
159 | + * @param int $forum_id |
|
160 | + * @param bool $refresh |
|
161 | + * @return array|mixed|null |
|
162 | + */ |
|
163 | + function newbbGetParentForum($forum_id = 0, $refresh = false) |
|
164 | + { |
|
165 | + static $list = null; |
|
166 | + |
|
167 | + if (null === $list) { |
|
168 | + $cacheHelper = new \Xmf\Module\Helper\Cache('newbb'); |
|
169 | + $list = $cacheHelper->read('forum_parent'); |
|
170 | + } |
|
171 | + if (!is_array($list) || $refresh) { |
|
172 | + $list = newbbCreateParentForumList(); |
|
173 | + } |
|
174 | + if (0 == $forum_id) { |
|
175 | + return $list; |
|
176 | + } else { |
|
177 | + return @$list[$forum_id]; |
|
178 | + } |
|
179 | + } |
|
180 | + |
|
181 | + /** |
|
182 | + * @return array |
|
183 | + */ |
|
184 | + function newbbCreateParentForumList() |
|
185 | + { |
|
186 | + /** @var Newbb\ForumHandler $forumHandler */ |
|
187 | + $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
|
188 | + $criteria = new \Criteria('1', 1); |
|
189 | + $criteria->setSort('parent_forum'); |
|
190 | + $criteria->setOrder('ASC'); |
|
191 | + $forumsObject = $forumHandler->getObjects($criteria); |
|
192 | 192 | // require_once $GLOBALS['xoops']->path('modules/newbb/class/Tree.php'); |
193 | - $tree = new Newbb\ObjectTree($forumsObject, 'forum_id', 'parent_forum'); |
|
194 | - $forum_array = []; |
|
195 | - foreach (array_keys($forumsObject) as $key) { |
|
196 | - $parent_forum = $forumsObject[$key]->getVar('parent_forum'); |
|
197 | - if (!$parent_forum) { |
|
198 | - continue; |
|
199 | - } |
|
200 | - if (isset($forum_array[$parent_forum])) { |
|
201 | - $forum_array[$forumsObject[$key]->getVar('forum_id')] = $forum_array[$parent_forum]; |
|
202 | - $forum_array[$forumsObject[$key]->getVar('forum_id')][] = $parent_forum; |
|
203 | - } else { |
|
204 | - $forum_array[$forumsObject[$key]->getVar('forum_id')] = $tree->getParentForums($forumsObject[$key]->getVar('forum_id')); |
|
205 | - } |
|
206 | - } |
|
207 | - unset($forumsObject, $tree, $criteria); |
|
208 | - |
|
209 | - $cacheHelper = new \Xmf\Module\Helper\Cache('newbb'); |
|
210 | - $cacheHelper->write('forum_parent', $forum_array); |
|
211 | - |
|
212 | - return $forum_array; |
|
213 | - } |
|
193 | + $tree = new Newbb\ObjectTree($forumsObject, 'forum_id', 'parent_forum'); |
|
194 | + $forum_array = []; |
|
195 | + foreach (array_keys($forumsObject) as $key) { |
|
196 | + $parent_forum = $forumsObject[$key]->getVar('parent_forum'); |
|
197 | + if (!$parent_forum) { |
|
198 | + continue; |
|
199 | + } |
|
200 | + if (isset($forum_array[$parent_forum])) { |
|
201 | + $forum_array[$forumsObject[$key]->getVar('forum_id')] = $forum_array[$parent_forum]; |
|
202 | + $forum_array[$forumsObject[$key]->getVar('forum_id')][] = $parent_forum; |
|
203 | + } else { |
|
204 | + $forum_array[$forumsObject[$key]->getVar('forum_id')] = $tree->getParentForums($forumsObject[$key]->getVar('forum_id')); |
|
205 | + } |
|
206 | + } |
|
207 | + unset($forumsObject, $tree, $criteria); |
|
208 | + |
|
209 | + $cacheHelper = new \Xmf\Module\Helper\Cache('newbb'); |
|
210 | + $cacheHelper->write('forum_parent', $forum_array); |
|
211 | + |
|
212 | + return $forum_array; |
|
213 | + } |
|
214 | 214 | } |
@@ -17,75 +17,75 @@ |
||
17 | 17 | define('NEWBB_FUNCTIONS_READ_LOADED', true); |
18 | 18 | |
19 | 19 | if (!defined('NEWBB_FUNCTIONS_READ')) { |
20 | - define('NEWBB_FUNCTIONS_READ', 1); |
|
20 | + define('NEWBB_FUNCTIONS_READ', 1); |
|
21 | 21 | |
22 | - /** |
|
23 | - * @param $type |
|
24 | - * @param $item_id |
|
25 | - * @param $post_id |
|
26 | - * @param null $uid |
|
27 | - * @return mixed |
|
28 | - */ |
|
29 | - function newbbSetRead($type, $item_id, $post_id, $uid = null) |
|
30 | - { |
|
31 | - /** @var Newbb\ReadHandler $readHandler */ |
|
32 | - $readHandler = Newbb\Helper::getInstance()->getHandler('Read'.$type); |
|
22 | + /** |
|
23 | + * @param $type |
|
24 | + * @param $item_id |
|
25 | + * @param $post_id |
|
26 | + * @param null $uid |
|
27 | + * @return mixed |
|
28 | + */ |
|
29 | + function newbbSetRead($type, $item_id, $post_id, $uid = null) |
|
30 | + { |
|
31 | + /** @var Newbb\ReadHandler $readHandler */ |
|
32 | + $readHandler = Newbb\Helper::getInstance()->getHandler('Read'.$type); |
|
33 | 33 | |
34 | - return $readHandler->setRead($item_id, $post_id, $uid); |
|
35 | - } |
|
34 | + return $readHandler->setRead($item_id, $post_id, $uid); |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * @param $type |
|
39 | - * @param $item_id |
|
40 | - * @param null $uid |
|
41 | - * @return mixed |
|
42 | - */ |
|
43 | - function newbbGetRead($type, $item_id, $uid = null) |
|
44 | - { |
|
45 | - /** @var Newbb\ReadHandler $readHandler */ |
|
46 | - $readHandler = Newbb\Helper::getInstance()->getHandler('Read'.$type); |
|
37 | + /** |
|
38 | + * @param $type |
|
39 | + * @param $item_id |
|
40 | + * @param null $uid |
|
41 | + * @return mixed |
|
42 | + */ |
|
43 | + function newbbGetRead($type, $item_id, $uid = null) |
|
44 | + { |
|
45 | + /** @var Newbb\ReadHandler $readHandler */ |
|
46 | + $readHandler = Newbb\Helper::getInstance()->getHandler('Read'.$type); |
|
47 | 47 | |
48 | - return $readHandler->getRead($item_id, $uid); |
|
49 | - } |
|
48 | + return $readHandler->getRead($item_id, $uid); |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * @param int $status |
|
53 | - * @param null $uid |
|
54 | - * @return mixed |
|
55 | - */ |
|
56 | - function newbbSetReadForum($status = 0, $uid = null) |
|
57 | - { |
|
58 | - /** @var Newbb\ReadForumHandler $readHandler */ |
|
59 | - $readForumHandler = Newbb\Helper::getInstance()->getHandler('Readforum'); |
|
51 | + /** |
|
52 | + * @param int $status |
|
53 | + * @param null $uid |
|
54 | + * @return mixed |
|
55 | + */ |
|
56 | + function newbbSetReadForum($status = 0, $uid = null) |
|
57 | + { |
|
58 | + /** @var Newbb\ReadForumHandler $readHandler */ |
|
59 | + $readForumHandler = Newbb\Helper::getInstance()->getHandler('Readforum'); |
|
60 | 60 | |
61 | - return $readForumHandler->setReadItems($status, $uid); |
|
62 | - } |
|
61 | + return $readForumHandler->setReadItems($status, $uid); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @param int $status |
|
66 | - * @param int $forum_id |
|
67 | - * @param null $uid |
|
68 | - * @return mixed |
|
69 | - */ |
|
70 | - function newbbSetReadTopic($status = 0, $forum_id = 0, $uid = null) |
|
71 | - { |
|
72 | - /** @var Newbb\ReadtopicHandler $readHandler */ |
|
73 | - $readTopicHandler = Newbb\Helper::getInstance()->getHandler('Readtopic'); |
|
64 | + /** |
|
65 | + * @param int $status |
|
66 | + * @param int $forum_id |
|
67 | + * @param null $uid |
|
68 | + * @return mixed |
|
69 | + */ |
|
70 | + function newbbSetReadTopic($status = 0, $forum_id = 0, $uid = null) |
|
71 | + { |
|
72 | + /** @var Newbb\ReadtopicHandler $readHandler */ |
|
73 | + $readTopicHandler = Newbb\Helper::getInstance()->getHandler('Readtopic'); |
|
74 | 74 | |
75 | - return $readTopicHandler->setReadItems($status, $forum_id, $uid); |
|
76 | - } |
|
75 | + return $readTopicHandler->setReadItems($status, $forum_id, $uid); |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * @param $type |
|
80 | - * @param $items |
|
81 | - * @param null $uid |
|
82 | - * @return mixed |
|
83 | - */ |
|
84 | - function newbbIsRead($type, &$items, $uid = null) |
|
85 | - { |
|
86 | - /** @var Newbb\ReadHandler $readHandler */ |
|
87 | - $readHandler = Newbb\Helper::getInstance()->getHandler('Read'.$type); |
|
78 | + /** |
|
79 | + * @param $type |
|
80 | + * @param $items |
|
81 | + * @param null $uid |
|
82 | + * @return mixed |
|
83 | + */ |
|
84 | + function newbbIsRead($type, &$items, $uid = null) |
|
85 | + { |
|
86 | + /** @var Newbb\ReadHandler $readHandler */ |
|
87 | + $readHandler = Newbb\Helper::getInstance()->getHandler('Read'.$type); |
|
88 | 88 | |
89 | - return $readHandler->isReadItems($items, $uid); |
|
90 | - } |
|
89 | + return $readHandler->isReadItems($items, $uid); |
|
90 | + } |
|
91 | 91 | } |
@@ -13,7 +13,7 @@ |
||
13 | 13 | |
14 | 14 | // defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
15 | 15 | |
16 | -defined('NEWBB_FUNCTIONS_INI') || require_once __DIR__ . '/functions.ini.php'; |
|
16 | +defined('NEWBB_FUNCTIONS_INI') || require_once __DIR__.'/functions.ini.php'; |
|
17 | 17 | define('NEWBB_FUNCTIONS_READ_LOADED', true); |
18 | 18 | |
19 | 19 | if (!defined('NEWBB_FUNCTIONS_READ')) { |
@@ -15,12 +15,12 @@ |
||
15 | 15 | define('NEWBB_FUNCTIONS_LOADED', true); |
16 | 16 | |
17 | 17 | if (!defined('NEWBB_FUNCTIONS')) { |
18 | - define('NEWBB_FUNCTIONS', 1); |
|
18 | + define('NEWBB_FUNCTIONS', 1); |
|
19 | 19 | |
20 | - require_once __DIR__ . '/functions.image.php'; |
|
21 | - require_once __DIR__ . '/functions.user.php'; |
|
22 | - require_once __DIR__ . '/functions.render.php'; |
|
23 | - require_once __DIR__ . '/functions.forum.php'; |
|
24 | - require_once __DIR__ . '/functions.session.php'; |
|
25 | - require_once __DIR__ . '/functions.stats.php'; |
|
20 | + require_once __DIR__ . '/functions.image.php'; |
|
21 | + require_once __DIR__ . '/functions.user.php'; |
|
22 | + require_once __DIR__ . '/functions.render.php'; |
|
23 | + require_once __DIR__ . '/functions.forum.php'; |
|
24 | + require_once __DIR__ . '/functions.session.php'; |
|
25 | + require_once __DIR__ . '/functions.stats.php'; |
|
26 | 26 | } |
@@ -11,16 +11,16 @@ |
||
11 | 11 | |
12 | 12 | // defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
13 | 13 | |
14 | -defined('NEWBB_FUNCTIONS_INI') || require_once __DIR__ . '/functions.ini.php'; |
|
14 | +defined('NEWBB_FUNCTIONS_INI') || require_once __DIR__.'/functions.ini.php'; |
|
15 | 15 | define('NEWBB_FUNCTIONS_LOADED', true); |
16 | 16 | |
17 | 17 | if (!defined('NEWBB_FUNCTIONS')) { |
18 | 18 | define('NEWBB_FUNCTIONS', 1); |
19 | 19 | |
20 | - require_once __DIR__ . '/functions.image.php'; |
|
21 | - require_once __DIR__ . '/functions.user.php'; |
|
22 | - require_once __DIR__ . '/functions.render.php'; |
|
23 | - require_once __DIR__ . '/functions.forum.php'; |
|
24 | - require_once __DIR__ . '/functions.session.php'; |
|
25 | - require_once __DIR__ . '/functions.stats.php'; |
|
20 | + require_once __DIR__.'/functions.image.php'; |
|
21 | + require_once __DIR__.'/functions.user.php'; |
|
22 | + require_once __DIR__.'/functions.render.php'; |
|
23 | + require_once __DIR__.'/functions.forum.php'; |
|
24 | + require_once __DIR__.'/functions.session.php'; |
|
25 | + require_once __DIR__.'/functions.stats.php'; |
|
26 | 26 | } |
@@ -17,97 +17,97 @@ |
||
17 | 17 | define('NEWBB_FUNCTIONS_STATS_LOADED', true); |
18 | 18 | |
19 | 19 | if (!defined('NEWBB_FUNCTIONS_STATS')) { |
20 | - define('NEWBB_FUNCTIONS_STATS', 1); |
|
20 | + define('NEWBB_FUNCTIONS_STATS', 1); |
|
21 | 21 | |
22 | - /** |
|
23 | - * @return mixed |
|
24 | - */ |
|
25 | - function newbbGetStats() |
|
26 | - { |
|
27 | - /** @var Newbb\StatsHandler $statsHandler */ |
|
28 | - $statsHandler = Newbb\Helper::getInstance()->getHandler('Stats'); |
|
29 | - $stats = $statsHandler->getStats(); |
|
22 | + /** |
|
23 | + * @return mixed |
|
24 | + */ |
|
25 | + function newbbGetStats() |
|
26 | + { |
|
27 | + /** @var Newbb\StatsHandler $statsHandler */ |
|
28 | + $statsHandler = Newbb\Helper::getInstance()->getHandler('Stats'); |
|
29 | + $stats = $statsHandler->getStats(); |
|
30 | 30 | |
31 | - return $stats; |
|
32 | - } |
|
31 | + return $stats; |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * @param $id |
|
36 | - * @param $type |
|
37 | - * @param int $increment |
|
38 | - * @return mixed |
|
39 | - */ |
|
40 | - function newbbUpdateStats($id, $type, $increment = 1) |
|
41 | - { |
|
42 | - /** @var Newbb\StatsHandler $statsHandler */ |
|
43 | - $statsHandler = Newbb\Helper::getInstance()->getHandler('Stats'); |
|
34 | + /** |
|
35 | + * @param $id |
|
36 | + * @param $type |
|
37 | + * @param int $increment |
|
38 | + * @return mixed |
|
39 | + */ |
|
40 | + function newbbUpdateStats($id, $type, $increment = 1) |
|
41 | + { |
|
42 | + /** @var Newbb\StatsHandler $statsHandler */ |
|
43 | + $statsHandler = Newbb\Helper::getInstance()->getHandler('Stats'); |
|
44 | 44 | |
45 | - return $statsHandler->update($id, $type, $increment); |
|
46 | - } |
|
45 | + return $statsHandler->update($id, $type, $increment); |
|
46 | + } |
|
47 | 47 | |
48 | - /* |
|
48 | + /* |
|
49 | 49 | * Gets the total number of topics in a form |
50 | 50 | */ |
51 | - /** |
|
52 | - * @param string $forum_id |
|
53 | - * @return mixed |
|
54 | - */ |
|
55 | - function getTotalTopics($forum_id = '') |
|
56 | - { |
|
57 | - /** @var Newbb\TopicHandler $topicHandler */ |
|
58 | - $topicHandler = Newbb\Helper::getInstance()->getHandler('Topic'); |
|
59 | - $criteria = new \CriteriaCompo(new \Criteria('approved', 0, '>')); |
|
60 | - if ($forum_id) { |
|
61 | - $criteria->add(new \Criteria('forum_id', (int)$forum_id)); |
|
62 | - } |
|
51 | + /** |
|
52 | + * @param string $forum_id |
|
53 | + * @return mixed |
|
54 | + */ |
|
55 | + function getTotalTopics($forum_id = '') |
|
56 | + { |
|
57 | + /** @var Newbb\TopicHandler $topicHandler */ |
|
58 | + $topicHandler = Newbb\Helper::getInstance()->getHandler('Topic'); |
|
59 | + $criteria = new \CriteriaCompo(new \Criteria('approved', 0, '>')); |
|
60 | + if ($forum_id) { |
|
61 | + $criteria->add(new \Criteria('forum_id', (int)$forum_id)); |
|
62 | + } |
|
63 | 63 | |
64 | - return $topicHandler->getCount($criteria); |
|
65 | - } |
|
64 | + return $topicHandler->getCount($criteria); |
|
65 | + } |
|
66 | 66 | |
67 | - /* |
|
67 | + /* |
|
68 | 68 | * Returns the total number of posts in the whole system, a forum, or a topic |
69 | 69 | * Also can return the number of users on the system. |
70 | 70 | */ |
71 | - /** |
|
72 | - * @param int $id |
|
73 | - * @param string $type |
|
74 | - * @return mixed |
|
75 | - */ |
|
76 | - function getTotalPosts($id = 0, $type = 'all') |
|
77 | - { |
|
78 | - /** @var Newbb\PostHandler $postHandler */ |
|
79 | - $postHandler = Newbb\Helper::getInstance()->getHandler('Post'); |
|
80 | - $criteria = new \CriteriaCompo(new \Criteria('approved', 0, '>')); |
|
81 | - switch ($type) { |
|
82 | - case 'forum': |
|
83 | - if ($id > 0) { |
|
84 | - $criteria->add(new \Criteria('forum_id', (int)$id)); |
|
85 | - } |
|
86 | - break; |
|
87 | - case 'topic': |
|
88 | - if ($id > 0) { |
|
89 | - $criteria->add(new \Criteria('topic_id', (int)$id)); |
|
90 | - } |
|
91 | - break; |
|
92 | - case 'all': |
|
93 | - default: |
|
94 | - break; |
|
95 | - } |
|
71 | + /** |
|
72 | + * @param int $id |
|
73 | + * @param string $type |
|
74 | + * @return mixed |
|
75 | + */ |
|
76 | + function getTotalPosts($id = 0, $type = 'all') |
|
77 | + { |
|
78 | + /** @var Newbb\PostHandler $postHandler */ |
|
79 | + $postHandler = Newbb\Helper::getInstance()->getHandler('Post'); |
|
80 | + $criteria = new \CriteriaCompo(new \Criteria('approved', 0, '>')); |
|
81 | + switch ($type) { |
|
82 | + case 'forum': |
|
83 | + if ($id > 0) { |
|
84 | + $criteria->add(new \Criteria('forum_id', (int)$id)); |
|
85 | + } |
|
86 | + break; |
|
87 | + case 'topic': |
|
88 | + if ($id > 0) { |
|
89 | + $criteria->add(new \Criteria('topic_id', (int)$id)); |
|
90 | + } |
|
91 | + break; |
|
92 | + case 'all': |
|
93 | + default: |
|
94 | + break; |
|
95 | + } |
|
96 | 96 | |
97 | - return $postHandler->getCount($criteria); |
|
98 | - } |
|
97 | + return $postHandler->getCount($criteria); |
|
98 | + } |
|
99 | 99 | |
100 | - /** |
|
101 | - * @return null |
|
102 | - */ |
|
103 | - function getTotalViews() |
|
104 | - { |
|
105 | - $sql = 'SELECT sum(topic_views) FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . ' '; |
|
106 | - if (!$result = $GLOBALS['xoopsDB']->query($sql)) { |
|
107 | - return null; |
|
108 | - } |
|
109 | - list($total) = $GLOBALS['xoopsDB']->fetchRow($result); |
|
100 | + /** |
|
101 | + * @return null |
|
102 | + */ |
|
103 | + function getTotalViews() |
|
104 | + { |
|
105 | + $sql = 'SELECT sum(topic_views) FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . ' '; |
|
106 | + if (!$result = $GLOBALS['xoopsDB']->query($sql)) { |
|
107 | + return null; |
|
108 | + } |
|
109 | + list($total) = $GLOBALS['xoopsDB']->fetchRow($result); |
|
110 | 110 | |
111 | - return $total; |
|
112 | - } |
|
111 | + return $total; |
|
112 | + } |
|
113 | 113 | } |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | |
14 | 14 | // defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
15 | 15 | |
16 | -defined('NEWBB_FUNCTIONS_INI') || require_once __DIR__ . '/functions.ini.php'; |
|
16 | +defined('NEWBB_FUNCTIONS_INI') || require_once __DIR__.'/functions.ini.php'; |
|
17 | 17 | define('NEWBB_FUNCTIONS_STATS_LOADED', true); |
18 | 18 | |
19 | 19 | if (!defined('NEWBB_FUNCTIONS_STATS')) { |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | $topicHandler = Newbb\Helper::getInstance()->getHandler('Topic'); |
59 | 59 | $criteria = new \CriteriaCompo(new \Criteria('approved', 0, '>')); |
60 | 60 | if ($forum_id) { |
61 | - $criteria->add(new \Criteria('forum_id', (int)$forum_id)); |
|
61 | + $criteria->add(new \Criteria('forum_id', (int) $forum_id)); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | return $topicHandler->getCount($criteria); |
@@ -81,12 +81,12 @@ discard block |
||
81 | 81 | switch ($type) { |
82 | 82 | case 'forum': |
83 | 83 | if ($id > 0) { |
84 | - $criteria->add(new \Criteria('forum_id', (int)$id)); |
|
84 | + $criteria->add(new \Criteria('forum_id', (int) $id)); |
|
85 | 85 | } |
86 | 86 | break; |
87 | 87 | case 'topic': |
88 | 88 | if ($id > 0) { |
89 | - $criteria->add(new \Criteria('topic_id', (int)$id)); |
|
89 | + $criteria->add(new \Criteria('topic_id', (int) $id)); |
|
90 | 90 | } |
91 | 91 | break; |
92 | 92 | case 'all': |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | function getTotalViews() |
104 | 104 | { |
105 | - $sql = 'SELECT sum(topic_views) FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . ' '; |
|
105 | + $sql = 'SELECT sum(topic_views) FROM '.$GLOBALS['xoopsDB']->prefix('newbb_topics').' '; |
|
106 | 106 | if (!$result = $GLOBALS['xoopsDB']->query($sql)) { |
107 | 107 | return null; |
108 | 108 | } |