@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /* Copyright (C) NAVER <http://www.navercorp.com> */ |
3 | 3 | |
4 | -if(!defined("__XE__")) exit(); |
|
4 | +if (!defined("__XE__")) exit(); |
|
5 | 5 | |
6 | 6 | /** |
7 | 7 | * @file captcha.addon.php |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @brief Captcha for a particular action |
10 | 10 | * English alphabets and voice verification added |
11 | 11 | * */ |
12 | -if(!class_exists('AddonMemberCaptcha', false)) |
|
12 | +if (!class_exists('AddonMemberCaptcha', false)) |
|
13 | 13 | { |
14 | 14 | class AddonMemberCaptcha |
15 | 15 | { |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | function before_module_init(&$ModuleHandler) |
33 | 33 | { |
34 | 34 | $logged_info = Context::get('logged_info'); |
35 | - if($logged_info->is_admin == 'Y' || $logged_info->is_site_admin) |
|
35 | + if ($logged_info->is_admin == 'Y' || $logged_info->is_site_admin) |
|
36 | 36 | { |
37 | 37 | return false; |
38 | 38 | } |
@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | // { |
41 | 41 | // return false; |
42 | 42 | // } |
43 | - if($_SESSION['XE_VALIDATOR_ERROR'] == -1) |
|
43 | + if ($_SESSION['XE_VALIDATOR_ERROR'] == -1) |
|
44 | 44 | { |
45 | 45 | $_SESSION['member_captcha_authed'] = false; |
46 | 46 | } |
47 | - if($_SESSION['member_captcha_authed']) |
|
47 | + if ($_SESSION['member_captcha_authed']) |
|
48 | 48 | { |
49 | 49 | return false; |
50 | 50 | } |
@@ -52,26 +52,26 @@ discard block |
||
52 | 52 | $type = Context::get('captchaType'); |
53 | 53 | |
54 | 54 | $this->target_acts = array(); |
55 | - if($this->addon_info->apply_find_account == 'apply') |
|
55 | + if ($this->addon_info->apply_find_account == 'apply') |
|
56 | 56 | { |
57 | 57 | $this->target_acts[] = 'procMemberFindAccount'; |
58 | 58 | } |
59 | - if($this->addon_info->apply_resend_auth_mail == 'apply') |
|
59 | + if ($this->addon_info->apply_resend_auth_mail == 'apply') |
|
60 | 60 | { |
61 | 61 | $this->target_acts[] = 'procMemberResendAuthMail'; |
62 | 62 | } |
63 | - if($this->addon_info->apply_signup == 'apply') |
|
63 | + if ($this->addon_info->apply_signup == 'apply') |
|
64 | 64 | { |
65 | 65 | $this->target_acts[] = 'procMemberInsert'; |
66 | 66 | } |
67 | 67 | |
68 | - if(Context::getRequestMethod() != 'XMLRPC' && Context::getRequestMethod() !== 'JSON') |
|
68 | + if (Context::getRequestMethod() != 'XMLRPC' && Context::getRequestMethod() !== 'JSON') |
|
69 | 69 | { |
70 | - if($type == 'inline') |
|
70 | + if ($type == 'inline') |
|
71 | 71 | { |
72 | - if(!$this->compareCaptcha()) |
|
72 | + if (!$this->compareCaptcha()) |
|
73 | 73 | { |
74 | - Context::loadLang(_XE_PATH_ . 'addons/captcha_member/lang'); |
|
74 | + Context::loadLang(_XE_PATH_.'addons/captcha_member/lang'); |
|
75 | 75 | $_SESSION['XE_VALIDATOR_ERROR'] = -1; |
76 | 76 | $_SESSION['XE_VALIDATOR_MESSAGE'] = Context::getLang('captcha_denied'); |
77 | 77 | $_SESSION['XE_VALIDATOR_MESSAGE_TYPE'] = 'error'; |
@@ -83,16 +83,16 @@ discard block |
||
83 | 83 | { |
84 | 84 | Context::addHtmlHeader('<script> |
85 | 85 | if(!captchaTargetAct) {var captchaTargetAct = [];} |
86 | - captchaTargetAct.push("' . implode('","', $this->target_acts) . '"); |
|
86 | + captchaTargetAct.push("' . implode('","', $this->target_acts).'"); |
|
87 | 87 | </script>'); |
88 | 88 | Context::loadFile(array('./addons/captcha_member/captcha.min.js', 'body', '', null), true); |
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
92 | 92 | // compare session when calling actions such as writing a post or a comment on the board/issue tracker module |
93 | - if(!$_SESSION['member_captcha_authed'] && in_array(Context::get('act'), $this->target_acts)) |
|
93 | + if (!$_SESSION['member_captcha_authed'] && in_array(Context::get('act'), $this->target_acts)) |
|
94 | 94 | { |
95 | - Context::loadLang(_XE_PATH_ . 'addons/captcha_member/lang'); |
|
95 | + Context::loadLang(_XE_PATH_.'addons/captcha_member/lang'); |
|
96 | 96 | $ModuleHandler->error = "captcha_denied"; |
97 | 97 | } |
98 | 98 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | function createKeyword() |
103 | 103 | { |
104 | 104 | $type = Context::get('captchaType'); |
105 | - if($type == 'inline' && $_SESSION['captcha_keyword']) |
|
105 | + if ($type == 'inline' && $_SESSION['captcha_keyword']) |
|
106 | 106 | { |
107 | 107 | return; |
108 | 108 | } |
@@ -115,19 +115,19 @@ discard block |
||
115 | 115 | |
116 | 116 | function before_module_init_setCaptchaSession() |
117 | 117 | { |
118 | - if($_SESSION['member_captcha_authed']) |
|
118 | + if ($_SESSION['member_captcha_authed']) |
|
119 | 119 | { |
120 | 120 | return false; |
121 | 121 | } |
122 | 122 | // Load language files |
123 | - Context::loadLang(_XE_PATH_ . 'addons/captcha_member/lang'); |
|
123 | + Context::loadLang(_XE_PATH_.'addons/captcha_member/lang'); |
|
124 | 124 | // Generate keywords |
125 | 125 | $this->createKeyword(); |
126 | 126 | |
127 | 127 | $target = Context::getLang('target_captcha'); |
128 | 128 | header("Content-Type: text/xml; charset=UTF-8"); |
129 | 129 | header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); |
130 | - header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); |
|
130 | + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); |
|
131 | 131 | header("Cache-Control: no-store, no-cache, must-revalidate"); |
132 | 132 | header("Cache-Control: post-check=0, pre-check=0", false); |
133 | 133 | header("Pragma: no-cache"); |
@@ -144,11 +144,11 @@ discard block |
||
144 | 144 | |
145 | 145 | function before_module_init_captchaImage() |
146 | 146 | { |
147 | - if($_SESSION['member_captcha_authed']) |
|
147 | + if ($_SESSION['member_captcha_authed']) |
|
148 | 148 | { |
149 | 149 | return false; |
150 | 150 | } |
151 | - if(Context::get('renew')) |
|
151 | + if (Context::get('renew')) |
|
152 | 152 | { |
153 | 153 | $this->createKeyword(); |
154 | 154 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | function createCaptchaImage($string) |
171 | 171 | { |
172 | 172 | $arr = array(); |
173 | - for($i = 0, $c = strlen($string); $i < $c; $i++) |
|
173 | + for ($i = 0, $c = strlen($string); $i < $c; $i++) |
|
174 | 174 | { |
175 | 175 | $arr[] = $string{$i}; |
176 | 176 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | shuffle($deg); |
193 | 193 | |
194 | 194 | // Create an image for each letter |
195 | - foreach($arr as $i => $str) |
|
195 | + foreach ($arr as $i => $str) |
|
196 | 196 | { |
197 | 197 | $im[$i + 1] = @imagecreate($w, $h); |
198 | 198 | $background_color = imagecolorallocate($im[$i + 1], 255, 255, 255); |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | $ran = range(1, 20); |
203 | 203 | shuffle($ran); |
204 | 204 | |
205 | - if(function_exists('imagerotate')) |
|
205 | + if (function_exists('imagerotate')) |
|
206 | 206 | { |
207 | 207 | imagestring($im[$i + 1], (array_pop($ran) % 3) + 3, 2, (array_pop($ran) % 8), $str, $text_color); |
208 | 208 | $im[$i + 1] = imagerotate($im[$i + 1], array_pop($deg), 0); |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | } |
218 | 218 | |
219 | 219 | // Combine images of each character |
220 | - for($i = 1; $i < count($im); $i++) |
|
220 | + for ($i = 1; $i < count($im); $i++) |
|
221 | 221 | { |
222 | 222 | imagecopy($im[0], $im[$i], (($w + 2) * ($i - 1)), 0, 0, 0, $w, $h); |
223 | 223 | imagedestroy($im[$i]); |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | imagecopyresized($big, $im[0], 0, 0, 0, 0, ($w + 2) * $big_count * $c, $h * $big_count, ($w + 2) * $c, $h); |
230 | 230 | imagedestroy($im[0]); |
231 | 231 | |
232 | - if(function_exists('imageantialias')) |
|
232 | + if (function_exists('imageantialias')) |
|
233 | 233 | { |
234 | 234 | imageantialias($big, true); |
235 | 235 | } |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | $h = $h * $big_count; |
242 | 242 | $d = array_pop($deg); |
243 | 243 | |
244 | - for($i = -abs($d); $i < $h + abs($d); $i = $i + 7) |
|
244 | + for ($i = -abs($d); $i < $h + abs($d); $i = $i + 7) |
|
245 | 245 | { |
246 | 246 | imageline($big, 0, $i + $d, $w, $i, $line_color); |
247 | 247 | } |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | $x = range(0, ($w - 10)); |
250 | 250 | shuffle($x); |
251 | 251 | |
252 | - for($i = 0; $i < 200; $i++) |
|
252 | + for ($i = 0; $i < 200; $i++) |
|
253 | 253 | { |
254 | 254 | imagesetpixel($big, $x[$i] % $w, $x[$i + 1] % $h, $line_color); |
255 | 255 | } |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | |
260 | 260 | function before_module_init_captchaAudio() |
261 | 261 | { |
262 | - if($_SESSION['member_captcha_authed']) |
|
262 | + if ($_SESSION['member_captcha_authed']) |
|
263 | 263 | { |
264 | 264 | return false; |
265 | 265 | } |
@@ -271,8 +271,8 @@ discard block |
||
271 | 271 | header("Content-Disposition: attachment; filename=\"captcha_audio.mp3\""); |
272 | 272 | header('Cache-Control: no-store, no-cache, must-revalidate'); |
273 | 273 | header('Expires: Sun, 1 Jan 2000 12:00:00 GMT'); |
274 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . 'GMT'); |
|
275 | - header('Content-Length: ' . strlen($data)); |
|
274 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s').'GMT'); |
|
275 | + header('Content-Length: '.strlen($data)); |
|
276 | 276 | |
277 | 277 | echo $data; |
278 | 278 | Context::close(); |
@@ -283,17 +283,17 @@ discard block |
||
283 | 283 | { |
284 | 284 | $data = ''; |
285 | 285 | $_audio = './addons/captcha_member/audio/F_%s.mp3'; |
286 | - for($i = 0, $c = strlen($string); $i < $c; $i++) |
|
286 | + for ($i = 0, $c = strlen($string); $i < $c; $i++) |
|
287 | 287 | { |
288 | 288 | $_data = FileHandler::readFile(sprintf($_audio, $string{$i})); |
289 | 289 | |
290 | 290 | $start = rand(5, 68); // Random start in 4-byte header and 64 byte data |
291 | 291 | $datalen = strlen($_data) - $start - 256; // Last unchanged 256 bytes |
292 | 292 | |
293 | - for($j = $start; $j < $datalen; $j+=64) |
|
293 | + for ($j = $start; $j < $datalen; $j += 64) |
|
294 | 294 | { |
295 | 295 | $ch = ord($_data{$j}); |
296 | - if($ch < 9 || $ch > 119) |
|
296 | + if ($ch < 9 || $ch > 119) |
|
297 | 297 | { |
298 | 298 | continue; |
299 | 299 | } |
@@ -308,14 +308,14 @@ discard block |
||
308 | 308 | |
309 | 309 | function compareCaptcha() |
310 | 310 | { |
311 | - if(!in_array(Context::get('act'), $this->target_acts)) return true; |
|
311 | + if (!in_array(Context::get('act'), $this->target_acts)) return true; |
|
312 | 312 | |
313 | - if($_SESSION['member_captcha_authed']) |
|
313 | + if ($_SESSION['member_captcha_authed']) |
|
314 | 314 | { |
315 | 315 | return true; |
316 | 316 | } |
317 | 317 | |
318 | - if(strtoupper($_SESSION['captcha_keyword']) == strtoupper(Context::get('secret_text'))) |
|
318 | + if (strtoupper($_SESSION['captcha_keyword']) == strtoupper(Context::get('secret_text'))) |
|
319 | 319 | { |
320 | 320 | $_SESSION['member_captcha_authed'] = true; |
321 | 321 | return true; |
@@ -328,14 +328,14 @@ discard block |
||
328 | 328 | |
329 | 329 | function before_module_init_captchaCompare() |
330 | 330 | { |
331 | - if(!$this->compareCaptcha()) |
|
331 | + if (!$this->compareCaptcha()) |
|
332 | 332 | { |
333 | 333 | return false; |
334 | 334 | } |
335 | 335 | |
336 | 336 | header("Content-Type: text/xml; charset=UTF-8"); |
337 | 337 | header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); |
338 | - header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); |
|
338 | + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); |
|
339 | 339 | header("Cache-Control: no-store, no-cache, must-revalidate"); |
340 | 340 | header("Cache-Control: post-check=0, pre-check=0", false); |
341 | 341 | header("Pragma: no-cache"); |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | unset($_SESSION['member_captcha_authed']); |
351 | 351 | $this->createKeyword(); |
352 | 352 | |
353 | - $swfURL = getUrl() . 'addons/captcha_member/swf/play.swf'; |
|
353 | + $swfURL = getUrl().'addons/captcha_member/swf/play.swf'; |
|
354 | 354 | Context::unloadFile('./addons/captcha_member/captcha.min.js'); |
355 | 355 | Context::loadFile(array('./addons/captcha_member/inline_captcha.js', 'body')); |
356 | 356 | |
@@ -388,18 +388,18 @@ discard block |
||
388 | 388 | |
389 | 389 | $oAddonMemberCaptcha = &$GLOBALS['__AddonMemberCaptcha__']; |
390 | 390 | |
391 | -if(method_exists($oAddonMemberCaptcha, $called_position)) |
|
391 | +if (method_exists($oAddonMemberCaptcha, $called_position)) |
|
392 | 392 | { |
393 | - if(!call_user_func_array(array(&$oAddonMemberCaptcha, $called_position), array(&$this))) |
|
393 | + if (!call_user_func_array(array(&$oAddonMemberCaptcha, $called_position), array(&$this))) |
|
394 | 394 | { |
395 | 395 | return false; |
396 | 396 | } |
397 | 397 | } |
398 | 398 | |
399 | 399 | $addon_act = Context::get('captcha_action'); |
400 | -if($addon_act && method_exists($oAddonMemberCaptcha, $called_position . '_' . $addon_act)) |
|
400 | +if ($addon_act && method_exists($oAddonMemberCaptcha, $called_position.'_'.$addon_act)) |
|
401 | 401 | { |
402 | - if(!call_user_func_array(array(&$oAddonMemberCaptcha, $called_position . '_' . $addon_act), array(&$this))) |
|
402 | + if (!call_user_func_array(array(&$oAddonMemberCaptcha, $called_position.'_'.$addon_act), array(&$this))) |
|
403 | 403 | { |
404 | 404 | return false; |
405 | 405 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /* Copyright (C) NAVER <http://www.navercorp.com> */ |
3 | 3 | |
4 | -if(!defined("__XE__")) exit(); |
|
4 | +if (!defined("__XE__")) exit(); |
|
5 | 5 | |
6 | 6 | /** |
7 | 7 | * @file captcha.addon.php |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @brief Captcha for a particular action |
10 | 10 | * English alphabets and voice verification added |
11 | 11 | * */ |
12 | -if(!class_exists('AddonCaptcha', false)) |
|
12 | +if (!class_exists('AddonCaptcha', false)) |
|
13 | 13 | { |
14 | 14 | class AddonCaptcha |
15 | 15 | { |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | function before_module_proc() |
26 | 26 | { |
27 | - if($this->addon_info->act_type == 'everytime' && $_SESSION['captcha_authed']) |
|
27 | + if ($this->addon_info->act_type == 'everytime' && $_SESSION['captcha_authed']) |
|
28 | 28 | { |
29 | 29 | unset($_SESSION['captcha_authed']); |
30 | 30 | } |
@@ -33,19 +33,19 @@ discard block |
||
33 | 33 | function before_module_init(&$ModuleHandler) |
34 | 34 | { |
35 | 35 | $logged_info = Context::get('logged_info'); |
36 | - if($logged_info->is_admin == 'Y' || $logged_info->is_site_admin) |
|
36 | + if ($logged_info->is_admin == 'Y' || $logged_info->is_site_admin) |
|
37 | 37 | { |
38 | 38 | return false; |
39 | 39 | } |
40 | - if($this->addon_info->target != 'all' && Context::get('is_logged')) |
|
40 | + if ($this->addon_info->target != 'all' && Context::get('is_logged')) |
|
41 | 41 | { |
42 | 42 | return false; |
43 | 43 | } |
44 | - if($_SESSION['XE_VALIDATOR_ERROR'] == -1) |
|
44 | + if ($_SESSION['XE_VALIDATOR_ERROR'] == -1) |
|
45 | 45 | { |
46 | 46 | $_SESSION['captcha_authed'] = false; |
47 | 47 | } |
48 | - if($_SESSION['captcha_authed']) |
|
48 | + if ($_SESSION['captcha_authed']) |
|
49 | 49 | { |
50 | 50 | return false; |
51 | 51 | } |
@@ -54,13 +54,13 @@ discard block |
||
54 | 54 | |
55 | 55 | $this->target_acts = array('procBoardInsertDocument', 'procBoardInsertComment', 'procIssuetrackerInsertIssue', 'procIssuetrackerInsertHistory', 'procTextyleInsertComment'); |
56 | 56 | |
57 | - if(Context::getRequestMethod() != 'XMLRPC' && Context::getRequestMethod() !== 'JSON') |
|
57 | + if (Context::getRequestMethod() != 'XMLRPC' && Context::getRequestMethod() !== 'JSON') |
|
58 | 58 | { |
59 | - if($type == 'inline') |
|
59 | + if ($type == 'inline') |
|
60 | 60 | { |
61 | - if(!$this->compareCaptcha()) |
|
61 | + if (!$this->compareCaptcha()) |
|
62 | 62 | { |
63 | - Context::loadLang(_XE_PATH_ . 'addons/captcha/lang'); |
|
63 | + Context::loadLang(_XE_PATH_.'addons/captcha/lang'); |
|
64 | 64 | $_SESSION['XE_VALIDATOR_ERROR'] = -1; |
65 | 65 | $_SESSION['XE_VALIDATOR_MESSAGE'] = Context::getLang('captcha_denied'); |
66 | 66 | $_SESSION['XE_VALIDATOR_MESSAGE_TYPE'] = 'error'; |
@@ -72,16 +72,16 @@ discard block |
||
72 | 72 | { |
73 | 73 | Context::addHtmlHeader('<script> |
74 | 74 | if(!captchaTargetAct) {var captchaTargetAct = [];} |
75 | - captchaTargetAct.push("' . implode('","', $this->target_acts) . '"); |
|
75 | + captchaTargetAct.push("' . implode('","', $this->target_acts).'"); |
|
76 | 76 | </script>'); |
77 | 77 | Context::loadFile(array('./addons/captcha/captcha.min.js', 'body', '', null), true); |
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
81 | 81 | // compare session when calling actions such as writing a post or a comment on the board/issue tracker module |
82 | - if(!$_SESSION['captcha_authed'] && in_array(Context::get('act'), $this->target_acts)) |
|
82 | + if (!$_SESSION['captcha_authed'] && in_array(Context::get('act'), $this->target_acts)) |
|
83 | 83 | { |
84 | - Context::loadLang(_XE_PATH_ . 'addons/captcha/lang'); |
|
84 | + Context::loadLang(_XE_PATH_.'addons/captcha/lang'); |
|
85 | 85 | $ModuleHandler->error = "captcha_denied"; |
86 | 86 | } |
87 | 87 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | function createKeyword() |
92 | 92 | { |
93 | 93 | $type = Context::get('captchaType'); |
94 | - if($type == 'inline' && $_SESSION['captcha_keyword']) |
|
94 | + if ($type == 'inline' && $_SESSION['captcha_keyword']) |
|
95 | 95 | { |
96 | 96 | return; |
97 | 97 | } |
@@ -104,19 +104,19 @@ discard block |
||
104 | 104 | |
105 | 105 | function before_module_init_setCaptchaSession() |
106 | 106 | { |
107 | - if($_SESSION['captcha_authed']) |
|
107 | + if ($_SESSION['captcha_authed']) |
|
108 | 108 | { |
109 | 109 | return false; |
110 | 110 | } |
111 | 111 | // Load language files |
112 | - Context::loadLang(_XE_PATH_ . 'addons/captcha/lang'); |
|
112 | + Context::loadLang(_XE_PATH_.'addons/captcha/lang'); |
|
113 | 113 | // Generate keywords |
114 | 114 | $this->createKeyword(); |
115 | 115 | |
116 | 116 | $target = Context::getLang('target_captcha'); |
117 | 117 | header("Content-Type: text/xml; charset=UTF-8"); |
118 | 118 | header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); |
119 | - header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); |
|
119 | + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); |
|
120 | 120 | header("Cache-Control: no-store, no-cache, must-revalidate"); |
121 | 121 | header("Cache-Control: post-check=0, pre-check=0", false); |
122 | 122 | header("Pragma: no-cache"); |
@@ -133,11 +133,11 @@ discard block |
||
133 | 133 | |
134 | 134 | function before_module_init_captchaImage() |
135 | 135 | { |
136 | - if($_SESSION['captcha_authed']) |
|
136 | + if ($_SESSION['captcha_authed']) |
|
137 | 137 | { |
138 | 138 | return false; |
139 | 139 | } |
140 | - if(Context::get('renew')) |
|
140 | + if (Context::get('renew')) |
|
141 | 141 | { |
142 | 142 | $this->createKeyword(); |
143 | 143 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | function createCaptchaImage($string) |
160 | 160 | { |
161 | 161 | $arr = array(); |
162 | - for($i = 0, $c = strlen($string); $i < $c; $i++) |
|
162 | + for ($i = 0, $c = strlen($string); $i < $c; $i++) |
|
163 | 163 | { |
164 | 164 | $arr[] = $string{$i}; |
165 | 165 | } |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | shuffle($deg); |
182 | 182 | |
183 | 183 | // Create an image for each letter |
184 | - foreach($arr as $i => $str) |
|
184 | + foreach ($arr as $i => $str) |
|
185 | 185 | { |
186 | 186 | $im[$i + 1] = @imagecreate($w, $h); |
187 | 187 | $background_color = imagecolorallocate($im[$i + 1], 255, 255, 255); |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | $ran = range(1, 20); |
192 | 192 | shuffle($ran); |
193 | 193 | |
194 | - if(function_exists('imagerotate')) |
|
194 | + if (function_exists('imagerotate')) |
|
195 | 195 | { |
196 | 196 | imagestring($im[$i + 1], (array_pop($ran) % 3) + 3, 2, (array_pop($ran) % 8), $str, $text_color); |
197 | 197 | $im[$i + 1] = imagerotate($im[$i + 1], array_pop($deg), 0); |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | } |
207 | 207 | |
208 | 208 | // Combine images of each character |
209 | - for($i = 1, $c = count($im); $i<$c; $i++) |
|
209 | + for ($i = 1, $c = count($im); $i < $c; $i++) |
|
210 | 210 | { |
211 | 211 | imagecopy($im[0], $im[$i], (($w + 2) * ($i - 1)), 0, 0, 0, $w, $h); |
212 | 212 | imagedestroy($im[$i]); |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | imagecopyresized($big, $im[0], 0, 0, 0, 0, ($w + 2) * $big_count * $c, $h * $big_count, ($w + 2) * $c, $h); |
219 | 219 | imagedestroy($im[0]); |
220 | 220 | |
221 | - if(function_exists('imageantialias')) |
|
221 | + if (function_exists('imageantialias')) |
|
222 | 222 | { |
223 | 223 | imageantialias($big, true); |
224 | 224 | } |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | $h = $h * $big_count; |
231 | 231 | $d = array_pop($deg); |
232 | 232 | |
233 | - for($i = -abs($d); $i < $h + abs($d); $i = $i + 7) |
|
233 | + for ($i = -abs($d); $i < $h + abs($d); $i = $i + 7) |
|
234 | 234 | { |
235 | 235 | imageline($big, 0, $i + $d, $w, $i, $line_color); |
236 | 236 | } |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | $x = range(0, ($w - 10)); |
239 | 239 | shuffle($x); |
240 | 240 | |
241 | - for($i = 0; $i < 200; $i++) |
|
241 | + for ($i = 0; $i < 200; $i++) |
|
242 | 242 | { |
243 | 243 | imagesetpixel($big, $x[$i] % $w, $x[$i + 1] % $h, $line_color); |
244 | 244 | } |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | |
249 | 249 | function before_module_init_captchaAudio() |
250 | 250 | { |
251 | - if($_SESSION['captcha_authed']) |
|
251 | + if ($_SESSION['captcha_authed']) |
|
252 | 252 | { |
253 | 253 | return false; |
254 | 254 | } |
@@ -260,8 +260,8 @@ discard block |
||
260 | 260 | header("Content-Disposition: attachment; filename=\"captcha_audio.mp3\""); |
261 | 261 | header('Cache-Control: no-store, no-cache, must-revalidate'); |
262 | 262 | header('Expires: Sun, 1 Jan 2000 12:00:00 GMT'); |
263 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . 'GMT'); |
|
264 | - header('Content-Length: ' . strlen($data)); |
|
263 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s').'GMT'); |
|
264 | + header('Content-Length: '.strlen($data)); |
|
265 | 265 | |
266 | 266 | echo $data; |
267 | 267 | Context::close(); |
@@ -272,17 +272,17 @@ discard block |
||
272 | 272 | { |
273 | 273 | $data = ''; |
274 | 274 | $_audio = './addons/captcha/audio/F_%s.mp3'; |
275 | - for($i = 0, $c = strlen($string); $i < $c; $i++) |
|
275 | + for ($i = 0, $c = strlen($string); $i < $c; $i++) |
|
276 | 276 | { |
277 | 277 | $_data = FileHandler::readFile(sprintf($_audio, $string{$i})); |
278 | 278 | |
279 | 279 | $start = rand(5, 68); // Random start in 4-byte header and 64 byte data |
280 | 280 | $datalen = strlen($_data) - $start - 256; // Last unchanged 256 bytes |
281 | 281 | |
282 | - for($j = $start; $j < $datalen; $j+=64) |
|
282 | + for ($j = $start; $j < $datalen; $j += 64) |
|
283 | 283 | { |
284 | 284 | $ch = ord($_data{$j}); |
285 | - if($ch < 9 || $ch > 119) |
|
285 | + if ($ch < 9 || $ch > 119) |
|
286 | 286 | { |
287 | 287 | continue; |
288 | 288 | } |
@@ -297,14 +297,14 @@ discard block |
||
297 | 297 | |
298 | 298 | function compareCaptcha() |
299 | 299 | { |
300 | - if(!in_array(Context::get('act'), $this->target_acts)) return true; |
|
300 | + if (!in_array(Context::get('act'), $this->target_acts)) return true; |
|
301 | 301 | |
302 | - if($_SESSION['captcha_authed']) |
|
302 | + if ($_SESSION['captcha_authed']) |
|
303 | 303 | { |
304 | 304 | return true; |
305 | 305 | } |
306 | 306 | |
307 | - if(strtoupper($_SESSION['captcha_keyword']) == strtoupper(Context::get('secret_text'))) |
|
307 | + if (strtoupper($_SESSION['captcha_keyword']) == strtoupper(Context::get('secret_text'))) |
|
308 | 308 | { |
309 | 309 | $_SESSION['captcha_authed'] = true; |
310 | 310 | return true; |
@@ -317,14 +317,14 @@ discard block |
||
317 | 317 | |
318 | 318 | function before_module_init_captchaCompare() |
319 | 319 | { |
320 | - if(!$this->compareCaptcha()) |
|
320 | + if (!$this->compareCaptcha()) |
|
321 | 321 | { |
322 | 322 | return false; |
323 | 323 | } |
324 | 324 | |
325 | 325 | header("Content-Type: text/xml; charset=UTF-8"); |
326 | 326 | header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); |
327 | - header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); |
|
327 | + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); |
|
328 | 328 | header("Cache-Control: no-store, no-cache, must-revalidate"); |
329 | 329 | header("Cache-Control: post-check=0, pre-check=0", false); |
330 | 330 | header("Pragma: no-cache"); |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | unset($_SESSION['captcha_authed']); |
340 | 340 | $this->createKeyword(); |
341 | 341 | |
342 | - $swfURL = getUrl() . 'addons/captcha/swf/play.swf'; |
|
342 | + $swfURL = getUrl().'addons/captcha/swf/play.swf'; |
|
343 | 343 | Context::unloadFile('./addons/captcha/captcha.min.js'); |
344 | 344 | Context::loadFile(array('./addons/captcha/inline_captcha.js', 'body')); |
345 | 345 | |
@@ -377,18 +377,18 @@ discard block |
||
377 | 377 | |
378 | 378 | $oAddonCaptcha = &$GLOBALS['__AddonCaptcha__']; |
379 | 379 | |
380 | -if(method_exists($oAddonCaptcha, $called_position)) |
|
380 | +if (method_exists($oAddonCaptcha, $called_position)) |
|
381 | 381 | { |
382 | - if(!call_user_func_array(array(&$oAddonCaptcha, $called_position), array(&$this))) |
|
382 | + if (!call_user_func_array(array(&$oAddonCaptcha, $called_position), array(&$this))) |
|
383 | 383 | { |
384 | 384 | return false; |
385 | 385 | } |
386 | 386 | } |
387 | 387 | |
388 | 388 | $addon_act = Context::get('captcha_action'); |
389 | -if($addon_act && method_exists($oAddonCaptcha, $called_position . '_' . $addon_act)) |
|
389 | +if ($addon_act && method_exists($oAddonCaptcha, $called_position.'_'.$addon_act)) |
|
390 | 390 | { |
391 | - if(!call_user_func_array(array(&$oAddonCaptcha, $called_position . '_' . $addon_act), array(&$this))) |
|
391 | + if (!call_user_func_array(array(&$oAddonCaptcha, $called_position.'_'.$addon_act), array(&$this))) |
|
392 | 392 | { |
393 | 393 | return false; |
394 | 394 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /* Copyright (C) NAVER <http://www.navercorp.com> */ |
3 | 3 | |
4 | -if(!defined('__XE__')) |
|
4 | +if (!defined('__XE__')) |
|
5 | 5 | exit(); |
6 | 6 | |
7 | 7 | /** |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @author NAVER ([email protected]) |
10 | 10 | * @brief Automatic link add-on |
11 | 11 | */ |
12 | -if($called_position == 'after_module_proc' && Context::getResponseMethod() == "HTML") |
|
12 | +if ($called_position == 'after_module_proc' && Context::getResponseMethod() == "HTML") |
|
13 | 13 | { |
14 | 14 | Context::loadFile(array('./addons/autolink/autolink.js', 'body', '', null), true); |
15 | 15 | } |
@@ -18,32 +18,32 @@ discard block |
||
18 | 18 | function proc($args) |
19 | 19 | { |
20 | 20 | // Targets to sort |
21 | - if(!in_array($args->order_target, array('list_order','update_order'))) $args->order_target = 'list_order'; |
|
21 | + if (!in_array($args->order_target, array('list_order', 'update_order'))) $args->order_target = 'list_order'; |
|
22 | 22 | // Sort order |
23 | - if(!in_array($args->order_type, array('asc','desc'))) $args->order_type = 'asc'; |
|
23 | + if (!in_array($args->order_type, array('asc', 'desc'))) $args->order_type = 'asc'; |
|
24 | 24 | // The number of displayed lists |
25 | - $args->list_count = (int)$args->list_count; |
|
26 | - if(!$args->list_count) $args->list_count = 5; |
|
25 | + $args->list_count = (int) $args->list_count; |
|
26 | + if (!$args->list_count) $args->list_count = 5; |
|
27 | 27 | // Cut the length of the title |
28 | - if(!$args->subject_cut_size) $args->subject_cut_size = 0; |
|
28 | + if (!$args->subject_cut_size) $args->subject_cut_size = 0; |
|
29 | 29 | // Cut the length of contents |
30 | - if(!$args->content_cut_size) $args->content_cut_size = 100; |
|
30 | + if (!$args->content_cut_size) $args->content_cut_size = 100; |
|
31 | 31 | // Viewing options |
32 | - $args->option_view_arr = explode(',',$args->option_view); |
|
32 | + $args->option_view_arr = explode(',', $args->option_view); |
|
33 | 33 | // markup options |
34 | - if(!$args->markup_type) $args->markup_type = 'list'; |
|
34 | + if (!$args->markup_type) $args->markup_type = 'list'; |
|
35 | 35 | // Set variables for internal use |
36 | 36 | $oModuleModel = getModel('module'); |
37 | 37 | $module_srls = $args->modules_info = $args->module_srls_info = $args->mid_lists = array(); |
38 | 38 | $site_module_info = Context::get('site_module_info'); |
39 | 39 | // List URLs if a type is RSS |
40 | - if($args->content_type == 'rss') |
|
40 | + if ($args->content_type == 'rss') |
|
41 | 41 | { |
42 | 42 | $args->rss_urls = array(); |
43 | - $rss_urls = array_unique(array($args->rss_url0,$args->rss_url1,$args->rss_url2,$args->rss_url3,$args->rss_url4)); |
|
44 | - for($i=0,$c=count($rss_urls);$i<$c;$i++) |
|
43 | + $rss_urls = array_unique(array($args->rss_url0, $args->rss_url1, $args->rss_url2, $args->rss_url3, $args->rss_url4)); |
|
44 | + for ($i = 0, $c = count($rss_urls); $i < $c; $i++) |
|
45 | 45 | { |
46 | - if($rss_urls[$i]) $args->rss_urls[] = $rss_urls[$i]; |
|
46 | + if ($rss_urls[$i]) $args->rss_urls[] = $rss_urls[$i]; |
|
47 | 47 | } |
48 | 48 | // Get module information after listing module_srls if the module is not RSS |
49 | 49 | } |
@@ -51,13 +51,13 @@ discard block |
||
51 | 51 | { |
52 | 52 | $obj = new stdClass(); |
53 | 53 | // Apply to all modules in the site if a target module is not specified |
54 | - if(!$args->module_srls) |
|
54 | + if (!$args->module_srls) |
|
55 | 55 | { |
56 | - $obj->site_srl = (int)$site_module_info->site_srl; |
|
56 | + $obj->site_srl = (int) $site_module_info->site_srl; |
|
57 | 57 | $output = executeQueryArray('widgets.content.getMids', $obj); |
58 | - if($output->data) |
|
58 | + if ($output->data) |
|
59 | 59 | { |
60 | - foreach($output->data as $key => $val) |
|
60 | + foreach ($output->data as $key => $val) |
|
61 | 61 | { |
62 | 62 | $args->modules_info[$val->mid] = $val; |
63 | 63 | $args->module_srls_info[$val->module_srl] = $val; |
@@ -73,35 +73,35 @@ discard block |
||
73 | 73 | { |
74 | 74 | $obj->module_srls = $args->module_srls; |
75 | 75 | $output = executeQueryArray('widgets.content.getMids', $obj); |
76 | - if($output->data) |
|
76 | + if ($output->data) |
|
77 | 77 | { |
78 | - foreach($output->data as $key => $val) |
|
78 | + foreach ($output->data as $key => $val) |
|
79 | 79 | { |
80 | 80 | $args->modules_info[$val->mid] = $val; |
81 | 81 | $args->module_srls_info[$val->module_srl] = $val; |
82 | 82 | $module_srls[] = $val->module_srl; |
83 | 83 | } |
84 | - $idx = explode(',',$args->module_srls); |
|
85 | - for($i=0,$c=count($idx);$i<$c;$i++) |
|
84 | + $idx = explode(',', $args->module_srls); |
|
85 | + for ($i = 0, $c = count($idx); $i < $c; $i++) |
|
86 | 86 | { |
87 | 87 | $srl = $idx[$i]; |
88 | - if(!$args->module_srls_info[$srl]) continue; |
|
88 | + if (!$args->module_srls_info[$srl]) continue; |
|
89 | 89 | $args->mid_lists[$srl] = $args->module_srls_info[$srl]->mid; |
90 | 90 | } |
91 | 91 | } |
92 | 92 | } |
93 | 93 | // Exit if no module is found |
94 | - if(!count($args->modules_info)) return Context::get('msg_not_founded'); |
|
95 | - $args->module_srl = implode(',',$module_srls); |
|
94 | + if (!count($args->modules_info)) return Context::get('msg_not_founded'); |
|
95 | + $args->module_srl = implode(',', $module_srls); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
99 | 99 | * Method is separately made because content extraction, articles, comments, trackbacks, RSS and other elements exist |
100 | 100 | */ |
101 | 101 | // tab mode |
102 | - if($args->tab_type == 'none' || $args->tab_type == '') |
|
102 | + if ($args->tab_type == 'none' || $args->tab_type == '') |
|
103 | 103 | { |
104 | - switch($args->content_type) |
|
104 | + switch ($args->content_type) |
|
105 | 105 | { |
106 | 106 | case 'comment': |
107 | 107 | $content_items = $this->_getCommentItems($args); |
@@ -125,17 +125,17 @@ discard block |
||
125 | 125 | { |
126 | 126 | $content_items = array(); |
127 | 127 | |
128 | - switch($args->content_type) |
|
128 | + switch ($args->content_type) |
|
129 | 129 | { |
130 | 130 | case 'comment': |
131 | - foreach($args->mid_lists as $module_srl => $mid) |
|
131 | + foreach ($args->mid_lists as $module_srl => $mid) |
|
132 | 132 | { |
133 | 133 | $args->module_srl = $module_srl; |
134 | 134 | $content_items[$module_srl] = $this->_getCommentItems($args); |
135 | 135 | } |
136 | 136 | break; |
137 | 137 | case 'image': |
138 | - foreach($args->mid_lists as $module_srl => $mid) |
|
138 | + foreach ($args->mid_lists as $module_srl => $mid) |
|
139 | 139 | { |
140 | 140 | $args->module_srl = $module_srl; |
141 | 141 | $content_items[$module_srl] = $this->_getImageItems($args); |
@@ -145,13 +145,13 @@ discard block |
||
145 | 145 | $content_items = $this->getRssItems($args); |
146 | 146 | break; |
147 | 147 | case 'trackback': |
148 | - foreach($args->mid_lists as $module_srl => $mid){ |
|
148 | + foreach ($args->mid_lists as $module_srl => $mid) { |
|
149 | 149 | $args->module_srl = $module_srl; |
150 | 150 | $content_items[$module_srl] = $this->_getTrackbackItems($args); |
151 | 151 | } |
152 | 152 | break; |
153 | 153 | default: |
154 | - foreach($args->mid_lists as $module_srl => $mid) |
|
154 | + foreach ($args->mid_lists as $module_srl => $mid) |
|
155 | 155 | { |
156 | 156 | $args->module_srl = $module_srl; |
157 | 157 | $content_items[$module_srl] = $this->_getDocumentItems($args); |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
163 | - $output = $this->_compile($args,$content_items); |
|
163 | + $output = $this->_compile($args, $content_items); |
|
164 | 164 | return $output; |
165 | 165 | } |
166 | 166 | |
@@ -180,14 +180,14 @@ discard block |
||
180 | 180 | |
181 | 181 | $content_items = array(); |
182 | 182 | |
183 | - if(!count($output)) return; |
|
183 | + if (!count($output)) return; |
|
184 | 184 | |
185 | - foreach($output as $key => $oComment) |
|
185 | + foreach ($output as $key => $oComment) |
|
186 | 186 | { |
187 | 187 | $attribute = $oComment->getObjectVars(); |
188 | 188 | $title = $oComment->getSummary($args->content_cut_size); |
189 | 189 | $thumbnail = $oComment->getThumbnail(); |
190 | - $url = sprintf("%s#comment_%s",getUrl('', 'mid', $args->mid_lists[$attribute->module_srl], 'document_srl',$oComment->get('document_srl')),$oComment->get('comment_srl')); |
|
190 | + $url = sprintf("%s#comment_%s", getUrl('', 'mid', $args->mid_lists[$attribute->module_srl], 'document_srl', $oComment->get('document_srl')), $oComment->get('comment_srl')); |
|
191 | 191 | |
192 | 192 | $attribute->mid = $args->mid_lists[$attribute->module_srl]; |
193 | 193 | $browser_title = $args->module_srls_info[$attribute->module_srl]->browser_title; |
@@ -212,10 +212,10 @@ discard block |
||
212 | 212 | // Get categories |
213 | 213 | $obj = new stdClass(); |
214 | 214 | $obj->module_srl = $args->module_srl; |
215 | - $output = executeQueryArray('widgets.content.getCategories',$obj); |
|
216 | - if($output->toBool() && $output->data) |
|
215 | + $output = executeQueryArray('widgets.content.getCategories', $obj); |
|
216 | + if ($output->toBool() && $output->data) |
|
217 | 217 | { |
218 | - foreach($output->data as $key => $val) |
|
218 | + foreach ($output->data as $key => $val) |
|
219 | 219 | { |
220 | 220 | $category_lists[$val->module_srl][$val->category_srl] = $val; |
221 | 221 | } |
@@ -223,17 +223,17 @@ discard block |
||
223 | 223 | // Get a list of documents |
224 | 224 | $obj->module_srl = $args->module_srl; |
225 | 225 | $obj->sort_index = $args->order_target; |
226 | - $obj->order_type = $args->order_type=="desc"?"asc":"desc"; |
|
226 | + $obj->order_type = $args->order_type == "desc" ? "asc" : "desc"; |
|
227 | 227 | $obj->list_count = $args->list_count; |
228 | 228 | $obj->statusList = array('PUBLIC'); |
229 | 229 | $output = executeQueryArray('widgets.content.getNewestDocuments', $obj); |
230 | - if(!$output->toBool() || !$output->data) return; |
|
230 | + if (!$output->toBool() || !$output->data) return; |
|
231 | 231 | // If the result exists, make each document as an object |
232 | 232 | $content_items = array(); |
233 | 233 | $first_thumbnail_idx = -1; |
234 | - if(count($output->data)) |
|
234 | + if (count($output->data)) |
|
235 | 235 | { |
236 | - foreach($output->data as $key => $attribute) |
|
236 | + foreach ($output->data as $key => $attribute) |
|
237 | 237 | { |
238 | 238 | $oDocument = new documentItem(); |
239 | 239 | $oDocument->setAttribute($attribute, false); |
@@ -242,23 +242,23 @@ discard block |
||
242 | 242 | } |
243 | 243 | $oDocumentModel->setToAllDocumentExtraVars(); |
244 | 244 | |
245 | - for($i=0,$c=count($document_srls);$i<$c;$i++) |
|
245 | + for ($i = 0, $c = count($document_srls); $i < $c; $i++) |
|
246 | 246 | { |
247 | 247 | $oDocument = $GLOBALS['XE_DOCUMENT_LIST'][$document_srls[$i]]; |
248 | 248 | $document_srl = $oDocument->document_srl; |
249 | 249 | $module_srl = $oDocument->get('module_srl'); |
250 | 250 | $category_srl = $oDocument->get('category_srl'); |
251 | 251 | $thumbnail = $oDocument->getThumbnail(); |
252 | - $content_item = new mcontentItem( $args->module_srls_info[$module_srl]->browser_title ); |
|
252 | + $content_item = new mcontentItem($args->module_srls_info[$module_srl]->browser_title); |
|
253 | 253 | $content_item->adds($oDocument->getObjectVars()); |
254 | 254 | $content_item->setTitle($oDocument->getTitleText()); |
255 | - $content_item->setCategory( $category_lists[$module_srl][$category_srl]->title ); |
|
256 | - $content_item->setDomain( $args->module_srls_info[$module_srl]->domain ); |
|
255 | + $content_item->setCategory($category_lists[$module_srl][$category_srl]->title); |
|
256 | + $content_item->setDomain($args->module_srls_info[$module_srl]->domain); |
|
257 | 257 | $content_item->setContent($oDocument->getSummary($args->content_cut_size)); |
258 | - $content_item->setLink( getSiteUrl($domain,'', 'mid',$args->mid_lists[$module_srl], 'document_srl',$document_srl) ); |
|
258 | + $content_item->setLink(getSiteUrl($domain, '', 'mid', $args->mid_lists[$module_srl], 'document_srl', $document_srl)); |
|
259 | 259 | $content_item->setThumbnail($thumbnail); |
260 | 260 | $content_item->add('mid', $args->mid_lists[$module_srl]); |
261 | - if($first_thumbnail_idx==-1 && $thumbnail) $first_thumbnail_idx = $i; |
|
261 | + if ($first_thumbnail_idx == -1 && $thumbnail) $first_thumbnail_idx = $i; |
|
262 | 262 | $content_items[] = $content_item; |
263 | 263 | } |
264 | 264 | |
@@ -276,10 +276,10 @@ discard block |
||
276 | 276 | $obj->direct_download = 'Y'; |
277 | 277 | $obj->isvalid = 'Y'; |
278 | 278 | // Get categories |
279 | - $output = executeQueryArray('widgets.content.getCategories',$obj); |
|
280 | - if($output->toBool() && $output->data) |
|
279 | + $output = executeQueryArray('widgets.content.getCategories', $obj); |
|
280 | + if ($output->toBool() && $output->data) |
|
281 | 281 | { |
282 | - foreach($output->data as $key => $val) |
|
282 | + foreach ($output->data as $key => $val) |
|
283 | 283 | { |
284 | 284 | $category_lists[$val->module_srl][$val->category_srl] = $val; |
285 | 285 | } |
@@ -288,24 +288,24 @@ discard block |
||
288 | 288 | $obj->list_count = $args->list_count; |
289 | 289 | $files_output = executeQueryArray("file.getOneFileInDocument", $obj); |
290 | 290 | $files_count = count($files_output->data); |
291 | - if(!$files_count) return; |
|
291 | + if (!$files_count) return; |
|
292 | 292 | |
293 | 293 | $content_items = array(); |
294 | 294 | |
295 | - for($i=0;$i<$files_count;$i++) $document_srl_list[] = $files_output->data[$i]->document_srl; |
|
295 | + for ($i = 0; $i < $files_count; $i++) $document_srl_list[] = $files_output->data[$i]->document_srl; |
|
296 | 296 | |
297 | 297 | $tmp_document_list = $oDocumentModel->getDocuments($document_srl_list); |
298 | 298 | |
299 | - if(!count($tmp_document_list)) return; |
|
299 | + if (!count($tmp_document_list)) return; |
|
300 | 300 | |
301 | - foreach($tmp_document_list as $oDocument) |
|
301 | + foreach ($tmp_document_list as $oDocument) |
|
302 | 302 | { |
303 | 303 | $attribute = $oDocument->getObjectVars(); |
304 | 304 | $browser_title = $args->module_srls_info[$attribute->module_srl]->browser_title; |
305 | 305 | $domain = $args->module_srls_info[$attribute->module_srl]->domain; |
306 | 306 | $category = $category_lists[$attribute->module_srl]->text; |
307 | 307 | $content = $oDocument->getSummary($args->content_cut_size); |
308 | - $url = sprintf("%s#%s",$oDocument->getPermanentUrl() ,$oDocument->getCommentCount()); |
|
308 | + $url = sprintf("%s#%s", $oDocument->getPermanentUrl(), $oDocument->getCommentCount()); |
|
309 | 309 | $thumbnail = $oDocument->getThumbnail(); |
310 | 310 | $content_item = new mcontentItem($browser_title); |
311 | 311 | $content_item->adds($attribute); |
@@ -327,11 +327,11 @@ discard block |
||
327 | 327 | $content_items = array(); |
328 | 328 | $args->mid_lists = array(); |
329 | 329 | |
330 | - foreach($args->rss_urls as $key => $rss) |
|
330 | + foreach ($args->rss_urls as $key => $rss) |
|
331 | 331 | { |
332 | 332 | $args->rss_url = $rss; |
333 | 333 | $content_item = $this->_getRssItems($args); |
334 | - if(count($content_item) > 0) |
|
334 | + if (count($content_item) > 0) |
|
335 | 335 | { |
336 | 336 | $browser_title = $content_item[0]->getBrowserTitle(); |
337 | 337 | $args->mid_lists[] = $browser_title; |
@@ -339,40 +339,40 @@ discard block |
||
339 | 339 | } |
340 | 340 | } |
341 | 341 | |
342 | - if($args->tab_type == 'none' || $args->tab_type == '') |
|
342 | + if ($args->tab_type == 'none' || $args->tab_type == '') |
|
343 | 343 | { |
344 | 344 | $items = array(); |
345 | - foreach($content_items as $key => $val) |
|
345 | + foreach ($content_items as $key => $val) |
|
346 | 346 | { |
347 | - foreach($val as $k => $v) |
|
347 | + foreach ($val as $k => $v) |
|
348 | 348 | { |
349 | 349 | $date = $v->get('regdate'); |
350 | - $i=0; |
|
351 | - while(array_key_exists(sprintf('%s%02d',$date,$i), $items)) $i++; |
|
352 | - $items[sprintf('%s%02d',$date,$i)] = $v; |
|
350 | + $i = 0; |
|
351 | + while (array_key_exists(sprintf('%s%02d', $date, $i), $items)) $i++; |
|
352 | + $items[sprintf('%s%02d', $date, $i)] = $v; |
|
353 | 353 | } |
354 | 354 | } |
355 | - if($args->order_type =='asc') ksort($items); |
|
355 | + if ($args->order_type == 'asc') ksort($items); |
|
356 | 356 | else krsort($items); |
357 | - $content_items = array_slice(array_values($items),0,$args->list_count); |
|
357 | + $content_items = array_slice(array_values($items), 0, $args->list_count); |
|
358 | 358 | } return $content_items; |
359 | 359 | } |
360 | 360 | |
361 | 361 | function _getRssBody($value) |
362 | 362 | { |
363 | - if(!$value || is_string($value)) return $value; |
|
364 | - if(is_object($value)) $value = get_object_vars($value); |
|
363 | + if (!$value || is_string($value)) return $value; |
|
364 | + if (is_object($value)) $value = get_object_vars($value); |
|
365 | 365 | $body = null; |
366 | - if(!count($value)) return; |
|
367 | - foreach($value as $key => $val) |
|
366 | + if (!count($value)) return; |
|
367 | + foreach ($value as $key => $val) |
|
368 | 368 | { |
369 | - if($key == 'body') |
|
369 | + if ($key == 'body') |
|
370 | 370 | { |
371 | 371 | $body = $val; |
372 | 372 | continue; |
373 | 373 | } |
374 | - if(is_object($val)||is_array($val)) $body = $this->_getRssBody($val); |
|
375 | - if($body !== null) return $body; |
|
374 | + if (is_object($val) || is_array($val)) $body = $this->_getRssBody($val); |
|
375 | + if ($body !== null) return $body; |
|
376 | 376 | } |
377 | 377 | return $body; |
378 | 378 | } |
@@ -383,17 +383,17 @@ discard block |
||
383 | 383 | // Replace tags such as </p> , </div> , </li> and others to a whitespace |
384 | 384 | $content = str_replace(array('</p>', '</div>', '</li>'), ' ', $content); |
385 | 385 | // Remove Tag |
386 | - $content = preg_replace('!<([^>]*?)>!is','', $content); |
|
386 | + $content = preg_replace('!<([^>]*?)>!is', '', $content); |
|
387 | 387 | // Replace tags to < , > , " |
388 | - $content = str_replace(array('<','>','"',' '), array('<','>','"',' '), $content); |
|
388 | + $content = str_replace(array('<', '>', '"', ' '), array('<', '>', '"', ' '), $content); |
|
389 | 389 | // Delete a series of whitespaces |
390 | 390 | $content = preg_replace('/ ( +)/is', ' ', $content); |
391 | 391 | // Truncate string |
392 | 392 | $content = trim(cut_str($content, $str_size, $tail)); |
393 | 393 | // Replace back < , > , " to theoriginal tags |
394 | - $content = str_replace(array('<','>','"'),array('<','>','"'), $content); |
|
394 | + $content = str_replace(array('<', '>', '"'), array('<', '>', '"'), $content); |
|
395 | 395 | // Fixed a newline bug on a set of consecutive English letters |
396 | - $content = preg_replace('/([a-z0-9\+:\/\.\~,\|\!\@\#\$\%\^\&\*\(\)\_]){20}/is',"$0-",$content); |
|
396 | + $content = preg_replace('/([a-z0-9\+:\/\.\~,\|\!\@\#\$\%\^\&\*\(\)\_]){20}/is', "$0-", $content); |
|
397 | 397 | return $content; |
398 | 398 | } |
399 | 399 | |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | */ |
405 | 405 | function requestFeedContents($rss_url) |
406 | 406 | { |
407 | - $rss_url = str_replace('&','&',Context::convertEncodingStr($rss_url)); |
|
407 | + $rss_url = str_replace('&', '&', Context::convertEncodingStr($rss_url)); |
|
408 | 408 | return FileHandler::getRemoteResource($rss_url, null, 3, 'GET', 'application/xml'); |
409 | 409 | } |
410 | 410 | |
@@ -416,52 +416,52 @@ discard block |
||
416 | 416 | $buff = $this->requestFeedContents($args->rss_url); |
417 | 417 | |
418 | 418 | $encoding = preg_match("/<\?xml.*encoding=\"(.+)\".*\?>/i", $buff, $matches); |
419 | - if($encoding && stripos($matches[1], "UTF-8") === FALSE) $buff = Context::convertEncodingStr($buff); |
|
419 | + if ($encoding && stripos($matches[1], "UTF-8") === FALSE) $buff = Context::convertEncodingStr($buff); |
|
420 | 420 | |
421 | 421 | $buff = preg_replace("/<\?xml.*\?>/i", "", $buff); |
422 | 422 | |
423 | 423 | $oXmlParser = new XmlParser(); |
424 | 424 | $xml_doc = $oXmlParser->parse($buff); |
425 | 425 | $rss = new stdClass(); |
426 | - if($xml_doc->rss) |
|
426 | + if ($xml_doc->rss) |
|
427 | 427 | { |
428 | 428 | $rss->title = $xml_doc->rss->channel->title->body; |
429 | 429 | $rss->link = $xml_doc->rss->channel->link->body; |
430 | 430 | |
431 | 431 | $items = $xml_doc->rss->channel->item; |
432 | 432 | |
433 | - if(!$items) return; |
|
434 | - if($items && !is_array($items)) $items = array($items); |
|
433 | + if (!$items) return; |
|
434 | + if ($items && !is_array($items)) $items = array($items); |
|
435 | 435 | |
436 | 436 | $content_items = array(); |
437 | 437 | |
438 | 438 | foreach ($items as $key => $value) |
439 | 439 | { |
440 | - if($key >= $args->list_count) break; |
|
440 | + if ($key >= $args->list_count) break; |
|
441 | 441 | unset($item); |
442 | 442 | $item = new stdClass(); |
443 | 443 | |
444 | - foreach($value as $key2 => $value2) |
|
444 | + foreach ($value as $key2 => $value2) |
|
445 | 445 | { |
446 | - if(is_array($value2)) $value2 = array_shift($value2); |
|
446 | + if (is_array($value2)) $value2 = array_shift($value2); |
|
447 | 447 | $item->{$key2} = $this->_getRssBody($value2); |
448 | 448 | } |
449 | 449 | |
450 | 450 | $content_item = new mcontentItem($rss->title); |
451 | 451 | $content_item->setContentsLink($rss->link); |
452 | 452 | $content_item->setTitle($item->title); |
453 | - $content_item->setNickName(max($item->author,$item->{'dc:creator'})); |
|
453 | + $content_item->setNickName(max($item->author, $item->{'dc:creator'})); |
|
454 | 454 | //$content_item->setCategory($item->category); |
455 | - $item->description = preg_replace('!<a href=!is','<a target="_blank" rel="noopener" href=', $item->description); |
|
455 | + $item->description = preg_replace('!<a href=!is', '<a target="_blank" rel="noopener" href=', $item->description); |
|
456 | 456 | $content_item->setContent($this->_getSummary($item->description, $args->content_cut_size)); |
457 | 457 | $content_item->setLink($item->link); |
458 | - $date = date('YmdHis', strtotime(max($item->pubdate,$item->pubDate,$item->{'dc:date'}))); |
|
458 | + $date = date('YmdHis', strtotime(max($item->pubdate, $item->pubDate, $item->{'dc:date'}))); |
|
459 | 459 | $content_item->setRegdate($date); |
460 | 460 | |
461 | 461 | $content_items[] = $content_item; |
462 | 462 | } |
463 | 463 | } |
464 | - else if($xml_doc->{'rdf:rdf'}) |
|
464 | + else if ($xml_doc->{'rdf:rdf'}) |
|
465 | 465 | { |
466 | 466 | // rss1.0 supported (XE's XML is case-insensitive because XML parser converts all to small letters) Fixed by misol |
467 | 467 | $rss->title = $xml_doc->{'rdf:rdf'}->channel->title->body; |
@@ -469,102 +469,102 @@ discard block |
||
469 | 469 | |
470 | 470 | $items = $xml_doc->{'rdf:rdf'}->item; |
471 | 471 | |
472 | - if(!$items) return; |
|
473 | - if($items && !is_array($items)) $items = array($items); |
|
472 | + if (!$items) return; |
|
473 | + if ($items && !is_array($items)) $items = array($items); |
|
474 | 474 | |
475 | 475 | $content_items = array(); |
476 | 476 | |
477 | 477 | foreach ($items as $key => $value) |
478 | 478 | { |
479 | - if($key >= $args->list_count) break; |
|
479 | + if ($key >= $args->list_count) break; |
|
480 | 480 | unset($item); |
481 | 481 | $item = new stdClass(); |
482 | 482 | |
483 | - foreach($value as $key2 => $value2) |
|
483 | + foreach ($value as $key2 => $value2) |
|
484 | 484 | { |
485 | - if(is_array($value2)) $value2 = array_shift($value2); |
|
485 | + if (is_array($value2)) $value2 = array_shift($value2); |
|
486 | 486 | $item->{$key2} = $this->_getRssBody($value2); |
487 | 487 | } |
488 | 488 | |
489 | 489 | $content_item = new mcontentItem($rss->title); |
490 | 490 | $content_item->setContentsLink($rss->link); |
491 | 491 | $content_item->setTitle($item->title); |
492 | - $content_item->setNickName(max($item->author,$item->{'dc:creator'})); |
|
492 | + $content_item->setNickName(max($item->author, $item->{'dc:creator'})); |
|
493 | 493 | //$content_item->setCategory($item->category); |
494 | - $item->description = preg_replace('!<a href=!is','<a target="_blank" rel="noopener" href=', $item->description); |
|
494 | + $item->description = preg_replace('!<a href=!is', '<a target="_blank" rel="noopener" href=', $item->description); |
|
495 | 495 | $content_item->setContent($this->_getSummary($item->description, $args->content_cut_size)); |
496 | 496 | $content_item->setLink($item->link); |
497 | - $date = date('YmdHis', strtotime(max($item->pubdate,$item->pubDate,$item->{'dc:date'}))); |
|
497 | + $date = date('YmdHis', strtotime(max($item->pubdate, $item->pubDate, $item->{'dc:date'}))); |
|
498 | 498 | $content_item->setRegdate($date); |
499 | 499 | |
500 | 500 | $content_items[] = $content_item; |
501 | 501 | } |
502 | 502 | } |
503 | - else if($xml_doc->feed && $xml_doc->feed->attrs->xmlns == 'http://www.w3.org/2005/Atom') |
|
503 | + else if ($xml_doc->feed && $xml_doc->feed->attrs->xmlns == 'http://www.w3.org/2005/Atom') |
|
504 | 504 | { |
505 | 505 | // Atom 1.0 spec supported by misol |
506 | 506 | $rss->title = $xml_doc->feed->title->body; |
507 | 507 | $links = $xml_doc->feed->link; |
508 | - if(is_array($links)) |
|
508 | + if (is_array($links)) |
|
509 | 509 | { |
510 | 510 | foreach ($links as $value) |
511 | 511 | { |
512 | - if($value->attrs->rel == 'alternate') |
|
512 | + if ($value->attrs->rel == 'alternate') |
|
513 | 513 | { |
514 | 514 | $rss->link = $value->attrs->href; |
515 | 515 | break; |
516 | 516 | } |
517 | 517 | } |
518 | 518 | } |
519 | - else if($links->attrs->rel == 'alternate') $rss->link = $links->attrs->href; |
|
519 | + else if ($links->attrs->rel == 'alternate') $rss->link = $links->attrs->href; |
|
520 | 520 | |
521 | 521 | $items = $xml_doc->feed->entry; |
522 | 522 | |
523 | - if(!$items) return; |
|
524 | - if($items && !is_array($items)) $items = array($items); |
|
523 | + if (!$items) return; |
|
524 | + if ($items && !is_array($items)) $items = array($items); |
|
525 | 525 | |
526 | 526 | $content_items = array(); |
527 | 527 | |
528 | 528 | foreach ($items as $key => $value) |
529 | 529 | { |
530 | - if($key >= $args->list_count) break; |
|
530 | + if ($key >= $args->list_count) break; |
|
531 | 531 | unset($item); |
532 | 532 | |
533 | - foreach($value as $key2 => $value2) |
|
533 | + foreach ($value as $key2 => $value2) |
|
534 | 534 | { |
535 | - if(is_array($value2)) $value2 = array_shift($value2); |
|
535 | + if (is_array($value2)) $value2 = array_shift($value2); |
|
536 | 536 | $item->{$key2} = $this->_getRssBody($value2); |
537 | 537 | } |
538 | 538 | |
539 | 539 | $content_item = new mcontentItem($rss->title); |
540 | 540 | $links = $value->link; |
541 | - if(is_array($links)) |
|
541 | + if (is_array($links)) |
|
542 | 542 | { |
543 | 543 | foreach ($links as $val) |
544 | 544 | { |
545 | - if($val->attrs->rel == 'alternate') |
|
545 | + if ($val->attrs->rel == 'alternate') |
|
546 | 546 | { |
547 | 547 | $item->link = $val->attrs->href; |
548 | 548 | break; |
549 | 549 | } |
550 | 550 | } |
551 | 551 | } |
552 | - else if($links->attrs->rel == 'alternate') $item->link = $links->attrs->href; |
|
552 | + else if ($links->attrs->rel == 'alternate') $item->link = $links->attrs->href; |
|
553 | 553 | |
554 | 554 | $content_item->setContentsLink($rss->link); |
555 | - if($item->title) |
|
555 | + if ($item->title) |
|
556 | 556 | { |
557 | - if(stripos($value->title->attrs->type, "html") === FALSE) $item->title = $value->title->body; |
|
557 | + if (stripos($value->title->attrs->type, "html") === FALSE) $item->title = $value->title->body; |
|
558 | 558 | } |
559 | 559 | $content_item->setTitle($item->title); |
560 | - $content_item->setNickName(max($item->author,$item->{'dc:creator'})); |
|
560 | + $content_item->setNickName(max($item->author, $item->{'dc:creator'})); |
|
561 | 561 | $content_item->setAuthorSite($value->author->uri->body); |
562 | 562 | |
563 | 563 | //$content_item->setCategory($item->category); |
564 | 564 | $item->description = ($item->content) ? $item->content : $item->description = $item->summary; |
565 | - $item->description = preg_replace('!<a href=!is','<a target="_blank" rel="noopener" href=', $item->description); |
|
565 | + $item->description = preg_replace('!<a href=!is', '<a target="_blank" rel="noopener" href=', $item->description); |
|
566 | 566 | |
567 | - if(($item->content && stripos($value->content->attrs->type, "html") === FALSE) || (!$item->content && stripos($value->summary->attrs->type, "html") === FALSE)) |
|
567 | + if (($item->content && stripos($value->content->attrs->type, "html") === FALSE) || (!$item->content && stripos($value->summary->attrs->type, "html") === FALSE)) |
|
568 | 568 | { |
569 | 569 | $item->description = htmlspecialchars($item->description, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
570 | 570 | |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | |
573 | 573 | $content_item->setContent($this->_getSummary($item->description, $args->content_cut_size)); |
574 | 574 | $content_item->setLink($item->link); |
575 | - $date = date('YmdHis', strtotime(max($item->published,$item->updated,$item->{'dc:date'}))); |
|
575 | + $date = date('YmdHis', strtotime(max($item->published, $item->updated, $item->{'dc:date'}))); |
|
576 | 576 | $content_item->setRegdate($date); |
577 | 577 | |
578 | 578 | $content_items[] = $content_item; |
@@ -581,12 +581,12 @@ discard block |
||
581 | 581 | return $content_items; |
582 | 582 | } |
583 | 583 | |
584 | - function _getTrackbackItems($args){ |
|
584 | + function _getTrackbackItems($args) { |
|
585 | 585 | // Get categories |
586 | - $output = executeQueryArray('widgets.content.getCategories',$obj); |
|
587 | - if($output->toBool() && $output->data) |
|
586 | + $output = executeQueryArray('widgets.content.getCategories', $obj); |
|
587 | + if ($output->toBool() && $output->data) |
|
588 | 588 | { |
589 | - foreach($output->data as $key => $val) { |
|
589 | + foreach ($output->data as $key => $val) { |
|
590 | 590 | $category_lists[$val->module_srl][$val->category_srl] = $val; |
591 | 591 | } |
592 | 592 | } |
@@ -598,14 +598,14 @@ discard block |
||
598 | 598 | $oTrackbackModel = getModel('trackback'); |
599 | 599 | $output = $oTrackbackModel->getNewestTrackbackList($obj); |
600 | 600 | // If an error occurs, just ignore it. |
601 | - if(!$output->toBool() || !$output->data) return; |
|
601 | + if (!$output->toBool() || !$output->data) return; |
|
602 | 602 | // If the result exists, make each document as an object |
603 | 603 | $content_items = array(); |
604 | - foreach($output->data as $key => $item) |
|
604 | + foreach ($output->data as $key => $item) |
|
605 | 605 | { |
606 | 606 | $domain = $args->module_srls_info[$item->module_srl]->domain; |
607 | 607 | $category = $category_lists[$item->module_srl]->text; |
608 | - $url = getSiteUrl($domain,'','mid', $args->mid_lists[$item->module_srl],'document_srl',$item->document_srl); |
|
608 | + $url = getSiteUrl($domain, '', 'mid', $args->mid_lists[$item->module_srl], 'document_srl', $item->document_srl); |
|
609 | 609 | $browser_title = $args->module_srls_info[$item->module_srl]->browser_title; |
610 | 610 | |
611 | 611 | $content_item = new mcontentItem($browser_title); |
@@ -613,8 +613,8 @@ discard block |
||
613 | 613 | $content_item->setTitle($item->title); |
614 | 614 | $content_item->setCategory($category); |
615 | 615 | $content_item->setNickName($item->blog_name); |
616 | - $content_item->setContent($item->excerpt); ///<< |
|
617 | - $content_item->setDomain($domain); ///<< |
|
616 | + $content_item->setContent($item->excerpt); ///<< |
|
617 | + $content_item->setDomain($domain); ///<< |
|
618 | 618 | $content_item->setLink($url); |
619 | 619 | $content_item->add('mid', $args->mid_lists[$item->module_srl]); |
620 | 620 | $content_item->setRegdate($item->regdate); |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | return $content_items; |
624 | 624 | } |
625 | 625 | |
626 | - function _compile($args,$content_items) |
|
626 | + function _compile($args, $content_items) |
|
627 | 627 | { |
628 | 628 | $oTemplate = &TemplateHandler::getInstance(); |
629 | 629 | // Set variables for widget |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | var $contents_link = null; |
672 | 672 | var $domain = null; |
673 | 673 | |
674 | - function mcontentItem($browser_title='') |
|
674 | + function mcontentItem($browser_title = '') |
|
675 | 675 | { |
676 | 676 | $this->browser_title = $browser_title; |
677 | 677 | } |
@@ -681,58 +681,58 @@ discard block |
||
681 | 681 | } |
682 | 682 | function setFirstThumbnailIdx($first_thumbnail_idx) |
683 | 683 | { |
684 | - if(is_null($this->first_thumbnail) && $first_thumbnail_idx>-1) { |
|
684 | + if (is_null($this->first_thumbnail) && $first_thumbnail_idx > -1) { |
|
685 | 685 | $this->has_first_thumbnail_idx = true; |
686 | - $this->first_thumbnail_idx= $first_thumbnail_idx; |
|
686 | + $this->first_thumbnail_idx = $first_thumbnail_idx; |
|
687 | 687 | } |
688 | 688 | } |
689 | 689 | function setExtraImages($extra_images) |
690 | 690 | { |
691 | - $this->add('extra_images',$extra_images); |
|
691 | + $this->add('extra_images', $extra_images); |
|
692 | 692 | } |
693 | 693 | function setDomain($domain) |
694 | 694 | { |
695 | 695 | static $default_domain = null; |
696 | - if(!$domain) |
|
696 | + if (!$domain) |
|
697 | 697 | { |
698 | - if(is_null($default_domain)) $default_domain = Context::getDefaultUrl(); |
|
698 | + if (is_null($default_domain)) $default_domain = Context::getDefaultUrl(); |
|
699 | 699 | $domain = $default_domain; |
700 | 700 | } |
701 | 701 | $this->domain = $domain; |
702 | 702 | } |
703 | 703 | function setLink($url) |
704 | 704 | { |
705 | - $this->add('url',$url); |
|
705 | + $this->add('url', $url); |
|
706 | 706 | } |
707 | 707 | function setTitle($title) |
708 | 708 | { |
709 | - $this->add('title',$title); |
|
709 | + $this->add('title', $title); |
|
710 | 710 | } |
711 | 711 | |
712 | 712 | function setThumbnail($thumbnail) |
713 | 713 | { |
714 | - $this->add('thumbnail',$thumbnail); |
|
714 | + $this->add('thumbnail', $thumbnail); |
|
715 | 715 | } |
716 | 716 | function setContent($content) |
717 | 717 | { |
718 | - $this->add('content',$content); |
|
718 | + $this->add('content', $content); |
|
719 | 719 | } |
720 | 720 | function setRegdate($regdate) |
721 | 721 | { |
722 | - $this->add('regdate',$regdate); |
|
722 | + $this->add('regdate', $regdate); |
|
723 | 723 | } |
724 | 724 | function setNickName($nick_name) |
725 | 725 | { |
726 | - $this->add('nick_name',$nick_name); |
|
726 | + $this->add('nick_name', $nick_name); |
|
727 | 727 | } |
728 | 728 | // Save author's homepage url by misol |
729 | 729 | function setAuthorSite($site_url) |
730 | 730 | { |
731 | - $this->add('author_site',$site_url); |
|
731 | + $this->add('author_site', $site_url); |
|
732 | 732 | } |
733 | 733 | function setCategory($category) |
734 | 734 | { |
735 | - $this->add('category',$category); |
|
735 | + $this->add('category', $category); |
|
736 | 736 | } |
737 | 737 | function getBrowserTitle() |
738 | 738 | { |
@@ -760,17 +760,17 @@ discard block |
||
760 | 760 | { |
761 | 761 | return $this->get('module_srl'); |
762 | 762 | } |
763 | - function getTitle($cut_size = 0, $tail='...') |
|
763 | + function getTitle($cut_size = 0, $tail = '...') |
|
764 | 764 | { |
765 | 765 | $title = strip_tags($this->get('title')); |
766 | 766 | |
767 | - if($cut_size) $title = cut_str($title, $cut_size, $tail); |
|
767 | + if ($cut_size) $title = cut_str($title, $cut_size, $tail); |
|
768 | 768 | |
769 | 769 | $attrs = array(); |
770 | - if($this->get('title_bold') == 'Y') $attrs[] = 'font-weight:bold'; |
|
771 | - if($this->get('title_color') && $this->get('title_color') != 'N') $attrs[] = 'color:#'.$this->get('title_color'); |
|
770 | + if ($this->get('title_bold') == 'Y') $attrs[] = 'font-weight:bold'; |
|
771 | + if ($this->get('title_color') && $this->get('title_color') != 'N') $attrs[] = 'color:#'.$this->get('title_color'); |
|
772 | 772 | |
773 | - if(count($attrs)) $title = sprintf("<span style=\"%s\">%s</span>", implode(';', $attrs), htmlspecialchars($title)); |
|
773 | + if (count($attrs)) $title = sprintf("<span style=\"%s\">%s</span>", implode(';', $attrs), htmlspecialchars($title)); |
|
774 | 774 | |
775 | 775 | return $title; |
776 | 776 | } |
@@ -793,12 +793,12 @@ discard block |
||
793 | 793 | function getCommentCount() |
794 | 794 | { |
795 | 795 | $comment_count = $this->get('comment_count'); |
796 | - return $comment_count>0 ? $comment_count : ''; |
|
796 | + return $comment_count > 0 ? $comment_count : ''; |
|
797 | 797 | } |
798 | 798 | function getTrackbackCount() |
799 | 799 | { |
800 | 800 | $trackback_count = $this->get('trackback_count'); |
801 | - return $trackback_count>0 ? $trackback_count : ''; |
|
801 | + return $trackback_count > 0 ? $trackback_count : ''; |
|
802 | 802 | } |
803 | 803 | function getRegdate($format = 'Y.m.d H:i:s') |
804 | 804 | { |
@@ -18,20 +18,32 @@ discard block |
||
18 | 18 | function proc($args) |
19 | 19 | { |
20 | 20 | // Targets to sort |
21 | - if(!in_array($args->order_target, array('list_order','update_order'))) $args->order_target = 'list_order'; |
|
21 | + if(!in_array($args->order_target, array('list_order','update_order'))) { |
|
22 | + $args->order_target = 'list_order'; |
|
23 | + } |
|
22 | 24 | // Sort order |
23 | - if(!in_array($args->order_type, array('asc','desc'))) $args->order_type = 'asc'; |
|
25 | + if(!in_array($args->order_type, array('asc','desc'))) { |
|
26 | + $args->order_type = 'asc'; |
|
27 | + } |
|
24 | 28 | // The number of displayed lists |
25 | 29 | $args->list_count = (int)$args->list_count; |
26 | - if(!$args->list_count) $args->list_count = 5; |
|
30 | + if(!$args->list_count) { |
|
31 | + $args->list_count = 5; |
|
32 | + } |
|
27 | 33 | // Cut the length of the title |
28 | - if(!$args->subject_cut_size) $args->subject_cut_size = 0; |
|
34 | + if(!$args->subject_cut_size) { |
|
35 | + $args->subject_cut_size = 0; |
|
36 | + } |
|
29 | 37 | // Cut the length of contents |
30 | - if(!$args->content_cut_size) $args->content_cut_size = 100; |
|
38 | + if(!$args->content_cut_size) { |
|
39 | + $args->content_cut_size = 100; |
|
40 | + } |
|
31 | 41 | // Viewing options |
32 | 42 | $args->option_view_arr = explode(',',$args->option_view); |
33 | 43 | // markup options |
34 | - if(!$args->markup_type) $args->markup_type = 'list'; |
|
44 | + if(!$args->markup_type) { |
|
45 | + $args->markup_type = 'list'; |
|
46 | + } |
|
35 | 47 | // Set variables for internal use |
36 | 48 | $oModuleModel = getModel('module'); |
37 | 49 | $module_srls = $args->modules_info = $args->module_srls_info = $args->mid_lists = array(); |
@@ -43,11 +55,12 @@ discard block |
||
43 | 55 | $rss_urls = array_unique(array($args->rss_url0,$args->rss_url1,$args->rss_url2,$args->rss_url3,$args->rss_url4)); |
44 | 56 | for($i=0,$c=count($rss_urls);$i<$c;$i++) |
45 | 57 | { |
46 | - if($rss_urls[$i]) $args->rss_urls[] = $rss_urls[$i]; |
|
58 | + if($rss_urls[$i]) { |
|
59 | + $args->rss_urls[] = $rss_urls[$i]; |
|
60 | + } |
|
47 | 61 | } |
48 | 62 | // Get module information after listing module_srls if the module is not RSS |
49 | - } |
|
50 | - else |
|
63 | + } else |
|
51 | 64 | { |
52 | 65 | $obj = new stdClass(); |
53 | 66 | // Apply to all modules in the site if a target module is not specified |
@@ -68,8 +81,7 @@ discard block |
||
68 | 81 | |
69 | 82 | $args->modules_info = $oModuleModel->getMidList($obj); |
70 | 83 | // Apply to the module only if a target module is specified |
71 | - } |
|
72 | - else |
|
84 | + } else |
|
73 | 85 | { |
74 | 86 | $obj->module_srls = $args->module_srls; |
75 | 87 | $output = executeQueryArray('widgets.content.getMids', $obj); |
@@ -85,13 +97,17 @@ discard block |
||
85 | 97 | for($i=0,$c=count($idx);$i<$c;$i++) |
86 | 98 | { |
87 | 99 | $srl = $idx[$i]; |
88 | - if(!$args->module_srls_info[$srl]) continue; |
|
100 | + if(!$args->module_srls_info[$srl]) { |
|
101 | + continue; |
|
102 | + } |
|
89 | 103 | $args->mid_lists[$srl] = $args->module_srls_info[$srl]->mid; |
90 | 104 | } |
91 | 105 | } |
92 | 106 | } |
93 | 107 | // Exit if no module is found |
94 | - if(!count($args->modules_info)) return Context::get('msg_not_founded'); |
|
108 | + if(!count($args->modules_info)) { |
|
109 | + return Context::get('msg_not_founded'); |
|
110 | + } |
|
95 | 111 | $args->module_srl = implode(',',$module_srls); |
96 | 112 | } |
97 | 113 | |
@@ -120,8 +136,7 @@ discard block |
||
120 | 136 | break; |
121 | 137 | } |
122 | 138 | // If not a tab type |
123 | - } |
|
124 | - else |
|
139 | + } else |
|
125 | 140 | { |
126 | 141 | $content_items = array(); |
127 | 142 | |
@@ -180,7 +195,9 @@ discard block |
||
180 | 195 | |
181 | 196 | $content_items = array(); |
182 | 197 | |
183 | - if(!count($output)) return; |
|
198 | + if(!count($output)) { |
|
199 | + return; |
|
200 | + } |
|
184 | 201 | |
185 | 202 | foreach($output as $key => $oComment) |
186 | 203 | { |
@@ -227,7 +244,9 @@ discard block |
||
227 | 244 | $obj->list_count = $args->list_count; |
228 | 245 | $obj->statusList = array('PUBLIC'); |
229 | 246 | $output = executeQueryArray('widgets.content.getNewestDocuments', $obj); |
230 | - if(!$output->toBool() || !$output->data) return; |
|
247 | + if(!$output->toBool() || !$output->data) { |
|
248 | + return; |
|
249 | + } |
|
231 | 250 | // If the result exists, make each document as an object |
232 | 251 | $content_items = array(); |
233 | 252 | $first_thumbnail_idx = -1; |
@@ -258,7 +277,9 @@ discard block |
||
258 | 277 | $content_item->setLink( getSiteUrl($domain,'', 'mid',$args->mid_lists[$module_srl], 'document_srl',$document_srl) ); |
259 | 278 | $content_item->setThumbnail($thumbnail); |
260 | 279 | $content_item->add('mid', $args->mid_lists[$module_srl]); |
261 | - if($first_thumbnail_idx==-1 && $thumbnail) $first_thumbnail_idx = $i; |
|
280 | + if($first_thumbnail_idx==-1 && $thumbnail) { |
|
281 | + $first_thumbnail_idx = $i; |
|
282 | + } |
|
262 | 283 | $content_items[] = $content_item; |
263 | 284 | } |
264 | 285 | |
@@ -288,15 +309,21 @@ discard block |
||
288 | 309 | $obj->list_count = $args->list_count; |
289 | 310 | $files_output = executeQueryArray("file.getOneFileInDocument", $obj); |
290 | 311 | $files_count = count($files_output->data); |
291 | - if(!$files_count) return; |
|
312 | + if(!$files_count) { |
|
313 | + return; |
|
314 | + } |
|
292 | 315 | |
293 | 316 | $content_items = array(); |
294 | 317 | |
295 | - for($i=0;$i<$files_count;$i++) $document_srl_list[] = $files_output->data[$i]->document_srl; |
|
318 | + for($i=0;$i<$files_count;$i++) { |
|
319 | + $document_srl_list[] = $files_output->data[$i]->document_srl; |
|
320 | + } |
|
296 | 321 | |
297 | 322 | $tmp_document_list = $oDocumentModel->getDocuments($document_srl_list); |
298 | 323 | |
299 | - if(!count($tmp_document_list)) return; |
|
324 | + if(!count($tmp_document_list)) { |
|
325 | + return; |
|
326 | + } |
|
300 | 327 | |
301 | 328 | foreach($tmp_document_list as $oDocument) |
302 | 329 | { |
@@ -348,22 +375,33 @@ discard block |
||
348 | 375 | { |
349 | 376 | $date = $v->get('regdate'); |
350 | 377 | $i=0; |
351 | - while(array_key_exists(sprintf('%s%02d',$date,$i), $items)) $i++; |
|
378 | + while(array_key_exists(sprintf('%s%02d',$date,$i), $items)) { |
|
379 | + $i++; |
|
380 | + } |
|
352 | 381 | $items[sprintf('%s%02d',$date,$i)] = $v; |
353 | 382 | } |
354 | 383 | } |
355 | - if($args->order_type =='asc') ksort($items); |
|
356 | - else krsort($items); |
|
384 | + if($args->order_type =='asc') { |
|
385 | + ksort($items); |
|
386 | + } else { |
|
387 | + krsort($items); |
|
388 | + } |
|
357 | 389 | $content_items = array_slice(array_values($items),0,$args->list_count); |
358 | 390 | } return $content_items; |
359 | 391 | } |
360 | 392 | |
361 | 393 | function _getRssBody($value) |
362 | 394 | { |
363 | - if(!$value || is_string($value)) return $value; |
|
364 | - if(is_object($value)) $value = get_object_vars($value); |
|
395 | + if(!$value || is_string($value)) { |
|
396 | + return $value; |
|
397 | + } |
|
398 | + if(is_object($value)) { |
|
399 | + $value = get_object_vars($value); |
|
400 | + } |
|
365 | 401 | $body = null; |
366 | - if(!count($value)) return; |
|
402 | + if(!count($value)) { |
|
403 | + return; |
|
404 | + } |
|
367 | 405 | foreach($value as $key => $val) |
368 | 406 | { |
369 | 407 | if($key == 'body') |
@@ -371,8 +409,12 @@ discard block |
||
371 | 409 | $body = $val; |
372 | 410 | continue; |
373 | 411 | } |
374 | - if(is_object($val)||is_array($val)) $body = $this->_getRssBody($val); |
|
375 | - if($body !== null) return $body; |
|
412 | + if(is_object($val)||is_array($val)) { |
|
413 | + $body = $this->_getRssBody($val); |
|
414 | + } |
|
415 | + if($body !== null) { |
|
416 | + return $body; |
|
417 | + } |
|
376 | 418 | } |
377 | 419 | return $body; |
378 | 420 | } |
@@ -416,7 +458,9 @@ discard block |
||
416 | 458 | $buff = $this->requestFeedContents($args->rss_url); |
417 | 459 | |
418 | 460 | $encoding = preg_match("/<\?xml.*encoding=\"(.+)\".*\?>/i", $buff, $matches); |
419 | - if($encoding && stripos($matches[1], "UTF-8") === FALSE) $buff = Context::convertEncodingStr($buff); |
|
461 | + if($encoding && stripos($matches[1], "UTF-8") === FALSE) { |
|
462 | + $buff = Context::convertEncodingStr($buff); |
|
463 | + } |
|
420 | 464 | |
421 | 465 | $buff = preg_replace("/<\?xml.*\?>/i", "", $buff); |
422 | 466 | |
@@ -430,20 +474,28 @@ discard block |
||
430 | 474 | |
431 | 475 | $items = $xml_doc->rss->channel->item; |
432 | 476 | |
433 | - if(!$items) return; |
|
434 | - if($items && !is_array($items)) $items = array($items); |
|
477 | + if(!$items) { |
|
478 | + return; |
|
479 | + } |
|
480 | + if($items && !is_array($items)) { |
|
481 | + $items = array($items); |
|
482 | + } |
|
435 | 483 | |
436 | 484 | $content_items = array(); |
437 | 485 | |
438 | 486 | foreach ($items as $key => $value) |
439 | 487 | { |
440 | - if($key >= $args->list_count) break; |
|
488 | + if($key >= $args->list_count) { |
|
489 | + break; |
|
490 | + } |
|
441 | 491 | unset($item); |
442 | 492 | $item = new stdClass(); |
443 | 493 | |
444 | 494 | foreach($value as $key2 => $value2) |
445 | 495 | { |
446 | - if(is_array($value2)) $value2 = array_shift($value2); |
|
496 | + if(is_array($value2)) { |
|
497 | + $value2 = array_shift($value2); |
|
498 | + } |
|
447 | 499 | $item->{$key2} = $this->_getRssBody($value2); |
448 | 500 | } |
449 | 501 | |
@@ -460,8 +512,7 @@ discard block |
||
460 | 512 | |
461 | 513 | $content_items[] = $content_item; |
462 | 514 | } |
463 | - } |
|
464 | - else if($xml_doc->{'rdf:rdf'}) |
|
515 | + } else if($xml_doc->{'rdf:rdf'}) |
|
465 | 516 | { |
466 | 517 | // rss1.0 supported (XE's XML is case-insensitive because XML parser converts all to small letters) Fixed by misol |
467 | 518 | $rss->title = $xml_doc->{'rdf:rdf'}->channel->title->body; |
@@ -469,20 +520,28 @@ discard block |
||
469 | 520 | |
470 | 521 | $items = $xml_doc->{'rdf:rdf'}->item; |
471 | 522 | |
472 | - if(!$items) return; |
|
473 | - if($items && !is_array($items)) $items = array($items); |
|
523 | + if(!$items) { |
|
524 | + return; |
|
525 | + } |
|
526 | + if($items && !is_array($items)) { |
|
527 | + $items = array($items); |
|
528 | + } |
|
474 | 529 | |
475 | 530 | $content_items = array(); |
476 | 531 | |
477 | 532 | foreach ($items as $key => $value) |
478 | 533 | { |
479 | - if($key >= $args->list_count) break; |
|
534 | + if($key >= $args->list_count) { |
|
535 | + break; |
|
536 | + } |
|
480 | 537 | unset($item); |
481 | 538 | $item = new stdClass(); |
482 | 539 | |
483 | 540 | foreach($value as $key2 => $value2) |
484 | 541 | { |
485 | - if(is_array($value2)) $value2 = array_shift($value2); |
|
542 | + if(is_array($value2)) { |
|
543 | + $value2 = array_shift($value2); |
|
544 | + } |
|
486 | 545 | $item->{$key2} = $this->_getRssBody($value2); |
487 | 546 | } |
488 | 547 | |
@@ -499,8 +558,7 @@ discard block |
||
499 | 558 | |
500 | 559 | $content_items[] = $content_item; |
501 | 560 | } |
502 | - } |
|
503 | - else if($xml_doc->feed && $xml_doc->feed->attrs->xmlns == 'http://www.w3.org/2005/Atom') |
|
561 | + } else if($xml_doc->feed && $xml_doc->feed->attrs->xmlns == 'http://www.w3.org/2005/Atom') |
|
504 | 562 | { |
505 | 563 | // Atom 1.0 spec supported by misol |
506 | 564 | $rss->title = $xml_doc->feed->title->body; |
@@ -515,24 +573,33 @@ discard block |
||
515 | 573 | break; |
516 | 574 | } |
517 | 575 | } |
576 | + } else if($links->attrs->rel == 'alternate') { |
|
577 | + $rss->link = $links->attrs->href; |
|
518 | 578 | } |
519 | - else if($links->attrs->rel == 'alternate') $rss->link = $links->attrs->href; |
|
520 | 579 | |
521 | 580 | $items = $xml_doc->feed->entry; |
522 | 581 | |
523 | - if(!$items) return; |
|
524 | - if($items && !is_array($items)) $items = array($items); |
|
582 | + if(!$items) { |
|
583 | + return; |
|
584 | + } |
|
585 | + if($items && !is_array($items)) { |
|
586 | + $items = array($items); |
|
587 | + } |
|
525 | 588 | |
526 | 589 | $content_items = array(); |
527 | 590 | |
528 | 591 | foreach ($items as $key => $value) |
529 | 592 | { |
530 | - if($key >= $args->list_count) break; |
|
593 | + if($key >= $args->list_count) { |
|
594 | + break; |
|
595 | + } |
|
531 | 596 | unset($item); |
532 | 597 | |
533 | 598 | foreach($value as $key2 => $value2) |
534 | 599 | { |
535 | - if(is_array($value2)) $value2 = array_shift($value2); |
|
600 | + if(is_array($value2)) { |
|
601 | + $value2 = array_shift($value2); |
|
602 | + } |
|
536 | 603 | $item->{$key2} = $this->_getRssBody($value2); |
537 | 604 | } |
538 | 605 | |
@@ -548,13 +615,16 @@ discard block |
||
548 | 615 | break; |
549 | 616 | } |
550 | 617 | } |
618 | + } else if($links->attrs->rel == 'alternate') { |
|
619 | + $item->link = $links->attrs->href; |
|
551 | 620 | } |
552 | - else if($links->attrs->rel == 'alternate') $item->link = $links->attrs->href; |
|
553 | 621 | |
554 | 622 | $content_item->setContentsLink($rss->link); |
555 | 623 | if($item->title) |
556 | 624 | { |
557 | - if(stripos($value->title->attrs->type, "html") === FALSE) $item->title = $value->title->body; |
|
625 | + if(stripos($value->title->attrs->type, "html") === FALSE) { |
|
626 | + $item->title = $value->title->body; |
|
627 | + } |
|
558 | 628 | } |
559 | 629 | $content_item->setTitle($item->title); |
560 | 630 | $content_item->setNickName(max($item->author,$item->{'dc:creator'})); |
@@ -598,7 +668,9 @@ discard block |
||
598 | 668 | $oTrackbackModel = getModel('trackback'); |
599 | 669 | $output = $oTrackbackModel->getNewestTrackbackList($obj); |
600 | 670 | // If an error occurs, just ignore it. |
601 | - if(!$output->toBool() || !$output->data) return; |
|
671 | + if(!$output->toBool() || !$output->data) { |
|
672 | + return; |
|
673 | + } |
|
602 | 674 | // If the result exists, make each document as an object |
603 | 675 | $content_items = array(); |
604 | 676 | foreach($output->data as $key => $item) |
@@ -695,7 +767,9 @@ discard block |
||
695 | 767 | static $default_domain = null; |
696 | 768 | if(!$domain) |
697 | 769 | { |
698 | - if(is_null($default_domain)) $default_domain = Context::getDefaultUrl(); |
|
770 | + if(is_null($default_domain)) { |
|
771 | + $default_domain = Context::getDefaultUrl(); |
|
772 | + } |
|
699 | 773 | $domain = $default_domain; |
700 | 774 | } |
701 | 775 | $this->domain = $domain; |
@@ -764,13 +838,21 @@ discard block |
||
764 | 838 | { |
765 | 839 | $title = strip_tags($this->get('title')); |
766 | 840 | |
767 | - if($cut_size) $title = cut_str($title, $cut_size, $tail); |
|
841 | + if($cut_size) { |
|
842 | + $title = cut_str($title, $cut_size, $tail); |
|
843 | + } |
|
768 | 844 | |
769 | 845 | $attrs = array(); |
770 | - if($this->get('title_bold') == 'Y') $attrs[] = 'font-weight:bold'; |
|
771 | - if($this->get('title_color') && $this->get('title_color') != 'N') $attrs[] = 'color:#'.$this->get('title_color'); |
|
846 | + if($this->get('title_bold') == 'Y') { |
|
847 | + $attrs[] = 'font-weight:bold'; |
|
848 | + } |
|
849 | + if($this->get('title_color') && $this->get('title_color') != 'N') { |
|
850 | + $attrs[] = 'color:#'.$this->get('title_color'); |
|
851 | + } |
|
772 | 852 | |
773 | - if(count($attrs)) $title = sprintf("<span style=\"%s\">%s</span>", implode(';', $attrs), htmlspecialchars($title)); |
|
853 | + if(count($attrs)) { |
|
854 | + $title = sprintf("<span style=\"%s\">%s</span>", implode(';', $attrs), htmlspecialchars($title)); |
|
855 | + } |
|
774 | 856 | |
775 | 857 | return $title; |
776 | 858 | } |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | |
491 | 491 | /** |
492 | 492 | * Returns object of error info |
493 | - * @return object object of error |
|
493 | + * @return BaseObject object of error |
|
494 | 494 | */ |
495 | 495 | function getError() |
496 | 496 | { |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | * Returns counter cache data |
668 | 668 | * @param array|string $tables tables to get data |
669 | 669 | * @param string $condition condition to get data |
670 | - * @return int count of cache data |
|
670 | + * @return boolean count of cache data |
|
671 | 671 | */ |
672 | 672 | function getCountCache($tables, $condition) |
673 | 673 | { |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | * @param array|string $tables tables to save data |
728 | 728 | * @param string $condition condition to save data |
729 | 729 | * @param int $count count of cache data to save |
730 | - * @return void |
|
730 | + * @return boolean |
|
731 | 731 | */ |
732 | 732 | function putCountCache($tables, $condition, $count = 0) |
733 | 733 | { |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | |
810 | 810 | /** |
811 | 811 | * Return select query string |
812 | - * @param object $query |
|
812 | + * @param BaseObject $query |
|
813 | 813 | * @param boolean $with_values |
814 | 814 | * @return string |
815 | 815 | */ |
@@ -903,7 +903,7 @@ discard block |
||
903 | 903 | |
904 | 904 | /** |
905 | 905 | * Return delete query string |
906 | - * @param object $query |
|
906 | + * @param BaseObject $query |
|
907 | 907 | * @param boolean $with_values |
908 | 908 | * @param boolean $with_priority |
909 | 909 | * @return string |
@@ -935,7 +935,7 @@ discard block |
||
935 | 935 | |
936 | 936 | /** |
937 | 937 | * Return update query string |
938 | - * @param object $query |
|
938 | + * @param BaseObject $query |
|
939 | 939 | * @param boolean $with_values |
940 | 940 | * @param boolean $with_priority |
941 | 941 | * @return string |
@@ -967,7 +967,7 @@ discard block |
||
967 | 967 | |
968 | 968 | /** |
969 | 969 | * Return insert query string |
970 | - * @param object $query |
|
970 | + * @param BaseObject $query |
|
971 | 971 | * @param boolean $with_values |
972 | 972 | * @param boolean $with_priority |
973 | 973 | * @return string |
@@ -1238,7 +1238,7 @@ discard block |
||
1238 | 1238 | * DB Connect |
1239 | 1239 | * this method is protected |
1240 | 1240 | * @param array $connection |
1241 | - * @return void |
|
1241 | + * @return resource |
|
1242 | 1242 | */ |
1243 | 1243 | function __connect($connection) |
1244 | 1244 | { |
@@ -141,24 +141,24 @@ discard block |
||
141 | 141 | */ |
142 | 142 | function getInstance($db_type = NULL) |
143 | 143 | { |
144 | - if(!$db_type) |
|
144 | + if (!$db_type) |
|
145 | 145 | { |
146 | 146 | $db_type = Context::getDBType(); |
147 | 147 | } |
148 | - if(!$db_type && Context::isInstalled()) |
|
148 | + if (!$db_type && Context::isInstalled()) |
|
149 | 149 | { |
150 | 150 | return new BaseObject(-1, 'msg_db_not_setted'); |
151 | 151 | } |
152 | 152 | |
153 | - if(!isset($GLOBALS['__DB__'])) |
|
153 | + if (!isset($GLOBALS['__DB__'])) |
|
154 | 154 | { |
155 | 155 | $GLOBALS['__DB__'] = array(); |
156 | 156 | } |
157 | - if(!isset($GLOBALS['__DB__'][$db_type])) |
|
157 | + if (!isset($GLOBALS['__DB__'][$db_type])) |
|
158 | 158 | { |
159 | - $class_name = 'DB' . ucfirst($db_type); |
|
160 | - $class_file = _XE_PATH_ . "classes/db/$class_name.class.php"; |
|
161 | - if(!file_exists($class_file)) |
|
159 | + $class_name = 'DB'.ucfirst($db_type); |
|
160 | + $class_file = _XE_PATH_."classes/db/$class_name.class.php"; |
|
161 | + if (!file_exists($class_file)) |
|
162 | 162 | { |
163 | 163 | return new BaseObject(-1, 'msg_db_not_setted'); |
164 | 164 | } |
@@ -187,8 +187,8 @@ discard block |
||
187 | 187 | */ |
188 | 188 | function DB() |
189 | 189 | { |
190 | - $this->count_cache_path = _XE_PATH_ . $this->count_cache_path; |
|
191 | - $this->cache_file = _XE_PATH_ . $this->cache_file; |
|
190 | + $this->count_cache_path = _XE_PATH_.$this->count_cache_path; |
|
191 | + $this->cache_file = _XE_PATH_.$this->cache_file; |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | /** |
@@ -210,18 +210,18 @@ discard block |
||
210 | 210 | */ |
211 | 211 | public static function getEnableList() |
212 | 212 | { |
213 | - if(!self::$supported_list) |
|
213 | + if (!self::$supported_list) |
|
214 | 214 | { |
215 | 215 | $oDB = new DB(); |
216 | 216 | self::$supported_list = $oDB->_getSupportedList(); |
217 | 217 | } |
218 | 218 | |
219 | 219 | $enableList = array(); |
220 | - if(is_array(self::$supported_list)) |
|
220 | + if (is_array(self::$supported_list)) |
|
221 | 221 | { |
222 | - foreach(self::$supported_list AS $key => $value) |
|
222 | + foreach (self::$supported_list AS $key => $value) |
|
223 | 223 | { |
224 | - if($value->enable) |
|
224 | + if ($value->enable) |
|
225 | 225 | { |
226 | 226 | $enableList[] = $value; |
227 | 227 | } |
@@ -237,18 +237,18 @@ discard block |
||
237 | 237 | */ |
238 | 238 | public static function getDisableList() |
239 | 239 | { |
240 | - if(!self::$supported_list) |
|
240 | + if (!self::$supported_list) |
|
241 | 241 | { |
242 | 242 | $oDB = new DB(); |
243 | 243 | self::$supported_list = $oDB->_getSupportedList(); |
244 | 244 | } |
245 | 245 | |
246 | 246 | $disableList = array(); |
247 | - if(is_array(self::$supported_list)) |
|
247 | + if (is_array(self::$supported_list)) |
|
248 | 248 | { |
249 | - foreach(self::$supported_list AS $key => $value) |
|
249 | + foreach (self::$supported_list AS $key => $value) |
|
250 | 250 | { |
251 | - if(!$value->enable) |
|
251 | + if (!$value->enable) |
|
252 | 252 | { |
253 | 253 | $disableList[] = $value; |
254 | 254 | } |
@@ -265,24 +265,24 @@ discard block |
||
265 | 265 | function _getSupportedList() |
266 | 266 | { |
267 | 267 | static $get_supported_list = ''; |
268 | - if(is_array($get_supported_list)) |
|
268 | + if (is_array($get_supported_list)) |
|
269 | 269 | { |
270 | 270 | self::$supported_list = $get_supported_list; |
271 | 271 | return self::$supported_list; |
272 | 272 | } |
273 | 273 | $get_supported_list = array(); |
274 | - $db_classes_path = _XE_PATH_ . "classes/db/"; |
|
274 | + $db_classes_path = _XE_PATH_."classes/db/"; |
|
275 | 275 | $filter = "/^DB([^\.]+)\.class\.php/i"; |
276 | 276 | $supported_list = FileHandler::readDir($db_classes_path, $filter, TRUE); |
277 | 277 | |
278 | 278 | // after creating instance of class, check is supported |
279 | - for($i = 0; $i < count($supported_list); $i++) |
|
279 | + for ($i = 0; $i < count($supported_list); $i++) |
|
280 | 280 | { |
281 | 281 | $db_type = $supported_list[$i]; |
282 | 282 | |
283 | 283 | $class_name = sprintf("DB%s%s", strtoupper(substr($db_type, 0, 1)), strtolower(substr($db_type, 1))); |
284 | - $class_file = sprintf(_XE_PATH_ . "classes/db/%s.class.php", $class_name); |
|
285 | - if(!file_exists($class_file)) |
|
284 | + $class_file = sprintf(_XE_PATH_."classes/db/%s.class.php", $class_name); |
|
285 | + if (!file_exists($class_file)) |
|
286 | 286 | { |
287 | 287 | continue; |
288 | 288 | } |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | require_once($class_file); |
292 | 292 | $oDB = new $class_name(FALSE); |
293 | 293 | |
294 | - if(!$oDB) |
|
294 | + if (!$oDB) |
|
295 | 295 | { |
296 | 296 | continue; |
297 | 297 | } |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | */ |
316 | 316 | function _sortDBMS($a, $b) |
317 | 317 | { |
318 | - if(!isset($this->priority_dbms[$a->db_type])) |
|
318 | + if (!isset($this->priority_dbms[$a->db_type])) |
|
319 | 319 | { |
320 | 320 | $priority_a = 0; |
321 | 321 | } |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | $priority_a = $this->priority_dbms[$a->db_type]; |
325 | 325 | } |
326 | 326 | |
327 | - if(!isset($this->priority_dbms[$b->db_type])) |
|
327 | + if (!isset($this->priority_dbms[$b->db_type])) |
|
328 | 328 | { |
329 | 329 | $priority_b = 0; |
330 | 330 | } |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | $priority_b = $this->priority_dbms[$b->db_type]; |
334 | 334 | } |
335 | 335 | |
336 | - if($priority_a == $priority_b) |
|
336 | + if ($priority_a == $priority_b) |
|
337 | 337 | { |
338 | 338 | return 0; |
339 | 339 | } |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | */ |
360 | 360 | function isConnected($type = 'master', $indx = 0) |
361 | 361 | { |
362 | - if($type == 'master') |
|
362 | + if ($type == 'master') |
|
363 | 363 | { |
364 | 364 | return $this->master_db["is_connected"] ? TRUE : FALSE; |
365 | 365 | } |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | */ |
389 | 389 | function actFinish() |
390 | 390 | { |
391 | - if(!$this->query) |
|
391 | + if (!$this->query) |
|
392 | 392 | { |
393 | 393 | return; |
394 | 394 | } |
@@ -409,14 +409,14 @@ discard block |
||
409 | 409 | |
410 | 410 | $bt = version_compare(PHP_VERSION, '5.3.6', '>=') ? debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) : debug_backtrace(); |
411 | 411 | |
412 | - foreach($bt as $no => $call) |
|
412 | + foreach ($bt as $no => $call) |
|
413 | 413 | { |
414 | - if($call['function'] == 'executeQuery' || $call['function'] == 'executeQueryArray') |
|
414 | + if ($call['function'] == 'executeQuery' || $call['function'] == 'executeQueryArray') |
|
415 | 415 | { |
416 | 416 | $call_no = $no; |
417 | 417 | $call_no++; |
418 | 418 | $log['called_file'] = $bt[$call_no]['file'].':'.$bt[$call_no]['line']; |
419 | - $log['called_file'] = str_replace(_XE_PATH_ , '', $log['called_file']); |
|
419 | + $log['called_file'] = str_replace(_XE_PATH_, '', $log['called_file']); |
|
420 | 420 | $call_no++; |
421 | 421 | $log['called_method'] = $bt[$call_no]['class'].$bt[$call_no]['type'].$bt[$call_no]['function']; |
422 | 422 | break; |
@@ -424,22 +424,22 @@ discard block |
||
424 | 424 | } |
425 | 425 | |
426 | 426 | // leave error log if an error occured (if __DEBUG_DB_OUTPUT__ is defined) |
427 | - if($this->isError()) |
|
427 | + if ($this->isError()) |
|
428 | 428 | { |
429 | 429 | $log['result'] = 'Failed'; |
430 | 430 | $log['errno'] = $this->errno; |
431 | 431 | $log['errstr'] = $this->errstr; |
432 | 432 | |
433 | - if(__DEBUG_DB_OUTPUT__ == 1) |
|
433 | + if (__DEBUG_DB_OUTPUT__ == 1) |
|
434 | 434 | { |
435 | - $debug_file = _XE_PATH_ . "files/_debug_db_query.php"; |
|
435 | + $debug_file = _XE_PATH_."files/_debug_db_query.php"; |
|
436 | 436 | $buff = array(); |
437 | - if(!file_exists($debug_file)) |
|
437 | + if (!file_exists($debug_file)) |
|
438 | 438 | { |
439 | - $buff[] = '<?php exit(); ?' . '>'; |
|
439 | + $buff[] = '<?php exit(); ?'.'>'; |
|
440 | 440 | } |
441 | 441 | $buff[] = print_r($log, TRUE); |
442 | - @file_put_contents($log_file, implode("\n", $buff) . "\n\n", FILE_APPEND|LOCK_EX); |
|
442 | + @file_put_contents($log_file, implode("\n", $buff)."\n\n", FILE_APPEND | LOCK_EX); |
|
443 | 443 | } |
444 | 444 | } |
445 | 445 | else |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | $log_args = new stdClass; |
453 | 453 | $log_args->query = $this->query; |
454 | 454 | $log_args->query_id = $this->query_id; |
455 | - $log_args->caller = $log['called_method'] . '() in ' . $log['called_file']; |
|
455 | + $log_args->caller = $log['called_method'].'() in '.$log['called_file']; |
|
456 | 456 | $log_args->connection = $log['connection']; |
457 | 457 | writeSlowlog('query', $elapsed_time, $log_args); |
458 | 458 | } |
@@ -510,11 +510,11 @@ discard block |
||
510 | 510 | { |
511 | 511 | static $cache_file = array(); |
512 | 512 | |
513 | - if(!$query_id) |
|
513 | + if (!$query_id) |
|
514 | 514 | { |
515 | 515 | return new BaseObject(-1, 'msg_invalid_queryid'); |
516 | 516 | } |
517 | - if(!$this->db_type) |
|
517 | + if (!$this->db_type) |
|
518 | 518 | { |
519 | 519 | return; |
520 | 520 | } |
@@ -523,20 +523,20 @@ discard block |
||
523 | 523 | |
524 | 524 | $this->query_id = $query_id; |
525 | 525 | |
526 | - if(!isset($cache_file[$query_id]) || !file_exists($cache_file[$query_id])) |
|
526 | + if (!isset($cache_file[$query_id]) || !file_exists($cache_file[$query_id])) |
|
527 | 527 | { |
528 | 528 | $id_args = explode('.', $query_id); |
529 | - if(count($id_args) == 2) |
|
529 | + if (count($id_args) == 2) |
|
530 | 530 | { |
531 | 531 | $target = 'modules'; |
532 | 532 | $module = $id_args[0]; |
533 | 533 | $id = $id_args[1]; |
534 | 534 | } |
535 | - elseif(count($id_args) == 3) |
|
535 | + elseif (count($id_args) == 3) |
|
536 | 536 | { |
537 | 537 | $target = $id_args[0]; |
538 | 538 | $typeList = array('addons' => 1, 'widgets' => 1); |
539 | - if(!isset($typeList[$target])) |
|
539 | + if (!isset($typeList[$target])) |
|
540 | 540 | { |
541 | 541 | $this->actDBClassFinish(); |
542 | 542 | return; |
@@ -544,14 +544,14 @@ discard block |
||
544 | 544 | $module = $id_args[1]; |
545 | 545 | $id = $id_args[2]; |
546 | 546 | } |
547 | - if(!$target || !$module || !$id) |
|
547 | + if (!$target || !$module || !$id) |
|
548 | 548 | { |
549 | 549 | $this->actDBClassFinish(); |
550 | 550 | return new BaseObject(-1, 'msg_invalid_queryid'); |
551 | 551 | } |
552 | 552 | |
553 | 553 | $xml_file = sprintf('%s%s/%s/queries/%s.xml', _XE_PATH_, $target, $module, $id); |
554 | - if(!file_exists($xml_file)) |
|
554 | + if (!file_exists($xml_file)) |
|
555 | 555 | { |
556 | 556 | $this->actDBClassFinish(); |
557 | 557 | return new BaseObject(-1, 'msg_invalid_queryid'); |
@@ -579,13 +579,13 @@ discard block |
||
579 | 579 | $cache_file = sprintf('%s%s%s.%s.%s.cache.php', _XE_PATH_, $this->cache_file, $query_id, __ZBXE_VERSION__, $this->db_type); |
580 | 580 | |
581 | 581 | $cache_time = -1; |
582 | - if(file_exists($cache_file)) |
|
582 | + if (file_exists($cache_file)) |
|
583 | 583 | { |
584 | 584 | $cache_time = filemtime($cache_file); |
585 | 585 | } |
586 | 586 | |
587 | 587 | // if there is no cache file or is not new, find original xml query file and parse it |
588 | - if($cache_time < filemtime($xml_file) || $cache_time < filemtime(_XE_PATH_ . 'classes/db/DB.class.php') || $cache_time < filemtime(_XE_PATH_ . 'classes/xml/XmlQueryParser.class.php')) |
|
588 | + if ($cache_time < filemtime($xml_file) || $cache_time < filemtime(_XE_PATH_.'classes/db/DB.class.php') || $cache_time < filemtime(_XE_PATH_.'classes/xml/XmlQueryParser.class.php')) |
|
589 | 589 | { |
590 | 590 | $oParser = new XmlQueryParser(); |
591 | 591 | $oParser->parse($query_id, $xml_file, $cache_file); |
@@ -606,27 +606,27 @@ discard block |
||
606 | 606 | { |
607 | 607 | global $lang; |
608 | 608 | |
609 | - if(!in_array($type, array('master','slave'))) $type = 'slave'; |
|
609 | + if (!in_array($type, array('master', 'slave'))) $type = 'slave'; |
|
610 | 610 | |
611 | - if(!file_exists($cache_file)) |
|
611 | + if (!file_exists($cache_file)) |
|
612 | 612 | { |
613 | 613 | return new BaseObject(-1, 'msg_invalid_queryid'); |
614 | 614 | } |
615 | 615 | |
616 | - if($source_args) |
|
616 | + if ($source_args) |
|
617 | 617 | { |
618 | 618 | $args = clone $source_args; |
619 | 619 | } |
620 | 620 | |
621 | 621 | $output = include($cache_file); |
622 | 622 | |
623 | - if((is_a($output, 'BaseObject') || is_subclass_of($output, 'BaseObject')) && !$output->toBool()) |
|
623 | + if ((is_a($output, 'BaseObject') || is_subclass_of($output, 'BaseObject')) && !$output->toBool()) |
|
624 | 624 | { |
625 | 625 | return $output; |
626 | 626 | } |
627 | 627 | |
628 | 628 | // execute appropriate query |
629 | - switch($output->getAction()) |
|
629 | + switch ($output->getAction()) |
|
630 | 630 | { |
631 | 631 | case 'insert' : |
632 | 632 | case 'insert-select' : |
@@ -649,11 +649,11 @@ discard block |
||
649 | 649 | break; |
650 | 650 | } |
651 | 651 | |
652 | - if($this->isError()) |
|
652 | + if ($this->isError()) |
|
653 | 653 | { |
654 | 654 | $output = $this->getError(); |
655 | 655 | } |
656 | - else if(!is_a($output, 'BaseObject') && !is_subclass_of($output, 'BaseObject')) |
|
656 | + else if (!is_a($output, 'BaseObject') && !is_subclass_of($output, 'BaseObject')) |
|
657 | 657 | { |
658 | 658 | $output = new BaseObject(); |
659 | 659 | } |
@@ -799,7 +799,7 @@ discard block |
||
799 | 799 | */ |
800 | 800 | function dropTable($table_name) |
801 | 801 | { |
802 | - if(!$table_name) |
|
802 | + if (!$table_name) |
|
803 | 803 | { |
804 | 804 | return; |
805 | 805 | } |
@@ -816,59 +816,59 @@ discard block |
||
816 | 816 | function getSelectSql($query, $with_values = TRUE) |
817 | 817 | { |
818 | 818 | $select = $query->getSelectString($with_values); |
819 | - if($select == '') |
|
819 | + if ($select == '') |
|
820 | 820 | { |
821 | 821 | return new BaseObject(-1, "Invalid query"); |
822 | 822 | } |
823 | - $select = 'SELECT ' . $select; |
|
823 | + $select = 'SELECT '.$select; |
|
824 | 824 | |
825 | 825 | $from = $query->getFromString($with_values); |
826 | - if($from == '') |
|
826 | + if ($from == '') |
|
827 | 827 | { |
828 | 828 | return new BaseObject(-1, "Invalid query"); |
829 | 829 | } |
830 | - $from = ' FROM ' . $from; |
|
830 | + $from = ' FROM '.$from; |
|
831 | 831 | |
832 | 832 | $where = $query->getWhereString($with_values); |
833 | - if($where != '') |
|
833 | + if ($where != '') |
|
834 | 834 | { |
835 | - $where = ' WHERE ' . $where; |
|
835 | + $where = ' WHERE '.$where; |
|
836 | 836 | } |
837 | 837 | |
838 | 838 | $tableObjects = $query->getTables(); |
839 | 839 | $index_hint_list = ''; |
840 | - foreach($tableObjects as $tableObject) |
|
840 | + foreach ($tableObjects as $tableObject) |
|
841 | 841 | { |
842 | - if(is_a($tableObject, 'CubridTableWithHint')) |
|
842 | + if (is_a($tableObject, 'CubridTableWithHint')) |
|
843 | 843 | { |
844 | - $index_hint_list .= $tableObject->getIndexHintString() . ', '; |
|
844 | + $index_hint_list .= $tableObject->getIndexHintString().', '; |
|
845 | 845 | } |
846 | 846 | } |
847 | 847 | $index_hint_list = substr($index_hint_list, 0, -2); |
848 | - if($index_hint_list != '') |
|
848 | + if ($index_hint_list != '') |
|
849 | 849 | { |
850 | - $index_hint_list = 'USING INDEX ' . $index_hint_list; |
|
850 | + $index_hint_list = 'USING INDEX '.$index_hint_list; |
|
851 | 851 | } |
852 | 852 | |
853 | 853 | $groupBy = $query->getGroupByString(); |
854 | - if($groupBy != '') |
|
854 | + if ($groupBy != '') |
|
855 | 855 | { |
856 | - $groupBy = ' GROUP BY ' . $groupBy; |
|
856 | + $groupBy = ' GROUP BY '.$groupBy; |
|
857 | 857 | } |
858 | 858 | |
859 | 859 | $orderBy = $query->getOrderByString(); |
860 | - if($orderBy != '') |
|
860 | + if ($orderBy != '') |
|
861 | 861 | { |
862 | - $orderBy = ' ORDER BY ' . $orderBy; |
|
862 | + $orderBy = ' ORDER BY '.$orderBy; |
|
863 | 863 | } |
864 | 864 | |
865 | 865 | $limit = $query->getLimitString(); |
866 | - if($limit != '') |
|
866 | + if ($limit != '') |
|
867 | 867 | { |
868 | - $limit = ' LIMIT ' . $limit; |
|
868 | + $limit = ' LIMIT '.$limit; |
|
869 | 869 | } |
870 | 870 | |
871 | - return $select . ' ' . $from . ' ' . $where . ' ' . $index_hint_list . ' ' . $groupBy . ' ' . $orderBy . ' ' . $limit; |
|
871 | + return $select.' '.$from.' '.$where.' '.$index_hint_list.' '.$groupBy.' '.$orderBy.' '.$limit; |
|
872 | 872 | } |
873 | 873 | |
874 | 874 | /** |
@@ -886,7 +886,7 @@ discard block |
||
886 | 886 | { |
887 | 887 | $new_update_columns = array(); |
888 | 888 | $click_count_columns = $queryObject->getClickCountColumns(); |
889 | - foreach($click_count_columns as $click_count_column) |
|
889 | + foreach ($click_count_columns as $click_count_column) |
|
890 | 890 | { |
891 | 891 | $click_count_column_name = $click_count_column->column_name; |
892 | 892 | |
@@ -918,16 +918,16 @@ discard block |
||
918 | 918 | $sql .= $tables[0]->getAlias(); |
919 | 919 | |
920 | 920 | $from = $query->getFromString($with_values); |
921 | - if($from == '') |
|
921 | + if ($from == '') |
|
922 | 922 | { |
923 | 923 | return new BaseObject(-1, "Invalid query"); |
924 | 924 | } |
925 | - $sql .= ' FROM ' . $from; |
|
925 | + $sql .= ' FROM '.$from; |
|
926 | 926 | |
927 | 927 | $where = $query->getWhereString($with_values); |
928 | - if($where != '') |
|
928 | + if ($where != '') |
|
929 | 929 | { |
930 | - $sql .= ' WHERE ' . $where; |
|
930 | + $sql .= ' WHERE '.$where; |
|
931 | 931 | } |
932 | 932 | |
933 | 933 | return $sql; |
@@ -943,26 +943,26 @@ discard block |
||
943 | 943 | function getUpdateSql($query, $with_values = TRUE, $with_priority = FALSE) |
944 | 944 | { |
945 | 945 | $columnsList = $query->getUpdateString($with_values); |
946 | - if($columnsList == '') |
|
946 | + if ($columnsList == '') |
|
947 | 947 | { |
948 | 948 | return new BaseObject(-1, "Invalid query"); |
949 | 949 | } |
950 | 950 | |
951 | 951 | $tables = $query->getFromString($with_values); |
952 | - if($tables == '') |
|
952 | + if ($tables == '') |
|
953 | 953 | { |
954 | 954 | return new BaseObject(-1, "Invalid query"); |
955 | 955 | } |
956 | 956 | |
957 | 957 | $where = $query->getWhereString($with_values); |
958 | - if($where != '') |
|
958 | + if ($where != '') |
|
959 | 959 | { |
960 | - $where = ' WHERE ' . $where; |
|
960 | + $where = ' WHERE '.$where; |
|
961 | 961 | } |
962 | 962 | |
963 | 963 | $priority = $with_priority ? $query->getPriority() : ''; |
964 | 964 | |
965 | - return "UPDATE $priority $tables SET $columnsList " . $where; |
|
965 | + return "UPDATE $priority $tables SET $columnsList ".$where; |
|
966 | 966 | } |
967 | 967 | |
968 | 968 | /** |
@@ -1000,27 +1000,27 @@ discard block |
||
1000 | 1000 | */ |
1001 | 1001 | function _getConnection($type = 'master', $indx = NULL) |
1002 | 1002 | { |
1003 | - if($type == 'master') |
|
1003 | + if ($type == 'master') |
|
1004 | 1004 | { |
1005 | - if(!$this->master_db['is_connected']) |
|
1005 | + if (!$this->master_db['is_connected']) |
|
1006 | 1006 | { |
1007 | 1007 | $this->_connect($type); |
1008 | 1008 | } |
1009 | - $this->connection = 'Master ' . $this->master_db['db_hostname']; |
|
1009 | + $this->connection = 'Master '.$this->master_db['db_hostname']; |
|
1010 | 1010 | return $this->master_db["resource"]; |
1011 | 1011 | } |
1012 | 1012 | |
1013 | - if($indx === NULL) |
|
1013 | + if ($indx === NULL) |
|
1014 | 1014 | { |
1015 | 1015 | $indx = $this->_getSlaveConnectionStringIndex($type); |
1016 | 1016 | } |
1017 | 1017 | |
1018 | - if(!$this->slave_db[$indx]['is_connected']) |
|
1018 | + if (!$this->slave_db[$indx]['is_connected']) |
|
1019 | 1019 | { |
1020 | 1020 | $this->_connect($type, $indx); |
1021 | 1021 | } |
1022 | 1022 | |
1023 | - $this->connection = 'Slave ' . $this->slave_db[$indx]['db_hostname']; |
|
1023 | + $this->connection = 'Slave '.$this->slave_db[$indx]['db_hostname']; |
|
1024 | 1024 | return $this->slave_db[$indx]["resource"]; |
1025 | 1025 | } |
1026 | 1026 | |
@@ -1030,11 +1030,11 @@ discard block |
||
1030 | 1030 | */ |
1031 | 1031 | function _dbInfoExists() |
1032 | 1032 | { |
1033 | - if(!$this->master_db) |
|
1033 | + if (!$this->master_db) |
|
1034 | 1034 | { |
1035 | 1035 | return FALSE; |
1036 | 1036 | } |
1037 | - if(count($this->slave_db) === 0) |
|
1037 | + if (count($this->slave_db) === 0) |
|
1038 | 1038 | { |
1039 | 1039 | return FALSE; |
1040 | 1040 | } |
@@ -1060,12 +1060,12 @@ discard block |
||
1060 | 1060 | */ |
1061 | 1061 | function close($type = 'master', $indx = 0) |
1062 | 1062 | { |
1063 | - if(!$this->isConnected($type, $indx)) |
|
1063 | + if (!$this->isConnected($type, $indx)) |
|
1064 | 1064 | { |
1065 | 1065 | return; |
1066 | 1066 | } |
1067 | 1067 | |
1068 | - if($type == 'master') |
|
1068 | + if ($type == 'master') |
|
1069 | 1069 | { |
1070 | 1070 | $connection = &$this->master_db; |
1071 | 1071 | } |
@@ -1096,12 +1096,12 @@ discard block |
||
1096 | 1096 | */ |
1097 | 1097 | function begin() |
1098 | 1098 | { |
1099 | - if(!$this->isConnected()) |
|
1099 | + if (!$this->isConnected()) |
|
1100 | 1100 | { |
1101 | 1101 | return; |
1102 | 1102 | } |
1103 | 1103 | |
1104 | - if($this->_begin($this->transactionNestedLevel)) |
|
1104 | + if ($this->_begin($this->transactionNestedLevel)) |
|
1105 | 1105 | { |
1106 | 1106 | $this->transaction_started = TRUE; |
1107 | 1107 | $this->transactionNestedLevel++; |
@@ -1124,15 +1124,15 @@ discard block |
||
1124 | 1124 | */ |
1125 | 1125 | function rollback() |
1126 | 1126 | { |
1127 | - if(!$this->isConnected() || !$this->transaction_started) |
|
1127 | + if (!$this->isConnected() || !$this->transaction_started) |
|
1128 | 1128 | { |
1129 | 1129 | return; |
1130 | 1130 | } |
1131 | - if($this->_rollback($this->transactionNestedLevel)) |
|
1131 | + if ($this->_rollback($this->transactionNestedLevel)) |
|
1132 | 1132 | { |
1133 | 1133 | $this->transactionNestedLevel--; |
1134 | 1134 | |
1135 | - if(!$this->transactionNestedLevel) |
|
1135 | + if (!$this->transactionNestedLevel) |
|
1136 | 1136 | { |
1137 | 1137 | $this->transaction_started = FALSE; |
1138 | 1138 | } |
@@ -1156,11 +1156,11 @@ discard block |
||
1156 | 1156 | */ |
1157 | 1157 | function commit($force = FALSE) |
1158 | 1158 | { |
1159 | - if(!$force && (!$this->isConnected() || !$this->transaction_started)) |
|
1159 | + if (!$force && (!$this->isConnected() || !$this->transaction_started)) |
|
1160 | 1160 | { |
1161 | 1161 | return; |
1162 | 1162 | } |
1163 | - if($this->transactionNestedLevel == 1 && $this->_commit()) |
|
1163 | + if ($this->transactionNestedLevel == 1 && $this->_commit()) |
|
1164 | 1164 | { |
1165 | 1165 | $this->transaction_started = FALSE; |
1166 | 1166 | $this->transactionNestedLevel = 0; |
@@ -1192,7 +1192,7 @@ discard block |
||
1192 | 1192 | */ |
1193 | 1193 | function _query($query, $connection = NULL) |
1194 | 1194 | { |
1195 | - if($connection == NULL) |
|
1195 | + if ($connection == NULL) |
|
1196 | 1196 | { |
1197 | 1197 | $connection = $this->_getConnection('master'); |
1198 | 1198 | } |
@@ -1217,7 +1217,7 @@ discard block |
||
1217 | 1217 | { |
1218 | 1218 | $db_info = Context::getDBInfo(); |
1219 | 1219 | $this->master_db = $db_info->master_db; |
1220 | - if($db_info->master_db["db_hostname"] == $db_info->slave_db[0]["db_hostname"] |
|
1220 | + if ($db_info->master_db["db_hostname"] == $db_info->slave_db[0]["db_hostname"] |
|
1221 | 1221 | && $db_info->master_db["db_port"] == $db_info->slave_db[0]["db_port"] |
1222 | 1222 | && $db_info->master_db["db_userid"] == $db_info->slave_db[0]["db_userid"] |
1223 | 1223 | && $db_info->master_db["db_password"] == $db_info->slave_db[0]["db_password"] |
@@ -1265,18 +1265,18 @@ discard block |
||
1265 | 1265 | */ |
1266 | 1266 | function _connect($type = 'master', $indx = 0) |
1267 | 1267 | { |
1268 | - if($this->isConnected($type, $indx)) |
|
1268 | + if ($this->isConnected($type, $indx)) |
|
1269 | 1269 | { |
1270 | 1270 | return; |
1271 | 1271 | } |
1272 | 1272 | |
1273 | 1273 | // Ignore if no DB information exists |
1274 | - if(!$this->_dbInfoExists()) |
|
1274 | + if (!$this->_dbInfoExists()) |
|
1275 | 1275 | { |
1276 | 1276 | return; |
1277 | 1277 | } |
1278 | 1278 | |
1279 | - if($type == 'master') |
|
1279 | + if ($type == 'master') |
|
1280 | 1280 | { |
1281 | 1281 | $connection = &$this->master_db; |
1282 | 1282 | } |
@@ -1286,7 +1286,7 @@ discard block |
||
1286 | 1286 | } |
1287 | 1287 | |
1288 | 1288 | $result = $this->__connect($connection); |
1289 | - if($result === NULL || $result === FALSE) |
|
1289 | + if ($result === NULL || $result === FALSE) |
|
1290 | 1290 | { |
1291 | 1291 | $connection["is_connected"] = FALSE; |
1292 | 1292 | return; |
@@ -1297,7 +1297,7 @@ discard block |
||
1297 | 1297 | $connection["is_connected"] = TRUE; |
1298 | 1298 | |
1299 | 1299 | // Save connection info for db logs |
1300 | - $this->connection = ucfirst($type) . ' ' . $connection["db_hostname"]; |
|
1300 | + $this->connection = ucfirst($type).' '.$connection["db_hostname"]; |
|
1301 | 1301 | |
1302 | 1302 | // regist $this->close callback |
1303 | 1303 | register_shutdown_function(array($this, "close")); |
@@ -1322,7 +1322,7 @@ discard block |
||
1322 | 1322 | */ |
1323 | 1323 | function actDBClassFinish() |
1324 | 1324 | { |
1325 | - if(!$this->query) |
|
1325 | + if (!$this->query) |
|
1326 | 1326 | { |
1327 | 1327 | return; |
1328 | 1328 | } |
@@ -1345,7 +1345,7 @@ discard block |
||
1345 | 1345 | function getParser($force = FALSE) |
1346 | 1346 | { |
1347 | 1347 | static $dbParser = NULL; |
1348 | - if(!$dbParser || $force) |
|
1348 | + if (!$dbParser || $force) |
|
1349 | 1349 | { |
1350 | 1350 | $oDB = DB::getInstance(); |
1351 | 1351 | $dbParser = $oDB->getParser(); |
@@ -318,8 +318,7 @@ discard block |
||
318 | 318 | if(!isset($this->priority_dbms[$a->db_type])) |
319 | 319 | { |
320 | 320 | $priority_a = 0; |
321 | - } |
|
322 | - else |
|
321 | + } else |
|
323 | 322 | { |
324 | 323 | $priority_a = $this->priority_dbms[$a->db_type]; |
325 | 324 | } |
@@ -327,8 +326,7 @@ discard block |
||
327 | 326 | if(!isset($this->priority_dbms[$b->db_type])) |
328 | 327 | { |
329 | 328 | $priority_b = 0; |
330 | - } |
|
331 | - else |
|
329 | + } else |
|
332 | 330 | { |
333 | 331 | $priority_b = $this->priority_dbms[$b->db_type]; |
334 | 332 | } |
@@ -362,8 +360,7 @@ discard block |
||
362 | 360 | if($type == 'master') |
363 | 361 | { |
364 | 362 | return $this->master_db["is_connected"] ? TRUE : FALSE; |
365 | - } |
|
366 | - else |
|
363 | + } else |
|
367 | 364 | { |
368 | 365 | return $this->slave_db[$indx]["is_connected"] ? TRUE : FALSE; |
369 | 366 | } |
@@ -441,8 +438,7 @@ discard block |
||
441 | 438 | $buff[] = print_r($log, TRUE); |
442 | 439 | @file_put_contents($log_file, implode("\n", $buff) . "\n\n", FILE_APPEND|LOCK_EX); |
443 | 440 | } |
444 | - } |
|
445 | - else |
|
441 | + } else |
|
446 | 442 | { |
447 | 443 | $log['result'] = 'Success'; |
448 | 444 | } |
@@ -531,8 +527,7 @@ discard block |
||
531 | 527 | $target = 'modules'; |
532 | 528 | $module = $id_args[0]; |
533 | 529 | $id = $id_args[1]; |
534 | - } |
|
535 | - elseif(count($id_args) == 3) |
|
530 | + } elseif(count($id_args) == 3) |
|
536 | 531 | { |
537 | 532 | $target = $id_args[0]; |
538 | 533 | $typeList = array('addons' => 1, 'widgets' => 1); |
@@ -606,7 +601,9 @@ discard block |
||
606 | 601 | { |
607 | 602 | global $lang; |
608 | 603 | |
609 | - if(!in_array($type, array('master','slave'))) $type = 'slave'; |
|
604 | + if(!in_array($type, array('master','slave'))) { |
|
605 | + $type = 'slave'; |
|
606 | + } |
|
610 | 607 | |
611 | 608 | if(!file_exists($cache_file)) |
612 | 609 | { |
@@ -652,8 +649,7 @@ discard block |
||
652 | 649 | if($this->isError()) |
653 | 650 | { |
654 | 651 | $output = $this->getError(); |
655 | - } |
|
656 | - else if(!is_a($output, 'BaseObject') && !is_subclass_of($output, 'BaseObject')) |
|
652 | + } else if(!is_a($output, 'BaseObject') && !is_subclass_of($output, 'BaseObject')) |
|
657 | 653 | { |
658 | 654 | $output = new BaseObject(); |
659 | 655 | } |
@@ -1068,8 +1064,7 @@ discard block |
||
1068 | 1064 | if($type == 'master') |
1069 | 1065 | { |
1070 | 1066 | $connection = &$this->master_db; |
1071 | - } |
|
1072 | - else |
|
1067 | + } else |
|
1073 | 1068 | { |
1074 | 1069 | $connection = &$this->slave_db[$indx]; |
1075 | 1070 | } |
@@ -1164,8 +1159,7 @@ discard block |
||
1164 | 1159 | { |
1165 | 1160 | $this->transaction_started = FALSE; |
1166 | 1161 | $this->transactionNestedLevel = 0; |
1167 | - } |
|
1168 | - else |
|
1162 | + } else |
|
1169 | 1163 | { |
1170 | 1164 | $this->transactionNestedLevel--; |
1171 | 1165 | } |
@@ -1225,8 +1219,7 @@ discard block |
||
1225 | 1219 | ) |
1226 | 1220 | { |
1227 | 1221 | $this->slave_db[0] = &$this->master_db; |
1228 | - } |
|
1229 | - else |
|
1222 | + } else |
|
1230 | 1223 | { |
1231 | 1224 | $this->slave_db = $db_info->slave_db; |
1232 | 1225 | } |
@@ -1279,8 +1272,7 @@ discard block |
||
1279 | 1272 | if($type == 'master') |
1280 | 1273 | { |
1281 | 1274 | $connection = &$this->master_db; |
1282 | - } |
|
1283 | - else |
|
1275 | + } else |
|
1284 | 1276 | { |
1285 | 1277 | $connection = &$this->slave_db[$indx]; |
1286 | 1278 | } |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | * @param int $size column size |
478 | 478 | * @param string|int $default default value |
479 | 479 | * @param boolean $notnull not null status, default value is false |
480 | - * @return void |
|
480 | + * @return resource|null |
|
481 | 481 | */ |
482 | 482 | function addColumn($table_name, $column_name, $type = 'number', $size = '', $default = null, $notnull = FALSE) |
483 | 483 | { |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | /** |
694 | 694 | * Creates a table by using xml contents |
695 | 695 | * @param string $xml_doc xml schema contents |
696 | - * @return void|object |
|
696 | + * @return null|resource |
|
697 | 697 | */ |
698 | 698 | function createTableByXml($xml_doc) |
699 | 699 | { |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | /** |
704 | 704 | * Creates a table by using xml file path |
705 | 705 | * @param string $file_name xml schema file path |
706 | - * @return void|object |
|
706 | + * @return null|resource |
|
707 | 707 | */ |
708 | 708 | function createTableByXmlFile($file_name) |
709 | 709 | { |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | * opt : notnull, default, size\n |
724 | 724 | * index : primary key, index, unique\n |
725 | 725 | * @param string $xml_doc xml schema contents |
726 | - * @return void|object |
|
726 | + * @return null|resource |
|
727 | 727 | */ |
728 | 728 | function _createTable($xml_doc) |
729 | 729 | { |
@@ -1125,7 +1125,7 @@ discard block |
||
1125 | 1125 | |
1126 | 1126 | /** |
1127 | 1127 | * If select query execute, return paging sql |
1128 | - * @param object $query |
|
1128 | + * @param BaseObject $query |
|
1129 | 1129 | * @param boolean $with_values |
1130 | 1130 | * @param int $start_count |
1131 | 1131 | * @param int $list_count |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | function DBCubrid($auto_connect = TRUE) |
53 | 53 | { |
54 | 54 | $this->_setDBInfo(); |
55 | - if($auto_connect) $this->_connect(); |
|
55 | + if ($auto_connect) $this->_connect(); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -76,21 +76,21 @@ discard block |
||
76 | 76 | $result = @cubrid_connect($connection["db_hostname"], $connection["db_port"], $connection["db_database"], $connection["db_userid"], $connection["db_password"]); |
77 | 77 | |
78 | 78 | // check connections |
79 | - if(!$result) |
|
79 | + if (!$result) |
|
80 | 80 | { |
81 | 81 | $this->setError(-1, 'database connect fail'); |
82 | 82 | return; |
83 | 83 | } |
84 | 84 | |
85 | - if(!defined('__CUBRID_VERSION__')) |
|
85 | + if (!defined('__CUBRID_VERSION__')) |
|
86 | 86 | { |
87 | 87 | $cubrid_version = cubrid_get_server_info($result); |
88 | 88 | $cubrid_version_elem = explode('.', $cubrid_version); |
89 | - $cubrid_version = $cubrid_version_elem[0] . '.' . $cubrid_version_elem[1] . '.' . $cubrid_version_elem[2]; |
|
89 | + $cubrid_version = $cubrid_version_elem[0].'.'.$cubrid_version_elem[1].'.'.$cubrid_version_elem[2]; |
|
90 | 90 | define('__CUBRID_VERSION__', $cubrid_version); |
91 | 91 | } |
92 | 92 | |
93 | - if(__CUBRID_VERSION__ >= '8.4.0') |
|
93 | + if (__CUBRID_VERSION__ >= '8.4.0') |
|
94 | 94 | cubrid_set_autocommit($result, CUBRID_AUTOCOMMIT_TRUE); |
95 | 95 | |
96 | 96 | return $result; |
@@ -116,13 +116,13 @@ discard block |
||
116 | 116 | */ |
117 | 117 | function addQuotes($string) |
118 | 118 | { |
119 | - if(version_compare(PHP_VERSION, "5.4.0", "<") && |
|
119 | + if (version_compare(PHP_VERSION, "5.4.0", "<") && |
|
120 | 120 | get_magic_quotes_gpc()) |
121 | 121 | { |
122 | 122 | $string = stripslashes(str_replace("\\", "\\\\", $string)); |
123 | 123 | } |
124 | 124 | |
125 | - if(!is_numeric($string)) |
|
125 | + if (!is_numeric($string)) |
|
126 | 126 | { |
127 | 127 | /* |
128 | 128 | if ($this->isConnected()) { |
@@ -146,17 +146,17 @@ discard block |
||
146 | 146 | */ |
147 | 147 | function _begin($transactionLevel = 0) |
148 | 148 | { |
149 | - if(__CUBRID_VERSION__ >= '8.4.0') |
|
149 | + if (__CUBRID_VERSION__ >= '8.4.0') |
|
150 | 150 | { |
151 | 151 | $connection = $this->_getConnection('master'); |
152 | 152 | |
153 | - if(!$transactionLevel) |
|
153 | + if (!$transactionLevel) |
|
154 | 154 | { |
155 | 155 | cubrid_set_autocommit($connection, CUBRID_AUTOCOMMIT_FALSE); |
156 | 156 | } |
157 | 157 | else |
158 | 158 | { |
159 | - $this->_query("SAVEPOINT SP" . $transactionLevel, $connection); |
|
159 | + $this->_query("SAVEPOINT SP".$transactionLevel, $connection); |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | return TRUE; |
@@ -173,9 +173,9 @@ discard block |
||
173 | 173 | |
174 | 174 | $point = $transactionLevel - 1; |
175 | 175 | |
176 | - if($point) |
|
176 | + if ($point) |
|
177 | 177 | { |
178 | - $this->_query("ROLLBACK TO SP" . $point, $connection); |
|
178 | + $this->_query("ROLLBACK TO SP".$point, $connection); |
|
179 | 179 | } |
180 | 180 | else |
181 | 181 | { |
@@ -206,29 +206,29 @@ discard block |
||
206 | 206 | */ |
207 | 207 | function __query($query, $connection) |
208 | 208 | { |
209 | - if($this->use_prepared_statements == 'Y') |
|
209 | + if ($this->use_prepared_statements == 'Y') |
|
210 | 210 | { |
211 | 211 | $req = @cubrid_prepare($connection, $query); |
212 | - if(!$req) |
|
212 | + if (!$req) |
|
213 | 213 | { |
214 | 214 | $this->_setError(); |
215 | 215 | return false; |
216 | 216 | } |
217 | 217 | |
218 | 218 | $position = 0; |
219 | - if($this->param) |
|
219 | + if ($this->param) |
|
220 | 220 | { |
221 | - foreach($this->param as $param) |
|
221 | + foreach ($this->param as $param) |
|
222 | 222 | { |
223 | 223 | $value = $param->getUnescapedValue(); |
224 | 224 | $type = $param->getType(); |
225 | 225 | |
226 | - if($param->isColumnName()) |
|
226 | + if ($param->isColumnName()) |
|
227 | 227 | { |
228 | 228 | continue; |
229 | 229 | } |
230 | 230 | |
231 | - switch($type) |
|
231 | + switch ($type) |
|
232 | 232 | { |
233 | 233 | case 'number' : |
234 | 234 | $bind_type = 'numeric'; |
@@ -240,12 +240,12 @@ discard block |
||
240 | 240 | $bind_type = 'string'; |
241 | 241 | } |
242 | 242 | |
243 | - if(is_array($value)) |
|
243 | + if (is_array($value)) |
|
244 | 244 | { |
245 | - foreach($value as $v) |
|
245 | + foreach ($value as $v) |
|
246 | 246 | { |
247 | 247 | $bound = @cubrid_bind($req, ++$position, $v, $bind_type); |
248 | - if(!$bound) |
|
248 | + if (!$bound) |
|
249 | 249 | { |
250 | 250 | $this->_setError(); |
251 | 251 | return false; |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | else |
256 | 256 | { |
257 | 257 | $bound = @cubrid_bind($req, ++$position, $value, $bind_type); |
258 | - if(!$bound) |
|
258 | + if (!$bound) |
|
259 | 259 | { |
260 | 260 | $this->_setError(); |
261 | 261 | return false; |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | } |
266 | 266 | |
267 | 267 | $result = @cubrid_execute($req); |
268 | - if(!$result) |
|
268 | + if (!$result) |
|
269 | 269 | { |
270 | 270 | $this->_setError(); |
271 | 271 | return false; |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | // Execute the query |
276 | 276 | $result = @cubrid_execute($connection, $query); |
277 | 277 | // error check |
278 | - if(!$result) |
|
278 | + if (!$result) |
|
279 | 279 | { |
280 | 280 | $this->_setError(); |
281 | 281 | return false; |
@@ -306,12 +306,12 @@ discard block |
||
306 | 306 | function _fetch($result, $arrayIndexEndValue = NULL) |
307 | 307 | { |
308 | 308 | $output = array(); |
309 | - if(!$this->isConnected() || $this->isError() || !$result) |
|
309 | + if (!$this->isConnected() || $this->isError() || !$result) |
|
310 | 310 | { |
311 | 311 | return array(); |
312 | 312 | } |
313 | 313 | |
314 | - if($this->use_prepared_statements == 'Y') |
|
314 | + if ($this->use_prepared_statements == 'Y') |
|
315 | 315 | { |
316 | 316 | |
317 | 317 | } |
@@ -322,25 +322,25 @@ discard block |
||
322 | 322 | $col_names = cubrid_column_names($result); |
323 | 323 | $max = count($col_types); |
324 | 324 | |
325 | - for($count = 0; $count < $max; $count++) |
|
325 | + for ($count = 0; $count < $max; $count++) |
|
326 | 326 | { |
327 | - if(preg_match("/^char/", $col_types[$count]) > 0) |
|
327 | + if (preg_match("/^char/", $col_types[$count]) > 0) |
|
328 | 328 | { |
329 | 329 | $char_type_fields[] = $col_names[$count]; |
330 | 330 | } |
331 | 331 | } |
332 | 332 | |
333 | - while($tmp = cubrid_fetch($result, CUBRID_OBJECT)) |
|
333 | + while ($tmp = cubrid_fetch($result, CUBRID_OBJECT)) |
|
334 | 334 | { |
335 | - if(is_array($char_type_fields)) |
|
335 | + if (is_array($char_type_fields)) |
|
336 | 336 | { |
337 | - foreach($char_type_fields as $val) |
|
337 | + foreach ($char_type_fields as $val) |
|
338 | 338 | { |
339 | 339 | $tmp->{$val} = rtrim($tmp->{$val}); |
340 | 340 | } |
341 | 341 | } |
342 | 342 | |
343 | - if($arrayIndexEndValue) |
|
343 | + if ($arrayIndexEndValue) |
|
344 | 344 | { |
345 | 345 | $output[$arrayIndexEndValue--] = $tmp; |
346 | 346 | } |
@@ -352,15 +352,15 @@ discard block |
||
352 | 352 | |
353 | 353 | unset($char_type_fields); |
354 | 354 | |
355 | - if($result) |
|
355 | + if ($result) |
|
356 | 356 | { |
357 | 357 | cubrid_close_request($result); |
358 | 358 | } |
359 | 359 | |
360 | - if(count($output) == 1) |
|
360 | + if (count($output) == 1) |
|
361 | 361 | { |
362 | 362 | // If call is made for pagination, always return array |
363 | - if(isset($arrayIndexEndValue)) |
|
363 | + if (isset($arrayIndexEndValue)) |
|
364 | 364 | { |
365 | 365 | return $output; |
366 | 366 | } |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | */ |
396 | 396 | function _makeSequence() |
397 | 397 | { |
398 | - if($_GLOBALS['XE_EXISTS_SEQUENCE']) |
|
398 | + if ($_GLOBALS['XE_EXISTS_SEQUENCE']) |
|
399 | 399 | return; |
400 | 400 | |
401 | 401 | // check cubrid serial |
@@ -404,21 +404,21 @@ discard block |
||
404 | 404 | $output = $this->_fetch($result); |
405 | 405 | |
406 | 406 | // if do not create serial |
407 | - if($output->count == 0) |
|
408 | - { |
|
409 | - $query = sprintf('select max("a"."srl") as "srl" from ' . |
|
410 | - '( select max("document_srl") as "srl" from ' . |
|
411 | - '"%sdocuments" UNION ' . |
|
412 | - 'select max("comment_srl") as "srl" from ' . |
|
413 | - '"%scomments" UNION ' . |
|
414 | - 'select max("member_srl") as "srl" from ' . |
|
415 | - '"%smember"' . |
|
407 | + if ($output->count == 0) |
|
408 | + { |
|
409 | + $query = sprintf('select max("a"."srl") as "srl" from '. |
|
410 | + '( select max("document_srl") as "srl" from '. |
|
411 | + '"%sdocuments" UNION '. |
|
412 | + 'select max("comment_srl") as "srl" from '. |
|
413 | + '"%scomments" UNION '. |
|
414 | + 'select max("member_srl") as "srl" from '. |
|
415 | + '"%smember"'. |
|
416 | 416 | ') as "a"', $this->prefix, $this->prefix, $this->prefix); |
417 | 417 | |
418 | 418 | $result = $this->_query($query); |
419 | 419 | $output = $this->_fetch($result); |
420 | 420 | $srl = $output->srl; |
421 | - if($srl < 1) |
|
421 | + if ($srl < 1) |
|
422 | 422 | { |
423 | 423 | $start = 1; |
424 | 424 | } |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | */ |
443 | 443 | function isTableExists($target_name) |
444 | 444 | { |
445 | - if($target_name == 'sequence') |
|
445 | + if ($target_name == 'sequence') |
|
446 | 446 | { |
447 | 447 | $query = sprintf("select \"name\" from \"db_serial\" where \"name\" = '%s%s'", $this->prefix, $target_name); |
448 | 448 | } |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | } |
453 | 453 | |
454 | 454 | $result = $this->_query($query); |
455 | - if(cubrid_num_rows($result) > 0) |
|
455 | + if (cubrid_num_rows($result) > 0) |
|
456 | 456 | { |
457 | 457 | $output = TRUE; |
458 | 458 | } |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | $output = FALSE; |
462 | 462 | } |
463 | 463 | |
464 | - if($result) |
|
464 | + if ($result) |
|
465 | 465 | { |
466 | 466 | cubrid_close_request($result); |
467 | 467 | } |
@@ -482,22 +482,22 @@ discard block |
||
482 | 482 | function addColumn($table_name, $column_name, $type = 'number', $size = '', $default = null, $notnull = FALSE) |
483 | 483 | { |
484 | 484 | $type = strtoupper($this->column_type[$type]); |
485 | - if($type == 'INTEGER') |
|
485 | + if ($type == 'INTEGER') |
|
486 | 486 | { |
487 | 487 | $size = ''; |
488 | 488 | } |
489 | 489 | |
490 | 490 | $query = sprintf("alter class \"%s%s\" add \"%s\" ", $this->prefix, $table_name, $column_name); |
491 | 491 | |
492 | - if($type == 'char' || $type == 'varchar') |
|
492 | + if ($type == 'char' || $type == 'varchar') |
|
493 | 493 | { |
494 | - if($size) |
|
494 | + if ($size) |
|
495 | 495 | { |
496 | 496 | $size = $size * 3; |
497 | 497 | } |
498 | 498 | } |
499 | 499 | |
500 | - if($size) |
|
500 | + if ($size) |
|
501 | 501 | { |
502 | 502 | $query .= sprintf("%s(%s) ", $type, $size); |
503 | 503 | } |
@@ -506,9 +506,9 @@ discard block |
||
506 | 506 | $query .= sprintf("%s ", $type); |
507 | 507 | } |
508 | 508 | |
509 | - if(isset($default)) |
|
509 | + if (isset($default)) |
|
510 | 510 | { |
511 | - if($type == 'INTEGER' || $type == 'BIGINT' || $type == 'INT') |
|
511 | + if ($type == 'INTEGER' || $type == 'BIGINT' || $type == 'INT') |
|
512 | 512 | { |
513 | 513 | $query .= sprintf("default %d ", $default); |
514 | 514 | } |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | } |
519 | 519 | } |
520 | 520 | |
521 | - if($notnull) |
|
521 | + if ($notnull) |
|
522 | 522 | { |
523 | 523 | $query .= "not null "; |
524 | 524 | } |
@@ -547,10 +547,10 @@ discard block |
||
547 | 547 | */ |
548 | 548 | function isColumnExists($table_name, $column_name) |
549 | 549 | { |
550 | - $query = sprintf("select \"attr_name\" from \"db_attribute\" where " . "\"attr_name\" ='%s' and \"class_name\" = '%s%s'", $column_name, $this->prefix, $table_name); |
|
550 | + $query = sprintf("select \"attr_name\" from \"db_attribute\" where "."\"attr_name\" ='%s' and \"class_name\" = '%s%s'", $column_name, $this->prefix, $table_name); |
|
551 | 551 | $result = $this->_query($query); |
552 | 552 | |
553 | - if(cubrid_num_rows($result) > 0) |
|
553 | + if (cubrid_num_rows($result) > 0) |
|
554 | 554 | { |
555 | 555 | $output = TRUE; |
556 | 556 | } |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | $output = FALSE; |
560 | 560 | } |
561 | 561 | |
562 | - if($result) |
|
562 | + if ($result) |
|
563 | 563 | { |
564 | 564 | cubrid_close_request($result); |
565 | 565 | } |
@@ -579,12 +579,12 @@ discard block |
||
579 | 579 | */ |
580 | 580 | function addIndex($table_name, $index_name, $target_columns, $is_unique = FALSE) |
581 | 581 | { |
582 | - if(!is_array($target_columns)) |
|
582 | + if (!is_array($target_columns)) |
|
583 | 583 | { |
584 | 584 | $target_columns = array($target_columns); |
585 | 585 | } |
586 | 586 | |
587 | - $query = sprintf("create %s index \"%s\" on \"%s%s\" (%s);", $is_unique ? 'unique' : '', $index_name, $this->prefix, $table_name, '"' . implode('","', $target_columns) . '"'); |
|
587 | + $query = sprintf("create %s index \"%s\" on \"%s%s\" (%s);", $is_unique ? 'unique' : '', $index_name, $this->prefix, $table_name, '"'.implode('","', $target_columns).'"'); |
|
588 | 588 | |
589 | 589 | $this->_query($query); |
590 | 590 | } |
@@ -611,17 +611,17 @@ discard block |
||
611 | 611 | */ |
612 | 612 | function isIndexExists($table_name, $index_name) |
613 | 613 | { |
614 | - $query = sprintf("select \"index_name\" from \"db_index\" where " . "\"class_name\" = '%s%s' and (\"index_name\" = '%s' or \"index_name\" = '%s') ", $this->prefix, $table_name, $this->prefix . $index_name, $index_name); |
|
614 | + $query = sprintf("select \"index_name\" from \"db_index\" where "."\"class_name\" = '%s%s' and (\"index_name\" = '%s' or \"index_name\" = '%s') ", $this->prefix, $table_name, $this->prefix.$index_name, $index_name); |
|
615 | 615 | $result = $this->_query($query); |
616 | 616 | |
617 | - if($this->isError()) |
|
617 | + if ($this->isError()) |
|
618 | 618 | { |
619 | 619 | return FALSE; |
620 | 620 | } |
621 | 621 | |
622 | 622 | $output = $this->_fetch($result); |
623 | 623 | |
624 | - if(!$output) |
|
624 | + if (!$output) |
|
625 | 625 | { |
626 | 626 | return FALSE; |
627 | 627 | } |
@@ -653,25 +653,25 @@ discard block |
||
653 | 653 | ", strlen($this->prefix) |
654 | 654 | , $this->prefix |
655 | 655 | , strlen($this->prefix) + 1 |
656 | - , "'" . $this->prefix . '%' . "'" |
|
656 | + , "'".$this->prefix.'%'."'" |
|
657 | 657 | , strlen($this->prefix) |
658 | 658 | , $this->prefix |
659 | 659 | , strlen($this->prefix) + 1 |
660 | 660 | ); |
661 | 661 | $result = $this->_query($query); |
662 | 662 | |
663 | - if($this->isError()) |
|
663 | + if ($this->isError()) |
|
664 | 664 | { |
665 | 665 | return FALSE; |
666 | 666 | } |
667 | 667 | |
668 | 668 | $output = $this->_fetch($result); |
669 | - if(!$output) |
|
669 | + if (!$output) |
|
670 | 670 | { |
671 | 671 | return FALSE; |
672 | 672 | } |
673 | 673 | |
674 | - if(!is_array($output)) |
|
674 | + if (!is_array($output)) |
|
675 | 675 | { |
676 | 676 | $indexes_to_be_deleted = array($output); |
677 | 677 | } |
@@ -680,10 +680,10 @@ discard block |
||
680 | 680 | $indexes_to_be_deleted = $output; |
681 | 681 | } |
682 | 682 | |
683 | - foreach($indexes_to_be_deleted as $index) |
|
683 | + foreach ($indexes_to_be_deleted as $index) |
|
684 | 684 | { |
685 | 685 | $this->dropIndex(substr($index->class_name, strlen($this->prefix)) |
686 | - , $this->prefix . $index->unprefixed_index_name |
|
686 | + , $this->prefix.$index->unprefixed_index_name |
|
687 | 687 | , $index->is_unique == 'YES' ? TRUE : FALSE); |
688 | 688 | } |
689 | 689 | |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | */ |
708 | 708 | function createTableByXmlFile($file_name) |
709 | 709 | { |
710 | - if(!file_exists($file_name)) |
|
710 | + if (!file_exists($file_name)) |
|
711 | 711 | { |
712 | 712 | return; |
713 | 713 | } |
@@ -734,28 +734,28 @@ discard block |
||
734 | 734 | $table_name = $xml_obj->table->attrs->name; |
735 | 735 | |
736 | 736 | // if the table already exists exit function |
737 | - if($this->isTableExists($table_name)) |
|
737 | + if ($this->isTableExists($table_name)) |
|
738 | 738 | { |
739 | 739 | return; |
740 | 740 | } |
741 | 741 | |
742 | 742 | // If the table name is sequence, it creates a serial |
743 | - if($table_name == 'sequence') |
|
743 | + if ($table_name == 'sequence') |
|
744 | 744 | { |
745 | - $query = sprintf('create serial "%s" start with 1 increment by 1' . |
|
746 | - ' minvalue 1 ' . |
|
747 | - 'maxvalue 10000000000000000000000000000000000000' . ' nocycle;', $this->prefix . $table_name); |
|
745 | + $query = sprintf('create serial "%s" start with 1 increment by 1'. |
|
746 | + ' minvalue 1 '. |
|
747 | + 'maxvalue 10000000000000000000000000000000000000'.' nocycle;', $this->prefix.$table_name); |
|
748 | 748 | |
749 | 749 | return $this->_query($query); |
750 | 750 | } |
751 | 751 | |
752 | 752 | |
753 | - $table_name = $this->prefix . $table_name; |
|
753 | + $table_name = $this->prefix.$table_name; |
|
754 | 754 | |
755 | 755 | $query = sprintf('create class "%s";', $table_name); |
756 | 756 | $this->_query($query); |
757 | 757 | |
758 | - if(!is_array($xml_obj->table->column)) |
|
758 | + if (!is_array($xml_obj->table->column)) |
|
759 | 759 | { |
760 | 760 | $columns[] = $xml_obj->table->column; |
761 | 761 | } |
@@ -770,7 +770,7 @@ discard block |
||
770 | 770 | $unique_list = array(); |
771 | 771 | $index_list = array(); |
772 | 772 | |
773 | - foreach($columns as $column) |
|
773 | + foreach ($columns as $column) |
|
774 | 774 | { |
775 | 775 | $name = $column->attrs->name; |
776 | 776 | $type = $column->attrs->type; |
@@ -781,7 +781,7 @@ discard block |
||
781 | 781 | $unique = $column->attrs->unique; |
782 | 782 | $default = $column->attrs->default; |
783 | 783 | |
784 | - switch($this->column_type[$type]) |
|
784 | + switch ($this->column_type[$type]) |
|
785 | 785 | { |
786 | 786 | case 'integer' : |
787 | 787 | $size = NULL; |
@@ -791,58 +791,58 @@ discard block |
||
791 | 791 | break; |
792 | 792 | } |
793 | 793 | |
794 | - if(isset($default) && ($type == 'varchar' || $type == 'char' || |
|
794 | + if (isset($default) && ($type == 'varchar' || $type == 'char' || |
|
795 | 795 | $type == 'text' || $type == 'tinytext' || $type == 'bigtext')) |
796 | 796 | { |
797 | 797 | $default = sprintf("'%s'", $default); |
798 | 798 | } |
799 | 799 | |
800 | - if($type == 'varchar' || $type == 'char') |
|
800 | + if ($type == 'varchar' || $type == 'char') |
|
801 | 801 | { |
802 | - if($size) |
|
802 | + if ($size) |
|
803 | 803 | $size = $size * 3; |
804 | 804 | } |
805 | 805 | |
806 | 806 | |
807 | - $column_schema[] = sprintf('"%s" %s%s %s %s', $name, $this->column_type[$type], $size ? '(' . $size . ')' : '', isset($default) ? "default " . $default : '', $notnull ? 'not null' : ''); |
|
807 | + $column_schema[] = sprintf('"%s" %s%s %s %s', $name, $this->column_type[$type], $size ? '('.$size.')' : '', isset($default) ? "default ".$default : '', $notnull ? 'not null' : ''); |
|
808 | 808 | |
809 | - if($primary_key) |
|
809 | + if ($primary_key) |
|
810 | 810 | { |
811 | 811 | $primary_list[] = $name; |
812 | 812 | } |
813 | - else if($unique) |
|
813 | + else if ($unique) |
|
814 | 814 | { |
815 | 815 | $unique_list[$unique][] = $name; |
816 | 816 | } |
817 | - else if($index) |
|
817 | + else if ($index) |
|
818 | 818 | { |
819 | 819 | $index_list[$index][] = $name; |
820 | 820 | } |
821 | 821 | } |
822 | 822 | |
823 | - $query .= implode(',', $column_schema) . ';'; |
|
823 | + $query .= implode(',', $column_schema).';'; |
|
824 | 824 | $this->_query($query); |
825 | 825 | |
826 | - if(count($primary_list)) |
|
826 | + if (count($primary_list)) |
|
827 | 827 | { |
828 | - $query = sprintf("alter class \"%s\" add attribute constraint " . "\"pkey_%s\" PRIMARY KEY(%s);", $table_name, $table_name, '"' . implode('","', $primary_list) . '"'); |
|
828 | + $query = sprintf("alter class \"%s\" add attribute constraint "."\"pkey_%s\" PRIMARY KEY(%s);", $table_name, $table_name, '"'.implode('","', $primary_list).'"'); |
|
829 | 829 | $this->_query($query); |
830 | 830 | } |
831 | 831 | |
832 | - if(count($unique_list)) |
|
832 | + if (count($unique_list)) |
|
833 | 833 | { |
834 | - foreach($unique_list as $key => $val) |
|
834 | + foreach ($unique_list as $key => $val) |
|
835 | 835 | { |
836 | - $query = sprintf("create unique index \"%s\" on \"%s\" " . "(%s);", $key, $table_name, '"' . implode('","', $val) . '"'); |
|
836 | + $query = sprintf("create unique index \"%s\" on \"%s\" "."(%s);", $key, $table_name, '"'.implode('","', $val).'"'); |
|
837 | 837 | $this->_query($query); |
838 | 838 | } |
839 | 839 | } |
840 | 840 | |
841 | - if(count($index_list)) |
|
841 | + if (count($index_list)) |
|
842 | 842 | { |
843 | - foreach($index_list as $key => $val) |
|
843 | + foreach ($index_list as $key => $val) |
|
844 | 844 | { |
845 | - $query = sprintf("create index \"%s\" on \"%s\" (%s);", $key, $table_name, '"' . implode('","', $val) . '"'); |
|
845 | + $query = sprintf("create index \"%s\" on \"%s\" (%s);", $key, $table_name, '"'.implode('","', $val).'"'); |
|
846 | 846 | $this->_query($query); |
847 | 847 | } |
848 | 848 | } |
@@ -856,22 +856,22 @@ discard block |
||
856 | 856 | */ |
857 | 857 | function _executeInsertAct($queryObject, $with_values = TRUE) |
858 | 858 | { |
859 | - if($this->use_prepared_statements == 'Y') |
|
859 | + if ($this->use_prepared_statements == 'Y') |
|
860 | 860 | { |
861 | 861 | $this->param = $queryObject->getArguments(); |
862 | 862 | $with_values = FALSE; |
863 | 863 | } |
864 | 864 | $query = $this->getInsertSql($queryObject, $with_values); |
865 | - if(is_a($query, 'BaseObject')) |
|
865 | + if (is_a($query, 'BaseObject')) |
|
866 | 866 | { |
867 | 867 | unset($this->param); |
868 | 868 | return; |
869 | 869 | } |
870 | 870 | |
871 | - $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; |
|
871 | + $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' '.$this->comment_syntax, $this->query_id) : ''; |
|
872 | 872 | |
873 | 873 | $result = $this->_query($query); |
874 | - if($result && !$this->transaction_started) |
|
874 | + if ($result && !$this->transaction_started) |
|
875 | 875 | { |
876 | 876 | $this->_commit(); |
877 | 877 | } |
@@ -887,23 +887,23 @@ discard block |
||
887 | 887 | */ |
888 | 888 | function _executeUpdateAct($queryObject, $with_values = TRUE) |
889 | 889 | { |
890 | - if($this->use_prepared_statements == 'Y') |
|
890 | + if ($this->use_prepared_statements == 'Y') |
|
891 | 891 | { |
892 | 892 | $this->param = $queryObject->getArguments(); |
893 | 893 | $with_values = FALSE; |
894 | 894 | } |
895 | 895 | $query = $this->getUpdateSql($queryObject, $with_values); |
896 | - if(is_a($query, 'BaseObject')) |
|
896 | + if (is_a($query, 'BaseObject')) |
|
897 | 897 | { |
898 | 898 | unset($this->param); |
899 | 899 | return; |
900 | 900 | } |
901 | 901 | |
902 | - $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; |
|
902 | + $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' '.$this->comment_syntax, $this->query_id) : ''; |
|
903 | 903 | |
904 | 904 | $result = $this->_query($query); |
905 | 905 | |
906 | - if($result && !$this->transaction_started) |
|
906 | + if ($result && !$this->transaction_started) |
|
907 | 907 | { |
908 | 908 | $this->_commit(); |
909 | 909 | } |
@@ -919,23 +919,23 @@ discard block |
||
919 | 919 | */ |
920 | 920 | function _executeDeleteAct($queryObject, $with_values = TRUE) |
921 | 921 | { |
922 | - if($this->use_prepared_statements == 'Y') |
|
922 | + if ($this->use_prepared_statements == 'Y') |
|
923 | 923 | { |
924 | 924 | $this->param = $queryObject->getArguments(); |
925 | 925 | $with_values = FALSE; |
926 | 926 | } |
927 | 927 | $query = $this->getDeleteSql($queryObject, $with_values); |
928 | - if(is_a($query, 'BaseObject')) |
|
928 | + if (is_a($query, 'BaseObject')) |
|
929 | 929 | { |
930 | 930 | unset($this->param); |
931 | 931 | return; |
932 | 932 | } |
933 | 933 | |
934 | - $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; |
|
934 | + $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' '.$this->comment_syntax, $this->query_id) : ''; |
|
935 | 935 | |
936 | 936 | $result = $this->_query($query); |
937 | 937 | |
938 | - if($result && !$this->transaction_started) |
|
938 | + if ($result && !$this->transaction_started) |
|
939 | 939 | { |
940 | 940 | $this->_commit(); |
941 | 941 | } |
@@ -955,29 +955,29 @@ discard block |
||
955 | 955 | */ |
956 | 956 | function _executeSelectAct($queryObject, $connection = NULL, $with_values = TRUE) |
957 | 957 | { |
958 | - if($this->use_prepared_statements == 'Y') |
|
958 | + if ($this->use_prepared_statements == 'Y') |
|
959 | 959 | { |
960 | 960 | $this->param = $queryObject->getArguments(); |
961 | 961 | $with_values = FALSE; |
962 | 962 | } |
963 | 963 | $limit = $queryObject->getLimit(); |
964 | - if($limit && $limit->isPageHandler()) |
|
964 | + if ($limit && $limit->isPageHandler()) |
|
965 | 965 | { |
966 | 966 | return $this->queryPageLimit($queryObject, $connection, $with_values); |
967 | 967 | } |
968 | 968 | else |
969 | 969 | { |
970 | 970 | $query = $this->getSelectSql($queryObject, $with_values); |
971 | - if(is_a($query, 'BaseObject')) |
|
971 | + if (is_a($query, 'BaseObject')) |
|
972 | 972 | { |
973 | 973 | unset($this->param); |
974 | 974 | return; |
975 | 975 | } |
976 | 976 | |
977 | - $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; |
|
977 | + $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' '.$this->comment_syntax, $this->query_id) : ''; |
|
978 | 978 | $result = $this->_query($query, $connection); |
979 | 979 | |
980 | - if($this->isError()) |
|
980 | + if ($this->isError()) |
|
981 | 981 | { |
982 | 982 | unset($this->param); |
983 | 983 | return $this->queryError($queryObject); |
@@ -1000,16 +1000,16 @@ discard block |
||
1000 | 1000 | function queryError($queryObject) |
1001 | 1001 | { |
1002 | 1002 | $limit = $queryObject->getLimit(); |
1003 | - if($limit && $limit->isPageHandler()) |
|
1003 | + if ($limit && $limit->isPageHandler()) |
|
1004 | 1004 | { |
1005 | - $buff = new BaseObject (); |
|
1005 | + $buff = new BaseObject(); |
|
1006 | 1006 | $buff->total_count = 0; |
1007 | 1007 | $buff->total_page = 0; |
1008 | 1008 | $buff->page = 1; |
1009 | 1009 | $buff->data = array(); |
1010 | 1010 | $buff->page_navigation = new PageHandler(/* $total_count */0, /* $total_page */1, /* $page */1, /* $page_count */10); //default page handler values |
1011 | 1011 | return $buff; |
1012 | - }else |
|
1012 | + } else |
|
1013 | 1013 | return; |
1014 | 1014 | } |
1015 | 1015 | |
@@ -1025,48 +1025,48 @@ discard block |
||
1025 | 1025 | $limit = $queryObject->getLimit(); |
1026 | 1026 | // Total count |
1027 | 1027 | $temp_where = $queryObject->getWhereString($with_values, FALSE); |
1028 | - $count_query = sprintf('select count(*) as "count" %s %s', 'FROM ' . $queryObject->getFromString($with_values), ($temp_where === '' ? '' : ' WHERE ' . $temp_where)); |
|
1028 | + $count_query = sprintf('select count(*) as "count" %s %s', 'FROM '.$queryObject->getFromString($with_values), ($temp_where === '' ? '' : ' WHERE '.$temp_where)); |
|
1029 | 1029 | |
1030 | 1030 | // Check for distinct query and if found update count query structure |
1031 | 1031 | $temp_select = $queryObject->getSelectString($with_values); |
1032 | 1032 | $uses_distinct = stripos($temp_select, "distinct") !== FALSE; |
1033 | 1033 | $uses_groupby = $queryObject->getGroupByString() != ''; |
1034 | - if($uses_distinct || $uses_groupby) |
|
1034 | + if ($uses_distinct || $uses_groupby) |
|
1035 | 1035 | { |
1036 | 1036 | $count_query = sprintf('select %s %s %s %s' |
1037 | 1037 | , $temp_select |
1038 | - , 'FROM ' . $queryObject->getFromString($with_values) |
|
1039 | - , ($temp_where === '' ? '' : ' WHERE ' . $temp_where) |
|
1040 | - , ($uses_groupby ? ' GROUP BY ' . $queryObject->getGroupByString() : '') |
|
1038 | + , 'FROM '.$queryObject->getFromString($with_values) |
|
1039 | + , ($temp_where === '' ? '' : ' WHERE '.$temp_where) |
|
1040 | + , ($uses_groupby ? ' GROUP BY '.$queryObject->getGroupByString() : '') |
|
1041 | 1041 | ); |
1042 | 1042 | |
1043 | 1043 | // If query uses grouping or distinct, count from original select |
1044 | 1044 | $count_query = sprintf('select count(*) as "count" from (%s) xet', $count_query); |
1045 | 1045 | } |
1046 | 1046 | |
1047 | - $count_query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(' ' . $this->comment_syntax, $queryObject->queryID) : ''; |
|
1047 | + $count_query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(' '.$this->comment_syntax, $queryObject->queryID) : ''; |
|
1048 | 1048 | $result = $this->_query($count_query, $connection); |
1049 | 1049 | $count_output = $this->_fetch($result); |
1050 | 1050 | $total_count = (int) (isset($count_output->count) ? $count_output->count : NULL); |
1051 | 1051 | |
1052 | 1052 | $list_count = $limit->list_count->getValue(); |
1053 | - if(!$list_count) |
|
1053 | + if (!$list_count) |
|
1054 | 1054 | { |
1055 | 1055 | $list_count = 20; |
1056 | 1056 | } |
1057 | 1057 | $page_count = $limit->page_count->getValue(); |
1058 | - if(!$page_count) |
|
1058 | + if (!$page_count) |
|
1059 | 1059 | { |
1060 | 1060 | $page_count = 10; |
1061 | 1061 | } |
1062 | 1062 | $page = $limit->page->getValue(); |
1063 | - if(!$page || $page < 1) |
|
1063 | + if (!$page || $page < 1) |
|
1064 | 1064 | { |
1065 | 1065 | $page = 1; |
1066 | 1066 | } |
1067 | 1067 | |
1068 | 1068 | // total pages |
1069 | - if($total_count) |
|
1069 | + if ($total_count) |
|
1070 | 1070 | { |
1071 | 1071 | $total_page = (int) (($total_count - 1) / $list_count) + 1; |
1072 | 1072 | } |
@@ -1076,7 +1076,7 @@ discard block |
||
1076 | 1076 | } |
1077 | 1077 | |
1078 | 1078 | // check the page variables |
1079 | - if($page > $total_page) |
|
1079 | + if ($page > $total_page) |
|
1080 | 1080 | { |
1081 | 1081 | // If requested page is bigger than total number of pages, return empty list |
1082 | 1082 | |
@@ -1092,9 +1092,9 @@ discard block |
||
1092 | 1092 | $start_count = ($page - 1) * $list_count; |
1093 | 1093 | |
1094 | 1094 | $query = $this->getSelectPageSql($queryObject, $with_values, $start_count, $list_count); |
1095 | - $query .= (__DEBUG_QUERY__ & 1 && $queryObject->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; |
|
1095 | + $query .= (__DEBUG_QUERY__ & 1 && $queryObject->query_id) ? sprintf(' '.$this->comment_syntax, $this->query_id) : ''; |
|
1096 | 1096 | $result = $this->_query($query, $connection); |
1097 | - if($this->isError()) |
|
1097 | + if ($this->isError()) |
|
1098 | 1098 | { |
1099 | 1099 | unset($this->param); |
1100 | 1100 | return $this->queryError($queryObject); |
@@ -1135,44 +1135,44 @@ discard block |
||
1135 | 1135 | { |
1136 | 1136 | |
1137 | 1137 | $select = $query->getSelectString($with_values); |
1138 | - if($select == '') |
|
1138 | + if ($select == '') |
|
1139 | 1139 | { |
1140 | 1140 | return new BaseObject(-1, "Invalid query"); |
1141 | 1141 | } |
1142 | - $select = 'SELECT ' . $select; |
|
1142 | + $select = 'SELECT '.$select; |
|
1143 | 1143 | |
1144 | 1144 | $from = $query->getFromString($with_values); |
1145 | - if($from == '') |
|
1145 | + if ($from == '') |
|
1146 | 1146 | { |
1147 | 1147 | return new BaseObject(-1, "Invalid query"); |
1148 | 1148 | } |
1149 | - $from = ' FROM ' . $from; |
|
1149 | + $from = ' FROM '.$from; |
|
1150 | 1150 | |
1151 | 1151 | $where = $query->getWhereString($with_values); |
1152 | - if($where != '') |
|
1152 | + if ($where != '') |
|
1153 | 1153 | { |
1154 | - $where = ' WHERE ' . $where; |
|
1154 | + $where = ' WHERE '.$where; |
|
1155 | 1155 | } |
1156 | 1156 | |
1157 | 1157 | $groupBy = $query->getGroupByString(); |
1158 | - if($groupBy != '') |
|
1158 | + if ($groupBy != '') |
|
1159 | 1159 | { |
1160 | - $groupBy = ' GROUP BY ' . $groupBy; |
|
1160 | + $groupBy = ' GROUP BY '.$groupBy; |
|
1161 | 1161 | } |
1162 | 1162 | |
1163 | 1163 | $orderBy = $query->getOrderByString(); |
1164 | - if($orderBy != '') |
|
1164 | + if ($orderBy != '') |
|
1165 | 1165 | { |
1166 | - $orderBy = ' ORDER BY ' . $orderBy; |
|
1166 | + $orderBy = ' ORDER BY '.$orderBy; |
|
1167 | 1167 | } |
1168 | 1168 | |
1169 | 1169 | $limit = $query->getLimitString(); |
1170 | - if($limit != '') |
|
1170 | + if ($limit != '') |
|
1171 | 1171 | { |
1172 | 1172 | $limit = sprintf(' LIMIT %d, %d', $start_count, $list_count); |
1173 | 1173 | } |
1174 | 1174 | |
1175 | - return $select . ' ' . $from . ' ' . $where . ' ' . $groupBy . ' ' . $orderBy . ' ' . $limit; |
|
1175 | + return $select.' '.$from.' '.$where.' '.$groupBy.' '.$orderBy.' '.$limit; |
|
1176 | 1176 | } |
1177 | 1177 | |
1178 | 1178 | } |
@@ -52,7 +52,9 @@ discard block |
||
52 | 52 | function DBCubrid($auto_connect = TRUE) |
53 | 53 | { |
54 | 54 | $this->_setDBInfo(); |
55 | - if($auto_connect) $this->_connect(); |
|
55 | + if($auto_connect) { |
|
56 | + $this->_connect(); |
|
57 | + } |
|
56 | 58 | } |
57 | 59 | |
58 | 60 | /** |
@@ -90,8 +92,9 @@ discard block |
||
90 | 92 | define('__CUBRID_VERSION__', $cubrid_version); |
91 | 93 | } |
92 | 94 | |
93 | - if(__CUBRID_VERSION__ >= '8.4.0') |
|
94 | - cubrid_set_autocommit($result, CUBRID_AUTOCOMMIT_TRUE); |
|
95 | + if(__CUBRID_VERSION__ >= '8.4.0') { |
|
96 | + cubrid_set_autocommit($result, CUBRID_AUTOCOMMIT_TRUE); |
|
97 | + } |
|
95 | 98 | |
96 | 99 | return $result; |
97 | 100 | } |
@@ -153,8 +156,7 @@ discard block |
||
153 | 156 | if(!$transactionLevel) |
154 | 157 | { |
155 | 158 | cubrid_set_autocommit($connection, CUBRID_AUTOCOMMIT_FALSE); |
156 | - } |
|
157 | - else |
|
159 | + } else |
|
158 | 160 | { |
159 | 161 | $this->_query("SAVEPOINT SP" . $transactionLevel, $connection); |
160 | 162 | } |
@@ -176,8 +178,7 @@ discard block |
||
176 | 178 | if($point) |
177 | 179 | { |
178 | 180 | $this->_query("ROLLBACK TO SP" . $point, $connection); |
179 | - } |
|
180 | - else |
|
181 | + } else |
|
181 | 182 | { |
182 | 183 | @cubrid_rollback($connection); |
183 | 184 | } |
@@ -251,8 +252,7 @@ discard block |
||
251 | 252 | return false; |
252 | 253 | } |
253 | 254 | } |
254 | - } |
|
255 | - else |
|
255 | + } else |
|
256 | 256 | { |
257 | 257 | $bound = @cubrid_bind($req, ++$position, $value, $bind_type); |
258 | 258 | if(!$bound) |
@@ -343,8 +343,7 @@ discard block |
||
343 | 343 | if($arrayIndexEndValue) |
344 | 344 | { |
345 | 345 | $output[$arrayIndexEndValue--] = $tmp; |
346 | - } |
|
347 | - else |
|
346 | + } else |
|
348 | 347 | { |
349 | 348 | $output[] = $tmp; |
350 | 349 | } |
@@ -395,8 +394,9 @@ discard block |
||
395 | 394 | */ |
396 | 395 | function _makeSequence() |
397 | 396 | { |
398 | - if($_GLOBALS['XE_EXISTS_SEQUENCE']) |
|
399 | - return; |
|
397 | + if($_GLOBALS['XE_EXISTS_SEQUENCE']) { |
|
398 | + return; |
|
399 | + } |
|
400 | 400 | |
401 | 401 | // check cubrid serial |
402 | 402 | $query = sprintf('select count(*) as "count" from "db_serial" where name=\'%ssequence\'', $this->prefix); |
@@ -421,8 +421,7 @@ discard block |
||
421 | 421 | if($srl < 1) |
422 | 422 | { |
423 | 423 | $start = 1; |
424 | - } |
|
425 | - else |
|
424 | + } else |
|
426 | 425 | { |
427 | 426 | $start = $srl + 1000000; |
428 | 427 | } |
@@ -445,8 +444,7 @@ discard block |
||
445 | 444 | if($target_name == 'sequence') |
446 | 445 | { |
447 | 446 | $query = sprintf("select \"name\" from \"db_serial\" where \"name\" = '%s%s'", $this->prefix, $target_name); |
448 | - } |
|
449 | - else |
|
447 | + } else |
|
450 | 448 | { |
451 | 449 | $query = sprintf("select \"class_name\" from \"db_class\" where \"class_name\" = '%s%s'", $this->prefix, $target_name); |
452 | 450 | } |
@@ -455,8 +453,7 @@ discard block |
||
455 | 453 | if(cubrid_num_rows($result) > 0) |
456 | 454 | { |
457 | 455 | $output = TRUE; |
458 | - } |
|
459 | - else |
|
456 | + } else |
|
460 | 457 | { |
461 | 458 | $output = FALSE; |
462 | 459 | } |
@@ -500,8 +497,7 @@ discard block |
||
500 | 497 | if($size) |
501 | 498 | { |
502 | 499 | $query .= sprintf("%s(%s) ", $type, $size); |
503 | - } |
|
504 | - else |
|
500 | + } else |
|
505 | 501 | { |
506 | 502 | $query .= sprintf("%s ", $type); |
507 | 503 | } |
@@ -511,8 +507,7 @@ discard block |
||
511 | 507 | if($type == 'INTEGER' || $type == 'BIGINT' || $type == 'INT') |
512 | 508 | { |
513 | 509 | $query .= sprintf("default %d ", $default); |
514 | - } |
|
515 | - else |
|
510 | + } else |
|
516 | 511 | { |
517 | 512 | $query .= sprintf("default '%s' ", $default); |
518 | 513 | } |
@@ -553,8 +548,7 @@ discard block |
||
553 | 548 | if(cubrid_num_rows($result) > 0) |
554 | 549 | { |
555 | 550 | $output = TRUE; |
556 | - } |
|
557 | - else |
|
551 | + } else |
|
558 | 552 | { |
559 | 553 | $output = FALSE; |
560 | 554 | } |
@@ -674,8 +668,7 @@ discard block |
||
674 | 668 | if(!is_array($output)) |
675 | 669 | { |
676 | 670 | $indexes_to_be_deleted = array($output); |
677 | - } |
|
678 | - else |
|
671 | + } else |
|
679 | 672 | { |
680 | 673 | $indexes_to_be_deleted = $output; |
681 | 674 | } |
@@ -758,8 +751,7 @@ discard block |
||
758 | 751 | if(!is_array($xml_obj->table->column)) |
759 | 752 | { |
760 | 753 | $columns[] = $xml_obj->table->column; |
761 | - } |
|
762 | - else |
|
754 | + } else |
|
763 | 755 | { |
764 | 756 | $columns = $xml_obj->table->column; |
765 | 757 | } |
@@ -799,8 +791,9 @@ discard block |
||
799 | 791 | |
800 | 792 | if($type == 'varchar' || $type == 'char') |
801 | 793 | { |
802 | - if($size) |
|
803 | - $size = $size * 3; |
|
794 | + if($size) { |
|
795 | + $size = $size * 3; |
|
796 | + } |
|
804 | 797 | } |
805 | 798 | |
806 | 799 | |
@@ -809,12 +802,10 @@ discard block |
||
809 | 802 | if($primary_key) |
810 | 803 | { |
811 | 804 | $primary_list[] = $name; |
812 | - } |
|
813 | - else if($unique) |
|
805 | + } else if($unique) |
|
814 | 806 | { |
815 | 807 | $unique_list[$unique][] = $name; |
816 | - } |
|
817 | - else if($index) |
|
808 | + } else if($index) |
|
818 | 809 | { |
819 | 810 | $index_list[$index][] = $name; |
820 | 811 | } |
@@ -964,8 +955,7 @@ discard block |
||
964 | 955 | if($limit && $limit->isPageHandler()) |
965 | 956 | { |
966 | 957 | return $this->queryPageLimit($queryObject, $connection, $with_values); |
967 | - } |
|
968 | - else |
|
958 | + } else |
|
969 | 959 | { |
970 | 960 | $query = $this->getSelectSql($queryObject, $with_values); |
971 | 961 | if(is_a($query, 'BaseObject')) |
@@ -1009,8 +999,9 @@ discard block |
||
1009 | 999 | $buff->data = array(); |
1010 | 1000 | $buff->page_navigation = new PageHandler(/* $total_count */0, /* $total_page */1, /* $page */1, /* $page_count */10); //default page handler values |
1011 | 1001 | return $buff; |
1012 | - }else |
|
1013 | - return; |
|
1002 | + } else { |
|
1003 | + return; |
|
1004 | + } |
|
1014 | 1005 | } |
1015 | 1006 | |
1016 | 1007 | /** |
@@ -1069,8 +1060,7 @@ discard block |
||
1069 | 1060 | if($total_count) |
1070 | 1061 | { |
1071 | 1062 | $total_page = (int) (($total_count - 1) / $list_count) + 1; |
1072 | - } |
|
1073 | - else |
|
1063 | + } else |
|
1074 | 1064 | { |
1075 | 1065 | $total_page = 1; |
1076 | 1066 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | /** |
112 | 112 | * DB transaction start |
113 | 113 | * this method is private |
114 | - * @return boolean |
|
114 | + * @return null|boolean |
|
115 | 115 | */ |
116 | 116 | function _begin($transactionLevel = 0) |
117 | 117 | { |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * this method is private |
171 | 171 | * @param string $query |
172 | 172 | * @param resource $connection |
173 | - * @return resource|boolean Returns a statement resource on success and FALSE if an error occurred. |
|
173 | + * @return resource Returns a statement resource on success and FALSE if an error occurred. |
|
174 | 174 | */ |
175 | 175 | function __query($query, $connection) |
176 | 176 | { |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | * @param int $size column size |
376 | 376 | * @param string|int $default default value |
377 | 377 | * @param boolean $notnull not null status, default value is false |
378 | - * @return void |
|
378 | + * @return null|resource |
|
379 | 379 | */ |
380 | 380 | function addColumn($table_name, $column_name, $type = 'number', $size = '', $default = null, $notnull = false) |
381 | 381 | { |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | * Check column exist status of the table |
432 | 432 | * @param string $table_name table name |
433 | 433 | * @param string $column_name column name |
434 | - * @return boolean |
|
434 | + * @return null|boolean |
|
435 | 435 | */ |
436 | 436 | function isColumnExists($table_name, $column_name) |
437 | 437 | { |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | * Check index status of the table |
496 | 496 | * @param string $table_name table name |
497 | 497 | * @param string $index_name index name |
498 | - * @return boolean |
|
498 | + * @return null|boolean |
|
499 | 499 | */ |
500 | 500 | function isIndexExists($table_name, $index_name) |
501 | 501 | { |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | |
675 | 675 | /** |
676 | 676 | * Return update query string |
677 | - * @param object $query |
|
677 | + * @param BaseObject $query |
|
678 | 678 | * @param boolean $with_values |
679 | 679 | * @param boolean $with_priority |
680 | 680 | * @return string |
@@ -726,8 +726,9 @@ discard block |
||
726 | 726 | |
727 | 727 | /** |
728 | 728 | * Return select query string |
729 | - * @param object $query |
|
729 | + * @param BaseObject $query |
|
730 | 730 | * @param boolean $with_values |
731 | + * @param resource $connection |
|
731 | 732 | * @return string |
732 | 733 | */ |
733 | 734 | function getSelectSql($query, $with_values = TRUE, $connection=NULL) |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | function DBMssql($auto_connect = TRUE) |
46 | 46 | { |
47 | 47 | $this->_setDBInfo(); |
48 | - if($auto_connect) $this->_connect(); |
|
48 | + if ($auto_connect) $this->_connect(); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -70,10 +70,10 @@ discard block |
||
70 | 70 | //sqlsrv_configure( 'LogSubsystems', SQLSRV_LOG_SYSTEM_ALL ); |
71 | 71 | $result = @sqlsrv_connect($connection["db_hostname"], array('Database' => $connection["db_database"], 'UID' => $connection["db_userid"], 'PWD' => $connection["db_password"])); |
72 | 72 | |
73 | - if(!$result) |
|
73 | + if (!$result) |
|
74 | 74 | { |
75 | 75 | $errors = print_r(sqlsrv_errors(), true); |
76 | - $this->setError(-1, 'database connect fail' . PHP_EOL . $errors); |
|
76 | + $this->setError(-1, 'database connect fail'.PHP_EOL.$errors); |
|
77 | 77 | return; |
78 | 78 | } |
79 | 79 | return $result; |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | */ |
100 | 100 | function addQuotes($string) |
101 | 101 | { |
102 | - if(version_compare(PHP_VERSION, "5.4.0", "<") && get_magic_quotes_gpc()) |
|
102 | + if (version_compare(PHP_VERSION, "5.4.0", "<") && get_magic_quotes_gpc()) |
|
103 | 103 | { |
104 | 104 | $string = stripslashes(str_replace("\\", "\\\\", $string)); |
105 | 105 | } |
@@ -117,16 +117,16 @@ discard block |
||
117 | 117 | { |
118 | 118 | $connection = $this->_getConnection('master'); |
119 | 119 | |
120 | - if(!$transactionLevel) |
|
120 | + if (!$transactionLevel) |
|
121 | 121 | { |
122 | - if(sqlsrv_begin_transaction($connection) === false) |
|
122 | + if (sqlsrv_begin_transaction($connection) === false) |
|
123 | 123 | { |
124 | 124 | return; |
125 | 125 | } |
126 | 126 | } |
127 | 127 | else |
128 | 128 | { |
129 | - $this->_query("SAVE TRANS SP" . $transactionLevel, $connection); |
|
129 | + $this->_query("SAVE TRANS SP".$transactionLevel, $connection); |
|
130 | 130 | } |
131 | 131 | return true; |
132 | 132 | } |
@@ -142,9 +142,9 @@ discard block |
||
142 | 142 | |
143 | 143 | $point = $transactionLevel - 1; |
144 | 144 | |
145 | - if($point) |
|
145 | + if ($point) |
|
146 | 146 | { |
147 | - $this->_query("ROLLBACK TRANS SP" . $point, $connection); |
|
147 | + $this->_query("ROLLBACK TRANS SP".$point, $connection); |
|
148 | 148 | } |
149 | 149 | else |
150 | 150 | { |
@@ -176,18 +176,18 @@ discard block |
||
176 | 176 | { |
177 | 177 | $_param = array(); |
178 | 178 | |
179 | - if(count($this->param)) |
|
179 | + if (count($this->param)) |
|
180 | 180 | { |
181 | - foreach($this->param as $k => $o) |
|
181 | + foreach ($this->param as $k => $o) |
|
182 | 182 | { |
183 | - if($o->isColumnName()) |
|
183 | + if ($o->isColumnName()) |
|
184 | 184 | { |
185 | 185 | continue; |
186 | 186 | } |
187 | - if($o->getType() == 'number') |
|
187 | + if ($o->getType() == 'number') |
|
188 | 188 | { |
189 | 189 | $value = $o->getUnescapedValue(); |
190 | - if(is_array($value)) |
|
190 | + if (is_array($value)) |
|
191 | 191 | { |
192 | 192 | $_param = array_merge($_param, $value); |
193 | 193 | } |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | else |
200 | 200 | { |
201 | 201 | $value = $o->getUnescapedValue(); |
202 | - if(is_array($value)) |
|
202 | + if (is_array($value)) |
|
203 | 203 | { |
204 | - foreach($value as $v) |
|
204 | + foreach ($value as $v) |
|
205 | 205 | { |
206 | 206 | $_param[] = array($v, SQLSRV_PARAM_IN, SQLSRV_PHPTYPE_STRING('utf-8')); |
207 | 207 | } |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | |
217 | 217 | // Run the query statement |
218 | 218 | $result = false; |
219 | - if(count($_param)) |
|
219 | + if (count($_param)) |
|
220 | 220 | { |
221 | 221 | $args = $this->_getParametersByReference($_param); |
222 | 222 | $stmt = sqlsrv_prepare($connection, $query, $args); |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | $stmt = sqlsrv_prepare($connection, $query); |
227 | 227 | } |
228 | 228 | |
229 | - if(!$stmt) |
|
229 | + if (!$stmt) |
|
230 | 230 | { |
231 | 231 | $result = false; |
232 | 232 | } |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | } |
237 | 237 | |
238 | 238 | // Error Check |
239 | - if(!$result) |
|
239 | + if (!$result) |
|
240 | 240 | { |
241 | 241 | $this->setError(print_r(sqlsrv_errors(), true)); |
242 | 242 | } |
@@ -259,9 +259,9 @@ discard block |
||
259 | 259 | $copy = array(); |
260 | 260 | $args = array(); |
261 | 261 | $i = 0; |
262 | - foreach($_param as $key => $value) |
|
262 | + foreach ($_param as $key => $value) |
|
263 | 263 | { |
264 | - if(is_array($value)) |
|
264 | + if (is_array($value)) |
|
265 | 265 | { |
266 | 266 | $value_copy = $value; |
267 | 267 | $value_arg = array(); |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | function _fetch($result, $arrayIndexEndValue = NULL) |
289 | 289 | { |
290 | 290 | $output = array(); |
291 | - if(!$this->isConnected() || $this->isError() || !$result) |
|
291 | + if (!$this->isConnected() || $this->isError() || !$result) |
|
292 | 292 | { |
293 | 293 | return $output; |
294 | 294 | } |
@@ -296,18 +296,18 @@ discard block |
||
296 | 296 | $c = sqlsrv_num_fields($result); |
297 | 297 | $m = null; |
298 | 298 | |
299 | - while(sqlsrv_fetch($result)) |
|
299 | + while (sqlsrv_fetch($result)) |
|
300 | 300 | { |
301 | - if(!$m) |
|
301 | + if (!$m) |
|
302 | 302 | { |
303 | 303 | $m = sqlsrv_field_metadata($result); |
304 | 304 | } |
305 | 305 | unset($row); |
306 | - for($i = 0; $i < $c; $i++) |
|
306 | + for ($i = 0; $i < $c; $i++) |
|
307 | 307 | { |
308 | 308 | $row->{$m[$i]['Name']} = sqlsrv_get_field($result, $i, SQLSRV_PHPTYPE_STRING('utf-8')); |
309 | 309 | } |
310 | - if($arrayIndexEndValue) |
|
310 | + if ($arrayIndexEndValue) |
|
311 | 311 | { |
312 | 312 | $output[$arrayIndexEndValue--] = $row; |
313 | 313 | } |
@@ -317,9 +317,9 @@ discard block |
||
317 | 317 | } |
318 | 318 | } |
319 | 319 | |
320 | - if(count($output) == 1) |
|
320 | + if (count($output) == 1) |
|
321 | 321 | { |
322 | - if(isset($arrayIndexEndValue)) |
|
322 | + if (isset($arrayIndexEndValue)) |
|
323 | 323 | { |
324 | 324 | return $output; |
325 | 325 | } |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | $result = $this->_query($query); |
361 | 361 | $tmp = $this->_fetch($result); |
362 | 362 | |
363 | - if(!$tmp) |
|
363 | + if (!$tmp) |
|
364 | 364 | { |
365 | 365 | return false; |
366 | 366 | } |
@@ -379,18 +379,18 @@ discard block |
||
379 | 379 | */ |
380 | 380 | function addColumn($table_name, $column_name, $type = 'number', $size = '', $default = null, $notnull = false) |
381 | 381 | { |
382 | - if($this->isColumnExists($table_name, $column_name)) |
|
382 | + if ($this->isColumnExists($table_name, $column_name)) |
|
383 | 383 | { |
384 | 384 | return; |
385 | 385 | } |
386 | 386 | $type = $this->column_type[$type]; |
387 | - if(strtoupper($type) == 'INTEGER') |
|
387 | + if (strtoupper($type) == 'INTEGER') |
|
388 | 388 | { |
389 | 389 | $size = ''; |
390 | 390 | } |
391 | 391 | |
392 | 392 | $query = sprintf("alter table %s%s add \"%s\" ", $this->prefix, $table_name, $column_name); |
393 | - if($size) |
|
393 | + if ($size) |
|
394 | 394 | { |
395 | 395 | $query .= sprintf(" %s(%s) ", $type, $size); |
396 | 396 | } |
@@ -399,11 +399,11 @@ discard block |
||
399 | 399 | $query .= sprintf(" %s ", $type); |
400 | 400 | } |
401 | 401 | |
402 | - if(isset($default)) |
|
402 | + if (isset($default)) |
|
403 | 403 | { |
404 | 404 | $query .= sprintf(" default '%s' ", $default); |
405 | 405 | } |
406 | - if($notnull) |
|
406 | + if ($notnull) |
|
407 | 407 | { |
408 | 408 | $query .= " not null "; |
409 | 409 | } |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | */ |
420 | 420 | function dropColumn($table_name, $column_name) |
421 | 421 | { |
422 | - if(!$this->isColumnExists($table_name, $column_name)) |
|
422 | + if (!$this->isColumnExists($table_name, $column_name)) |
|
423 | 423 | { |
424 | 424 | return; |
425 | 425 | } |
@@ -437,12 +437,12 @@ discard block |
||
437 | 437 | { |
438 | 438 | $query = sprintf("select syscolumns.name as name from syscolumns, sysobjects where sysobjects.name = '%s%s' and sysobjects.id = syscolumns.id and syscolumns.name = '%s'", $this->prefix, $table_name, $column_name); |
439 | 439 | $result = $this->_query($query); |
440 | - if($this->isError()) |
|
440 | + if ($this->isError()) |
|
441 | 441 | { |
442 | 442 | return; |
443 | 443 | } |
444 | 444 | $tmp = $this->_fetch($result); |
445 | - if(!$tmp->name) |
|
445 | + if (!$tmp->name) |
|
446 | 446 | { |
447 | 447 | return false; |
448 | 448 | } |
@@ -461,11 +461,11 @@ discard block |
||
461 | 461 | */ |
462 | 462 | function addIndex($table_name, $index_name, $target_columns, $is_unique = false) |
463 | 463 | { |
464 | - if($this->isIndexExists($table_name, $index_name)) |
|
464 | + if ($this->isIndexExists($table_name, $index_name)) |
|
465 | 465 | { |
466 | 466 | return; |
467 | 467 | } |
468 | - if(!is_array($target_columns)) |
|
468 | + if (!is_array($target_columns)) |
|
469 | 469 | { |
470 | 470 | $target_columns = array($target_columns); |
471 | 471 | } |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | */ |
484 | 484 | function dropIndex($table_name, $index_name, $is_unique = false) |
485 | 485 | { |
486 | - if(!$this->isIndexExists($table_name, $index_name)) |
|
486 | + if (!$this->isIndexExists($table_name, $index_name)) |
|
487 | 487 | { |
488 | 488 | return; |
489 | 489 | } |
@@ -502,13 +502,13 @@ discard block |
||
502 | 502 | $query = sprintf("select sysindexes.name as name from sysindexes, sysobjects where sysobjects.name = '%s%s' and sysobjects.id = sysindexes.id and sysindexes.name = '%s'", $this->prefix, $table_name, $index_name); |
503 | 503 | |
504 | 504 | $result = $this->_query($query); |
505 | - if($this->isError()) |
|
505 | + if ($this->isError()) |
|
506 | 506 | { |
507 | 507 | return; |
508 | 508 | } |
509 | 509 | $tmp = $this->_fetch($result); |
510 | 510 | |
511 | - if(!$tmp->name) |
|
511 | + if (!$tmp->name) |
|
512 | 512 | { |
513 | 513 | return false; |
514 | 514 | } |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | */ |
533 | 533 | function createTableByXmlFile($file_name) |
534 | 534 | { |
535 | - if(!file_exists($file_name)) |
|
535 | + if (!file_exists($file_name)) |
|
536 | 536 | { |
537 | 537 | return; |
538 | 538 | } |
@@ -557,22 +557,22 @@ discard block |
||
557 | 557 | $xml_obj = $oXml->parse($xml_doc); |
558 | 558 | // Create a table schema |
559 | 559 | $table_name = $xml_obj->table->attrs->name; |
560 | - if($this->isTableExists($table_name)) |
|
560 | + if ($this->isTableExists($table_name)) |
|
561 | 561 | { |
562 | 562 | return; |
563 | 563 | } |
564 | 564 | |
565 | - if($table_name == 'sequence') |
|
565 | + if ($table_name == 'sequence') |
|
566 | 566 | { |
567 | - $table_name = $this->prefix . $table_name; |
|
567 | + $table_name = $this->prefix.$table_name; |
|
568 | 568 | $query = sprintf('create table %s ( sequence int identity(1,1), seq int )', $table_name); |
569 | 569 | return $this->_query($query); |
570 | 570 | } |
571 | 571 | else |
572 | 572 | { |
573 | - $table_name = $this->prefix . $table_name; |
|
573 | + $table_name = $this->prefix.$table_name; |
|
574 | 574 | |
575 | - if(!is_array($xml_obj->table->column)) |
|
575 | + if (!is_array($xml_obj->table->column)) |
|
576 | 576 | { |
577 | 577 | $columns[] = $xml_obj->table->column; |
578 | 578 | } |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | $index_list = array(); |
587 | 587 | |
588 | 588 | $typeList = array('number' => 1, 'text' => 1); |
589 | - foreach($columns as $column) |
|
589 | + foreach ($columns as $column) |
|
590 | 590 | { |
591 | 591 | $name = $column->attrs->name; |
592 | 592 | $type = $column->attrs->type; |
@@ -598,48 +598,48 @@ discard block |
||
598 | 598 | $default = $column->attrs->default; |
599 | 599 | $auto_increment = $column->attrs->auto_increment; |
600 | 600 | |
601 | - $column_schema[] = sprintf('[%s] %s%s %s %s %s', $name, $this->column_type[$type], !isset($typeList[$type]) && $size ? '(' . $size . ')' : '', isset($default) ? "default '" . $default . "'" : '', $notnull ? 'not null' : 'null', $auto_increment ? 'identity(1,1)' : ''); |
|
601 | + $column_schema[] = sprintf('[%s] %s%s %s %s %s', $name, $this->column_type[$type], !isset($typeList[$type]) && $size ? '('.$size.')' : '', isset($default) ? "default '".$default."'" : '', $notnull ? 'not null' : 'null', $auto_increment ? 'identity(1,1)' : ''); |
|
602 | 602 | |
603 | - if($primary_key) |
|
603 | + if ($primary_key) |
|
604 | 604 | { |
605 | 605 | $primary_list[] = $name; |
606 | 606 | } |
607 | - else if($unique) |
|
607 | + else if ($unique) |
|
608 | 608 | { |
609 | 609 | $unique_list[$unique][] = $name; |
610 | 610 | } |
611 | - else if($index) |
|
611 | + else if ($index) |
|
612 | 612 | { |
613 | 613 | $index_list[$index][] = $name; |
614 | 614 | } |
615 | 615 | } |
616 | 616 | |
617 | - if(count($primary_list)) |
|
617 | + if (count($primary_list)) |
|
618 | 618 | { |
619 | - $column_schema[] = sprintf("primary key (%s)", '"' . implode($primary_list, '","') . '"'); |
|
619 | + $column_schema[] = sprintf("primary key (%s)", '"'.implode($primary_list, '","').'"'); |
|
620 | 620 | } |
621 | 621 | |
622 | 622 | $schema = sprintf('create table [%s] (%s%s)', $this->addQuotes($table_name), "\n", implode($column_schema, ",\n")); |
623 | 623 | $output = $this->_query($schema); |
624 | - if(!$output) |
|
624 | + if (!$output) |
|
625 | 625 | { |
626 | 626 | return false; |
627 | 627 | } |
628 | 628 | |
629 | - if(count($unique_list)) |
|
629 | + if (count($unique_list)) |
|
630 | 630 | { |
631 | - foreach($unique_list as $key => $val) |
|
631 | + foreach ($unique_list as $key => $val) |
|
632 | 632 | { |
633 | - $query = sprintf("create unique index %s on %s (%s);", $key, $table_name, '[' . implode('],[', $val) . ']'); |
|
633 | + $query = sprintf("create unique index %s on %s (%s);", $key, $table_name, '['.implode('],[', $val).']'); |
|
634 | 634 | $this->_query($query); |
635 | 635 | } |
636 | 636 | } |
637 | 637 | |
638 | - if(count($index_list)) |
|
638 | + if (count($index_list)) |
|
639 | 639 | { |
640 | - foreach($index_list as $key => $val) |
|
640 | + foreach ($index_list as $key => $val) |
|
641 | 641 | { |
642 | - $query = sprintf("create index %s on %s (%s);", $key, $table_name, '[' . implode('],[', $val) . ']'); |
|
642 | + $query = sprintf("create index %s on %s (%s);", $key, $table_name, '['.implode('],[', $val).']'); |
|
643 | 643 | $this->_query($query); |
644 | 644 | } |
645 | 645 | } |
@@ -682,34 +682,34 @@ discard block |
||
682 | 682 | function getUpdateSql($query, $with_values = true, $with_priority = false) |
683 | 683 | { |
684 | 684 | $columnsList = $query->getUpdateString($with_values); |
685 | - if($columnsList == '') |
|
685 | + if ($columnsList == '') |
|
686 | 686 | { |
687 | 687 | return new BaseObject(-1, "Invalid query"); |
688 | 688 | } |
689 | 689 | |
690 | 690 | $from = $query->getFromString($with_values); |
691 | - if($from == '') |
|
691 | + if ($from == '') |
|
692 | 692 | { |
693 | 693 | return new BaseObject(-1, "Invalid query"); |
694 | 694 | } |
695 | 695 | |
696 | 696 | $tables = $query->getTables(); |
697 | 697 | $alias_list = ''; |
698 | - foreach($tables as $table) |
|
698 | + foreach ($tables as $table) |
|
699 | 699 | { |
700 | 700 | $alias_list .= $table->getAlias(); |
701 | 701 | } |
702 | 702 | implode(',', explode(' ', $alias_list)); |
703 | 703 | |
704 | 704 | $where = $query->getWhereString($with_values); |
705 | - if($where != '') |
|
705 | + if ($where != '') |
|
706 | 706 | { |
707 | - $where = ' WHERE ' . $where; |
|
707 | + $where = ' WHERE '.$where; |
|
708 | 708 | } |
709 | 709 | |
710 | 710 | $priority = $with_priority ? $query->getPriority() : ''; |
711 | 711 | |
712 | - return "UPDATE $priority $alias_list SET $columnsList FROM " . $from . $where; |
|
712 | + return "UPDATE $priority $alias_list SET $columnsList FROM ".$from.$where; |
|
713 | 713 | } |
714 | 714 | |
715 | 715 | /** |
@@ -730,7 +730,7 @@ discard block |
||
730 | 730 | * @param boolean $with_values |
731 | 731 | * @return string |
732 | 732 | */ |
733 | - function getSelectSql($query, $with_values = TRUE, $connection=NULL) |
|
733 | + function getSelectSql($query, $with_values = TRUE, $connection = NULL) |
|
734 | 734 | { |
735 | 735 | $with_values = false; |
736 | 736 | |
@@ -740,75 +740,75 @@ discard block |
||
740 | 740 | $limit = ''; |
741 | 741 | $limitCount = ''; |
742 | 742 | $limitQueryPart = $query->getLimit(); |
743 | - if($limitQueryPart) |
|
743 | + if ($limitQueryPart) |
|
744 | 744 | { |
745 | 745 | $limitCount = $limitQueryPart->getLimit(); |
746 | 746 | } |
747 | - if($limitCount != '') |
|
747 | + if ($limitCount != '') |
|
748 | 748 | { |
749 | - $limit = 'SELECT TOP ' . $limitCount; |
|
749 | + $limit = 'SELECT TOP '.$limitCount; |
|
750 | 750 | } |
751 | 751 | |
752 | 752 | $select = $query->getSelectString($with_values); |
753 | - if($select == '') |
|
753 | + if ($select == '') |
|
754 | 754 | { |
755 | 755 | return new BaseObject(-1, "Invalid query"); |
756 | 756 | } |
757 | - if($limit != '') |
|
757 | + if ($limit != '') |
|
758 | 758 | { |
759 | - $select = $limit . ' ' . $select; |
|
759 | + $select = $limit.' '.$select; |
|
760 | 760 | } |
761 | 761 | else |
762 | 762 | { |
763 | - $select = 'SELECT ' . $select; |
|
763 | + $select = 'SELECT '.$select; |
|
764 | 764 | } |
765 | 765 | |
766 | 766 | $from = $query->getFromString($with_values); |
767 | - if($from == '') |
|
767 | + if ($from == '') |
|
768 | 768 | { |
769 | 769 | return new BaseObject(-1, "Invalid query"); |
770 | 770 | } |
771 | - $from = ' FROM ' . $from; |
|
771 | + $from = ' FROM '.$from; |
|
772 | 772 | |
773 | 773 | $where = $query->getWhereString($with_values); |
774 | - if($where != '') |
|
774 | + if ($where != '') |
|
775 | 775 | { |
776 | - $where = ' WHERE ' . $where; |
|
776 | + $where = ' WHERE '.$where; |
|
777 | 777 | } |
778 | 778 | |
779 | 779 | $groupBy = $query->getGroupByString(); |
780 | - if($groupBy != '') |
|
780 | + if ($groupBy != '') |
|
781 | 781 | { |
782 | - $groupBy = ' GROUP BY ' . $groupBy; |
|
782 | + $groupBy = ' GROUP BY '.$groupBy; |
|
783 | 783 | } |
784 | 784 | |
785 | 785 | $orderBy = $query->getOrderByString(); |
786 | - if($orderBy != '') |
|
786 | + if ($orderBy != '') |
|
787 | 787 | { |
788 | - $orderBy = ' ORDER BY ' . $orderBy; |
|
788 | + $orderBy = ' ORDER BY '.$orderBy; |
|
789 | 789 | } |
790 | 790 | |
791 | - if($limitCount != '' && $query->limit->start > 0) |
|
791 | + if ($limitCount != '' && $query->limit->start > 0) |
|
792 | 792 | { |
793 | 793 | $order = $query->getOrder(); |
794 | 794 | $first_columns = array(); |
795 | - foreach($order as $val) |
|
795 | + foreach ($order as $val) |
|
796 | 796 | { |
797 | 797 | $tmpColumnName = $val->getPureColumnName(); |
798 | - $first_columns[] = sprintf('%s(%s) as %s', $val->getPureSortOrder()=='asc'?'max':'min', $tmpColumnName, $tmpColumnName); |
|
798 | + $first_columns[] = sprintf('%s(%s) as %s', $val->getPureSortOrder() == 'asc' ? 'max' : 'min', $tmpColumnName, $tmpColumnName); |
|
799 | 799 | $first_sub_columns[] = $tmpColumnName; |
800 | 800 | } |
801 | 801 | |
802 | - $first_query = sprintf("select %s from (select top %d %s %s %s %s %s) xet", implode(',',$first_columns), $query->limit->start, implode(',',$first_sub_columns), $from, $where, $groupBy, $orderBy); |
|
802 | + $first_query = sprintf("select %s from (select top %d %s %s %s %s %s) xet", implode(',', $first_columns), $query->limit->start, implode(',', $first_sub_columns), $from, $where, $groupBy, $orderBy); |
|
803 | 803 | $this->param = $query->getArguments(); |
804 | 804 | $result = $this->__query($first_query, $connection); |
805 | 805 | $tmp = $this->_fetch($result); |
806 | 806 | |
807 | 807 | $sub_cond = array(); |
808 | - foreach($order as $k => $v) |
|
808 | + foreach ($order as $k => $v) |
|
809 | 809 | { |
810 | 810 | //for example... use Document |
811 | - if(get_class($v->sort_order) == 'SortArgument') |
|
811 | + if (get_class($v->sort_order) == 'SortArgument') |
|
812 | 812 | { |
813 | 813 | $sort_order = $v->sort_order->value; |
814 | 814 | } |
@@ -818,19 +818,19 @@ discard block |
||
818 | 818 | $sort_order = $v->sort_order; |
819 | 819 | } |
820 | 820 | |
821 | - $sub_cond[] = sprintf("%s %s '%s'", $v->getPureColumnName(), $sort_order=='asc'?'>':'<', $tmp->{$v->getPureColumnName()}); |
|
821 | + $sub_cond[] = sprintf("%s %s '%s'", $v->getPureColumnName(), $sort_order == 'asc' ? '>' : '<', $tmp->{$v->getPureColumnName()}); |
|
822 | 822 | } |
823 | 823 | |
824 | - if(!$where) |
|
824 | + if (!$where) |
|
825 | 825 | { |
826 | - $sub_condition = ' WHERE ( '.implode(' and ',$sub_cond).' )'; |
|
826 | + $sub_condition = ' WHERE ( '.implode(' and ', $sub_cond).' )'; |
|
827 | 827 | } |
828 | 828 | else |
829 | 829 | { |
830 | - $sub_condition = ' and ( '.implode(' and ',$sub_cond).' )'; |
|
830 | + $sub_condition = ' and ( '.implode(' and ', $sub_cond).' )'; |
|
831 | 831 | } |
832 | 832 | } |
833 | - return $select . ' ' . $from . ' ' . $where .$sub_condition. ' ' . $groupBy . ' ' . $orderBy; |
|
833 | + return $select.' '.$from.' '.$where.$sub_condition.' '.$groupBy.' '.$orderBy; |
|
834 | 834 | } |
835 | 835 | |
836 | 836 | /** |
@@ -845,7 +845,7 @@ discard block |
||
845 | 845 | { |
846 | 846 | $query = $this->getSelectSql($queryObject, true, $connection); |
847 | 847 | |
848 | - if(strpos($query, "substr")) |
|
848 | + if (strpos($query, "substr")) |
|
849 | 849 | { |
850 | 850 | $query = str_replace("substr", "substring", $query); |
851 | 851 | } |
@@ -853,10 +853,10 @@ discard block |
||
853 | 853 | // TODO Decide if we continue to pass parameters like this |
854 | 854 | $this->param = $queryObject->getArguments(); |
855 | 855 | |
856 | - $query .= (__DEBUG_QUERY__ & 1 && $output->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; |
|
856 | + $query .= (__DEBUG_QUERY__ & 1 && $output->query_id) ? sprintf(' '.$this->comment_syntax, $this->query_id) : ''; |
|
857 | 857 | $result = $this->_query($query, $connection); |
858 | 858 | |
859 | - if($this->isError()) |
|
859 | + if ($this->isError()) |
|
860 | 860 | { |
861 | 861 | return $this->queryError($queryObject); |
862 | 862 | } |
@@ -884,7 +884,7 @@ discard block |
||
884 | 884 | function queryError($queryObject) |
885 | 885 | { |
886 | 886 | $limit = $queryObject->getLimit(); |
887 | - if($limit && $limit->isPageHandler()) |
|
887 | + if ($limit && $limit->isPageHandler()) |
|
888 | 888 | { |
889 | 889 | $buff = new BaseObject(); |
890 | 890 | $buff->total_count = 0; |
@@ -910,52 +910,52 @@ discard block |
||
910 | 910 | function queryPageLimit($queryObject, $result, $connection) |
911 | 911 | { |
912 | 912 | $limit = $queryObject->getLimit(); |
913 | - if($limit && $limit->isPageHandler()) |
|
913 | + if ($limit && $limit->isPageHandler()) |
|
914 | 914 | { |
915 | 915 | // Total count |
916 | 916 | $temp_where = $queryObject->getWhereString(true, false); |
917 | - $count_query = sprintf('select count(*) as "count" %s %s', 'FROM ' . $queryObject->getFromString(), ($temp_where === '' ? '' : ' WHERE ' . $temp_where)); |
|
917 | + $count_query = sprintf('select count(*) as "count" %s %s', 'FROM '.$queryObject->getFromString(), ($temp_where === '' ? '' : ' WHERE '.$temp_where)); |
|
918 | 918 | |
919 | 919 | // Check for distinct query and if found update count query structure |
920 | 920 | $temp_select = $queryObject->getSelectString(true); |
921 | 921 | $uses_distinct = stripos($temp_select, "distinct") !== false; |
922 | 922 | $uses_groupby = $queryObject->getGroupByString() != ''; |
923 | - if($uses_distinct || $uses_groupby) |
|
923 | + if ($uses_distinct || $uses_groupby) |
|
924 | 924 | { |
925 | 925 | $count_query = sprintf('select %s %s %s %s' |
926 | 926 | , $temp_select |
927 | - , 'FROM ' . $queryObject->getFromString(true) |
|
928 | - , ($temp_where === '' ? '' : ' WHERE ' . $temp_where) |
|
929 | - , ($uses_groupby ? ' GROUP BY ' . $queryObject->getGroupByString() : '') |
|
927 | + , 'FROM '.$queryObject->getFromString(true) |
|
928 | + , ($temp_where === '' ? '' : ' WHERE '.$temp_where) |
|
929 | + , ($uses_groupby ? ' GROUP BY '.$queryObject->getGroupByString() : '') |
|
930 | 930 | ); |
931 | 931 | |
932 | 932 | // If query uses grouping or distinct, count from original select |
933 | 933 | $count_query = sprintf('select count(*) as "count" from (%s) xet', $count_query); |
934 | 934 | } |
935 | 935 | |
936 | - $count_query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; |
|
936 | + $count_query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(' '.$this->comment_syntax, $this->query_id) : ''; |
|
937 | 937 | $this->param = $queryObject->getArguments(); |
938 | 938 | $result_count = $this->_query($count_query, $connection); |
939 | 939 | $count_output = $this->_fetch($result_count); |
940 | 940 | $total_count = (int) $count_output->count; |
941 | 941 | |
942 | 942 | $list_count = $limit->list_count->getValue(); |
943 | - if(!$list_count) |
|
943 | + if (!$list_count) |
|
944 | 944 | { |
945 | 945 | $list_count = 20; |
946 | 946 | } |
947 | 947 | $page_count = $limit->page_count->getValue(); |
948 | - if(!$page_count) |
|
948 | + if (!$page_count) |
|
949 | 949 | { |
950 | 950 | $page_count = 10; |
951 | 951 | } |
952 | 952 | $page = $limit->page->getValue(); |
953 | - if(!$page || $page < 1) |
|
953 | + if (!$page || $page < 1) |
|
954 | 954 | { |
955 | 955 | $page = 1; |
956 | 956 | } |
957 | 957 | // Total pages |
958 | - if($total_count) |
|
958 | + if ($total_count) |
|
959 | 959 | { |
960 | 960 | $total_page = (int) (($total_count - 1) / $list_count) + 1; |
961 | 961 | } |
@@ -965,7 +965,7 @@ discard block |
||
965 | 965 | } |
966 | 966 | |
967 | 967 | // check the page variables |
968 | - if($page > $total_page) |
|
968 | + if ($page > $total_page) |
|
969 | 969 | { |
970 | 970 | // If requested page is bigger than total number of pages, return empty list |
971 | 971 | |
@@ -977,7 +977,7 @@ discard block |
||
977 | 977 | $buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count); |
978 | 978 | return $buff; |
979 | 979 | |
980 | - if($queryObject->usesClickCount()) |
|
980 | + if ($queryObject->usesClickCount()) |
|
981 | 981 | { |
982 | 982 | $update_query = $this->getClickCountQuery($queryObject); |
983 | 983 | $this->_executeUpdateAct($update_query); |
@@ -45,7 +45,9 @@ discard block |
||
45 | 45 | function DBMssql($auto_connect = TRUE) |
46 | 46 | { |
47 | 47 | $this->_setDBInfo(); |
48 | - if($auto_connect) $this->_connect(); |
|
48 | + if($auto_connect) { |
|
49 | + $this->_connect(); |
|
50 | + } |
|
49 | 51 | } |
50 | 52 | |
51 | 53 | /** |
@@ -123,8 +125,7 @@ discard block |
||
123 | 125 | { |
124 | 126 | return; |
125 | 127 | } |
126 | - } |
|
127 | - else |
|
128 | + } else |
|
128 | 129 | { |
129 | 130 | $this->_query("SAVE TRANS SP" . $transactionLevel, $connection); |
130 | 131 | } |
@@ -145,8 +146,7 @@ discard block |
||
145 | 146 | if($point) |
146 | 147 | { |
147 | 148 | $this->_query("ROLLBACK TRANS SP" . $point, $connection); |
148 | - } |
|
149 | - else |
|
149 | + } else |
|
150 | 150 | { |
151 | 151 | sqlsrv_rollback($connection); |
152 | 152 | } |
@@ -190,13 +190,11 @@ discard block |
||
190 | 190 | if(is_array($value)) |
191 | 191 | { |
192 | 192 | $_param = array_merge($_param, $value); |
193 | - } |
|
194 | - else |
|
193 | + } else |
|
195 | 194 | { |
196 | 195 | $_param[] = $o->getUnescapedValue(); |
197 | 196 | } |
198 | - } |
|
199 | - else |
|
197 | + } else |
|
200 | 198 | { |
201 | 199 | $value = $o->getUnescapedValue(); |
202 | 200 | if(is_array($value)) |
@@ -205,8 +203,7 @@ discard block |
||
205 | 203 | { |
206 | 204 | $_param[] = array($v, SQLSRV_PARAM_IN, SQLSRV_PHPTYPE_STRING('utf-8')); |
207 | 205 | } |
208 | - } |
|
209 | - else |
|
206 | + } else |
|
210 | 207 | { |
211 | 208 | $_param[] = array($value, SQLSRV_PARAM_IN, SQLSRV_PHPTYPE_STRING('utf-8')); |
212 | 209 | } |
@@ -220,8 +217,7 @@ discard block |
||
220 | 217 | { |
221 | 218 | $args = $this->_getParametersByReference($_param); |
222 | 219 | $stmt = sqlsrv_prepare($connection, $query, $args); |
223 | - } |
|
224 | - else |
|
220 | + } else |
|
225 | 221 | { |
226 | 222 | $stmt = sqlsrv_prepare($connection, $query); |
227 | 223 | } |
@@ -229,8 +225,7 @@ discard block |
||
229 | 225 | if(!$stmt) |
230 | 226 | { |
231 | 227 | $result = false; |
232 | - } |
|
233 | - else |
|
228 | + } else |
|
234 | 229 | { |
235 | 230 | $result = sqlsrv_execute($stmt); |
236 | 231 | } |
@@ -268,8 +263,7 @@ discard block |
||
268 | 263 | $value_arg[] = &$value_copy[0]; |
269 | 264 | $value_arg[] = $value_copy[1]; |
270 | 265 | $value_arg[] = $value_copy[2]; |
271 | - } |
|
272 | - else |
|
266 | + } else |
|
273 | 267 | { |
274 | 268 | $value_arg = $value; |
275 | 269 | } |
@@ -310,8 +304,7 @@ discard block |
||
310 | 304 | if($arrayIndexEndValue) |
311 | 305 | { |
312 | 306 | $output[$arrayIndexEndValue--] = $row; |
313 | - } |
|
314 | - else |
|
307 | + } else |
|
315 | 308 | { |
316 | 309 | $output[] = $row; |
317 | 310 | } |
@@ -322,8 +315,7 @@ discard block |
||
322 | 315 | if(isset($arrayIndexEndValue)) |
323 | 316 | { |
324 | 317 | return $output; |
325 | - } |
|
326 | - else |
|
318 | + } else |
|
327 | 319 | { |
328 | 320 | return $output[0]; |
329 | 321 | } |
@@ -393,8 +385,7 @@ discard block |
||
393 | 385 | if($size) |
394 | 386 | { |
395 | 387 | $query .= sprintf(" %s(%s) ", $type, $size); |
396 | - } |
|
397 | - else |
|
388 | + } else |
|
398 | 389 | { |
399 | 390 | $query .= sprintf(" %s ", $type); |
400 | 391 | } |
@@ -567,16 +558,14 @@ discard block |
||
567 | 558 | $table_name = $this->prefix . $table_name; |
568 | 559 | $query = sprintf('create table %s ( sequence int identity(1,1), seq int )', $table_name); |
569 | 560 | return $this->_query($query); |
570 | - } |
|
571 | - else |
|
561 | + } else |
|
572 | 562 | { |
573 | 563 | $table_name = $this->prefix . $table_name; |
574 | 564 | |
575 | 565 | if(!is_array($xml_obj->table->column)) |
576 | 566 | { |
577 | 567 | $columns[] = $xml_obj->table->column; |
578 | - } |
|
579 | - else |
|
568 | + } else |
|
580 | 569 | { |
581 | 570 | $columns = $xml_obj->table->column; |
582 | 571 | } |
@@ -603,12 +592,10 @@ discard block |
||
603 | 592 | if($primary_key) |
604 | 593 | { |
605 | 594 | $primary_list[] = $name; |
606 | - } |
|
607 | - else if($unique) |
|
595 | + } else if($unique) |
|
608 | 596 | { |
609 | 597 | $unique_list[$unique][] = $name; |
610 | - } |
|
611 | - else if($index) |
|
598 | + } else if($index) |
|
612 | 599 | { |
613 | 600 | $index_list[$index][] = $name; |
614 | 601 | } |
@@ -757,8 +744,7 @@ discard block |
||
757 | 744 | if($limit != '') |
758 | 745 | { |
759 | 746 | $select = $limit . ' ' . $select; |
760 | - } |
|
761 | - else |
|
747 | + } else |
|
762 | 748 | { |
763 | 749 | $select = 'SELECT ' . $select; |
764 | 750 | } |
@@ -824,8 +810,7 @@ discard block |
||
824 | 810 | if(!$where) |
825 | 811 | { |
826 | 812 | $sub_condition = ' WHERE ( '.implode(' and ',$sub_cond).' )'; |
827 | - } |
|
828 | - else |
|
813 | + } else |
|
829 | 814 | { |
830 | 815 | $sub_condition = ' and ( '.implode(' and ',$sub_cond).' )'; |
831 | 816 | } |
@@ -859,8 +844,7 @@ discard block |
||
859 | 844 | if($this->isError()) |
860 | 845 | { |
861 | 846 | return $this->queryError($queryObject); |
862 | - } |
|
863 | - else |
|
847 | + } else |
|
864 | 848 | { |
865 | 849 | return $this->queryPageLimit($queryObject, $result, $connection); |
866 | 850 | } |
@@ -893,8 +877,7 @@ discard block |
||
893 | 877 | $buff->data = array(); |
894 | 878 | $buff->page_navigation = new PageHandler(/* $total_count */0, /* $total_page */1, /* $page */1, /* $page_count */10); //default page handler values |
895 | 879 | return $buff; |
896 | - } |
|
897 | - else |
|
880 | + } else |
|
898 | 881 | { |
899 | 882 | return; |
900 | 883 | } |
@@ -958,8 +941,7 @@ discard block |
||
958 | 941 | if($total_count) |
959 | 942 | { |
960 | 943 | $total_page = (int) (($total_count - 1) / $list_count) + 1; |
961 | - } |
|
962 | - else |
|
944 | + } else |
|
963 | 945 | { |
964 | 946 | $total_page = 1; |
965 | 947 | } |
@@ -995,8 +977,7 @@ discard block |
||
995 | 977 | $buff->page = $page; |
996 | 978 | $buff->data = $data; |
997 | 979 | $buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count); |
998 | - } |
|
999 | - else |
|
980 | + } else |
|
1000 | 981 | { |
1001 | 982 | $data = $this->_fetch($result); |
1002 | 983 | $buff = new BaseObject(); |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | * @param int $size column size |
298 | 298 | * @param string|int $default default value |
299 | 299 | * @param boolean $notnull not null status, default value is false |
300 | - * @return void |
|
300 | + * @return resource|null |
|
301 | 301 | */ |
302 | 302 | function addColumn($table_name, $column_name, $type = 'number', $size = '', $default = null, $notnull = false) |
303 | 303 | { |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | * Check column exist status of the table |
345 | 345 | * @param string $table_name table name |
346 | 346 | * @param string $column_name column name |
347 | - * @return boolean |
|
347 | + * @return null|boolean |
|
348 | 348 | */ |
349 | 349 | function isColumnExists($table_name, $column_name) |
350 | 350 | { |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | * Check index status of the table |
409 | 409 | * @param string $table_name table name |
410 | 410 | * @param string $index_name index name |
411 | - * @return boolean |
|
411 | + * @return null|boolean |
|
412 | 412 | */ |
413 | 413 | function isIndexExists($table_name, $index_name) |
414 | 414 | { |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | /** |
443 | 443 | * Creates a table by using xml contents |
444 | 444 | * @param string $xml_doc xml schema contents |
445 | - * @return void|object |
|
445 | + * @return null|false |
|
446 | 446 | */ |
447 | 447 | function createTableByXml($xml_doc) |
448 | 448 | { |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | /** |
453 | 453 | * Creates a table by using xml file path |
454 | 454 | * @param string $file_name xml schema file path |
455 | - * @return void|object |
|
455 | + * @return null|false |
|
456 | 456 | */ |
457 | 457 | function createTableByXmlFile($file_name) |
458 | 458 | { |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | * opt : notnull, default, size\n |
473 | 473 | * index : primary key, index, unique\n |
474 | 474 | * @param string $xml_doc xml schema contents |
475 | - * @return void|object |
|
475 | + * @return null|false |
|
476 | 476 | */ |
477 | 477 | function _createTable($xml_doc) |
478 | 478 | { |
@@ -824,7 +824,7 @@ discard block |
||
824 | 824 | |
825 | 825 | /** |
826 | 826 | * If select query execute, return paging sql |
827 | - * @param object $query |
|
827 | + * @param BaseObject $query |
|
828 | 828 | * @param boolean $with_values |
829 | 829 | * @param int $start_count |
830 | 830 | * @param int $list_count |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | function DBMysql($auto_connect = TRUE) |
47 | 47 | { |
48 | 48 | $this->_setDBInfo(); |
49 | - if($auto_connect) $this->_connect(); |
|
49 | + if ($auto_connect) $this->_connect(); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -67,32 +67,32 @@ discard block |
||
67 | 67 | function __connect($connection) |
68 | 68 | { |
69 | 69 | // Ignore if no DB information exists |
70 | - if(strpos($connection["db_hostname"], ':') === false && $connection["db_port"]) |
|
70 | + if (strpos($connection["db_hostname"], ':') === false && $connection["db_port"]) |
|
71 | 71 | { |
72 | - $connection["db_hostname"] .= ':' . $connection["db_port"]; |
|
72 | + $connection["db_hostname"] .= ':'.$connection["db_port"]; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | // Attempt to connect |
76 | 76 | $result = @mysql_connect($connection["db_hostname"], $connection["db_userid"], $connection["db_password"]); |
77 | - if(!$result) |
|
77 | + if (!$result) |
|
78 | 78 | { |
79 | 79 | exit('XE cannot connect to DB.'); |
80 | 80 | } |
81 | 81 | |
82 | - if(mysql_error()) |
|
82 | + if (mysql_error()) |
|
83 | 83 | { |
84 | 84 | $this->setError(mysql_errno(), mysql_error()); |
85 | 85 | return; |
86 | 86 | } |
87 | 87 | // Error appears if the version is lower than 4.1 |
88 | - if(version_compare(mysql_get_server_info($result), '4.1', '<')) |
|
88 | + if (version_compare(mysql_get_server_info($result), '4.1', '<')) |
|
89 | 89 | { |
90 | - $this->setError(-1, 'XE cannot be installed under the version of mysql 4.1. Current mysql version is ' . mysql_get_server_info()); |
|
90 | + $this->setError(-1, 'XE cannot be installed under the version of mysql 4.1. Current mysql version is '.mysql_get_server_info()); |
|
91 | 91 | return; |
92 | 92 | } |
93 | 93 | // select db |
94 | 94 | @mysql_select_db($connection["db_database"], $result); |
95 | - if(mysql_error()) |
|
95 | + if (mysql_error()) |
|
96 | 96 | { |
97 | 97 | $this->setError(mysql_errno(), mysql_error()); |
98 | 98 | return; |
@@ -131,11 +131,11 @@ discard block |
||
131 | 131 | */ |
132 | 132 | function addQuotes($string) |
133 | 133 | { |
134 | - if(version_compare(PHP_VERSION, "5.4.0", "<") && get_magic_quotes_gpc()) |
|
134 | + if (version_compare(PHP_VERSION, "5.4.0", "<") && get_magic_quotes_gpc()) |
|
135 | 135 | { |
136 | 136 | $string = stripslashes(str_replace("\\", "\\\\", $string)); |
137 | 137 | } |
138 | - if(!is_numeric($string)) |
|
138 | + if (!is_numeric($string)) |
|
139 | 139 | { |
140 | 140 | $string = @mysql_real_escape_string($string); |
141 | 141 | } |
@@ -181,14 +181,14 @@ discard block |
||
181 | 181 | */ |
182 | 182 | function __query($query, $connection) |
183 | 183 | { |
184 | - if(!$connection) |
|
184 | + if (!$connection) |
|
185 | 185 | { |
186 | 186 | exit('XE cannot handle DB connection.'); |
187 | 187 | } |
188 | 188 | // Run the query statement |
189 | 189 | $result = mysql_query($query, $connection); |
190 | 190 | // Error Check |
191 | - if(mysql_error($connection)) |
|
191 | + if (mysql_error($connection)) |
|
192 | 192 | { |
193 | 193 | $this->setError(mysql_errno($connection), mysql_error($connection)); |
194 | 194 | } |
@@ -205,13 +205,13 @@ discard block |
||
205 | 205 | function _fetch($result, $arrayIndexEndValue = NULL) |
206 | 206 | { |
207 | 207 | $output = array(); |
208 | - if(!$this->isConnected() || $this->isError() || !$result) |
|
208 | + if (!$this->isConnected() || $this->isError() || !$result) |
|
209 | 209 | { |
210 | 210 | return $output; |
211 | 211 | } |
212 | - while($tmp = $this->db_fetch_object($result)) |
|
212 | + while ($tmp = $this->db_fetch_object($result)) |
|
213 | 213 | { |
214 | - if($arrayIndexEndValue) |
|
214 | + if ($arrayIndexEndValue) |
|
215 | 215 | { |
216 | 216 | $output[$arrayIndexEndValue--] = $tmp; |
217 | 217 | } |
@@ -220,9 +220,9 @@ discard block |
||
220 | 220 | $output[] = $tmp; |
221 | 221 | } |
222 | 222 | } |
223 | - if(count($output) == 1) |
|
223 | + if (count($output) == 1) |
|
224 | 224 | { |
225 | - if(isset($arrayIndexEndValue)) |
|
225 | + if (isset($arrayIndexEndValue)) |
|
226 | 226 | { |
227 | 227 | return $output; |
228 | 228 | } |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | $query = sprintf("insert into `%ssequence` (seq) values ('0')", $this->prefix); |
246 | 246 | $this->_query($query); |
247 | 247 | $sequence = $this->db_insert_id(); |
248 | - if($sequence % 10000 == 0) |
|
248 | + if ($sequence % 10000 == 0) |
|
249 | 249 | { |
250 | 250 | $query = sprintf("delete from `%ssequence` where seq < %d", $this->prefix, $sequence); |
251 | 251 | $this->_query($query); |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | $query = sprintf("select password('%s') as password, old_password('%s') as old_password", $this->addQuotes($password), $this->addQuotes($password)); |
266 | 266 | $result = $this->_query($query); |
267 | 267 | $tmp = $this->_fetch($result); |
268 | - if($tmp->password === $saved_password || $tmp->old_password === $saved_password) |
|
268 | + if ($tmp->password === $saved_password || $tmp->old_password === $saved_password) |
|
269 | 269 | { |
270 | 270 | return true; |
271 | 271 | } |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | $query = sprintf("show tables like '%s%s'", $this->prefix, $this->addQuotes($target_name)); |
283 | 283 | $result = $this->_query($query); |
284 | 284 | $tmp = $this->_fetch($result); |
285 | - if(!$tmp) |
|
285 | + if (!$tmp) |
|
286 | 286 | { |
287 | 287 | return false; |
288 | 288 | } |
@@ -302,13 +302,13 @@ discard block |
||
302 | 302 | function addColumn($table_name, $column_name, $type = 'number', $size = '', $default = null, $notnull = false) |
303 | 303 | { |
304 | 304 | $type = $this->column_type[$type]; |
305 | - if(strtoupper($type) == 'INTEGER') |
|
305 | + if (strtoupper($type) == 'INTEGER') |
|
306 | 306 | { |
307 | 307 | $size = ''; |
308 | 308 | } |
309 | 309 | |
310 | 310 | $query = sprintf("alter table `%s%s` add `%s` ", $this->prefix, $table_name, $column_name); |
311 | - if($size) |
|
311 | + if ($size) |
|
312 | 312 | { |
313 | 313 | $query .= sprintf(" %s(%s) ", $type, $size); |
314 | 314 | } |
@@ -316,11 +316,11 @@ discard block |
||
316 | 316 | { |
317 | 317 | $query .= sprintf(" %s ", $type); |
318 | 318 | } |
319 | - if(isset($default)) |
|
319 | + if (isset($default)) |
|
320 | 320 | { |
321 | 321 | $query .= sprintf(" default '%s' ", $default); |
322 | 322 | } |
323 | - if($notnull) |
|
323 | + if ($notnull) |
|
324 | 324 | { |
325 | 325 | $query .= " not null "; |
326 | 326 | } |
@@ -350,18 +350,18 @@ discard block |
||
350 | 350 | { |
351 | 351 | $query = sprintf("show fields from `%s%s`", $this->prefix, $table_name); |
352 | 352 | $result = $this->_query($query); |
353 | - if($this->isError()) |
|
353 | + if ($this->isError()) |
|
354 | 354 | { |
355 | 355 | return; |
356 | 356 | } |
357 | 357 | $output = $this->_fetch($result); |
358 | - if($output) |
|
358 | + if ($output) |
|
359 | 359 | { |
360 | 360 | $column_name = strtolower($column_name); |
361 | - foreach($output as $key => $val) |
|
361 | + foreach ($output as $key => $val) |
|
362 | 362 | { |
363 | 363 | $name = strtolower($val->Field); |
364 | - if($column_name == $name) |
|
364 | + if ($column_name == $name) |
|
365 | 365 | { |
366 | 366 | return true; |
367 | 367 | } |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | */ |
383 | 383 | function addIndex($table_name, $index_name, $target_columns, $is_unique = false) |
384 | 384 | { |
385 | - if(!is_array($target_columns)) |
|
385 | + if (!is_array($target_columns)) |
|
386 | 386 | { |
387 | 387 | $target_columns = array($target_columns); |
388 | 388 | } |
@@ -415,23 +415,23 @@ discard block |
||
415 | 415 | //$query = sprintf("show indexes from %s%s where key_name = '%s' ", $this->prefix, $table_name, $index_name); |
416 | 416 | $query = sprintf("show indexes from `%s%s`", $this->prefix, $table_name); |
417 | 417 | $result = $this->_query($query); |
418 | - if($this->isError()) |
|
418 | + if ($this->isError()) |
|
419 | 419 | { |
420 | 420 | return; |
421 | 421 | } |
422 | 422 | $output = $this->_fetch($result); |
423 | - if(!$output) |
|
423 | + if (!$output) |
|
424 | 424 | { |
425 | 425 | return; |
426 | 426 | } |
427 | - if(!is_array($output)) |
|
427 | + if (!is_array($output)) |
|
428 | 428 | { |
429 | 429 | $output = array($output); |
430 | 430 | } |
431 | 431 | |
432 | - for($i = 0; $i < count($output); $i++) |
|
432 | + for ($i = 0; $i < count($output); $i++) |
|
433 | 433 | { |
434 | - if($output[$i]->Key_name == $index_name) |
|
434 | + if ($output[$i]->Key_name == $index_name) |
|
435 | 435 | { |
436 | 436 | return true; |
437 | 437 | } |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | */ |
457 | 457 | function createTableByXmlFile($file_name) |
458 | 458 | { |
459 | - if(!file_exists($file_name)) |
|
459 | + if (!file_exists($file_name)) |
|
460 | 460 | { |
461 | 461 | return; |
462 | 462 | } |
@@ -481,13 +481,13 @@ discard block |
||
481 | 481 | $xml_obj = $oXml->parse($xml_doc); |
482 | 482 | // Create a table schema |
483 | 483 | $table_name = $xml_obj->table->attrs->name; |
484 | - if($this->isTableExists($table_name)) |
|
484 | + if ($this->isTableExists($table_name)) |
|
485 | 485 | { |
486 | 486 | return; |
487 | 487 | } |
488 | - $table_name = $this->prefix . $table_name; |
|
488 | + $table_name = $this->prefix.$table_name; |
|
489 | 489 | |
490 | - if(!is_array($xml_obj->table->column)) |
|
490 | + if (!is_array($xml_obj->table->column)) |
|
491 | 491 | { |
492 | 492 | $columns[] = $xml_obj->table->column; |
493 | 493 | } |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | $unique_list = array(); |
501 | 501 | $index_list = array(); |
502 | 502 | |
503 | - foreach($columns as $column) |
|
503 | + foreach ($columns as $column) |
|
504 | 504 | { |
505 | 505 | $name = $column->attrs->name; |
506 | 506 | $type = $column->attrs->type; |
@@ -512,47 +512,47 @@ discard block |
||
512 | 512 | $default = $column->attrs->default; |
513 | 513 | $auto_increment = $column->attrs->auto_increment; |
514 | 514 | |
515 | - $column_schema[] = sprintf('`%s` %s%s %s %s %s', $name, $this->column_type[$type], $size ? '(' . $size . ')' : '', isset($default) ? "default '" . $default . "'" : '', $notnull ? 'not null' : '', $auto_increment ? 'auto_increment' : ''); |
|
515 | + $column_schema[] = sprintf('`%s` %s%s %s %s %s', $name, $this->column_type[$type], $size ? '('.$size.')' : '', isset($default) ? "default '".$default."'" : '', $notnull ? 'not null' : '', $auto_increment ? 'auto_increment' : ''); |
|
516 | 516 | |
517 | - if($primary_key) |
|
517 | + if ($primary_key) |
|
518 | 518 | { |
519 | 519 | $primary_list[] = $name; |
520 | 520 | } |
521 | - else if($unique) |
|
521 | + else if ($unique) |
|
522 | 522 | { |
523 | 523 | $unique_list[$unique][] = $name; |
524 | 524 | } |
525 | - else if($index) |
|
525 | + else if ($index) |
|
526 | 526 | { |
527 | 527 | $index_list[$index][] = $name; |
528 | 528 | } |
529 | 529 | } |
530 | 530 | |
531 | - if(count($primary_list)) |
|
531 | + if (count($primary_list)) |
|
532 | 532 | { |
533 | - $column_schema[] = sprintf("primary key (%s)", '`' . implode($primary_list, '`,`') . '`'); |
|
533 | + $column_schema[] = sprintf("primary key (%s)", '`'.implode($primary_list, '`,`').'`'); |
|
534 | 534 | } |
535 | 535 | |
536 | - if(count($unique_list)) |
|
536 | + if (count($unique_list)) |
|
537 | 537 | { |
538 | - foreach($unique_list as $key => $val) |
|
538 | + foreach ($unique_list as $key => $val) |
|
539 | 539 | { |
540 | - $column_schema[] = sprintf("unique %s (%s)", $key, '`' . implode($val, '`,`') . '`'); |
|
540 | + $column_schema[] = sprintf("unique %s (%s)", $key, '`'.implode($val, '`,`').'`'); |
|
541 | 541 | } |
542 | 542 | } |
543 | 543 | |
544 | - if(count($index_list)) |
|
544 | + if (count($index_list)) |
|
545 | 545 | { |
546 | - foreach($index_list as $key => $val) |
|
546 | + foreach ($index_list as $key => $val) |
|
547 | 547 | { |
548 | - $column_schema[] = sprintf("index %s (%s)", $key, '`' . implode($val, '`,`') . '`'); |
|
548 | + $column_schema[] = sprintf("index %s (%s)", $key, '`'.implode($val, '`,`').'`'); |
|
549 | 549 | } |
550 | 550 | } |
551 | 551 | |
552 | 552 | $schema = sprintf('create table `%s` (%s%s) %s;', $this->addQuotes($table_name), "\n", implode($column_schema, ",\n"), "ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci"); |
553 | 553 | |
554 | 554 | $output = $this->_query($schema); |
555 | - if(!$output) |
|
555 | + if (!$output) |
|
556 | 556 | return false; |
557 | 557 | } |
558 | 558 | |
@@ -565,8 +565,8 @@ discard block |
||
565 | 565 | function _executeInsertAct($queryObject, $with_values = true) |
566 | 566 | { |
567 | 567 | $query = $this->getInsertSql($queryObject, $with_values, true); |
568 | - $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; |
|
569 | - if(is_a($query, 'BaseObject')) |
|
568 | + $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' '.$this->comment_syntax, $this->query_id) : ''; |
|
569 | + if (is_a($query, 'BaseObject')) |
|
570 | 570 | { |
571 | 571 | return; |
572 | 572 | } |
@@ -582,13 +582,13 @@ discard block |
||
582 | 582 | function _executeUpdateAct($queryObject, $with_values = true) |
583 | 583 | { |
584 | 584 | $query = $this->getUpdateSql($queryObject, $with_values, true); |
585 | - if(is_a($query, 'BaseObject')) |
|
585 | + if (is_a($query, 'BaseObject')) |
|
586 | 586 | { |
587 | - if(!$query->toBool()) return $query; |
|
587 | + if (!$query->toBool()) return $query; |
|
588 | 588 | else return; |
589 | 589 | } |
590 | 590 | |
591 | - $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; |
|
591 | + $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' '.$this->comment_syntax, $this->query_id) : ''; |
|
592 | 592 | |
593 | 593 | |
594 | 594 | return $this->_query($query); |
@@ -603,8 +603,8 @@ discard block |
||
603 | 603 | function _executeDeleteAct($queryObject, $with_values = true) |
604 | 604 | { |
605 | 605 | $query = $this->getDeleteSql($queryObject, $with_values, true); |
606 | - $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; |
|
607 | - if(is_a($query, 'BaseObject')) |
|
606 | + $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' '.$this->comment_syntax, $this->query_id) : ''; |
|
607 | + if (is_a($query, 'BaseObject')) |
|
608 | 608 | { |
609 | 609 | return; |
610 | 610 | } |
@@ -624,21 +624,21 @@ discard block |
||
624 | 624 | { |
625 | 625 | $limit = $queryObject->getLimit(); |
626 | 626 | $result = NULL; |
627 | - if($limit && $limit->isPageHandler()) |
|
627 | + if ($limit && $limit->isPageHandler()) |
|
628 | 628 | { |
629 | 629 | return $this->queryPageLimit($queryObject, $result, $connection, $with_values); |
630 | 630 | } |
631 | 631 | else |
632 | 632 | { |
633 | 633 | $query = $this->getSelectSql($queryObject, $with_values); |
634 | - if(is_a($query, 'BaseObject')) |
|
634 | + if (is_a($query, 'BaseObject')) |
|
635 | 635 | { |
636 | 636 | return; |
637 | 637 | } |
638 | - $query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(' ' . $this->comment_syntax, $queryObject->queryID) : ''; |
|
638 | + $query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(' '.$this->comment_syntax, $queryObject->queryID) : ''; |
|
639 | 639 | |
640 | 640 | $result = $this->_query($query, $connection); |
641 | - if($this->isError()) |
|
641 | + if ($this->isError()) |
|
642 | 642 | { |
643 | 643 | return $this->queryError($queryObject); |
644 | 644 | } |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | $buff = new BaseObject(); |
648 | 648 | $buff->data = $data; |
649 | 649 | |
650 | - if($queryObject->usesClickCount()) |
|
650 | + if ($queryObject->usesClickCount()) |
|
651 | 651 | { |
652 | 652 | $update_query = $this->getClickCountQuery($queryObject); |
653 | 653 | $this->_executeUpdateAct($update_query, $with_values); |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | function queryError($queryObject) |
709 | 709 | { |
710 | 710 | $limit = $queryObject->getLimit(); |
711 | - if($limit && $limit->isPageHandler()) |
|
711 | + if ($limit && $limit->isPageHandler()) |
|
712 | 712 | { |
713 | 713 | $buff = new BaseObject(); |
714 | 714 | $buff->total_count = 0; |
@@ -737,48 +737,48 @@ discard block |
||
737 | 737 | $limit = $queryObject->getLimit(); |
738 | 738 | // Total count |
739 | 739 | $temp_where = $queryObject->getWhereString($with_values, false); |
740 | - $count_query = sprintf('select count(*) as "count" %s %s', 'FROM ' . $queryObject->getFromString($with_values), ($temp_where === '' ? '' : ' WHERE ' . $temp_where)); |
|
740 | + $count_query = sprintf('select count(*) as "count" %s %s', 'FROM '.$queryObject->getFromString($with_values), ($temp_where === '' ? '' : ' WHERE '.$temp_where)); |
|
741 | 741 | |
742 | 742 | // Check for distinct query and if found update count query structure |
743 | 743 | $temp_select = $queryObject->getSelectString($with_values); |
744 | 744 | $uses_distinct = stripos($temp_select, "distinct") !== false; |
745 | 745 | $uses_groupby = $queryObject->getGroupByString() != ''; |
746 | - if($uses_distinct || $uses_groupby) |
|
746 | + if ($uses_distinct || $uses_groupby) |
|
747 | 747 | { |
748 | 748 | $count_query = sprintf('select %s %s %s %s' |
749 | 749 | , $temp_select == '*' ? '1' : $temp_select |
750 | - , 'FROM ' . $queryObject->getFromString($with_values) |
|
751 | - , ($temp_where === '' ? '' : ' WHERE ' . $temp_where) |
|
752 | - , ($uses_groupby ? ' GROUP BY ' . $queryObject->getGroupByString() : '') |
|
750 | + , 'FROM '.$queryObject->getFromString($with_values) |
|
751 | + , ($temp_where === '' ? '' : ' WHERE '.$temp_where) |
|
752 | + , ($uses_groupby ? ' GROUP BY '.$queryObject->getGroupByString() : '') |
|
753 | 753 | ); |
754 | 754 | |
755 | 755 | // If query uses grouping or distinct, count from original select |
756 | 756 | $count_query = sprintf('select count(*) as "count" from (%s) xet', $count_query); |
757 | 757 | } |
758 | 758 | |
759 | - $count_query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(' ' . $this->comment_syntax, $queryObject->queryID) : ''; |
|
759 | + $count_query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(' '.$this->comment_syntax, $queryObject->queryID) : ''; |
|
760 | 760 | $result_count = $this->_query($count_query, $connection); |
761 | 761 | $count_output = $this->_fetch($result_count); |
762 | 762 | $total_count = (int) (isset($count_output->count) ? $count_output->count : NULL); |
763 | 763 | |
764 | 764 | $list_count = $limit->list_count->getValue(); |
765 | - if(!$list_count) |
|
765 | + if (!$list_count) |
|
766 | 766 | { |
767 | 767 | $list_count = 20; |
768 | 768 | } |
769 | 769 | $page_count = $limit->page_count->getValue(); |
770 | - if(!$page_count) |
|
770 | + if (!$page_count) |
|
771 | 771 | { |
772 | 772 | $page_count = 10; |
773 | 773 | } |
774 | 774 | $page = $limit->page->getValue(); |
775 | - if(!$page || $page < 1) |
|
775 | + if (!$page || $page < 1) |
|
776 | 776 | { |
777 | 777 | $page = 1; |
778 | 778 | } |
779 | 779 | |
780 | 780 | // total pages |
781 | - if($total_count) |
|
781 | + if ($total_count) |
|
782 | 782 | { |
783 | 783 | $total_page = (int) (($total_count - 1) / $list_count) + 1; |
784 | 784 | } |
@@ -788,7 +788,7 @@ discard block |
||
788 | 788 | } |
789 | 789 | |
790 | 790 | // check the page variables |
791 | - if($page > $total_page) |
|
791 | + if ($page > $total_page) |
|
792 | 792 | { |
793 | 793 | // If requested page is bigger than total number of pages, return empty list |
794 | 794 | $buff = new BaseObject(); |
@@ -803,9 +803,9 @@ discard block |
||
803 | 803 | |
804 | 804 | $query = $this->getSelectPageSql($queryObject, $with_values, $start_count, $list_count); |
805 | 805 | |
806 | - $query .= (__DEBUG_QUERY__ & 1 && $queryObject->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; |
|
806 | + $query .= (__DEBUG_QUERY__ & 1 && $queryObject->query_id) ? sprintf(' '.$this->comment_syntax, $this->query_id) : ''; |
|
807 | 807 | $result = $this->_query($query, $connection); |
808 | - if($this->isError()) |
|
808 | + if ($this->isError()) |
|
809 | 809 | { |
810 | 810 | return $this->queryError($queryObject); |
811 | 811 | } |
@@ -833,44 +833,44 @@ discard block |
||
833 | 833 | function getSelectPageSql($query, $with_values = true, $start_count = 0, $list_count = 0) |
834 | 834 | { |
835 | 835 | $select = $query->getSelectString($with_values); |
836 | - if($select == '') |
|
836 | + if ($select == '') |
|
837 | 837 | { |
838 | 838 | return new BaseObject(-1, "Invalid query"); |
839 | 839 | } |
840 | - $select = 'SELECT ' . $select; |
|
840 | + $select = 'SELECT '.$select; |
|
841 | 841 | |
842 | 842 | $from = $query->getFromString($with_values); |
843 | - if($from == '') |
|
843 | + if ($from == '') |
|
844 | 844 | { |
845 | 845 | return new BaseObject(-1, "Invalid query"); |
846 | 846 | } |
847 | - $from = ' FROM ' . $from; |
|
847 | + $from = ' FROM '.$from; |
|
848 | 848 | |
849 | 849 | $where = $query->getWhereString($with_values); |
850 | - if($where != '') |
|
850 | + if ($where != '') |
|
851 | 851 | { |
852 | - $where = ' WHERE ' . $where; |
|
852 | + $where = ' WHERE '.$where; |
|
853 | 853 | } |
854 | 854 | |
855 | 855 | $groupBy = $query->getGroupByString(); |
856 | - if($groupBy != '') |
|
856 | + if ($groupBy != '') |
|
857 | 857 | { |
858 | - $groupBy = ' GROUP BY ' . $groupBy; |
|
858 | + $groupBy = ' GROUP BY '.$groupBy; |
|
859 | 859 | } |
860 | 860 | |
861 | 861 | $orderBy = $query->getOrderByString(); |
862 | - if($orderBy != '') |
|
862 | + if ($orderBy != '') |
|
863 | 863 | { |
864 | - $orderBy = ' ORDER BY ' . $orderBy; |
|
864 | + $orderBy = ' ORDER BY '.$orderBy; |
|
865 | 865 | } |
866 | 866 | |
867 | 867 | $limit = $query->getLimitString(); |
868 | - if($limit != '') |
|
868 | + if ($limit != '') |
|
869 | 869 | { |
870 | 870 | $limit = sprintf(' LIMIT %d, %d', $start_count, $list_count); |
871 | 871 | } |
872 | 872 | |
873 | - return $select . ' ' . $from . ' ' . $where . ' ' . $groupBy . ' ' . $orderBy . ' ' . $limit; |
|
873 | + return $select.' '.$from.' '.$where.' '.$groupBy.' '.$orderBy.' '.$limit; |
|
874 | 874 | } |
875 | 875 | |
876 | 876 | } |
@@ -46,7 +46,9 @@ discard block |
||
46 | 46 | function DBMysql($auto_connect = TRUE) |
47 | 47 | { |
48 | 48 | $this->_setDBInfo(); |
49 | - if($auto_connect) $this->_connect(); |
|
49 | + if($auto_connect) { |
|
50 | + $this->_connect(); |
|
51 | + } |
|
50 | 52 | } |
51 | 53 | |
52 | 54 | /** |
@@ -214,8 +216,7 @@ discard block |
||
214 | 216 | if($arrayIndexEndValue) |
215 | 217 | { |
216 | 218 | $output[$arrayIndexEndValue--] = $tmp; |
217 | - } |
|
218 | - else |
|
219 | + } else |
|
219 | 220 | { |
220 | 221 | $output[] = $tmp; |
221 | 222 | } |
@@ -225,8 +226,7 @@ discard block |
||
225 | 226 | if(isset($arrayIndexEndValue)) |
226 | 227 | { |
227 | 228 | return $output; |
228 | - } |
|
229 | - else |
|
229 | + } else |
|
230 | 230 | { |
231 | 231 | return $output[0]; |
232 | 232 | } |
@@ -311,8 +311,7 @@ discard block |
||
311 | 311 | if($size) |
312 | 312 | { |
313 | 313 | $query .= sprintf(" %s(%s) ", $type, $size); |
314 | - } |
|
315 | - else |
|
314 | + } else |
|
316 | 315 | { |
317 | 316 | $query .= sprintf(" %s ", $type); |
318 | 317 | } |
@@ -490,8 +489,7 @@ discard block |
||
490 | 489 | if(!is_array($xml_obj->table->column)) |
491 | 490 | { |
492 | 491 | $columns[] = $xml_obj->table->column; |
493 | - } |
|
494 | - else |
|
492 | + } else |
|
495 | 493 | { |
496 | 494 | $columns = $xml_obj->table->column; |
497 | 495 | } |
@@ -517,12 +515,10 @@ discard block |
||
517 | 515 | if($primary_key) |
518 | 516 | { |
519 | 517 | $primary_list[] = $name; |
520 | - } |
|
521 | - else if($unique) |
|
518 | + } else if($unique) |
|
522 | 519 | { |
523 | 520 | $unique_list[$unique][] = $name; |
524 | - } |
|
525 | - else if($index) |
|
521 | + } else if($index) |
|
526 | 522 | { |
527 | 523 | $index_list[$index][] = $name; |
528 | 524 | } |
@@ -552,8 +548,9 @@ discard block |
||
552 | 548 | $schema = sprintf('create table `%s` (%s%s) %s;', $this->addQuotes($table_name), "\n", implode($column_schema, ",\n"), "ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci"); |
553 | 549 | |
554 | 550 | $output = $this->_query($schema); |
555 | - if(!$output) |
|
556 | - return false; |
|
551 | + if(!$output) { |
|
552 | + return false; |
|
553 | + } |
|
557 | 554 | } |
558 | 555 | |
559 | 556 | /** |
@@ -584,8 +581,11 @@ discard block |
||
584 | 581 | $query = $this->getUpdateSql($queryObject, $with_values, true); |
585 | 582 | if(is_a($query, 'BaseObject')) |
586 | 583 | { |
587 | - if(!$query->toBool()) return $query; |
|
588 | - else return; |
|
584 | + if(!$query->toBool()) { |
|
585 | + return $query; |
|
586 | + } else { |
|
587 | + return; |
|
588 | + } |
|
589 | 589 | } |
590 | 590 | |
591 | 591 | $query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : ''; |
@@ -627,8 +627,7 @@ discard block |
||
627 | 627 | if($limit && $limit->isPageHandler()) |
628 | 628 | { |
629 | 629 | return $this->queryPageLimit($queryObject, $result, $connection, $with_values); |
630 | - } |
|
631 | - else |
|
630 | + } else |
|
632 | 631 | { |
633 | 632 | $query = $this->getSelectSql($queryObject, $with_values); |
634 | 633 | if(is_a($query, 'BaseObject')) |
@@ -717,8 +716,7 @@ discard block |
||
717 | 716 | $buff->data = array(); |
718 | 717 | $buff->page_navigation = new PageHandler(/* $total_count */0, /* $total_page */1, /* $page */1, /* $page_count */10); //default page handler values |
719 | 718 | return $buff; |
720 | - } |
|
721 | - else |
|
719 | + } else |
|
722 | 720 | { |
723 | 721 | return; |
724 | 722 | } |
@@ -781,8 +779,7 @@ discard block |
||
781 | 779 | if($total_count) |
782 | 780 | { |
783 | 781 | $total_page = (int) (($total_count - 1) / $list_count) + 1; |
784 | - } |
|
785 | - else |
|
782 | + } else |
|
786 | 783 | { |
787 | 784 | $total_page = 1; |
788 | 785 | } |
@@ -131,7 +131,7 @@ |
||
131 | 131 | * opt : notnull, default, size\n |
132 | 132 | * index : primary key, index, unique\n |
133 | 133 | * @param string $xml_doc xml schema contents |
134 | - * @return void|object |
|
134 | + * @return null|false |
|
135 | 135 | */ |
136 | 136 | function _createTable($xml_doc) |
137 | 137 | { |