GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 99f185...656a22 )
by gyeong-won
12:40
created
classes/module/ModuleHandler.class.php 1 patch
Spacing   +178 added lines, -178 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	function ModuleHandler($module = '', $act = '', $mid = '', $document_srl = '', $module_srl = '')
36 36
 	{
37 37
 		// If XE has not installed yet, set module as install
38
-		if(!Context::isInstalled())
38
+		if (!Context::isInstalled())
39 39
 		{
40 40
 			$this->module = 'install';
41 41
 			$this->act = Context::get('act');
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
 		}
44 44
 
45 45
 		$oContext = Context::getInstance();
46
-		if($oContext->isSuccessInit == FALSE)
46
+		if ($oContext->isSuccessInit == FALSE)
47 47
 		{
48 48
 			$logged_info = Context::get('logged_info');
49
-			if($logged_info->is_admin != "Y")
49
+			if ($logged_info->is_admin != "Y")
50 50
 			{
51 51
 				$this->error = 'msg_invalid_request';
52 52
 				return;
@@ -59,26 +59,26 @@  discard block
 block discarded – undo
59 59
 		$this->mid = $mid ? $mid : Context::get('mid');
60 60
 		$this->document_srl = $document_srl ? (int) $document_srl : (int) Context::get('document_srl');
61 61
 		$this->module_srl = $module_srl ? (int) $module_srl : (int) Context::get('module_srl');
62
-        if($entry = Context::get('entry'))
62
+        if ($entry = Context::get('entry'))
63 63
         {
64 64
             $this->entry = Context::convertEncodingStr($entry);
65 65
         }
66 66
 
67 67
 		// Validate variables to prevent XSS
68 68
 		$isInvalid = NULL;
69
-		if($this->module && !preg_match("/^([a-z0-9\_\-]+)$/i", $this->module))
69
+		if ($this->module && !preg_match("/^([a-z0-9\_\-]+)$/i", $this->module))
70 70
 		{
71 71
 			$isInvalid = TRUE;
72 72
 		}
73
-		if($this->mid && !preg_match("/^([a-z0-9\_\-]+)$/i", $this->mid))
73
+		if ($this->mid && !preg_match("/^([a-z0-9\_\-]+)$/i", $this->mid))
74 74
 		{
75 75
 			$isInvalid = TRUE;
76 76
 		}
77
-		if($this->act && !preg_match("/^([a-z0-9\_\-]+)$/i", $this->act))
77
+		if ($this->act && !preg_match("/^([a-z0-9\_\-]+)$/i", $this->act))
78 78
 		{
79 79
 			$isInvalid = TRUE;
80 80
 		}
81
-		if($isInvalid)
81
+		if ($isInvalid)
82 82
 		{
83 83
 			htmlHeader();
84 84
 			echo Context::getLang("msg_invalid_request");
@@ -87,14 +87,14 @@  discard block
 block discarded – undo
87 87
 			exit;
88 88
 		}
89 89
 
90
-		if(isset($this->act) && (strlen($this->act) >= 4 && substr_compare($this->act, 'disp', 0, 4) === 0))
90
+		if (isset($this->act) && (strlen($this->act) >= 4 && substr_compare($this->act, 'disp', 0, 4) === 0))
91 91
 		{
92
-			if(Context::get('_use_ssl') == 'optional' && Context::isExistsSSLAction($this->act) && $_SERVER['HTTPS'] != 'on')
92
+			if (Context::get('_use_ssl') == 'optional' && Context::isExistsSSLAction($this->act) && $_SERVER['HTTPS'] != 'on')
93 93
 			{
94
-				if(Context::get('_https_port')!=null) {
95
-					header('location:https://' . $_SERVER['HTTP_HOST'] . ':' . Context::get('_https_port') . $_SERVER['REQUEST_URI']);
94
+				if (Context::get('_https_port') != null) {
95
+					header('location:https://'.$_SERVER['HTTP_HOST'].':'.Context::get('_https_port').$_SERVER['REQUEST_URI']);
96 96
 				} else {
97
-					header('location:https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
97
+					header('location:https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
98 98
 				}
99 99
 				return;
100 100
 			}
@@ -102,9 +102,9 @@  discard block
 block discarded – undo
102 102
 
103 103
 		// call a trigger before moduleHandler init
104 104
 		ModuleHandler::triggerCall('moduleHandler.init', 'before', $this);
105
-		if(__ERROR_LOG__ == 1 && __DEBUG_OUTPUT__ == 0)
105
+		if (__ERROR_LOG__ == 1 && __DEBUG_OUTPUT__ == 0)
106 106
 		{
107
-			if(__DEBUG_PROTECT__ === 0 || __DEBUG_PROTECT__ === 1 && __DEBUG_PROTECT_IP__ == $_SERVER['REMOTE_ADDR'])
107
+			if (__DEBUG_PROTECT__ === 0 || __DEBUG_PROTECT__ === 1 && __DEBUG_PROTECT_IP__ == $_SERVER['REMOTE_ADDR'])
108 108
 			{
109 109
 				set_error_handler(array($this, 'xeErrorLog'), E_WARNING);
110 110
 				register_shutdown_function(array($this, 'shutdownHandler'));
@@ -115,40 +115,40 @@  discard block
 block discarded – undo
115 115
 		$called_position = 'before_module_init';
116 116
 		$oAddonController = getController('addon');
117 117
 		$addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone() ? 'mobile' : 'pc');
118
-		if(file_exists($addon_file)) include($addon_file);
118
+		if (file_exists($addon_file)) include($addon_file);
119 119
 	}
120 120
 
121 121
 	public static function xeErrorLog($errnumber, $errormassage, $errorfile, $errorline, $errorcontext)
122 122
 	{
123
-		if(($errnumber & 3) == 0 || error_reporting() == 0)
123
+		if (($errnumber & 3) == 0 || error_reporting() == 0)
124 124
 		{
125 125
 			return false;
126 126
 		}
127 127
 
128 128
 		set_error_handler(function() { }, ~0);
129 129
 
130
-		$debug_file = _XE_PATH_ . 'files/_debug_message.php';
131
-		if(!file_exists($debug_file))
130
+		$debug_file = _XE_PATH_.'files/_debug_message.php';
131
+		if (!file_exists($debug_file))
132 132
 		{
133 133
 			$print[] = '<?php exit() ?>';
134 134
 		}
135 135
 
136 136
 		$errorname = self::getErrorType($errnumber);
137
-		$print[] = '['.date('Y-m-d H:i:s').'] ' . $errorname . ' : ' . $errormassage;
137
+		$print[] = '['.date('Y-m-d H:i:s').'] '.$errorname.' : '.$errormassage;
138 138
 		$backtrace_args = defined('DEBUG_BACKTRACE_IGNORE_ARGS') ? \DEBUG_BACKTRACE_IGNORE_ARGS : 0;
139 139
 		$backtrace = debug_backtrace($backtrace_args);
140
-		if(count($backtrace) > 1 && $backtrace[1]['function'] === 'xeErrorLog' && !$backtrace[1]['class'])
140
+		if (count($backtrace) > 1 && $backtrace[1]['function'] === 'xeErrorLog' && !$backtrace[1]['class'])
141 141
 		{
142 142
 			array_shift($backtrace);
143 143
 		}
144 144
 
145
-		foreach($backtrace as $key => $value)
145
+		foreach ($backtrace as $key => $value)
146 146
 		{
147
-			$message = '    - ' . $value['file'] . ' : ' . $value['line'];
147
+			$message = '    - '.$value['file'].' : '.$value['line'];
148 148
 			$print[] = $message;
149 149
 		}
150 150
 		$print[] = PHP_EOL;
151
-		@file_put_contents($debug_file, implode(PHP_EOL, $print), FILE_APPEND|LOCK_EX);
151
+		@file_put_contents($debug_file, implode(PHP_EOL, $print), FILE_APPEND | LOCK_EX);
152 152
 		restore_error_handler();
153 153
 
154 154
 		return true;
@@ -164,21 +164,21 @@  discard block
 block discarded – undo
164 164
 
165 165
 		set_error_handler(function() { }, ~0);
166 166
 
167
-		$debug_file = _XE_PATH_ . 'files/_debug_message.php';
168
-		if(!file_exists($debug_file))
167
+		$debug_file = _XE_PATH_.'files/_debug_message.php';
168
+		if (!file_exists($debug_file))
169 169
 		{
170 170
 			$print[] = '<?php exit() ?>';
171 171
 		}
172 172
 
173 173
 		$errorname = self::getErrorType($errinfo['type']);
174 174
 		$print[] = '['.date('Y-m-d H:i:s').']';
175
-		$print[] = $errorname . ' : ' . $errinfo['message'];
175
+		$print[] = $errorname.' : '.$errinfo['message'];
176 176
 
177
-		$message = '    - ' . $errinfo['file'] . ' : ' . $errinfo['line'];
177
+		$message = '    - '.$errinfo['file'].' : '.$errinfo['line'];
178 178
 		$print[] = $message;
179 179
 
180 180
 		$print[] = PHP_EOL;
181
-		@file_put_contents($debug_file, implode(PHP_EOL, $print), FILE_APPEND|LOCK_EX);
181
+		@file_put_contents($debug_file, implode(PHP_EOL, $print), FILE_APPEND | LOCK_EX);
182 182
 		set_error_handler(array($this, 'dummyHandler'), ~0);
183 183
 
184 184
 		return true;
@@ -218,9 +218,9 @@  discard block
 block discarded – undo
218 218
 
219 219
 		// if success_return_url and error_return_url is incorrect
220 220
 		$urls = array(Context::get('success_return_url'), Context::get('error_return_url'));
221
-		foreach($urls as $url)
221
+		foreach ($urls as $url)
222 222
 		{
223
-			if(empty($url))
223
+			if (empty($url))
224 224
 			{
225 225
 				continue;
226 226
 			}
@@ -232,29 +232,29 @@  discard block
 block discarded – undo
232 232
 			$defaultUrlInfo = parse_url($dbInfo->default_url);
233 233
 			$defaultHost = $defaultUrlInfo['host'];
234 234
 		
235
-			if($host && ($host != $defaultHost && $host != $site_module_info->domain))
235
+			if ($host && ($host != $defaultHost && $host != $site_module_info->domain))
236 236
 			{
237 237
 				throw new Exception('msg_default_url_is_null');
238 238
 			}
239 239
 		}
240 240
 		
241
-		if(!$this->document_srl && $this->mid && $this->entry)
241
+		if (!$this->document_srl && $this->mid && $this->entry)
242 242
 		{
243 243
 			$oDocumentModel = getModel('document');
244 244
 			$this->document_srl = $oDocumentModel->getDocumentSrlByAlias($this->mid, $this->entry);
245
-			if($this->document_srl)
245
+			if ($this->document_srl)
246 246
 			{
247 247
 				Context::set('document_srl', $this->document_srl);
248 248
 			}
249 249
 		}
250 250
 
251 251
 		// Get module's information based on document_srl, if it's specified
252
-		if($this->document_srl)
252
+		if ($this->document_srl)
253 253
 		{
254 254
 			
255 255
 			$module_info = $oModuleModel->getModuleInfoByDocumentSrl($this->document_srl);
256 256
 			// If the document does not exist, remove document_srl
257
-			if(!$module_info)
257
+			if (!$module_info)
258 258
 			{
259 259
 				unset($this->document_srl);
260 260
 			}
@@ -262,13 +262,13 @@  discard block
 block discarded – undo
262 262
 			{
263 263
 				// If it exists, compare mid based on the module information
264 264
 				// if mids are not matching, set it as the document's mid
265
-				if(!$this->mid || ($this->mid != $module_info->mid))
265
+				if (!$this->mid || ($this->mid != $module_info->mid))
266 266
 				{
267 267
 					
268
-					if(Context::getRequestMethod() == 'GET')
268
+					if (Context::getRequestMethod() == 'GET')
269 269
 					{
270 270
 						$this->mid = $module_info->mid;
271
-						header('location:' . getNotEncodedSiteUrl($site_module_info->domain, 'mid', $this->mid, 'document_srl', $this->document_srl));
271
+						header('location:'.getNotEncodedSiteUrl($site_module_info->domain, 'mid', $this->mid, 'document_srl', $this->document_srl));
272 272
 						return FALSE;
273 273
 					}
274 274
 					else
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 					
280 280
 				}
281 281
 				// if requested module is different from one of the document, remove the module information retrieved based on the document number
282
-				if($this->module && $module_info->module != $this->module)
282
+				if ($this->module && $module_info->module != $this->module)
283 283
 				{
284 284
 					unset($module_info);
285 285
 				}
@@ -288,36 +288,36 @@  discard block
 block discarded – undo
288 288
 		}
289 289
 
290 290
 		// If module_info is not set yet, and there exists mid information, get module information based on the mid
291
-		if(!$module_info && $this->mid)
291
+		if (!$module_info && $this->mid)
292 292
 		{
293 293
 			$module_info = $oModuleModel->getModuleInfoByMid($this->mid, $site_module_info->site_srl);
294 294
 			//if($this->module && $module_info->module != $this->module) unset($module_info);
295 295
 		}
296 296
 
297 297
 		// redirect, if module_site_srl and site_srl are different
298
-		if(!$this->module && !$module_info && $site_module_info->site_srl == 0 && $site_module_info->module_site_srl > 0)
298
+		if (!$this->module && !$module_info && $site_module_info->site_srl == 0 && $site_module_info->module_site_srl > 0)
299 299
 		{
300 300
 			$site_info = $oModuleModel->getSiteInfo($site_module_info->module_site_srl);
301
-			header("location:" . getNotEncodedSiteUrl($site_info->domain, 'mid', $site_module_info->mid));
301
+			header("location:".getNotEncodedSiteUrl($site_info->domain, 'mid', $site_module_info->mid));
302 302
 			return FALSE;
303 303
 		}
304 304
 
305 305
 		// If module_info is not set still, and $module does not exist, find the default module
306
-		if(!$module_info && !$this->module && !$this->mid)
306
+		if (!$module_info && !$this->module && !$this->mid)
307 307
 		{
308 308
 			$module_info = $site_module_info;
309 309
 		}
310 310
 
311
-		if(!$module_info && !$this->module && $site_module_info->module_site_srl)
311
+		if (!$module_info && !$this->module && $site_module_info->module_site_srl)
312 312
 		{
313 313
 			$module_info = $site_module_info;
314 314
 		}
315 315
 
316 316
 		// redirect, if site_srl of module_info is different from one of site's module_info
317
-		if($module_info && $module_info->site_srl != $site_module_info->site_srl && !isCrawler())
317
+		if ($module_info && $module_info->site_srl != $site_module_info->site_srl && !isCrawler())
318 318
 		{
319 319
 			// If the module is of virtual site
320
-			if($module_info->site_srl)
320
+			if ($module_info->site_srl)
321 321
 			{
322 322
 				$site_info = $oModuleModel->getSiteInfo($module_info->site_srl);
323 323
 				$redirect_url = getNotEncodedSiteUrl($site_info->domain, 'mid', Context::get('mid'), 'document_srl', Context::get('document_srl'), 'module_srl', Context::get('module_srl'), 'entry', Context::get('entry'));
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 			else
327 327
 			{
328 328
 				$db_info = Context::getDBInfo();
329
-				if(!$db_info->default_url)
329
+				if (!$db_info->default_url)
330 330
 				{
331 331
 					return Context::getLang('msg_default_url_is_not_defined');
332 332
 				}
@@ -335,12 +335,12 @@  discard block
 block discarded – undo
335 335
 					$redirect_url = getNotEncodedSiteUrl($db_info->default_url, 'mid', Context::get('mid'), 'document_srl', Context::get('document_srl'), 'module_srl', Context::get('module_srl'), 'entry', Context::get('entry'));
336 336
 				}
337 337
 			}
338
-			header("location:" . $redirect_url);
338
+			header("location:".$redirect_url);
339 339
 			return FALSE;
340 340
 		}
341 341
 
342 342
 		// If module info was set, retrieve variables from the module information
343
-		if($module_info)
343
+		if ($module_info)
344 344
 		{
345 345
 			$this->module = $module_info->module;
346 346
 			$this->mid = $module_info->mid;
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 			$targetSrl = (Mobile::isFromMobilePhone()) ? 'mlayout_srl' : 'layout_srl';
352 352
 
353 353
 			// use the site default layout.
354
-			if($module_info->{$targetSrl} == -1)
354
+			if ($module_info->{$targetSrl} == -1)
355 355
 			{
356 356
 				$oLayoutAdminModel = getAdminModel('layout');
357 357
 				$layoutSrl = $oLayoutAdminModel->getSiteDefaultLayout($viewType, $module_info->site_srl);
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 		}
370 370
 
371 371
 		// Set module and mid into module_info
372
-		if(!isset($this->module_info))
372
+		if (!isset($this->module_info))
373 373
 		{
374 374
 			$this->module_info = new stdClass();
375 375
 		}
@@ -380,21 +380,21 @@  discard block
 block discarded – undo
380 380
 		$this->module_info->site_srl = $site_module_info->site_srl;
381 381
 
382 382
 		// Still no module? it's an error
383
-		if(!$this->module)
383
+		if (!$this->module)
384 384
 		{
385 385
 			$this->error = 'msg_module_is_not_exists';
386 386
 			$this->httpStatusCode = '404';
387 387
 		}
388 388
 
389 389
 		// If mid exists, set mid into context
390
-		if($this->mid)
390
+		if ($this->mid)
391 391
 		{
392 392
 			Context::set('mid', $this->mid, TRUE);
393 393
 		}
394 394
 		
395 395
 		// Call a trigger after moduleHandler init
396 396
 		$output = ModuleHandler::triggerCall('moduleHandler.init', 'after', $this->module_info);
397
-		if(!$output->toBool())
397
+		if (!$output->toBool())
398 398
 		{
399 399
 			$this->error = $output->getMessage();
400 400
 			return TRUE;
@@ -416,14 +416,14 @@  discard block
 block discarded – undo
416 416
 		$display_mode = Mobile::isFromMobilePhone() ? 'mobile' : 'view';
417 417
 
418 418
 		// If error occurred while preparation, return a message instance
419
-		if($this->error)
419
+		if ($this->error)
420 420
 		{
421 421
 			$this->_setInputErrorToContext();
422 422
 			$oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
423 423
 			$oMessageObject->setError(-1);
424 424
 			$oMessageObject->setMessage($this->error);
425 425
 			$oMessageObject->dispMessage();
426
-			if($this->httpStatusCode)
426
+			if ($this->httpStatusCode)
427 427
 			{
428 428
 				$oMessageObject->setHttpStatusCode($this->httpStatusCode);
429 429
 			}
@@ -434,22 +434,22 @@  discard block
 block discarded – undo
434 434
 		$xml_info = $oModuleModel->getModuleActionXml($this->module);
435 435
 
436 436
 		// If not installed yet, modify act
437
-		if($this->module == "install")
437
+		if ($this->module == "install")
438 438
 		{
439
-			if(!$this->act || !$xml_info->action->{$this->act})
439
+			if (!$this->act || !$xml_info->action->{$this->act})
440 440
 			{
441 441
 				$this->act = $xml_info->default_index_act;
442 442
 			}
443 443
 		}
444 444
 
445 445
 		// if act exists, find type of the action, if not use default index act
446
-		if(!$this->act)
446
+		if (!$this->act)
447 447
 		{
448 448
 			$this->act = $xml_info->default_index_act;
449 449
 		}
450 450
 
451 451
 		// still no act means error
452
-		if(!$this->act)
452
+		if (!$this->act)
453 453
 		{
454 454
 			$this->error = 'msg_module_is_not_exists';
455 455
 			$this->httpStatusCode = '404';
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
 			$oMessageObject->setError(-1);
460 460
 			$oMessageObject->setMessage($this->error);
461 461
 			$oMessageObject->dispMessage();
462
-			if($this->httpStatusCode)
462
+			if ($this->httpStatusCode)
463 463
 			{
464 464
 				$oMessageObject->setHttpStatusCode($this->httpStatusCode);
465 465
 			}
@@ -470,17 +470,17 @@  discard block
 block discarded – undo
470 470
 		$type = $xml_info->action->{$this->act}->type;
471 471
 		$ruleset = $xml_info->action->{$this->act}->ruleset;
472 472
 		$kind = stripos($this->act, 'admin') !== FALSE ? 'admin' : '';
473
-		if(!$kind && $this->module == 'admin')
473
+		if (!$kind && $this->module == 'admin')
474 474
 		{
475 475
 			$kind = 'admin';
476 476
 		}
477 477
 
478 478
 		// check REQUEST_METHOD in controller
479
-		if($type == 'controller')
479
+		if ($type == 'controller')
480 480
 		{
481 481
 			$allowedMethod = $xml_info->action->{$this->act}->method;
482 482
 
483
-			if(!$allowedMethod)
483
+			if (!$allowedMethod)
484 484
 			{
485 485
 				$allowedMethodList[0] = 'POST';
486 486
 			}
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
 				$allowedMethodList = explode('|', strtoupper($allowedMethod));
490 490
 			}
491 491
 
492
-			if(!in_array(strtoupper($_SERVER['REQUEST_METHOD']), $allowedMethodList))
492
+			if (!in_array(strtoupper($_SERVER['REQUEST_METHOD']), $allowedMethodList))
493 493
 			{
494 494
 				$this->error = "msg_invalid_request";
495 495
 				$oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
 			}
501 501
 		}
502 502
 
503
-		if($this->module_info->use_mobile != "Y")
503
+		if ($this->module_info->use_mobile != "Y")
504 504
 		{
505 505
 			Mobile::setMobile(FALSE);
506 506
 		}
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
 		$logged_info = Context::get('logged_info');
509 509
 
510 510
 		// check CSRF for POST actions
511
-		if($_SERVER['REQUEST_METHOD'] !== 'GET' && Context::isInstalled() && $this->act !== 'procFileUpload' && !checkCSRF()) {
511
+		if ($_SERVER['REQUEST_METHOD'] !== 'GET' && Context::isInstalled() && $this->act !== 'procFileUpload' && !checkCSRF()) {
512 512
 			$this->error = 'msg_invalid_request';
513 513
 			$oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
514 514
 			$oMessageObject->setError(-1);
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
 		}
519 519
 
520 520
 		// Admin ip
521
-		if($kind == 'admin' && $_SESSION['denied_admin'] == 'Y')
521
+		if ($kind == 'admin' && $_SESSION['denied_admin'] == 'Y')
522 522
 		{
523 523
 			$this->_setInputErrorToContext();
524 524
 			$this->error = "msg_not_permitted_act";
@@ -530,13 +530,13 @@  discard block
 block discarded – undo
530 530
 		}
531 531
 
532 532
 		// if(type == view, and case for using mobilephone)
533
-		if($type == "view" && Mobile::isFromMobilePhone() && Context::isInstalled())
533
+		if ($type == "view" && Mobile::isFromMobilePhone() && Context::isInstalled())
534 534
 		{
535 535
 			$orig_type = "view";
536 536
 			$type = "mobile";
537 537
 			// create a module instance
538 538
 			$oModule = $this->getModuleInstance($this->module, $type, $kind);
539
-			if(!is_object($oModule) || !method_exists($oModule, $this->act))
539
+			if (!is_object($oModule) || !method_exists($oModule, $this->act))
540 540
 			{
541 541
 				$type = $orig_type;
542 542
 				Mobile::setMobile(FALSE);
@@ -549,14 +549,14 @@  discard block
 block discarded – undo
549 549
 			$oModule = $this->getModuleInstance($this->module, $type, $kind);
550 550
 		}
551 551
 
552
-		if(!is_object($oModule))
552
+		if (!is_object($oModule))
553 553
 		{
554 554
 			$this->_setInputErrorToContext();
555 555
 			$oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
556 556
 			$oMessageObject->setError(-1);
557 557
 			$oMessageObject->setMessage($this->error);
558 558
 			$oMessageObject->dispMessage();
559
-			if($this->httpStatusCode)
559
+			if ($this->httpStatusCode)
560 560
 			{
561 561
 				$oMessageObject->setHttpStatusCode($this->httpStatusCode);
562 562
 			}
@@ -564,10 +564,10 @@  discard block
 block discarded – undo
564 564
 		}
565 565
 
566 566
 		// If there is no such action in the module object
567
-		if(!isset($xml_info->action->{$this->act}) || !method_exists($oModule, $this->act))
567
+		if (!isset($xml_info->action->{$this->act}) || !method_exists($oModule, $this->act))
568 568
 		{
569 569
 
570
-			if(!Context::isInstalled())
570
+			if (!Context::isInstalled())
571 571
 			{
572 572
 				$this->_setInputErrorToContext();
573 573
 				$this->error = 'msg_invalid_request';
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
 				$oMessageObject->setError(-1);
576 576
 				$oMessageObject->setMessage($this->error);
577 577
 				$oMessageObject->dispMessage();
578
-				if($this->httpStatusCode)
578
+				if ($this->httpStatusCode)
579 579
 				{
580 580
 					$oMessageObject->setHttpStatusCode($this->httpStatusCode);
581 581
 				}
@@ -584,12 +584,12 @@  discard block
 block discarded – undo
584 584
 
585 585
 			$forward = NULL;
586 586
 			// 1. Look for the module with action name
587
-			if(preg_match('/^([a-z]+)([A-Z])([a-z0-9\_]+)(.*)$/', $this->act, $matches))
587
+			if (preg_match('/^([a-z]+)([A-Z])([a-z0-9\_]+)(.*)$/', $this->act, $matches))
588 588
 			{
589
-				$module = strtolower($matches[2] . $matches[3]);
589
+				$module = strtolower($matches[2].$matches[3]);
590 590
 				$xml_info = $oModuleModel->getModuleActionXml($module);
591 591
 
592
-				if($xml_info->action->{$this->act} && ((stripos($this->act, 'admin') !== FALSE) || $xml_info->action->{$this->act}->standalone != 'false'))
592
+				if ($xml_info->action->{$this->act} && ((stripos($this->act, 'admin') !== FALSE) || $xml_info->action->{$this->act}->standalone != 'false'))
593 593
 				{
594 594
 					$forward = new stdClass();
595 595
 					$forward->module = $module;
@@ -609,12 +609,12 @@  discard block
 block discarded – undo
609 609
 				}
610 610
 			}
611 611
 
612
-			if(!$forward)
612
+			if (!$forward)
613 613
 			{
614 614
 				$forward = $oModuleModel->getActionForward($this->act);
615 615
 			}
616 616
 
617
-			if($forward->module && $forward->type && $forward->act && $forward->act == $this->act)
617
+			if ($forward->module && $forward->type && $forward->act && $forward->act == $this->act)
618 618
 			{
619 619
 				$kind = stripos($forward->act, 'admin') !== FALSE ? 'admin' : '';
620 620
 				$type = $forward->type;
@@ -626,11 +626,11 @@  discard block
 block discarded – undo
626 626
 
627 627
 				// SECISSUE also check foward act method
628 628
 				// check REQUEST_METHOD in controller
629
-				if($type == 'controller')
629
+				if ($type == 'controller')
630 630
 				{
631 631
 					$allowedMethod = $xml_info->action->{$forward->act}->method;
632 632
 
633
-					if(!$allowedMethod)
633
+					if (!$allowedMethod)
634 634
 					{
635 635
 						$allowedMethodList[0] = 'POST';
636 636
 					}
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
 						$allowedMethodList = explode('|', strtoupper($allowedMethod));
640 640
 					}
641 641
 
642
-					if(!in_array(strtoupper($_SERVER['REQUEST_METHOD']), $allowedMethodList))
642
+					if (!in_array(strtoupper($_SERVER['REQUEST_METHOD']), $allowedMethodList))
643 643
 					{
644 644
 						$this->error = "msg_invalid_request";
645 645
 						$oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
@@ -650,13 +650,13 @@  discard block
 block discarded – undo
650 650
 					}
651 651
 				}
652 652
 
653
-				if($type == "view" && Mobile::isFromMobilePhone())
653
+				if ($type == "view" && Mobile::isFromMobilePhone())
654 654
 				{
655 655
 					$orig_type = "view";
656 656
 					$type = "mobile";
657 657
 					// create a module instance
658 658
 					$oModule = $this->getModuleInstance($forward->module, $type, $kind);
659
-					if(!is_object($oModule) || !method_exists($oModule, $this->act))
659
+					if (!is_object($oModule) || !method_exists($oModule, $this->act))
660 660
 					{
661 661
 						$type = $orig_type;
662 662
 						Mobile::setMobile(FALSE);
@@ -668,25 +668,25 @@  discard block
 block discarded – undo
668 668
 					$oModule = $this->getModuleInstance($forward->module, $type, $kind);
669 669
 				}
670 670
 
671
-				if(!is_object($oModule))
671
+				if (!is_object($oModule))
672 672
 				{
673 673
 					$this->_setInputErrorToContext();
674 674
 					$oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
675 675
 					$oMessageObject->setError(-1);
676 676
 					$oMessageObject->setMessage('msg_module_is_not_exists');
677 677
 					$oMessageObject->dispMessage();
678
-					if($this->httpStatusCode)
678
+					if ($this->httpStatusCode)
679 679
 					{
680 680
 						$oMessageObject->setHttpStatusCode($this->httpStatusCode);
681 681
 					}
682 682
 					return $oMessageObject;
683 683
 				}
684 684
 
685
-				if($this->module == "admin" && $type == "view")
685
+				if ($this->module == "admin" && $type == "view")
686 686
 				{
687
-					if($logged_info->is_admin == 'Y')
687
+					if ($logged_info->is_admin == 'Y')
688 688
 					{
689
-						if($this->act != 'dispLayoutAdminLayoutModify')
689
+						if ($this->act != 'dispLayoutAdminLayoutModify')
690 690
 						{
691 691
 							$oAdminView = getAdminView('admin');
692 692
 							$oAdminView->makeGnbUrl($forward->module);
@@ -706,10 +706,10 @@  discard block
 block discarded – undo
706 706
 						return $oMessageObject;
707 707
 					}
708 708
 				}
709
-				if($kind == 'admin')
709
+				if ($kind == 'admin')
710 710
 				{
711 711
 					$grant = $oModuleModel->getGrant($this->module_info, $logged_info);
712
-					if(!$grant->manager)
712
+					if (!$grant->manager)
713 713
 					{
714 714
 						$this->_setInputErrorToContext();
715 715
 						$this->error = 'msg_is_not_manager';
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
 					}
722 722
 					else
723 723
 					{
724
-						if(!$grant->is_admin && $this->module != $this->orig_module->module && $xml_info->permission->{$this->act} != 'manager')
724
+						if (!$grant->is_admin && $this->module != $this->orig_module->module && $xml_info->permission->{$this->act} != 'manager')
725 725
 						{
726 726
 							$this->_setInputErrorToContext();
727 727
 							$this->error = 'msg_is_not_administrator';
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
 					}
735 735
 				}
736 736
 			}
737
-			else if($xml_info->default_index_act && method_exists($oModule, $xml_info->default_index_act))
737
+			else if ($xml_info->default_index_act && method_exists($oModule, $xml_info->default_index_act))
738 738
 			{
739 739
 				$this->act = $xml_info->default_index_act;
740 740
 			}
@@ -748,16 +748,16 @@  discard block
 block discarded – undo
748 748
 		}
749 749
 
750 750
 		// ruleset check...
751
-		if(!empty($ruleset))
751
+		if (!empty($ruleset))
752 752
 		{
753 753
 			$rulesetModule = $forward->module ? $forward->module : $this->module;
754 754
 			$rulesetFile = $oModuleModel->getValidatorFilePath($rulesetModule, $ruleset, $this->mid);
755
-			if(!empty($rulesetFile))
755
+			if (!empty($rulesetFile))
756 756
 			{
757
-				if($_SESSION['XE_VALIDATOR_ERROR_LANG'])
757
+				if ($_SESSION['XE_VALIDATOR_ERROR_LANG'])
758 758
 				{
759 759
 					$errorLang = $_SESSION['XE_VALIDATOR_ERROR_LANG'];
760
-					foreach($errorLang as $key => $val)
760
+					foreach ($errorLang as $key => $val)
761 761
 					{
762 762
 						Context::setLang($key, $val);
763 763
 					}
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
 
767 767
 				$Validator = new Validator($rulesetFile);
768 768
 				$result = $Validator->validate();
769
-				if(!$result)
769
+				if (!$result)
770 770
 				{
771 771
 					$lastError = $Validator->getLastError();
772 772
 					$returnUrl = Context::get('error_return_url');
@@ -798,26 +798,26 @@  discard block
 block discarded – undo
798 798
 				'dispLayoutPreviewWithModule' => 1
799 799
 		);
800 800
 		$db_use_mobile = Mobile::isMobileEnabled();
801
-		if($type == "view" && $this->module_info->use_mobile == "Y" && Mobile::isMobileCheckByAgent() && !isset($skipAct[Context::get('act')]) && $db_use_mobile === true)
801
+		if ($type == "view" && $this->module_info->use_mobile == "Y" && Mobile::isMobileCheckByAgent() && !isset($skipAct[Context::get('act')]) && $db_use_mobile === true)
802 802
 		{
803 803
 			global $lang;
804 804
 			$header = '<style>div.xe_mobile{opacity:0.7;margin:1em 0;padding:.5em;background:#333;border:1px solid #666;border-left:0;border-right:0}p.xe_mobile{text-align:center;margin:1em 0}a.xe_mobile{color:#ff0;font-weight:bold;font-size:24px}@media only screen and (min-width:500px){a.xe_mobile{font-size:15px}}</style>';
805
-			$footer = '<div class="xe_mobile"><p class="xe_mobile"><a class="xe_mobile" href="' . getUrl('m', '1') . '">' . $lang->msg_pc_to_mobile . '</a></p></div>';
805
+			$footer = '<div class="xe_mobile"><p class="xe_mobile"><a class="xe_mobile" href="'.getUrl('m', '1').'">'.$lang->msg_pc_to_mobile.'</a></p></div>';
806 806
 			Context::addHtmlHeader($header);
807 807
 			Context::addHtmlFooter($footer);
808 808
 		}
809 809
 
810
-		if($type == "view" && $kind != 'admin')
810
+		if ($type == "view" && $kind != 'admin')
811 811
 		{
812 812
 			$module_config = $oModuleModel->getModuleConfig('module');
813
-			if($module_config->htmlFooter)
813
+			if ($module_config->htmlFooter)
814 814
 			{
815 815
 				Context::addHtmlFooter($module_config->htmlFooter);
816 816
 			}
817
-			if($module_config->siteTitle)
817
+			if ($module_config->siteTitle)
818 818
 			{
819 819
 				$siteTitle = Context::getBrowserTitle();
820
-				if(!$siteTitle)
820
+				if (!$siteTitle)
821 821
 				{
822 822
 					Context::setBrowserTitle($module_config->siteTitle);
823 823
 				}
@@ -830,18 +830,18 @@  discard block
 block discarded – undo
830 830
 		$procResult = $oModule->proc();
831 831
 
832 832
 		$methodList = array('XMLRPC' => 1, 'JSON' => 1, 'JS_CALLBACK' => 1);
833
-		if(!$oModule->stop_proc && !isset($methodList[Context::getRequestMethod()]))
833
+		if (!$oModule->stop_proc && !isset($methodList[Context::getRequestMethod()]))
834 834
 		{
835 835
 			$error = $oModule->getError();
836 836
 			$message = $oModule->getMessage();
837 837
 			$messageType = $oModule->getMessageType();
838 838
 			$redirectUrl = $oModule->getRedirectUrl();
839
-			if($messageType == 'error') debugPrint($message, 'ERROR');
839
+			if ($messageType == 'error') debugPrint($message, 'ERROR');
840 840
 
841
-			if(!$procResult)
841
+			if (!$procResult)
842 842
 			{
843 843
 				$this->error = $message;
844
-				if(!$redirectUrl && Context::get('error_return_url'))
844
+				if (!$redirectUrl && Context::get('error_return_url'))
845 845
 				{
846 846
 					$redirectUrl = Context::get('error_return_url');
847 847
 				}
@@ -854,13 +854,13 @@  discard block
 block discarded – undo
854 854
 
855 855
 			$_SESSION['XE_VALIDATOR_ERROR'] = $error;
856 856
 			$_SESSION['XE_VALIDATOR_ID'] = Context::get('xe_validator_id');
857
-			if($message != 'success')
857
+			if ($message != 'success')
858 858
 			{
859 859
 				$_SESSION['XE_VALIDATOR_MESSAGE'] = $message;
860 860
 			}
861 861
 			$_SESSION['XE_VALIDATOR_MESSAGE_TYPE'] = $messageType;
862 862
 
863
-			if(Context::get('xeVirtualRequestMethod') != 'xml')
863
+			if (Context::get('xeVirtualRequestMethod') != 'xml')
864 864
 			{
865 865
 				$_SESSION['XE_VALIDATOR_RETURN_URL'] = $redirectUrl;
866 866
 			}
@@ -876,27 +876,27 @@  discard block
 block discarded – undo
876 876
 	 * */
877 877
 	function _setInputErrorToContext()
878 878
 	{
879
-		if($_SESSION['XE_VALIDATOR_ERROR'] && !Context::get('XE_VALIDATOR_ERROR'))
879
+		if ($_SESSION['XE_VALIDATOR_ERROR'] && !Context::get('XE_VALIDATOR_ERROR'))
880 880
 		{
881 881
 			Context::set('XE_VALIDATOR_ERROR', $_SESSION['XE_VALIDATOR_ERROR']);
882 882
 		}
883
-		if($_SESSION['XE_VALIDATOR_MESSAGE'] && !Context::get('XE_VALIDATOR_MESSAGE'))
883
+		if ($_SESSION['XE_VALIDATOR_MESSAGE'] && !Context::get('XE_VALIDATOR_MESSAGE'))
884 884
 		{
885 885
 			Context::set('XE_VALIDATOR_MESSAGE', $_SESSION['XE_VALIDATOR_MESSAGE']);
886 886
 		}
887
-		if($_SESSION['XE_VALIDATOR_MESSAGE_TYPE'] && !Context::get('XE_VALIDATOR_MESSAGE_TYPE'))
887
+		if ($_SESSION['XE_VALIDATOR_MESSAGE_TYPE'] && !Context::get('XE_VALIDATOR_MESSAGE_TYPE'))
888 888
 		{
889 889
 			Context::set('XE_VALIDATOR_MESSAGE_TYPE', $_SESSION['XE_VALIDATOR_MESSAGE_TYPE']);
890 890
 		}
891
-		if($_SESSION['XE_VALIDATOR_RETURN_URL'] && !Context::get('XE_VALIDATOR_RETURN_URL'))
891
+		if ($_SESSION['XE_VALIDATOR_RETURN_URL'] && !Context::get('XE_VALIDATOR_RETURN_URL'))
892 892
 		{
893 893
 			Context::set('XE_VALIDATOR_RETURN_URL', $_SESSION['XE_VALIDATOR_RETURN_URL']);
894 894
 		}
895
-		if($_SESSION['XE_VALIDATOR_ID'] && !Context::get('XE_VALIDATOR_ID'))
895
+		if ($_SESSION['XE_VALIDATOR_ID'] && !Context::get('XE_VALIDATOR_ID'))
896 896
 		{
897 897
 			Context::set('XE_VALIDATOR_ID', $_SESSION['XE_VALIDATOR_ID']);
898 898
 		}
899
-		if(count($_SESSION['INPUT_ERROR']))
899
+		if (count($_SESSION['INPUT_ERROR']))
900 900
 		{
901 901
 			Context::set('INPUT_ERROR', $_SESSION['INPUT_ERROR']);
902 902
 		}
@@ -926,7 +926,7 @@  discard block
 block discarded – undo
926 926
 	{
927 927
 		$requestVars = Context::getRequestVars();
928 928
 		unset($requestVars->act, $requestVars->mid, $requestVars->vid, $requestVars->success_return_url, $requestVars->error_return_url);
929
-		foreach($requestVars AS $key => $value)
929
+		foreach ($requestVars AS $key => $value)
930 930
 		{
931 931
 			$_SESSION['INPUT_ERROR'][$key] = $value;
932 932
 		}
@@ -940,41 +940,41 @@  discard block
 block discarded – undo
940 940
 	function displayContent($oModule = NULL)
941 941
 	{
942 942
 		// If the module is not set or not an object, set error
943
-		if(!$oModule || !is_object($oModule))
943
+		if (!$oModule || !is_object($oModule))
944 944
 		{
945 945
 			$this->error = 'msg_module_is_not_exists';
946 946
 			$this->httpStatusCode = '404';
947 947
 		}
948 948
 
949 949
 		// If connection to DB has a problem even though it's not install module, set error
950
-		if($this->module != 'install' && isset($GLOBALS['__DB__']) && $GLOBALS['__DB__'][Context::getDBType()]->isConnected() == FALSE)
950
+		if ($this->module != 'install' && isset($GLOBALS['__DB__']) && $GLOBALS['__DB__'][Context::getDBType()]->isConnected() == FALSE)
951 951
 		{
952 952
 			$this->error = 'msg_dbconnect_failed';
953 953
 		}
954 954
 
955 955
 		// Call trigger after moduleHandler proc
956 956
 		$output = ModuleHandler::triggerCall('moduleHandler.proc', 'after', $oModule);
957
-		if(!$output->toBool())
957
+		if (!$output->toBool())
958 958
 		{
959 959
 			$this->error = $output->getMessage();
960 960
 		}
961 961
 
962 962
 		// Use message view object, if HTML call
963 963
 		$methodList = array('XMLRPC' => 1, 'JSON' => 1, 'JS_CALLBACK' => 1);
964
-		if(!isset($methodList[Context::getRequestMethod()]))
964
+		if (!isset($methodList[Context::getRequestMethod()]))
965 965
 		{
966 966
 
967
-			if($_SESSION['XE_VALIDATOR_RETURN_URL'])
967
+			if ($_SESSION['XE_VALIDATOR_RETURN_URL'])
968 968
 			{
969 969
 				$display_handler = new DisplayHandler();
970 970
 				$display_handler->_debugOutput();
971 971
 
972
-				header('location:' . $_SESSION['XE_VALIDATOR_RETURN_URL']);
972
+				header('location:'.$_SESSION['XE_VALIDATOR_RETURN_URL']);
973 973
 				return;
974 974
 			}
975 975
 
976 976
 			// If error occurred, handle it
977
-			if($this->error)
977
+			if ($this->error)
978 978
 			{
979 979
 				// display content with message module instance
980 980
 				$type = Mobile::isFromMobilePhone() ? 'mobile' : 'view';
@@ -983,14 +983,14 @@  discard block
 block discarded – undo
983 983
 				$oMessageObject->setMessage($this->error);
984 984
 				$oMessageObject->dispMessage();
985 985
 
986
-				if($oMessageObject->getHttpStatusCode() && $oMessageObject->getHttpStatusCode() != '200')
986
+				if ($oMessageObject->getHttpStatusCode() && $oMessageObject->getHttpStatusCode() != '200')
987 987
 				{
988 988
 					$this->_setHttpStatusMessage($oMessageObject->getHttpStatusCode());
989 989
 					$oMessageObject->setTemplateFile('http_status_code');
990 990
 				}
991 991
 
992 992
 				// If module was called normally, change the templates of the module into ones of the message view module
993
-				if($oModule)
993
+				if ($oModule)
994 994
 				{
995 995
 					$oModule->setTemplatePath($oMessageObject->getTemplatePath());
996 996
 					$oModule->setTemplateFile($oMessageObject->getTemplateFile());
@@ -1005,7 +1005,7 @@  discard block
 block discarded – undo
1005 1005
 			}
1006 1006
 
1007 1007
 			// Check if layout_srl exists for the module
1008
-			if(Mobile::isFromMobilePhone())
1008
+			if (Mobile::isFromMobilePhone())
1009 1009
 			{
1010 1010
 				$layout_srl = $oModule->module_info->mlayout_srl;
1011 1011
 			}
@@ -1015,58 +1015,58 @@  discard block
 block discarded – undo
1015 1015
 			}
1016 1016
 
1017 1017
 			// if layout_srl is rollback by module, set default layout
1018
-			if($layout_srl == -1)
1018
+			if ($layout_srl == -1)
1019 1019
 			{
1020 1020
 				$viewType = (Mobile::isFromMobilePhone()) ? 'M' : 'P';
1021 1021
 				$oLayoutAdminModel = getAdminModel('layout');
1022 1022
 				$layout_srl = $oLayoutAdminModel->getSiteDefaultLayout($viewType, $oModule->module_info->site_srl);
1023 1023
 			}
1024 1024
 
1025
-			if($layout_srl && !$oModule->getLayoutFile())
1025
+			if ($layout_srl && !$oModule->getLayoutFile())
1026 1026
 			{
1027 1027
 
1028 1028
 				// If layout_srl exists, get information of the layout, and set the location of layout_path/ layout_file
1029 1029
 				$oLayoutModel = getModel('layout');
1030 1030
 				$layout_info = $oLayoutModel->getLayout($layout_srl);
1031
-				if($layout_info)
1031
+				if ($layout_info)
1032 1032
 				{
1033 1033
 
1034 1034
 					// Input extra_vars into $layout_info
1035
-					if($layout_info->extra_var_count)
1035
+					if ($layout_info->extra_var_count)
1036 1036
 					{
1037 1037
 
1038
-						foreach($layout_info->extra_var as $var_id => $val)
1038
+						foreach ($layout_info->extra_var as $var_id => $val)
1039 1039
 						{
1040
-							if($val->type == 'image')
1040
+							if ($val->type == 'image')
1041 1041
 							{
1042
-								if(strncmp('./files/attach/images/', $val->value, 22) === 0)
1042
+								if (strncmp('./files/attach/images/', $val->value, 22) === 0)
1043 1043
 								{
1044
-									$val->value = Context::getRequestUri() . substr($val->value, 2);
1044
+									$val->value = Context::getRequestUri().substr($val->value, 2);
1045 1045
 								}
1046 1046
 							}
1047 1047
 							$layout_info->{$var_id} = $val->value;
1048 1048
 						}
1049 1049
 					}
1050 1050
 					// Set menus into context
1051
-					if($layout_info->menu_count)
1051
+					if ($layout_info->menu_count)
1052 1052
 					{
1053
-						foreach($layout_info->menu as $menu_id => $menu)
1053
+						foreach ($layout_info->menu as $menu_id => $menu)
1054 1054
 						{
1055 1055
 							// set default menu set(included home menu)
1056
-							if(!$menu->menu_srl || $menu->menu_srl == -1)
1056
+							if (!$menu->menu_srl || $menu->menu_srl == -1)
1057 1057
 							{
1058 1058
 								$oMenuAdminController = getAdminController('menu');
1059 1059
 								$homeMenuCacheFile = $oMenuAdminController->getHomeMenuCacheFile();
1060 1060
 
1061
-								if(FileHandler::exists($homeMenuCacheFile))
1061
+								if (FileHandler::exists($homeMenuCacheFile))
1062 1062
 								{
1063 1063
 									include($homeMenuCacheFile);
1064 1064
 								}
1065 1065
 
1066
-								if(!$menu->menu_srl)
1066
+								if (!$menu->menu_srl)
1067 1067
 								{
1068
-									$menu->xml_file = str_replace('.xml.php', $homeMenuSrl . '.xml.php', $menu->xml_file);
1069
-									$menu->php_file = str_replace('.php', $homeMenuSrl . '.php', $menu->php_file);
1068
+									$menu->xml_file = str_replace('.xml.php', $homeMenuSrl.'.xml.php', $menu->xml_file);
1069
+									$menu->php_file = str_replace('.php', $homeMenuSrl.'.php', $menu->php_file);
1070 1070
 									$layout_info->menu->{$menu_id}->menu_srl = $homeMenuSrl;
1071 1071
 								}
1072 1072
 								else
@@ -1077,7 +1077,7 @@  discard block
 block discarded – undo
1077 1077
 							}
1078 1078
 
1079 1079
 							$php_file = FileHandler::exists($menu->php_file);
1080
-							if($php_file)
1080
+							if ($php_file)
1081 1081
 							{
1082 1082
 								include($php_file);
1083 1083
 							}
@@ -1093,17 +1093,17 @@  discard block
 block discarded – undo
1093 1093
 
1094 1094
 					// If layout was modified, use the modified version
1095 1095
 					$edited_layout = $oLayoutModel->getUserLayoutHtml($layout_info->layout_srl);
1096
-					if(file_exists($edited_layout))
1096
+					if (file_exists($edited_layout))
1097 1097
 					{
1098 1098
 						$oModule->setEditedLayoutFile($edited_layout);
1099 1099
 					}
1100 1100
 				}
1101 1101
 			}
1102 1102
 			$isLayoutDrop = Context::get('isLayoutDrop');
1103
-			if($isLayoutDrop)
1103
+			if ($isLayoutDrop)
1104 1104
 			{
1105 1105
 				$kind = stripos($this->act, 'admin') !== FALSE ? 'admin' : '';
1106
-				if($kind == 'admin')
1106
+				if ($kind == 'admin')
1107 1107
 				{
1108 1108
 					$oModule->setLayoutFile('popup_layout');
1109 1109
 				}
@@ -1141,7 +1141,7 @@  discard block
 block discarded – undo
1141 1141
 	function &getModuleInstance($module, $type = 'view', $kind = '')
1142 1142
 	{
1143 1143
 
1144
-		if(__DEBUG__ == 3)
1144
+		if (__DEBUG__ == 3)
1145 1145
 		{
1146 1146
 			$start_time = getMicroTime();
1147 1147
 		}
@@ -1151,51 +1151,51 @@  discard block
 block discarded – undo
1151 1151
 		$type = strtolower($type);
1152 1152
 
1153 1153
 		$kinds = array('svc' => 1, 'admin' => 1);
1154
-		if(!isset($kinds[$kind]))
1154
+		if (!isset($kinds[$kind]))
1155 1155
 		{
1156 1156
 			$kind = 'svc';
1157 1157
 		}
1158 1158
 
1159
-		$key = $module . '.' . ($kind != 'admin' ? '' : 'admin') . '.' . $type;
1159
+		$key = $module.'.'.($kind != 'admin' ? '' : 'admin').'.'.$type;
1160 1160
 
1161
-		if(is_array($GLOBALS['__MODULE_EXTEND__']) && array_key_exists($key, $GLOBALS['__MODULE_EXTEND__']))
1161
+		if (is_array($GLOBALS['__MODULE_EXTEND__']) && array_key_exists($key, $GLOBALS['__MODULE_EXTEND__']))
1162 1162
 		{
1163 1163
 			$module = $extend_module = $GLOBALS['__MODULE_EXTEND__'][$key];
1164 1164
 		}
1165 1165
 
1166 1166
 		// if there is no instance of the module in global variable, create a new one
1167
-		if(!isset($GLOBALS['_loaded_module'][$module][$type][$kind]))
1167
+		if (!isset($GLOBALS['_loaded_module'][$module][$type][$kind]))
1168 1168
 		{
1169 1169
 			ModuleHandler::_getModuleFilePath($module, $type, $kind, $class_path, $high_class_file, $class_file, $instance_name);
1170 1170
 
1171
-			if($extend_module && (!is_readable($high_class_file) || !is_readable($class_file)))
1171
+			if ($extend_module && (!is_readable($high_class_file) || !is_readable($class_file)))
1172 1172
 			{
1173 1173
 				$module = $parent_module;
1174 1174
 				ModuleHandler::_getModuleFilePath($module, $type, $kind, $class_path, $high_class_file, $class_file, $instance_name);
1175 1175
 			}
1176 1176
 
1177 1177
 			// Check if the base class and instance class exist
1178
-			if(!class_exists($module, true))
1178
+			if (!class_exists($module, true))
1179 1179
 			{
1180 1180
 				return NULL;
1181 1181
 			}
1182
-			if(!class_exists($instance_name, true))
1182
+			if (!class_exists($instance_name, true))
1183 1183
 			{
1184 1184
 				return NULL;
1185 1185
 			}
1186 1186
 
1187 1187
 			// Create an instance
1188 1188
 			$oModule = new $instance_name();
1189
-			if(!is_object($oModule))
1189
+			if (!is_object($oModule))
1190 1190
 			{
1191 1191
 				return NULL;
1192 1192
 			}
1193 1193
 
1194 1194
 			// Load language files for the class
1195
-			Context::loadLang($class_path . 'lang');
1196
-			if($extend_module)
1195
+			Context::loadLang($class_path.'lang');
1196
+			if ($extend_module)
1197 1197
 			{
1198
-				Context::loadLang(ModuleHandler::getModulePath($parent_module) . 'lang');
1198
+				Context::loadLang(ModuleHandler::getModulePath($parent_module).'lang');
1199 1199
 			}
1200 1200
 
1201 1201
 			// Set variables to the instance
@@ -1203,10 +1203,10 @@  discard block
 block discarded – undo
1203 1203
 			$oModule->setModulePath($class_path);
1204 1204
 
1205 1205
 			// If the module has a constructor, run it.
1206
-			if(!isset($GLOBALS['_called_constructor'][$instance_name]))
1206
+			if (!isset($GLOBALS['_called_constructor'][$instance_name]))
1207 1207
 			{
1208 1208
 				$GLOBALS['_called_constructor'][$instance_name] = TRUE;
1209
-				if(@method_exists($oModule, $instance_name))
1209
+				if (@method_exists($oModule, $instance_name))
1210 1210
 				{
1211 1211
 					$oModule->{$instance_name}();
1212 1212
 				}
@@ -1216,7 +1216,7 @@  discard block
 block discarded – undo
1216 1216
 			$GLOBALS['_loaded_module'][$module][$type][$kind] = $oModule;
1217 1217
 		}
1218 1218
 
1219
-		if(__DEBUG__ == 3)
1219
+		if (__DEBUG__ == 3)
1220 1220
 		{
1221 1221
 			$GLOBALS['__elapsed_class_load__'] += getMicroTime() - $start_time;
1222 1222
 		}
@@ -1232,17 +1232,17 @@  discard block
 block discarded – undo
1232 1232
 		$highClassFile = sprintf('%s%s%s.class.php', _XE_PATH_, $classPath, $module);
1233 1233
 		$highClassFile = FileHandler::getRealPath($highClassFile);
1234 1234
 
1235
-		$types = array('view','controller','model','api','wap','mobile','class');
1236
-		if(!in_array($type, $types))
1235
+		$types = array('view', 'controller', 'model', 'api', 'wap', 'mobile', 'class');
1236
+		if (!in_array($type, $types))
1237 1237
 		{
1238 1238
 			$type = $types[0];
1239 1239
 		}
1240
-		if($type == 'class')
1240
+		if ($type == 'class')
1241 1241
 		{
1242 1242
 			$instanceName = '%s';
1243 1243
 			$classFile = '%s%s.%s.php';
1244 1244
 		}
1245
-		elseif($kind == 'admin' && array_search($type, $types) < 3)
1245
+		elseif ($kind == 'admin' && array_search($type, $types) < 3)
1246 1246
 		{
1247 1247
 			$instanceName = '%sAdmin%s';
1248 1248
 			$classFile = '%s%s.admin.%s.php';
@@ -1267,26 +1267,26 @@  discard block
 block discarded – undo
1267 1267
 	function triggerCall($trigger_name, $called_position, &$obj)
1268 1268
 	{
1269 1269
 		// skip if not installed
1270
-		if(!Context::isInstalled())
1270
+		if (!Context::isInstalled())
1271 1271
 		{
1272 1272
 			return new Object();
1273 1273
 		}
1274 1274
 
1275 1275
 		$oModuleModel = getModel('module');
1276 1276
 		$triggers = $oModuleModel->getTriggers($trigger_name, $called_position);
1277
-		if(!$triggers || count($triggers) < 1)
1277
+		if (!$triggers || count($triggers) < 1)
1278 1278
 		{
1279 1279
 			return new Object();
1280 1280
 		}
1281 1281
 		
1282 1282
 		//store before trigger call time
1283 1283
 		$before_trigger_time = NULL;
1284
-		if(__LOG_SLOW_TRIGGER__> 0)
1284
+		if (__LOG_SLOW_TRIGGER__ > 0)
1285 1285
 		{
1286 1286
 			$before_trigger_time = microtime(true);
1287 1287
 		}
1288 1288
 
1289
-		foreach($triggers as $item)
1289
+		foreach ($triggers as $item)
1290 1290
 		{
1291 1291
 			$module = $item->module;
1292 1292
 			$type = $item->type;
@@ -1294,7 +1294,7 @@  discard block
 block discarded – undo
1294 1294
 
1295 1295
 			// todo why don't we call a normal class object ?
1296 1296
 			$oModule = getModule($module, $type);
1297
-			if(!$oModule || !method_exists($oModule, $called_method))
1297
+			if (!$oModule || !method_exists($oModule, $called_method))
1298 1298
 			{
1299 1299
 				continue;
1300 1300
 			}
@@ -1307,12 +1307,12 @@  discard block
 block discarded – undo
1307 1307
 			$elapsed_time_trigger = $after_each_trigger_time - $before_each_trigger_time;
1308 1308
 
1309 1309
 			$slowlog = new stdClass;
1310
-			$slowlog->caller = $trigger_name . '.' . $called_position;
1311
-			$slowlog->called = $module . '.' . $called_method;
1310
+			$slowlog->caller = $trigger_name.'.'.$called_position;
1311
+			$slowlog->called = $module.'.'.$called_method;
1312 1312
 			$slowlog->called_extension = $module;
1313
-			if($trigger_name != 'XE.writeSlowlog') writeSlowlog('trigger', $elapsed_time_trigger, $slowlog);
1313
+			if ($trigger_name != 'XE.writeSlowlog') writeSlowlog('trigger', $elapsed_time_trigger, $slowlog);
1314 1314
 
1315
-			if(is_object($output) && method_exists($output, 'toBool') && !$output->toBool())
1315
+			if (is_object($output) && method_exists($output, 'toBool') && !$output->toBool())
1316 1316
 			{
1317 1317
 				return $output;
1318 1318
 			}
@@ -1397,9 +1397,9 @@  discard block
 block discarded – undo
1397 1397
 			'511' => 'Network Authentication Required',
1398 1398
 		);
1399 1399
 		$statusMessage = $statusMessageList[$code];
1400
-		if(!$statusMessage)
1400
+		if (!$statusMessage)
1401 1401
 		{
1402
-			$statusMessage = 'HTTP ' . $code;
1402
+			$statusMessage = 'HTTP '.$code;
1403 1403
 		}
1404 1404
 
1405 1405
 		Context::set('http_status_code', $code);
Please login to merge, or discard this patch.
modules/document/document.controller.php 1 patch
Spacing   +367 added lines, -367 removed lines patch added patch discarded remove patch
@@ -24,19 +24,19 @@  discard block
 block discarded – undo
24 24
 	 */
25 25
 	function procDocumentVoteUp()
26 26
 	{
27
-		if(!Context::get('is_logged')) return new Object(-1, 'msg_invalid_request');
27
+		if (!Context::get('is_logged')) return new Object(-1, 'msg_invalid_request');
28 28
 
29 29
 		$document_srl = Context::get('target_srl');
30
-		if(!$document_srl) return new Object(-1, 'msg_invalid_request');
30
+		if (!$document_srl) return new Object(-1, 'msg_invalid_request');
31 31
 
32 32
 		$oDocumentModel = getModel('document');
33 33
 		$oDocument = $oDocumentModel->getDocument($document_srl, false, false);
34 34
 		$module_srl = $oDocument->get('module_srl');
35
-		if(!$module_srl) return new Object(-1, 'msg_invalid_request');
35
+		if (!$module_srl) return new Object(-1, 'msg_invalid_request');
36 36
 
37 37
 		$oModuleModel = getModel('module');
38
-		$document_config = $oModuleModel->getModulePartConfig('document',$module_srl);
39
-		if($document_config->use_vote_up=='N') return new Object(-1, 'msg_invalid_request');
38
+		$document_config = $oModuleModel->getModulePartConfig('document', $module_srl);
39
+		if ($document_config->use_vote_up == 'N') return new Object(-1, 'msg_invalid_request');
40 40
 
41 41
 		$point = 1;
42 42
 		$output = $this->updateVotedCount($document_srl, $point);
@@ -69,19 +69,19 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	function procDocumentVoteDown()
71 71
 	{
72
-		if(!Context::get('is_logged')) return new Object(-1, 'msg_invalid_request');
72
+		if (!Context::get('is_logged')) return new Object(-1, 'msg_invalid_request');
73 73
 
74 74
 		$document_srl = Context::get('target_srl');
75
-		if(!$document_srl) return new Object(-1, 'msg_invalid_request');
75
+		if (!$document_srl) return new Object(-1, 'msg_invalid_request');
76 76
 
77 77
 		$oDocumentModel = getModel('document');
78 78
 		$oDocument = $oDocumentModel->getDocument($document_srl, false, false);
79 79
 		$module_srl = $oDocument->get('module_srl');
80
-		if(!$module_srl) return new Object(-1, 'msg_invalid_request');
80
+		if (!$module_srl) return new Object(-1, 'msg_invalid_request');
81 81
 
82 82
 		$oModuleModel = getModel('module');
83
-		$document_config = $oModuleModel->getModulePartConfig('document',$module_srl);
84
-		if($document_config->use_vote_down=='N') return new Object(-1, 'msg_invalid_request');
83
+		$document_config = $oModuleModel->getModulePartConfig('document', $module_srl);
84
+		if ($document_config->use_vote_down == 'N') return new Object(-1, 'msg_invalid_request');
85 85
 
86 86
 		$point = -1;
87 87
 		$output = $this->updateVotedCount($document_srl, $point);
@@ -95,10 +95,10 @@  discard block
 block discarded – undo
95 95
 	 */
96 96
 	function procDocumentDeclare()
97 97
 	{
98
-		if(!Context::get('is_logged')) return new Object(-1, 'msg_invalid_request');
98
+		if (!Context::get('is_logged')) return new Object(-1, 'msg_invalid_request');
99 99
 
100 100
 		$document_srl = Context::get('target_srl');
101
-		if(!$document_srl) return new Object(-1, 'msg_invalid_request');
101
+		if (!$document_srl) return new Object(-1, 'msg_invalid_request');
102 102
 
103 103
 		return $this->declaredDocument($document_srl);
104 104
 	}
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 		$args->history_srl = $history_srl;
141 141
 		$args->module_srl = $module_srl;
142 142
 		$args->document_srl = $document_srl;
143
-		if(!$args->history_srl && !$args->module_srl && !$args->document_srl) return;
143
+		if (!$args->history_srl && !$args->module_srl && !$args->document_srl) return;
144 144
 		executeQuery("document.deleteHistory", $args);
145 145
 	}
146 146
 
@@ -152,15 +152,15 @@  discard block
 block discarded – undo
152 152
 	function triggerDeleteModuleDocuments(&$obj)
153 153
 	{
154 154
 		$module_srl = $obj->module_srl;
155
-		if(!$module_srl) return new Object();
155
+		if (!$module_srl) return new Object();
156 156
 		// Delete the document
157 157
 		$oDocumentAdminController = getAdminController('document');
158 158
 		$output = $oDocumentAdminController->deleteModuleDocument($module_srl);
159
-		if(!$output->toBool()) return $output;
159
+		if (!$output->toBool()) return $output;
160 160
 		// Delete the category
161 161
 		$oDocumentController = getController('document');
162 162
 		$output = $oDocumentController->deleteModuleCategory($module_srl);
163
-		if(!$output->toBool()) return $output;
163
+		if (!$output->toBool()) return $output;
164 164
 		// Delete extra key and variable, because module deleted
165 165
 		$this->deleteDocumentExtraKeys($module_srl);
166 166
 
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	 */
194 194
 	function insertDocument($obj, $manual_inserted = false, $isRestore = false, $isLatest = true)
195 195
 	{
196
-		if(!$manual_inserted && !checkCSRF())
196
+		if (!$manual_inserted && !checkCSRF())
197 197
 		{
198 198
 			return new Object(-1, 'msg_invalid_request');
199 199
 		}
@@ -202,32 +202,32 @@  discard block
 block discarded – undo
202 202
 		$oDB = &DB::getInstance();
203 203
 		$oDB->begin();
204 204
 		// List variables
205
-		if($obj->comment_status) $obj->commentStatus = $obj->comment_status;
206
-		if(!$obj->commentStatus) $obj->commentStatus = 'DENY';
207
-		if($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj);
208
-		if($obj->allow_trackback!='Y') $obj->allow_trackback = 'N';
209
-		if($obj->homepage) 
205
+		if ($obj->comment_status) $obj->commentStatus = $obj->comment_status;
206
+		if (!$obj->commentStatus) $obj->commentStatus = 'DENY';
207
+		if ($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj);
208
+		if ($obj->allow_trackback != 'Y') $obj->allow_trackback = 'N';
209
+		if ($obj->homepage) 
210 210
 		{
211 211
 			$obj->homepage = removeHackTag($obj->homepage);
212
-			if(!preg_match('/^[a-z]+:\/\//i',$obj->homepage))
212
+			if (!preg_match('/^[a-z]+:\/\//i', $obj->homepage))
213 213
 			{
214 214
 				$obj->homepage = 'http://'.$obj->homepage;
215 215
 			}
216 216
 		}
217 217
 		
218
-		if($obj->notify_message != 'Y') $obj->notify_message = 'N';
219
-		if(!$obj->email_address) $obj->email_address = '';
220
-		if(!$isRestore) $obj->ipaddress = $_SERVER['REMOTE_ADDR'];
218
+		if ($obj->notify_message != 'Y') $obj->notify_message = 'N';
219
+		if (!$obj->email_address) $obj->email_address = '';
220
+		if (!$isRestore) $obj->ipaddress = $_SERVER['REMOTE_ADDR'];
221 221
 
222 222
                 // can modify regdate only manager
223 223
                 $grant = Context::get('grant');
224
-		if(!$grant->manager)
224
+		if (!$grant->manager)
225 225
 		{
226 226
 			unset($obj->regdate);
227 227
 		}
228 228
 		
229 229
 		// Serialize the $extra_vars, check the extra_vars type, because duplicate serialized avoid
230
-		if(!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars);
230
+		if (!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars);
231 231
 		// Remove the columns for automatic saving
232 232
 		unset($obj->_saved_doc_srl);
233 233
 		unset($obj->_saved_doc_title);
@@ -235,34 +235,34 @@  discard block
 block discarded – undo
235 235
 		unset($obj->_saved_doc_message);
236 236
 		// Call a trigger (before)
237 237
 		$output = ModuleHandler::triggerCall('document.insertDocument', 'before', $obj);
238
-		if(!$output->toBool()) return $output;
238
+		if (!$output->toBool()) return $output;
239 239
 		// Register it if no given document_srl exists
240
-		if(!$obj->document_srl) $obj->document_srl = getNextSequence();
241
-		elseif(!$manual_inserted && !$isRestore && !checkUserSequence($obj->document_srl)) return new Object(-1, 'msg_not_permitted');
240
+		if (!$obj->document_srl) $obj->document_srl = getNextSequence();
241
+		elseif (!$manual_inserted && !$isRestore && !checkUserSequence($obj->document_srl)) return new Object(-1, 'msg_not_permitted');
242 242
 
243 243
 		$oDocumentModel = getModel('document');
244 244
 		// Set to 0 if the category_srl doesn't exist
245
-		if($obj->category_srl)
245
+		if ($obj->category_srl)
246 246
 		{
247 247
 			$category_list = $oDocumentModel->getCategoryList($obj->module_srl);
248
-			if(count($category_list) > 0 && !$category_list[$obj->category_srl]->grant)
248
+			if (count($category_list) > 0 && !$category_list[$obj->category_srl]->grant)
249 249
 			{
250 250
 				return new Object(-1, 'msg_not_permitted');
251 251
 			}
252
-			if(count($category_list) > 0 && !$category_list[$obj->category_srl]) $obj->category_srl = 0;
252
+			if (count($category_list) > 0 && !$category_list[$obj->category_srl]) $obj->category_srl = 0;
253 253
 		}
254 254
 		// Set the read counts and update order.
255
-		if(!$obj->readed_count) $obj->readed_count = 0;
256
-		if($isLatest) $obj->update_order = $obj->list_order = $obj->document_srl * -1;
255
+		if (!$obj->readed_count) $obj->readed_count = 0;
256
+		if ($isLatest) $obj->update_order = $obj->list_order = $obj->document_srl * -1;
257 257
 		else $obj->update_order = $obj->list_order;
258 258
 		// Check the status of password hash for manually inserting. Apply hashing for otherwise.
259
-		if($obj->password && !$obj->password_is_hashed)
259
+		if ($obj->password && !$obj->password_is_hashed)
260 260
 		{
261 261
 			$obj->password = getModel('member')->hashPassword($obj->password);
262 262
 		}
263 263
 		// Insert member's information only if the member is logged-in and not manually registered.
264 264
 		$logged_info = Context::get('logged_info');
265
-		if(Context::get('is_logged') && !$manual_inserted && !$isRestore)
265
+		if (Context::get('is_logged') && !$manual_inserted && !$isRestore)
266 266
 		{
267 267
 			$obj->member_srl = $logged_info->member_srl;
268 268
 
@@ -276,61 +276,61 @@  discard block
 block discarded – undo
276 276
 		// If the tile is empty, extract string from the contents.
277 277
 		$obj->title = htmlspecialchars($obj->title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
278 278
 		settype($obj->title, "string");
279
-		if($obj->title == '') $obj->title = cut_str(trim(strip_tags(nl2br($obj->content))),20,'...');
279
+		if ($obj->title == '') $obj->title = cut_str(trim(strip_tags(nl2br($obj->content))), 20, '...');
280 280
 		// If no tile extracted from the contents, leave it untitled.
281
-		if($obj->title == '') $obj->title = 'Untitled';
281
+		if ($obj->title == '') $obj->title = 'Untitled';
282 282
 		// Remove XE's own tags from the contents.
283 283
 		$obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content);
284
-		if(Mobile::isFromMobilePhone())
284
+		if (Mobile::isFromMobilePhone())
285 285
 		{
286
-			if($obj->use_html != 'Y')
286
+			if ($obj->use_html != 'Y')
287 287
 			{
288 288
 				$obj->content = htmlspecialchars($obj->content, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
289 289
 			}
290 290
 			$obj->content = nl2br($obj->content);
291 291
 		}
292 292
 		// Remove iframe and script if not a top adminisrator in the session.
293
-		if($logged_info->is_admin != 'Y') $obj->content = removeHackTag($obj->content);
293
+		if ($logged_info->is_admin != 'Y') $obj->content = removeHackTag($obj->content);
294 294
 		// An error appears if both log-in info and user name don't exist.
295
-		if(!$logged_info->member_srl && !$obj->nick_name) return new Object(-1,'msg_invalid_request');
295
+		if (!$logged_info->member_srl && !$obj->nick_name) return new Object(-1, 'msg_invalid_request');
296 296
 
297 297
 		$obj->lang_code = Context::getLangType();
298 298
 		// Insert data into the DB
299
-		if(!$obj->status) $this->_checkDocumentStatusForOldVersion($obj);
299
+		if (!$obj->status) $this->_checkDocumentStatusForOldVersion($obj);
300 300
 		$output = executeQuery('document.insertDocument', $obj);
301
-		if(!$output->toBool())
301
+		if (!$output->toBool())
302 302
 		{
303 303
 			$oDB->rollback();
304 304
 			return $output;
305 305
 		}
306 306
 		// Insert extra variables if the document successfully inserted.
307 307
 		$extra_keys = $oDocumentModel->getExtraKeys($obj->module_srl);
308
-		if(count($extra_keys))
308
+		if (count($extra_keys))
309 309
 		{
310
-			foreach($extra_keys as $idx => $extra_item)
310
+			foreach ($extra_keys as $idx => $extra_item)
311 311
 			{
312 312
 				$value = NULL;
313
-				if(isset($obj->{'extra_vars'.$idx}))
313
+				if (isset($obj->{'extra_vars'.$idx}))
314 314
 				{
315 315
 					$tmp = $obj->{'extra_vars'.$idx};
316
-					if(is_array($tmp))
316
+					if (is_array($tmp))
317 317
 						$value = implode('|@|', $tmp);
318 318
 					else
319 319
 						$value = trim($tmp);
320 320
 				}
321
-				else if(isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name});
322
-				if($value == NULL) continue;
321
+				else if (isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name});
322
+				if ($value == NULL) continue;
323 323
 
324 324
 				$this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid);
325 325
 			}
326 326
 		}
327 327
 		// Update the category if the category_srl exists.
328
-		if($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl);
328
+		if ($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl);
329 329
 		// Call a trigger (after)
330
-		if($output->toBool())
330
+		if ($output->toBool())
331 331
 		{
332 332
 			$trigger_output = ModuleHandler::triggerCall('document.insertDocument', 'after', $obj);
333
-			if(!$trigger_output->toBool())
333
+			if (!$trigger_output->toBool())
334 334
 			{
335 335
 				$oDB->rollback();
336 336
 				return $trigger_output;
@@ -341,12 +341,12 @@  discard block
 block discarded – undo
341 341
 		$oDB->commit();
342 342
 
343 343
 		// return
344
-		if(!$manual_inserted)
344
+		if (!$manual_inserted)
345 345
 		{
346 346
 			$this->addGrant($obj->document_srl);
347 347
 		}
348
-		$output->add('document_srl',$obj->document_srl);
349
-		$output->add('category_srl',$obj->category_srl);
348
+		$output->add('document_srl', $obj->document_srl);
349
+		$output->add('category_srl', $obj->category_srl);
350 350
 
351 351
 		return $output;
352 352
 	}
@@ -362,41 +362,41 @@  discard block
 block discarded – undo
362 362
 	{
363 363
 		$logged_info = Context::get('logged_info');
364 364
 
365
-		if(!$manual_updated && !checkCSRF())
365
+		if (!$manual_updated && !checkCSRF())
366 366
 		{
367 367
 			return new Object(-1, 'msg_invalid_request');
368 368
 		}
369 369
 
370
-		if(!$source_obj->document_srl || !$obj->document_srl) return new Object(-1,'msg_invalied_request');
371
-		if(!$obj->status && $obj->is_secret == 'Y') $obj->status = 'SECRET';
372
-		if(!$obj->status) $obj->status = 'PUBLIC';
370
+		if (!$source_obj->document_srl || !$obj->document_srl) return new Object(-1, 'msg_invalied_request');
371
+		if (!$obj->status && $obj->is_secret == 'Y') $obj->status = 'SECRET';
372
+		if (!$obj->status) $obj->status = 'PUBLIC';
373 373
 
374 374
 		// Call a trigger (before)
375 375
 		$output = ModuleHandler::triggerCall('document.updateDocument', 'before', $obj);
376
-		if(!$output->toBool()) return $output;
376
+		if (!$output->toBool()) return $output;
377 377
 
378 378
 		// begin transaction
379 379
 		$oDB = &DB::getInstance();
380 380
 		$oDB->begin();
381 381
 
382 382
 		$oModuleModel = getModel('module');
383
-		if(!$obj->module_srl) $obj->module_srl = $source_obj->get('module_srl');
383
+		if (!$obj->module_srl) $obj->module_srl = $source_obj->get('module_srl');
384 384
 		$module_srl = $obj->module_srl;
385 385
 		$document_config = $oModuleModel->getModulePartConfig('document', $module_srl);
386
-		if(!$document_config)
386
+		if (!$document_config)
387 387
 		{
388 388
 			$document_config = new stdClass();
389 389
 		}
390
-		if(!isset($document_config->use_history)) $document_config->use_history = 'N';
390
+		if (!isset($document_config->use_history)) $document_config->use_history = 'N';
391 391
 		$bUseHistory = $document_config->use_history == 'Y' || $document_config->use_history == 'Trace';
392 392
 
393
-		if($bUseHistory)
393
+		if ($bUseHistory)
394 394
 		{
395 395
 			$args = new stdClass;
396 396
 			$args->history_srl = getNextSequence();
397 397
 			$args->document_srl = $obj->document_srl;
398 398
 			$args->module_srl = $module_srl;
399
-			if($document_config->use_history == 'Y') $args->content = $source_obj->get('content');
399
+			if ($document_config->use_history == 'Y') $args->content = $source_obj->get('content');
400 400
 			$args->nick_name = $source_obj->get('nick_name');
401 401
 			$args->member_srl = $source_obj->get('member_srl');
402 402
 			$args->regdate = $source_obj->get('last_update');
@@ -408,30 +408,30 @@  discard block
 block discarded – undo
408 408
 			$obj->ipaddress = $source_obj->get('ipaddress');
409 409
 		}
410 410
 		// List variables
411
-		if($obj->comment_status) $obj->commentStatus = $obj->comment_status;
412
-		if(!$obj->commentStatus) $obj->commentStatus = 'DENY';
413
-		if($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj);
414
-		if($obj->allow_trackback!='Y') $obj->allow_trackback = 'N';
415
-		if($obj->homepage)
411
+		if ($obj->comment_status) $obj->commentStatus = $obj->comment_status;
412
+		if (!$obj->commentStatus) $obj->commentStatus = 'DENY';
413
+		if ($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj);
414
+		if ($obj->allow_trackback != 'Y') $obj->allow_trackback = 'N';
415
+		if ($obj->homepage)
416 416
 		{
417 417
 			$obj->homepage = removeHackTag($obj->homepage);
418
-			if(!preg_match('/^[a-z]+:\/\//i',$obj->homepage))
418
+			if (!preg_match('/^[a-z]+:\/\//i', $obj->homepage))
419 419
 			{
420 420
 				$obj->homepage = 'http://'.$obj->homepage;
421 421
 			}
422 422
 		}
423 423
 		
424
-		if($obj->notify_message != 'Y') $obj->notify_message = 'N';
424
+		if ($obj->notify_message != 'Y') $obj->notify_message = 'N';
425 425
 		
426 426
 		// can modify regdate only manager
427 427
                 $grant = Context::get('grant');
428
-		if(!$grant->manager)
428
+		if (!$grant->manager)
429 429
 		{
430 430
 			unset($obj->regdate);
431 431
 		}
432 432
 		
433 433
 		// Serialize the $extra_vars
434
-		if(!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars);
434
+		if (!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars);
435 435
 		// Remove the columns for automatic saving
436 436
 		unset($obj->_saved_doc_srl);
437 437
 		unset($obj->_saved_doc_title);
@@ -440,23 +440,23 @@  discard block
 block discarded – undo
440 440
 
441 441
 		$oDocumentModel = getModel('document');
442 442
 		// Set the category_srl to 0 if the changed category is not exsiting.
443
-		if($source_obj->get('category_srl')!=$obj->category_srl)
443
+		if ($source_obj->get('category_srl') != $obj->category_srl)
444 444
 		{
445 445
 			$category_list = $oDocumentModel->getCategoryList($obj->module_srl);
446
-			if(!$category_list[$obj->category_srl]) $obj->category_srl = 0;
446
+			if (!$category_list[$obj->category_srl]) $obj->category_srl = 0;
447 447
 		}
448 448
 		// Change the update order
449 449
 		$obj->update_order = getNextSequence() * -1;
450 450
 		// Hash the password if it exists
451
-		if($obj->password)
451
+		if ($obj->password)
452 452
 		{
453 453
 			$obj->password = getModel('member')->hashPassword($obj->password);
454 454
 		}
455 455
 
456 456
 		// If an author is identical to the modifier or history is used, use the logged-in user's information.
457
-		if(Context::get('is_logged') && !$manual_updated)
457
+		if (Context::get('is_logged') && !$manual_updated)
458 458
 		{
459
-			if($source_obj->get('member_srl')==$logged_info->member_srl)
459
+			if ($source_obj->get('member_srl') == $logged_info->member_srl)
460 460
 			{
461 461
 				$obj->member_srl = $logged_info->member_srl;
462 462
 				$obj->user_name = htmlspecialchars_decode($logged_info->user_name);
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 		}
468 468
 
469 469
 		// For the document written by logged-in user however no nick_name exists
470
-		if($source_obj->get('member_srl')&& !$obj->nick_name)
470
+		if ($source_obj->get('member_srl') && !$obj->nick_name)
471 471
 		{
472 472
 			$obj->member_srl = $source_obj->get('member_srl');
473 473
 			$obj->user_name = $source_obj->get('user_name');
@@ -478,24 +478,24 @@  discard block
 block discarded – undo
478 478
 		// If the tile is empty, extract string from the contents.
479 479
 		$obj->title = htmlspecialchars($obj->title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
480 480
 		settype($obj->title, "string");
481
-		if($obj->title == '') $obj->title = cut_str(strip_tags($obj->content),20,'...');
481
+		if ($obj->title == '') $obj->title = cut_str(strip_tags($obj->content), 20, '...');
482 482
 		// If no tile extracted from the contents, leave it untitled.
483
-		if($obj->title == '') $obj->title = 'Untitled';
483
+		if ($obj->title == '') $obj->title = 'Untitled';
484 484
 		// Remove XE's own tags from the contents.
485 485
 		$obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content);
486
-		if(Mobile::isFromMobilePhone())
486
+		if (Mobile::isFromMobilePhone())
487 487
 		{
488
-			if($obj->use_html != 'Y')
488
+			if ($obj->use_html != 'Y')
489 489
 			{
490 490
 				$obj->content = htmlspecialchars($obj->content, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
491 491
 			}
492 492
 			$obj->content = nl2br($obj->content);
493 493
 		}
494 494
 		// Change not extra vars but language code of the original document if document's lang_code is different from author's setting.
495
-		if($source_obj->get('lang_code') != Context::getLangType())
495
+		if ($source_obj->get('lang_code') != Context::getLangType())
496 496
 		{
497 497
 			// Change not extra vars but language code of the original document if document's lang_code doesn't exist.
498
-			if(!$source_obj->get('lang_code'))
498
+			if (!$source_obj->get('lang_code'))
499 499
 			{
500 500
 				$lang_code_args->document_srl = $source_obj->get('document_srl');
501 501
 				$lang_code_args->lang_code = Context::getLangType();
@@ -515,59 +515,59 @@  discard block
 block discarded – undo
515 515
 			}
516 516
 		}
517 517
 		// Remove iframe and script if not a top adminisrator in the session.
518
-		if($logged_info->is_admin != 'Y')
518
+		if ($logged_info->is_admin != 'Y')
519 519
 		{
520 520
 			$obj->content = removeHackTag($obj->content);
521 521
 		}
522 522
 		// if temporary document, regdate is now setting
523
-		if($source_obj->get('status') == $this->getConfigStatus('temp')) $obj->regdate = date('YmdHis');
523
+		if ($source_obj->get('status') == $this->getConfigStatus('temp')) $obj->regdate = date('YmdHis');
524 524
 
525 525
 		// Insert data into the DB
526 526
 		$output = executeQuery('document.updateDocument', $obj);
527
-		if(!$output->toBool())
527
+		if (!$output->toBool())
528 528
 		{
529 529
 			$oDB->rollback();
530 530
 			return $output;
531 531
 		}
532 532
 		// Remove all extra variables
533
-		if(Context::get('act')!='procFileDelete')
533
+		if (Context::get('act') != 'procFileDelete')
534 534
 		{
535 535
 			$this->deleteDocumentExtraVars($source_obj->get('module_srl'), $obj->document_srl, null, Context::getLangType());
536 536
 			// Insert extra variables if the document successfully inserted.
537 537
 			$extra_keys = $oDocumentModel->getExtraKeys($obj->module_srl);
538
-			if(count($extra_keys))
538
+			if (count($extra_keys))
539 539
 			{
540
-				foreach($extra_keys as $idx => $extra_item)
540
+				foreach ($extra_keys as $idx => $extra_item)
541 541
 				{
542 542
 					$value = NULL;
543
-					if(isset($obj->{'extra_vars'.$idx}))
543
+					if (isset($obj->{'extra_vars'.$idx}))
544 544
 					{
545 545
 						$tmp = $obj->{'extra_vars'.$idx};
546
-						if(is_array($tmp))
546
+						if (is_array($tmp))
547 547
 							$value = implode('|@|', $tmp);
548 548
 						else
549 549
 							$value = trim($tmp);
550 550
 					}
551
-					else if(isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name});
552
-					if($value == NULL) continue;
551
+					else if (isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name});
552
+					if ($value == NULL) continue;
553 553
 					$this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid);
554 554
 				}
555 555
 			}
556 556
 			// Inert extra vars for multi-language support of title and contents.
557
-			if($extra_content->title) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -1, $extra_content->title, 'title_'.Context::getLangType());
558
-			if($extra_content->content) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -2, $extra_content->content, 'content_'.Context::getLangType());
557
+			if ($extra_content->title) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -1, $extra_content->title, 'title_'.Context::getLangType());
558
+			if ($extra_content->content) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -2, $extra_content->content, 'content_'.Context::getLangType());
559 559
 		}
560 560
 		// Update the category if the category_srl exists.
561
-		if($source_obj->get('category_srl') != $obj->category_srl || $source_obj->get('module_srl') == $logged_info->member_srl)
561
+		if ($source_obj->get('category_srl') != $obj->category_srl || $source_obj->get('module_srl') == $logged_info->member_srl)
562 562
 		{
563
-			if($source_obj->get('category_srl') != $obj->category_srl) $this->updateCategoryCount($obj->module_srl, $source_obj->get('category_srl'));
564
-			if($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl);
563
+			if ($source_obj->get('category_srl') != $obj->category_srl) $this->updateCategoryCount($obj->module_srl, $source_obj->get('category_srl'));
564
+			if ($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl);
565 565
 		}
566 566
 		// Call a trigger (after)
567
-		if($output->toBool())
567
+		if ($output->toBool())
568 568
 		{
569 569
 			$trigger_output = ModuleHandler::triggerCall('document.updateDocument', 'after', $obj);
570
-			if(!$trigger_output->toBool())
570
+			if (!$trigger_output->toBool())
571 571
 			{
572 572
 				$oDB->rollback();
573 573
 				return $trigger_output;
@@ -577,15 +577,15 @@  discard block
 block discarded – undo
577 577
 		// commit
578 578
 		$oDB->commit();
579 579
 		// Remove the thumbnail file
580
-		FileHandler::removeDir(sprintf('files/thumbnails/%s',getNumberingPath($obj->document_srl, 3)));
580
+		FileHandler::removeDir(sprintf('files/thumbnails/%s', getNumberingPath($obj->document_srl, 3)));
581 581
 
582
-		$output->add('document_srl',$obj->document_srl);
582
+		$output->add('document_srl', $obj->document_srl);
583 583
 		//remove from cache
584 584
 		$oCacheHandler = CacheHandler::getInstance('object');
585
-		if($oCacheHandler->isSupport())
585
+		if ($oCacheHandler->isSupport())
586 586
 		{
587 587
 			//remove document item from cache
588
-			$cache_key = 'document_item:'. getNumberingPath($obj->document_srl) . $obj->document_srl;
588
+			$cache_key = 'document_item:'.getNumberingPath($obj->document_srl).$obj->document_srl;
589 589
 			$oCacheHandler->delete($cache_key);
590 590
 		}
591 591
 
@@ -606,33 +606,33 @@  discard block
 block discarded – undo
606 606
 		$trigger_obj = new stdClass();
607 607
 		$trigger_obj->document_srl = $document_srl;
608 608
 		$output = ModuleHandler::triggerCall('document.deleteDocument', 'before', $trigger_obj);
609
-		if(!$output->toBool()) return $output;
609
+		if (!$output->toBool()) return $output;
610 610
 
611 611
 		// begin transaction
612 612
 		$oDB = &DB::getInstance();
613 613
 		$oDB->begin();
614 614
 
615
-		if(!$isEmptyTrash)
615
+		if (!$isEmptyTrash)
616 616
 		{
617 617
 			// get model object of the document
618 618
 			$oDocumentModel = getModel('document');
619 619
 			// Check if the documnet exists
620 620
 			$oDocument = $oDocumentModel->getDocument($document_srl, $is_admin);
621 621
 		}
622
-		else if($isEmptyTrash && $oDocument == null) return new Object(-1, 'document is not exists');
622
+		else if ($isEmptyTrash && $oDocument == null) return new Object(-1, 'document is not exists');
623 623
 
624
-		if(!$oDocument->isExists() || $oDocument->document_srl != $document_srl) return new Object(-1, 'msg_invalid_document');
624
+		if (!$oDocument->isExists() || $oDocument->document_srl != $document_srl) return new Object(-1, 'msg_invalid_document');
625 625
 		// Check if a permossion is granted
626
-		if(!$oDocument->isGranted()) return new Object(-1, 'msg_not_permitted');
626
+		if (!$oDocument->isGranted()) return new Object(-1, 'msg_not_permitted');
627 627
 
628 628
 		//if empty trash, document already deleted, therefore document not delete
629 629
 		$args = new stdClass();
630 630
 		$args->document_srl = $document_srl;
631
-		if(!$isEmptyTrash)
631
+		if (!$isEmptyTrash)
632 632
 		{
633 633
 			// Delete the document
634 634
 			$output = executeQuery('document.deleteDocument', $args);
635
-			if(!$output->toBool())
635
+			if (!$output->toBool())
636 636
 			{
637 637
 				$oDB->rollback();
638 638
 				return $output;
@@ -643,7 +643,7 @@  discard block
 block discarded – undo
643 643
 
644 644
 		$this->deleteDocumentHistory(null, $document_srl, null);
645 645
 		// Update category information if the category_srl exists.
646
-		if($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl'));
646
+		if ($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'), $oDocument->get('category_srl'));
647 647
 		// Delete a declared list
648 648
 		executeQuery('document.deleteDeclared', $args);
649 649
 		// Delete extra variable
@@ -651,11 +651,11 @@  discard block
 block discarded – undo
651 651
 
652 652
 		//this
653 653
 		// Call a trigger (after)
654
-		if($output->toBool())
654
+		if ($output->toBool())
655 655
 		{
656 656
 			$trigger_obj = $oDocument->getObjectVars();
657 657
 			$trigger_output = ModuleHandler::triggerCall('document.deleteDocument', 'after', $trigger_obj);
658
-			if(!$trigger_output->toBool())
658
+			if (!$trigger_output->toBool())
659 659
 			{
660 660
 				$oDB->rollback();
661 661
 				return $trigger_output;
@@ -667,16 +667,16 @@  discard block
 block discarded – undo
667 667
 		$this->_deleteDocumentVotedLog($args);
668 668
 
669 669
 		// Remove the thumbnail file
670
-		FileHandler::removeDir(sprintf('files/thumbnails/%s',getNumberingPath($document_srl, 3)));
670
+		FileHandler::removeDir(sprintf('files/thumbnails/%s', getNumberingPath($document_srl, 3)));
671 671
 
672 672
 		// commit
673 673
 		$oDB->commit();
674 674
 
675 675
 		//remove from cache
676 676
 		$oCacheHandler = CacheHandler::getInstance('object');
677
-		if($oCacheHandler->isSupport())
677
+		if ($oCacheHandler->isSupport())
678 678
 		{
679
-			$cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl;
679
+			$cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl;
680 680
 			$oCacheHandler->delete($cache_key);
681 681
 		}
682 682
 
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 	{
724 724
 		$trash_args = new stdClass();
725 725
 		// Get trash_srl if a given trash_srl doesn't exist
726
-		if(!$obj->trash_srl) $trash_args->trash_srl = getNextSequence();
726
+		if (!$obj->trash_srl) $trash_args->trash_srl = getNextSequence();
727 727
 		else $trash_args->trash_srl = $obj->trash_srl;
728 728
 		// Get its module_srl which the document belongs to
729 729
 		$oDocumentModel = getModel('document');
@@ -732,12 +732,12 @@  discard block
 block discarded – undo
732 732
 		$trash_args->module_srl = $oDocument->get('module_srl');
733 733
 		$obj->module_srl = $oDocument->get('module_srl');
734 734
 		// Cannot throw data from the trash to the trash
735
-		if($trash_args->module_srl == 0) return false;
735
+		if ($trash_args->module_srl == 0) return false;
736 736
 		// Data setting
737 737
 		$trash_args->document_srl = $obj->document_srl;
738 738
 		$trash_args->description = $obj->description;
739 739
 		// Insert member's information only if the member is logged-in and not manually registered.
740
-		if(Context::get('is_logged')&&!$manual_inserted)
740
+		if (Context::get('is_logged') && !$manual_inserted)
741 741
 		{
742 742
 			$logged_info = Context::get('logged_info');
743 743
 			$trash_args->member_srl = $logged_info->member_srl;
@@ -773,14 +773,14 @@  discard block
 block discarded – undo
773 773
 
774 774
 		$oTrashAdminController = getAdminController('trash');
775 775
 		$output = $oTrashAdminController->insertTrash($oTrashVO);
776
-		if(!$output->toBool())
776
+		if (!$output->toBool())
777 777
 		{
778 778
 			$oDB->rollback();
779 779
 			return $output;
780 780
 		}
781 781
 
782 782
 		$output = executeQuery('document.deleteDocument', $trash_args);
783
-		if(!$output->toBool())
783
+		if (!$output->toBool())
784 784
 		{
785 785
 			$oDB->rollback();
786 786
 			return $output;
@@ -793,12 +793,12 @@  discard block
 block discarded – undo
793 793
 		  }*/
794 794
 
795 795
 		// update category
796
-		if($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl'));
796
+		if ($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'), $oDocument->get('category_srl'));
797 797
 
798 798
 		// remove thumbnails
799
-		FileHandler::removeDir(sprintf('files/thumbnails/%s',getNumberingPath($obj->document_srl, 3)));
799
+		FileHandler::removeDir(sprintf('files/thumbnails/%s', getNumberingPath($obj->document_srl, 3)));
800 800
 		// Set the attachment to be invalid state
801
-		if($oDocument->hasUploadedFiles())
801
+		if ($oDocument->hasUploadedFiles())
802 802
 		{
803 803
 			$args = new stdClass();
804 804
 			$args->upload_target_srl = $oDocument->document_srl;
@@ -806,10 +806,10 @@  discard block
 block discarded – undo
806 806
 			executeQuery('file.updateFileValid', $args);
807 807
 		}
808 808
 		// Call a trigger (after)
809
-		if($output->toBool())
809
+		if ($output->toBool())
810 810
 		{
811 811
 			$trigger_output = ModuleHandler::triggerCall('document.moveDocumentToTrash', 'after', $obj);
812
-			if(!$trigger_output->toBool())
812
+			if (!$trigger_output->toBool())
813 813
 			{
814 814
 				$oDB->rollback();
815 815
 				return $trigger_output;
@@ -821,9 +821,9 @@  discard block
 block discarded – undo
821 821
 
822 822
 		// Clear cache
823 823
 		$oCacheHandler = CacheHandler::getInstance('object');
824
-		if($oCacheHandler->isSupport())
824
+		if ($oCacheHandler->isSupport())
825 825
 		{
826
-			$cache_key = 'document_item:'. getNumberingPath($oDocument->document_srl) . $oDocument->document_srl;
826
+			$cache_key = 'document_item:'.getNumberingPath($oDocument->document_srl).$oDocument->document_srl;
827 827
 			$oCacheHandler->delete($cache_key);
828 828
 		}
829 829
 
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
 	function updateReadedCount(&$oDocument)
839 839
 	{
840 840
 		// Pass if Crawler access
841
-		if(isCrawler()) return false;
841
+		if (isCrawler()) return false;
842 842
 		
843 843
 		$document_srl = $oDocument->document_srl;
844 844
 		$member_srl = $oDocument->get('member_srl');
@@ -846,19 +846,19 @@  discard block
 block discarded – undo
846 846
 
847 847
 		// Call a trigger when the read count is updated (before)
848 848
 		$trigger_output = ModuleHandler::triggerCall('document.updateReadedCount', 'before', $oDocument);
849
-		if(!$trigger_output->toBool()) return $trigger_output;
849
+		if (!$trigger_output->toBool()) return $trigger_output;
850 850
 
851 851
 		// Pass if read count is increaded on the session information
852
-		if($_SESSION['readed_document'][$document_srl]) return false;
852
+		if ($_SESSION['readed_document'][$document_srl]) return false;
853 853
 
854 854
 		// Pass if the author's IP address is as same as visitor's.
855
-		if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR'])
855
+		if ($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR'])
856 856
 		{
857 857
 			$_SESSION['readed_document'][$document_srl] = true;
858 858
 			return false;
859 859
 		}
860 860
 		// Pass ater registering sesscion if the author is a member and has same information as the currently logged-in user.
861
-		if($member_srl && $logged_info->member_srl == $member_srl)
861
+		if ($member_srl && $logged_info->member_srl == $member_srl)
862 862
 		{
863 863
 			$_SESSION['readed_document'][$document_srl] = true;
864 864
 			return false;
@@ -874,7 +874,7 @@  discard block
 block discarded – undo
874 874
 
875 875
 		// Call a trigger when the read count is updated (after)
876 876
 		$trigger_output = ModuleHandler::triggerCall('document.updateReadedCount', 'after', $oDocument);
877
-		if(!$trigger_output->toBool())
877
+		if (!$trigger_output->toBool())
878 878
 		{
879 879
 			$oDB->rollback();
880 880
 			return $trigger_output;
@@ -883,15 +883,15 @@  discard block
 block discarded – undo
883 883
 		$oDB->commit();
884 884
 
885 885
 		$oCacheHandler = CacheHandler::getInstance('object');
886
-		if($oCacheHandler->isSupport())
886
+		if ($oCacheHandler->isSupport())
887 887
 		{
888 888
 			//remove document item from cache
889
-			$cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl;
889
+			$cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl;
890 890
 			$oCacheHandler->delete($cache_key);
891 891
 		}
892 892
 
893 893
 		// Register session
894
-		if(!$_SESSION['banned_document'][$document_srl]) 
894
+		if (!$_SESSION['banned_document'][$document_srl]) 
895 895
 		{
896 896
 			$_SESSION['readed_document'][$document_srl] = true;
897 897
 		}
@@ -914,21 +914,21 @@  discard block
 block discarded – undo
914 914
 	 */
915 915
 	function insertDocumentExtraKey($module_srl, $var_idx, $var_name, $var_type, $var_is_required = 'N', $var_search = 'N', $var_default = '', $var_desc = '', $eid)
916 916
 	{
917
-		if(!$module_srl || !$var_idx || !$var_name || !$var_type || !$eid) return new Object(-1,'msg_invalid_request');
917
+		if (!$module_srl || !$var_idx || !$var_name || !$var_type || !$eid) return new Object(-1, 'msg_invalid_request');
918 918
 
919 919
 		$obj = new stdClass();
920 920
 		$obj->module_srl = $module_srl;
921 921
 		$obj->var_idx = $var_idx;
922 922
 		$obj->var_name = $var_name;
923 923
 		$obj->var_type = $var_type;
924
-		$obj->var_is_required = $var_is_required=='Y'?'Y':'N';
925
-		$obj->var_search = $var_search=='Y'?'Y':'N';
924
+		$obj->var_is_required = $var_is_required == 'Y' ? 'Y' : 'N';
925
+		$obj->var_search = $var_search == 'Y' ? 'Y' : 'N';
926 926
 		$obj->var_default = $var_default;
927 927
 		$obj->var_desc = $var_desc;
928 928
 		$obj->eid = $eid;
929 929
 
930 930
 		$output = executeQuery('document.getDocumentExtraKeys', $obj);
931
-		if(!$output->data)
931
+		if (!$output->data)
932 932
 		{
933 933
 			$output = executeQuery('document.insertDocumentExtraKey', $obj);
934 934
 		}
@@ -940,7 +940,7 @@  discard block
 block discarded – undo
940 940
 		}
941 941
 
942 942
 		$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
943
-		if($oCacheHandler->isSupport())
943
+		if ($oCacheHandler->isSupport())
944 944
 		{
945 945
 			$object_key = 'module_document_extra_keys:'.$module_srl;
946 946
 			$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
@@ -958,42 +958,42 @@  discard block
 block discarded – undo
958 958
 	 */
959 959
 	function deleteDocumentExtraKeys($module_srl, $var_idx = null)
960 960
 	{
961
-		if(!$module_srl) return new Object(-1,'msg_invalid_request');
961
+		if (!$module_srl) return new Object(-1, 'msg_invalid_request');
962 962
 		$obj = new stdClass();
963 963
 		$obj->module_srl = $module_srl;
964
-		if(!is_null($var_idx)) $obj->var_idx = $var_idx;
964
+		if (!is_null($var_idx)) $obj->var_idx = $var_idx;
965 965
 
966 966
 		$oDB = DB::getInstance();
967 967
 		$oDB->begin();
968 968
 
969 969
 		$output = $oDB->executeQuery('document.deleteDocumentExtraKeys', $obj);
970
-		if(!$output->toBool())
970
+		if (!$output->toBool())
971 971
 		{
972 972
 			$oDB->rollback();
973 973
 			return $output;
974 974
 		}
975 975
 
976
-		if($var_idx != NULL)
976
+		if ($var_idx != NULL)
977 977
 		{
978 978
 			$output = $oDB->executeQuery('document.updateDocumentExtraKeyIdxOrder', $obj);
979
-			if(!$output->toBool())
979
+			if (!$output->toBool())
980 980
 			{
981 981
 				$oDB->rollback();
982 982
 				return $output;
983 983
 			}
984 984
 		}
985 985
 
986
-		$output =  executeQuery('document.deleteDocumentExtraVars', $obj);
987
-		if(!$output->toBool())
986
+		$output = executeQuery('document.deleteDocumentExtraVars', $obj);
987
+		if (!$output->toBool())
988 988
 		{
989 989
 			$oDB->rollback();
990 990
 			return $output;
991 991
 		}
992 992
 
993
-		if($var_idx != NULL)
993
+		if ($var_idx != NULL)
994 994
 		{
995 995
 			$output = $oDB->executeQuery('document.updateDocumentExtraVarIdxOrder', $obj);
996
-			if(!$output->toBool())
996
+			if (!$output->toBool())
997 997
 			{
998 998
 				$oDB->rollback();
999 999
 				return $output;
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
 		$oDB->commit();
1004 1004
 
1005 1005
 		$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
1006
-		if($oCacheHandler->isSupport())
1006
+		if ($oCacheHandler->isSupport())
1007 1007
 		{
1008 1008
 			$object_key = 'module_document_extra_keys:'.$module_srl;
1009 1009
 			$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
@@ -1025,8 +1025,8 @@  discard block
 block discarded – undo
1025 1025
 	 */
1026 1026
 	function insertDocumentExtraVar($module_srl, $document_srl, $var_idx, $value, $eid = null, $lang_code = '')
1027 1027
 	{
1028
-		if(!$module_srl || !$document_srl || !$var_idx || !isset($value)) return new Object(-1,'msg_invalid_request');
1029
-		if(!$lang_code) $lang_code = Context::getLangType();
1028
+		if (!$module_srl || !$document_srl || !$var_idx || !isset($value)) return new Object(-1, 'msg_invalid_request');
1029
+		if (!$lang_code) $lang_code = Context::getLangType();
1030 1030
 
1031 1031
 		$obj = new stdClass;
1032 1032
 		$obj->module_srl = $module_srl;
@@ -1052,10 +1052,10 @@  discard block
 block discarded – undo
1052 1052
 	{
1053 1053
 		$obj = new stdClass();
1054 1054
 		$obj->module_srl = $module_srl;
1055
-		if(!is_null($document_srl)) $obj->document_srl = $document_srl;
1056
-		if(!is_null($var_idx)) $obj->var_idx = $var_idx;
1057
-		if(!is_null($lang_code)) $obj->lang_code = $lang_code;
1058
-		if(!is_null($eid)) $obj->eid = $eid;
1055
+		if (!is_null($document_srl)) $obj->document_srl = $document_srl;
1056
+		if (!is_null($var_idx)) $obj->var_idx = $var_idx;
1057
+		if (!is_null($lang_code)) $obj->lang_code = $lang_code;
1058
+		if (!is_null($eid)) $obj->eid = $eid;
1059 1059
 		$output = executeQuery('document.deleteDocumentExtraVars', $obj);
1060 1060
 		return $output;
1061 1061
 	}
@@ -1069,10 +1069,10 @@  discard block
 block discarded – undo
1069 1069
 	 */
1070 1070
 	function updateVotedCount($document_srl, $point = 1)
1071 1071
 	{
1072
-		if($point > 0) $failed_voted = 'failed_voted';
1072
+		if ($point > 0) $failed_voted = 'failed_voted';
1073 1073
 		else $failed_voted = 'failed_blamed';
1074 1074
 		// Return fail if session already has information about votes
1075
-		if($_SESSION['voted_document'][$document_srl])
1075
+		if ($_SESSION['voted_document'][$document_srl])
1076 1076
 		{
1077 1077
 			return new Object(-1, $failed_voted);
1078 1078
 		}
@@ -1080,7 +1080,7 @@  discard block
 block discarded – undo
1080 1080
 		$oDocumentModel = getModel('document');
1081 1081
 		$oDocument = $oDocumentModel->getDocument($document_srl, false, false);
1082 1082
 		// Pass if the author's IP address is as same as visitor's.
1083
-		if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR'])
1083
+		if ($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR'])
1084 1084
 		{
1085 1085
 			$_SESSION['voted_document'][$document_srl] = true;
1086 1086
 			return new Object(-1, $failed_voted);
@@ -1091,10 +1091,10 @@  discard block
 block discarded – undo
1091 1091
 		$member_srl = $oMemberModel->getLoggedMemberSrl();
1092 1092
 
1093 1093
 		// Check if document's author is a member.
1094
-		if($oDocument->get('member_srl'))
1094
+		if ($oDocument->get('member_srl'))
1095 1095
 		{
1096 1096
 			// Pass after registering a session if author's information is same as the currently logged-in user's.
1097
-			if($member_srl && $member_srl == abs($oDocument->get('member_srl')))
1097
+			if ($member_srl && $member_srl == abs($oDocument->get('member_srl')))
1098 1098
 			{
1099 1099
 				$_SESSION['voted_document'][$document_srl] = true;
1100 1100
 				return new Object(-1, $failed_voted);
@@ -1103,7 +1103,7 @@  discard block
 block discarded – undo
1103 1103
 
1104 1104
 		// Use member_srl for logged-in members and IP address for non-members.
1105 1105
 		$args = new stdClass;
1106
-		if($member_srl)
1106
+		if ($member_srl)
1107 1107
 		{
1108 1108
 			$args->member_srl = $member_srl;
1109 1109
 		}
@@ -1114,7 +1114,7 @@  discard block
 block discarded – undo
1114 1114
 		$args->document_srl = $document_srl;
1115 1115
 		$output = executeQuery('document.getDocumentVotedLogInfo', $args);
1116 1116
 		// Pass after registering a session if log information has vote-up logs
1117
-		if($output->data->count)
1117
+		if ($output->data->count)
1118 1118
 		{
1119 1119
 			$_SESSION['voted_document'][$document_srl] = true;
1120 1120
 			return new Object(-1, $failed_voted);
@@ -1125,7 +1125,7 @@  discard block
 block discarded – undo
1125 1125
 		$oDB->begin();
1126 1126
 
1127 1127
 		// Update the voted count
1128
-		if($point < 0)
1128
+		if ($point < 0)
1129 1129
 		{
1130 1130
 			$args->blamed_count = $oDocument->get('blamed_count') + $point;
1131 1131
 			$output = executeQuery('document.updateBlamedCount', $args);
@@ -1135,11 +1135,11 @@  discard block
 block discarded – undo
1135 1135
 			$args->voted_count = $oDocument->get('voted_count') + $point;
1136 1136
 			$output = executeQuery('document.updateVotedCount', $args);
1137 1137
 		}
1138
-		if(!$output->toBool()) return $output;
1138
+		if (!$output->toBool()) return $output;
1139 1139
 		// Leave logs
1140 1140
 		$args->point = $point;
1141 1141
 		$output = executeQuery('document.insertDocumentVotedLog', $args);
1142
-		if(!$output->toBool()) return $output;
1142
+		if (!$output->toBool()) return $output;
1143 1143
 
1144 1144
 		$obj = new stdClass;
1145 1145
 		$obj->member_srl = $oDocument->get('member_srl');
@@ -1150,7 +1150,7 @@  discard block
 block discarded – undo
1150 1150
 		$obj->before_point = ($point < 0) ? $oDocument->get('blamed_count') : $oDocument->get('voted_count');
1151 1151
 		$obj->after_point = ($point < 0) ? $args->blamed_count : $args->voted_count;
1152 1152
 		$trigger_output = ModuleHandler::triggerCall('document.updateVotedCount', 'after', $obj);
1153
-		if(!$trigger_output->toBool())
1153
+		if (!$trigger_output->toBool())
1154 1154
 		{
1155 1155
 			$oDB->rollback();
1156 1156
 			return $trigger_output;
@@ -1159,10 +1159,10 @@  discard block
 block discarded – undo
1159 1159
 		$oDB->commit();
1160 1160
 
1161 1161
 		$oCacheHandler = CacheHandler::getInstance('object');
1162
-		if($oCacheHandler->isSupport())
1162
+		if ($oCacheHandler->isSupport())
1163 1163
 		{
1164 1164
 			//remove document item from cache
1165
-			$cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl;
1165
+			$cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl;
1166 1166
 			$oCacheHandler->delete($cache_key);
1167 1167
 		}
1168 1168
 
@@ -1171,7 +1171,7 @@  discard block
 block discarded – undo
1171 1171
 
1172 1172
 		// Return result
1173 1173
 		$output = new Object();
1174
-		if($point > 0)
1174
+		if ($point > 0)
1175 1175
 		{
1176 1176
 			$output->setMessage('success_voted');
1177 1177
 			$output->add('voted_count', $obj->after_point);
@@ -1193,13 +1193,13 @@  discard block
 block discarded – undo
1193 1193
 	function declaredDocument($document_srl)
1194 1194
 	{
1195 1195
 		// Fail if session information already has a reported document
1196
-		if($_SESSION['declared_document'][$document_srl]) return new Object(-1, 'failed_declared');
1196
+		if ($_SESSION['declared_document'][$document_srl]) return new Object(-1, 'failed_declared');
1197 1197
 
1198 1198
 		// Check if previously reported
1199 1199
 		$args = new stdClass();
1200 1200
 		$args->document_srl = $document_srl;
1201 1201
 		$output = executeQuery('document.getDeclaredDocument', $args);
1202
-		if(!$output->toBool()) return $output;
1202
+		if (!$output->toBool()) return $output;
1203 1203
 
1204 1204
 		$declared_count = ($output->data->declared_count) ? $output->data->declared_count : 0;
1205 1205
 
@@ -1209,7 +1209,7 @@  discard block
 block discarded – undo
1209 1209
 
1210 1210
 		// Call a trigger (before)
1211 1211
 		$trigger_output = ModuleHandler::triggerCall('document.declaredDocument', 'before', $trigger_obj);
1212
-		if(!$trigger_output->toBool())
1212
+		if (!$trigger_output->toBool())
1213 1213
 		{
1214 1214
 			return $trigger_output;
1215 1215
 		}
@@ -1219,19 +1219,19 @@  discard block
 block discarded – undo
1219 1219
 		$oDocument = $oDocumentModel->getDocument($document_srl, false, false);
1220 1220
 
1221 1221
 		// Pass if the author's IP address is as same as visitor's.
1222
-		if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) {
1222
+		if ($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) {
1223 1223
 			$_SESSION['declared_document'][$document_srl] = true;
1224 1224
 			return new Object(-1, 'failed_declared');
1225 1225
 		}
1226 1226
 
1227 1227
 		// Check if document's author is a member.
1228
-		if($oDocument->get('member_srl'))
1228
+		if ($oDocument->get('member_srl'))
1229 1229
 		{
1230 1230
 			// Create a member model object
1231 1231
 			$oMemberModel = getModel('member');
1232 1232
 			$member_srl = $oMemberModel->getLoggedMemberSrl();
1233 1233
 			// Pass after registering a session if author's information is same as the currently logged-in user's.
1234
-			if($member_srl && $member_srl == abs($oDocument->get('member_srl')))
1234
+			if ($member_srl && $member_srl == abs($oDocument->get('member_srl')))
1235 1235
 			{
1236 1236
 				$_SESSION['declared_document'][$document_srl] = true;
1237 1237
 				return new Object(-1, 'failed_declared');
@@ -1240,7 +1240,7 @@  discard block
 block discarded – undo
1240 1240
 
1241 1241
 		// Use member_srl for logged-in members and IP address for non-members.
1242 1242
 		$args = new stdClass;
1243
-		if($member_srl)
1243
+		if ($member_srl)
1244 1244
 		{
1245 1245
 			$args->member_srl = $member_srl;
1246 1246
 		}
@@ -1253,7 +1253,7 @@  discard block
 block discarded – undo
1253 1253
 		$output = executeQuery('document.getDocumentDeclaredLogInfo', $args);
1254 1254
 
1255 1255
 		// Pass after registering a sesson if reported/declared documents are in the logs.
1256
-		if($output->data->count)
1256
+		if ($output->data->count)
1257 1257
 		{
1258 1258
 			$_SESSION['declared_document'][$document_srl] = true;
1259 1259
 			return new Object(-1, 'failed_declared');
@@ -1264,23 +1264,23 @@  discard block
 block discarded – undo
1264 1264
 		$oDB->begin();
1265 1265
 
1266 1266
 		// Add the declared document
1267
-		if($declared_count > 0) $output = executeQuery('document.updateDeclaredDocument', $args);
1267
+		if ($declared_count > 0) $output = executeQuery('document.updateDeclaredDocument', $args);
1268 1268
 		else $output = executeQuery('document.insertDeclaredDocument', $args);
1269
-		if(!$output->toBool()) return $output;
1269
+		if (!$output->toBool()) return $output;
1270 1270
 		// Leave logs
1271 1271
 		$output = executeQuery('document.insertDocumentDeclaredLog', $args);
1272
-		if(!$output->toBool())
1272
+		if (!$output->toBool())
1273 1273
 		{
1274 1274
 			$oDB->rollback();
1275 1275
 			return $output;
1276 1276
 		}
1277 1277
 
1278
-		$this->add('declared_count', $declared_count+1);
1278
+		$this->add('declared_count', $declared_count + 1);
1279 1279
 
1280 1280
 		// Call a trigger (after)
1281 1281
 		$trigger_obj->declared_count = $declared_count + 1;
1282 1282
 		$trigger_output = ModuleHandler::triggerCall('document.declaredDocument', 'after', $trigger_obj);
1283
-		if(!$trigger_output->toBool())
1283
+		if (!$trigger_output->toBool())
1284 1284
 		{
1285 1285
 			$oDB->rollback();
1286 1286
 			return $trigger_output;
@@ -1310,16 +1310,16 @@  discard block
 block discarded – undo
1310 1310
 		$args->document_srl = $document_srl;
1311 1311
 		$args->comment_count = $comment_count;
1312 1312
 
1313
-		if($comment_inserted)
1313
+		if ($comment_inserted)
1314 1314
 		{
1315
-			$args->update_order = -1*getNextSequence();
1315
+			$args->update_order = -1 * getNextSequence();
1316 1316
 			$args->last_updater = $last_updater;
1317 1317
 
1318 1318
 			$oCacheHandler = CacheHandler::getInstance('object');
1319
-			if($oCacheHandler->isSupport())
1319
+			if ($oCacheHandler->isSupport())
1320 1320
 			{
1321 1321
 				//remove document item from cache
1322
-				$cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl;
1322
+				$cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl;
1323 1323
 				$oCacheHandler->delete($cache_key);
1324 1324
 			}
1325 1325
 		}
@@ -1340,10 +1340,10 @@  discard block
 block discarded – undo
1340 1340
 		$args->trackback_count = $trackback_count;
1341 1341
 
1342 1342
 		$oCacheHandler = CacheHandler::getInstance('object');
1343
-		if($oCacheHandler->isSupport())
1343
+		if ($oCacheHandler->isSupport())
1344 1344
 		{
1345 1345
 			//remove document item from cache
1346
-			$cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl;
1346
+			$cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl;
1347 1347
 			$oCacheHandler->delete($cache_key);
1348 1348
 		}
1349 1349
 
@@ -1358,14 +1358,14 @@  discard block
 block discarded – undo
1358 1358
 	function insertCategory($obj)
1359 1359
 	{
1360 1360
 		// Sort the order to display if a child category is added
1361
-		if($obj->parent_srl)
1361
+		if ($obj->parent_srl)
1362 1362
 		{
1363 1363
 			// Get its parent category
1364 1364
 			$oDocumentModel = getModel('document');
1365 1365
 			$parent_category = $oDocumentModel->getCategory($obj->parent_srl);
1366 1366
 			$obj->list_order = $parent_category->list_order;
1367
-			$this->updateCategoryListOrder($parent_category->module_srl, $parent_category->list_order+1);
1368
-			if(!$obj->category_srl) $obj->category_srl = getNextSequence();
1367
+			$this->updateCategoryListOrder($parent_category->module_srl, $parent_category->list_order + 1);
1368
+			if (!$obj->category_srl) $obj->category_srl = getNextSequence();
1369 1369
 		}
1370 1370
 		else
1371 1371
 		{
@@ -1373,7 +1373,7 @@  discard block
 block discarded – undo
1373 1373
 		}
1374 1374
 
1375 1375
 		$output = executeQuery('document.insertCategory', $obj);
1376
-		if($output->toBool())
1376
+		if ($output->toBool())
1377 1377
 		{
1378 1378
 			$output->add('category_srl', $obj->category_srl);
1379 1379
 			$this->makeCategoryFile($obj->module_srl);
@@ -1407,13 +1407,13 @@  discard block
 block discarded – undo
1407 1407
 	{
1408 1408
 		// Create a document model object
1409 1409
 		$oDocumentModel = getModel('document');
1410
-		if(!$document_count) $document_count = $oDocumentModel->getCategoryDocumentCount($module_srl,$category_srl);
1410
+		if (!$document_count) $document_count = $oDocumentModel->getCategoryDocumentCount($module_srl, $category_srl);
1411 1411
 
1412 1412
 		$args = new stdClass;
1413 1413
 		$args->category_srl = $category_srl;
1414 1414
 		$args->document_count = $document_count;
1415 1415
 		$output = executeQuery('document.updateCategoryCount', $args);
1416
-		if($output->toBool()) $this->makeCategoryFile($module_srl);
1416
+		if ($output->toBool()) $this->makeCategoryFile($module_srl);
1417 1417
 
1418 1418
 		return $output;
1419 1419
 	}
@@ -1426,7 +1426,7 @@  discard block
 block discarded – undo
1426 1426
 	function updateCategory($obj)
1427 1427
 	{
1428 1428
 		$output = executeQuery('document.updateCategory', $obj);
1429
-		if($output->toBool()) $this->makeCategoryFile($obj->module_srl);
1429
+		if ($output->toBool()) $this->makeCategoryFile($obj->module_srl);
1430 1430
 		return $output;
1431 1431
 	}
1432 1432
 
@@ -1443,32 +1443,32 @@  discard block
 block discarded – undo
1443 1443
 		$category_info = $oDocumentModel->getCategory($category_srl);
1444 1444
 		// Display an error that the category cannot be deleted if it has a child
1445 1445
 		$output = executeQuery('document.getChildCategoryCount', $args);
1446
-		if(!$output->toBool()) return $output;
1447
-		if($output->data->count>0) return new Object(-1, 'msg_cannot_delete_for_child');
1446
+		if (!$output->toBool()) return $output;
1447
+		if ($output->data->count > 0) return new Object(-1, 'msg_cannot_delete_for_child');
1448 1448
 		// Delete a category information
1449 1449
 		$output = executeQuery('document.deleteCategory', $args);
1450
-		if(!$output->toBool()) return $output;
1450
+		if (!$output->toBool()) return $output;
1451 1451
 
1452 1452
 		$this->makeCategoryFile($category_info->module_srl);
1453 1453
 		// remvove cache
1454 1454
 		$oCacheHandler = CacheHandler::getInstance('object');
1455
-		if($oCacheHandler->isSupport())
1455
+		if ($oCacheHandler->isSupport())
1456 1456
 		{
1457 1457
 			$page = 0;
1458
-			while(true) {
1458
+			while (true) {
1459 1459
 				$args = new stdClass();
1460 1460
 				$args->category_srl = $category_srl;
1461 1461
 				$args->list_count = 100;
1462 1462
 				$args->page = ++$page;
1463 1463
 				$output = executeQuery('document.getDocumentList', $args, array('document_srl'));
1464 1464
 
1465
-				if($output->data == array())
1465
+				if ($output->data == array())
1466 1466
 					break;
1467 1467
 
1468
-				foreach($output->data as $val)
1468
+				foreach ($output->data as $val)
1469 1469
 				{
1470 1470
 					//remove document item from cache
1471
-					$cache_key = 'document_item:'. getNumberingPath($val->document_srl) . $val->document_srl;
1471
+					$cache_key = 'document_item:'.getNumberingPath($val->document_srl).$val->document_srl;
1472 1472
 					$oCacheHandler->delete($cache_key);
1473 1473
 				}
1474 1474
 			}
@@ -1515,18 +1515,18 @@  discard block
 block discarded – undo
1515 1515
 		// Seek a full list of categories
1516 1516
 		$category_list = $oDocumentModel->getCategoryList($module_srl);
1517 1517
 		$category_srl_list = array_keys($category_list);
1518
-		if(count($category_srl_list)<2) return new Object();
1518
+		if (count($category_srl_list) < 2) return new Object();
1519 1519
 
1520 1520
 		$prev_category = NULL;
1521
-		foreach($category_list as $key => $val)
1521
+		foreach ($category_list as $key => $val)
1522 1522
 		{
1523
-			if($key==$category_srl) break;
1523
+			if ($key == $category_srl) break;
1524 1524
 			$prev_category = $val;
1525 1525
 		}
1526 1526
 		// Return if the previous category doesn't exist
1527
-		if(!$prev_category) return new Object(-1,Context::getLang('msg_category_not_moved'));
1527
+		if (!$prev_category) return new Object(-1, Context::getLang('msg_category_not_moved'));
1528 1528
 		// Return if the selected category is the top level
1529
-		if($category_srl_list[0]==$category_srl) return new Object(-1,Context::getLang('msg_category_not_moved'));
1529
+		if ($category_srl_list[0] == $category_srl) return new Object(-1, Context::getLang('msg_category_not_moved'));
1530 1530
 		// Information of the selected category
1531 1531
 		$cur_args = new stdClass;
1532 1532
 		$cur_args->category_srl = $category_srl;
@@ -1562,15 +1562,15 @@  discard block
 block discarded – undo
1562 1562
 		// Seek a full list of categories
1563 1563
 		$category_list = $oDocumentModel->getCategoryList($module_srl);
1564 1564
 		$category_srl_list = array_keys($category_list);
1565
-		if(count($category_srl_list)<2) return new Object();
1565
+		if (count($category_srl_list) < 2) return new Object();
1566 1566
 
1567
-		for($i=0;$i<count($category_srl_list);$i++)
1567
+		for ($i = 0; $i < count($category_srl_list); $i++)
1568 1568
 		{
1569
-			if($category_srl_list[$i]==$category_srl) break;
1569
+			if ($category_srl_list[$i] == $category_srl) break;
1570 1570
 		}
1571 1571
 
1572
-		$next_category_srl = $category_srl_list[$i+1];
1573
-		if(!$category_list[$next_category_srl]) return new Object(-1,Context::getLang('msg_category_not_moved'));
1572
+		$next_category_srl = $category_srl_list[$i + 1];
1573
+		if (!$category_list[$next_category_srl]) return new Object(-1, Context::getLang('msg_category_not_moved'));
1574 1574
 		$next_category = $category_list[$next_category_srl];
1575 1575
 		// Information of the selected category
1576 1576
 		$cur_args = new stdClass;
@@ -1597,7 +1597,7 @@  discard block
 block discarded – undo
1597 1597
 	{
1598 1598
 		$oDocumentModel = getModel('document');
1599 1599
 		$extra_keys = $oDocumentModel->getExtraKeys($module_srl);
1600
-		if(!count($extra_keys)) return;
1600
+		if (!count($extra_keys)) return;
1601 1601
 
1602 1602
 		$js_code = array();
1603 1603
 		$js_code[] = '<script>//<![CDATA[';
@@ -1607,16 +1607,16 @@  discard block
 block discarded – undo
1607 1607
 
1608 1608
 		$logged_info = Context::get('logged_info');
1609 1609
 
1610
-		foreach($extra_keys as $idx => $val)
1610
+		foreach ($extra_keys as $idx => $val)
1611 1611
 		{
1612 1612
 			$idx = $val->idx;
1613
-			if($val->type == 'kr_zip')
1613
+			if ($val->type == 'kr_zip')
1614 1614
 			{
1615 1615
 				$idx .= '[]';
1616 1616
 			}
1617 1617
 			$name = str_ireplace(array('<script', '</script'), array('<scr" + "ipt', '</scr" + "ipt'), $val->name);
1618 1618
 			$js_code[] = sprintf('validator.cast("ADD_MESSAGE", ["extra_vars%s","%s"]);', $idx, $name);
1619
-			if($val->is_required == 'Y') $js_code[] = sprintf('validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx);
1619
+			if ($val->is_required == 'Y') $js_code[] = sprintf('validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx);
1620 1620
 		}
1621 1621
 
1622 1622
 		$js_code[] = '})(jQuery);';
@@ -1634,12 +1634,12 @@  discard block
 block discarded – undo
1634 1634
 	function procDocumentInsertCategory($args = null)
1635 1635
 	{
1636 1636
 		// List variables
1637
-		if(!$args) $args = Context::gets('module_srl','category_srl','parent_srl','category_title','category_description','expand','group_srls','category_color','mid');
1637
+		if (!$args) $args = Context::gets('module_srl', 'category_srl', 'parent_srl', 'category_title', 'category_description', 'expand', 'group_srls', 'category_color', 'mid');
1638 1638
 		$args->title = $args->category_title;
1639 1639
 		$args->description = $args->category_description;
1640 1640
 		$args->color = $args->category_color;
1641 1641
 
1642
-		if(!$args->module_srl && $args->mid)
1642
+		if (!$args->module_srl && $args->mid)
1643 1643
 		{
1644 1644
 			$mid = $args->mid;
1645 1645
 			unset($args->mid);
@@ -1650,28 +1650,28 @@  discard block
 block discarded – undo
1650 1650
 		$columnList = array('module_srl', 'module');
1651 1651
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList);
1652 1652
 		$grant = $oModuleModel->getGrant($module_info, Context::get('logged_info'));
1653
-		if(!$grant->manager) return new Object(-1,'msg_not_permitted');
1653
+		if (!$grant->manager) return new Object(-1, 'msg_not_permitted');
1654 1654
 
1655
-		if($args->expand !="Y") $args->expand = "N";
1656
-		if(!is_array($args->group_srls)) $args->group_srls = str_replace('|@|',',',$args->group_srls);
1655
+		if ($args->expand != "Y") $args->expand = "N";
1656
+		if (!is_array($args->group_srls)) $args->group_srls = str_replace('|@|', ',', $args->group_srls);
1657 1657
 		else $args->group_srls = implode(',', $args->group_srls);
1658
-		$args->parent_srl = (int)$args->parent_srl;
1658
+		$args->parent_srl = (int) $args->parent_srl;
1659 1659
 
1660 1660
 		$oDocumentModel = getModel('document');
1661 1661
 
1662 1662
 		$oDB = &DB::getInstance();
1663 1663
 		$oDB->begin();
1664 1664
 		// Check if already exists
1665
-		if($args->category_srl)
1665
+		if ($args->category_srl)
1666 1666
 		{
1667 1667
 			$category_info = $oDocumentModel->getCategory($args->category_srl);
1668
-			if($category_info->category_srl != $args->category_srl) $args->category_srl = null;
1668
+			if ($category_info->category_srl != $args->category_srl) $args->category_srl = null;
1669 1669
 		}
1670 1670
 		// Update if exists
1671
-		if($args->category_srl)
1671
+		if ($args->category_srl)
1672 1672
 		{
1673 1673
 			$output = $this->updateCategory($args);
1674
-			if(!$output->toBool())
1674
+			if (!$output->toBool())
1675 1675
 			{
1676 1676
 				$oDB->rollback();
1677 1677
 				return $output;
@@ -1681,7 +1681,7 @@  discard block
 block discarded – undo
1681 1681
 		else
1682 1682
 		{
1683 1683
 			$output = $this->insertCategory($args);
1684
-			if(!$output->toBool())
1684
+			if (!$output->toBool())
1685 1685
 			{
1686 1686
 				$oDB->rollback();
1687 1687
 				return $output;
@@ -1720,11 +1720,11 @@  discard block
 block discarded – undo
1720 1720
 		$columnList = array('module_srl', 'module');
1721 1721
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($source_category->module_srl, $columnList);
1722 1722
 		$grant = $oModuleModel->getGrant($module_info, Context::get('logged_info'));
1723
-		if(!$grant->manager) return new Object(-1,'msg_not_permitted');
1723
+		if (!$grant->manager) return new Object(-1, 'msg_not_permitted');
1724 1724
 
1725 1725
 		// First child of the parent_category_srl
1726 1726
 		$source_args = new stdClass;
1727
-		if($parent_category_srl > 0 || ($parent_category_srl == 0 && $target_category_srl == 0))
1727
+		if ($parent_category_srl > 0 || ($parent_category_srl == 0 && $target_category_srl == 0))
1728 1728
 		{
1729 1729
 			$parent_category = $oDocumentModel->getCategory($parent_category_srl);
1730 1730
 
@@ -1733,30 +1733,30 @@  discard block
 block discarded – undo
1733 1733
 			$args->parent_srl = $parent_category_srl;
1734 1734
 			$output = executeQuery('document.getChildCategoryMinListOrder', $args);
1735 1735
 
1736
-			if(!$output->toBool()) return $output;
1737
-			$args->list_order = (int)$output->data->list_order;
1738
-			if(!$args->list_order) $args->list_order = 0;
1736
+			if (!$output->toBool()) return $output;
1737
+			$args->list_order = (int) $output->data->list_order;
1738
+			if (!$args->list_order) $args->list_order = 0;
1739 1739
 			$args->list_order--;
1740 1740
 
1741 1741
 			$source_args->category_srl = $source_category_srl;
1742 1742
 			$source_args->parent_srl = $parent_category_srl;
1743 1743
 			$source_args->list_order = $args->list_order;
1744 1744
 			$output = $this->updateCategory($source_args);
1745
-			if(!$output->toBool()) return $output;
1745
+			if (!$output->toBool()) return $output;
1746 1746
 			// Sibling of the $target_category_srl
1747 1747
 		}
1748
-		else if($target_category_srl > 0)
1748
+		else if ($target_category_srl > 0)
1749 1749
 		{
1750 1750
 			$target_category = $oDocumentModel->getCategory($target_category_srl);
1751 1751
 			// Move all siblings of the $target_category down
1752
-			$output = $this->updateCategoryListOrder($target_category->module_srl, $target_category->list_order+1);
1753
-			if(!$output->toBool()) return $output;
1752
+			$output = $this->updateCategoryListOrder($target_category->module_srl, $target_category->list_order + 1);
1753
+			if (!$output->toBool()) return $output;
1754 1754
 
1755 1755
 			$source_args->category_srl = $source_category_srl;
1756 1756
 			$source_args->parent_srl = $target_category->parent_srl;
1757
-			$source_args->list_order = $target_category->list_order+1;
1757
+			$source_args->list_order = $target_category->list_order + 1;
1758 1758
 			$output = $this->updateCategory($source_args);
1759
-			if(!$output->toBool()) return $output;
1759
+			if (!$output->toBool()) return $output;
1760 1760
 		}
1761 1761
 		// Re-generate the xml file
1762 1762
 		$xml_file = $this->makeCategoryFile($source_category->module_srl);
@@ -1772,7 +1772,7 @@  discard block
 block discarded – undo
1772 1772
 	function procDocumentDeleteCategory()
1773 1773
 	{
1774 1774
 		// List variables
1775
-		$args = Context::gets('module_srl','category_srl');
1775
+		$args = Context::gets('module_srl', 'category_srl');
1776 1776
 
1777 1777
 		$oDB = &DB::getInstance();
1778 1778
 		$oDB->begin();
@@ -1781,17 +1781,17 @@  discard block
 block discarded – undo
1781 1781
 		$columnList = array('module_srl', 'module');
1782 1782
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList);
1783 1783
 		$grant = $oModuleModel->getGrant($module_info, Context::get('logged_info'));
1784
-		if(!$grant->manager) return new Object(-1,'msg_not_permitted');
1784
+		if (!$grant->manager) return new Object(-1, 'msg_not_permitted');
1785 1785
 
1786 1786
 		$oDocumentModel = getModel('document');
1787 1787
 		// Get original information
1788 1788
 		$category_info = $oDocumentModel->getCategory($args->category_srl);
1789
-		if($category_info->parent_srl) $parent_srl = $category_info->parent_srl;
1789
+		if ($category_info->parent_srl) $parent_srl = $category_info->parent_srl;
1790 1790
 		// Display an error that the category cannot be deleted if it has a child node
1791
-		if($oDocumentModel->getCategoryChlidCount($args->category_srl)) return new Object(-1, 'msg_cannot_delete_for_child');
1791
+		if ($oDocumentModel->getCategoryChlidCount($args->category_srl)) return new Object(-1, 'msg_cannot_delete_for_child');
1792 1792
 		// Remove from the DB
1793 1793
 		$output = $this->deleteCategory($args->category_srl);
1794
-		if(!$output->toBool())
1794
+		if (!$output->toBool())
1795 1795
 		{
1796 1796
 			$oDB->rollback();
1797 1797
 			return $output;
@@ -1822,11 +1822,11 @@  discard block
 block discarded – undo
1822 1822
 		$columnList = array('module_srl', 'module');
1823 1823
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList);
1824 1824
 		$grant = $oModuleModel->getGrant($module_info, Context::get('logged_info'));
1825
-		if(!$grant->manager) return new Object(-1,'msg_not_permitted');
1825
+		if (!$grant->manager) return new Object(-1, 'msg_not_permitted');
1826 1826
 
1827 1827
 		$xml_file = $this->makeCategoryFile($module_srl);
1828 1828
 		// Set return value
1829
-		$this->add('xml_file',$xml_file);
1829
+		$this->add('xml_file', $xml_file);
1830 1830
 	}
1831 1831
 
1832 1832
 	/**
@@ -1837,14 +1837,14 @@  discard block
 block discarded – undo
1837 1837
 	function makeCategoryFile($module_srl)
1838 1838
 	{
1839 1839
 		// Return if there is no information you need for creating a cache file
1840
-		if(!$module_srl) return false;
1840
+		if (!$module_srl) return false;
1841 1841
 		// Get module information (to obtain mid)
1842 1842
 		$oModuleModel = getModel('module');
1843 1843
 		$columnList = array('module_srl', 'mid', 'site_srl');
1844 1844
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList);
1845 1845
 		$mid = $module_info->mid;
1846 1846
 
1847
-		if(!is_dir('./files/cache/document_category')) FileHandler::makeDir('./files/cache/document_category');
1847
+		if (!is_dir('./files/cache/document_category')) FileHandler::makeDir('./files/cache/document_category');
1848 1848
 		// Cache file's name
1849 1849
 		$xml_file = sprintf("./files/cache/document_category/%s.xml.php", $module_srl);
1850 1850
 		$php_file = sprintf("./files/cache/document_category/%s.php", $module_srl);
@@ -1856,17 +1856,17 @@  discard block
 block discarded – undo
1856 1856
 
1857 1857
 		$category_list = $output->data;
1858 1858
 
1859
-		if(!is_array($category_list)) $category_list = array($category_list);
1859
+		if (!is_array($category_list)) $category_list = array($category_list);
1860 1860
 
1861 1861
 		$category_count = count($category_list);
1862
-		for($i=0;$i<$category_count;$i++)
1862
+		for ($i = 0; $i < $category_count; $i++)
1863 1863
 		{
1864 1864
 			$category_srl = $category_list[$i]->category_srl;
1865
-			if(!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) $category_list[$i]->group_srls = '';
1865
+			if (!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) $category_list[$i]->group_srls = '';
1866 1866
 			$list[$category_srl] = $category_list[$i];
1867 1867
 		}
1868 1868
 		// Create the xml file without node data if no data is obtained
1869
-		if(!$list)
1869
+		if (!$list)
1870 1870
 		{
1871 1871
 			$xml_buff = "<root />";
1872 1872
 			FileHandler::writeFile($xml_file, $xml_buff);
@@ -1874,12 +1874,12 @@  discard block
 block discarded – undo
1874 1874
 			return $xml_file;
1875 1875
 		}
1876 1876
 		// Change to an array if only a single data is obtained
1877
-		if(!is_array($list)) $list = array($list);
1877
+		if (!is_array($list)) $list = array($list);
1878 1878
 		// Create a tree for loop
1879
-		foreach($list as $category_srl => $node)
1879
+		foreach ($list as $category_srl => $node)
1880 1880
 		{
1881 1881
 			$node->mid = $mid;
1882
-			$parent_srl = (int)$node->parent_srl;
1882
+			$parent_srl = (int) $node->parent_srl;
1883 1883
 			$tree[$parent_srl][$category_srl] = $node;
1884 1884
 		}
1885 1885
 		// A common header to set permissions and groups of the cache file
@@ -1953,13 +1953,13 @@  discard block
 block discarded – undo
1953 1953
 	 */
1954 1954
 	function getXmlTree($source_node, $tree, $site_srl, &$xml_header_buff)
1955 1955
 	{
1956
-		if(!$source_node) return;
1956
+		if (!$source_node) return;
1957 1957
 
1958
-		foreach($source_node as $category_srl => $node)
1958
+		foreach ($source_node as $category_srl => $node)
1959 1959
 		{
1960 1960
 			$child_buff = "";
1961 1961
 			// Get data of the child nodes
1962
-			if($category_srl && $tree[$category_srl]) $child_buff = $this->getXmlTree($tree[$category_srl], $tree, $site_srl, $xml_header_buff);
1962
+			if ($category_srl && $tree[$category_srl]) $child_buff = $this->getXmlTree($tree[$category_srl], $tree, $site_srl, $xml_header_buff);
1963 1963
 			// List variables
1964 1964
 			$expand = $node->expand;
1965 1965
 			$group_srls = $node->group_srls;
@@ -1969,27 +1969,27 @@  discard block
 block discarded – undo
1969 1969
 			$color = $node->color;
1970 1970
 			$description = $node->description;
1971 1971
 			// If node->group_srls value exists
1972
-			if($group_srls) $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$group_srls);
1972
+			if ($group_srls) $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))', $group_srls);
1973 1973
 			else $group_check_code = "true";
1974 1974
 
1975 1975
 			$title = $node->title;
1976 1976
 			$oModuleAdminModel = getAdminModel('module');
1977 1977
 
1978 1978
 			$langs = $oModuleAdminModel->getLangCode($site_srl, $title);
1979
-			if(count($langs))
1979
+			if (count($langs))
1980 1980
 			{
1981
-				foreach($langs as $key => $val)
1981
+				foreach ($langs as $key => $val)
1982 1982
 				{
1983
-					$xml_header_buff .= sprintf('$_titles[%d]["%s"] = "%s"; ', $category_srl, $key, str_replace('"','\\"',htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)));
1983
+					$xml_header_buff .= sprintf('$_titles[%d]["%s"] = "%s"; ', $category_srl, $key, str_replace('"', '\\"', htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)));
1984 1984
 				}
1985 1985
 			}
1986 1986
 
1987 1987
 			$langx = $oModuleAdminModel->getLangCode($site_srl, $description);
1988
-			if(count($langx))
1988
+			if (count($langx))
1989 1989
 			{
1990
-				foreach($langx as $key => $val)
1990
+				foreach ($langx as $key => $val)
1991 1991
 				{
1992
-					$xml_header_buff .= sprintf('$_descriptions[%d]["%s"] = "%s"; ', $category_srl, $key, str_replace('"','\\"',htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)));
1992
+					$xml_header_buff .= sprintf('$_descriptions[%d]["%s"] = "%s"; ', $category_srl, $key, str_replace('"', '\\"', htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)));
1993 1993
 				}
1994 1994
 			}
1995 1995
 
@@ -2002,7 +2002,7 @@  discard block
 block discarded – undo
2002 2002
 				$category_srl,
2003 2003
 				$group_check_code,
2004 2004
 				$category_srl,
2005
-				getUrl('','mid',$node->mid,'category',$category_srl),
2005
+				getUrl('', 'mid', $node->mid, 'category', $category_srl),
2006 2006
 				$expand,
2007 2007
 				htmlspecialchars($color, ENT_COMPAT | ENT_HTML401, 'UTF-8', false),
2008 2008
 				$group_check_code,
@@ -2010,8 +2010,8 @@  discard block
 block discarded – undo
2010 2010
 				$node->document_count
2011 2011
 			);
2012 2012
 
2013
-			if($child_buff) $buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff);
2014
-			else $buff .=  sprintf('<node %s />', $attribute);
2013
+			if ($child_buff) $buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff);
2014
+			else $buff .= sprintf('<node %s />', $attribute);
2015 2015
 		}
2016 2016
 		return $buff;
2017 2017
 	}
@@ -2030,13 +2030,13 @@  discard block
 block discarded – undo
2030 2030
 	function getPhpCacheCode($source_node, $tree, $site_srl, &$php_header_buff)
2031 2031
 	{
2032 2032
 		$output = array("buff"=>"", "category_srl_list"=>array());
2033
-		if(!$source_node) return $output;
2033
+		if (!$source_node) return $output;
2034 2034
 
2035 2035
 		// Set to an arraty for looping and then generate php script codes to be included
2036
-		foreach($source_node as $category_srl => $node)
2036
+		foreach ($source_node as $category_srl => $node)
2037 2037
 		{
2038 2038
 			// Get data from child nodes first if exist.
2039
-			if($category_srl && $tree[$category_srl]){
2039
+			if ($category_srl && $tree[$category_srl]) {
2040 2040
 				$child_output = $this->getPhpCacheCode($tree[$category_srl], $tree, $site_srl, $php_header_buff);
2041 2041
 			} else {
2042 2042
 				$child_output = array("buff"=>"", "category_srl_list"=>array());
@@ -2047,14 +2047,14 @@  discard block
 block discarded – undo
2047 2047
 			$output['category_srl_list'] = array_merge($output['category_srl_list'], $child_output['category_srl_list']);
2048 2048
 
2049 2049
 			// If node->group_srls value exists
2050
-			if($node->group_srls) {
2051
-				$group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$node->group_srls);
2050
+			if ($node->group_srls) {
2051
+				$group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))', $node->group_srls);
2052 2052
 			} else {
2053 2053
 				$group_check_code = "true";
2054 2054
 			}
2055 2055
 
2056 2056
 			// List variables
2057
-			$selected = '"' . implode('","', $child_output['category_srl_list']) . '"';
2057
+			$selected = '"'.implode('","', $child_output['category_srl_list']).'"';
2058 2058
 			$child_buff = $child_output['buff'];
2059 2059
 			$expand = $node->expand;
2060 2060
 
@@ -2063,32 +2063,32 @@  discard block
 block discarded – undo
2063 2063
 			$oModuleAdminModel = getAdminModel('module');
2064 2064
 			$langs = $oModuleAdminModel->getLangCode($site_srl, $title);
2065 2065
 
2066
-			if(count($langs))
2066
+			if (count($langs))
2067 2067
 			{
2068
-				foreach($langs as $key => $val)
2068
+				foreach ($langs as $key => $val)
2069 2069
 				{
2070 2070
 					$val = htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
2071 2071
 					$php_header_buff .= sprintf(
2072 2072
 						'$_titles[%d]["%s"] = "%s"; ',
2073 2073
 						$category_srl,
2074 2074
 						$key,
2075
-						str_replace('"','\\"', $val)
2075
+						str_replace('"', '\\"', $val)
2076 2076
 					);
2077 2077
 				}
2078 2078
 			}
2079 2079
 
2080 2080
 			$langx = $oModuleAdminModel->getLangCode($site_srl, $description);
2081 2081
 
2082
-			if(count($langx))
2082
+			if (count($langx))
2083 2083
 			{
2084
-				foreach($langx as $key => $val)
2084
+				foreach ($langx as $key => $val)
2085 2085
 				{
2086 2086
 					$val = htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
2087 2087
 					$php_header_buff .= sprintf(
2088 2088
 						'$_descriptions[%d]["%s"] = "%s"; ',
2089 2089
 						$category_srl,
2090 2090
 						$key,
2091
-						str_replace('"','\\"', $val)
2091
+						str_replace('"', '\\"', $val)
2092 2092
 					);
2093 2093
 				}
2094 2094
 			}
@@ -2112,7 +2112,7 @@  discard block
 block discarded – undo
2112 2112
 			);
2113 2113
 
2114 2114
 			// Generate buff data
2115
-			$output['buff'] .=  sprintf('%s=>array(%s),', $node->category_srl, $attribute);
2115
+			$output['buff'] .= sprintf('%s=>array(%s),', $node->category_srl, $attribute);
2116 2116
 		}
2117 2117
 
2118 2118
 		return $output;
@@ -2129,7 +2129,7 @@  discard block
 block discarded – undo
2129 2129
 	function addDocumentPopupMenu($url, $str, $icon = '', $target = 'self')
2130 2130
 	{
2131 2131
 		$document_popup_menu_list = Context::get('document_popup_menu_list');
2132
-		if(!is_array($document_popup_menu_list)) $document_popup_menu_list = array();
2132
+		if (!is_array($document_popup_menu_list)) $document_popup_menu_list = array();
2133 2133
 
2134 2134
 		$obj = new stdClass();
2135 2135
 		$obj->url = $url;
@@ -2147,68 +2147,68 @@  discard block
 block discarded – undo
2147 2147
 	 */
2148 2148
 	function procDocumentAddCart()
2149 2149
 	{
2150
-		if(!Context::get('is_logged')) return new Object(-1, 'msg_not_permitted');
2150
+		if (!Context::get('is_logged')) return new Object(-1, 'msg_not_permitted');
2151 2151
 
2152 2152
 		// Get document_srl
2153
-		$srls = explode(',',Context::get('srls'));
2154
-		for($i = 0; $i < count($srls); $i++)
2153
+		$srls = explode(',', Context::get('srls'));
2154
+		for ($i = 0; $i < count($srls); $i++)
2155 2155
 		{
2156 2156
 			$srl = trim($srls[$i]);
2157 2157
 
2158
-			if(!$srl) continue;
2158
+			if (!$srl) continue;
2159 2159
 
2160 2160
 			$document_srls[] = $srl;
2161 2161
 		}
2162
-		if(!count($document_srls)) return;
2162
+		if (!count($document_srls)) return;
2163 2163
 
2164 2164
 		// Get module_srl of the documents
2165 2165
 		$args = new stdClass;
2166 2166
 		$args->list_count = count($document_srls);
2167
-		$args->document_srls = implode(',',$document_srls);
2167
+		$args->document_srls = implode(',', $document_srls);
2168 2168
 		$args->order_type = 'asc';
2169 2169
 		$output = executeQueryArray('document.getDocuments', $args);
2170
-		if(!$output->data) return new Object();
2170
+		if (!$output->data) return new Object();
2171 2171
 
2172 2172
 		unset($document_srls);
2173
-		foreach($output->data as $key => $val)
2173
+		foreach ($output->data as $key => $val)
2174 2174
 		{
2175 2175
 			$document_srls[$val->module_srl][] = $val->document_srl;
2176 2176
 		}
2177
-		if(!$document_srls || !count($document_srls)) return new Object();
2177
+		if (!$document_srls || !count($document_srls)) return new Object();
2178 2178
 
2179 2179
 		// Check if each of module administrators exists. Top-level administator will have a permission to modify every document of all modules.(Even to modify temporarily saved or trashed documents)
2180 2180
 		$oModuleModel = getModel('module');
2181 2181
 		$module_srls = array_keys($document_srls);
2182
-		for($i=0;$i<count($module_srls);$i++)
2182
+		for ($i = 0; $i < count($module_srls); $i++)
2183 2183
 		{
2184 2184
 			$module_srl = $module_srls[$i];
2185 2185
 			$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
2186 2186
 			$logged_info = Context::get('logged_info');
2187
-			if($logged_info->is_admin != 'Y')
2187
+			if ($logged_info->is_admin != 'Y')
2188 2188
 			{
2189
-				if(!$module_info)
2189
+				if (!$module_info)
2190 2190
 				{
2191 2191
 					unset($document_srls[$module_srl]);
2192 2192
 					continue;
2193 2193
 				}
2194 2194
 				$grant = $oModuleModel->getGrant($module_info, $logged_info);
2195
-				if(!$grant->manager)
2195
+				if (!$grant->manager)
2196 2196
 				{
2197 2197
 					unset($document_srls[$module_srl]);
2198 2198
 					continue;
2199 2199
 				}
2200 2200
 			}
2201 2201
 		}
2202
-		if(!count($document_srls)) return new Object();
2202
+		if (!count($document_srls)) return new Object();
2203 2203
 
2204
-		foreach($document_srls as $module_srl => $documents)
2204
+		foreach ($document_srls as $module_srl => $documents)
2205 2205
 		{
2206 2206
 			$cnt = count($documents);
2207
-			for($i=0;$i<$cnt;$i++)
2207
+			for ($i = 0; $i < $cnt; $i++)
2208 2208
 			{
2209
-				$document_srl = (int)trim($documents[$i]);
2210
-				if(!$document_srls) continue;
2211
-				if($_SESSION['document_management'][$document_srl]) unset($_SESSION['document_management'][$document_srl]);
2209
+				$document_srl = (int) trim($documents[$i]);
2210
+				if (!$document_srls) continue;
2211
+				if ($_SESSION['document_management'][$document_srl]) unset($_SESSION['document_management'][$document_srl]);
2212 2212
 				else $_SESSION['document_management'][$document_srl] = true;
2213 2213
 			}
2214 2214
 		}
@@ -2221,9 +2221,9 @@  discard block
 block discarded – undo
2221 2221
 	function procDocumentManageCheckedDocument()
2222 2222
 	{
2223 2223
 		@set_time_limit(0);
2224
-		if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted');
2224
+		if (!Context::get('is_logged')) return new Object(-1, 'msg_not_permitted');
2225 2225
 
2226
-		if(!checkCSRF())
2226
+		if (!checkCSRF())
2227 2227
 		{
2228 2228
 			return new Object(-1, 'msg_invalid_request');
2229 2229
 		}
@@ -2231,44 +2231,44 @@  discard block
 block discarded – undo
2231 2231
 		$type = Context::get('type');
2232 2232
 		$target_module = Context::get('target_module');
2233 2233
 		$module_srl = Context::get('module_srl');
2234
-		if($target_module && !$module_srl) $module_srl = $target_module;
2234
+		if ($target_module && !$module_srl) $module_srl = $target_module;
2235 2235
 		$category_srl = Context::get('target_category');
2236 2236
 		$message_content = Context::get('message_content');
2237
-		if($message_content) $message_content = nl2br($message_content);
2237
+		if ($message_content) $message_content = nl2br($message_content);
2238 2238
 
2239 2239
 		$cart = Context::get('cart');
2240
-		if(!is_array($cart)) $document_srl_list = explode('|@|', $cart);
2240
+		if (!is_array($cart)) $document_srl_list = explode('|@|', $cart);
2241 2241
 		else $document_srl_list = $cart;
2242 2242
 
2243 2243
 		$document_srl_count = count($document_srl_list);
2244 2244
 
2245 2245
 		$oDocumentModel = getModel('document');
2246 2246
 		$document_items = array();
2247
-		foreach($document_srl_list as $document_srl)
2247
+		foreach ($document_srl_list as $document_srl)
2248 2248
 		{
2249 2249
 			$oDocument = $oDocumentModel->getDocument($document_srl);
2250 2250
 			$document_items[] = $oDocument;
2251
-			if(!$oDocument->isGranted()) return $this->stop('msg_not_permitted');
2251
+			if (!$oDocument->isGranted()) return $this->stop('msg_not_permitted');
2252 2252
 		}
2253 2253
 
2254 2254
 		// Send a message
2255
-		if($message_content)
2255
+		if ($message_content)
2256 2256
 		{
2257 2257
 
2258 2258
 			$oCommunicationController = getController('communication');
2259 2259
 
2260 2260
 			$logged_info = Context::get('logged_info');
2261 2261
 
2262
-			$title = cut_str($message_content,10,'...');
2262
+			$title = cut_str($message_content, 10, '...');
2263 2263
 			$sender_member_srl = $logged_info->member_srl;
2264 2264
 
2265
-			foreach($document_items as $oDocument)
2265
+			foreach ($document_items as $oDocument)
2266 2266
 			{
2267
-				if(!$oDocument->get('member_srl') || $oDocument->get('member_srl')==$sender_member_srl) continue;
2267
+				if (!$oDocument->get('member_srl') || $oDocument->get('member_srl') == $sender_member_srl) continue;
2268 2268
 
2269
-				if($type=='move') $purl = sprintf("<a href=\"%s\" onclick=\"window.open(this.href);return false;\">%s</a>", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl());
2269
+				if ($type == 'move') $purl = sprintf("<a href=\"%s\" onclick=\"window.open(this.href);return false;\">%s</a>", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl());
2270 2270
 				else $purl = "";
2271
-				$content = sprintf("<div>%s</div><hr />%s<div style=\"font-weight:bold\">%s</div>%s",$message_content, $purl, $oDocument->getTitleText(), $oDocument->getContent(false, false, false));
2271
+				$content = sprintf("<div>%s</div><hr />%s<div style=\"font-weight:bold\">%s</div>%s", $message_content, $purl, $oDocument->getTitleText(), $oDocument->getContent(false, false, false));
2272 2272
 
2273 2273
 				$oCommunicationController->sendMessage($sender_member_srl, $oDocument->get('member_srl'), $title, $content, false);
2274 2274
 			}
@@ -2278,54 +2278,54 @@  discard block
 block discarded – undo
2278 2278
 		$oSpamController->setAvoidLog();
2279 2279
 
2280 2280
 		$oDocumentAdminController = getAdminController('document');
2281
-		if($type == 'move')
2281
+		if ($type == 'move')
2282 2282
 		{
2283
-			if(!$module_srl) return new Object(-1, 'fail_to_move');
2283
+			if (!$module_srl) return new Object(-1, 'fail_to_move');
2284 2284
 
2285 2285
 			$output = $oDocumentAdminController->moveDocumentModule($document_srl_list, $module_srl, $category_srl);
2286
-			if(!$output->toBool()) return new Object(-1, 'fail_to_move');
2286
+			if (!$output->toBool()) return new Object(-1, 'fail_to_move');
2287 2287
 
2288 2288
 			$msg_code = 'success_moved';
2289 2289
 
2290 2290
 		}
2291
-		else if($type == 'copy')
2291
+		else if ($type == 'copy')
2292 2292
 		{
2293
-			if(!$module_srl) return new Object(-1, 'fail_to_move');
2293
+			if (!$module_srl) return new Object(-1, 'fail_to_move');
2294 2294
 
2295 2295
 			$output = $oDocumentAdminController->copyDocumentModule($document_srl_list, $module_srl, $category_srl);
2296
-			if(!$output->toBool()) return new Object(-1, 'fail_to_move');
2296
+			if (!$output->toBool()) return new Object(-1, 'fail_to_move');
2297 2297
 
2298 2298
 			$msg_code = 'success_copied';
2299 2299
 		}
2300
-		else if($type =='delete')
2300
+		else if ($type == 'delete')
2301 2301
 		{
2302 2302
 			$oDB = &DB::getInstance();
2303 2303
 			$oDB->begin();
2304
-			for($i=0;$i<$document_srl_count;$i++)
2304
+			for ($i = 0; $i < $document_srl_count; $i++)
2305 2305
 			{
2306 2306
 				$document_srl = $document_srl_list[$i];
2307 2307
 				$output = $this->deleteDocument($document_srl, true);
2308
-				if(!$output->toBool()) return new Object(-1, 'fail_to_delete');
2308
+				if (!$output->toBool()) return new Object(-1, 'fail_to_delete');
2309 2309
 			}
2310 2310
 			$oDB->commit();
2311 2311
 			$msg_code = 'success_deleted';
2312 2312
 		}
2313
-		else if($type == 'trash')
2313
+		else if ($type == 'trash')
2314 2314
 		{
2315 2315
 			$args = new stdClass();
2316 2316
 			$args->description = $message_content;
2317 2317
 
2318 2318
 			$oDB = &DB::getInstance();
2319 2319
 			$oDB->begin();
2320
-			for($i=0;$i<$document_srl_count;$i++) {
2320
+			for ($i = 0; $i < $document_srl_count; $i++) {
2321 2321
 				$args->document_srl = $document_srl_list[$i];
2322 2322
 				$output = $this->moveDocumentToTrash($args);
2323
-				if(!$output || !$output->toBool()) return new Object(-1, 'fail_to_trash');
2323
+				if (!$output || !$output->toBool()) return new Object(-1, 'fail_to_trash');
2324 2324
 			}
2325 2325
 			$oDB->commit();
2326 2326
 			$msg_code = 'success_trashed';
2327 2327
 		}
2328
-		else if($type == 'cancelDeclare')
2328
+		else if ($type == 'cancelDeclare')
2329 2329
 		{
2330 2330
 			$args->document_srl = $document_srl_list;
2331 2331
 			$output = executeQuery('document.deleteDeclaredDocuments', $args);
@@ -2347,27 +2347,27 @@  discard block
 block discarded – undo
2347 2347
 	function procDocumentInsertModuleConfig()
2348 2348
 	{
2349 2349
 		$module_srl = Context::get('target_module_srl');
2350
-		if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl);
2350
+		if (preg_match('/^([0-9,]+)$/', $module_srl)) $module_srl = explode(',', $module_srl);
2351 2351
 		else $module_srl = array($module_srl);
2352 2352
 
2353 2353
 		$document_config = new stdClass();
2354 2354
 		$document_config->use_history = Context::get('use_history');
2355
-		if(!$document_config->use_history) $document_config->use_history = 'N';
2355
+		if (!$document_config->use_history) $document_config->use_history = 'N';
2356 2356
 
2357 2357
 		$document_config->use_vote_up = Context::get('use_vote_up');
2358
-		if(!$document_config->use_vote_up) $document_config->use_vote_up = 'Y';
2358
+		if (!$document_config->use_vote_up) $document_config->use_vote_up = 'Y';
2359 2359
 
2360 2360
 		$document_config->use_vote_down = Context::get('use_vote_down');
2361
-		if(!$document_config->use_vote_down) $document_config->use_vote_down = 'Y';
2361
+		if (!$document_config->use_vote_down) $document_config->use_vote_down = 'Y';
2362 2362
 
2363 2363
 		$document_config->use_status = Context::get('use_status');
2364 2364
 
2365 2365
 		$oModuleController = getController('module');
2366
-		for($i=0;$i<count($module_srl);$i++)
2366
+		for ($i = 0; $i < count($module_srl); $i++)
2367 2367
 		{
2368 2368
 			$srl = trim($module_srl[$i]);
2369
-			if(!$srl) continue;
2370
-			$output = $oModuleController->insertModulePartConfig('document',$srl,$document_config);
2369
+			if (!$srl) continue;
2370
+			$output = $oModuleController->insertModulePartConfig('document', $srl, $document_config);
2371 2371
 		}
2372 2372
 		$this->setError(-1);
2373 2373
 		$this->setMessage('success_updated', 'info');
@@ -2383,7 +2383,7 @@  discard block
 block discarded – undo
2383 2383
 	function procDocumentTempSave()
2384 2384
 	{
2385 2385
 		// Check login information
2386
-		if(!Context::get('is_logged')) return new Object(-1, 'msg_not_logged');
2386
+		if (!Context::get('is_logged')) return new Object(-1, 'msg_not_logged');
2387 2387
 		$module_info = Context::get('module_info');
2388 2388
 		$logged_info = Context::get('logged_info');
2389 2389
 
@@ -2395,7 +2395,7 @@  discard block
 block discarded – undo
2395 2395
 		unset($obj->is_notice);
2396 2396
 
2397 2397
 		// Extract from beginning part of contents in the guestbook
2398
-		if(!$obj->title)
2398
+		if (!$obj->title)
2399 2399
 		{
2400 2400
 			$obj->title = cut_str(strip_tags($obj->content), 20, '...');
2401 2401
 		}
@@ -2406,13 +2406,13 @@  discard block
 block discarded – undo
2406 2406
 		$oDocument = $oDocumentModel->getDocument($obj->document_srl, $this->grant->manager);
2407 2407
 
2408 2408
 		// Update if already exists
2409
-		if($oDocument->isExists() && $oDocument->document_srl == $obj->document_srl)
2409
+		if ($oDocument->isExists() && $oDocument->document_srl == $obj->document_srl)
2410 2410
 		{
2411
-			if($oDocument->get('module_srl') != $obj->module_srl)
2411
+			if ($oDocument->get('module_srl') != $obj->module_srl)
2412 2412
 			{
2413 2413
 				return new Object(-1, 'msg_invalid_request');
2414 2414
 			}
2415
-			if(!$oDocument->isGranted())
2415
+			if (!$oDocument->isGranted())
2416 2416
 			{
2417 2417
 				return new Object(-1, 'msg_invalid_request');
2418 2418
 			}
@@ -2430,7 +2430,7 @@  discard block
 block discarded – undo
2430 2430
 			$oDocument = $oDocumentModel->getDocument($obj->document_srl, $this->grant->manager);
2431 2431
 		}
2432 2432
 		// Set the attachment to be invalid state
2433
-		if($oDocument->hasUploadedFiles())
2433
+		if ($oDocument->hasUploadedFiles())
2434 2434
 		{
2435 2435
 			$args = new stdClass;
2436 2436
 			$args->upload_target_srl = $oDocument->document_srl;
@@ -2448,11 +2448,11 @@  discard block
 block discarded – undo
2448 2448
 	 */
2449 2449
 	function procDocumentGetList()
2450 2450
 	{
2451
-		if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted');
2451
+		if (!Context::get('is_logged')) return new Object(-1, 'msg_not_permitted');
2452 2452
 		$documentSrls = Context::get('document_srls');
2453
-		if($documentSrls) $documentSrlList = explode(',', $documentSrls);
2453
+		if ($documentSrls) $documentSrlList = explode(',', $documentSrls);
2454 2454
 
2455
-		if(count($documentSrlList) > 0)
2455
+		if (count($documentSrlList) > 0)
2456 2456
 		{
2457 2457
 			$oDocumentModel = getModel('document');
2458 2458
 			$columnList = array('document_srl', 'title', 'nick_name', 'status');
@@ -2476,10 +2476,10 @@  discard block
 block discarded – undo
2476 2476
 	 */
2477 2477
 	function _checkCommentStatusForOldVersion(&$obj)
2478 2478
 	{
2479
-		if(!isset($obj->allow_comment)) $obj->allow_comment = 'N';
2480
-		if(!isset($obj->lock_comment)) $obj->lock_comment = 'N';
2479
+		if (!isset($obj->allow_comment)) $obj->allow_comment = 'N';
2480
+		if (!isset($obj->lock_comment)) $obj->lock_comment = 'N';
2481 2481
 
2482
-		if($obj->allow_comment == 'Y' && $obj->lock_comment == 'N') $obj->commentStatus = 'ALLOW';
2482
+		if ($obj->allow_comment == 'Y' && $obj->lock_comment == 'N') $obj->commentStatus = 'ALLOW';
2483 2483
 		else $obj->commentStatus = 'DENY';
2484 2484
 	}
2485 2485
 
@@ -2490,8 +2490,8 @@  discard block
 block discarded – undo
2490 2490
 	 */
2491 2491
 	function _checkDocumentStatusForOldVersion(&$obj)
2492 2492
 	{
2493
-		if(!$obj->status && $obj->is_secret == 'Y') $obj->status = $this->getConfigStatus('secret');
2494
-		if(!$obj->status && $obj->is_secret != 'Y') $obj->status = $this->getConfigStatus('public');
2493
+		if (!$obj->status && $obj->is_secret == 'Y') $obj->status = $this->getConfigStatus('secret');
2494
+		if (!$obj->status && $obj->is_secret != 'Y') $obj->status = $this->getConfigStatus('public');
2495 2495
 	}
2496 2496
 
2497 2497
 	public function updateUploaedCount($documentSrlList)
@@ -2499,10 +2499,10 @@  discard block
 block discarded – undo
2499 2499
 		$oDocumentModel = getModel('document');
2500 2500
 		$oFileModel = getModel('file');
2501 2501
 
2502
-		if(is_array($documentSrlList))
2502
+		if (is_array($documentSrlList))
2503 2503
 		{
2504 2504
 			$documentSrlList = array_unique($documentSrlList);
2505
-			foreach($documentSrlList AS $key => $documentSrl)
2505
+			foreach ($documentSrlList AS $key => $documentSrl)
2506 2506
 			{
2507 2507
 				$fileCount = $oFileModel->getFilesCount($documentSrl);
2508 2508
 				$args = new stdClass();
@@ -2523,14 +2523,14 @@  discard block
 block discarded – undo
2523 2523
 		$oDocumentModel = getModel('document');
2524 2524
 		$documentExtraKeys = $oDocumentModel->getExtraKeys($obj->originModuleSrl);
2525 2525
 
2526
-		if(is_array($documentExtraKeys) && is_array($obj->moduleSrlList))
2526
+		if (is_array($documentExtraKeys) && is_array($obj->moduleSrlList))
2527 2527
 		{
2528
-			$oDocumentController=getController('document');
2529
-			foreach($obj->moduleSrlList AS $key=>$value)
2528
+			$oDocumentController = getController('document');
2529
+			foreach ($obj->moduleSrlList AS $key=>$value)
2530 2530
 			{
2531
-				foreach($documentExtraKeys AS $extraItem)
2531
+				foreach ($documentExtraKeys AS $extraItem)
2532 2532
 				{
2533
-					$oDocumentController->insertDocumentExtraKey($value, $extraItem->idx, $extraItem->name, $extraItem->type, $extraItem->is_required , $extraItem->search , $extraItem->default , $extraItem->desc, $extraItem->eid) ;
2533
+					$oDocumentController->insertDocumentExtraKey($value, $extraItem->idx, $extraItem->name, $extraItem->type, $extraItem->is_required, $extraItem->search, $extraItem->default, $extraItem->desc, $extraItem->eid);
2534 2534
 				}
2535 2535
 			}
2536 2536
 		}
@@ -2542,9 +2542,9 @@  discard block
 block discarded – undo
2542 2542
 		$documentConfig = $oModuleModel->getModulePartConfig('document', $obj->originModuleSrl);
2543 2543
 
2544 2544
 		$oModuleController = getController('module');
2545
-		if(is_array($obj->moduleSrlList))
2545
+		if (is_array($obj->moduleSrlList))
2546 2546
 		{
2547
-			foreach($obj->moduleSrlList AS $key=>$moduleSrl)
2547
+			foreach ($obj->moduleSrlList AS $key=>$moduleSrl)
2548 2548
 			{
2549 2549
 				$oModuleController->insertModulePartConfig('document', $moduleSrl, $documentConfig);
2550 2550
 			}
Please login to merge, or discard this patch.
modules/comment/comment.controller.php 1 patch
Spacing   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -27,13 +27,13 @@  discard block
 block discarded – undo
27 27
 	 */
28 28
 	function procCommentVoteUp()
29 29
 	{
30
-		if(!Context::get('is_logged'))
30
+		if (!Context::get('is_logged'))
31 31
 		{
32 32
 			return new Object(-1, 'msg_invalid_request');
33 33
 		}
34 34
 
35 35
 		$comment_srl = Context::get('target_srl');
36
-		if(!$comment_srl)
36
+		if (!$comment_srl)
37 37
 		{
38 38
 			return new Object(-1, 'msg_invalid_request');
39 39
 		}
@@ -41,14 +41,14 @@  discard block
 block discarded – undo
41 41
 		$oCommentModel = getModel('comment');
42 42
 		$oComment = $oCommentModel->getComment($comment_srl, FALSE, FALSE);
43 43
 		$module_srl = $oComment->get('module_srl');
44
-		if(!$module_srl)
44
+		if (!$module_srl)
45 45
 		{
46 46
 			return new Object(-1, 'msg_invalid_request');
47 47
 		}
48 48
 
49 49
 		$oModuleModel = getModel('module');
50 50
 		$comment_config = $oModuleModel->getModulePartConfig('comment', $module_srl);
51
-		if($comment_config->use_vote_up == 'N')
51
+		if ($comment_config->use_vote_up == 'N')
52 52
 		{
53 53
 			return new Object(-1, 'msg_invalid_request');
54 54
 		}
@@ -65,13 +65,13 @@  discard block
 block discarded – undo
65 65
 	 */
66 66
 	function procCommentVoteDown()
67 67
 	{
68
-		if(!Context::get('is_logged'))
68
+		if (!Context::get('is_logged'))
69 69
 		{
70 70
 			return new Object(-1, 'msg_invalid_request');
71 71
 		}
72 72
 
73 73
 		$comment_srl = Context::get('target_srl');
74
-		if(!$comment_srl)
74
+		if (!$comment_srl)
75 75
 		{
76 76
 			return new Object(-1, 'msg_invalid_request');
77 77
 		}
@@ -79,14 +79,14 @@  discard block
 block discarded – undo
79 79
 		$oCommentModel = getModel('comment');
80 80
 		$oComment = $oCommentModel->getComment($comment_srl, FALSE, FALSE);
81 81
 		$module_srl = $oComment->get('module_srl');
82
-		if(!$module_srl)
82
+		if (!$module_srl)
83 83
 		{
84 84
 			return new Object(-1, 'msg_invalid_request');
85 85
 		}
86 86
 
87 87
 		$oModuleModel = getModel('module');
88 88
 		$comment_config = $oModuleModel->getModulePartConfig('comment', $module_srl);
89
-		if($comment_config->use_vote_down == 'N')
89
+		if ($comment_config->use_vote_down == 'N')
90 90
 		{
91 91
 			return new Object(-1, 'msg_invalid_request');
92 92
 		}
@@ -103,13 +103,13 @@  discard block
 block discarded – undo
103 103
 	 */
104 104
 	function procCommentDeclare()
105 105
 	{
106
-		if(!Context::get('is_logged'))
106
+		if (!Context::get('is_logged'))
107 107
 		{
108 108
 			return new Object(-1, 'msg_invalid_request');
109 109
 		}
110 110
 
111 111
 		$comment_srl = Context::get('target_srl');
112
-		if(!$comment_srl)
112
+		if (!$comment_srl)
113 113
 		{
114 114
 			return new Object(-1, 'msg_invalid_request');
115 115
 		}
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	function triggerDeleteDocumentComments(&$obj)
125 125
 	{
126 126
 		$document_srl = $obj->document_srl;
127
-		if(!$document_srl)
127
+		if (!$document_srl)
128 128
 		{
129 129
 			return new Object();
130 130
 		}
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 	function triggerDeleteModuleComments(&$obj)
140 140
 	{
141 141
 		$module_srl = $obj->module_srl;
142
-		if(!$module_srl)
142
+		if (!$module_srl)
143 143
 		{
144 144
 			return new Object();
145 145
 		}
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	 */
167 167
 	function isModuleUsingPublishValidation($module_srl = NULL)
168 168
 	{
169
-		if($module_srl == NULL)
169
+		if ($module_srl == NULL)
170 170
 		{
171 171
 			return FALSE;
172 172
 		}
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
176 176
 		$module_part_config = $oModuleModel->getModulePartConfig('comment', $module_info->module_srl);
177 177
 		$use_validation = FALSE;
178
-		if(isset($module_part_config->use_comment_validation) && $module_part_config->use_comment_validation == "Y")
178
+		if (isset($module_part_config->use_comment_validation) && $module_part_config->use_comment_validation == "Y")
179 179
 		{
180 180
 			$use_validation = TRUE;
181 181
 		}
@@ -190,12 +190,12 @@  discard block
 block discarded – undo
190 190
 	 */
191 191
 	function insertComment($obj, $manual_inserted = FALSE)
192 192
 	{
193
-		if(!$manual_inserted && !checkCSRF())
193
+		if (!$manual_inserted && !checkCSRF())
194 194
 		{
195 195
 			return new Object(-1, 'msg_invalid_request');
196 196
 		}
197 197
 
198
-		if(!is_object($obj))
198
+		if (!is_object($obj))
199 199
 		{
200 200
 			$obj = new stdClass();
201 201
 		}
@@ -203,12 +203,12 @@  discard block
 block discarded – undo
203 203
 		// check if comment's module is using comment validation and set the publish status to 0 (false)
204 204
 		// for inserting query, otherwise default is 1 (true - means comment is published)
205 205
 		$using_validation = $this->isModuleUsingPublishValidation($obj->module_srl);
206
-		if(!$manual_inserted)
206
+		if (!$manual_inserted)
207 207
 		{
208
-			if(Context::get('is_logged'))
208
+			if (Context::get('is_logged'))
209 209
 			{
210 210
 				$logged_info = Context::get('logged_info');
211
-				if($logged_info->is_admin == 'Y')
211
+				if ($logged_info->is_admin == 'Y')
212 212
 				{
213 213
 					$is_admin = TRUE;
214 214
 				}
@@ -223,13 +223,13 @@  discard block
 block discarded – undo
223 223
 			$is_admin = FALSE;
224 224
 		}
225 225
 
226
-		if(!$using_validation)
226
+		if (!$using_validation)
227 227
 		{
228 228
 			$obj->status = 1;
229 229
 		}
230 230
 		else
231 231
 		{
232
-			if($is_admin)
232
+			if ($is_admin)
233 233
 			{
234 234
 				$obj->status = 1;
235 235
 			}
@@ -242,14 +242,14 @@  discard block
 block discarded – undo
242 242
 
243 243
 		// call a trigger (before)
244 244
 		$output = ModuleHandler::triggerCall('comment.insertComment', 'before', $obj);
245
-		if(!$output->toBool())
245
+		if (!$output->toBool())
246 246
 		{
247 247
 			return $output;
248 248
 		}
249 249
 
250 250
 		// check if a posting of the corresponding document_srl exists
251 251
 		$document_srl = $obj->document_srl;
252
-		if(!$document_srl)
252
+		if (!$document_srl)
253 253
 		{
254 254
 			return new Object(-1, 'msg_invalid_document');
255 255
 		}
@@ -258,36 +258,36 @@  discard block
 block discarded – undo
258 258
 		$oDocumentModel = getModel('document');
259 259
 
260 260
 		// even for manual_inserted if password exists, hash it.
261
-		if($obj->password)
261
+		if ($obj->password)
262 262
 		{
263 263
 			$obj->password = getModel('member')->hashPassword($obj->password);
264 264
 		}
265 265
 
266 266
 		// get the original posting
267
-		if(!$manual_inserted)
267
+		if (!$manual_inserted)
268 268
 		{
269 269
 			$oDocument = $oDocumentModel->getDocument($document_srl);
270 270
 
271
-			if($document_srl != $oDocument->document_srl)
271
+			if ($document_srl != $oDocument->document_srl)
272 272
 			{
273 273
 				return new Object(-1, 'msg_invalid_document');
274 274
 			}
275
-			if($oDocument->isLocked())
275
+			if ($oDocument->isLocked())
276 276
 			{
277 277
 				return new Object(-1, 'msg_invalid_request');
278 278
 			}
279 279
 
280
-			if($obj->homepage)
280
+			if ($obj->homepage)
281 281
 			{
282 282
 				$obj->homepage = removeHackTag($obj->homepage);
283
-				if(!preg_match('/^[a-z]+:\/\//i',$obj->homepage))
283
+				if (!preg_match('/^[a-z]+:\/\//i', $obj->homepage))
284 284
 				{
285 285
 					$obj->homepage = 'http://'.$obj->homepage;
286 286
 				}
287 287
 			}
288 288
 
289 289
 			// input the member's information if logged-in
290
-			if(Context::get('is_logged'))
290
+			if (Context::get('is_logged'))
291 291
 			{
292 292
 				$logged_info = Context::get('logged_info');
293 293
 				$obj->member_srl = $logged_info->member_srl;
@@ -302,16 +302,16 @@  discard block
 block discarded – undo
302 302
 		}
303 303
 
304 304
 		// error display if neither of log-in info and user name exist.
305
-		if(!$logged_info->member_srl && !$obj->nick_name)
305
+		if (!$logged_info->member_srl && !$obj->nick_name)
306 306
 		{
307 307
 			return new Object(-1, 'msg_invalid_request');
308 308
 		}
309 309
 
310
-		if(!$obj->comment_srl)
310
+		if (!$obj->comment_srl)
311 311
 		{
312 312
 			$obj->comment_srl = getNextSequence();
313 313
 		}
314
-		elseif(!$is_admin && !$manual_inserted && !checkUserSequence($obj->comment_srl)) 
314
+		elseif (!$is_admin && !$manual_inserted && !checkUserSequence($obj->comment_srl)) 
315 315
 		{
316 316
 			return new Object(-1, 'msg_not_permitted');
317 317
 		}
@@ -322,32 +322,32 @@  discard block
 block discarded – undo
322 322
 		// remove XE's own tags from the contents
323 323
 		$obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content);
324 324
 
325
-		if(Mobile::isFromMobilePhone())
325
+		if (Mobile::isFromMobilePhone())
326 326
 		{
327
-			if($obj->use_html != 'Y')
327
+			if ($obj->use_html != 'Y')
328 328
 			{
329 329
 				$obj->content = htmlspecialchars($obj->content, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
330 330
 			}
331 331
 			$obj->content = nl2br($obj->content);
332 332
 		}
333 333
 
334
-		if(!$obj->regdate)
334
+		if (!$obj->regdate)
335 335
 		{
336 336
 			$obj->regdate = date("YmdHis");
337 337
 		}
338 338
 
339 339
 		// remove iframe and script if not a top administrator on the session.
340
-		if($logged_info->is_admin != 'Y')
340
+		if ($logged_info->is_admin != 'Y')
341 341
 		{
342 342
 			$obj->content = removeHackTag($obj->content);
343 343
 		}
344 344
 
345
-		if(!$obj->notify_message)
345
+		if (!$obj->notify_message)
346 346
 		{
347 347
 			$obj->notify_message = 'N';
348 348
 		}
349 349
 
350
-		if(!$obj->is_secret)
350
+		if (!$obj->is_secret)
351 351
 		{
352 352
 			$obj->is_secret = 'N';
353 353
 		}
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 		$list_args->regdate = $obj->regdate;
365 365
 
366 366
 		// If parent comment doesn't exist, set data directly
367
-		if(!$obj->parent_srl)
367
+		if (!$obj->parent_srl)
368 368
 		{
369 369
 			$list_args->head = $list_args->arrange = $obj->comment_srl;
370 370
 			$list_args->depth = 0;
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 			$parent_output = executeQuery('comment.getCommentListItem', $parent_args);
379 379
 
380 380
 			// return if no parent comment exists
381
-			if(!$parent_output->toBool() || !$parent_output->data)
381
+			if (!$parent_output->toBool() || !$parent_output->data)
382 382
 			{
383 383
 				return;
384 384
 			}
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 			$list_args->depth = $parent->depth + 1;
390 390
 
391 391
 			// if the depth of comments is less than 2, execute insert.
392
-			if($list_args->depth < 2)
392
+			if ($list_args->depth < 2)
393 393
 			{
394 394
 				$list_args->arrange = $obj->comment_srl;
395 395
 				// if the depth of comments is greater than 2, execute update.
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 				$p_args->depth = $parent->depth;
404 404
 				$output = executeQuery('comment.getCommentParentNextSibling', $p_args);
405 405
 
406
-				if($output->data->arrange)
406
+				if ($output->data->arrange)
407 407
 				{
408 408
 					$list_args->arrange = $output->data->arrange;
409 409
 					$output = executeQuery('comment.updateCommentListArrange', $list_args);
@@ -416,14 +416,14 @@  discard block
 block discarded – undo
416 416
 		}
417 417
 
418 418
 		$output = executeQuery('comment.insertCommentList', $list_args);
419
-		if(!$output->toBool())
419
+		if (!$output->toBool())
420 420
 		{
421 421
 			return $output;
422 422
 		}
423 423
 
424 424
 		// insert comment
425 425
 		$output = executeQuery('comment.insertComment', $obj);
426
-		if(!$output->toBool())
426
+		if (!$output->toBool())
427 427
 		{
428 428
 			$oDB->rollback();
429 429
 			return $output;
@@ -439,29 +439,29 @@  discard block
 block discarded – undo
439 439
 		$oDocumentController = getController('document');
440 440
 
441 441
 		// Update the number of comments in the post
442
-		if(!$using_validation)
442
+		if (!$using_validation)
443 443
 		{
444 444
 			$output = $oDocumentController->updateCommentCount($document_srl, $comment_count, $obj->nick_name, TRUE);
445 445
 		}
446 446
 		else
447 447
 		{
448
-			if($is_admin)
448
+			if ($is_admin)
449 449
 			{
450 450
 				$output = $oDocumentController->updateCommentCount($document_srl, $comment_count, $obj->nick_name, TRUE);
451 451
 			}
452 452
 		}
453 453
 
454 454
 		// grant autority of the comment
455
-		if(!$manual_inserted)
455
+		if (!$manual_inserted)
456 456
 		{
457 457
 			$this->addGrant($obj->comment_srl);
458 458
 		}
459 459
 
460 460
 		// call a trigger(after)
461
-		if($output->toBool())
461
+		if ($output->toBool())
462 462
 		{
463 463
 			$trigger_output = ModuleHandler::triggerCall('comment.insertComment', 'after', $obj);
464
-			if(!$trigger_output->toBool())
464
+			if (!$trigger_output->toBool())
465 465
 			{
466 466
 				$oDB->rollback();
467 467
 				return $trigger_output;
@@ -471,16 +471,16 @@  discard block
 block discarded – undo
471 471
 		// commit
472 472
 		$oDB->commit();
473 473
 
474
-		if(!$manual_inserted)
474
+		if (!$manual_inserted)
475 475
 		{
476 476
 			// send a message if notify_message option in enabled in the original article
477 477
 			$oDocument->notify(Context::getLang('comment'), $obj->content);
478 478
 
479 479
 			// send a message if notify_message option in enabled in the original comment
480
-			if($obj->parent_srl)
480
+			if ($obj->parent_srl)
481 481
 			{
482 482
 				$oParent = $oCommentModel->getComment($obj->parent_srl);
483
-				if($oParent->get('member_srl') != $oDocument->get('member_srl'))
483
+				if ($oParent->get('member_srl') != $oDocument->get('member_srl'))
484 484
 				{
485 485
 					$oParent->notify(Context::getLang('comment'), $obj->content);
486 486
 				}
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
 		$oDocument = $oDocumentModel->getDocument($obj->document_srl);
509 509
 
510 510
 		$oMemberModel = getModel("member");
511
-		if(isset($obj->member_srl) && !is_null($obj->member_srl))
511
+		if (isset($obj->member_srl) && !is_null($obj->member_srl))
512 512
 		{
513 513
 			$member_info = $oMemberModel->getMemberInfoByMemberSrl($obj->member_srl);
514 514
 		}
@@ -528,47 +528,47 @@  discard block
 block discarded – undo
528 528
 		$module_info = $oModuleModel->getModuleInfoByDocumentSrl($obj->document_srl);
529 529
 
530 530
 		// If there is no problem to register comment then send an email to all admin were set in module admin panel
531
-		if($module_info->admin_mail && $member_info->is_admin != 'Y')
531
+		if ($module_info->admin_mail && $member_info->is_admin != 'Y')
532 532
 		{
533 533
 			$oMail = new Mail();
534 534
 			$oMail->setSender($obj->email_address, $obj->email_address);
535
-			$mail_title = "[XE - " . Context::get('mid') . "] A new comment was posted on document: \"" . $oDocument->getTitleText() . "\"";
535
+			$mail_title = "[XE - ".Context::get('mid')."] A new comment was posted on document: \"".$oDocument->getTitleText()."\"";
536 536
 			$oMail->setTitle($mail_title);
537
-			$url_comment = getFullUrl('','document_srl',$obj->document_srl).'#comment_'.$obj->comment_srl;
538
-			if($using_validation)
537
+			$url_comment = getFullUrl('', 'document_srl', $obj->document_srl).'#comment_'.$obj->comment_srl;
538
+			if ($using_validation)
539 539
 			{
540 540
 				$url_approve = getFullUrl('', 'module', 'admin', 'act', 'procCommentAdminChangePublishedStatusChecked', 'cart[]', $obj->comment_srl, 'will_publish', '1', 'search_target', 'is_published', 'search_keyword', 'N');
541 541
 				$url_trash = getFullUrl('', 'module', 'admin', 'act', 'procCommentAdminDeleteChecked', 'cart[]', $obj->comment_srl, 'search_target', 'is_trash', 'search_keyword', 'true');
542 542
 				$mail_content = "
543
-					A new comment on the document \"" . $oDocument->getTitleText() . "\" is waiting for your approval.
543
+					A new comment on the document \"" . $oDocument->getTitleText()."\" is waiting for your approval.
544 544
 					<br />
545 545
 					<br />
546
-					Author: " . $member_info->nick_name . "
547
-					<br />Author e-mail: " . $member_info->email_address . "
548
-					<br />From : <a href=\"" . $url_comment . "\">" . $url_comment . "</a>
546
+					Author: " . $member_info->nick_name."
547
+					<br />Author e-mail: " . $member_info->email_address."
548
+					<br />From : <a href=\"" . $url_comment."\">".$url_comment."</a>
549 549
 					<br />Comment:
550
-					<br />\"" . $obj->content . "\"
550
+					<br />\"" . $obj->content."\"
551 551
 					<br />Document:
552
-					<br />\"" . $oDocument->getContentText(). "\"
552
+					<br />\"" . $oDocument->getContentText()."\"
553 553
 					<br />
554 554
 					<br />
555
-					Approve it: <a href=\"" . $url_approve . "\">" . $url_approve . "</a>
556
-					<br />Trash it: <a href=\"" . $url_trash . "\">" . $url_trash . "</a>
557
-					<br />Currently " . $nr_comments_not_approved . " comments on \"" . Context::get('mid') . "\" module are waiting for approval. Please visit the moderation panel:
558
-					<br /><a href=\"" . getFullUrl('', 'module', 'admin', 'act', 'dispCommentAdminList', 'search_target', 'module', 'search_keyword', $obj->module_srl) . "\">" . getFullUrl('', 'module', 'admin', 'act', 'dispCommentAdminList', 'search_target', 'module', 'search_keyword', $obj->module_srl) . "</a>
555
+					Approve it: <a href=\"" . $url_approve."\">".$url_approve."</a>
556
+					<br />Trash it: <a href=\"" . $url_trash."\">".$url_trash."</a>
557
+					<br />Currently " . $nr_comments_not_approved." comments on \"".Context::get('mid')."\" module are waiting for approval. Please visit the moderation panel:
558
+					<br /><a href=\"" . getFullUrl('', 'module', 'admin', 'act', 'dispCommentAdminList', 'search_target', 'module', 'search_keyword', $obj->module_srl)."\">".getFullUrl('', 'module', 'admin', 'act', 'dispCommentAdminList', 'search_target', 'module', 'search_keyword', $obj->module_srl)."</a>
559 559
 					";
560 560
 				$oMail->setContent($mail_content);
561 561
 			}
562 562
 			else
563 563
 			{
564 564
 				$mail_content = "
565
-					Author: " . $member_info->nick_name . "
566
-					<br />Author e-mail: " . $member_info->email_address . "
567
-					<br />From : <a href=\"" . $url_comment . "\">" . $url_comment . "</a>
565
+					Author: " . $member_info->nick_name."
566
+					<br />Author e-mail: " . $member_info->email_address."
567
+					<br />From : <a href=\"" . $url_comment."\">".$url_comment."</a>
568 568
 					<br />Comment:
569
-					<br />\"" . $obj->content . "\"
569
+					<br />\"" . $obj->content."\"
570 570
 					<br />Document:
571
-					<br />\"" . $oDocument->getContentText(). "\"
571
+					<br />\"" . $oDocument->getContentText()."\"
572 572
 					";
573 573
 				$oMail->setContent($mail_content);
574 574
 
@@ -597,10 +597,10 @@  discard block
 block discarded – undo
597 597
 			$target_mail = explode(',', $admins_emails);
598 598
 
599 599
 			// send email to all admins - START
600
-			for($i = 0; $i < count($target_mail); $i++)
600
+			for ($i = 0; $i < count($target_mail); $i++)
601 601
 			{
602 602
 				$email_address = trim($target_mail[$i]);
603
-				if(!$email_address)
603
+				if (!$email_address)
604 604
 				{
605 605
 					continue;
606 606
 				}
@@ -646,12 +646,12 @@  discard block
 block discarded – undo
646 646
 	 */
647 647
 	function updateComment($obj, $is_admin = FALSE, $manual_updated = FALSE)
648 648
 	{
649
-		if(!$manual_updated && !checkCSRF())
649
+		if (!$manual_updated && !checkCSRF())
650 650
 		{
651 651
 			return new Object(-1, 'msg_invalid_request');
652 652
 		}
653 653
 
654
-		if(!is_object($obj))
654
+		if (!is_object($obj))
655 655
 		{
656 656
 			$obj = new stdClass();
657 657
 		}
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
 
661 661
 		// call a trigger (before)
662 662
 		$output = ModuleHandler::triggerCall('comment.updateComment', 'before', $obj);
663
-		if(!$output->toBool())
663
+		if (!$output->toBool())
664 664
 		{
665 665
 			return $output;
666 666
 		}
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
 
671 671
 		// get the original data
672 672
 		$source_obj = $oCommentModel->getComment($obj->comment_srl);
673
-		if(!$source_obj->getMemberSrl())
673
+		if (!$source_obj->getMemberSrl())
674 674
 		{
675 675
 			$obj->member_srl = $source_obj->get('member_srl');
676 676
 			$obj->user_name = $source_obj->get('user_name');
@@ -680,30 +680,30 @@  discard block
 block discarded – undo
680 680
 		}
681 681
 
682 682
 		// check if permission is granted
683
-		if(!$is_admin && !$source_obj->isGranted())
683
+		if (!$is_admin && !$source_obj->isGranted())
684 684
 		{
685 685
 			return new Object(-1, 'msg_not_permitted');
686 686
 		}
687 687
 
688
-		if($obj->password)
688
+		if ($obj->password)
689 689
 		{
690 690
 			$obj->password = getModel('member')->hashPassword($obj->password);
691 691
 		}
692 692
 
693
-		if($obj->homepage) 
693
+		if ($obj->homepage) 
694 694
 		{
695 695
 			$obj->homepage = removeHackTag($obj->homepage);
696
-			if(!preg_match('/^[a-z]+:\/\//i',$obj->homepage))
696
+			if (!preg_match('/^[a-z]+:\/\//i', $obj->homepage))
697 697
 			{
698 698
 				$obj->homepage = 'http://'.$obj->homepage;
699 699
 			}
700 700
 		}
701 701
 
702 702
 		// set modifier's information if logged-in and posting author and modifier are matched.
703
-		if(Context::get('is_logged'))
703
+		if (Context::get('is_logged'))
704 704
 		{
705 705
 			$logged_info = Context::get('logged_info');
706
-			if($source_obj->member_srl == $logged_info->member_srl)
706
+			if ($source_obj->member_srl == $logged_info->member_srl)
707 707
 			{
708 708
 				$obj->member_srl = $logged_info->member_srl;
709 709
 				$obj->user_name = $logged_info->user_name;
@@ -714,7 +714,7 @@  discard block
 block discarded – undo
714 714
 		}
715 715
 
716 716
 		// if nick_name of the logged-in author doesn't exist
717
-		if($source_obj->get('member_srl') && !$obj->nick_name)
717
+		if ($source_obj->get('member_srl') && !$obj->nick_name)
718 718
 		{
719 719
 			$obj->member_srl = $source_obj->get('member_srl');
720 720
 			$obj->user_name = $source_obj->get('user_name');
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 			$obj->homepage = $source_obj->get('homepage');
724 724
 		}
725 725
 
726
-		if(!$obj->content)
726
+		if (!$obj->content)
727 727
 		{
728 728
 			$obj->content = $source_obj->get('content');
729 729
 		}
@@ -731,9 +731,9 @@  discard block
 block discarded – undo
731 731
 		// remove XE's wn tags from contents
732 732
 		$obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content);
733 733
 
734
-		if(Mobile::isFromMobilePhone())
734
+		if (Mobile::isFromMobilePhone())
735 735
 		{
736
-			if($obj->use_html != 'Y')
736
+			if ($obj->use_html != 'Y')
737 737
 			{
738 738
 				$obj->content = htmlspecialchars($obj->content, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
739 739
 			}
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
 		}
742 742
 
743 743
 		// remove iframe and script if not a top administrator on the session
744
-		if($logged_info->is_admin != 'Y')
744
+		if ($logged_info->is_admin != 'Y')
745 745
 		{
746 746
 			$obj->content = removeHackTag($obj->content);
747 747
 		}
@@ -752,17 +752,17 @@  discard block
 block discarded – undo
752 752
 
753 753
 		// Update
754 754
 		$output = executeQuery('comment.updateComment', $obj);
755
-		if(!$output->toBool())
755
+		if (!$output->toBool())
756 756
 		{
757 757
 			$oDB->rollback();
758 758
 			return $output;
759 759
 		}
760 760
 
761 761
 		// call a trigger (after)
762
-		if($output->toBool())
762
+		if ($output->toBool())
763 763
 		{
764 764
 			$trigger_output = ModuleHandler::triggerCall('comment.updateComment', 'after', $obj);
765
-			if(!$trigger_output->toBool())
765
+			if (!$trigger_output->toBool())
766 766
 			{
767 767
 				$oDB->rollback();
768 768
 				return $trigger_output;
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
 
792 792
 		// check if comment already exists
793 793
 		$comment = $oCommentModel->getComment($comment_srl);
794
-		if($comment->comment_srl != $comment_srl)
794
+		if ($comment->comment_srl != $comment_srl)
795 795
 		{
796 796
 			return new Object(-1, 'msg_invalid_request');
797 797
 		}
@@ -800,28 +800,28 @@  discard block
 block discarded – undo
800 800
 
801 801
 		// call a trigger (before)
802 802
 		$output = ModuleHandler::triggerCall('comment.deleteComment', 'before', $comment);
803
-		if(!$output->toBool())
803
+		if (!$output->toBool())
804 804
 		{
805 805
 			return $output;
806 806
 		}
807 807
 
808 808
 		// check if permission is granted
809
-		if(!$is_admin && !$comment->isGranted())
809
+		if (!$is_admin && !$comment->isGranted())
810 810
 		{
811 811
 			return new Object(-1, 'msg_not_permitted');
812 812
 		}
813 813
 
814 814
 		// check if child comment exists on the comment
815 815
 		$childs = $oCommentModel->getChildComments($comment_srl);
816
-		if(count($childs) > 0)
816
+		if (count($childs) > 0)
817 817
 		{
818 818
 			$deleteAllComment = TRUE;
819
-			if(!$is_admin)
819
+			if (!$is_admin)
820 820
 			{
821 821
 				$logged_info = Context::get('logged_info');
822
-				foreach($childs as $val)
822
+				foreach ($childs as $val)
823 823
 				{
824
-					if($val->member_srl != $logged_info->member_srl)
824
+					if ($val->member_srl != $logged_info->member_srl)
825 825
 					{
826 826
 						$deleteAllComment = FALSE;
827 827
 						break;
@@ -829,16 +829,16 @@  discard block
 block discarded – undo
829 829
 				}
830 830
 			}
831 831
 
832
-			if(!$deleteAllComment)
832
+			if (!$deleteAllComment)
833 833
 			{
834 834
 				return new Object(-1, 'fail_to_delete_have_children');
835 835
 			}
836 836
 			else
837 837
 			{
838
-				foreach($childs as $val)
838
+				foreach ($childs as $val)
839 839
 				{
840 840
 					$output = $this->deleteComment($val->comment_srl, $is_admin, $isMoveToTrash);
841
-					if(!$output->toBool())
841
+					if (!$output->toBool())
842 842
 					{
843 843
 						return $output;
844 844
 					}
@@ -854,7 +854,7 @@  discard block
 block discarded – undo
854 854
 		$args = new stdClass();
855 855
 		$args->comment_srl = $comment_srl;
856 856
 		$output = executeQuery('comment.deleteComment', $args);
857
-		if(!$output->toBool())
857
+		if (!$output->toBool())
858 858
 		{
859 859
 			$oDB->rollback();
860 860
 			return $output;
@@ -866,14 +866,14 @@  discard block
 block discarded – undo
866 866
 		$comment_count = $oCommentModel->getCommentCount($document_srl);
867 867
 
868 868
 		// only document is exists
869
-		if(isset($comment_count))
869
+		if (isset($comment_count))
870 870
 		{
871 871
 			// create the controller object of the document
872 872
 			$oDocumentController = getController('document');
873 873
 
874 874
 			// update comment count of the article posting
875 875
 			$output = $oDocumentController->updateCommentCount($document_srl, $comment_count, NULL, FALSE);
876
-			if(!$output->toBool())
876
+			if (!$output->toBool())
877 877
 			{
878 878
 				$oDB->rollback();
879 879
 				return $output;
@@ -881,11 +881,11 @@  discard block
 block discarded – undo
881 881
 		}
882 882
 
883 883
 		// call a trigger (after)
884
-		if($output->toBool())
884
+		if ($output->toBool())
885 885
 		{
886 886
 			$comment->isMoveToTrash = $isMoveToTrash;
887 887
 			$trigger_output = ModuleHandler::triggerCall('comment.deleteComment', 'after', $comment);
888
-			if(!$trigger_output->toBool())
888
+			if (!$trigger_output->toBool())
889 889
 			{
890 890
 				$oDB->rollback();
891 891
 				return $trigger_output;
@@ -893,7 +893,7 @@  discard block
 block discarded – undo
893 893
 			unset($comment->isMoveToTrash);
894 894
 		}
895 895
 
896
-		if(!$isMoveToTrash)
896
+		if (!$isMoveToTrash)
897 897
 		{
898 898
 			$this->_deleteDeclaredComments($args);
899 899
 			$this->_deleteVotedComments($args);
@@ -937,7 +937,7 @@  discard block
 block discarded – undo
937 937
 		$oCommentModel = getModel('comment');
938 938
 
939 939
 		// check if permission is granted
940
-		if(is_object($obj))
940
+		if (is_object($obj))
941 941
 		{
942 942
 			$oDocument = new documentItem();
943 943
 			$oDocument->setAttribute($obj);
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
 			$oDocument = $oDocumentModel->getDocument($document_srl);
948 948
 		}
949 949
 
950
-		if(!$oDocument->isExists() || !$oDocument->isGranted())
950
+		if (!$oDocument->isExists() || !$oDocument->isGranted())
951 951
 		{
952 952
 			return new Object(-1, 'msg_not_permitted');
953 953
 		}
@@ -956,23 +956,23 @@  discard block
 block discarded – undo
956 956
 		$args = new stdClass();
957 957
 		$args->document_srl = $document_srl;
958 958
 		$comments = executeQueryArray('comment.getAllComments', $args);
959
-		if($comments->data)
959
+		if ($comments->data)
960 960
 		{
961 961
 			$commentSrlList = array();
962
-			foreach($comments->data as $comment)
962
+			foreach ($comments->data as $comment)
963 963
 			{
964 964
 				$commentSrlList[] = $comment->comment_srl;
965 965
 
966 966
 				// call a trigger (before)
967 967
 				$output = ModuleHandler::triggerCall('comment.deleteComment', 'before', $comment);
968
-				if(!$output->toBool())
968
+				if (!$output->toBool())
969 969
 				{
970 970
 					continue;
971 971
 				}
972 972
 
973 973
 				// call a trigger (after)
974 974
 				$output = ModuleHandler::triggerCall('comment.deleteComment', 'after', $comment);
975
-				if(!$output->toBool())
975
+				if (!$output->toBool())
976 976
 				{
977 977
 					continue;
978 978
 				}
@@ -982,7 +982,7 @@  discard block
 block discarded – undo
982 982
 		// delete the comment
983 983
 		$args->document_srl = $document_srl;
984 984
 		$output = executeQuery('comment.deleteComments', $args);
985
-		if(!$output->toBool())
985
+		if (!$output->toBool())
986 986
 		{
987 987
 			return $output;
988 988
 		}
@@ -991,7 +991,7 @@  discard block
 block discarded – undo
991 991
 		$output = executeQuery('comment.deleteCommentsList', $args);
992 992
 
993 993
 		//delete declared, declared_log, voted_log
994
-		if(is_array($commentSrlList) && count($commentSrlList) > 0)
994
+		if (is_array($commentSrlList) && count($commentSrlList) > 0)
995 995
 		{
996 996
 			$args = new stdClass();
997 997
 			$args->comment_srl = join(',', $commentSrlList);
@@ -1031,7 +1031,7 @@  discard block
 block discarded – undo
1031 1031
 	 */
1032 1032
 	function updateVotedCount($comment_srl, $point = 1)
1033 1033
 	{
1034
-		if($point > 0)
1034
+		if ($point > 0)
1035 1035
 		{
1036 1036
 			$failed_voted = 'failed_voted';
1037 1037
 			$success_message = 'success_voted';
@@ -1043,7 +1043,7 @@  discard block
 block discarded – undo
1043 1043
 		}
1044 1044
 
1045 1045
 		// invalid vote if vote info exists in the session info.
1046
-		if($_SESSION['voted_comment'][$comment_srl])
1046
+		if ($_SESSION['voted_comment'][$comment_srl])
1047 1047
 		{
1048 1048
 			return new Object(-1, $failed_voted);
1049 1049
 		}
@@ -1052,21 +1052,21 @@  discard block
 block discarded – undo
1052 1052
 		$oComment = $oCommentModel->getComment($comment_srl, FALSE, FALSE);
1053 1053
 
1054 1054
 		// invalid vote if both ip addresses between author's and the current user are same.
1055
-		if($oComment->get('ipaddress') == $_SERVER['REMOTE_ADDR'])
1055
+		if ($oComment->get('ipaddress') == $_SERVER['REMOTE_ADDR'])
1056 1056
 		{
1057 1057
 			$_SESSION['voted_comment'][$comment_srl] = TRUE;
1058 1058
 			return new Object(-1, $failed_voted);
1059 1059
 		}
1060 1060
 
1061 1061
 		// if the comment author is a member
1062
-		if($oComment->get('member_srl'))
1062
+		if ($oComment->get('member_srl'))
1063 1063
 		{
1064 1064
 			// create the member model object
1065 1065
 			$oMemberModel = getModel('member');
1066 1066
 			$member_srl = $oMemberModel->getLoggedMemberSrl();
1067 1067
 
1068 1068
 			// session registered if the author information matches to the current logged-in user's.
1069
-			if($member_srl && $member_srl == abs($oComment->get('member_srl')))
1069
+			if ($member_srl && $member_srl == abs($oComment->get('member_srl')))
1070 1070
 			{
1071 1071
 				$_SESSION['voted_comment'][$comment_srl] = TRUE;
1072 1072
 				return new Object(-1, $failed_voted);
@@ -1076,7 +1076,7 @@  discard block
 block discarded – undo
1076 1076
 		$args = new stdClass();
1077 1077
 
1078 1078
 		// If logged-in, use the member_srl. otherwise use the ipaddress.
1079
-		if($member_srl)
1079
+		if ($member_srl)
1080 1080
 		{
1081 1081
 			$args->member_srl = $member_srl;
1082 1082
 		}
@@ -1089,7 +1089,7 @@  discard block
 block discarded – undo
1089 1089
 		$output = executeQuery('comment.getCommentVotedLogInfo', $args);
1090 1090
 
1091 1091
 		// session registered if log info contains recommendation vote log.
1092
-		if($output->data->count)
1092
+		if ($output->data->count)
1093 1093
 		{
1094 1094
 			$_SESSION['voted_comment'][$comment_srl] = TRUE;
1095 1095
 			return new Object(-1, $failed_voted);
@@ -1100,7 +1100,7 @@  discard block
 block discarded – undo
1100 1100
 		$oDB->begin();
1101 1101
 
1102 1102
 		// update the number of votes
1103
-		if($point < 0)
1103
+		if ($point < 0)
1104 1104
 		{
1105 1105
 			$args->blamed_count = $oComment->get('blamed_count') + $point;
1106 1106
 			$output = executeQuery('comment.updateBlamedCount', $args);
@@ -1124,7 +1124,7 @@  discard block
 block discarded – undo
1124 1124
 		$obj->before_point = ($point < 0) ? $oComment->get('blamed_count') : $oComment->get('voted_count');
1125 1125
 		$obj->after_point = ($point < 0) ? $args->blamed_count : $args->voted_count;
1126 1126
 		$trigger_output = ModuleHandler::triggerCall('comment.updateVotedCount', 'after', $obj);
1127
-		if(!$trigger_output->toBool())
1127
+		if (!$trigger_output->toBool())
1128 1128
 		{
1129 1129
 			$oDB->rollback();
1130 1130
 			return $trigger_output;
@@ -1137,7 +1137,7 @@  discard block
 block discarded – undo
1137 1137
 
1138 1138
 		// Return the result
1139 1139
 		$output = new Object(0, $success_message);
1140
-		if($point > 0)
1140
+		if ($point > 0)
1141 1141
 		{
1142 1142
 			$output->add('voted_count', $obj->after_point);
1143 1143
 		}
@@ -1157,7 +1157,7 @@  discard block
 block discarded – undo
1157 1157
 	function declaredComment($comment_srl)
1158 1158
 	{
1159 1159
 		// Fail if session information already has a reported document
1160
-		if($_SESSION['declared_comment'][$comment_srl])
1160
+		if ($_SESSION['declared_comment'][$comment_srl])
1161 1161
 		{
1162 1162
 			return new Object(-1, 'failed_declared');
1163 1163
 		}
@@ -1166,7 +1166,7 @@  discard block
 block discarded – undo
1166 1166
 		$args = new stdClass();
1167 1167
 		$args->comment_srl = $comment_srl;
1168 1168
 		$output = executeQuery('comment.getDeclaredComment', $args);
1169
-		if(!$output->toBool())
1169
+		if (!$output->toBool())
1170 1170
 		{
1171 1171
 			return $output;
1172 1172
 		}
@@ -1178,7 +1178,7 @@  discard block
 block discarded – undo
1178 1178
 
1179 1179
 		// Call a trigger (before)
1180 1180
 		$trigger_output = ModuleHandler::triggerCall('comment.declaredComment', 'before', $trigger_obj);
1181
-		if(!$trigger_output->toBool())
1181
+		if (!$trigger_output->toBool())
1182 1182
 		{
1183 1183
 			return $trigger_output;
1184 1184
 		}
@@ -1188,21 +1188,21 @@  discard block
 block discarded – undo
1188 1188
 		$oComment = $oCommentModel->getComment($comment_srl, FALSE, FALSE);
1189 1189
 
1190 1190
 		// failed if both ip addresses between author's and the current user are same.
1191
-		if($oComment->get('ipaddress') == $_SERVER['REMOTE_ADDR'])
1191
+		if ($oComment->get('ipaddress') == $_SERVER['REMOTE_ADDR'])
1192 1192
 		{
1193 1193
 			$_SESSION['declared_comment'][$comment_srl] = TRUE;
1194 1194
 			return new Object(-1, 'failed_declared');
1195 1195
 		}
1196 1196
 
1197 1197
 		// if the comment author is a member
1198
-		if($oComment->get('member_srl'))
1198
+		if ($oComment->get('member_srl'))
1199 1199
 		{
1200 1200
 			// create the member model object
1201 1201
 			$oMemberModel = getModel('member');
1202 1202
 			$member_srl = $oMemberModel->getLoggedMemberSrl();
1203 1203
 
1204 1204
 			// session registered if the author information matches to the current logged-in user's.
1205
-			if($member_srl && $member_srl == abs($oComment->get('member_srl')))
1205
+			if ($member_srl && $member_srl == abs($oComment->get('member_srl')))
1206 1206
 			{
1207 1207
 				$_SESSION['declared_comment'][$comment_srl] = TRUE;
1208 1208
 				return new Object(-1, 'failed_declared');
@@ -1210,7 +1210,7 @@  discard block
 block discarded – undo
1210 1210
 		}
1211 1211
 
1212 1212
 		// If logged-in, use the member_srl. otherwise use the ipaddress.
1213
-		if($member_srl)
1213
+		if ($member_srl)
1214 1214
 		{
1215 1215
 			$args->member_srl = $member_srl;
1216 1216
 		}
@@ -1222,7 +1222,7 @@  discard block
 block discarded – undo
1222 1222
 		$log_output = executeQuery('comment.getCommentDeclaredLogInfo', $args);
1223 1223
 
1224 1224
 		// session registered if log info contains report log.
1225
-		if($log_output->data->count)
1225
+		if ($log_output->data->count)
1226 1226
 		{
1227 1227
 			$_SESSION['declared_comment'][$comment_srl] = TRUE;
1228 1228
 			return new Object(-1, 'failed_declared');
@@ -1233,7 +1233,7 @@  discard block
 block discarded – undo
1233 1233
 		$oDB->begin();
1234 1234
 
1235 1235
 		// execute insert
1236
-		if($output->data->declared_count > 0)
1236
+		if ($output->data->declared_count > 0)
1237 1237
 		{
1238 1238
 			$output = executeQuery('comment.updateDeclaredComment', $args);
1239 1239
 		}
@@ -1242,7 +1242,7 @@  discard block
 block discarded – undo
1242 1242
 			$output = executeQuery('comment.insertDeclaredComment', $args);
1243 1243
 		}
1244 1244
 
1245
-		if(!$output->toBool())
1245
+		if (!$output->toBool())
1246 1246
 		{
1247 1247
 			$oDB->rollback();
1248 1248
 			return $output;
@@ -1254,7 +1254,7 @@  discard block
 block discarded – undo
1254 1254
 		// Call a trigger (after)
1255 1255
 		$trigger_obj->declared_count = $declared_count + 1;
1256 1256
 		$trigger_output = ModuleHandler::triggerCall('comment.declaredComment', 'after', $trigger_obj);
1257
-		if(!$trigger_output->toBool())
1257
+		if (!$trigger_output->toBool())
1258 1258
 		{
1259 1259
 			$oDB->rollback();
1260 1260
 			return $trigger_output;
@@ -1279,7 +1279,7 @@  discard block
 block discarded – undo
1279 1279
 	function addCommentPopupMenu($url, $str, $icon = '', $target = 'self')
1280 1280
 	{
1281 1281
 		$comment_popup_menu_list = Context::get('comment_popup_menu_list');
1282
-		if(!is_array($comment_popup_menu_list))
1282
+		if (!is_array($comment_popup_menu_list))
1283 1283
 		{
1284 1284
 			$comment_popup_menu_list = array();
1285 1285
 		}
@@ -1301,7 +1301,7 @@  discard block
 block discarded – undo
1301 1301
 	function procCommentInsertModuleConfig()
1302 1302
 	{
1303 1303
 		$module_srl = Context::get('target_module_srl');
1304
-		if(preg_match('/^([0-9,]+)$/', $module_srl))
1304
+		if (preg_match('/^([0-9,]+)$/', $module_srl))
1305 1305
 		{
1306 1306
 			$module_srl = explode(',', $module_srl);
1307 1307
 		}
@@ -1312,33 +1312,33 @@  discard block
 block discarded – undo
1312 1312
 
1313 1313
 		$comment_config = new stdClass();
1314 1314
 		$comment_config->comment_count = (int) Context::get('comment_count');
1315
-		if(!$comment_config->comment_count)
1315
+		if (!$comment_config->comment_count)
1316 1316
 		{
1317 1317
 			$comment_config->comment_count = 50;
1318 1318
 		}
1319 1319
 
1320 1320
 		$comment_config->use_vote_up = Context::get('use_vote_up');
1321
-		if(!$comment_config->use_vote_up)
1321
+		if (!$comment_config->use_vote_up)
1322 1322
 		{
1323 1323
 			$comment_config->use_vote_up = 'Y';
1324 1324
 		}
1325 1325
 
1326 1326
 		$comment_config->use_vote_down = Context::get('use_vote_down');
1327
-		if(!$comment_config->use_vote_down)
1327
+		if (!$comment_config->use_vote_down)
1328 1328
 		{
1329 1329
 			$comment_config->use_vote_down = 'Y';
1330 1330
 		}
1331 1331
 
1332 1332
 		$comment_config->use_comment_validation = Context::get('use_comment_validation');
1333
-		if(!$comment_config->use_comment_validation)
1333
+		if (!$comment_config->use_comment_validation)
1334 1334
 		{
1335 1335
 			$comment_config->use_comment_validation = 'N';
1336 1336
 		}
1337 1337
 
1338
-		for($i = 0; $i < count($module_srl); $i++)
1338
+		for ($i = 0; $i < count($module_srl); $i++)
1339 1339
 		{
1340 1340
 			$srl = trim($module_srl[$i]);
1341
-			if(!$srl)
1341
+			if (!$srl)
1342 1342
 			{
1343 1343
 				continue;
1344 1344
 			}
@@ -1372,25 +1372,25 @@  discard block
 block discarded – undo
1372 1372
 	 */
1373 1373
 	function procCommentGetList()
1374 1374
 	{
1375
-		if(!Context::get('is_logged'))
1375
+		if (!Context::get('is_logged'))
1376 1376
 		{
1377 1377
 			return new Object(-1, 'msg_not_permitted');
1378 1378
 		}
1379 1379
 
1380 1380
 		$commentSrls = Context::get('comment_srls');
1381
-		if($commentSrls)
1381
+		if ($commentSrls)
1382 1382
 		{
1383 1383
 			$commentSrlList = explode(',', $commentSrls);
1384 1384
 		}
1385 1385
 
1386
-		if(count($commentSrlList) > 0)
1386
+		if (count($commentSrlList) > 0)
1387 1387
 		{
1388 1388
 			$oCommentModel = getModel('comment');
1389 1389
 			$commentList = $oCommentModel->getComments($commentSrlList);
1390 1390
 
1391
-			if(is_array($commentList))
1391
+			if (is_array($commentList))
1392 1392
 			{
1393
-				foreach($commentList as $value)
1393
+				foreach ($commentList as $value)
1394 1394
 				{
1395 1395
 					$value->content = strip_tags($value->content);
1396 1396
 				}
@@ -1415,9 +1415,9 @@  discard block
 block discarded – undo
1415 1415
 		$commentConfig = $oModuleModel->getModulePartConfig('comment', $obj->originModuleSrl);
1416 1416
 
1417 1417
 		$oModuleController = getController('module');
1418
-		if(is_array($obj->moduleSrlList))
1418
+		if (is_array($obj->moduleSrlList))
1419 1419
 		{
1420
-			foreach($obj->moduleSrlList as $moduleSrl)
1420
+			foreach ($obj->moduleSrlList as $moduleSrl)
1421 1421
 			{
1422 1422
 				$oModuleController->insertModulePartConfig('comment', $moduleSrl, $commentConfig);
1423 1423
 			}
Please login to merge, or discard this patch.
classes/security/phphtmlparser/src/htmlparser.inc 2 patches
Indentation   +299 added lines, -299 removed lines patch added patch discarded remove patch
@@ -30,336 +30,336 @@
 block discarded – undo
30 30
  */
31 31
 class HtmlParser {
32 32
 
33
-    /**
34
-     * Field iNodeType.
35
-     * May be one of the NODE_TYPE_* constants above.
36
-     */
37
-    var $iNodeType;
33
+	/**
34
+	 * Field iNodeType.
35
+	 * May be one of the NODE_TYPE_* constants above.
36
+	 */
37
+	var $iNodeType;
38 38
 
39
-    /**
40
-     * Field iNodeName.
41
-     * For elements, it's the name of the element.
42
-     */
43
-    var $iNodeName = "";
39
+	/**
40
+	 * Field iNodeName.
41
+	 * For elements, it's the name of the element.
42
+	 */
43
+	var $iNodeName = "";
44 44
 
45
-    /**
46
-     * Field iNodeValue.
47
-     * For text nodes, it's the text.
48
-     */
49
-    var $iNodeValue = "";
45
+	/**
46
+	 * Field iNodeValue.
47
+	 * For text nodes, it's the text.
48
+	 */
49
+	var $iNodeValue = "";
50 50
 
51
-    /**
52
-     * Field iNodeAttributes.
53
-     * A string-indexed array containing attribute values
54
-     * of the current node. Indexes are always lowercase.
55
-     */
56
-    var $iNodeAttributes;
51
+	/**
52
+	 * Field iNodeAttributes.
53
+	 * A string-indexed array containing attribute values
54
+	 * of the current node. Indexes are always lowercase.
55
+	 */
56
+	var $iNodeAttributes;
57 57
 
58
-    // The following fields should be 
59
-    // considered private:
58
+	// The following fields should be 
59
+	// considered private:
60 60
 
61
-    var $iHtmlText;
62
-    var $iHtmlTextLength;
63
-    var $iHtmlTextIndex = 0;
64
-    var $iHtmlCurrentChar;
65
-    var $BOE_ARRAY;
66
-    var $B_ARRAY;
67
-    var $BOS_ARRAY;
61
+	var $iHtmlText;
62
+	var $iHtmlTextLength;
63
+	var $iHtmlTextIndex = 0;
64
+	var $iHtmlCurrentChar;
65
+	var $BOE_ARRAY;
66
+	var $B_ARRAY;
67
+	var $BOS_ARRAY;
68 68
     
69
-    /**
70
-     * Constructor.
71
-     * Constructs an HtmlParser instance with
72
-     * the HTML text given.
73
-     */
74
-    function HtmlParser ($aHtmlText) {
75
-        $this->iHtmlText = $aHtmlText;
76
-        $this->iHtmlTextLength = strlen($aHtmlText);
77
-        $this->iNodeAttributes = array();
78
-        $this->setTextIndex (0);
69
+	/**
70
+	 * Constructor.
71
+	 * Constructs an HtmlParser instance with
72
+	 * the HTML text given.
73
+	 */
74
+	function HtmlParser ($aHtmlText) {
75
+		$this->iHtmlText = $aHtmlText;
76
+		$this->iHtmlTextLength = strlen($aHtmlText);
77
+		$this->iNodeAttributes = array();
78
+		$this->setTextIndex (0);
79 79
 
80
-        $this->BOE_ARRAY = array (" ", "\t", "\r", "\n", "=" );
81
-        $this->B_ARRAY = array (" ", "\t", "\r", "\n" );
82
-        $this->BOS_ARRAY = array (" ", "\t", "\r", "\n", "/" );
83
-    }
80
+		$this->BOE_ARRAY = array (" ", "\t", "\r", "\n", "=" );
81
+		$this->B_ARRAY = array (" ", "\t", "\r", "\n" );
82
+		$this->BOS_ARRAY = array (" ", "\t", "\r", "\n", "/" );
83
+	}
84 84
 
85
-    /**
86
-     * Method parse.
87
-     * Parses the next node. Returns false only if
88
-     * the end of the HTML text has been reached.
89
-     * Updates values of iNode* fields.
90
-     */
91
-    function parse() {
92
-        $text = $this->skipToElement();
93
-        if ($text != "") {
94
-            $this->iNodeType = NODE_TYPE_TEXT;
95
-            $this->iNodeName = "Text";
96
-            $this->iNodeValue = $text;
97
-            return true;
98
-        }
99
-        return $this->readTag();
100
-    }
85
+	/**
86
+	 * Method parse.
87
+	 * Parses the next node. Returns false only if
88
+	 * the end of the HTML text has been reached.
89
+	 * Updates values of iNode* fields.
90
+	 */
91
+	function parse() {
92
+		$text = $this->skipToElement();
93
+		if ($text != "") {
94
+			$this->iNodeType = NODE_TYPE_TEXT;
95
+			$this->iNodeName = "Text";
96
+			$this->iNodeValue = $text;
97
+			return true;
98
+		}
99
+		return $this->readTag();
100
+	}
101 101
 
102
-    function clearAttributes() {
103
-        $this->iNodeAttributes = array();
104
-    }
102
+	function clearAttributes() {
103
+		$this->iNodeAttributes = array();
104
+	}
105 105
 
106
-    function readTag() {
107
-        if ($this->iCurrentChar != "<") {
108
-            $this->iNodeType = NODE_TYPE_DONE;
109
-            return false;
110
-        }
111
-        $this->clearAttributes();
112
-        $this->skipMaxInTag ("<", 1);
113
-        if ($this->iCurrentChar == '/') {
114
-            $this->moveNext();
115
-            $name = $this->skipToBlanksInTag();
116
-            $this->iNodeType = NODE_TYPE_ENDELEMENT;
117
-            $this->iNodeName = $name;
118
-            $this->iNodeValue = "";            
119
-            $this->skipEndOfTag();
120
-            return true;
121
-        }
122
-        $name = $this->skipToBlanksOrSlashInTag();
123
-        if (!$this->isValidTagIdentifier ($name)) {
124
-                $comment = false;
125
-                if (strpos($name, "!--") === 0) {
126
-                    $ppos = strpos($name, "--", 3);
127
-                    if (strpos($name, "--", 3) === (strlen($name) - 2)) {
128
-                        $this->iNodeType = NODE_TYPE_COMMENT;
129
-                        $this->iNodeName = "Comment";
130
-                        $this->iNodeValue = "<" . $name . ">";
131
-                        $comment = true;                        
132
-                    }
133
-                    else {
134
-                        $rest = $this->skipToStringInTag ("-->");    
135
-                        if ($rest != "") {
136
-                            $this->iNodeType = NODE_TYPE_COMMENT;
137
-                            $this->iNodeName = "Comment";
138
-                            $this->iNodeValue = "<" . $name . $rest;
139
-                            $comment = true;
140
-                            // Already skipped end of tag
141
-                            return true;
142
-                        }
143
-                    }
144
-                }
145
-                if (!$comment) {
146
-                    $this->iNodeType = NODE_TYPE_TEXT;
147
-                    $this->iNodeName = "Text";
148
-                    $this->iNodeValue = "<" . $name;
149
-                    return true;
150
-                }
151
-        }
152
-        else {
153
-                $this->iNodeType = NODE_TYPE_ELEMENT;
154
-                $this->iNodeValue = "";
155
-                $this->iNodeName = $name;
156
-                while ($this->skipBlanksInTag()) {
157
-                    $attrName = $this->skipToBlanksOrEqualsInTag();
158
-                    if ($attrName != "" && $attrName != "/") {
159
-                        $this->skipBlanksInTag();
160
-                        if ($this->iCurrentChar == "=") {
161
-                            $this->skipEqualsInTag();
162
-                            $this->skipBlanksInTag();
163
-                            $value = $this->readValueInTag();
164
-                            $this->iNodeAttributes[strtolower($attrName)] = $value;
165
-                        }
166
-                        else {
167
-                            $this->iNodeAttributes[strtolower($attrName)] = "";
168
-                        }
169
-                    }
170
-                }
171
-        }
172
-        $this->skipEndOfTag();
173
-        return true;            
174
-    }
106
+	function readTag() {
107
+		if ($this->iCurrentChar != "<") {
108
+			$this->iNodeType = NODE_TYPE_DONE;
109
+			return false;
110
+		}
111
+		$this->clearAttributes();
112
+		$this->skipMaxInTag ("<", 1);
113
+		if ($this->iCurrentChar == '/') {
114
+			$this->moveNext();
115
+			$name = $this->skipToBlanksInTag();
116
+			$this->iNodeType = NODE_TYPE_ENDELEMENT;
117
+			$this->iNodeName = $name;
118
+			$this->iNodeValue = "";            
119
+			$this->skipEndOfTag();
120
+			return true;
121
+		}
122
+		$name = $this->skipToBlanksOrSlashInTag();
123
+		if (!$this->isValidTagIdentifier ($name)) {
124
+				$comment = false;
125
+				if (strpos($name, "!--") === 0) {
126
+					$ppos = strpos($name, "--", 3);
127
+					if (strpos($name, "--", 3) === (strlen($name) - 2)) {
128
+						$this->iNodeType = NODE_TYPE_COMMENT;
129
+						$this->iNodeName = "Comment";
130
+						$this->iNodeValue = "<" . $name . ">";
131
+						$comment = true;                        
132
+					}
133
+					else {
134
+						$rest = $this->skipToStringInTag ("-->");    
135
+						if ($rest != "") {
136
+							$this->iNodeType = NODE_TYPE_COMMENT;
137
+							$this->iNodeName = "Comment";
138
+							$this->iNodeValue = "<" . $name . $rest;
139
+							$comment = true;
140
+							// Already skipped end of tag
141
+							return true;
142
+						}
143
+					}
144
+				}
145
+				if (!$comment) {
146
+					$this->iNodeType = NODE_TYPE_TEXT;
147
+					$this->iNodeName = "Text";
148
+					$this->iNodeValue = "<" . $name;
149
+					return true;
150
+				}
151
+		}
152
+		else {
153
+				$this->iNodeType = NODE_TYPE_ELEMENT;
154
+				$this->iNodeValue = "";
155
+				$this->iNodeName = $name;
156
+				while ($this->skipBlanksInTag()) {
157
+					$attrName = $this->skipToBlanksOrEqualsInTag();
158
+					if ($attrName != "" && $attrName != "/") {
159
+						$this->skipBlanksInTag();
160
+						if ($this->iCurrentChar == "=") {
161
+							$this->skipEqualsInTag();
162
+							$this->skipBlanksInTag();
163
+							$value = $this->readValueInTag();
164
+							$this->iNodeAttributes[strtolower($attrName)] = $value;
165
+						}
166
+						else {
167
+							$this->iNodeAttributes[strtolower($attrName)] = "";
168
+						}
169
+					}
170
+				}
171
+		}
172
+		$this->skipEndOfTag();
173
+		return true;            
174
+	}
175 175
 
176
-    function isValidTagIdentifier ($name) {
177
-        return preg_match ("/^[A-Za-z0-9_\\-]+$/", $name);
178
-    }
176
+	function isValidTagIdentifier ($name) {
177
+		return preg_match ("/^[A-Za-z0-9_\\-]+$/", $name);
178
+	}
179 179
     
180
-    function skipBlanksInTag() {
181
-        return "" != ($this->skipInTag ($this->B_ARRAY));
182
-    }
180
+	function skipBlanksInTag() {
181
+		return "" != ($this->skipInTag ($this->B_ARRAY));
182
+	}
183 183
 
184
-    function skipToBlanksOrEqualsInTag() {
185
-        return $this->skipToInTag ($this->BOE_ARRAY);
186
-    }
184
+	function skipToBlanksOrEqualsInTag() {
185
+		return $this->skipToInTag ($this->BOE_ARRAY);
186
+	}
187 187
 
188
-    function skipToBlanksInTag() {
189
-        return $this->skipToInTag ($this->B_ARRAY);
190
-    }
188
+	function skipToBlanksInTag() {
189
+		return $this->skipToInTag ($this->B_ARRAY);
190
+	}
191 191
 
192
-    function skipToBlanksOrSlashInTag() {
193
-        return $this->skipToInTag ($this->BOS_ARRAY);
194
-    }
192
+	function skipToBlanksOrSlashInTag() {
193
+		return $this->skipToInTag ($this->BOS_ARRAY);
194
+	}
195 195
 
196
-    function skipEqualsInTag() {
197
-        return $this->skipMaxInTag ("=", 1);
198
-    }
196
+	function skipEqualsInTag() {
197
+		return $this->skipMaxInTag ("=", 1);
198
+	}
199 199
 
200
-    function readValueInTag() {
201
-        $ch = $this->iCurrentChar;
202
-        $value = "";
203
-        if ($ch == "\"") {
204
-            $this->skipMaxInTag ("\"", 1);
205
-            $value = $this->skipToInTag ("\"");
206
-            $this->skipMaxInTag ("\"", 1);
207
-        }
208
-        else if ($ch == "'") {
209
-            $this->skipMaxInTag ("'", 1);
210
-            $value = $this->skipToInTag ("'");
211
-            $this->skipMaxInTag ("'", 1);
212
-        }                
213
-        else {
214
-            $value = $this->skipToBlanksInTag();
215
-        }
216
-        return $value;
217
-    }
200
+	function readValueInTag() {
201
+		$ch = $this->iCurrentChar;
202
+		$value = "";
203
+		if ($ch == "\"") {
204
+			$this->skipMaxInTag ("\"", 1);
205
+			$value = $this->skipToInTag ("\"");
206
+			$this->skipMaxInTag ("\"", 1);
207
+		}
208
+		else if ($ch == "'") {
209
+			$this->skipMaxInTag ("'", 1);
210
+			$value = $this->skipToInTag ("'");
211
+			$this->skipMaxInTag ("'", 1);
212
+		}                
213
+		else {
214
+			$value = $this->skipToBlanksInTag();
215
+		}
216
+		return $value;
217
+	}
218 218
 
219
-    function setTextIndex ($index) {
220
-        $this->iHtmlTextIndex = $index;
221
-        if ($index >= $this->iHtmlTextLength) {
222
-            $this->iCurrentChar = -1;
223
-        }
224
-        else {
225
-            $this->iCurrentChar = $this->iHtmlText{$index};
226
-        }
227
-    }
219
+	function setTextIndex ($index) {
220
+		$this->iHtmlTextIndex = $index;
221
+		if ($index >= $this->iHtmlTextLength) {
222
+			$this->iCurrentChar = -1;
223
+		}
224
+		else {
225
+			$this->iCurrentChar = $this->iHtmlText{$index};
226
+		}
227
+	}
228 228
 
229
-    function moveNext() {
230
-        if ($this->iHtmlTextIndex < $this->iHtmlTextLength) {
231
-            $this->setTextIndex ($this->iHtmlTextIndex + 1);
232
-            return true;
233
-        }
234
-        else {
235
-            return false;
236
-        }
237
-    }
229
+	function moveNext() {
230
+		if ($this->iHtmlTextIndex < $this->iHtmlTextLength) {
231
+			$this->setTextIndex ($this->iHtmlTextIndex + 1);
232
+			return true;
233
+		}
234
+		else {
235
+			return false;
236
+		}
237
+	}
238 238
 
239
-    function skipEndOfTag() {
240
-        while (($ch = $this->iCurrentChar) !== -1) {
241
-            if ($ch == ">") {
242
-                $this->moveNext();
243
-                return;
244
-            }
245
-            $this->moveNext();
246
-        }
247
-    }
239
+	function skipEndOfTag() {
240
+		while (($ch = $this->iCurrentChar) !== -1) {
241
+			if ($ch == ">") {
242
+				$this->moveNext();
243
+				return;
244
+			}
245
+			$this->moveNext();
246
+		}
247
+	}
248 248
 
249
-    function skipInTag ($chars) {
250
-        $sb = "";
251
-        while (($ch = $this->iCurrentChar) !== -1) {
252
-            if ($ch == ">") {
253
-                return $sb;
254
-            } else {
255
-                $match = false;
256
-                for ($idx = 0; $idx < count($chars); $idx++) {
257
-                    if ($ch == $chars[$idx]) {
258
-                        $match = true;
259
-                        break;
260
-                    }
261
-                }
262
-                if (!$match) {
263
-                    return $sb;
264
-                }
265
-                $sb .= $ch;
266
-                $this->moveNext();
267
-            }
268
-        }
269
-        return $sb;
270
-    }
249
+	function skipInTag ($chars) {
250
+		$sb = "";
251
+		while (($ch = $this->iCurrentChar) !== -1) {
252
+			if ($ch == ">") {
253
+				return $sb;
254
+			} else {
255
+				$match = false;
256
+				for ($idx = 0; $idx < count($chars); $idx++) {
257
+					if ($ch == $chars[$idx]) {
258
+						$match = true;
259
+						break;
260
+					}
261
+				}
262
+				if (!$match) {
263
+					return $sb;
264
+				}
265
+				$sb .= $ch;
266
+				$this->moveNext();
267
+			}
268
+		}
269
+		return $sb;
270
+	}
271 271
 
272
-    function skipMaxInTag ($chars, $maxChars) {
273
-        $sb = "";
274
-        $count = 0;
275
-        while (($ch = $this->iCurrentChar) !== -1 && $count++ < $maxChars) {
276
-            if ($ch == ">") {
277
-                return $sb;
278
-            } else {
279
-                $match = false;
280
-                for ($idx = 0; $idx < count($chars); $idx++) {
281
-                    if ($ch == $chars[$idx]) {
282
-                        $match = true;
283
-                        break;
284
-                    }
285
-                }
286
-                if (!$match) {
287
-                    return $sb;
288
-                }
289
-                $sb .= $ch;
290
-                $this->moveNext();
291
-            }
292
-        }
293
-        return $sb;
294
-    }
272
+	function skipMaxInTag ($chars, $maxChars) {
273
+		$sb = "";
274
+		$count = 0;
275
+		while (($ch = $this->iCurrentChar) !== -1 && $count++ < $maxChars) {
276
+			if ($ch == ">") {
277
+				return $sb;
278
+			} else {
279
+				$match = false;
280
+				for ($idx = 0; $idx < count($chars); $idx++) {
281
+					if ($ch == $chars[$idx]) {
282
+						$match = true;
283
+						break;
284
+					}
285
+				}
286
+				if (!$match) {
287
+					return $sb;
288
+				}
289
+				$sb .= $ch;
290
+				$this->moveNext();
291
+			}
292
+		}
293
+		return $sb;
294
+	}
295 295
 
296
-    function skipToInTag ($chars) {
297
-        $sb = "";
298
-        while (($ch = $this->iCurrentChar) !== -1) {
299
-            $match = $ch == ">";
300
-            if (!$match) {
301
-                for ($idx = 0; $idx < count($chars); $idx++) {
302
-                    if ($ch == $chars[$idx]) {
303
-                        $match = true;
304
-                        break;
305
-                    }
306
-                }
307
-            }
308
-            if ($match) {
309
-                return $sb;
310
-            }
311
-            $sb .= $ch;
312
-            $this->moveNext();
313
-        }
314
-        return $sb;
315
-    }
296
+	function skipToInTag ($chars) {
297
+		$sb = "";
298
+		while (($ch = $this->iCurrentChar) !== -1) {
299
+			$match = $ch == ">";
300
+			if (!$match) {
301
+				for ($idx = 0; $idx < count($chars); $idx++) {
302
+					if ($ch == $chars[$idx]) {
303
+						$match = true;
304
+						break;
305
+					}
306
+				}
307
+			}
308
+			if ($match) {
309
+				return $sb;
310
+			}
311
+			$sb .= $ch;
312
+			$this->moveNext();
313
+		}
314
+		return $sb;
315
+	}
316 316
 
317
-    function skipToElement() {
318
-        $sb = "";
319
-        while (($ch = $this->iCurrentChar) !== -1) {
320
-            if ($ch == "<") {
321
-                return $sb;
322
-            }
323
-            $sb .= $ch;
324
-            $this->moveNext();
325
-        }
326
-        return $sb;             
327
-    }
317
+	function skipToElement() {
318
+		$sb = "";
319
+		while (($ch = $this->iCurrentChar) !== -1) {
320
+			if ($ch == "<") {
321
+				return $sb;
322
+			}
323
+			$sb .= $ch;
324
+			$this->moveNext();
325
+		}
326
+		return $sb;             
327
+	}
328 328
 
329
-    /**
330
-     * Returns text between current position and $needle,
331
-     * inclusive, or "" if not found. The current index is moved to a point
332
-     * after the location of $needle, or not moved at all
333
-     * if nothing is found.
334
-     */
335
-    function skipToStringInTag ($needle) {
336
-        $pos = strpos ($this->iHtmlText, $needle, $this->iHtmlTextIndex);
337
-        if ($pos === false) {
338
-            return "";
339
-        }
340
-        $top = $pos + strlen($needle);
341
-        $retvalue = substr ($this->iHtmlText, $this->iHtmlTextIndex, $top - $this->iHtmlTextIndex);
342
-        $this->setTextIndex ($top);
343
-        return $retvalue;
344
-    }
329
+	/**
330
+	 * Returns text between current position and $needle,
331
+	 * inclusive, or "" if not found. The current index is moved to a point
332
+	 * after the location of $needle, or not moved at all
333
+	 * if nothing is found.
334
+	 */
335
+	function skipToStringInTag ($needle) {
336
+		$pos = strpos ($this->iHtmlText, $needle, $this->iHtmlTextIndex);
337
+		if ($pos === false) {
338
+			return "";
339
+		}
340
+		$top = $pos + strlen($needle);
341
+		$retvalue = substr ($this->iHtmlText, $this->iHtmlTextIndex, $top - $this->iHtmlTextIndex);
342
+		$this->setTextIndex ($top);
343
+		return $retvalue;
344
+	}
345 345
 }
346 346
 
347 347
 function HtmlParser_ForFile ($fileName) { 
348
-    return HtmlParser_ForURL($fileName);
348
+	return HtmlParser_ForURL($fileName);
349 349
 }
350 350
 
351 351
 function HtmlParser_ForURL ($url) {
352
-    $fp = fopen ($url, "r");
353
-    $content = "";
354
-    while (true) {
355
-        $data = fread ($fp, 8192);
356
-        if (strlen($data) == 0) {
357
-            break;
358
-        }
359
-        $content .= $data;
360
-    }
361
-    fclose ($fp);
362
-    return new HtmlParser ($content);
352
+	$fp = fopen ($url, "r");
353
+	$content = "";
354
+	while (true) {
355
+		$data = fread ($fp, 8192);
356
+		if (strlen($data) == 0) {
357
+			break;
358
+		}
359
+		$content .= $data;
360
+	}
361
+	fclose ($fp);
362
+	return new HtmlParser ($content);
363 363
 }
364 364
 
365 365
 php?>
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -10,12 +10,12 @@  discard block
 block discarded – undo
10 10
  * - Leo West (performance improvements)
11 11
  */
12 12
 
13
-define ("NODE_TYPE_START",0);
14
-define ("NODE_TYPE_ELEMENT",1);
15
-define ("NODE_TYPE_ENDELEMENT",2);
16
-define ("NODE_TYPE_TEXT",3);
17
-define ("NODE_TYPE_COMMENT",4);
18
-define ("NODE_TYPE_DONE",5);
13
+define("NODE_TYPE_START", 0);
14
+define("NODE_TYPE_ELEMENT", 1);
15
+define("NODE_TYPE_ENDELEMENT", 2);
16
+define("NODE_TYPE_TEXT", 3);
17
+define("NODE_TYPE_COMMENT", 4);
18
+define("NODE_TYPE_DONE", 5);
19 19
 
20 20
 /**
21 21
  * Class HtmlParser.
@@ -71,15 +71,15 @@  discard block
 block discarded – undo
71 71
      * Constructs an HtmlParser instance with
72 72
      * the HTML text given.
73 73
      */
74
-    function HtmlParser ($aHtmlText) {
74
+    function HtmlParser($aHtmlText) {
75 75
         $this->iHtmlText = $aHtmlText;
76 76
         $this->iHtmlTextLength = strlen($aHtmlText);
77 77
         $this->iNodeAttributes = array();
78
-        $this->setTextIndex (0);
78
+        $this->setTextIndex(0);
79 79
 
80
-        $this->BOE_ARRAY = array (" ", "\t", "\r", "\n", "=" );
81
-        $this->B_ARRAY = array (" ", "\t", "\r", "\n" );
82
-        $this->BOS_ARRAY = array (" ", "\t", "\r", "\n", "/" );
80
+        $this->BOE_ARRAY = array(" ", "\t", "\r", "\n", "=");
81
+        $this->B_ARRAY = array(" ", "\t", "\r", "\n");
82
+        $this->BOS_ARRAY = array(" ", "\t", "\r", "\n", "/");
83 83
     }
84 84
 
85 85
     /**
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
             return false;
110 110
         }
111 111
         $this->clearAttributes();
112
-        $this->skipMaxInTag ("<", 1);
112
+        $this->skipMaxInTag("<", 1);
113 113
         if ($this->iCurrentChar == '/') {
114 114
             $this->moveNext();
115 115
             $name = $this->skipToBlanksInTag();
@@ -120,22 +120,22 @@  discard block
 block discarded – undo
120 120
             return true;
121 121
         }
122 122
         $name = $this->skipToBlanksOrSlashInTag();
123
-        if (!$this->isValidTagIdentifier ($name)) {
123
+        if (!$this->isValidTagIdentifier($name)) {
124 124
                 $comment = false;
125 125
                 if (strpos($name, "!--") === 0) {
126 126
                     $ppos = strpos($name, "--", 3);
127 127
                     if (strpos($name, "--", 3) === (strlen($name) - 2)) {
128 128
                         $this->iNodeType = NODE_TYPE_COMMENT;
129 129
                         $this->iNodeName = "Comment";
130
-                        $this->iNodeValue = "<" . $name . ">";
130
+                        $this->iNodeValue = "<".$name.">";
131 131
                         $comment = true;                        
132 132
                     }
133 133
                     else {
134
-                        $rest = $this->skipToStringInTag ("-->");    
134
+                        $rest = $this->skipToStringInTag("-->");    
135 135
                         if ($rest != "") {
136 136
                             $this->iNodeType = NODE_TYPE_COMMENT;
137 137
                             $this->iNodeName = "Comment";
138
-                            $this->iNodeValue = "<" . $name . $rest;
138
+                            $this->iNodeValue = "<".$name.$rest;
139 139
                             $comment = true;
140 140
                             // Already skipped end of tag
141 141
                             return true;
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
                 if (!$comment) {
146 146
                     $this->iNodeType = NODE_TYPE_TEXT;
147 147
                     $this->iNodeName = "Text";
148
-                    $this->iNodeValue = "<" . $name;
148
+                    $this->iNodeValue = "<".$name;
149 149
                     return true;
150 150
                 }
151 151
         }
@@ -173,42 +173,42 @@  discard block
 block discarded – undo
173 173
         return true;            
174 174
     }
175 175
 
176
-    function isValidTagIdentifier ($name) {
177
-        return preg_match ("/^[A-Za-z0-9_\\-]+$/", $name);
176
+    function isValidTagIdentifier($name) {
177
+        return preg_match("/^[A-Za-z0-9_\\-]+$/", $name);
178 178
     }
179 179
     
180 180
     function skipBlanksInTag() {
181
-        return "" != ($this->skipInTag ($this->B_ARRAY));
181
+        return "" != ($this->skipInTag($this->B_ARRAY));
182 182
     }
183 183
 
184 184
     function skipToBlanksOrEqualsInTag() {
185
-        return $this->skipToInTag ($this->BOE_ARRAY);
185
+        return $this->skipToInTag($this->BOE_ARRAY);
186 186
     }
187 187
 
188 188
     function skipToBlanksInTag() {
189
-        return $this->skipToInTag ($this->B_ARRAY);
189
+        return $this->skipToInTag($this->B_ARRAY);
190 190
     }
191 191
 
192 192
     function skipToBlanksOrSlashInTag() {
193
-        return $this->skipToInTag ($this->BOS_ARRAY);
193
+        return $this->skipToInTag($this->BOS_ARRAY);
194 194
     }
195 195
 
196 196
     function skipEqualsInTag() {
197
-        return $this->skipMaxInTag ("=", 1);
197
+        return $this->skipMaxInTag("=", 1);
198 198
     }
199 199
 
200 200
     function readValueInTag() {
201 201
         $ch = $this->iCurrentChar;
202 202
         $value = "";
203 203
         if ($ch == "\"") {
204
-            $this->skipMaxInTag ("\"", 1);
205
-            $value = $this->skipToInTag ("\"");
206
-            $this->skipMaxInTag ("\"", 1);
204
+            $this->skipMaxInTag("\"", 1);
205
+            $value = $this->skipToInTag("\"");
206
+            $this->skipMaxInTag("\"", 1);
207 207
         }
208 208
         else if ($ch == "'") {
209
-            $this->skipMaxInTag ("'", 1);
210
-            $value = $this->skipToInTag ("'");
211
-            $this->skipMaxInTag ("'", 1);
209
+            $this->skipMaxInTag("'", 1);
210
+            $value = $this->skipToInTag("'");
211
+            $this->skipMaxInTag("'", 1);
212 212
         }                
213 213
         else {
214 214
             $value = $this->skipToBlanksInTag();
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
         return $value;
217 217
     }
218 218
 
219
-    function setTextIndex ($index) {
219
+    function setTextIndex($index) {
220 220
         $this->iHtmlTextIndex = $index;
221 221
         if ($index >= $this->iHtmlTextLength) {
222 222
             $this->iCurrentChar = -1;
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 
229 229
     function moveNext() {
230 230
         if ($this->iHtmlTextIndex < $this->iHtmlTextLength) {
231
-            $this->setTextIndex ($this->iHtmlTextIndex + 1);
231
+            $this->setTextIndex($this->iHtmlTextIndex + 1);
232 232
             return true;
233 233
         }
234 234
         else {
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
         }
247 247
     }
248 248
 
249
-    function skipInTag ($chars) {
249
+    function skipInTag($chars) {
250 250
         $sb = "";
251 251
         while (($ch = $this->iCurrentChar) !== -1) {
252 252
             if ($ch == ">") {
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
         return $sb;
270 270
     }
271 271
 
272
-    function skipMaxInTag ($chars, $maxChars) {
272
+    function skipMaxInTag($chars, $maxChars) {
273 273
         $sb = "";
274 274
         $count = 0;
275 275
         while (($ch = $this->iCurrentChar) !== -1 && $count++ < $maxChars) {
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
         return $sb;
294 294
     }
295 295
 
296
-    function skipToInTag ($chars) {
296
+    function skipToInTag($chars) {
297 297
         $sb = "";
298 298
         while (($ch = $this->iCurrentChar) !== -1) {
299 299
             $match = $ch == ">";
@@ -332,34 +332,34 @@  discard block
 block discarded – undo
332 332
      * after the location of $needle, or not moved at all
333 333
      * if nothing is found.
334 334
      */
335
-    function skipToStringInTag ($needle) {
336
-        $pos = strpos ($this->iHtmlText, $needle, $this->iHtmlTextIndex);
335
+    function skipToStringInTag($needle) {
336
+        $pos = strpos($this->iHtmlText, $needle, $this->iHtmlTextIndex);
337 337
         if ($pos === false) {
338 338
             return "";
339 339
         }
340 340
         $top = $pos + strlen($needle);
341
-        $retvalue = substr ($this->iHtmlText, $this->iHtmlTextIndex, $top - $this->iHtmlTextIndex);
342
-        $this->setTextIndex ($top);
341
+        $retvalue = substr($this->iHtmlText, $this->iHtmlTextIndex, $top - $this->iHtmlTextIndex);
342
+        $this->setTextIndex($top);
343 343
         return $retvalue;
344 344
     }
345 345
 }
346 346
 
347
-function HtmlParser_ForFile ($fileName) { 
347
+function HtmlParser_ForFile($fileName) { 
348 348
     return HtmlParser_ForURL($fileName);
349 349
 }
350 350
 
351
-function HtmlParser_ForURL ($url) {
352
-    $fp = fopen ($url, "r");
351
+function HtmlParser_ForURL($url) {
352
+    $fp = fopen($url, "r");
353 353
     $content = "";
354 354
     while (true) {
355
-        $data = fread ($fp, 8192);
355
+        $data = fread($fp, 8192);
356 356
         if (strlen($data) == 0) {
357 357
             break;
358 358
         }
359 359
         $content .= $data;
360 360
     }
361
-    fclose ($fp);
362
-    return new HtmlParser ($content);
361
+    fclose($fp);
362
+    return new HtmlParser($content);
363 363
 }
364 364
 
365 365
 php?>
Please login to merge, or discard this patch.