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
Pull Request — develop (#2172)
by
unknown
25:47 queued 17:56
created
modules/document/document.item.php 3 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1106,8 +1106,7 @@
 block discarded – undo
1106 1106
 
1107 1107
 	/**
1108 1108
 	 * Check accessible by document status
1109
-	 * @param array $matches
1110
-	 * @return mixed
1109
+	 * @return boolean
1111 1110
 	 */
1112 1111
 	function _checkAccessibleFromStatus()
1113 1112
 	{
Please login to merge, or discard this patch.
Spacing   +182 added lines, -182 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	 */
80 80
 	function _loadFromDB($load_extra_vars = true)
81 81
 	{
82
-		if(!$this->document_srl) return;
82
+		if (!$this->document_srl) return;
83 83
 
84 84
 		$document_item = false;
85 85
 		$cache_put = false;
@@ -88,11 +88,11 @@  discard block
 block discarded – undo
88 88
 
89 89
 		// cache controll
90 90
 		$oCacheHandler = CacheHandler::getInstance('object');
91
-		if($oCacheHandler->isSupport())
91
+		if ($oCacheHandler->isSupport())
92 92
 		{
93
-			$cache_key = 'document_item:' . getNumberingPath($this->document_srl) . $this->document_srl;
93
+			$cache_key = 'document_item:'.getNumberingPath($this->document_srl).$this->document_srl;
94 94
 			$document_item = $oCacheHandler->get($cache_key);
95
-			if($document_item !== false)
95
+			if ($document_item !== false)
96 96
 			{
97 97
 				$columnList = array('readed_count', 'voted_count', 'blamed_count', 'comment_count', 'trackback_count');
98 98
 			}
@@ -102,12 +102,12 @@  discard block
 block discarded – undo
102 102
 		$args->document_srl = $this->document_srl;
103 103
 		$output = executeQuery('document.getDocument', $args, $columnList);
104 104
 
105
-		if($document_item === false)
105
+		if ($document_item === false)
106 106
 		{
107 107
 			$document_item = $output->data;
108 108
 
109 109
 				//insert in cache
110
-			if($document_item && $oCacheHandler->isSupport())
110
+			if ($document_item && $oCacheHandler->isSupport())
111 111
 			{
112 112
 				$oCacheHandler->put($cache_key, $document_item);
113 113
 			}
@@ -124,9 +124,9 @@  discard block
 block discarded – undo
124 124
 		$this->setAttribute($document_item, $load_extra_vars);
125 125
 	}
126 126
 
127
-	function setAttribute($attribute, $load_extra_vars=true)
127
+	function setAttribute($attribute, $load_extra_vars = true)
128 128
 	{
129
-		if(!$attribute->document_srl)
129
+		if (!$attribute->document_srl)
130 130
 		{
131 131
 			$this->document_srl = null;
132 132
 			return;
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 		$this->adds($attribute);
137 137
 
138 138
 		// Tags
139
-		if($this->get('tags'))
139
+		if ($this->get('tags'))
140 140
 		{
141 141
 			$tag_list = explode(',', $this->get('tags'));
142 142
 			$tag_list = array_map('trim', $tag_list);
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 		}
145 145
 
146 146
 		$oDocumentModel = getModel('document');
147
-		if($load_extra_vars)
147
+		if ($load_extra_vars)
148 148
 		{
149 149
 			$GLOBALS['XE_DOCUMENT_LIST'][$attribute->document_srl] = $this;
150 150
 			$oDocumentModel->setToAllDocumentExtraVars();
@@ -159,23 +159,23 @@  discard block
 block discarded – undo
159 159
 
160 160
 	function isGranted()
161 161
 	{
162
-		if($_SESSION['own_document'][$this->document_srl]) return $this->grant_cache = true;
162
+		if ($_SESSION['own_document'][$this->document_srl]) return $this->grant_cache = true;
163 163
 
164
-		if($this->grant_cache !== null)
164
+		if ($this->grant_cache !== null)
165 165
 		{
166 166
 			return $this->grant_cache;
167 167
 		}
168 168
 
169
-		if(!Context::get('is_logged')) return $this->grant_cache = false;
169
+		if (!Context::get('is_logged')) return $this->grant_cache = false;
170 170
 
171 171
 		$logged_info = Context::get('logged_info');
172
-		if($logged_info->is_admin == 'Y') return $this->grant_cache = true;
172
+		if ($logged_info->is_admin == 'Y') return $this->grant_cache = true;
173 173
 
174 174
 		$oModuleModel = getModel('module');
175 175
 		$grant = $oModuleModel->getGrant($oModuleModel->getModuleInfoByModuleSrl($this->get('module_srl')), $logged_info);
176
-		if($grant->manager) return $this->grant_cache = true;
176
+		if ($grant->manager) return $this->grant_cache = true;
177 177
 
178
-		if($this->get('member_srl') && ($this->get('member_srl') == $logged_info->member_srl || $this->get('member_srl')*-1 == $logged_info->member_srl)) return $this->grant_cache = true;
178
+		if ($this->get('member_srl') && ($this->get('member_srl') == $logged_info->member_srl || $this->get('member_srl') * -1 == $logged_info->member_srl)) return $this->grant_cache = true;
179 179
 
180 180
 		return $this->grant_cache = false;
181 181
 	}
@@ -188,13 +188,13 @@  discard block
 block discarded – undo
188 188
 
189 189
 	function isAccessible()
190 190
 	{
191
-		return $_SESSION['accessible'][$this->document_srl]==true?true:false;
191
+		return $_SESSION['accessible'][$this->document_srl] == true ?true:false;
192 192
 	}
193 193
 
194 194
 	function allowComment()
195 195
 	{
196 196
 		// init write, document is not exists. so allow comment status is true
197
-		if(!$this->isExists()) return true;
197
+		if (!$this->isExists()) return true;
198 198
 
199 199
 		return $this->get('comment_status') == 'ALLOW' ? true : false;
200 200
 	}
@@ -202,11 +202,11 @@  discard block
 block discarded – undo
202 202
 	function allowTrackback()
203 203
 	{
204 204
 		static $allow_trackback_status = null;
205
-		if(is_null($allow_trackback_status))
205
+		if (is_null($allow_trackback_status))
206 206
 		{
207 207
 			
208 208
 			// Check the tarckback module exist
209
-			if(!getClass('trackback'))
209
+			if (!getClass('trackback'))
210 210
 			{
211 211
 				$allow_trackback_status = false;
212 212
 			}
@@ -216,20 +216,20 @@  discard block
 block discarded – undo
216 216
 				$oModuleModel = getModel('module');
217 217
 				$trackback_config = $oModuleModel->getModuleConfig('trackback');
218 218
 				
219
-				if(!$trackback_config)
219
+				if (!$trackback_config)
220 220
 				{
221 221
 					$trackback_config = new stdClass();
222 222
 				}
223 223
 				
224
-				if(!isset($trackback_config->enable_trackback)) $trackback_config->enable_trackback = 'Y';
225
-				if($trackback_config->enable_trackback != 'Y') $allow_trackback_status = false;
224
+				if (!isset($trackback_config->enable_trackback)) $trackback_config->enable_trackback = 'Y';
225
+				if ($trackback_config->enable_trackback != 'Y') $allow_trackback_status = false;
226 226
 				else
227 227
 				{
228 228
 					$module_srl = $this->get('module_srl');
229 229
 					// Check settings of each module
230 230
 					$module_config = $oModuleModel->getModulePartConfig('trackback', $module_srl);
231
-					if($module_config->enable_trackback == 'N') $allow_trackback_status = false;
232
-					else if($this->get('allow_trackback')=='Y' || !$this->isExists()) $allow_trackback_status = true;
231
+					if ($module_config->enable_trackback == 'N') $allow_trackback_status = false;
232
+					else if ($this->get('allow_trackback') == 'Y' || !$this->isExists()) $allow_trackback_status = true;
233 233
 				}
234 234
 			}
235 235
 		}
@@ -238,14 +238,14 @@  discard block
 block discarded – undo
238 238
 
239 239
 	function isLocked()
240 240
 	{
241
-		if(!$this->isExists()) return false;
241
+		if (!$this->isExists()) return false;
242 242
 
243 243
 		return $this->get('comment_status') == 'ALLOW' ? false : true;
244 244
 	}
245 245
 
246 246
 	function isEditable()
247 247
 	{
248
-		if($this->isGranted() || !$this->get('member_srl')) return true;
248
+		if ($this->isGranted() || !$this->get('member_srl')) return true;
249 249
 		return false;
250 250
 	}
251 251
 
@@ -262,13 +262,13 @@  discard block
 block discarded – undo
262 262
 
263 263
 	function useNotify()
264 264
 	{
265
-		return $this->get('notify_message')=='Y' ? true : false;
265
+		return $this->get('notify_message') == 'Y' ? true : false;
266 266
 	}
267 267
 
268 268
 	function doCart()
269 269
 	{
270
-		if(!$this->document_srl) return false;
271
-		if($this->isCarted()) $this->removeCart();
270
+		if (!$this->document_srl) return false;
271
+		if ($this->isCarted()) $this->removeCart();
272 272
 		else $this->addCart();
273 273
 	}
274 274
 
@@ -295,18 +295,18 @@  discard block
 block discarded – undo
295 295
 	 */
296 296
 	function notify($type, $content)
297 297
 	{
298
-		if(!$this->document_srl) return;
298
+		if (!$this->document_srl) return;
299 299
 		// return if it is not useNotify
300
-		if(!$this->useNotify()) return;
300
+		if (!$this->useNotify()) return;
301 301
 		// Pass if an author is not a logged-in user
302
-		if(!$this->get('member_srl')) return;
302
+		if (!$this->get('member_srl')) return;
303 303
 		// Return if the currently logged-in user is an author
304 304
 		$logged_info = Context::get('logged_info');
305
-		if($logged_info->member_srl == $this->get('member_srl')) return;
305
+		if ($logged_info->member_srl == $this->get('member_srl')) return;
306 306
 		// List variables
307
-		if($type) $title = "[".$type."] ";
307
+		if ($type) $title = "[".$type."] ";
308 308
 		$title .= cut_str(strip_tags($content), 10, '...');
309
-		$content = sprintf('%s<br /><br />from : <a href="%s" target="_blank">%s</a>',$content, getFullUrl('','document_srl',$this->document_srl), getFullUrl('','document_srl',$this->document_srl));
309
+		$content = sprintf('%s<br /><br />from : <a href="%s" target="_blank">%s</a>', $content, getFullUrl('', 'document_srl', $this->document_srl), getFullUrl('', 'document_srl', $this->document_srl));
310 310
 		$receiver_srl = $this->get('member_srl');
311 311
 		$sender_member_srl = $logged_info->member_srl;
312 312
 		// Send a message
@@ -321,26 +321,26 @@  discard block
 block discarded – undo
321 321
 
322 322
 	function getIpAddress()
323 323
 	{
324
-		if($this->isGranted())
324
+		if ($this->isGranted())
325 325
 		{
326 326
 			return $this->get('ipaddress');
327 327
 		}
328 328
 
329
-		return '*' . strstr($this->get('ipaddress'), '.');
329
+		return '*'.strstr($this->get('ipaddress'), '.');
330 330
 	}
331 331
 
332 332
 	function isExistsHomepage()
333 333
 	{
334
-		if(trim($this->get('homepage'))) return true;
334
+		if (trim($this->get('homepage'))) return true;
335 335
 		return false;
336 336
 	}
337 337
 
338 338
 	function getHomepageUrl()
339 339
 	{
340 340
 		$url = trim($this->get('homepage'));
341
-		if(!$url) return;
341
+		if (!$url) return;
342 342
 
343
-		if(strncasecmp('http://', $url, 7) !== 0 && strncasecmp('https://', $url, 8) !== 0)  $url = 'http://' . $url;
343
+		if (strncasecmp('http://', $url, 7) !== 0 && strncasecmp('https://', $url, 8) !== 0)  $url = 'http://'.$url;
344 344
 
345 345
 		return $url;
346 346
 	}
@@ -370,52 +370,52 @@  discard block
 block discarded – undo
370 370
 		return htmlspecialchars($this->get('last_updater'), ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
371 371
 	}
372 372
 
373
-	function getTitleText($cut_size = 0, $tail='...')
373
+	function getTitleText($cut_size = 0, $tail = '...')
374 374
 	{
375
-		if(!$this->document_srl) return;
375
+		if (!$this->document_srl) return;
376 376
 
377
-		if($cut_size) $title = cut_str($this->get('title'), $cut_size, $tail);
377
+		if ($cut_size) $title = cut_str($this->get('title'), $cut_size, $tail);
378 378
 		else $title = $this->get('title');
379 379
 
380 380
 		return $title;
381 381
 	}
382 382
 
383
-	function getTitle($cut_size = 0, $tail='...')
383
+	function getTitle($cut_size = 0, $tail = '...')
384 384
 	{
385
-		if(!$this->document_srl) return;
385
+		if (!$this->document_srl) return;
386 386
 
387 387
 		$title = $this->getTitleText($cut_size, $tail);
388 388
 
389 389
 		$attrs = array();
390 390
 		$this->add('title_color', trim($this->get('title_color')));
391
-		if($this->get('title_bold')=='Y') $attrs[] = "font-weight:bold;";
392
-		if($this->get('title_color') && $this->get('title_color') != 'N') $attrs[] = "color:#".$this->get('title_color');
391
+		if ($this->get('title_bold') == 'Y') $attrs[] = "font-weight:bold;";
392
+		if ($this->get('title_color') && $this->get('title_color') != 'N') $attrs[] = "color:#".$this->get('title_color');
393 393
 
394
-		if(count($attrs)) return sprintf("<span style=\"%s\">%s</span>", implode(';',$attrs), htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
394
+		if (count($attrs)) return sprintf("<span style=\"%s\">%s</span>", implode(';', $attrs), htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
395 395
 		else return htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
396 396
 	}
397 397
 
398 398
 	function getContentText($strlen = 0)
399 399
 	{
400
-		if(!$this->document_srl) return;
400
+		if (!$this->document_srl) return;
401 401
 
402
-		if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret');
402
+		if ($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret');
403 403
 
404 404
 		$result = $this->_checkAccessibleFromStatus();
405
-		if($result) $_SESSION['accessible'][$this->document_srl] = true;
405
+		if ($result) $_SESSION['accessible'][$this->document_srl] = true;
406 406
 
407 407
 		$content = $this->get('content');
408 408
 		$content = preg_replace_callback('/<(object|param|embed)[^>]*/is', array($this, '_checkAllowScriptAccess'), $content);
409 409
 		$content = preg_replace_callback('/<object[^>]*>/is', array($this, '_addAllowScriptAccess'), $content);
410 410
 
411
-		if($strlen) return cut_str(strip_tags($content),$strlen,'...');
411
+		if ($strlen) return cut_str(strip_tags($content), $strlen, '...');
412 412
 
413 413
 		return htmlspecialchars($content);
414 414
 	}
415 415
 
416 416
 	function _addAllowScriptAccess($m)
417 417
 	{
418
-		if($this->allowscriptaccessList[$this->allowscriptaccessKey] == 1)
418
+		if ($this->allowscriptaccessList[$this->allowscriptaccessKey] == 1)
419 419
 		{
420 420
 			$m[0] = $m[0].'<param name="allowscriptaccess" value="never"></param>';
421 421
 		}
@@ -425,26 +425,26 @@  discard block
 block discarded – undo
425 425
 
426 426
 	function _checkAllowScriptAccess($m)
427 427
 	{
428
-		if($m[1] == 'object')
428
+		if ($m[1] == 'object')
429 429
 		{
430 430
 			$this->allowscriptaccessList[] = 1;
431 431
 		}
432 432
 
433
-		if($m[1] == 'param')
433
+		if ($m[1] == 'param')
434 434
 		{
435
-			if(stripos($m[0], 'allowscriptaccess'))
435
+			if (stripos($m[0], 'allowscriptaccess'))
436 436
 			{
437 437
 				$m[0] = '<param name="allowscriptaccess" value="never"';
438
-				if(substr($m[0], -1) == '/')
438
+				if (substr($m[0], -1) == '/')
439 439
 				{
440 440
 					$m[0] .= '/';
441 441
 				}
442
-				$this->allowscriptaccessList[count($this->allowscriptaccessList)-1]--;
442
+				$this->allowscriptaccessList[count($this->allowscriptaccessList) - 1]--;
443 443
 			}
444 444
 		}
445
-		else if($m[1] == 'embed')
445
+		else if ($m[1] == 'embed')
446 446
 		{
447
-			if(stripos($m[0], 'allowscriptaccess'))
447
+			if (stripos($m[0], 'allowscriptaccess'))
448 448
 			{
449 449
 				$m[0] = preg_replace('/always|samedomain/i', 'never', $m[0]);
450 450
 			}
@@ -458,24 +458,24 @@  discard block
 block discarded – undo
458 458
 
459 459
 	function getContent($add_popup_menu = true, $add_content_info = true, $resource_realpath = false, $add_xe_content_class = true, $stripEmbedTagException = false)
460 460
 	{
461
-		if(!$this->document_srl) return;
461
+		if (!$this->document_srl) return;
462 462
 
463
-		if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret');
463
+		if ($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret');
464 464
 
465 465
 		$result = $this->_checkAccessibleFromStatus();
466
-		if($result) $_SESSION['accessible'][$this->document_srl] = true;
466
+		if ($result) $_SESSION['accessible'][$this->document_srl] = true;
467 467
 
468 468
 		$content = $this->get('content');
469
-		if(!$stripEmbedTagException) stripEmbedTagForAdmin($content, $this->get('member_srl'));
469
+		if (!$stripEmbedTagException) stripEmbedTagForAdmin($content, $this->get('member_srl'));
470 470
 
471 471
 		// Define a link if using a rewrite module
472 472
 		$oContext = &Context::getInstance();
473
-		if($oContext->allow_rewrite)
473
+		if ($oContext->allow_rewrite)
474 474
 		{
475
-			$content = preg_replace('/<a([ \t]+)href=("|\')\.\/\?/i',"<a href=\\2". Context::getRequestUri() ."?", $content);
475
+			$content = preg_replace('/<a([ \t]+)href=("|\')\.\/\?/i', "<a href=\\2".Context::getRequestUri()."?", $content);
476 476
 		}
477 477
 		// To display a pop-up menu
478
-		if($add_popup_menu)
478
+		if ($add_popup_menu)
479 479
 		{
480 480
 			$content = sprintf(
481 481
 				'%s<div class="document_popup_menu"><a href="#popup_menu_area" class="document_%d" onclick="return false">%s</a></div>',
@@ -484,10 +484,10 @@  discard block
 block discarded – undo
484 484
 			);
485 485
 		}
486 486
 		// If additional content information is set
487
-		if($add_content_info)
487
+		if ($add_content_info)
488 488
 		{
489 489
 			$memberSrl = $this->get('member_srl');
490
-			if($memberSrl < 0)
490
+			if ($memberSrl < 0)
491 491
 			{
492 492
 				$memberSrl = 0;
493 493
 			}
@@ -503,12 +503,12 @@  discard block
 block discarded – undo
503 503
 		}
504 504
 		else
505 505
 		{
506
-			if($add_xe_content_class) $content = sprintf('<div class="xe_content">%s</div>', $content);
506
+			if ($add_xe_content_class) $content = sprintf('<div class="xe_content">%s</div>', $content);
507 507
 		}
508 508
 		// Change the image path to a valid absolute path if resource_realpath is true
509
-		if($resource_realpath)
509
+		if ($resource_realpath)
510 510
 		{
511
-			$content = preg_replace_callback('/<img([^>]+)>/i',array($this,'replaceResourceRealPath'), $content);
511
+			$content = preg_replace_callback('/<img([^>]+)>/i', array($this, 'replaceResourceRealPath'), $content);
512 512
 		}
513 513
 
514 514
 		return $content;
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 		$content = trim(cut_str($content, $str_size, $tail));
558 558
 
559 559
 		// Replace back < , <, "
560
-		$content = str_replace(array('<', '>', '"'),array('&lt;', '&gt;', '&quot;'), $content);
560
+		$content = str_replace(array('<', '>', '"'), array('&lt;', '&gt;', '&quot;'), $content);
561 561
 
562 562
 		return $content;
563 563
 	}
@@ -570,13 +570,13 @@  discard block
 block discarded – undo
570 570
 	function getRegdateTime()
571 571
 	{
572 572
 		$regdate = $this->get('regdate');
573
-		$year = substr($regdate,0,4);
574
-		$month = substr($regdate,4,2);
575
-		$day = substr($regdate,6,2);
576
-		$hour = substr($regdate,8,2);
577
-		$min = substr($regdate,10,2);
578
-		$sec = substr($regdate,12,2);
579
-		return mktime($hour,$min,$sec,$month,$day,$year);
573
+		$year = substr($regdate, 0, 4);
574
+		$month = substr($regdate, 4, 2);
575
+		$day = substr($regdate, 6, 2);
576
+		$hour = substr($regdate, 8, 2);
577
+		$min = substr($regdate, 10, 2);
578
+		$sec = substr($regdate, 12, 2);
579
+		return mktime($hour, $min, $sec, $month, $day, $year);
580 580
 	}
581 581
 
582 582
 	function getRegdateGM()
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
 
587 587
 	function getRegdateDT()
588 588
 	{
589
-		return $this->getRegdate('Y-m-d').'T'.$this->getRegdate('H:i:s').substr($GLOBALS['_time_zone'],0,3).':'.substr($GLOBALS['_time_zone'],3,2);
589
+		return $this->getRegdate('Y-m-d').'T'.$this->getRegdate('H:i:s').substr($GLOBALS['_time_zone'], 0, 3).':'.substr($GLOBALS['_time_zone'], 3, 2);
590 590
 	}
591 591
 
592 592
 	function getUpdate($format = 'Y.m.d H:i:s')
@@ -596,13 +596,13 @@  discard block
 block discarded – undo
596 596
 
597 597
 	function getUpdateTime()
598 598
 	{
599
-		$year = substr($this->get('last_update'),0,4);
600
-		$month = substr($this->get('last_update'),4,2);
601
-		$day = substr($this->get('last_update'),6,2);
602
-		$hour = substr($this->get('last_update'),8,2);
603
-		$min = substr($this->get('last_update'),10,2);
604
-		$sec = substr($this->get('last_update'),12,2);
605
-		return mktime($hour,$min,$sec,$month,$day,$year);
599
+		$year = substr($this->get('last_update'), 0, 4);
600
+		$month = substr($this->get('last_update'), 4, 2);
601
+		$day = substr($this->get('last_update'), 6, 2);
602
+		$hour = substr($this->get('last_update'), 8, 2);
603
+		$min = substr($this->get('last_update'), 10, 2);
604
+		$sec = substr($this->get('last_update'), 12, 2);
605
+		return mktime($hour, $min, $sec, $month, $day, $year);
606 606
 	}
607 607
 
608 608
 	function getUpdateGM()
@@ -612,21 +612,21 @@  discard block
 block discarded – undo
612 612
 
613 613
 	function getUpdateDT()
614 614
 	{
615
-		return $this->getUpdate('Y-m-d').'T'.$this->getUpdate('H:i:s').substr($GLOBALS['_time_zone'],0,3).':'.substr($GLOBALS['_time_zone'],3,2);
615
+		return $this->getUpdate('Y-m-d').'T'.$this->getUpdate('H:i:s').substr($GLOBALS['_time_zone'], 0, 3).':'.substr($GLOBALS['_time_zone'], 3, 2);
616 616
 	}
617 617
 
618 618
 	function getPermanentUrl()
619 619
 	{
620
-		return getFullUrl('','mid', $this->getDocumentMid('document_srl'), 'document_srl', $this->get('document_srl'));
620
+		return getFullUrl('', 'mid', $this->getDocumentMid('document_srl'), 'document_srl', $this->get('document_srl'));
621 621
 	}
622 622
 
623 623
 	function getTrackbackUrl()
624 624
 	{
625
-		if(!$this->document_srl) return;
625
+		if (!$this->document_srl) return;
626 626
 
627 627
 		// Generate a key to prevent spams
628 628
 		$oTrackbackModel = getModel('trackback');
629
-		if($oTrackbackModel) return $oTrackbackModel->getTrackbackUrl($this->document_srl, $this->getDocumentMid());
629
+		if ($oTrackbackModel) return $oTrackbackModel->getTrackbackUrl($this->document_srl, $this->getDocumentMid());
630 630
 	}
631 631
 
632 632
 	/**
@@ -636,24 +636,24 @@  discard block
 block discarded – undo
636 636
 	function updateReadedCount()
637 637
 	{
638 638
 		$oDocumentController = getController('document');
639
-		if($oDocumentController->updateReadedCount($this))
639
+		if ($oDocumentController->updateReadedCount($this))
640 640
 		{
641 641
 			$readed_count = $this->get('readed_count');
642
-			$this->add('readed_count', $readed_count+1);
642
+			$this->add('readed_count', $readed_count + 1);
643 643
 		}
644 644
 	}
645 645
 
646 646
 	function isExtraVarsExists()
647 647
 	{
648
-		if(!$this->get('module_srl')) return false;
648
+		if (!$this->get('module_srl')) return false;
649 649
 		$oDocumentModel = getModel('document');
650 650
 		$extra_keys = $oDocumentModel->getExtraKeys($this->get('module_srl'));
651
-		return count($extra_keys)?true:false;
651
+		return count($extra_keys) ?true:false;
652 652
 	}
653 653
 
654 654
 	function getExtraVars()
655 655
 	{
656
-		if(!$this->get('module_srl') || !$this->document_srl) return null;
656
+		if (!$this->get('module_srl') || !$this->document_srl) return null;
657 657
 
658 658
 		$oDocumentModel = getModel('document');
659 659
 		return $oDocumentModel->getExtraVars($this->get('module_srl'), $this->document_srl);
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
 	function getExtraValue($idx)
663 663
 	{
664 664
 		$extra_vars = $this->getExtraVars();
665
-		if(is_array($extra_vars) && array_key_exists($idx,$extra_vars))
665
+		if (is_array($extra_vars) && array_key_exists($idx, $extra_vars))
666 666
 		{
667 667
 			return $extra_vars[$idx]->getValue();
668 668
 		}
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
 	function getExtraValueHTML($idx)
676 676
 	{
677 677
 		$extra_vars = $this->getExtraVars();
678
-		if(is_array($extra_vars) && array_key_exists($idx,$extra_vars))
678
+		if (is_array($extra_vars) && array_key_exists($idx, $extra_vars))
679 679
 		{
680 680
 			return $extra_vars[$idx]->getValueHTML();
681 681
 		}
@@ -689,16 +689,16 @@  discard block
 block discarded – undo
689 689
 	{
690 690
 		$extra_vars = $this->getExtraVars();
691 691
 
692
-		if($extra_vars)
692
+		if ($extra_vars)
693 693
 		{
694 694
 			// Handle extra variable(eid)
695
-			foreach($extra_vars as $idx => $key)
695
+			foreach ($extra_vars as $idx => $key)
696 696
 			{
697 697
 				$extra_eid[$key->eid] = $key;
698 698
 			}
699 699
 		}
700 700
 		
701
-		if(is_array($extra_eid) && array_key_exists($eid,$extra_eid))
701
+		if (is_array($extra_eid) && array_key_exists($eid, $extra_eid))
702 702
 		{
703 703
 			return $extra_eid[$eid]->getValue();
704 704
 		}
@@ -712,12 +712,12 @@  discard block
 block discarded – undo
712 712
 	{
713 713
 		$extra_vars = $this->getExtraVars();
714 714
 		// Handle extra variable(eid)
715
-		foreach($extra_vars as $idx => $key)
715
+		foreach ($extra_vars as $idx => $key)
716 716
 		{
717 717
 			$extra_eid[$key->eid] = $key;
718 718
 		}
719 719
 		
720
-		if(is_array($extra_eid) && array_key_exists($eid,$extra_eid))
720
+		if (is_array($extra_eid) && array_key_exists($eid, $extra_eid))
721 721
 		{
722 722
 			return $extra_eid[$eid]->getValueHTML();
723 723
 		}
@@ -741,13 +741,13 @@  discard block
 block discarded – undo
741 741
 
742 742
 	function getComments()
743 743
 	{
744
-		if(!$this->getCommentCount()) return;
745
-		if(!$this->isGranted() && $this->isSecret()) return;
744
+		if (!$this->getCommentCount()) return;
745
+		if (!$this->isGranted() && $this->isSecret()) return;
746 746
 		// cpage is a number of comment pages
747 747
 		$cpageStr = sprintf('%d_cpage', $this->document_srl);
748 748
 		$cpage = Context::get($cpageStr);
749 749
 
750
-		if(!$cpage)
750
+		if (!$cpage)
751 751
 		{
752 752
 			$cpage = Context::get('cpage');
753 753
 		}
@@ -755,19 +755,19 @@  discard block
 block discarded – undo
755 755
 		// Get a list of comments
756 756
 		$oCommentModel = getModel('comment');
757 757
 		$output = $oCommentModel->getCommentList($this->document_srl, $cpage, $is_admin);
758
-		if(!$output->toBool() || !count($output->data)) return;
758
+		if (!$output->toBool() || !count($output->data)) return;
759 759
 		// Create commentItem object from a comment list
760 760
 		// If admin priviledge is granted on parent posts, you can read its child posts.
761 761
 		$accessible = array();
762 762
 		$comment_list = array();
763
-		foreach($output->data as $key => $val)
763
+		foreach ($output->data as $key => $val)
764 764
 		{
765 765
 			$oCommentItem = new commentItem();
766 766
 			$oCommentItem->setAttribute($val);
767 767
 			// If permission is granted to the post, you can access it temporarily
768
-			if($oCommentItem->isGranted()) $accessible[$val->comment_srl] = true;
768
+			if ($oCommentItem->isGranted()) $accessible[$val->comment_srl] = true;
769 769
 			// If the comment is set to private and it belongs child post, it is allowable to read the comment for who has a admin privilege on its parent post
770
-			if($val->parent_srl>0 && $val->is_secret == 'Y' && !$oCommentItem->isAccessible() && $accessible[$val->parent_srl]===true)
770
+			if ($val->parent_srl > 0 && $val->is_secret == 'Y' && !$oCommentItem->isAccessible() && $accessible[$val->parent_srl] === true)
771 771
 			{
772 772
 				$oCommentItem->setAccessible();
773 773
 			}
@@ -776,7 +776,7 @@  discard block
 block discarded – undo
776 776
 		// Variable setting to be displayed on the skin
777 777
 		Context::set($cpageStr, $output->page_navigation->cur_page);
778 778
 		Context::set('cpage', $output->page_navigation->cur_page);
779
-		if($output->total_page>1) $this->comment_page_navigation = $output->page_navigation;
779
+		if ($output->total_page > 1) $this->comment_page_navigation = $output->page_navigation;
780 780
 
781 781
 		return $comment_list;
782 782
 	}
@@ -788,9 +788,9 @@  discard block
 block discarded – undo
788 788
 
789 789
 	function getTrackbacks()
790 790
 	{
791
-		if(!$this->document_srl) return;
791
+		if (!$this->document_srl) return;
792 792
 
793
-		if(!$this->allowTrackback() || !$this->get('trackback_count')) return;
793
+		if (!$this->allowTrackback() || !$this->get('trackback_count')) return;
794 794
 
795 795
 		$oTrackbackModel = getModel('trackback');
796 796
 		return $oTrackbackModel->getTrackbackList($this->document_srl, $is_admin);
@@ -798,47 +798,47 @@  discard block
 block discarded – undo
798 798
 
799 799
 	function thumbnailExists($width = 80, $height = 0, $type = '')
800 800
 	{
801
-		if(!$this->document_srl) return false;
802
-		if(!$this->getThumbnail($width, $height, $type)) return false;
801
+		if (!$this->document_srl) return false;
802
+		if (!$this->getThumbnail($width, $height, $type)) return false;
803 803
 		return true;
804 804
 	}
805 805
 
806 806
 	function getThumbnail($width = 80, $height = 0, $thumbnail_type = '')
807 807
 	{
808 808
 		// Return false if the document doesn't exist
809
-		if(!$this->document_srl) return;
809
+		if (!$this->document_srl) return;
810 810
 
811
-		if($this->isSecret() && !$this->isGranted())
811
+		if ($this->isSecret() && !$this->isGranted())
812 812
 		{
813 813
 			return;
814 814
 		}
815 815
 
816 816
 		// If not specify its height, create a square
817
-		if(!$height) $height = $width;
817
+		if (!$height) $height = $width;
818 818
 
819 819
 		// Return false if neither attachement nor image files in the document
820 820
 		$content = $this->get('content');
821
-		if(!$this->get('uploaded_count'))
821
+		if (!$this->get('uploaded_count'))
822 822
 		{
823
-			if(!$content)
823
+			if (!$content)
824 824
 			{
825 825
 				$args = new stdClass();
826 826
 				$args->document_srl = $this->document_srl;
827 827
 				$output = executeQuery('document.getDocument', $args, array('content'));
828
-				if($output->toBool() && $output->data)
828
+				if ($output->toBool() && $output->data)
829 829
 				{
830 830
 					$content = $output->data->content;
831 831
 					$this->add('content', $content);
832 832
 				}
833 833
 			}
834 834
 
835
-			if(!preg_match("!<img!is", $content)) return;
835
+			if (!preg_match("!<img!is", $content)) return;
836 836
 		}
837 837
 		// Get thumbnai_type information from document module's configuration
838
-		if(!in_array($thumbnail_type, array('crop','ratio')))
838
+		if (!in_array($thumbnail_type, array('crop', 'ratio')))
839 839
 		{
840 840
 			$config = $GLOBALS['__document_config__'];
841
-			if(!$config)
841
+			if (!$config)
842 842
 			{
843 843
 				$oDocumentModel = getModel('document');
844 844
 				$config = $oDocumentModel->getDocumentConfig();
@@ -848,15 +848,15 @@  discard block
 block discarded – undo
848 848
 		}
849 849
 
850 850
 		// Define thumbnail information
851
-		$thumbnail_path = sprintf('files/thumbnails/%s',getNumberingPath($this->document_srl, 3));
851
+		$thumbnail_path = sprintf('files/thumbnails/%s', getNumberingPath($this->document_srl, 3));
852 852
 		$thumbnail_file = sprintf('%s%dx%d.%s.jpg', $thumbnail_path, $width, $height, $thumbnail_type);
853 853
 		$thumbnail_lockfile = sprintf('%s%dx%d.%s.lock', $thumbnail_path, $width, $height, $thumbnail_type);
854 854
 		$thumbnail_url  = Context::getRequestUri().$thumbnail_file;
855 855
 
856 856
 		// Return false if thumbnail file exists and its size is 0. Otherwise, return its path
857
-		if(file_exists($thumbnail_file) || file_exists($thumbnail_lockfile))
857
+		if (file_exists($thumbnail_file) || file_exists($thumbnail_lockfile))
858 858
 		{
859
-			if(filesize($thumbnail_file) < 1)
859
+			if (filesize($thumbnail_file) < 1)
860 860
 			{
861 861
 				return FALSE;
862 862
 			}
@@ -874,64 +874,64 @@  discard block
 block discarded – undo
874 874
 		$is_tmp_file = false;
875 875
 
876 876
 		// Find an iamge file among attached files if exists
877
-		if($this->hasUploadedFiles())
877
+		if ($this->hasUploadedFiles())
878 878
 		{
879 879
 			$file_list = $this->getUploadedFiles();
880 880
 
881 881
 			$first_image = null;
882
-			foreach($file_list as $file)
882
+			foreach ($file_list as $file)
883 883
 			{
884
-				if($file->direct_download !== 'Y') continue;
884
+				if ($file->direct_download !== 'Y') continue;
885 885
 
886
-				if($file->cover_image === 'Y' && file_exists($file->uploaded_filename))
886
+				if ($file->cover_image === 'Y' && file_exists($file->uploaded_filename))
887 887
 				{
888 888
 					$source_file = $file->uploaded_filename;
889 889
 					break;
890 890
 				}
891 891
 
892
-				if($first_image) continue;
892
+				if ($first_image) continue;
893 893
 
894
-				if(preg_match("/\.(jpe?g|png|gif|bmp)$/i", $file->source_filename))
894
+				if (preg_match("/\.(jpe?g|png|gif|bmp)$/i", $file->source_filename))
895 895
 				{
896
-					if(file_exists($file->uploaded_filename))
896
+					if (file_exists($file->uploaded_filename))
897 897
 					{
898 898
 						$first_image = $file->uploaded_filename;
899 899
 					}
900 900
 				}
901 901
 			}
902 902
 
903
-			if(!$source_file && $first_image)
903
+			if (!$source_file && $first_image)
904 904
 			{
905 905
 				$source_file = $first_image;
906 906
 			}
907 907
 		}
908 908
 		// If not exists, file an image file from the content
909 909
 		$is_tmp_file = false;
910
-		if(!$source_file)
910
+		if (!$source_file)
911 911
 		{
912 912
 			$random = new Password();
913 913
 
914 914
 			preg_match_all("!<img[^>]*src=(?:\"|\')([^\"\']*?)(?:\"|\')!is", $content, $matches, PREG_SET_ORDER);
915 915
 
916
-			foreach($matches as $target_image)
916
+			foreach ($matches as $target_image)
917 917
 			{
918 918
 				$target_src = trim($target_image[1]);
919
-				if(preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) continue;
919
+				if (preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) continue;
920 920
 
921
-				if(!preg_match('/^(http|https):\/\//i',$target_src))
921
+				if (!preg_match('/^(http|https):\/\//i', $target_src))
922 922
 				{
923 923
 					$target_src = Context::getRequestUri().$target_src;
924 924
 				}
925 925
 
926 926
 				$target_src = htmlspecialchars_decode($target_src);
927 927
 
928
-				$tmp_file = _XE_PATH_ . 'files/cache/tmp/' . $random->createSecureSalt(32, 'hex');
928
+				$tmp_file = _XE_PATH_.'files/cache/tmp/'.$random->createSecureSalt(32, 'hex');
929 929
 				FileHandler::getRemoteFile($target_src, $tmp_file);
930
-				if(!file_exists($tmp_file)) continue;
930
+				if (!file_exists($tmp_file)) continue;
931 931
 
932 932
 				$imageinfo = getimagesize($tmp_file);
933 933
 				list($_w, $_h) = $imageinfo;
934
-				if($imageinfo === false || ($_w < ($width * 0.3) && $_h < ($height * 0.3))) {
934
+				if ($imageinfo === false || ($_w < ($width * 0.3) && $_h < ($height * 0.3))) {
935 935
 					FileHandler::removeFile($tmp_file);
936 936
 					continue;
937 937
 				}
@@ -942,13 +942,13 @@  discard block
 block discarded – undo
942 942
 			}
943 943
 		}
944 944
 
945
-		if($source_file)
945
+		if ($source_file)
946 946
 		{
947 947
 			$output_file = FileHandler::createImageFile($source_file, $thumbnail_file, $width, $height, 'jpg', $thumbnail_type);
948 948
 		}
949 949
 
950 950
 		// Remove source file if it was temporary
951
-		if($is_tmp_file)
951
+		if ($is_tmp_file)
952 952
 		{
953 953
 			FileHandler::removeFile($source_file);
954 954
 		}
@@ -957,14 +957,14 @@  discard block
 block discarded – undo
957 957
 		FileHandler::removeFile($thumbnail_lockfile);
958 958
 
959 959
 		// Return the thumbnail path if it was successfully generated
960
-		if($output_file)
960
+		if ($output_file)
961 961
 		{
962 962
 			return $thumbnail_url;
963 963
 		}
964 964
 		// Create an empty file if thumbnail generation failed
965 965
 		else
966 966
 		{
967
-			FileHandler::writeFile($thumbnail_file, '','w');
967
+			FileHandler::writeFile($thumbnail_file, '', 'w');
968 968
 		}
969 969
 
970 970
 		return;
@@ -978,21 +978,21 @@  discard block
 block discarded – undo
978 978
 	 */
979 979
 	function getExtraImages($time_interval = 43200)
980 980
 	{
981
-		if(!$this->document_srl) return;
981
+		if (!$this->document_srl) return;
982 982
 		// variables for icon list
983 983
 		$buffs = array();
984 984
 
985 985
 		$check_files = false;
986 986
 
987 987
 		// Check if secret post is
988
-		if($this->isSecret()) $buffs[] = "secret";
988
+		if ($this->isSecret()) $buffs[] = "secret";
989 989
 
990 990
 		// Set the latest time
991
-		$time_check = date("YmdHis", $_SERVER['REQUEST_TIME']-$time_interval);
991
+		$time_check = date("YmdHis", $_SERVER['REQUEST_TIME'] - $time_interval);
992 992
 
993 993
 		// Check new post
994
-		if($this->get('regdate')>$time_check) $buffs[] = "new";
995
-		else if($this->get('last_update')>$time_check) $buffs[] = "update";
994
+		if ($this->get('regdate') > $time_check) $buffs[] = "new";
995
+		else if ($this->get('last_update') > $time_check) $buffs[] = "update";
996 996
 
997 997
 		/*
998 998
 		   $content = $this->get('content');
@@ -1015,14 +1015,14 @@  discard block
 block discarded – undo
1015 1015
 		 */
1016 1016
 
1017 1017
 		// Check the attachment
1018
-		if($this->hasUploadedFiles()) $buffs[] = "file";
1018
+		if ($this->hasUploadedFiles()) $buffs[] = "file";
1019 1019
 
1020 1020
 		return $buffs;
1021 1021
 	}
1022 1022
 
1023 1023
 	function getStatus()
1024 1024
 	{
1025
-		if(!$this->get('status')) return $this->getDefaultStatus();
1025
+		if (!$this->get('status')) return $this->getDefaultStatus();
1026 1026
 		return $this->get('status');
1027 1027
 	}
1028 1028
 
@@ -1033,11 +1033,11 @@  discard block
 block discarded – undo
1033 1033
 	 */
1034 1034
 	function printExtraImages($time_check = 43200)
1035 1035
 	{
1036
-		if(!$this->document_srl) return;
1036
+		if (!$this->document_srl) return;
1037 1037
 
1038 1038
 		$oDocumentModel = getModel('document');
1039 1039
 		$documentConfig = $oDocumentModel->getDocumentConfig();
1040
-		if(Mobile::isFromMobilePhone())
1040
+		if (Mobile::isFromMobilePhone())
1041 1041
 		{
1042 1042
 			$iconSkin = $documentConfig->micons;
1043 1043
 		}
@@ -1045,13 +1045,13 @@  discard block
 block discarded – undo
1045 1045
 		{
1046 1046
 			$iconSkin = $documentConfig->icons;
1047 1047
 		}
1048
-		$path = sprintf('%s%s',getUrl(), "modules/document/tpl/icons/$iconSkin/");
1048
+		$path = sprintf('%s%s', getUrl(), "modules/document/tpl/icons/$iconSkin/");
1049 1049
 
1050 1050
 		$buffs = $this->getExtraImages($time_check);
1051
-		if(!count($buffs)) return;
1051
+		if (!count($buffs)) return;
1052 1052
 
1053 1053
 		$buff = array();
1054
-		foreach($buffs as $key => $val)
1054
+		foreach ($buffs as $key => $val)
1055 1055
 		{
1056 1056
 			$buff[] = sprintf('<img src="%s%s.gif" alt="%s" title="%s" style="margin-right:2px;" />', $path, $val, $val, $val);
1057 1057
 		}
@@ -1060,20 +1060,20 @@  discard block
 block discarded – undo
1060 1060
 
1061 1061
 	function hasUploadedFiles()
1062 1062
 	{
1063
-		if(!$this->document_srl) return;
1063
+		if (!$this->document_srl) return;
1064 1064
 
1065
-		if($this->isSecret() && !$this->isGranted()) return false;
1066
-		return $this->get('uploaded_count')? true : false;
1065
+		if ($this->isSecret() && !$this->isGranted()) return false;
1066
+		return $this->get('uploaded_count') ? true : false;
1067 1067
 	}
1068 1068
 
1069 1069
 	function getUploadedFiles($sortIndex = 'file_srl')
1070 1070
 	{
1071
-		if(!$this->document_srl) return;
1071
+		if (!$this->document_srl) return;
1072 1072
 
1073
-		if($this->isSecret() && !$this->isGranted()) return;
1074
-		if(!$this->get('uploaded_count')) return;
1073
+		if ($this->isSecret() && !$this->isGranted()) return;
1074
+		if (!$this->get('uploaded_count')) return;
1075 1075
 
1076
-		if(!$this->uploadedFiles[$sortIndex])
1076
+		if (!$this->uploadedFiles[$sortIndex])
1077 1077
 		{
1078 1078
 			$oFileModel = getModel('file');
1079 1079
 			$this->uploadedFiles[$sortIndex] = $oFileModel->getFiles($this->document_srl, array(), $sortIndex, true);
@@ -1089,7 +1089,7 @@  discard block
 block discarded – undo
1089 1089
 	function getEditor()
1090 1090
 	{
1091 1091
 		$module_srl = $this->get('module_srl');
1092
-		if(!$module_srl) $module_srl = Context::get('module_srl');
1092
+		if (!$module_srl) $module_srl = Context::get('module_srl');
1093 1093
 
1094 1094
 		$oEditorModel = getModel('editor');
1095 1095
 		return $oEditorModel->getModuleEditor('document', $module_srl, $this->document_srl, 'document_srl', 'content');
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
 	{
1105 1105
 		// Return false if not authorized, if a secret document, if the document is set not to allow any comment
1106 1106
 		if (!$this->allowComment()) return false;
1107
-		if(!$this->isGranted() && $this->isSecret()) return false;
1107
+		if (!$this->isGranted() && $this->isSecret()) return false;
1108 1108
 
1109 1109
 		return true;
1110 1110
 	}
@@ -1115,7 +1115,7 @@  discard block
 block discarded – undo
1115 1115
 	 */
1116 1116
 	function getCommentEditor()
1117 1117
 	{
1118
-		if(!$this->isEnableComment()) return;
1118
+		if (!$this->isEnableComment()) return;
1119 1119
 
1120 1120
 		$oEditorModel = getModel('editor');
1121 1121
 		return $oEditorModel->getModuleEditor('comment', $this->get('module_srl'), $comment_srl, 'comment_srl', 'content');
@@ -1127,10 +1127,10 @@  discard block
 block discarded – undo
1127 1127
 	 */
1128 1128
 	function getProfileImage()
1129 1129
 	{
1130
-		if(!$this->isExists() || !$this->get('member_srl')) return;
1130
+		if (!$this->isExists() || !$this->get('member_srl')) return;
1131 1131
 		$oMemberModel = getModel('member');
1132 1132
 		$profile_info = $oMemberModel->getProfileImage($this->get('member_srl'));
1133
-		if(!$profile_info) return;
1133
+		if (!$profile_info) return;
1134 1134
 
1135 1135
 		return $profile_info->src;
1136 1136
 	}
@@ -1142,21 +1142,21 @@  discard block
 block discarded – undo
1142 1142
 	function getSignature()
1143 1143
 	{
1144 1144
 		// Pass if a document doesn't exist
1145
-		if(!$this->isExists() || !$this->get('member_srl')) return;
1145
+		if (!$this->isExists() || !$this->get('member_srl')) return;
1146 1146
 		// Get signature information
1147 1147
 		$oMemberModel = getModel('member');
1148 1148
 		$signature = $oMemberModel->getSignature($this->get('member_srl'));
1149 1149
 		// Check if a maximum height of signiture is set in the member module
1150
-		if(!isset($GLOBALS['__member_signature_max_height']))
1150
+		if (!isset($GLOBALS['__member_signature_max_height']))
1151 1151
 		{
1152 1152
 			$oModuleModel = getModel('module');
1153 1153
 			$member_config = $oModuleModel->getModuleConfig('member');
1154 1154
 			$GLOBALS['__member_signature_max_height'] = $member_config->signature_max_height;
1155 1155
 		}
1156
-		if($signature)
1156
+		if ($signature)
1157 1157
 		{
1158 1158
 			$max_signature_height = $GLOBALS['__member_signature_max_height'];
1159
-			if($max_signature_height) $signature = sprintf('<div style="max-height:%dpx;overflow:auto;overflow-x:hidden;height:expression(this.scrollHeight > %d ? \'%dpx\': \'auto\')">%s</div>', $max_signature_height, $max_signature_height, $max_signature_height, $signature);
1159
+			if ($max_signature_height) $signature = sprintf('<div style="max-height:%dpx;overflow:auto;overflow-x:hidden;height:expression(this.scrollHeight > %d ? \'%dpx\': \'auto\')">%s</div>', $max_signature_height, $max_signature_height, $max_signature_height, $signature);
1160 1160
 		}
1161 1161
 
1162 1162
 		return $signature;
@@ -1169,7 +1169,7 @@  discard block
 block discarded – undo
1169 1169
 	 */
1170 1170
 	function replaceResourceRealPath($matches)
1171 1171
 	{
1172
-		return preg_replace('/src=(["\']?)files/i','src=$1'.Context::getRequestUri().'files', $matches[0]);
1172
+		return preg_replace('/src=(["\']?)files/i', 'src=$1'.Context::getRequestUri().'files', $matches[0]);
1173 1173
 	}
1174 1174
 
1175 1175
 	/**
@@ -1180,19 +1180,19 @@  discard block
 block discarded – undo
1180 1180
 	function _checkAccessibleFromStatus()
1181 1181
 	{
1182 1182
 		$logged_info = Context::get('logged_info');
1183
-		if($logged_info->is_admin == 'Y') return true;
1183
+		if ($logged_info->is_admin == 'Y') return true;
1184 1184
 
1185 1185
 		$status = $this->get('status');
1186
-		if(empty($status)) return false;
1186
+		if (empty($status)) return false;
1187 1187
 
1188 1188
 		$oDocumentModel = getModel('document');
1189 1189
 		$configStatusList = $oDocumentModel->getStatusList();
1190 1190
 
1191
-		if($status == $configStatusList['public'] || $status == $configStatusList['publish'])
1191
+		if ($status == $configStatusList['public'] || $status == $configStatusList['publish'])
1192 1192
 			return true;
1193
-		else if($status == $configStatusList['private'] || $status == $configStatusList['secret'])
1193
+		else if ($status == $configStatusList['private'] || $status == $configStatusList['secret'])
1194 1194
 		{
1195
-			if($this->get('member_srl') == $logged_info->member_srl)
1195
+			if ($this->get('member_srl') == $logged_info->member_srl)
1196 1196
 				return true;
1197 1197
 		}
1198 1198
 		return false;
Please login to merge, or discard this patch.
Braces   +264 added lines, -112 removed lines patch added patch discarded remove patch
@@ -79,7 +79,9 @@  discard block
 block discarded – undo
79 79
 	 */
80 80
 	function _loadFromDB($load_extra_vars = true)
81 81
 	{
82
-		if(!$this->document_srl) return;
82
+		if(!$this->document_srl) {
83
+			return;
84
+		}
83 85
 
84 86
 		$document_item = false;
85 87
 		$cache_put = false;
@@ -111,8 +113,7 @@  discard block
 block discarded – undo
111 113
 			{
112 114
 				$oCacheHandler->put($cache_key, $document_item);
113 115
 			}
114
-		}
115
-		else
116
+		} else
116 117
 		{
117 118
 			$document_item->readed_count = $output->data->readed_count;
118 119
 			$document_item->voted_count = $output->data->voted_count;
@@ -159,23 +160,33 @@  discard block
 block discarded – undo
159 160
 
160 161
 	function isGranted()
161 162
 	{
162
-		if($_SESSION['own_document'][$this->document_srl]) return $this->grant_cache = true;
163
+		if($_SESSION['own_document'][$this->document_srl]) {
164
+			return $this->grant_cache = true;
165
+		}
163 166
 
164 167
 		if($this->grant_cache !== null)
165 168
 		{
166 169
 			return $this->grant_cache;
167 170
 		}
168 171
 
169
-		if(!Context::get('is_logged')) return $this->grant_cache = false;
172
+		if(!Context::get('is_logged')) {
173
+			return $this->grant_cache = false;
174
+		}
170 175
 
171 176
 		$logged_info = Context::get('logged_info');
172
-		if($logged_info->is_admin == 'Y') return $this->grant_cache = true;
177
+		if($logged_info->is_admin == 'Y') {
178
+			return $this->grant_cache = true;
179
+		}
173 180
 
174 181
 		$oModuleModel = getModel('module');
175 182
 		$grant = $oModuleModel->getGrant($oModuleModel->getModuleInfoByModuleSrl($this->get('module_srl')), $logged_info);
176
-		if($grant->manager) return $this->grant_cache = true;
183
+		if($grant->manager) {
184
+			return $this->grant_cache = true;
185
+		}
177 186
 
178
-		if($this->get('member_srl') && ($this->get('member_srl') == $logged_info->member_srl || $this->get('member_srl')*-1 == $logged_info->member_srl)) return $this->grant_cache = true;
187
+		if($this->get('member_srl') && ($this->get('member_srl') == $logged_info->member_srl || $this->get('member_srl')*-1 == $logged_info->member_srl)) {
188
+			return $this->grant_cache = true;
189
+		}
179 190
 
180 191
 		return $this->grant_cache = false;
181 192
 	}
@@ -194,7 +205,9 @@  discard block
 block discarded – undo
194 205
 	function allowComment()
195 206
 	{
196 207
 		// init write, document is not exists. so allow comment status is true
197
-		if(!$this->isExists()) return true;
208
+		if(!$this->isExists()) {
209
+			return true;
210
+		}
198 211
 
199 212
 		return $this->get('comment_status') == 'ALLOW' ? true : false;
200 213
 	}
@@ -209,8 +222,7 @@  discard block
 block discarded – undo
209 222
 			if(!getClass('trackback'))
210 223
 			{
211 224
 				$allow_trackback_status = false;
212
-			}
213
-			else
225
+			} else
214 226
 			{
215 227
 				// If the trackback module is configured to be disabled, do not allow. Otherwise, check the setting of each module.
216 228
 				$oModuleModel = getModel('module');
@@ -221,15 +233,21 @@  discard block
 block discarded – undo
221 233
 					$trackback_config = new stdClass();
222 234
 				}
223 235
 				
224
-				if(!isset($trackback_config->enable_trackback)) $trackback_config->enable_trackback = 'Y';
225
-				if($trackback_config->enable_trackback != 'Y') $allow_trackback_status = false;
226
-				else
236
+				if(!isset($trackback_config->enable_trackback)) {
237
+					$trackback_config->enable_trackback = 'Y';
238
+				}
239
+				if($trackback_config->enable_trackback != 'Y') {
240
+					$allow_trackback_status = false;
241
+				} else
227 242
 				{
228 243
 					$module_srl = $this->get('module_srl');
229 244
 					// Check settings of each module
230 245
 					$module_config = $oModuleModel->getModulePartConfig('trackback', $module_srl);
231
-					if($module_config->enable_trackback == 'N') $allow_trackback_status = false;
232
-					else if($this->get('allow_trackback')=='Y' || !$this->isExists()) $allow_trackback_status = true;
246
+					if($module_config->enable_trackback == 'N') {
247
+						$allow_trackback_status = false;
248
+					} else if($this->get('allow_trackback')=='Y' || !$this->isExists()) {
249
+						$allow_trackback_status = true;
250
+					}
233 251
 				}
234 252
 			}
235 253
 		}
@@ -238,14 +256,18 @@  discard block
 block discarded – undo
238 256
 
239 257
 	function isLocked()
240 258
 	{
241
-		if(!$this->isExists()) return false;
259
+		if(!$this->isExists()) {
260
+			return false;
261
+		}
242 262
 
243 263
 		return $this->get('comment_status') == 'ALLOW' ? false : true;
244 264
 	}
245 265
 
246 266
 	function isEditable()
247 267
 	{
248
-		if($this->isGranted() || !$this->get('member_srl')) return true;
268
+		if($this->isGranted() || !$this->get('member_srl')) {
269
+			return true;
270
+		}
249 271
 		return false;
250 272
 	}
251 273
 
@@ -267,9 +289,14 @@  discard block
 block discarded – undo
267 289
 
268 290
 	function doCart()
269 291
 	{
270
-		if(!$this->document_srl) return false;
271
-		if($this->isCarted()) $this->removeCart();
272
-		else $this->addCart();
292
+		if(!$this->document_srl) {
293
+			return false;
294
+		}
295
+		if($this->isCarted()) {
296
+			$this->removeCart();
297
+		} else {
298
+			$this->addCart();
299
+		}
273 300
 	}
274 301
 
275 302
 	function addCart()
@@ -295,16 +322,26 @@  discard block
 block discarded – undo
295 322
 	 */
296 323
 	function notify($type, $content)
297 324
 	{
298
-		if(!$this->document_srl) return;
325
+		if(!$this->document_srl) {
326
+			return;
327
+		}
299 328
 		// return if it is not useNotify
300
-		if(!$this->useNotify()) return;
329
+		if(!$this->useNotify()) {
330
+			return;
331
+		}
301 332
 		// Pass if an author is not a logged-in user
302
-		if(!$this->get('member_srl')) return;
333
+		if(!$this->get('member_srl')) {
334
+			return;
335
+		}
303 336
 		// Return if the currently logged-in user is an author
304 337
 		$logged_info = Context::get('logged_info');
305
-		if($logged_info->member_srl == $this->get('member_srl')) return;
338
+		if($logged_info->member_srl == $this->get('member_srl')) {
339
+			return;
340
+		}
306 341
 		// List variables
307
-		if($type) $title = "[".$type."] ";
342
+		if($type) {
343
+			$title = "[".$type."] ";
344
+		}
308 345
 		$title .= cut_str(strip_tags($content), 10, '...');
309 346
 		$content = sprintf('%s<br /><br />from : <a href="%s" target="_blank">%s</a>',$content, getFullUrl('','document_srl',$this->document_srl), getFullUrl('','document_srl',$this->document_srl));
310 347
 		$receiver_srl = $this->get('member_srl');
@@ -331,16 +368,22 @@  discard block
 block discarded – undo
331 368
 
332 369
 	function isExistsHomepage()
333 370
 	{
334
-		if(trim($this->get('homepage'))) return true;
371
+		if(trim($this->get('homepage'))) {
372
+			return true;
373
+		}
335 374
 		return false;
336 375
 	}
337 376
 
338 377
 	function getHomepageUrl()
339 378
 	{
340 379
 		$url = trim($this->get('homepage'));
341
-		if(!$url) return;
380
+		if(!$url) {
381
+			return;
382
+		}
342 383
 
343
-		if(strncasecmp('http://', $url, 7) !== 0 && strncasecmp('https://', $url, 8) !== 0)  $url = 'http://' . $url;
384
+		if(strncasecmp('http://', $url, 7) !== 0 && strncasecmp('https://', $url, 8) !== 0) {
385
+			$url = 'http://' . $url;
386
+		}
344 387
 
345 388
 		return $url;
346 389
 	}
@@ -372,43 +415,65 @@  discard block
 block discarded – undo
372 415
 
373 416
 	function getTitleText($cut_size = 0, $tail='...')
374 417
 	{
375
-		if(!$this->document_srl) return;
418
+		if(!$this->document_srl) {
419
+			return;
420
+		}
376 421
 
377
-		if($cut_size) $title = cut_str($this->get('title'), $cut_size, $tail);
378
-		else $title = $this->get('title');
422
+		if($cut_size) {
423
+			$title = cut_str($this->get('title'), $cut_size, $tail);
424
+		} else {
425
+			$title = $this->get('title');
426
+		}
379 427
 
380 428
 		return $title;
381 429
 	}
382 430
 
383 431
 	function getTitle($cut_size = 0, $tail='...')
384 432
 	{
385
-		if(!$this->document_srl) return;
433
+		if(!$this->document_srl) {
434
+			return;
435
+		}
386 436
 
387 437
 		$title = $this->getTitleText($cut_size, $tail);
388 438
 
389 439
 		$attrs = array();
390 440
 		$this->add('title_color', trim($this->get('title_color')));
391
-		if($this->get('title_bold')=='Y') $attrs[] = "font-weight:bold;";
392
-		if($this->get('title_color') && $this->get('title_color') != 'N') $attrs[] = "color:#".$this->get('title_color');
441
+		if($this->get('title_bold')=='Y') {
442
+			$attrs[] = "font-weight:bold;";
443
+		}
444
+		if($this->get('title_color') && $this->get('title_color') != 'N') {
445
+			$attrs[] = "color:#".$this->get('title_color');
446
+		}
393 447
 
394
-		if(count($attrs)) return sprintf("<span style=\"%s\">%s</span>", implode(';',$attrs), htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
395
-		else return htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
448
+		if(count($attrs)) {
449
+			return sprintf("<span style=\"%s\">%s</span>", implode(';',$attrs), htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
450
+		} else {
451
+			return htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
452
+		}
396 453
 	}
397 454
 
398 455
 	function getContentText($strlen = 0)
399 456
 	{
400
-		if(!$this->document_srl) return;
457
+		if(!$this->document_srl) {
458
+			return;
459
+		}
401 460
 
402
-		if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret');
461
+		if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) {
462
+			return Context::getLang('msg_is_secret');
463
+		}
403 464
 
404 465
 		$result = $this->_checkAccessibleFromStatus();
405
-		if($result) $_SESSION['accessible'][$this->document_srl] = true;
466
+		if($result) {
467
+			$_SESSION['accessible'][$this->document_srl] = true;
468
+		}
406 469
 
407 470
 		$content = $this->get('content');
408 471
 		$content = preg_replace_callback('/<(object|param|embed)[^>]*/is', array($this, '_checkAllowScriptAccess'), $content);
409 472
 		$content = preg_replace_callback('/<object[^>]*>/is', array($this, '_addAllowScriptAccess'), $content);
410 473
 
411
-		if($strlen) return cut_str(strip_tags($content),$strlen,'...');
474
+		if($strlen) {
475
+			return cut_str(strip_tags($content),$strlen,'...');
476
+		}
412 477
 
413 478
 		return htmlspecialchars($content);
414 479
 	}
@@ -441,14 +506,12 @@  discard block
 block discarded – undo
441 506
 				}
442 507
 				$this->allowscriptaccessList[count($this->allowscriptaccessList)-1]--;
443 508
 			}
444
-		}
445
-		else if($m[1] == 'embed')
509
+		} else if($m[1] == 'embed')
446 510
 		{
447 511
 			if(stripos($m[0], 'allowscriptaccess'))
448 512
 			{
449 513
 				$m[0] = preg_replace('/always|samedomain/i', 'never', $m[0]);
450
-			}
451
-			else
514
+			} else
452 515
 			{
453 516
 				$m[0] = preg_replace('/\<embed/i', '<embed allowscriptaccess="never"', $m[0]);
454 517
 			}
@@ -458,15 +521,23 @@  discard block
 block discarded – undo
458 521
 
459 522
 	function getContent($add_popup_menu = true, $add_content_info = true, $resource_realpath = false, $add_xe_content_class = true, $stripEmbedTagException = false)
460 523
 	{
461
-		if(!$this->document_srl) return;
524
+		if(!$this->document_srl) {
525
+			return;
526
+		}
462 527
 
463
-		if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret');
528
+		if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) {
529
+			return Context::getLang('msg_is_secret');
530
+		}
464 531
 
465 532
 		$result = $this->_checkAccessibleFromStatus();
466
-		if($result) $_SESSION['accessible'][$this->document_srl] = true;
533
+		if($result) {
534
+			$_SESSION['accessible'][$this->document_srl] = true;
535
+		}
467 536
 
468 537
 		$content = $this->get('content');
469
-		if(!$stripEmbedTagException) stripEmbedTagForAdmin($content, $this->get('member_srl'));
538
+		if(!$stripEmbedTagException) {
539
+			stripEmbedTagForAdmin($content, $this->get('member_srl'));
540
+		}
470 541
 
471 542
 		// Define a link if using a rewrite module
472 543
 		$oContext = &Context::getInstance();
@@ -500,10 +571,11 @@  discard block
 block discarded – undo
500 571
 				$this->document_srl, $memberSrl
501 572
 			);
502 573
 			// Add xe_content class although accessing content is not required
503
-		}
504
-		else
574
+		} else
505 575
 		{
506
-			if($add_xe_content_class) $content = sprintf('<div class="xe_content">%s</div>', $content);
576
+			if($add_xe_content_class) {
577
+				$content = sprintf('<div class="xe_content">%s</div>', $content);
578
+			}
507 579
 		}
508 580
 		// Change the image path to a valid absolute path if resource_realpath is true
509 581
 		if($resource_realpath)
@@ -622,11 +694,15 @@  discard block
 block discarded – undo
622 694
 
623 695
 	function getTrackbackUrl()
624 696
 	{
625
-		if(!$this->document_srl) return;
697
+		if(!$this->document_srl) {
698
+			return;
699
+		}
626 700
 
627 701
 		// Generate a key to prevent spams
628 702
 		$oTrackbackModel = getModel('trackback');
629
-		if($oTrackbackModel) return $oTrackbackModel->getTrackbackUrl($this->document_srl, $this->getDocumentMid());
703
+		if($oTrackbackModel) {
704
+			return $oTrackbackModel->getTrackbackUrl($this->document_srl, $this->getDocumentMid());
705
+		}
630 706
 	}
631 707
 
632 708
 	/**
@@ -645,7 +721,9 @@  discard block
 block discarded – undo
645 721
 
646 722
 	function isExtraVarsExists()
647 723
 	{
648
-		if(!$this->get('module_srl')) return false;
724
+		if(!$this->get('module_srl')) {
725
+			return false;
726
+		}
649 727
 		$oDocumentModel = getModel('document');
650 728
 		$extra_keys = $oDocumentModel->getExtraKeys($this->get('module_srl'));
651 729
 		return count($extra_keys)?true:false;
@@ -653,7 +731,9 @@  discard block
 block discarded – undo
653 731
 
654 732
 	function getExtraVars()
655 733
 	{
656
-		if(!$this->get('module_srl') || !$this->document_srl) return null;
734
+		if(!$this->get('module_srl') || !$this->document_srl) {
735
+			return null;
736
+		}
657 737
 
658 738
 		$oDocumentModel = getModel('document');
659 739
 		return $oDocumentModel->getExtraVars($this->get('module_srl'), $this->document_srl);
@@ -665,8 +745,7 @@  discard block
 block discarded – undo
665 745
 		if(is_array($extra_vars) && array_key_exists($idx,$extra_vars))
666 746
 		{
667 747
 			return $extra_vars[$idx]->getValue();
668
-		}
669
-		else
748
+		} else
670 749
 		{
671 750
 			return '';
672 751
 		}
@@ -678,8 +757,7 @@  discard block
 block discarded – undo
678 757
 		if(is_array($extra_vars) && array_key_exists($idx,$extra_vars))
679 758
 		{
680 759
 			return $extra_vars[$idx]->getValueHTML();
681
-		}
682
-		else
760
+		} else
683 761
 		{
684 762
 			return '';
685 763
 		}
@@ -701,8 +779,7 @@  discard block
 block discarded – undo
701 779
 		if(is_array($extra_eid) && array_key_exists($eid,$extra_eid))
702 780
 		{
703 781
 			return $extra_eid[$eid]->getValue();
704
-		}
705
-		else
782
+		} else
706 783
 		{
707 784
 			return '';
708 785
 		}
@@ -720,8 +797,7 @@  discard block
 block discarded – undo
720 797
 		if(is_array($extra_eid) && array_key_exists($eid,$extra_eid))
721 798
 		{
722 799
 			return $extra_eid[$eid]->getValueHTML();
723
-		}
724
-		else
800
+		} else
725 801
 		{
726 802
 			return '';
727 803
 		}
@@ -741,8 +817,12 @@  discard block
 block discarded – undo
741 817
 
742 818
 	function getComments()
743 819
 	{
744
-		if(!$this->getCommentCount()) return;
745
-		if(!$this->isGranted() && $this->isSecret()) return;
820
+		if(!$this->getCommentCount()) {
821
+			return;
822
+		}
823
+		if(!$this->isGranted() && $this->isSecret()) {
824
+			return;
825
+		}
746 826
 		// cpage is a number of comment pages
747 827
 		$cpageStr = sprintf('%d_cpage', $this->document_srl);
748 828
 		$cpage = Context::get($cpageStr);
@@ -755,7 +835,9 @@  discard block
 block discarded – undo
755 835
 		// Get a list of comments
756 836
 		$oCommentModel = getModel('comment');
757 837
 		$output = $oCommentModel->getCommentList($this->document_srl, $cpage, $is_admin);
758
-		if(!$output->toBool() || !count($output->data)) return;
838
+		if(!$output->toBool() || !count($output->data)) {
839
+			return;
840
+		}
759 841
 		// Create commentItem object from a comment list
760 842
 		// If admin priviledge is granted on parent posts, you can read its child posts.
761 843
 		$accessible = array();
@@ -765,7 +847,9 @@  discard block
 block discarded – undo
765 847
 			$oCommentItem = new commentItem();
766 848
 			$oCommentItem->setAttribute($val);
767 849
 			// If permission is granted to the post, you can access it temporarily
768
-			if($oCommentItem->isGranted()) $accessible[$val->comment_srl] = true;
850
+			if($oCommentItem->isGranted()) {
851
+				$accessible[$val->comment_srl] = true;
852
+			}
769 853
 			// If the comment is set to private and it belongs child post, it is allowable to read the comment for who has a admin privilege on its parent post
770 854
 			if($val->parent_srl>0 && $val->is_secret == 'Y' && !$oCommentItem->isAccessible() && $accessible[$val->parent_srl]===true)
771 855
 			{
@@ -776,7 +860,9 @@  discard block
 block discarded – undo
776 860
 		// Variable setting to be displayed on the skin
777 861
 		Context::set($cpageStr, $output->page_navigation->cur_page);
778 862
 		Context::set('cpage', $output->page_navigation->cur_page);
779
-		if($output->total_page>1) $this->comment_page_navigation = $output->page_navigation;
863
+		if($output->total_page>1) {
864
+			$this->comment_page_navigation = $output->page_navigation;
865
+		}
780 866
 
781 867
 		return $comment_list;
782 868
 	}
@@ -788,9 +874,13 @@  discard block
 block discarded – undo
788 874
 
789 875
 	function getTrackbacks()
790 876
 	{
791
-		if(!$this->document_srl) return;
877
+		if(!$this->document_srl) {
878
+			return;
879
+		}
792 880
 
793
-		if(!$this->allowTrackback() || !$this->get('trackback_count')) return;
881
+		if(!$this->allowTrackback() || !$this->get('trackback_count')) {
882
+			return;
883
+		}
794 884
 
795 885
 		$oTrackbackModel = getModel('trackback');
796 886
 		return $oTrackbackModel->getTrackbackList($this->document_srl, $is_admin);
@@ -798,15 +888,21 @@  discard block
 block discarded – undo
798 888
 
799 889
 	function thumbnailExists($width = 80, $height = 0, $type = '')
800 890
 	{
801
-		if(!$this->document_srl) return false;
802
-		if(!$this->getThumbnail($width, $height, $type)) return false;
891
+		if(!$this->document_srl) {
892
+			return false;
893
+		}
894
+		if(!$this->getThumbnail($width, $height, $type)) {
895
+			return false;
896
+		}
803 897
 		return true;
804 898
 	}
805 899
 
806 900
 	function getThumbnail($width = 80, $height = 0, $thumbnail_type = '')
807 901
 	{
808 902
 		// Return false if the document doesn't exist
809
-		if(!$this->document_srl) return;
903
+		if(!$this->document_srl) {
904
+			return;
905
+		}
810 906
 
811 907
 		if($this->isSecret() && !$this->isGranted())
812 908
 		{
@@ -814,7 +910,9 @@  discard block
 block discarded – undo
814 910
 		}
815 911
 
816 912
 		// If not specify its height, create a square
817
-		if(!$height) $height = $width;
913
+		if(!$height) {
914
+			$height = $width;
915
+		}
818 916
 
819 917
 		// Return false if neither attachement nor image files in the document
820 918
 		$content = $this->get('content');
@@ -832,7 +930,9 @@  discard block
 block discarded – undo
832 930
 				}
833 931
 			}
834 932
 
835
-			if(!preg_match("!<img!is", $content)) return;
933
+			if(!preg_match("!<img!is", $content)) {
934
+				return;
935
+			}
836 936
 		}
837 937
 		// Get thumbnai_type information from document module's configuration
838 938
 		if(!in_array($thumbnail_type, array('crop','ratio')))
@@ -859,8 +959,7 @@  discard block
 block discarded – undo
859 959
 			if(filesize($thumbnail_file) < 1)
860 960
 			{
861 961
 				return FALSE;
862
-			}
863
-			else
962
+			} else
864 963
 			{
865 964
 				return $thumbnail_url;
866 965
 			}
@@ -881,7 +980,9 @@  discard block
 block discarded – undo
881 980
 			$first_image = null;
882 981
 			foreach($file_list as $file)
883 982
 			{
884
-				if($file->direct_download !== 'Y') continue;
983
+				if($file->direct_download !== 'Y') {
984
+					continue;
985
+				}
885 986
 
886 987
 				if($file->cover_image === 'Y' && file_exists($file->uploaded_filename))
887 988
 				{
@@ -889,7 +990,9 @@  discard block
 block discarded – undo
889 990
 					break;
890 991
 				}
891 992
 
892
-				if($first_image) continue;
993
+				if($first_image) {
994
+					continue;
995
+				}
893 996
 
894 997
 				if(preg_match("/\.(jpe?g|png|gif|bmp)$/i", $file->source_filename))
895 998
 				{
@@ -916,7 +1019,9 @@  discard block
 block discarded – undo
916 1019
 			foreach($matches as $target_image)
917 1020
 			{
918 1021
 				$target_src = trim($target_image[1]);
919
-				if(preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) continue;
1022
+				if(preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) {
1023
+					continue;
1024
+				}
920 1025
 
921 1026
 				if(!preg_match('/^(http|https):\/\//i',$target_src))
922 1027
 				{
@@ -927,7 +1032,9 @@  discard block
 block discarded – undo
927 1032
 
928 1033
 				$tmp_file = _XE_PATH_ . 'files/cache/tmp/' . $random->createSecureSalt(32, 'hex');
929 1034
 				FileHandler::getRemoteFile($target_src, $tmp_file);
930
-				if(!file_exists($tmp_file)) continue;
1035
+				if(!file_exists($tmp_file)) {
1036
+					continue;
1037
+				}
931 1038
 
932 1039
 				$imageinfo = getimagesize($tmp_file);
933 1040
 				list($_w, $_h) = $imageinfo;
@@ -978,21 +1085,28 @@  discard block
 block discarded – undo
978 1085
 	 */
979 1086
 	function getExtraImages($time_interval = 43200)
980 1087
 	{
981
-		if(!$this->document_srl) return;
1088
+		if(!$this->document_srl) {
1089
+			return;
1090
+		}
982 1091
 		// variables for icon list
983 1092
 		$buffs = array();
984 1093
 
985 1094
 		$check_files = false;
986 1095
 
987 1096
 		// Check if secret post is
988
-		if($this->isSecret()) $buffs[] = "secret";
1097
+		if($this->isSecret()) {
1098
+			$buffs[] = "secret";
1099
+		}
989 1100
 
990 1101
 		// Set the latest time
991 1102
 		$time_check = date("YmdHis", $_SERVER['REQUEST_TIME']-$time_interval);
992 1103
 
993 1104
 		// Check new post
994
-		if($this->get('regdate')>$time_check) $buffs[] = "new";
995
-		else if($this->get('last_update')>$time_check) $buffs[] = "update";
1105
+		if($this->get('regdate')>$time_check) {
1106
+			$buffs[] = "new";
1107
+		} else if($this->get('last_update')>$time_check) {
1108
+			$buffs[] = "update";
1109
+		}
996 1110
 
997 1111
 		/*
998 1112
 		   $content = $this->get('content');
@@ -1015,14 +1129,18 @@  discard block
 block discarded – undo
1015 1129
 		 */
1016 1130
 
1017 1131
 		// Check the attachment
1018
-		if($this->hasUploadedFiles()) $buffs[] = "file";
1132
+		if($this->hasUploadedFiles()) {
1133
+			$buffs[] = "file";
1134
+		}
1019 1135
 
1020 1136
 		return $buffs;
1021 1137
 	}
1022 1138
 
1023 1139
 	function getStatus()
1024 1140
 	{
1025
-		if(!$this->get('status')) return $this->getDefaultStatus();
1141
+		if(!$this->get('status')) {
1142
+			return $this->getDefaultStatus();
1143
+		}
1026 1144
 		return $this->get('status');
1027 1145
 	}
1028 1146
 
@@ -1033,22 +1151,25 @@  discard block
 block discarded – undo
1033 1151
 	 */
1034 1152
 	function printExtraImages($time_check = 43200)
1035 1153
 	{
1036
-		if(!$this->document_srl) return;
1154
+		if(!$this->document_srl) {
1155
+			return;
1156
+		}
1037 1157
 
1038 1158
 		$oDocumentModel = getModel('document');
1039 1159
 		$documentConfig = $oDocumentModel->getDocumentConfig();
1040 1160
 		if(Mobile::isFromMobilePhone())
1041 1161
 		{
1042 1162
 			$iconSkin = $documentConfig->micons;
1043
-		}
1044
-		else
1163
+		} else
1045 1164
 		{
1046 1165
 			$iconSkin = $documentConfig->icons;
1047 1166
 		}
1048 1167
 		$path = sprintf('%s%s',getUrl(), "modules/document/tpl/icons/$iconSkin/");
1049 1168
 
1050 1169
 		$buffs = $this->getExtraImages($time_check);
1051
-		if(!count($buffs)) return;
1170
+		if(!count($buffs)) {
1171
+			return;
1172
+		}
1052 1173
 
1053 1174
 		$buff = array();
1054 1175
 		foreach($buffs as $key => $val)
@@ -1060,18 +1181,28 @@  discard block
 block discarded – undo
1060 1181
 
1061 1182
 	function hasUploadedFiles()
1062 1183
 	{
1063
-		if(!$this->document_srl) return;
1184
+		if(!$this->document_srl) {
1185
+			return;
1186
+		}
1064 1187
 
1065
-		if($this->isSecret() && !$this->isGranted()) return false;
1188
+		if($this->isSecret() && !$this->isGranted()) {
1189
+			return false;
1190
+		}
1066 1191
 		return $this->get('uploaded_count')? true : false;
1067 1192
 	}
1068 1193
 
1069 1194
 	function getUploadedFiles($sortIndex = 'file_srl')
1070 1195
 	{
1071
-		if(!$this->document_srl) return;
1196
+		if(!$this->document_srl) {
1197
+			return;
1198
+		}
1072 1199
 
1073
-		if($this->isSecret() && !$this->isGranted()) return;
1074
-		if(!$this->get('uploaded_count')) return;
1200
+		if($this->isSecret() && !$this->isGranted()) {
1201
+			return;
1202
+		}
1203
+		if(!$this->get('uploaded_count')) {
1204
+			return;
1205
+		}
1075 1206
 
1076 1207
 		if(!$this->uploadedFiles[$sortIndex])
1077 1208
 		{
@@ -1089,7 +1220,9 @@  discard block
 block discarded – undo
1089 1220
 	function getEditor()
1090 1221
 	{
1091 1222
 		$module_srl = $this->get('module_srl');
1092
-		if(!$module_srl) $module_srl = Context::get('module_srl');
1223
+		if(!$module_srl) {
1224
+			$module_srl = Context::get('module_srl');
1225
+		}
1093 1226
 
1094 1227
 		$oEditorModel = getModel('editor');
1095 1228
 		return $oEditorModel->getModuleEditor('document', $module_srl, $this->document_srl, 'document_srl', 'content');
@@ -1103,8 +1236,12 @@  discard block
 block discarded – undo
1103 1236
 	function isEnableComment()
1104 1237
 	{
1105 1238
 		// Return false if not authorized, if a secret document, if the document is set not to allow any comment
1106
-		if (!$this->allowComment()) return false;
1107
-		if(!$this->isGranted() && $this->isSecret()) return false;
1239
+		if (!$this->allowComment()) {
1240
+			return false;
1241
+		}
1242
+		if(!$this->isGranted() && $this->isSecret()) {
1243
+			return false;
1244
+		}
1108 1245
 
1109 1246
 		return true;
1110 1247
 	}
@@ -1115,7 +1252,9 @@  discard block
 block discarded – undo
1115 1252
 	 */
1116 1253
 	function getCommentEditor()
1117 1254
 	{
1118
-		if(!$this->isEnableComment()) return;
1255
+		if(!$this->isEnableComment()) {
1256
+			return;
1257
+		}
1119 1258
 
1120 1259
 		$oEditorModel = getModel('editor');
1121 1260
 		return $oEditorModel->getModuleEditor('comment', $this->get('module_srl'), $comment_srl, 'comment_srl', 'content');
@@ -1127,10 +1266,14 @@  discard block
 block discarded – undo
1127 1266
 	 */
1128 1267
 	function getProfileImage()
1129 1268
 	{
1130
-		if(!$this->isExists() || !$this->get('member_srl')) return;
1269
+		if(!$this->isExists() || !$this->get('member_srl')) {
1270
+			return;
1271
+		}
1131 1272
 		$oMemberModel = getModel('member');
1132 1273
 		$profile_info = $oMemberModel->getProfileImage($this->get('member_srl'));
1133
-		if(!$profile_info) return;
1274
+		if(!$profile_info) {
1275
+			return;
1276
+		}
1134 1277
 
1135 1278
 		return $profile_info->src;
1136 1279
 	}
@@ -1142,7 +1285,9 @@  discard block
 block discarded – undo
1142 1285
 	function getSignature()
1143 1286
 	{
1144 1287
 		// Pass if a document doesn't exist
1145
-		if(!$this->isExists() || !$this->get('member_srl')) return;
1288
+		if(!$this->isExists() || !$this->get('member_srl')) {
1289
+			return;
1290
+		}
1146 1291
 		// Get signature information
1147 1292
 		$oMemberModel = getModel('member');
1148 1293
 		$signature = $oMemberModel->getSignature($this->get('member_srl'));
@@ -1156,7 +1301,9 @@  discard block
 block discarded – undo
1156 1301
 		if($signature)
1157 1302
 		{
1158 1303
 			$max_signature_height = $GLOBALS['__member_signature_max_height'];
1159
-			if($max_signature_height) $signature = sprintf('<div style="max-height:%dpx;overflow:auto;overflow-x:hidden;height:expression(this.scrollHeight > %d ? \'%dpx\': \'auto\')">%s</div>', $max_signature_height, $max_signature_height, $max_signature_height, $signature);
1304
+			if($max_signature_height) {
1305
+				$signature = sprintf('<div style="max-height:%dpx;overflow:auto;overflow-x:hidden;height:expression(this.scrollHeight > %d ? \'%dpx\': \'auto\')">%s</div>', $max_signature_height, $max_signature_height, $max_signature_height, $signature);
1306
+			}
1160 1307
 		}
1161 1308
 
1162 1309
 		return $signature;
@@ -1180,20 +1327,25 @@  discard block
 block discarded – undo
1180 1327
 	function _checkAccessibleFromStatus()
1181 1328
 	{
1182 1329
 		$logged_info = Context::get('logged_info');
1183
-		if($logged_info->is_admin == 'Y') return true;
1330
+		if($logged_info->is_admin == 'Y') {
1331
+			return true;
1332
+		}
1184 1333
 
1185 1334
 		$status = $this->get('status');
1186
-		if(empty($status)) return false;
1335
+		if(empty($status)) {
1336
+			return false;
1337
+		}
1187 1338
 
1188 1339
 		$oDocumentModel = getModel('document');
1189 1340
 		$configStatusList = $oDocumentModel->getStatusList();
1190 1341
 
1191
-		if($status == $configStatusList['public'] || $status == $configStatusList['publish'])
1192
-			return true;
1193
-		else if($status == $configStatusList['private'] || $status == $configStatusList['secret'])
1342
+		if($status == $configStatusList['public'] || $status == $configStatusList['publish']) {
1343
+					return true;
1344
+		} else if($status == $configStatusList['private'] || $status == $configStatusList['secret'])
1194 1345
 		{
1195
-			if($this->get('member_srl') == $logged_info->member_srl)
1196
-				return true;
1346
+			if($this->get('member_srl') == $logged_info->member_srl) {
1347
+							return true;
1348
+			}
1197 1349
 		}
1198 1350
 		return false;
1199 1351
 	}
Please login to merge, or discard this patch.
modules/document/document.model.php 3 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 	/**
473 473
 	 * Show pop-up menu of the selected posts
474 474
 	 * Printing, scrap, recommendations and negative, reported the Add Features
475
-	 * @return void
475
+	 * @return Object|null
476 476
 	 */
477 477
 	function getDocumentMenu()
478 478
 	{
@@ -884,7 +884,7 @@  discard block
 block discarded – undo
884 884
 
885 885
 	/**
886 886
 	 * Get a list for a particular module
887
-	 * @return void|Object
887
+	 * @return Object|null
888 888
 	 */
889 889
 	function getDocumentCategories()
890 890
 	{
@@ -970,7 +970,7 @@  discard block
 block discarded – undo
970 970
 	/**
971 971
 	 * Certain categories of information, return the template guhanhu
972 972
 	 * Manager on the page to add information about a particular menu from the server after compiling tpl compiled a direct return html
973
-	 * @return void|Object
973
+	 * @return Object|null
974 974
 	 */
975 975
 	function getDocumentCategoryTplInfo()
976 976
 	{
@@ -1227,7 +1227,7 @@  discard block
 block discarded – undo
1227 1227
 	 * Setting sort index
1228 1228
 	 * @param object $obj
1229 1229
 	 * @param bool $load_extra_vars
1230
-	 * @return object
1230
+	 * @return stdClass
1231 1231
 	 */
1232 1232
 	function _setSortIndex($obj, $load_extra_vars)
1233 1233
 	{
Please login to merge, or discard this patch.
Spacing   +234 added lines, -234 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 */
38 38
 	function getDocumentExtraVarsFromDB($documentSrls)
39 39
 	{
40
-		if(!is_array($documentSrls) || count($documentSrls) == 0)
40
+		if (!is_array($documentSrls) || count($documentSrls) == 0)
41 41
 		{
42 42
 			return new Object(-1, 'msg_invalid_request');
43 43
 		}
@@ -58,52 +58,52 @@  discard block
 block discarded – undo
58 58
 		$_document_list = &$GLOBALS['XE_DOCUMENT_LIST'];
59 59
 
60 60
 		// XE XE_DOCUMENT_LIST all documents that the object referred to the global variable settings
61
-		if(count($_document_list) <= 0) return;
61
+		if (count($_document_list) <= 0) return;
62 62
 
63 63
 		// Find all called the document object variable has been set extension
64 64
 		$document_srls = array();
65
-		foreach($_document_list as $key => $val)
65
+		foreach ($_document_list as $key => $val)
66 66
 		{
67
-			if(!$val->document_srl || $checked_documents[$val->document_srl]) continue;
67
+			if (!$val->document_srl || $checked_documents[$val->document_srl]) continue;
68 68
 			$checked_documents[$val->document_srl] = true;
69 69
 			$document_srls[] = $val->document_srl;
70 70
 		}
71 71
 		// If the document number, return detected
72
-		if(!count($document_srls)) return;
72
+		if (!count($document_srls)) return;
73 73
 		// Expand variables mijijeongdoen article about a current visitor to the extension of the language code, the search variable
74 74
 		//$obj->document_srl = implode(',',$document_srls);
75 75
 		$output = $this->getDocumentExtraVarsFromDB($document_srls);
76
-		if($output->toBool() && $output->data)
76
+		if ($output->toBool() && $output->data)
77 77
 		{
78
-			foreach($output->data as $key => $val)
78
+			foreach ($output->data as $key => $val)
79 79
 			{
80
-				if(!isset($val->value)) continue;
81
-				if(!$extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0]) $extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0] = trim($val->value);
80
+				if (!isset($val->value)) continue;
81
+				if (!$extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0]) $extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0] = trim($val->value);
82 82
 				$extra_vars[$val->document_srl][$val->var_idx][$val->lang_code] = trim($val->value);
83 83
 			}
84 84
 		}
85 85
 
86 86
 		$user_lang_code = Context::getLangType();
87
-		for($i=0,$c=count($document_srls);$i<$c;$i++)
87
+		for ($i = 0, $c = count($document_srls); $i < $c; $i++)
88 88
 		{
89 89
 			$document_srl = $document_srls[$i];
90 90
 			unset($vars);
91 91
 
92
-			if(!$_document_list[$document_srl] || !is_object($_document_list[$document_srl]) || !$_document_list[$document_srl]->isExists()) continue;
92
+			if (!$_document_list[$document_srl] || !is_object($_document_list[$document_srl]) || !$_document_list[$document_srl]->isExists()) continue;
93 93
 			$module_srl = $_document_list[$document_srl]->get('module_srl');
94 94
 			$extra_keys = $this->getExtraKeys($module_srl);
95 95
 			$vars = $extra_vars[$document_srl];
96 96
 			$document_lang_code = $_document_list[$document_srl]->get('lang_code');
97 97
 			// Expand the variable processing
98
-			if(count($extra_keys))
98
+			if (count($extra_keys))
99 99
 			{
100
-				foreach($extra_keys as $idx => $key)
100
+				foreach ($extra_keys as $idx => $key)
101 101
 				{
102 102
 					$extra_keys[$idx] = clone($key);
103 103
 					$val = $vars[$idx];
104
-					if(isset($val[$user_lang_code])) $v = $val[$user_lang_code];
105
-					else if(isset($val[$document_lang_code])) $v = $val[$document_lang_code];
106
-					else if(isset($val[0])) $v = $val[0];
104
+					if (isset($val[$user_lang_code])) $v = $val[$user_lang_code];
105
+					else if (isset($val[$document_lang_code])) $v = $val[$document_lang_code];
106
+					else if (isset($val[0])) $v = $val[0];
107 107
 					else $v = null;
108 108
 					$extra_keys[$idx]->value = $v;
109 109
 				}
@@ -113,11 +113,11 @@  discard block
 block discarded – undo
113 113
 			$evars = new ExtraVar($module_srl);
114 114
 			$evars->setExtraVarKeys($extra_keys);
115 115
 			// Title Processing
116
-			if($vars[-1][$user_lang_code]) $_document_list[$document_srl]->add('title',$vars[-1][$user_lang_code]);
116
+			if ($vars[-1][$user_lang_code]) $_document_list[$document_srl]->add('title', $vars[-1][$user_lang_code]);
117 117
 			// Information processing
118
-			if($vars[-2][$user_lang_code]) $_document_list[$document_srl]->add('content',$vars[-2][$user_lang_code]);
118
+			if ($vars[-2][$user_lang_code]) $_document_list[$document_srl]->add('content', $vars[-2][$user_lang_code]);
119 119
 
120
-			if($vars[-1][$user_lang_code] || $vars[-2][$user_lang_code])
120
+			if ($vars[-1][$user_lang_code] || $vars[-2][$user_lang_code])
121 121
 			{
122 122
 				unset($checked_documents[$document_srl]);
123 123
 			}
@@ -134,17 +134,17 @@  discard block
 block discarded – undo
134 134
 	 * @param array $columnList
135 135
 	 * @return documentItem
136 136
 	 */
137
-	function getDocument($document_srl=0, $is_admin = false, $load_extra_vars=true, $columnList = array())
137
+	function getDocument($document_srl = 0, $is_admin = false, $load_extra_vars = true, $columnList = array())
138 138
 	{
139
-		if(!$document_srl) return new documentItem();
139
+		if (!$document_srl) return new documentItem();
140 140
 
141
-		if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl])
141
+		if (!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl])
142 142
 		{
143 143
 			$oDocument = new documentItem($document_srl, $load_extra_vars, $columnList);
144 144
 			$GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument;
145
-			if($load_extra_vars) $this->setToAllDocumentExtraVars();
145
+			if ($load_extra_vars) $this->setToAllDocumentExtraVars();
146 146
 		}
147
-		if($is_admin) $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]->setGrant();
147
+		if ($is_admin) $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]->setGrant();
148 148
 
149 149
 		return $GLOBALS['XE_DOCUMENT_LIST'][$document_srl];
150 150
 	}
@@ -157,12 +157,12 @@  discard block
 block discarded – undo
157 157
 	 * @param array $columnList
158 158
 	 * @return array value type is documentItem
159 159
 	 */
160
-	function getDocuments($document_srls, $is_admin = false, $load_extra_vars=true, $columnList = array())
160
+	function getDocuments($document_srls, $is_admin = false, $load_extra_vars = true, $columnList = array())
161 161
 	{
162
-		if(is_array($document_srls))
162
+		if (is_array($document_srls))
163 163
 		{
164 164
 			$list_count = count($document_srls);
165
-			$document_srls = implode(',',$document_srls);
165
+			$document_srls = implode(',', $document_srls);
166 166
 		}
167 167
 		else
168 168
 		{
@@ -175,33 +175,33 @@  discard block
 block discarded – undo
175 175
 
176 176
 		$output = executeQuery('document.getDocuments', $args, $columnList);
177 177
 		$document_list = $output->data;
178
-		if(!$document_list) return;
179
-		if(!is_array($document_list)) $document_list = array($document_list);
178
+		if (!$document_list) return;
179
+		if (!is_array($document_list)) $document_list = array($document_list);
180 180
 
181 181
 		$document_count = count($document_list);
182
-		foreach($document_list as $key => $attribute)
182
+		foreach ($document_list as $key => $attribute)
183 183
 		{
184 184
 			$document_srl = $attribute->document_srl;
185
-			if(!$document_srl) continue;
185
+			if (!$document_srl) continue;
186 186
 
187
-			if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl])
187
+			if (!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl])
188 188
 			{
189 189
 				$oDocument = null;
190 190
 				$oDocument = new documentItem();
191 191
 				$oDocument->setAttribute($attribute, false);
192
-				if($is_admin) $oDocument->setGrant();
192
+				if ($is_admin) $oDocument->setGrant();
193 193
 				$GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument;
194 194
 			}
195 195
 
196 196
 			$result[$attribute->document_srl] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl];
197 197
 		}
198 198
 
199
-		if($load_extra_vars) $this->setToAllDocumentExtraVars();
199
+		if ($load_extra_vars) $this->setToAllDocumentExtraVars();
200 200
 
201 201
 		$output = null;
202
-		if(count($result))
202
+		if (count($result))
203 203
 		{
204
-			foreach($result as $document_srl => $val)
204
+			foreach ($result as $document_srl => $val)
205 205
 			{
206 206
 				$output[$document_srl] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl];
207 207
 			}
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 	 * @param array $columnList
219 219
 	 * @return Object
220 220
 	 */
221
-	function getDocumentList($obj, $except_notice = false, $load_extra_vars=true, $columnList = array())
221
+	function getDocumentList($obj, $except_notice = false, $load_extra_vars = true, $columnList = array())
222 222
 	{
223 223
 		$sort_check = $this->_setSortIndex($obj, $load_extra_vars);
224 224
 		$obj->sort_index = $sort_check->sort_index;
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 		// Call trigger (before)
229 229
 		// This trigger can be used to set an alternative output using a different search method
230 230
 		$output = ModuleHandler::triggerCall('document.getDocumentList', 'before', $obj);
231
-		if($output instanceof Object && !$output->toBool())
231
+		if ($output instanceof Object && !$output->toBool())
232 232
 		{
233 233
 			return $output;
234 234
 		}
@@ -245,10 +245,10 @@  discard block
 block discarded – undo
245 245
 			$output = $obj->use_alternate_output;
246 246
 			unset($obj->use_alternate_output);
247 247
 		}
248
-		elseif ($sort_check->isExtraVars && substr_count($obj->search_target,'extra_vars'))
248
+		elseif ($sort_check->isExtraVars && substr_count($obj->search_target, 'extra_vars'))
249 249
 		{
250 250
 			$query_id = 'document.getDocumentListWithinExtraVarsExtraSort';
251
-			$args->sort_index = str_replace('documents.','',$args->sort_index);
251
+			$args->sort_index = str_replace('documents.', '', $args->sort_index);
252 252
 			$output = executeQueryArray($query_id, $args);
253 253
 		}
254 254
 		elseif ($sort_check->isExtraVars)
@@ -260,16 +260,16 @@  discard block
 block discarded – undo
260 260
 			// document.getDocumentList query execution
261 261
 			// Query_id if you have a group by clause getDocumentListWithinTag getDocumentListWithinComment or used again to perform the query because
262 262
 			$groupByQuery = array('document.getDocumentListWithinComment' => 1, 'document.getDocumentListWithinTag' => 1, 'document.getDocumentListWithinExtraVars' => 1);
263
-			if(isset($groupByQuery[$query_id]))
263
+			if (isset($groupByQuery[$query_id]))
264 264
 			{
265 265
 				$group_args = clone($args);
266 266
 				$group_args->sort_index = 'documents.'.$args->sort_index;
267 267
 				$output = executeQueryArray($query_id, $group_args);
268
-				if(!$output->toBool()||!count($output->data)) return $output;
268
+				if (!$output->toBool() || !count($output->data)) return $output;
269 269
 
270
-				foreach($output->data as $key => $val)
270
+				foreach ($output->data as $key => $val)
271 271
 				{
272
-					if($val->document_srl) $target_srls[] = $val->document_srl;
272
+					if ($val->document_srl) $target_srls[] = $val->document_srl;
273 273
 				}
274 274
 
275 275
 				$page_navigation = $output->page_navigation;
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 				$virtual_number = $keys[0];
278 278
 
279 279
 				$target_args = new stdClass();
280
-				$target_args->document_srls = implode(',',$target_srls);
280
+				$target_args->document_srls = implode(',', $target_srls);
281 281
 				$target_args->list_order = $args->sort_index;
282 282
 				$target_args->order_type = $args->order_type;
283 283
 				$target_args->list_count = $args->list_count;
@@ -294,35 +294,35 @@  discard block
 block discarded – undo
294 294
 			}
295 295
 		}
296 296
 		// Return if no result or an error occurs
297
-		if(!$output->toBool()||!count($output->data)) return $output;
297
+		if (!$output->toBool() || !count($output->data)) return $output;
298 298
 		$idx = 0;
299 299
 		$data = $output->data;
300 300
 		unset($output->data);
301 301
 
302
-		if(!isset($virtual_number))
302
+		if (!isset($virtual_number))
303 303
 		{
304 304
 			$keys = array_keys($data);
305 305
 			$virtual_number = $keys[0];
306 306
 		}
307 307
 
308
-		if($except_notice)
308
+		if ($except_notice)
309 309
 		{
310
-			foreach($data as $key => $attribute)
310
+			foreach ($data as $key => $attribute)
311 311
 			{
312
-				if($attribute->is_notice == 'Y') $virtual_number --;
312
+				if ($attribute->is_notice == 'Y') $virtual_number--;
313 313
 			}
314 314
 		}
315 315
 
316
-		foreach($data as $key => $attribute)
316
+		foreach ($data as $key => $attribute)
317 317
 		{
318
-			if($except_notice && $attribute->is_notice == 'Y') continue;
318
+			if ($except_notice && $attribute->is_notice == 'Y') continue;
319 319
 			$document_srl = $attribute->document_srl;
320
-			if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl])
320
+			if (!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl])
321 321
 			{
322 322
 				$oDocument = null;
323 323
 				$oDocument = new documentItem();
324 324
 				$oDocument->setAttribute($attribute, false);
325
-				if($is_admin) $oDocument->setGrant();
325
+				if ($is_admin) $oDocument->setGrant();
326 326
 				$GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument;
327 327
 			}
328 328
 
@@ -330,11 +330,11 @@  discard block
 block discarded – undo
330 330
 			$virtual_number--;
331 331
 		}
332 332
 
333
-		if($load_extra_vars) $this->setToAllDocumentExtraVars();
333
+		if ($load_extra_vars) $this->setToAllDocumentExtraVars();
334 334
 
335
-		if(count($output->data))
335
+		if (count($output->data))
336 336
 		{
337
-			foreach($output->data as $number => $document)
337
+			foreach ($output->data as $number => $document)
338 338
 			{
339 339
 				$output->data[$number] = $GLOBALS['XE_DOCUMENT_LIST'][$document->document_srl];
340 340
 			}
@@ -356,16 +356,16 @@  discard block
 block discarded – undo
356 356
 	{
357 357
 		$args = new stdClass();
358 358
 		$args->module_srl = $obj->module_srl;
359
-		$args->category_srl= $obj->category_srl;
359
+		$args->category_srl = $obj->category_srl;
360 360
 		$output = executeQueryArray('document.getNoticeList', $args, $columnList);
361
-		if(!$output->toBool()||!$output->data) return;
361
+		if (!$output->toBool() || !$output->data) return;
362 362
 
363
-		foreach($output->data as $key => $val)
363
+		foreach ($output->data as $key => $val)
364 364
 		{
365 365
 			$document_srl = $val->document_srl;
366
-			if(!$document_srl) continue;
366
+			if (!$document_srl) continue;
367 367
 
368
-			if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl])
368
+			if (!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl])
369 369
 			{
370 370
 				$oDocument = null;
371 371
 				$oDocument = new documentItem();
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 		}
377 377
 		$this->setToAllDocumentExtraVars();
378 378
 
379
-		foreach($result->data as $document_srl => $val)
379
+		foreach ($result->data as $document_srl => $val)
380 380
 		{
381 381
 			$result->data[$document_srl] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl];
382 382
 		}
@@ -392,20 +392,20 @@  discard block
 block discarded – undo
392 392
 	 */
393 393
 	function getExtraKeys($module_srl)
394 394
 	{
395
-		if(!isset($GLOBALS['XE_EXTRA_KEYS'][$module_srl]))
395
+		if (!isset($GLOBALS['XE_EXTRA_KEYS'][$module_srl]))
396 396
 		{
397 397
 			$keys = false;
398 398
 			$oCacheHandler = CacheHandler::getInstance('object', null, true);
399
-			if($oCacheHandler->isSupport())
399
+			if ($oCacheHandler->isSupport())
400 400
 			{
401
-				$object_key = 'module_document_extra_keys:' . $module_srl;
401
+				$object_key = 'module_document_extra_keys:'.$module_srl;
402 402
 				$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
403 403
 				$keys = $oCacheHandler->get($cache_key);
404 404
 			}
405 405
 
406 406
 			$oExtraVar = ExtraVar::getInstance($module_srl);
407 407
 
408
-			if($keys === false)
408
+			if ($keys === false)
409 409
 			{
410 410
 				$obj = new stdClass();
411 411
 				$obj->module_srl = $module_srl;
@@ -415,13 +415,13 @@  discard block
 block discarded – undo
415 415
 
416 416
 				// correcting index order
417 417
 				$isFixed = FALSE;
418
-				if(is_array($output->data))
418
+				if (is_array($output->data))
419 419
 				{
420 420
 					$prevIdx = 0;
421
-					foreach($output->data as $no => $value)
421
+					foreach ($output->data as $no => $value)
422 422
 					{
423 423
 						// case first
424
-						if($prevIdx == 0 && $value->idx != 1)
424
+						if ($prevIdx == 0 && $value->idx != 1)
425 425
 						{
426 426
 							$args = new stdClass();
427 427
 							$args->module_srl = $module_srl;
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 						}
436 436
 
437 437
 						// case others
438
-						if($prevIdx > 0 && $prevIdx + 1 != $value->idx)
438
+						if ($prevIdx > 0 && $prevIdx + 1 != $value->idx)
439 439
 						{
440 440
 							$args = new stdClass();
441 441
 							$args->module_srl = $module_srl;
@@ -452,16 +452,16 @@  discard block
 block discarded – undo
452 452
 					}
453 453
 				}
454 454
 
455
-				if($isFixed)
455
+				if ($isFixed)
456 456
 				{
457 457
 					$output = executeQueryArray('document.getDocumentExtraKeys', $obj);
458 458
 				}
459 459
 
460 460
 				$oExtraVar->setExtraVarKeys($output->data);
461 461
 				$keys = $oExtraVar->getExtraVars();
462
-				if(!$keys) $keys = array();
462
+				if (!$keys) $keys = array();
463 463
 
464
-				if($oCacheHandler->isSupport())
464
+				if ($oCacheHandler->isSupport())
465 465
 				{
466 466
 					$oCacheHandler->put($cache_key, $keys);
467 467
 				}
@@ -482,14 +482,14 @@  discard block
 block discarded – undo
482 482
 	 */
483 483
 	function getExtraVars($module_srl, $document_srl)
484 484
 	{
485
-		if(!isset($GLOBALS['XE_EXTRA_VARS'][$document_srl]))
485
+		if (!isset($GLOBALS['XE_EXTRA_VARS'][$document_srl]))
486 486
 		{
487 487
 			// Extended to extract the values of variables set
488 488
 			$oDocument = $this->getDocument($document_srl, false);
489 489
 			$GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument;
490 490
 			$this->setToAllDocumentExtraVars();
491 491
 		}
492
-		if(is_array($GLOBALS['XE_EXTRA_VARS'][$document_srl])) ksort($GLOBALS['XE_EXTRA_VARS'][$document_srl]);
492
+		if (is_array($GLOBALS['XE_EXTRA_VARS'][$document_srl])) ksort($GLOBALS['XE_EXTRA_VARS'][$document_srl]);
493 493
 		return $GLOBALS['XE_EXTRA_VARS'][$document_srl];
494 494
 	}
495 495
 
@@ -512,71 +512,71 @@  discard block
 block discarded – undo
512 512
 
513 513
 		$oDocumentController = getController('document');
514 514
 		// Members must be a possible feature
515
-		if($logged_info->member_srl)
515
+		if ($logged_info->member_srl)
516 516
 		{
517 517
 			$oDocumentModel = getModel('document');
518 518
 			$columnList = array('document_srl', 'module_srl', 'member_srl', 'ipaddress');
519 519
 			$oDocument = $oDocumentModel->getDocument($document_srl, false, false, $columnList);
520 520
 			$module_srl = $oDocument->get('module_srl');
521 521
 			$member_srl = $oDocument->get('member_srl');
522
-			if(!$module_srl) return new Object(-1, 'msg_invalid_request');
522
+			if (!$module_srl) return new Object(-1, 'msg_invalid_request');
523 523
 
524 524
 			$oModuleModel = getModel('module');
525
-			$document_config = $oModuleModel->getModulePartConfig('document',$module_srl);
526
-			if($document_config->use_vote_up!='N' && $member_srl!=$logged_info->member_srl)
525
+			$document_config = $oModuleModel->getModulePartConfig('document', $module_srl);
526
+			if ($document_config->use_vote_up != 'N' && $member_srl != $logged_info->member_srl)
527 527
 			{
528 528
 				// Add a Referral Button
529 529
 				$url = sprintf("doCallModuleAction('document','procDocumentVoteUp','%s')", $document_srl);
530
-				$oDocumentController->addDocumentPopupMenu($url,'cmd_vote','','javascript');
530
+				$oDocumentController->addDocumentPopupMenu($url, 'cmd_vote', '', 'javascript');
531 531
 			}
532 532
 
533
-			if($document_config->use_vote_down!='N' && $member_srl!=$logged_info->member_srl)
533
+			if ($document_config->use_vote_down != 'N' && $member_srl != $logged_info->member_srl)
534 534
 			{
535 535
 				// Add button to negative
536
-				$url= sprintf("doCallModuleAction('document','procDocumentVoteDown','%s')", $document_srl);
537
-				$oDocumentController->addDocumentPopupMenu($url,'cmd_vote_down','','javascript');
536
+				$url = sprintf("doCallModuleAction('document','procDocumentVoteDown','%s')", $document_srl);
537
+				$oDocumentController->addDocumentPopupMenu($url, 'cmd_vote_down', '', 'javascript');
538 538
 			}
539 539
 
540 540
 			// Adding Report
541 541
 			$url = sprintf("doCallModuleAction('document','procDocumentDeclare','%s')", $document_srl);
542
-			$oDocumentController->addDocumentPopupMenu($url,'cmd_declare','','javascript');
542
+			$oDocumentController->addDocumentPopupMenu($url, 'cmd_declare', '', 'javascript');
543 543
 
544 544
 			// Add Bookmark button
545 545
 			$url = sprintf("doCallModuleAction('member','procMemberScrapDocument','%s')", $document_srl);
546
-			$oDocumentController->addDocumentPopupMenu($url,'cmd_scrap','','javascript');
546
+			$oDocumentController->addDocumentPopupMenu($url, 'cmd_scrap', '', 'javascript');
547 547
 		}
548 548
 		// Add print button
549
-		$url = getUrl('','module','document','act','dispDocumentPrint','document_srl',$document_srl);
550
-		$oDocumentController->addDocumentPopupMenu($url,'cmd_print','','printDocument');
549
+		$url = getUrl('', 'module', 'document', 'act', 'dispDocumentPrint', 'document_srl', $document_srl);
550
+		$oDocumentController->addDocumentPopupMenu($url, 'cmd_print', '', 'printDocument');
551 551
 		// Call a trigger (after)
552 552
 		ModuleHandler::triggerCall('document.getDocumentMenu', 'after', $menu_list);
553
-		if($this->grant->manager)
553
+		if ($this->grant->manager)
554 554
 		{
555 555
 			$str_confirm = Context::getLang('confirm_move');
556 556
 			$url = sprintf("if(!confirm('%s')) return; var params = new Array(); params['document_srl']='%s'; params['mid']=current_mid;params['cur_url']=current_url; exec_xml('document', 'procDocumentAdminMoveToTrash', params)", $str_confirm, $document_srl);
557
-			$oDocumentController->addDocumentPopupMenu($url,'cmd_trash','','javascript');
557
+			$oDocumentController->addDocumentPopupMenu($url, 'cmd_trash', '', 'javascript');
558 558
 		}
559 559
 
560 560
 		// If you are managing to find posts by ip
561
-		if($logged_info->is_admin == 'Y')
561
+		if ($logged_info->is_admin == 'Y')
562 562
 		{
563 563
 			$oDocumentModel = getModel('document');
564
-			$oDocument = $oDocumentModel->getDocument($document_srl);	//before setting document recycle
564
+			$oDocument = $oDocumentModel->getDocument($document_srl); //before setting document recycle
565 565
 
566
-			if($oDocument->isExists())
566
+			if ($oDocument->isExists())
567 567
 			{
568 568
 				// Find a post equivalent to ip address
569
-				$url = getUrl('','module','admin','act','dispDocumentAdminList','search_target','ipaddress','search_keyword',$oDocument->getIpAddress());
570
-				$oDocumentController->addDocumentPopupMenu($url,'cmd_search_by_ipaddress',$icon_path,'TraceByIpaddress');
569
+				$url = getUrl('', 'module', 'admin', 'act', 'dispDocumentAdminList', 'search_target', 'ipaddress', 'search_keyword', $oDocument->getIpAddress());
570
+				$oDocumentController->addDocumentPopupMenu($url, 'cmd_search_by_ipaddress', $icon_path, 'TraceByIpaddress');
571 571
 
572 572
 				$url = sprintf("var params = new Array(); params['ipaddress_list']='%s'; exec_xml('spamfilter', 'procSpamfilterAdminInsertDeniedIP', params, completeCallModuleAction)", $oDocument->getIpAddress());
573
-				$oDocumentController->addDocumentPopupMenu($url,'cmd_add_ip_to_spamfilter','','javascript');
573
+				$oDocumentController->addDocumentPopupMenu($url, 'cmd_add_ip_to_spamfilter', '', 'javascript');
574 574
 			}
575 575
 		}
576 576
 		// Changing the language of pop-up menu
577 577
 		$menus = Context::get('document_popup_menu_list');
578 578
 		$menus_count = count($menus);
579
-		for($i=0;$i<$menus_count;$i++)
579
+		for ($i = 0; $i < $menus_count; $i++)
580 580
 		{
581 581
 			$menus[$i]->str = Context::getLang($menus[$i]->str);
582 582
 		}
@@ -592,13 +592,13 @@  discard block
 block discarded – undo
592 592
 	 */
593 593
 	function getDocumentCount($module_srl, $search_obj = NULL)
594 594
 	{
595
-		if(is_null($search_obj)) $search_obj = new stdClass();
595
+		if (is_null($search_obj)) $search_obj = new stdClass();
596 596
 		$search_obj->module_srl = $module_srl;
597 597
 
598 598
 		$output = executeQuery('document.getDocumentCount', $search_obj);
599 599
 		// Return total number of
600 600
 		$total_count = $output->data->count;
601
-		return (int)$total_count;
601
+		return (int) $total_count;
602 602
 	}
603 603
 
604 604
 	/**
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
 	function getDocumentCountByGroupStatus($search_obj = NULL)
610 610
 	{
611 611
 		$output = executeQuery('document.getDocumentCountByGroupStatus', $search_obj);
612
-		if(!$output->toBool()) return array();
612
+		if (!$output->toBool()) return array();
613 613
 
614 614
 		return $output->data;
615 615
 	}
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
 		$output = executeQuery('document.getDocumentExtraVarsCount', $args);
629 629
 		// Return total number of
630 630
 		$total_count = $output->data->count;
631
-		return (int)$total_count;
631
+		return (int) $total_count;
632 632
 	}
633 633
 
634 634
 	/**
@@ -645,29 +645,29 @@  discard block
 block discarded – undo
645 645
 
646 646
 		$this->_setSearchOption($opt, $args, $query_id, $use_division);
647 647
 
648
-		if($sort_check->isExtraVars)
648
+		if ($sort_check->isExtraVars)
649 649
 		{
650 650
 			return 1;
651 651
 		}
652 652
 		else
653 653
 		{
654
-			if($sort_check->sort_index === 'list_order' || $sort_check->sort_index === 'update_order')
654
+			if ($sort_check->sort_index === 'list_order' || $sort_check->sort_index === 'update_order')
655 655
 			{
656
-				if($args->order_type === 'desc')
656
+				if ($args->order_type === 'desc')
657 657
 				{
658
-					$args->{'rev_' . $sort_check->sort_index} = $oDocument->get($sort_check->sort_index);
658
+					$args->{'rev_'.$sort_check->sort_index} = $oDocument->get($sort_check->sort_index);
659 659
 				}
660 660
 				else
661 661
 				{
662 662
 					$args->{$sort_check->sort_index} = $oDocument->get($sort_check->sort_index);
663 663
 				}
664 664
 			}
665
-			elseif($sort_check->sort_index === 'regdate')
665
+			elseif ($sort_check->sort_index === 'regdate')
666 666
 			{
667 667
 
668
-				if($args->order_type === 'asc')
668
+				if ($args->order_type === 'asc')
669 669
 				{
670
-					$args->{'rev_' . $sort_check->sort_index} = $oDocument->get($sort_check->sort_index);
670
+					$args->{'rev_'.$sort_check->sort_index} = $oDocument->get($sort_check->sort_index);
671 671
 				}
672 672
 				else
673 673
 				{
@@ -682,9 +682,9 @@  discard block
 block discarded – undo
682 682
 		}
683 683
 
684 684
 		// Guhanhu total number of the article search page
685
-		$output = executeQuery($query_id . 'Page', $args);
685
+		$output = executeQuery($query_id.'Page', $args);
686 686
 		$count = $output->data->count;
687
-		$page = (int)(($count-1)/$opt->list_count)+1;
687
+		$page = (int) (($count - 1) / $opt->list_count) + 1;
688 688
 		return $page;
689 689
 	}
690 690
 
@@ -696,16 +696,16 @@  discard block
 block discarded – undo
696 696
 	 */
697 697
 	function getCategory($category_srl, $columnList = array())
698 698
 	{
699
-		$args =new stdClass();
699
+		$args = new stdClass();
700 700
 		$args->category_srl = $category_srl;
701 701
 		$output = executeQuery('document.getCategory', $args, $columnList);
702 702
 
703 703
 		$node = $output->data;
704
-		if(!$node) return;
704
+		if (!$node) return;
705 705
 
706
-		if($node->group_srls)
706
+		if ($node->group_srls)
707 707
 		{
708
-			$group_srls = explode(',',$node->group_srls);
708
+			$group_srls = explode(',', $node->group_srls);
709 709
 			unset($node->group_srls);
710 710
 			$node->group_srls = $group_srls;
711 711
 		}
@@ -726,8 +726,8 @@  discard block
 block discarded – undo
726 726
 	{
727 727
 		$args = new stdClass();
728 728
 		$args->category_srl = $category_srl;
729
-		$output = executeQuery('document.getChildCategoryCount',$args);
730
-		if($output->data->count > 0) return true;
729
+		$output = executeQuery('document.getChildCategoryCount', $args);
730
+		if ($output->data->count > 0) return true;
731 731
 		return false;
732 732
 	}
733 733
 
@@ -743,10 +743,10 @@  discard block
 block discarded – undo
743 743
 		// Category of the target module file swollen
744 744
 		$filename = sprintf("%sfiles/cache/document_category/%s.php", _XE_PATH_, $module_srl);
745 745
 		// If the target file to the cache file regeneration category
746
-		if(!file_exists($filename))
746
+		if (!file_exists($filename))
747 747
 		{
748 748
 			$oDocumentController = getController('document');
749
-			if(!$oDocumentController->makeCategoryFile($module_srl)) return array();
749
+			if (!$oDocumentController->makeCategoryFile($module_srl)) return array();
750 750
 		}
751 751
 
752 752
 		include($filename);
@@ -766,10 +766,10 @@  discard block
 block discarded – undo
766 766
 	 */
767 767
 	function _arrangeCategory(&$document_category, $list, $depth)
768 768
 	{
769
-		if(!count($list)) return;
769
+		if (!count($list)) return;
770 770
 		$idx = 0;
771 771
 		$list_order = array();
772
-		foreach($list as $key => $val)
772
+		foreach ($list as $key => $val)
773 773
 		{
774 774
 			$obj = new stdClass;
775 775
 			$obj->mid = $val['mid'];
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
 			$obj->parent_srl = $val['parent_srl'];
779 779
 			$obj->title = $obj->text = $val['text'];
780 780
 			$obj->description = $val['description'];
781
-			$obj->expand = $val['expand']=='Y'?true:false;
781
+			$obj->expand = $val['expand'] == 'Y' ?true:false;
782 782
 			$obj->color = $val['color'];
783 783
 			$obj->document_count = $val['document_count'];
784 784
 			$obj->depth = $depth;
@@ -786,26 +786,26 @@  discard block
 block discarded – undo
786 786
 			$obj->childs = array();
787 787
 			$obj->grant = $val['grant'];
788 788
 
789
-			if(Context::get('mid') == $obj->mid && Context::get('category') == $obj->category_srl) $selected = true;
789
+			if (Context::get('mid') == $obj->mid && Context::get('category') == $obj->category_srl) $selected = true;
790 790
 			else $selected = false;
791 791
 
792 792
 			$obj->selected = $selected;
793 793
 
794 794
 			$list_order[$idx++] = $obj->category_srl;
795 795
 			// If you have a parent category of child nodes apply data
796
-			if($obj->parent_srl)
796
+			if ($obj->parent_srl)
797 797
 			{
798 798
 				$parent_srl = $obj->parent_srl;
799 799
 				$document_count = $obj->document_count;
800 800
 				$expand = $obj->expand;
801
-				if($selected) $expand = true;
801
+				if ($selected) $expand = true;
802 802
 
803
-				while($parent_srl)
803
+				while ($parent_srl)
804 804
 				{
805 805
 					$document_category[$parent_srl]->document_count += $document_count;
806 806
 					$document_category[$parent_srl]->childs[] = $obj->category_srl;
807 807
 					$document_category[$parent_srl]->child_count = count($document_category[$parent_srl]->childs);
808
-					if($expand) $document_category[$parent_srl]->expand = $expand;
808
+					if ($expand) $document_category[$parent_srl]->expand = $expand;
809 809
 
810 810
 					$parent_srl = $document_category[$parent_srl]->parent_srl;
811 811
 				}
@@ -813,10 +813,10 @@  discard block
 block discarded – undo
813 813
 
814 814
 			$document_category[$key] = $obj;
815 815
 
816
-			if(count($val['list'])) $this->_arrangeCategory($document_category, $val['list'], $depth+1);
816
+			if (count($val['list'])) $this->_arrangeCategory($document_category, $val['list'], $depth + 1);
817 817
 		}
818 818
 		$document_category[$list_order[0]]->first = true;
819
-		$document_category[$list_order[count($list_order)-1]]->last = true;
819
+		$document_category[$list_order[count($list_order) - 1]]->last = true;
820 820
 	}
821 821
 
822 822
 	/**
@@ -831,7 +831,7 @@  discard block
 block discarded – undo
831 831
 		$args->module_srl = $module_srl;
832 832
 		$args->category_srl = $category_srl;
833 833
 		$output = executeQuery('document.getCategoryDocumentCount', $args);
834
-		return (int)$output->data->count;
834
+		return (int) $output->data->count;
835 835
 	}
836 836
 
837 837
 	/**
@@ -841,8 +841,8 @@  discard block
 block discarded – undo
841 841
 	 */
842 842
 	function getCategoryXmlFile($module_srl)
843 843
 	{
844
-		$xml_file = sprintf('files/cache/document_category/%s.xml.php',$module_srl);
845
-		if(!file_exists($xml_file))
844
+		$xml_file = sprintf('files/cache/document_category/%s.xml.php', $module_srl);
845
+		if (!file_exists($xml_file))
846 846
 		{
847 847
 			$oDocumentController = getController('document');
848 848
 			$oDocumentController->makeCategoryFile($module_srl);
@@ -857,8 +857,8 @@  discard block
 block discarded – undo
857 857
 	 */
858 858
 	function getCategoryPhpFile($module_srl)
859 859
 	{
860
-		$php_file = sprintf('files/cache/document_category/%s.php',$module_srl);
861
-		if(!file_exists($php_file))
860
+		$php_file = sprintf('files/cache/document_category/%s.php', $module_srl);
861
+		if (!file_exists($php_file))
862 862
 		{
863 863
 			$oDocumentController = getController('document');
864 864
 			$oDocumentController->makeCategoryFile($module_srl);
@@ -873,7 +873,7 @@  discard block
 block discarded – undo
873 873
 	 */
874 874
 	function getMonthlyArchivedList($obj)
875 875
 	{
876
-		if($obj->mid)
876
+		if ($obj->mid)
877 877
 		{
878 878
 			$oModuleModel = getModel('module');
879 879
 			$obj->module_srl = $oModuleModel->getModuleSrlByMid($obj->mid);
@@ -881,13 +881,13 @@  discard block
 block discarded – undo
881 881
 		}
882 882
 		// Module_srl passed the array may be a check whether the array
883 883
 		$args = new stdClass;
884
-		if(is_array($obj->module_srl)) $args->module_srl = implode(',', $obj->module_srl);
884
+		if (is_array($obj->module_srl)) $args->module_srl = implode(',', $obj->module_srl);
885 885
 		else $args->module_srl = $obj->module_srl;
886 886
 
887 887
 		$output = executeQuery('document.getMonthlyArchivedList', $args);
888
-		if(!$output->toBool()||!$output->data) return $output;
888
+		if (!$output->toBool() || !$output->data) return $output;
889 889
 
890
-		if(!is_array($output->data)) $output->data = array($output->data);
890
+		if (!is_array($output->data)) $output->data = array($output->data);
891 891
 
892 892
 		return $output;
893 893
 	}
@@ -899,7 +899,7 @@  discard block
 block discarded – undo
899 899
 	 */
900 900
 	function getDailyArchivedList($obj)
901 901
 	{
902
-		if($obj->mid)
902
+		if ($obj->mid)
903 903
 		{
904 904
 			$oModuleModel = getModel('module');
905 905
 			$obj->module_srl = $oModuleModel->getModuleSrlByMid($obj->mid);
@@ -907,14 +907,14 @@  discard block
 block discarded – undo
907 907
 		}
908 908
 		// Module_srl passed the array may be a check whether the array
909 909
 		$args = new stdClass;
910
-		if(is_array($obj->module_srl)) $args->module_srl = implode(',', $obj->module_srl);
910
+		if (is_array($obj->module_srl)) $args->module_srl = implode(',', $obj->module_srl);
911 911
 		else $args->module_srl = $obj->module_srl;
912 912
 		$args->regdate = $obj->regdate;
913 913
 
914 914
 		$output = executeQuery('document.getDailyArchivedList', $args);
915
-		if(!$output->toBool()) return $output;
915
+		if (!$output->toBool()) return $output;
916 916
 
917
-		if(!is_array($output->data)) $output->data = array($output->data);
917
+		if (!is_array($output->data)) $output->data = array($output->data);
918 918
 
919 919
 		return $output;
920 920
 	}
@@ -925,17 +925,17 @@  discard block
 block discarded – undo
925 925
 	 */
926 926
 	function getDocumentCategories()
927 927
 	{
928
-		if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted');
928
+		if (!Context::get('is_logged')) return new Object(-1, 'msg_not_permitted');
929 929
 		$module_srl = Context::get('module_srl');
930
-		$categories= $this->getCategoryList($module_srl);
930
+		$categories = $this->getCategoryList($module_srl);
931 931
 		$lang = Context::get('lang');
932 932
 		// No additional category
933 933
 		$output = "0,0,{$lang->none_category}\n";
934
-		if($categories)
934
+		if ($categories)
935 935
 		{
936
-			foreach($categories as $category_srl => $category)
936
+			foreach ($categories as $category_srl => $category)
937 937
 			{
938
-				$output .= sprintf("%d,%d,%s\n",$category_srl, $category->depth,$category->title);
938
+				$output .= sprintf("%d,%d,%s\n", $category_srl, $category->depth, $category->title);
939 939
 			}
940 940
 		}
941 941
 		$this->add('categories', $output);
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
 	 */
948 948
 	function getDocumentConfig()
949 949
 	{
950
-		if($this->documentConfig === NULL)
950
+		if ($this->documentConfig === NULL)
951 951
 		{
952 952
 			$oModuleModel = getModel('module');
953 953
 			$config = $oModuleModel->getModuleConfig('document');
@@ -1020,11 +1020,11 @@  discard block
 block discarded – undo
1020 1020
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
1021 1021
 		// Check permissions
1022 1022
 		$grant = $oModuleModel->getGrant($module_info, Context::get('logged_info'));
1023
-		if(!$grant->manager) return new Object(-1,'msg_not_permitted');
1023
+		if (!$grant->manager) return new Object(-1, 'msg_not_permitted');
1024 1024
 
1025 1025
 		$category_srl = Context::get('category_srl');
1026 1026
 		$category_info = $this->getCategory($category_srl);
1027
-		if(!$category_info)
1027
+		if (!$category_info)
1028 1028
 		{
1029 1029
 			return new Object(-1, 'msg_invalid_request');
1030 1030
 		}
@@ -1040,14 +1040,14 @@  discard block
 block discarded – undo
1040 1040
 	 */
1041 1041
 	function getDocumentSrlByAlias($mid, $alias)
1042 1042
 	{
1043
-		if(!$mid || !$alias) return null;
1043
+		if (!$mid || !$alias) return null;
1044 1044
 		$site_module_info = Context::get('site_module_info');
1045 1045
 		$args = new stdClass;
1046 1046
 		$args->mid = $mid;
1047 1047
 		$args->alias_title = $alias;
1048 1048
 		$args->site_srl = $site_module_info->site_srl;
1049 1049
 		$output = executeQuery('document.getDocumentSrlByAlias', $args);
1050
-		if(!$output->data) return null;
1050
+		if (!$output->data) return null;
1051 1051
 		else return $output->data->document_srl;
1052 1052
 	}
1053 1053
 
@@ -1059,15 +1059,15 @@  discard block
 block discarded – undo
1059 1059
 	 */
1060 1060
 	function getDocumentSrlByTitle($module_srl, $title)
1061 1061
 	{
1062
-		if(!$module_srl || !$title) return null;
1062
+		if (!$module_srl || !$title) return null;
1063 1063
 		$args = new stdClass;
1064 1064
 		$args->module_srl = $module_srl;
1065 1065
 		$args->title = $title;
1066 1066
 		$output = executeQuery('document.getDocumentSrlByTitle', $args);
1067
-		if(!$output->data) return null;
1067
+		if (!$output->data) return null;
1068 1068
 		else
1069 1069
 		{
1070
-			if(is_array($output->data)) return $output->data[0]->document_srl;
1070
+			if (is_array($output->data)) return $output->data[0]->document_srl;
1071 1071
 			return $output->data->document_srl;
1072 1072
 		}
1073 1073
 	}
@@ -1079,12 +1079,12 @@  discard block
 block discarded – undo
1079 1079
 	 */
1080 1080
 	function getAlias($document_srl)
1081 1081
 	{
1082
-		if(!$document_srl) return null;
1082
+		if (!$document_srl) return null;
1083 1083
 		$args = new stdClass;
1084 1084
 		$args->document_srl = $document_srl;
1085 1085
 		$output = executeQueryArray('document.getAliases', $args);
1086 1086
 
1087
-		if(!$output->data) return null;
1087
+		if (!$output->data) return null;
1088 1088
 		else return $output->data[0]->alias_title;
1089 1089
 	}
1090 1090
 
@@ -1127,32 +1127,32 @@  discard block
 block discarded – undo
1127 1127
 	{
1128 1128
 		// Variable check
1129 1129
 		$args = new stdClass;
1130
-		$args->category_srl = $obj->category_srl?$obj->category_srl:null;
1130
+		$args->category_srl = $obj->category_srl ? $obj->category_srl : null;
1131 1131
 		$args->sort_index = $obj->sort_index;
1132
-		$args->order_type = $obj->order_type?$obj->order_type:'desc';
1133
-		$args->page = $obj->page?$obj->page:1;
1134
-		$args->list_count = $obj->list_count?$obj->list_count:20;
1135
-		$args->page_count = $obj->page_count?$obj->page_count:10;
1132
+		$args->order_type = $obj->order_type ? $obj->order_type : 'desc';
1133
+		$args->page = $obj->page ? $obj->page : 1;
1134
+		$args->list_count = $obj->list_count ? $obj->list_count : 20;
1135
+		$args->page_count = $obj->page_count ? $obj->page_count : 10;
1136 1136
 		// Search options
1137 1137
 		$search_target = $obj->search_target;
1138 1138
 		$search_keyword = $obj->search_keyword;
1139
-		if($search_target && $search_keyword)
1139
+		if ($search_target && $search_keyword)
1140 1140
 		{
1141
-			switch($search_target)
1141
+			switch ($search_target)
1142 1142
 			{
1143 1143
 				case 'title' :
1144 1144
 				case 'content' :
1145
-					if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword);
1145
+					if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword);
1146 1146
 					$args->{"s_".$search_target} = $search_keyword;
1147 1147
 					$use_division = true;
1148 1148
 					break;
1149 1149
 				case 'title_content' :
1150
-					if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword);
1150
+					if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword);
1151 1151
 					$args->s_title = $search_keyword;
1152 1152
 					$args->s_content = $search_keyword;
1153 1153
 					break;
1154 1154
 				case 'user_id' :
1155
-					if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword);
1155
+					if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword);
1156 1156
 					$args->s_user_id = $search_keyword;
1157 1157
 					$args->sort_index = 'documents.'.$args->sort_index;
1158 1158
 					break;
@@ -1160,13 +1160,13 @@  discard block
 block discarded – undo
1160 1160
 				case 'nick_name' :
1161 1161
 				case 'email_address' :
1162 1162
 				case 'homepage' :
1163
-					if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword);
1163
+					if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword);
1164 1164
 					$args->{"s_".$search_target} = $search_keyword;
1165 1165
 					break;
1166 1166
 				case 'is_notice' :
1167 1167
 				case 'is_secret' :
1168
-					if($search_keyword=='N') $args->statusList = array($this->getConfigStatus('public'));
1169
-					elseif($search_keyword=='Y') $args->statusList = array($this->getConfigStatus('secret'));
1168
+					if ($search_keyword == 'N') $args->statusList = array($this->getConfigStatus('public'));
1169
+					elseif ($search_keyword == 'Y') $args->statusList = array($this->getConfigStatus('secret'));
1170 1170
 					break;
1171 1171
 				case 'member_srl' :
1172 1172
 				case 'readed_count' :
@@ -1175,7 +1175,7 @@  discard block
 block discarded – undo
1175 1175
 				case 'comment_count' :
1176 1176
 				case 'trackback_count' :
1177 1177
 				case 'uploaded_count' :
1178
-					$args->{"s_".$search_target} = (int)$search_keyword;
1178
+					$args->{"s_".$search_target} = (int) $search_keyword;
1179 1179
 					break;
1180 1180
 				case 'regdate' :
1181 1181
 				case 'last_update' :
@@ -1187,9 +1187,9 @@  discard block
 block discarded – undo
1187 1187
 		}
1188 1188
 
1189 1189
 		$output = executeQueryArray('document.getTrashList', $args);
1190
-		if($output->data)
1190
+		if ($output->data)
1191 1191
 		{
1192
-			foreach($output->data as $key => $attribute)
1192
+			foreach ($output->data as $key => $attribute)
1193 1193
 			{
1194 1194
 				$oDocument = null;
1195 1195
 				$oDocument = new documentItem();
@@ -1208,46 +1208,46 @@  discard block
 block discarded – undo
1208 1208
 	{
1209 1209
 		$args = new stdClass;
1210 1210
 		$document_srl = Context::get('document_srl');
1211
-		if(!$document_srl) return new Object(-1,'msg_invalid_request');
1211
+		if (!$document_srl) return new Object(-1, 'msg_invalid_request');
1212 1212
 
1213 1213
 		$point = Context::get('point');
1214
-		if($point != -1) $point = 1;
1214
+		if ($point != -1) $point = 1;
1215 1215
 
1216 1216
 		$oDocumentModel = getModel('document');
1217 1217
 		$columnList = array('document_srl', 'module_srl');
1218 1218
 		$oDocument = $oDocumentModel->getDocument($document_srl, false, false, $columnList);
1219 1219
 		$module_srl = $oDocument->get('module_srl');
1220
-		if(!$module_srl) return new Object(-1, 'msg_invalid_request');
1220
+		if (!$module_srl) return new Object(-1, 'msg_invalid_request');
1221 1221
 
1222 1222
 		$oModuleModel = getModel('module');
1223
-		$document_config = $oModuleModel->getModulePartConfig('document',$module_srl);
1224
-		if($point == -1)
1223
+		$document_config = $oModuleModel->getModulePartConfig('document', $module_srl);
1224
+		if ($point == -1)
1225 1225
 		{
1226
-			if($document_config->use_vote_down!='S') return new Object(-1, 'msg_invalid_request');
1226
+			if ($document_config->use_vote_down != 'S') return new Object(-1, 'msg_invalid_request');
1227 1227
 			$args->below_point = 0;
1228 1228
 		}
1229 1229
 		else
1230 1230
 		{
1231
-			if($document_config->use_vote_up!='S') return new Object(-1, 'msg_invalid_request');
1231
+			if ($document_config->use_vote_up != 'S') return new Object(-1, 'msg_invalid_request');
1232 1232
 			$args->more_point = 0;
1233 1233
 		}
1234 1234
 
1235 1235
 		$args->document_srl = $document_srl;
1236 1236
 
1237
-		$output = executeQueryArray('document.getVotedMemberList',$args);
1238
-		if(!$output->toBool()) return $output;
1237
+		$output = executeQueryArray('document.getVotedMemberList', $args);
1238
+		if (!$output->toBool()) return $output;
1239 1239
 
1240 1240
 		$oMemberModel = getModel('member');
1241
-		if($output->data)
1241
+		if ($output->data)
1242 1242
 		{
1243
-			foreach($output->data as $k => $d)
1243
+			foreach ($output->data as $k => $d)
1244 1244
 			{
1245 1245
 				$profile_image = $oMemberModel->getProfileImage($d->member_srl);
1246 1246
 				$output->data[$k]->src = $profile_image->src;
1247 1247
 			}
1248 1248
 		}
1249 1249
 
1250
-		$this->add('voted_member_list',$output->data);
1250
+		$this->add('voted_member_list', $output->data);
1251 1251
 	}
1252 1252
 
1253 1253
 	/**
@@ -1257,7 +1257,7 @@  discard block
 block discarded – undo
1257 1257
 	function getStatusNameList()
1258 1258
 	{
1259 1259
 		global $lang;
1260
-		if(!isset($lang->status_name_list))
1260
+		if (!isset($lang->status_name_list))
1261 1261
 			return array_flip($this->getStatusList());
1262 1262
 		else return $lang->status_name_list;
1263 1263
 	}
@@ -1272,7 +1272,7 @@  discard block
 block discarded – undo
1272 1272
 	{
1273 1273
 		$sortIndex = $obj->sort_index;
1274 1274
 		$isExtraVars = false;
1275
-		if(!in_array($sortIndex, array('list_order','regdate','last_update','update_order','readed_count','voted_count','blamed_count','comment_count','trackback_count','uploaded_count','title','category_srl')))
1275
+		if (!in_array($sortIndex, array('list_order', 'regdate', 'last_update', 'update_order', 'readed_count', 'voted_count', 'blamed_count', 'comment_count', 'trackback_count', 'uploaded_count', 'title', 'category_srl')))
1276 1276
 		{
1277 1277
 			// get module_srl extra_vars list
1278 1278
 			if ($load_extra_vars)
@@ -1287,11 +1287,11 @@  discard block
 block discarded – undo
1287 1287
 				else
1288 1288
 				{
1289 1289
 					$check_array = array();
1290
-					foreach($extra_output->data as $val)
1290
+					foreach ($extra_output->data as $val)
1291 1291
 					{
1292 1292
 						$check_array[] = $val->eid;
1293 1293
 					}
1294
-					if(!in_array($sortIndex, $check_array)) $sortIndex = 'list_order';
1294
+					if (!in_array($sortIndex, $check_array)) $sortIndex = 'list_order';
1295 1295
 					else $isExtraVars = true;
1296 1296
 				}
1297 1297
 			}
@@ -1319,13 +1319,13 @@  discard block
 block discarded – undo
1319 1319
 	{
1320 1320
 		// Variable check
1321 1321
 		$args = new stdClass();
1322
-		$args->category_srl = $searchOpt->category_srl?$searchOpt->category_srl:null;
1322
+		$args->category_srl = $searchOpt->category_srl ? $searchOpt->category_srl : null;
1323 1323
 		$args->order_type = $searchOpt->order_type;
1324
-		$args->page = $searchOpt->page?$searchOpt->page:1;
1325
-		$args->list_count = $searchOpt->list_count?$searchOpt->list_count:20;
1326
-		$args->page_count = $searchOpt->page_count?$searchOpt->page_count:10;
1327
-		$args->start_date = $searchOpt->start_date?$searchOpt->start_date:null;
1328
-		$args->end_date = $searchOpt->end_date?$searchOpt->end_date:null;
1324
+		$args->page = $searchOpt->page ? $searchOpt->page : 1;
1325
+		$args->list_count = $searchOpt->list_count ? $searchOpt->list_count : 20;
1326
+		$args->page_count = $searchOpt->page_count ? $searchOpt->page_count : 10;
1327
+		$args->start_date = $searchOpt->start_date ? $searchOpt->start_date : null;
1328
+		$args->end_date = $searchOpt->end_date ? $searchOpt->end_date : null;
1329 1329
 		$args->member_srl = $searchOpt->member_srl;
1330 1330
 
1331 1331
 		$logged_info = Context::get('logged_info');
@@ -1334,10 +1334,10 @@  discard block
 block discarded – undo
1334 1334
 
1335 1335
 		// Check the target and sequence alignment
1336 1336
 		$orderType = array('desc' => 1, 'asc' => 1);
1337
-		if(!isset($orderType[$args->order_type])) $args->order_type = 'asc';
1337
+		if (!isset($orderType[$args->order_type])) $args->order_type = 'asc';
1338 1338
 
1339 1339
 		// If that came across mid module_srl instead of a direct module_srl guhaejum
1340
-		if($searchOpt->mid)
1340
+		if ($searchOpt->mid)
1341 1341
 		{
1342 1342
 			$oModuleModel = getModel('module');
1343 1343
 			$args->module_srl = $oModuleModel->getModuleSrlByMid($obj->mid);
@@ -1345,30 +1345,30 @@  discard block
 block discarded – undo
1345 1345
 		}
1346 1346
 
1347 1347
 		// Module_srl passed the array may be a check whether the array
1348
-		if(is_array($searchOpt->module_srl)) $args->module_srl = implode(',', $searchOpt->module_srl);
1348
+		if (is_array($searchOpt->module_srl)) $args->module_srl = implode(',', $searchOpt->module_srl);
1349 1349
 		else $args->module_srl = $searchOpt->module_srl;
1350 1350
 
1351 1351
 		// Except for the test module_srl
1352
-		if(is_array($searchOpt->exclude_module_srl)) $args->exclude_module_srl = implode(',', $searchOpt->exclude_module_srl);
1352
+		if (is_array($searchOpt->exclude_module_srl)) $args->exclude_module_srl = implode(',', $searchOpt->exclude_module_srl);
1353 1353
 		else $args->exclude_module_srl = $searchOpt->exclude_module_srl;
1354 1354
 
1355 1355
 		// only admin document list, temp document showing
1356
-		if($searchOpt->statusList) $args->statusList = $searchOpt->statusList;
1356
+		if ($searchOpt->statusList) $args->statusList = $searchOpt->statusList;
1357 1357
 		else
1358 1358
 		{
1359
-			if($logged_info->is_admin == 'Y' && !$searchOpt->module_srl)
1359
+			if ($logged_info->is_admin == 'Y' && !$searchOpt->module_srl)
1360 1360
 				$args->statusList = array($this->getConfigStatus('secret'), $this->getConfigStatus('public'), $this->getConfigStatus('temp'));
1361 1361
 			else
1362 1362
 				$args->statusList = array($this->getConfigStatus('secret'), $this->getConfigStatus('public'));
1363 1363
 		}
1364 1364
 
1365 1365
 		// Category is selected, further sub-categories until all conditions
1366
-		if($args->category_srl)
1366
+		if ($args->category_srl)
1367 1367
 		{
1368 1368
 			$category_list = $this->getCategoryList($args->module_srl);
1369 1369
 			$category_info = $category_list[$args->category_srl];
1370 1370
 			$category_info->childs[] = $args->category_srl;
1371
-			$args->category_srl = implode(',',$category_info->childs);
1371
+			$args->category_srl = implode(',', $category_info->childs);
1372 1372
 		}
1373 1373
 
1374 1374
 		// Used to specify the default query id (based on several search options to query id modified)
@@ -1381,24 +1381,24 @@  discard block
 block discarded – undo
1381 1381
 		$search_target = $searchOpt->search_target;
1382 1382
 		$search_keyword = $searchOpt->search_keyword;
1383 1383
 
1384
-		if($search_target && $search_keyword)
1384
+		if ($search_target && $search_keyword)
1385 1385
 		{
1386
-			switch($search_target)
1386
+			switch ($search_target)
1387 1387
 			{
1388 1388
 				case 'title' :
1389 1389
 				case 'content' :
1390
-					if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword);
1390
+					if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword);
1391 1391
 					$args->{"s_".$search_target} = $search_keyword;
1392 1392
 					$use_division = true;
1393 1393
 					break;
1394 1394
 				case 'title_content' :
1395
-					if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword);
1395
+					if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword);
1396 1396
 					$args->s_title = $search_keyword;
1397 1397
 					$args->s_content = $search_keyword;
1398 1398
 					$use_division = true;
1399 1399
 					break;
1400 1400
 				case 'user_id' :
1401
-					if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword);
1401
+					if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword);
1402 1402
 					$args->s_user_id = $search_keyword;
1403 1403
 					$args->sort_index = 'documents.'.$args->sort_index;
1404 1404
 					break;
@@ -1406,18 +1406,18 @@  discard block
 block discarded – undo
1406 1406
 				case 'nick_name' :
1407 1407
 				case 'email_address' :
1408 1408
 				case 'homepage' :
1409
-					if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword);
1409
+					if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword);
1410 1410
 					$args->{"s_".$search_target} = $search_keyword;
1411 1411
 					break;
1412 1412
 				case 'is_notice' :
1413
-					if($search_keyword=='N') $args->{"s_".$search_target} = 'N';
1414
-					elseif($search_keyword=='Y') $args->{"s_".$search_target} = 'Y';
1413
+					if ($search_keyword == 'N') $args->{"s_".$search_target} = 'N';
1414
+					elseif ($search_keyword == 'Y') $args->{"s_".$search_target} = 'Y';
1415 1415
 					else $args->{"s_".$search_target} = '';
1416 1416
 					break;
1417 1417
 				case 'is_secret' :
1418
-					if($search_keyword=='N') $args->statusList = array($this->getConfigStatus('public'));
1419
-					elseif($search_keyword=='Y') $args->statusList = array($this->getConfigStatus('secret'));
1420
-					elseif($search_keyword=='temp') $args->statusList = array($this->getConfigStatus('temp'));
1418
+					if ($search_keyword == 'N') $args->statusList = array($this->getConfigStatus('public'));
1419
+					elseif ($search_keyword == 'Y') $args->statusList = array($this->getConfigStatus('secret'));
1420
+					elseif ($search_keyword == 'temp') $args->statusList = array($this->getConfigStatus('temp'));
1421 1421
 					break;
1422 1422
 				case 'member_srl' :
1423 1423
 				case 'readed_count' :
@@ -1425,10 +1425,10 @@  discard block
 block discarded – undo
1425 1425
 				case 'comment_count' :
1426 1426
 				case 'trackback_count' :
1427 1427
 				case 'uploaded_count' :
1428
-					$args->{"s_".$search_target} = (int)$search_keyword;
1428
+					$args->{"s_".$search_target} = (int) $search_keyword;
1429 1429
 					break;
1430 1430
 				case 'blamed_count' :
1431
-					$args->{"s_".$search_target} = (int)$search_keyword * -1;
1431
+					$args->{"s_".$search_target} = (int) $search_keyword * -1;
1432 1432
 					break;
1433 1433
 				case 'regdate' :
1434 1434
 				case 'last_update' :
@@ -1441,7 +1441,7 @@  discard block
 block discarded – undo
1441 1441
 					$use_division = true;
1442 1442
 					break;
1443 1443
 				case 'tag' :
1444
-					$args->s_tags = str_replace(' ','%',$search_keyword);
1444
+					$args->s_tags = str_replace(' ', '%', $search_keyword);
1445 1445
 					$query_id = 'document.getDocumentListWithinTag';
1446 1446
 					break;
1447 1447
 				case 'extra_vars':
@@ -1449,9 +1449,9 @@  discard block
 block discarded – undo
1449 1449
 					$query_id = 'document.getDocumentListWithinExtraVars';
1450 1450
 					break;
1451 1451
 				default :
1452
-					if(strpos($search_target,'extra_vars')!==false) {
1452
+					if (strpos($search_target, 'extra_vars') !== false) {
1453 1453
 						$args->var_idx = substr($search_target, strlen('extra_vars'));
1454
-						$args->var_value = str_replace(' ','%',$search_keyword);
1454
+						$args->var_value = str_replace(' ', '%', $search_keyword);
1455 1455
 						$args->sort_index = 'documents.'.$args->sort_index;
1456 1456
 						$query_id = 'document.getDocumentListWithExtraVars';
1457 1457
 					}
@@ -1468,18 +1468,18 @@  discard block
 block discarded – undo
1468 1468
 			/**
1469 1469
 			 * list_order asc sort of division that can be used only when
1470 1470
 			 */
1471
-			if($args->sort_index != 'list_order' || $args->order_type != 'asc') $use_division = false;
1471
+			if ($args->sort_index != 'list_order' || $args->order_type != 'asc') $use_division = false;
1472 1472
 
1473 1473
 			/**
1474 1474
 			 * If it is true, use_division changed to use the document division
1475 1475
 			 */
1476
-			if($use_division)
1476
+			if ($use_division)
1477 1477
 			{
1478 1478
 				// Division begins
1479
-				$division = (int)Context::get('division');
1479
+				$division = (int) Context::get('division');
1480 1480
 
1481 1481
 				// order by list_order and (module_srl===0 or module_srl may count), therefore case table full scan
1482
-				if($args->sort_index == 'list_order' && ($args->exclude_module_srl === '0' || count(explode(',', $args->module_srl)) > 5))
1482
+				if ($args->sort_index == 'list_order' && ($args->exclude_module_srl === '0' || count(explode(',', $args->module_srl)) > 5))
1483 1483
 				{
1484 1484
 					$listSqlID = 'document.getDocumentListUseIndex';
1485 1485
 					$divisionSqlID = 'document.getDocumentDivisionUseIndex';
@@ -1491,7 +1491,7 @@  discard block
 block discarded – undo
1491 1491
 				}
1492 1492
 
1493 1493
 				// If you do not value the best division top
1494
-				if(!$division)
1494
+				if (!$division)
1495 1495
 				{
1496 1496
 					$division_args = new stdClass();
1497 1497
 					$division_args->module_srl = $args->module_srl;
@@ -1502,7 +1502,7 @@  discard block
 block discarded – undo
1502 1502
 					$division_args->statusList = $args->statusList;
1503 1503
 
1504 1504
 					$output = executeQuery($divisionSqlID, $division_args, array('list_order'));
1505
-					if($output->data)
1505
+					if ($output->data)
1506 1506
 					{
1507 1507
 						$item = array_pop($output->data);
1508 1508
 						$division = $item->list_order;
@@ -1511,10 +1511,10 @@  discard block
 block discarded – undo
1511 1511
 				}
1512 1512
 
1513 1513
 				// The last division
1514
-				$last_division = (int)Context::get('last_division');
1514
+				$last_division = (int) Context::get('last_division');
1515 1515
 
1516 1516
 				// Division after division from the 5000 value of the specified Wanted
1517
-				if(!$last_division)
1517
+				if (!$last_division)
1518 1518
 				{
1519 1519
 					$last_division_args = new stdClass();
1520 1520
 					$last_division_args->module_srl = $args->module_srl;
@@ -1526,7 +1526,7 @@  discard block
 block discarded – undo
1526 1526
 					$last_division_args->page = 5001;
1527 1527
 
1528 1528
 					$output = executeQuery($divisionSqlID, $last_division_args, array('list_order'));
1529
-					if($output->data)
1529
+					if ($output->data)
1530 1530
 					{
1531 1531
 						$item = array_pop($output->data);
1532 1532
 						$last_division = $item->list_order;
@@ -1534,14 +1534,14 @@  discard block
 block discarded – undo
1534 1534
 				}
1535 1535
 
1536 1536
 				// Make sure that after last_division article
1537
-				if($last_division)
1537
+				if ($last_division)
1538 1538
 				{
1539 1539
 					$last_division_args = new stdClass();
1540 1540
 					$last_division_args->module_srl = $args->module_srl;
1541 1541
 					$last_division_args->exclude_module_srl = $args->exclude_module_srl;
1542 1542
 					$last_division_args->list_order = $last_division;
1543 1543
 					$output = executeQuery('document.getDocumentDivisionCount', $last_division_args);
1544
-					if($output->data->count<1) $last_division = null;
1544
+					if ($output->data->count < 1) $last_division = null;
1545 1545
 				}
1546 1546
 
1547 1547
 				$args->division = $division;
@@ -1574,7 +1574,7 @@  discard block
 block discarded – undo
1574 1574
 	 * @param int $count
1575 1575
 	 * @return object
1576 1576
 	 */
1577
-	function getDocumentListByMemberSrl($member_srl, $columnList = array(), $page = 0, $is_admin = FALSE, $count = 0 )
1577
+	function getDocumentListByMemberSrl($member_srl, $columnList = array(), $page = 0, $is_admin = FALSE, $count = 0)
1578 1578
 	{
1579 1579
 		$args = new stdClass();
1580 1580
 		$args->member_srl = $member_srl;
@@ -1582,8 +1582,8 @@  discard block
 block discarded – undo
1582 1582
 		$output = executeQuery('document.getDocumentListByMemberSrl', $args, $columnList);
1583 1583
 		$document_list = $output->data;
1584 1584
 
1585
-		if(!$document_list) return array();
1586
-		if(!is_array($document_list)) $document_list = array($document_list);
1585
+		if (!$document_list) return array();
1586
+		if (!is_array($document_list)) $document_list = array($document_list);
1587 1587
 
1588 1588
 		return $document_list;
1589 1589
 	}
@@ -1591,7 +1591,7 @@  discard block
 block discarded – undo
1591 1591
 	function getDocumentExtraImagePath()
1592 1592
 	{
1593 1593
 		$documentConfig = getModel('document')->getDocumentConfig();
1594
-		if(Mobile::isFromMobilePhone())
1594
+		if (Mobile::isFromMobilePhone())
1595 1595
 		{
1596 1596
 			$iconSkin = $documentConfig->micons;
1597 1597
 		}
@@ -1599,7 +1599,7 @@  discard block
 block discarded – undo
1599 1599
 		{
1600 1600
 			$iconSkin = $documentConfig->icons;
1601 1601
 		}
1602
-		$path = sprintf('%s%s',getUrl(), "modules/document/tpl/icons/$iconSkin/");
1602
+		$path = sprintf('%s%s', getUrl(), "modules/document/tpl/icons/$iconSkin/");
1603 1603
 
1604 1604
 		return $path;
1605 1605
 	}
Please login to merge, or discard this patch.
Braces   +300 added lines, -139 removed lines patch added patch discarded remove patch
@@ -58,18 +58,24 @@  discard block
 block discarded – undo
58 58
 		$_document_list = &$GLOBALS['XE_DOCUMENT_LIST'];
59 59
 
60 60
 		// XE XE_DOCUMENT_LIST all documents that the object referred to the global variable settings
61
-		if(count($_document_list) <= 0) return;
61
+		if(count($_document_list) <= 0) {
62
+			return;
63
+		}
62 64
 
63 65
 		// Find all called the document object variable has been set extension
64 66
 		$document_srls = array();
65 67
 		foreach($_document_list as $key => $val)
66 68
 		{
67
-			if(!$val->document_srl || $checked_documents[$val->document_srl]) continue;
69
+			if(!$val->document_srl || $checked_documents[$val->document_srl]) {
70
+				continue;
71
+			}
68 72
 			$checked_documents[$val->document_srl] = true;
69 73
 			$document_srls[] = $val->document_srl;
70 74
 		}
71 75
 		// If the document number, return detected
72
-		if(!count($document_srls)) return;
76
+		if(!count($document_srls)) {
77
+			return;
78
+		}
73 79
 		// Expand variables mijijeongdoen article about a current visitor to the extension of the language code, the search variable
74 80
 		//$obj->document_srl = implode(',',$document_srls);
75 81
 		$output = $this->getDocumentExtraVarsFromDB($document_srls);
@@ -77,8 +83,12 @@  discard block
 block discarded – undo
77 83
 		{
78 84
 			foreach($output->data as $key => $val)
79 85
 			{
80
-				if(!isset($val->value)) continue;
81
-				if(!$extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0]) $extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0] = trim($val->value);
86
+				if(!isset($val->value)) {
87
+					continue;
88
+				}
89
+				if(!$extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0]) {
90
+					$extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0] = trim($val->value);
91
+				}
82 92
 				$extra_vars[$val->document_srl][$val->var_idx][$val->lang_code] = trim($val->value);
83 93
 			}
84 94
 		}
@@ -89,7 +99,9 @@  discard block
 block discarded – undo
89 99
 			$document_srl = $document_srls[$i];
90 100
 			unset($vars);
91 101
 
92
-			if(!$_document_list[$document_srl] || !is_object($_document_list[$document_srl]) || !$_document_list[$document_srl]->isExists()) continue;
102
+			if(!$_document_list[$document_srl] || !is_object($_document_list[$document_srl]) || !$_document_list[$document_srl]->isExists()) {
103
+				continue;
104
+			}
93 105
 			$module_srl = $_document_list[$document_srl]->get('module_srl');
94 106
 			$extra_keys = $this->getExtraKeys($module_srl);
95 107
 			$vars = $extra_vars[$document_srl];
@@ -101,10 +113,15 @@  discard block
 block discarded – undo
101 113
 				{
102 114
 					$extra_keys[$idx] = clone($key);
103 115
 					$val = $vars[$idx];
104
-					if(isset($val[$user_lang_code])) $v = $val[$user_lang_code];
105
-					else if(isset($val[$document_lang_code])) $v = $val[$document_lang_code];
106
-					else if(isset($val[0])) $v = $val[0];
107
-					else $v = null;
116
+					if(isset($val[$user_lang_code])) {
117
+						$v = $val[$user_lang_code];
118
+					} else if(isset($val[$document_lang_code])) {
119
+						$v = $val[$document_lang_code];
120
+					} else if(isset($val[0])) {
121
+						$v = $val[0];
122
+					} else {
123
+						$v = null;
124
+					}
108 125
 					$extra_keys[$idx]->value = $v;
109 126
 				}
110 127
 			}
@@ -113,9 +130,13 @@  discard block
 block discarded – undo
113 130
 			$evars = new ExtraVar($module_srl);
114 131
 			$evars->setExtraVarKeys($extra_keys);
115 132
 			// Title Processing
116
-			if($vars[-1][$user_lang_code]) $_document_list[$document_srl]->add('title',$vars[-1][$user_lang_code]);
133
+			if($vars[-1][$user_lang_code]) {
134
+				$_document_list[$document_srl]->add('title',$vars[-1][$user_lang_code]);
135
+			}
117 136
 			// Information processing
118
-			if($vars[-2][$user_lang_code]) $_document_list[$document_srl]->add('content',$vars[-2][$user_lang_code]);
137
+			if($vars[-2][$user_lang_code]) {
138
+				$_document_list[$document_srl]->add('content',$vars[-2][$user_lang_code]);
139
+			}
119 140
 
120 141
 			if($vars[-1][$user_lang_code] || $vars[-2][$user_lang_code])
121 142
 			{
@@ -136,15 +157,21 @@  discard block
 block discarded – undo
136 157
 	 */
137 158
 	function getDocument($document_srl=0, $is_admin = false, $load_extra_vars=true, $columnList = array())
138 159
 	{
139
-		if(!$document_srl) return new documentItem();
160
+		if(!$document_srl) {
161
+			return new documentItem();
162
+		}
140 163
 
141 164
 		if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl])
142 165
 		{
143 166
 			$oDocument = new documentItem($document_srl, $load_extra_vars, $columnList);
144 167
 			$GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument;
145
-			if($load_extra_vars) $this->setToAllDocumentExtraVars();
168
+			if($load_extra_vars) {
169
+				$this->setToAllDocumentExtraVars();
170
+			}
171
+		}
172
+		if($is_admin) {
173
+			$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]->setGrant();
146 174
 		}
147
-		if($is_admin) $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]->setGrant();
148 175
 
149 176
 		return $GLOBALS['XE_DOCUMENT_LIST'][$document_srl];
150 177
 	}
@@ -163,8 +190,7 @@  discard block
 block discarded – undo
163 190
 		{
164 191
 			$list_count = count($document_srls);
165 192
 			$document_srls = implode(',',$document_srls);
166
-		}
167
-		else
193
+		} else
168 194
 		{
169 195
 			$list_count = 1;
170 196
 		}
@@ -175,28 +201,38 @@  discard block
 block discarded – undo
175 201
 
176 202
 		$output = executeQuery('document.getDocuments', $args, $columnList);
177 203
 		$document_list = $output->data;
178
-		if(!$document_list) return;
179
-		if(!is_array($document_list)) $document_list = array($document_list);
204
+		if(!$document_list) {
205
+			return;
206
+		}
207
+		if(!is_array($document_list)) {
208
+			$document_list = array($document_list);
209
+		}
180 210
 
181 211
 		$document_count = count($document_list);
182 212
 		foreach($document_list as $key => $attribute)
183 213
 		{
184 214
 			$document_srl = $attribute->document_srl;
185
-			if(!$document_srl) continue;
215
+			if(!$document_srl) {
216
+				continue;
217
+			}
186 218
 
187 219
 			if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl])
188 220
 			{
189 221
 				$oDocument = null;
190 222
 				$oDocument = new documentItem();
191 223
 				$oDocument->setAttribute($attribute, false);
192
-				if($is_admin) $oDocument->setGrant();
224
+				if($is_admin) {
225
+					$oDocument->setGrant();
226
+				}
193 227
 				$GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument;
194 228
 			}
195 229
 
196 230
 			$result[$attribute->document_srl] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl];
197 231
 		}
198 232
 
199
-		if($load_extra_vars) $this->setToAllDocumentExtraVars();
233
+		if($load_extra_vars) {
234
+			$this->setToAllDocumentExtraVars();
235
+		}
200 236
 
201 237
 		$output = null;
202 238
 		if(count($result))
@@ -244,18 +280,15 @@  discard block
 block discarded – undo
244 280
 		{
245 281
 			$output = $obj->use_alternate_output;
246 282
 			unset($obj->use_alternate_output);
247
-		}
248
-		elseif ($sort_check->isExtraVars && substr_count($obj->search_target,'extra_vars'))
283
+		} elseif ($sort_check->isExtraVars && substr_count($obj->search_target,'extra_vars'))
249 284
 		{
250 285
 			$query_id = 'document.getDocumentListWithinExtraVarsExtraSort';
251 286
 			$args->sort_index = str_replace('documents.','',$args->sort_index);
252 287
 			$output = executeQueryArray($query_id, $args);
253
-		}
254
-		elseif ($sort_check->isExtraVars)
288
+		} elseif ($sort_check->isExtraVars)
255 289
 		{
256 290
 			$output = executeQueryArray($query_id, $args);
257
-		}
258
-		else
291
+		} else
259 292
 		{
260 293
 			// document.getDocumentList query execution
261 294
 			// Query_id if you have a group by clause getDocumentListWithinTag getDocumentListWithinComment or used again to perform the query because
@@ -265,11 +298,15 @@  discard block
 block discarded – undo
265 298
 				$group_args = clone($args);
266 299
 				$group_args->sort_index = 'documents.'.$args->sort_index;
267 300
 				$output = executeQueryArray($query_id, $group_args);
268
-				if(!$output->toBool()||!count($output->data)) return $output;
301
+				if(!$output->toBool()||!count($output->data)) {
302
+					return $output;
303
+				}
269 304
 
270 305
 				foreach($output->data as $key => $val)
271 306
 				{
272
-					if($val->document_srl) $target_srls[] = $val->document_srl;
307
+					if($val->document_srl) {
308
+						$target_srls[] = $val->document_srl;
309
+					}
273 310
 				}
274 311
 
275 312
 				$page_navigation = $output->page_navigation;
@@ -287,14 +324,15 @@  discard block
 block discarded – undo
287 324
 				$output->total_count = $page_navigation->total_count;
288 325
 				$output->total_page = $page_navigation->total_page;
289 326
 				$output->page = $page_navigation->cur_page;
290
-			}
291
-			else
327
+			} else
292 328
 			{
293 329
 				$output = executeQueryArray($query_id, $args, $columnList);
294 330
 			}
295 331
 		}
296 332
 		// Return if no result or an error occurs
297
-		if(!$output->toBool()||!count($output->data)) return $output;
333
+		if(!$output->toBool()||!count($output->data)) {
334
+			return $output;
335
+		}
298 336
 		$idx = 0;
299 337
 		$data = $output->data;
300 338
 		unset($output->data);
@@ -309,20 +347,26 @@  discard block
 block discarded – undo
309 347
 		{
310 348
 			foreach($data as $key => $attribute)
311 349
 			{
312
-				if($attribute->is_notice == 'Y') $virtual_number --;
350
+				if($attribute->is_notice == 'Y') {
351
+					$virtual_number --;
352
+				}
313 353
 			}
314 354
 		}
315 355
 
316 356
 		foreach($data as $key => $attribute)
317 357
 		{
318
-			if($except_notice && $attribute->is_notice == 'Y') continue;
358
+			if($except_notice && $attribute->is_notice == 'Y') {
359
+				continue;
360
+			}
319 361
 			$document_srl = $attribute->document_srl;
320 362
 			if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl])
321 363
 			{
322 364
 				$oDocument = null;
323 365
 				$oDocument = new documentItem();
324 366
 				$oDocument->setAttribute($attribute, false);
325
-				if($is_admin) $oDocument->setGrant();
367
+				if($is_admin) {
368
+					$oDocument->setGrant();
369
+				}
326 370
 				$GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument;
327 371
 			}
328 372
 
@@ -330,7 +374,9 @@  discard block
 block discarded – undo
330 374
 			$virtual_number--;
331 375
 		}
332 376
 
333
-		if($load_extra_vars) $this->setToAllDocumentExtraVars();
377
+		if($load_extra_vars) {
378
+			$this->setToAllDocumentExtraVars();
379
+		}
334 380
 
335 381
 		if(count($output->data))
336 382
 		{
@@ -358,12 +404,16 @@  discard block
 block discarded – undo
358 404
 		$args->module_srl = $obj->module_srl;
359 405
 		$args->category_srl= $obj->category_srl;
360 406
 		$output = executeQueryArray('document.getNoticeList', $args, $columnList);
361
-		if(!$output->toBool()||!$output->data) return;
407
+		if(!$output->toBool()||!$output->data) {
408
+			return;
409
+		}
362 410
 
363 411
 		foreach($output->data as $key => $val)
364 412
 		{
365 413
 			$document_srl = $val->document_srl;
366
-			if(!$document_srl) continue;
414
+			if(!$document_srl) {
415
+				continue;
416
+			}
367 417
 
368 418
 			if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl])
369 419
 			{
@@ -459,7 +509,9 @@  discard block
 block discarded – undo
459 509
 
460 510
 				$oExtraVar->setExtraVarKeys($output->data);
461 511
 				$keys = $oExtraVar->getExtraVars();
462
-				if(!$keys) $keys = array();
512
+				if(!$keys) {
513
+					$keys = array();
514
+				}
463 515
 
464 516
 				if($oCacheHandler->isSupport())
465 517
 				{
@@ -489,7 +541,9 @@  discard block
 block discarded – undo
489 541
 			$GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument;
490 542
 			$this->setToAllDocumentExtraVars();
491 543
 		}
492
-		if(is_array($GLOBALS['XE_EXTRA_VARS'][$document_srl])) ksort($GLOBALS['XE_EXTRA_VARS'][$document_srl]);
544
+		if(is_array($GLOBALS['XE_EXTRA_VARS'][$document_srl])) {
545
+			ksort($GLOBALS['XE_EXTRA_VARS'][$document_srl]);
546
+		}
493 547
 		return $GLOBALS['XE_EXTRA_VARS'][$document_srl];
494 548
 	}
495 549
 
@@ -519,7 +573,9 @@  discard block
 block discarded – undo
519 573
 			$oDocument = $oDocumentModel->getDocument($document_srl, false, false, $columnList);
520 574
 			$module_srl = $oDocument->get('module_srl');
521 575
 			$member_srl = $oDocument->get('member_srl');
522
-			if(!$module_srl) return new Object(-1, 'msg_invalid_request');
576
+			if(!$module_srl) {
577
+				return new Object(-1, 'msg_invalid_request');
578
+			}
523 579
 
524 580
 			$oModuleModel = getModel('module');
525 581
 			$document_config = $oModuleModel->getModulePartConfig('document',$module_srl);
@@ -592,7 +648,9 @@  discard block
 block discarded – undo
592 648
 	 */
593 649
 	function getDocumentCount($module_srl, $search_obj = NULL)
594 650
 	{
595
-		if(is_null($search_obj)) $search_obj = new stdClass();
651
+		if(is_null($search_obj)) {
652
+			$search_obj = new stdClass();
653
+		}
596 654
 		$search_obj->module_srl = $module_srl;
597 655
 
598 656
 		$output = executeQuery('document.getDocumentCount', $search_obj);
@@ -609,7 +667,9 @@  discard block
 block discarded – undo
609 667
 	function getDocumentCountByGroupStatus($search_obj = NULL)
610 668
 	{
611 669
 		$output = executeQuery('document.getDocumentCountByGroupStatus', $search_obj);
612
-		if(!$output->toBool()) return array();
670
+		if(!$output->toBool()) {
671
+			return array();
672
+		}
613 673
 
614 674
 		return $output->data;
615 675
 	}
@@ -648,34 +708,29 @@  discard block
 block discarded – undo
648 708
 		if($sort_check->isExtraVars)
649 709
 		{
650 710
 			return 1;
651
-		}
652
-		else
711
+		} else
653 712
 		{
654 713
 			if($sort_check->sort_index === 'list_order' || $sort_check->sort_index === 'update_order')
655 714
 			{
656 715
 				if($args->order_type === 'desc')
657 716
 				{
658 717
 					$args->{'rev_' . $sort_check->sort_index} = $oDocument->get($sort_check->sort_index);
659
-				}
660
-				else
718
+				} else
661 719
 				{
662 720
 					$args->{$sort_check->sort_index} = $oDocument->get($sort_check->sort_index);
663 721
 				}
664
-			}
665
-			elseif($sort_check->sort_index === 'regdate')
722
+			} elseif($sort_check->sort_index === 'regdate')
666 723
 			{
667 724
 
668 725
 				if($args->order_type === 'asc')
669 726
 				{
670 727
 					$args->{'rev_' . $sort_check->sort_index} = $oDocument->get($sort_check->sort_index);
671
-				}
672
-				else
728
+				} else
673 729
 				{
674 730
 					$args->{$sort_check->sort_index} = $oDocument->get($sort_check->sort_index);
675 731
 				}
676 732
 
677
-			}
678
-			else
733
+			} else
679 734
 			{
680 735
 				return 1;
681 736
 			}
@@ -701,15 +756,16 @@  discard block
 block discarded – undo
701 756
 		$output = executeQuery('document.getCategory', $args, $columnList);
702 757
 
703 758
 		$node = $output->data;
704
-		if(!$node) return;
759
+		if(!$node) {
760
+			return;
761
+		}
705 762
 
706 763
 		if($node->group_srls)
707 764
 		{
708 765
 			$group_srls = explode(',',$node->group_srls);
709 766
 			unset($node->group_srls);
710 767
 			$node->group_srls = $group_srls;
711
-		}
712
-		else
768
+		} else
713 769
 		{
714 770
 			unset($node->group_srls);
715 771
 			$node->group_srls = array();
@@ -727,7 +783,9 @@  discard block
 block discarded – undo
727 783
 		$args = new stdClass();
728 784
 		$args->category_srl = $category_srl;
729 785
 		$output = executeQuery('document.getChildCategoryCount',$args);
730
-		if($output->data->count > 0) return true;
786
+		if($output->data->count > 0) {
787
+			return true;
788
+		}
731 789
 		return false;
732 790
 	}
733 791
 
@@ -746,7 +804,9 @@  discard block
 block discarded – undo
746 804
 		if(!file_exists($filename))
747 805
 		{
748 806
 			$oDocumentController = getController('document');
749
-			if(!$oDocumentController->makeCategoryFile($module_srl)) return array();
807
+			if(!$oDocumentController->makeCategoryFile($module_srl)) {
808
+				return array();
809
+			}
750 810
 		}
751 811
 
752 812
 		include($filename);
@@ -766,7 +826,9 @@  discard block
 block discarded – undo
766 826
 	 */
767 827
 	function _arrangeCategory(&$document_category, $list, $depth)
768 828
 	{
769
-		if(!count($list)) return;
829
+		if(!count($list)) {
830
+			return;
831
+		}
770 832
 		$idx = 0;
771 833
 		$list_order = array();
772 834
 		foreach($list as $key => $val)
@@ -786,8 +848,11 @@  discard block
 block discarded – undo
786 848
 			$obj->childs = array();
787 849
 			$obj->grant = $val['grant'];
788 850
 
789
-			if(Context::get('mid') == $obj->mid && Context::get('category') == $obj->category_srl) $selected = true;
790
-			else $selected = false;
851
+			if(Context::get('mid') == $obj->mid && Context::get('category') == $obj->category_srl) {
852
+				$selected = true;
853
+			} else {
854
+				$selected = false;
855
+			}
791 856
 
792 857
 			$obj->selected = $selected;
793 858
 
@@ -798,14 +863,18 @@  discard block
 block discarded – undo
798 863
 				$parent_srl = $obj->parent_srl;
799 864
 				$document_count = $obj->document_count;
800 865
 				$expand = $obj->expand;
801
-				if($selected) $expand = true;
866
+				if($selected) {
867
+					$expand = true;
868
+				}
802 869
 
803 870
 				while($parent_srl)
804 871
 				{
805 872
 					$document_category[$parent_srl]->document_count += $document_count;
806 873
 					$document_category[$parent_srl]->childs[] = $obj->category_srl;
807 874
 					$document_category[$parent_srl]->child_count = count($document_category[$parent_srl]->childs);
808
-					if($expand) $document_category[$parent_srl]->expand = $expand;
875
+					if($expand) {
876
+						$document_category[$parent_srl]->expand = $expand;
877
+					}
809 878
 
810 879
 					$parent_srl = $document_category[$parent_srl]->parent_srl;
811 880
 				}
@@ -813,7 +882,9 @@  discard block
 block discarded – undo
813 882
 
814 883
 			$document_category[$key] = $obj;
815 884
 
816
-			if(count($val['list'])) $this->_arrangeCategory($document_category, $val['list'], $depth+1);
885
+			if(count($val['list'])) {
886
+				$this->_arrangeCategory($document_category, $val['list'], $depth+1);
887
+			}
817 888
 		}
818 889
 		$document_category[$list_order[0]]->first = true;
819 890
 		$document_category[$list_order[count($list_order)-1]]->last = true;
@@ -881,13 +952,20 @@  discard block
 block discarded – undo
881 952
 		}
882 953
 		// Module_srl passed the array may be a check whether the array
883 954
 		$args = new stdClass;
884
-		if(is_array($obj->module_srl)) $args->module_srl = implode(',', $obj->module_srl);
885
-		else $args->module_srl = $obj->module_srl;
955
+		if(is_array($obj->module_srl)) {
956
+			$args->module_srl = implode(',', $obj->module_srl);
957
+		} else {
958
+			$args->module_srl = $obj->module_srl;
959
+		}
886 960
 
887 961
 		$output = executeQuery('document.getMonthlyArchivedList', $args);
888
-		if(!$output->toBool()||!$output->data) return $output;
962
+		if(!$output->toBool()||!$output->data) {
963
+			return $output;
964
+		}
889 965
 
890
-		if(!is_array($output->data)) $output->data = array($output->data);
966
+		if(!is_array($output->data)) {
967
+			$output->data = array($output->data);
968
+		}
891 969
 
892 970
 		return $output;
893 971
 	}
@@ -907,14 +985,21 @@  discard block
 block discarded – undo
907 985
 		}
908 986
 		// Module_srl passed the array may be a check whether the array
909 987
 		$args = new stdClass;
910
-		if(is_array($obj->module_srl)) $args->module_srl = implode(',', $obj->module_srl);
911
-		else $args->module_srl = $obj->module_srl;
988
+		if(is_array($obj->module_srl)) {
989
+			$args->module_srl = implode(',', $obj->module_srl);
990
+		} else {
991
+			$args->module_srl = $obj->module_srl;
992
+		}
912 993
 		$args->regdate = $obj->regdate;
913 994
 
914 995
 		$output = executeQuery('document.getDailyArchivedList', $args);
915
-		if(!$output->toBool()) return $output;
996
+		if(!$output->toBool()) {
997
+			return $output;
998
+		}
916 999
 
917
-		if(!is_array($output->data)) $output->data = array($output->data);
1000
+		if(!is_array($output->data)) {
1001
+			$output->data = array($output->data);
1002
+		}
918 1003
 
919 1004
 		return $output;
920 1005
 	}
@@ -925,7 +1010,9 @@  discard block
 block discarded – undo
925 1010
 	 */
926 1011
 	function getDocumentCategories()
927 1012
 	{
928
-		if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted');
1013
+		if(!Context::get('is_logged')) {
1014
+			return new Object(-1,'msg_not_permitted');
1015
+		}
929 1016
 		$module_srl = Context::get('module_srl');
930 1017
 		$categories= $this->getCategoryList($module_srl);
931 1018
 		$lang = Context::get('lang');
@@ -1020,7 +1107,9 @@  discard block
 block discarded – undo
1020 1107
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
1021 1108
 		// Check permissions
1022 1109
 		$grant = $oModuleModel->getGrant($module_info, Context::get('logged_info'));
1023
-		if(!$grant->manager) return new Object(-1,'msg_not_permitted');
1110
+		if(!$grant->manager) {
1111
+			return new Object(-1,'msg_not_permitted');
1112
+		}
1024 1113
 
1025 1114
 		$category_srl = Context::get('category_srl');
1026 1115
 		$category_info = $this->getCategory($category_srl);
@@ -1040,15 +1129,20 @@  discard block
 block discarded – undo
1040 1129
 	 */
1041 1130
 	function getDocumentSrlByAlias($mid, $alias)
1042 1131
 	{
1043
-		if(!$mid || !$alias) return null;
1132
+		if(!$mid || !$alias) {
1133
+			return null;
1134
+		}
1044 1135
 		$site_module_info = Context::get('site_module_info');
1045 1136
 		$args = new stdClass;
1046 1137
 		$args->mid = $mid;
1047 1138
 		$args->alias_title = $alias;
1048 1139
 		$args->site_srl = $site_module_info->site_srl;
1049 1140
 		$output = executeQuery('document.getDocumentSrlByAlias', $args);
1050
-		if(!$output->data) return null;
1051
-		else return $output->data->document_srl;
1141
+		if(!$output->data) {
1142
+			return null;
1143
+		} else {
1144
+			return $output->data->document_srl;
1145
+		}
1052 1146
 	}
1053 1147
 
1054 1148
 	/**
@@ -1059,15 +1153,20 @@  discard block
 block discarded – undo
1059 1153
 	 */
1060 1154
 	function getDocumentSrlByTitle($module_srl, $title)
1061 1155
 	{
1062
-		if(!$module_srl || !$title) return null;
1156
+		if(!$module_srl || !$title) {
1157
+			return null;
1158
+		}
1063 1159
 		$args = new stdClass;
1064 1160
 		$args->module_srl = $module_srl;
1065 1161
 		$args->title = $title;
1066 1162
 		$output = executeQuery('document.getDocumentSrlByTitle', $args);
1067
-		if(!$output->data) return null;
1068
-		else
1163
+		if(!$output->data) {
1164
+			return null;
1165
+		} else
1069 1166
 		{
1070
-			if(is_array($output->data)) return $output->data[0]->document_srl;
1167
+			if(is_array($output->data)) {
1168
+				return $output->data[0]->document_srl;
1169
+			}
1071 1170
 			return $output->data->document_srl;
1072 1171
 		}
1073 1172
 	}
@@ -1079,13 +1178,18 @@  discard block
 block discarded – undo
1079 1178
 	 */
1080 1179
 	function getAlias($document_srl)
1081 1180
 	{
1082
-		if(!$document_srl) return null;
1181
+		if(!$document_srl) {
1182
+			return null;
1183
+		}
1083 1184
 		$args = new stdClass;
1084 1185
 		$args->document_srl = $document_srl;
1085 1186
 		$output = executeQueryArray('document.getAliases', $args);
1086 1187
 
1087
-		if(!$output->data) return null;
1088
-		else return $output->data[0]->alias_title;
1188
+		if(!$output->data) {
1189
+			return null;
1190
+		} else {
1191
+			return $output->data[0]->alias_title;
1192
+		}
1089 1193
 	}
1090 1194
 
1091 1195
 	/**
@@ -1142,17 +1246,23 @@  discard block
 block discarded – undo
1142 1246
 			{
1143 1247
 				case 'title' :
1144 1248
 				case 'content' :
1145
-					if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword);
1249
+					if($search_keyword) {
1250
+						$search_keyword = str_replace(' ','%',$search_keyword);
1251
+					}
1146 1252
 					$args->{"s_".$search_target} = $search_keyword;
1147 1253
 					$use_division = true;
1148 1254
 					break;
1149 1255
 				case 'title_content' :
1150
-					if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword);
1256
+					if($search_keyword) {
1257
+						$search_keyword = str_replace(' ','%',$search_keyword);
1258
+					}
1151 1259
 					$args->s_title = $search_keyword;
1152 1260
 					$args->s_content = $search_keyword;
1153 1261
 					break;
1154 1262
 				case 'user_id' :
1155
-					if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword);
1263
+					if($search_keyword) {
1264
+						$search_keyword = str_replace(' ','%',$search_keyword);
1265
+					}
1156 1266
 					$args->s_user_id = $search_keyword;
1157 1267
 					$args->sort_index = 'documents.'.$args->sort_index;
1158 1268
 					break;
@@ -1160,13 +1270,18 @@  discard block
 block discarded – undo
1160 1270
 				case 'nick_name' :
1161 1271
 				case 'email_address' :
1162 1272
 				case 'homepage' :
1163
-					if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword);
1273
+					if($search_keyword) {
1274
+						$search_keyword = str_replace(' ','%',$search_keyword);
1275
+					}
1164 1276
 					$args->{"s_".$search_target} = $search_keyword;
1165 1277
 					break;
1166 1278
 				case 'is_notice' :
1167 1279
 				case 'is_secret' :
1168
-					if($search_keyword=='N') $args->statusList = array($this->getConfigStatus('public'));
1169
-					elseif($search_keyword=='Y') $args->statusList = array($this->getConfigStatus('secret'));
1280
+					if($search_keyword=='N') {
1281
+						$args->statusList = array($this->getConfigStatus('public'));
1282
+					} elseif($search_keyword=='Y') {
1283
+						$args->statusList = array($this->getConfigStatus('secret'));
1284
+					}
1170 1285
 					break;
1171 1286
 				case 'member_srl' :
1172 1287
 				case 'readed_count' :
@@ -1208,34 +1323,45 @@  discard block
 block discarded – undo
1208 1323
 	{
1209 1324
 		$args = new stdClass;
1210 1325
 		$document_srl = Context::get('document_srl');
1211
-		if(!$document_srl) return new Object(-1,'msg_invalid_request');
1326
+		if(!$document_srl) {
1327
+			return new Object(-1,'msg_invalid_request');
1328
+		}
1212 1329
 
1213 1330
 		$point = Context::get('point');
1214
-		if($point != -1) $point = 1;
1331
+		if($point != -1) {
1332
+			$point = 1;
1333
+		}
1215 1334
 
1216 1335
 		$oDocumentModel = getModel('document');
1217 1336
 		$columnList = array('document_srl', 'module_srl');
1218 1337
 		$oDocument = $oDocumentModel->getDocument($document_srl, false, false, $columnList);
1219 1338
 		$module_srl = $oDocument->get('module_srl');
1220
-		if(!$module_srl) return new Object(-1, 'msg_invalid_request');
1339
+		if(!$module_srl) {
1340
+			return new Object(-1, 'msg_invalid_request');
1341
+		}
1221 1342
 
1222 1343
 		$oModuleModel = getModel('module');
1223 1344
 		$document_config = $oModuleModel->getModulePartConfig('document',$module_srl);
1224 1345
 		if($point == -1)
1225 1346
 		{
1226
-			if($document_config->use_vote_down!='S') return new Object(-1, 'msg_invalid_request');
1347
+			if($document_config->use_vote_down!='S') {
1348
+				return new Object(-1, 'msg_invalid_request');
1349
+			}
1227 1350
 			$args->below_point = 0;
1228
-		}
1229
-		else
1351
+		} else
1230 1352
 		{
1231
-			if($document_config->use_vote_up!='S') return new Object(-1, 'msg_invalid_request');
1353
+			if($document_config->use_vote_up!='S') {
1354
+				return new Object(-1, 'msg_invalid_request');
1355
+			}
1232 1356
 			$args->more_point = 0;
1233 1357
 		}
1234 1358
 
1235 1359
 		$args->document_srl = $document_srl;
1236 1360
 
1237 1361
 		$output = executeQueryArray('document.getVotedMemberList',$args);
1238
-		if(!$output->toBool()) return $output;
1362
+		if(!$output->toBool()) {
1363
+			return $output;
1364
+		}
1239 1365
 
1240 1366
 		$oMemberModel = getModel('member');
1241 1367
 		if($output->data)
@@ -1257,9 +1383,11 @@  discard block
 block discarded – undo
1257 1383
 	function getStatusNameList()
1258 1384
 	{
1259 1385
 		global $lang;
1260
-		if(!isset($lang->status_name_list))
1261
-			return array_flip($this->getStatusList());
1262
-		else return $lang->status_name_list;
1386
+		if(!isset($lang->status_name_list)) {
1387
+					return array_flip($this->getStatusList());
1388
+		} else {
1389
+			return $lang->status_name_list;
1390
+		}
1263 1391
 	}
1264 1392
 
1265 1393
 	/**
@@ -1283,20 +1411,22 @@  discard block
 block discarded – undo
1283 1411
 				if (!$extra_output->data || !$extra_output->toBool())
1284 1412
 				{
1285 1413
 					$sortIndex = 'list_order';
1286
-				}
1287
-				else
1414
+				} else
1288 1415
 				{
1289 1416
 					$check_array = array();
1290 1417
 					foreach($extra_output->data as $val)
1291 1418
 					{
1292 1419
 						$check_array[] = $val->eid;
1293 1420
 					}
1294
-					if(!in_array($sortIndex, $check_array)) $sortIndex = 'list_order';
1295
-					else $isExtraVars = true;
1421
+					if(!in_array($sortIndex, $check_array)) {
1422
+						$sortIndex = 'list_order';
1423
+					} else {
1424
+						$isExtraVars = true;
1425
+					}
1296 1426
 				}
1427
+			} else {
1428
+							$sortIndex = 'list_order';
1297 1429
 			}
1298
-			else
1299
-				$sortIndex = 'list_order';
1300 1430
 		}
1301 1431
 		$returnObj = new stdClass();
1302 1432
 		$returnObj->sort_index = $sortIndex;
@@ -1334,7 +1464,9 @@  discard block
 block discarded – undo
1334 1464
 
1335 1465
 		// Check the target and sequence alignment
1336 1466
 		$orderType = array('desc' => 1, 'asc' => 1);
1337
-		if(!isset($orderType[$args->order_type])) $args->order_type = 'asc';
1467
+		if(!isset($orderType[$args->order_type])) {
1468
+			$args->order_type = 'asc';
1469
+		}
1338 1470
 
1339 1471
 		// If that came across mid module_srl instead of a direct module_srl guhaejum
1340 1472
 		if($searchOpt->mid)
@@ -1345,21 +1477,29 @@  discard block
 block discarded – undo
1345 1477
 		}
1346 1478
 
1347 1479
 		// Module_srl passed the array may be a check whether the array
1348
-		if(is_array($searchOpt->module_srl)) $args->module_srl = implode(',', $searchOpt->module_srl);
1349
-		else $args->module_srl = $searchOpt->module_srl;
1480
+		if(is_array($searchOpt->module_srl)) {
1481
+			$args->module_srl = implode(',', $searchOpt->module_srl);
1482
+		} else {
1483
+			$args->module_srl = $searchOpt->module_srl;
1484
+		}
1350 1485
 
1351 1486
 		// Except for the test module_srl
1352
-		if(is_array($searchOpt->exclude_module_srl)) $args->exclude_module_srl = implode(',', $searchOpt->exclude_module_srl);
1353
-		else $args->exclude_module_srl = $searchOpt->exclude_module_srl;
1487
+		if(is_array($searchOpt->exclude_module_srl)) {
1488
+			$args->exclude_module_srl = implode(',', $searchOpt->exclude_module_srl);
1489
+		} else {
1490
+			$args->exclude_module_srl = $searchOpt->exclude_module_srl;
1491
+		}
1354 1492
 
1355 1493
 		// only admin document list, temp document showing
1356
-		if($searchOpt->statusList) $args->statusList = $searchOpt->statusList;
1357
-		else
1494
+		if($searchOpt->statusList) {
1495
+			$args->statusList = $searchOpt->statusList;
1496
+		} else
1358 1497
 		{
1359
-			if($logged_info->is_admin == 'Y' && !$searchOpt->module_srl)
1360
-				$args->statusList = array($this->getConfigStatus('secret'), $this->getConfigStatus('public'), $this->getConfigStatus('temp'));
1361
-			else
1362
-				$args->statusList = array($this->getConfigStatus('secret'), $this->getConfigStatus('public'));
1498
+			if($logged_info->is_admin == 'Y' && !$searchOpt->module_srl) {
1499
+							$args->statusList = array($this->getConfigStatus('secret'), $this->getConfigStatus('public'), $this->getConfigStatus('temp'));
1500
+			} else {
1501
+							$args->statusList = array($this->getConfigStatus('secret'), $this->getConfigStatus('public'));
1502
+			}
1363 1503
 		}
1364 1504
 
1365 1505
 		// Category is selected, further sub-categories until all conditions
@@ -1387,18 +1527,24 @@  discard block
 block discarded – undo
1387 1527
 			{
1388 1528
 				case 'title' :
1389 1529
 				case 'content' :
1390
-					if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword);
1530
+					if($search_keyword) {
1531
+						$search_keyword = str_replace(' ','%',$search_keyword);
1532
+					}
1391 1533
 					$args->{"s_".$search_target} = $search_keyword;
1392 1534
 					$use_division = true;
1393 1535
 					break;
1394 1536
 				case 'title_content' :
1395
-					if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword);
1537
+					if($search_keyword) {
1538
+						$search_keyword = str_replace(' ','%',$search_keyword);
1539
+					}
1396 1540
 					$args->s_title = $search_keyword;
1397 1541
 					$args->s_content = $search_keyword;
1398 1542
 					$use_division = true;
1399 1543
 					break;
1400 1544
 				case 'user_id' :
1401
-					if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword);
1545
+					if($search_keyword) {
1546
+						$search_keyword = str_replace(' ','%',$search_keyword);
1547
+					}
1402 1548
 					$args->s_user_id = $search_keyword;
1403 1549
 					$args->sort_index = 'documents.'.$args->sort_index;
1404 1550
 					break;
@@ -1406,18 +1552,28 @@  discard block
 block discarded – undo
1406 1552
 				case 'nick_name' :
1407 1553
 				case 'email_address' :
1408 1554
 				case 'homepage' :
1409
-					if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword);
1555
+					if($search_keyword) {
1556
+						$search_keyword = str_replace(' ','%',$search_keyword);
1557
+					}
1410 1558
 					$args->{"s_".$search_target} = $search_keyword;
1411 1559
 					break;
1412 1560
 				case 'is_notice' :
1413
-					if($search_keyword=='N') $args->{"s_".$search_target} = 'N';
1414
-					elseif($search_keyword=='Y') $args->{"s_".$search_target} = 'Y';
1415
-					else $args->{"s_".$search_target} = '';
1561
+					if($search_keyword=='N') {
1562
+						$args->{"s_".$search_target} = 'N';
1563
+					} elseif($search_keyword=='Y') {
1564
+						$args->{"s_".$search_target} = 'Y';
1565
+					} else {
1566
+						$args->{"s_".$search_target} = '';
1567
+					}
1416 1568
 					break;
1417 1569
 				case 'is_secret' :
1418
-					if($search_keyword=='N') $args->statusList = array($this->getConfigStatus('public'));
1419
-					elseif($search_keyword=='Y') $args->statusList = array($this->getConfigStatus('secret'));
1420
-					elseif($search_keyword=='temp') $args->statusList = array($this->getConfigStatus('temp'));
1570
+					if($search_keyword=='N') {
1571
+						$args->statusList = array($this->getConfigStatus('public'));
1572
+					} elseif($search_keyword=='Y') {
1573
+						$args->statusList = array($this->getConfigStatus('secret'));
1574
+					} elseif($search_keyword=='temp') {
1575
+						$args->statusList = array($this->getConfigStatus('temp'));
1576
+					}
1421 1577
 					break;
1422 1578
 				case 'member_srl' :
1423 1579
 				case 'readed_count' :
@@ -1462,13 +1618,14 @@  discard block
 block discarded – undo
1462 1618
 		if ($searchOpt->isExtraVars)
1463 1619
 		{
1464 1620
 			$query_id = 'document.getDocumentListExtraSort';
1465
-		}
1466
-		else
1621
+		} else
1467 1622
 		{
1468 1623
 			/**
1469 1624
 			 * list_order asc sort of division that can be used only when
1470 1625
 			 */
1471
-			if($args->sort_index != 'list_order' || $args->order_type != 'asc') $use_division = false;
1626
+			if($args->sort_index != 'list_order' || $args->order_type != 'asc') {
1627
+				$use_division = false;
1628
+			}
1472 1629
 
1473 1630
 			/**
1474 1631
 			 * If it is true, use_division changed to use the document division
@@ -1483,8 +1640,7 @@  discard block
 block discarded – undo
1483 1640
 				{
1484 1641
 					$listSqlID = 'document.getDocumentListUseIndex';
1485 1642
 					$divisionSqlID = 'document.getDocumentDivisionUseIndex';
1486
-				}
1487
-				else
1643
+				} else
1488 1644
 				{
1489 1645
 					$listSqlID = 'document.getDocumentList';
1490 1646
 					$divisionSqlID = 'document.getDocumentDivision';
@@ -1541,7 +1697,9 @@  discard block
 block discarded – undo
1541 1697
 					$last_division_args->exclude_module_srl = $args->exclude_module_srl;
1542 1698
 					$last_division_args->list_order = $last_division;
1543 1699
 					$output = executeQuery('document.getDocumentDivisionCount', $last_division_args);
1544
-					if($output->data->count<1) $last_division = null;
1700
+					if($output->data->count<1) {
1701
+						$last_division = null;
1702
+					}
1545 1703
 				}
1546 1704
 
1547 1705
 				$args->division = $division;
@@ -1582,8 +1740,12 @@  discard block
 block discarded – undo
1582 1740
 		$output = executeQuery('document.getDocumentListByMemberSrl', $args, $columnList);
1583 1741
 		$document_list = $output->data;
1584 1742
 
1585
-		if(!$document_list) return array();
1586
-		if(!is_array($document_list)) $document_list = array($document_list);
1743
+		if(!$document_list) {
1744
+			return array();
1745
+		}
1746
+		if(!is_array($document_list)) {
1747
+			$document_list = array($document_list);
1748
+		}
1587 1749
 
1588 1750
 		return $document_list;
1589 1751
 	}
@@ -1594,8 +1756,7 @@  discard block
 block discarded – undo
1594 1756
 		if(Mobile::isFromMobilePhone())
1595 1757
 		{
1596 1758
 			$iconSkin = $documentConfig->micons;
1597
-		}
1598
-		else
1759
+		} else
1599 1760
 		{
1600 1761
 			$iconSkin = $documentConfig->icons;
1601 1762
 		}
Please login to merge, or discard this patch.
modules/editor/editor.controller.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -238,6 +238,7 @@
 block discarded – undo
238 238
 
239 239
 	/**
240 240
 	 * @brief AutoSave
241
+	 * @param stdClass $args
241 242
 	 */
242 243
 	function doSaveDoc($args)
243 244
 	{
Please login to merge, or discard this patch.
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -47,28 +47,28 @@  discard block
 block discarded – undo
47 47
 	{
48 48
 		$component = Context::get('component');
49 49
 		$method = Context::get('method');
50
-		if(!$component) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component));
50
+		if (!$component) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component));
51 51
 
52 52
 		$oEditorModel = getModel('editor');
53 53
 		$oComponent = &$oEditorModel->getComponentObject($component);
54
-		if(!$oComponent->toBool()) return $oComponent;
54
+		if (!$oComponent->toBool()) return $oComponent;
55 55
 
56
-		if(!method_exists($oComponent, $method)) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component));
56
+		if (!method_exists($oComponent, $method)) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component));
57 57
 
58 58
 		//$output = call_user_method($method, $oComponent);
59 59
 		//$output = call_user_func(array($oComponent, $method));
60
-		if(method_exists($oComponent, $method)) $output = $oComponent->{$method}();
61
-		else return new Object(-1,sprintf('%s method is not exists', $method));
60
+		if (method_exists($oComponent, $method)) $output = $oComponent->{$method}();
61
+		else return new Object(-1, sprintf('%s method is not exists', $method));
62 62
 
63
-		if((is_a($output, 'Object') || is_subclass_of($output, 'Object')) && !$output->toBool()) return $output;
63
+		if ((is_a($output, 'Object') || is_subclass_of($output, 'Object')) && !$output->toBool()) return $output;
64 64
 
65 65
 		$this->setError($oComponent->getError());
66 66
 		$this->setMessage($oComponent->getMessage());
67 67
 
68 68
 		$vars = $oComponent->getVariables();
69
-		if(count($vars))
69
+		if (count($vars))
70 70
 		{
71
-			foreach($vars as $key => $val)
71
+			foreach ($vars as $key => $val)
72 72
 			{
73 73
 				$this->add($key, $val);
74 74
 			}
@@ -86,18 +86,18 @@  discard block
 block discarded – undo
86 86
 		$module_srl = array();
87 87
 		$oModuleModel = getModel('module');
88 88
 
89
-		foreach($target_module_srl as $srl)
89
+		foreach ($target_module_srl as $srl)
90 90
 		{
91
-			if(!$srl) continue;
91
+			if (!$srl) continue;
92 92
 
93 93
 			$module_info = $oModuleModel->getModuleInfoByModuleSrl($srl);
94
-			if(!$module_info->module_srl)
94
+			if (!$module_info->module_srl)
95 95
 			{
96 96
 				return new Object(-1, 'msg_invalid_request');
97 97
 			}
98 98
 
99 99
 			$module_grant = $oModuleModel->getGrant($module_info, $logged_info);
100
-			if(!$module_grant->manager)
100
+			if (!$module_grant->manager)
101 101
 			{
102 102
 				return new Object(-1, 'msg_not_permitted');
103 103
 			}
@@ -111,32 +111,32 @@  discard block
 block discarded – undo
111 111
 		$editor_config->content_style = Context::get('content_style');
112 112
 		$editor_config->comment_content_style = Context::get('comment_content_style');
113 113
 		$editor_config->content_font = Context::get('content_font');
114
-		if($editor_config->content_font)
114
+		if ($editor_config->content_font)
115 115
 		{
116 116
 			$font_list = array();
117
-			$fonts = explode(',',$editor_config->content_font);
118
-			for($i=0,$c=count($fonts);$i<$c;$i++)
117
+			$fonts = explode(',', $editor_config->content_font);
118
+			for ($i = 0, $c = count($fonts); $i < $c; $i++)
119 119
 			{
120
-				$font = trim(str_replace(array('"','\''),'',$fonts[$i]));
121
-				if(!$font) continue;
120
+				$font = trim(str_replace(array('"', '\''), '', $fonts[$i]));
121
+				if (!$font) continue;
122 122
 				$font_list[] = $font;
123 123
 			}
124
-			if(count($font_list)) $editor_config->content_font = '"'.implode('","',$font_list).'"';
124
+			if (count($font_list)) $editor_config->content_font = '"'.implode('","', $font_list).'"';
125 125
 		}
126 126
 		$editor_config->content_font_size = Context::get('content_font_size');
127 127
 		$editor_config->sel_editor_colorset = Context::get('sel_editor_colorset');
128 128
 		$editor_config->sel_comment_editor_colorset = Context::get('sel_comment_editor_colorset');
129 129
 
130
-		$grants = array('enable_html_grant','enable_comment_html_grant','upload_file_grant','comment_upload_file_grant','enable_default_component_grant','enable_comment_default_component_grant','enable_component_grant','enable_comment_component_grant');
130
+		$grants = array('enable_html_grant', 'enable_comment_html_grant', 'upload_file_grant', 'comment_upload_file_grant', 'enable_default_component_grant', 'enable_comment_default_component_grant', 'enable_component_grant', 'enable_comment_component_grant');
131 131
 
132
-		foreach($grants as $key)
132
+		foreach ($grants as $key)
133 133
 		{
134 134
 			$grant = Context::get($key);
135
-			if(!$grant)
135
+			if (!$grant)
136 136
 			{
137 137
 				$editor_config->{$key} = array();
138 138
 			}
139
-			else if(is_array($grant))
139
+			else if (is_array($grant))
140 140
 			{
141 141
 				$editor_config->{$key} = $grant;
142 142
 			}
@@ -146,13 +146,13 @@  discard block
 block discarded – undo
146 146
 			}
147 147
 		}
148 148
 
149
-		$editor_config->editor_height = (int)Context::get('editor_height');
150
-		$editor_config->comment_editor_height = (int)Context::get('comment_editor_height');
149
+		$editor_config->editor_height = (int) Context::get('editor_height');
150
+		$editor_config->comment_editor_height = (int) Context::get('comment_editor_height');
151 151
 		$editor_config->enable_autosave = Context::get('enable_autosave');
152
-		if($editor_config->enable_autosave != 'Y') $editor_config->enable_autosave = 'N';
152
+		if ($editor_config->enable_autosave != 'Y') $editor_config->enable_autosave = 'N';
153 153
 
154 154
 		$oModuleController = getController('module');
155
-		foreach($module_srl as $srl)
155
+		foreach ($module_srl as $srl)
156 156
 		{
157 157
 			$oModuleController->insertModulePartConfig('editor', $srl, $editor_config);
158 158
 		}
@@ -169,31 +169,31 @@  discard block
 block discarded – undo
169 169
 	 */
170 170
 	function triggerEditorComponentCompile(&$content)
171 171
 	{
172
-		if(Context::getResponseMethod()!='HTML') return new Object();
172
+		if (Context::getResponseMethod() != 'HTML') return new Object();
173 173
 
174 174
 		$module_info = Context::get('module_info');
175 175
 		$module_srl = $module_info->module_srl;
176
-		if($module_srl)
176
+		if ($module_srl)
177 177
 		{
178 178
 			$oEditorModel = getModel('editor');
179 179
 			$editor_config = $oEditorModel->getEditorConfig($module_srl);
180 180
 			$content_style = $editor_config->content_style;
181
-			if($content_style)
181
+			if ($content_style)
182 182
 			{
183
-				$path = _XE_PATH_ . 'modules/editor/styles/'.$content_style.'/';
184
-				if(is_dir($path) && file_exists($path . 'style.ini'))
183
+				$path = _XE_PATH_.'modules/editor/styles/'.$content_style.'/';
184
+				if (is_dir($path) && file_exists($path.'style.ini'))
185 185
 				{
186 186
 					$ini = file($path.'style.ini');
187
-					for($i = 0, $c = count($ini); $i < $c; $i++)
187
+					for ($i = 0, $c = count($ini); $i < $c; $i++)
188 188
 					{
189 189
 						$file = trim($ini[$i]);
190
-						if(!$file) continue;
190
+						if (!$file) continue;
191 191
 
192
-						if(substr_compare($file, '.css', -4) === 0)
192
+						if (substr_compare($file, '.css', -4) === 0)
193 193
 						{
194 194
 							Context::addCSSFile('./modules/editor/styles/'.$content_style.'/'.$file, false);
195 195
 						}
196
-						elseif(substr_compare($file, '.js', -3) === 0)
196
+						elseif (substr_compare($file, '.js', -3) === 0)
197 197
 						{
198 198
 							Context::addJsFile('./modules/editor/styles/'.$content_style.'/'.$file, false);
199 199
 						}
@@ -202,12 +202,12 @@  discard block
 block discarded – undo
202 202
 			}
203 203
 			$content_font = $editor_config->content_font;
204 204
 			$content_font_size = $editor_config->content_font_size;
205
-			if($content_font || $content_font_size)
205
+			if ($content_font || $content_font_size)
206 206
 			{
207 207
 				$buff = array();
208 208
 				$buff[] = '<style> .xe_content { ';
209
-				if($content_font) $buff[] = 'font-family:'.$content_font.';';
210
-				if($content_font_size) $buff[] = 'font-size:'.$content_font_size.';';
209
+				if ($content_font) $buff[] = 'font-family:'.$content_font.';';
210
+				if ($content_font_size) $buff[] = 'font-size:'.$content_font_size.';';
211 211
 				$buff[] = ' }</style>';
212 212
 				Context::addHtmlHeader(implode('', $buff));
213 213
 			}
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 	 */
223 223
 	function transComponent($content)
224 224
 	{
225
-		$content = preg_replace_callback('!<(?:(div)|img)([^>]*)editor_component=([^>]*)>(?(1)(.*?)</div>)!is', array($this,'transEditorComponent'), $content);
225
+		$content = preg_replace_callback('!<(?:(div)|img)([^>]*)editor_component=([^>]*)>(?(1)(.*?)</div>)!is', array($this, 'transEditorComponent'), $content);
226 226
 		return $content;
227 227
 	}
228 228
 
@@ -237,19 +237,19 @@  discard block
 block discarded – undo
237 237
 
238 238
 		$xml_obj = new stdClass;
239 239
 		$xml_obj->attrs = new stdClass;
240
-		for($i=0,$c=count($m[0]);$i<$c;$i++)
240
+		for ($i = 0, $c = count($m[0]); $i < $c; $i++)
241 241
 		{
242
-			if(!isset($xml_obj->attrs)) $xml_obj->attrs = new stdClass;
242
+			if (!isset($xml_obj->attrs)) $xml_obj->attrs = new stdClass;
243 243
 			$xml_obj->attrs->{$m[1][$i]} = $m[2][$i];
244 244
 		}
245 245
 		$xml_obj->body = $match[4];
246 246
 
247
-		if(!$xml_obj->attrs->editor_component) return $match[0];
247
+		if (!$xml_obj->attrs->editor_component) return $match[0];
248 248
 
249 249
 		// Get converted codes by using component::transHTML()
250 250
 		$oEditorModel = getModel('editor');
251 251
 		$oComponent = &$oEditorModel->getComponentObject($xml_obj->attrs->editor_component, 0);
252
-		if(!is_object($oComponent)||!method_exists($oComponent, 'transHTML')) return $match[0];
252
+		if (!is_object($oComponent) || !method_exists($oComponent, 'transHTML')) return $match[0];
253 253
 
254 254
 		return $oComponent->transHTML($xml_obj);
255 255
 	}
@@ -259,8 +259,8 @@  discard block
 block discarded – undo
259 259
 	 */
260 260
 	function doSaveDoc($args)
261 261
 	{
262
-		if(!$args->document_srl) $args->document_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
263
-		if(Context::get('is_logged'))
262
+		if (!$args->document_srl) $args->document_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
263
+		if (Context::get('is_logged'))
264 264
 		{
265 265
 			$logged_info = Context::get('logged_info');
266 266
 			$args->member_srl = $logged_info->member_srl;
@@ -271,11 +271,11 @@  discard block
 block discarded – undo
271 271
 		}
272 272
 
273 273
 		// Get the current module if module_srl doesn't exist
274
-		if(!$args->module_srl)
274
+		if (!$args->module_srl)
275 275
 		{
276 276
 			$args->module_srl = Context::get('module_srl');
277 277
 		}
278
-		if(!$args->module_srl)
278
+		if (!$args->module_srl)
279 279
 		{
280 280
 			$current_module_info = Context::get('current_module_info');
281 281
 			$args->module_srl = $current_module_info->module_srl;
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 	function deleteSavedDoc($mode = false)
322 322
 	{
323 323
 		$args = new stdClass();
324
-		if(Context::get('is_logged'))
324
+		if (Context::get('is_logged'))
325 325
 		{
326 326
 			$logged_info = Context::get('logged_info');
327 327
 			$args->member_srl = $logged_info->member_srl;
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 		}
333 333
 		$args->module_srl = Context::get('module_srl');
334 334
 		// Get the current module if module_srl doesn't exist
335
-		if(!$args->module_srl)
335
+		if (!$args->module_srl)
336 336
 		{
337 337
 			$current_module_info = Context::get('current_module_info');
338 338
 			$args->module_srl = $current_module_info->module_srl;
@@ -340,13 +340,13 @@  discard block
 block discarded – undo
340 340
 		// Check if the auto-saved document already exists
341 341
 		$output = executeQuery('editor.getSavedDocument', $args);
342 342
 		$saved_doc = $output->data;
343
-		if(!$saved_doc) return;
343
+		if (!$saved_doc) return;
344 344
 
345 345
 		$oDocumentModel = getModel('document');
346 346
 		$oSaved = $oDocumentModel->getDocument($saved_doc->document_srl);
347
-		if(!$oSaved->isExists())
347
+		if (!$oSaved->isExists())
348 348
 		{
349
-			if($mode)
349
+			if ($mode)
350 350
 			{
351 351
 				$output = executeQuery('editor.getSavedDocument', $args);
352 352
 				$output = ModuleHandler::triggerCall('editor.deleteSavedDoc', 'after', $saved_doc);
@@ -374,9 +374,9 @@  discard block
 block discarded – undo
374 374
 		$oEditorModel = getModel('editor');
375 375
 		$args = new stdClass;
376 376
 
377
-		if($filter_enabled) $args->enabled = "Y";
377
+		if ($filter_enabled) $args->enabled = "Y";
378 378
 
379
-		if($site_srl)
379
+		if ($site_srl)
380 380
 		{
381 381
 			$args->site_srl = $site_srl;
382 382
 			$output = executeQuery('editor.getSiteComponentList', $args);
@@ -389,10 +389,10 @@  discard block
 block discarded – undo
389 389
 
390 390
 		// Get information about log-in status and its group
391 391
 		$is_logged = Context::get('is_logged');
392
-		if($is_logged)
392
+		if ($is_logged)
393 393
 		{
394 394
 			$logged_info = Context::get('logged_info');
395
-			if($logged_info->group_list && is_array($logged_info->group_list))
395
+			if ($logged_info->group_list && is_array($logged_info->group_list))
396 396
 			{
397 397
 				$group_list = array_keys($logged_info->group_list);
398 398
 			}
@@ -400,30 +400,30 @@  discard block
 block discarded – undo
400 400
 		}
401 401
 
402 402
 		// Get xml information for looping DB list
403
-		if(!is_array($db_list)) $db_list = array($db_list);
403
+		if (!is_array($db_list)) $db_list = array($db_list);
404 404
 		$component_list = new stdClass();
405
-		foreach($db_list as $component)
405
+		foreach ($db_list as $component)
406 406
 		{
407
-			if(in_array($component->component_name, array('colorpicker_text','colorpicker_bg'))) continue;
407
+			if (in_array($component->component_name, array('colorpicker_text', 'colorpicker_bg'))) continue;
408 408
 
409 409
 			$component_name = $component->component_name;
410
-			if(!$component_name) continue;
410
+			if (!$component_name) continue;
411 411
 
412
-			if(!in_array($component_name, $downloaded_list)) continue;
412
+			if (!in_array($component_name, $downloaded_list)) continue;
413 413
 
414 414
 			unset($xml_info);
415 415
 			$xml_info = $oEditorModel->getComponentXmlInfo($component_name);
416 416
 			$xml_info->enabled = $component->enabled;
417 417
 
418
-			if($component->extra_vars)
418
+			if ($component->extra_vars)
419 419
 			{
420 420
 				$extra_vars = unserialize($component->extra_vars);
421
-				if($extra_vars->target_group)
421
+				if ($extra_vars->target_group)
422 422
 				{
423 423
 					$xml_info->target_group = $extra_vars->target_group;
424 424
 				}
425 425
 
426
-				if($extra_vars->mid_list && count($extra_vars->mid_list))
426
+				if ($extra_vars->mid_list && count($extra_vars->mid_list))
427 427
 				{
428 428
 					$xml_info->mid_list = $extra_vars->mid_list;
429 429
 				}
@@ -450,9 +450,9 @@  discard block
 block discarded – undo
450 450
 				if(!in_array(Context::get('mid'), $extra_vars->mid_list)) continue;
451 451
 				}*/
452 452
 				// Check the configuration of the editor component
453
-				if($xml_info->extra_vars)
453
+				if ($xml_info->extra_vars)
454 454
 				{
455
-					foreach($xml_info->extra_vars as $key => $val)
455
+					foreach ($xml_info->extra_vars as $key => $val)
456 456
 					{
457 457
 						$xml_info->extra_vars->{$key}->value = $extra_vars->{$key};
458 458
 					}
@@ -463,25 +463,25 @@  discard block
 block discarded – undo
463 463
 			// Get buttons, icons, images
464 464
 			$icon_file = _XE_PATH_.'modules/editor/components/'.$component_name.'/icon.gif';
465 465
 			$component_icon_file = _XE_PATH_.'modules/editor/components/'.$component_name.'/component_icon.gif';
466
-			if(file_exists($icon_file)) $component_list->{$component_name}->icon = true;
467
-			if(file_exists($component_icon_file)) $component_list->{$component_name}->component_icon = true;
466
+			if (file_exists($icon_file)) $component_list->{$component_name}->icon = true;
467
+			if (file_exists($component_icon_file)) $component_list->{$component_name}->component_icon = true;
468 468
 		}
469 469
 
470 470
 		// Return if it checks enabled only
471
-		if($filter_enabled)
471
+		if ($filter_enabled)
472 472
 		{
473 473
 			$cache_file = $oEditorModel->getCacheFile($filter_enabled, $site_srl);
474
-			$buff = sprintf('<?php if(!defined("__XE__")) exit(); $component_list = unserialize("%s"); ?>', str_replace('"','\\"',serialize($component_list)));
474
+			$buff = sprintf('<?php if(!defined("__XE__")) exit(); $component_list = unserialize("%s"); ?>', str_replace('"', '\\"', serialize($component_list)));
475 475
 			FileHandler::writeFile($cache_file, $buff);
476 476
 			return $component_list;
477 477
 		}
478 478
 
479 479
 		// Get xml_info of downloaded list
480
-		foreach($downloaded_list as $component_name)
480
+		foreach ($downloaded_list as $component_name)
481 481
 		{
482
-			if(in_array($component_name, array('colorpicker_text','colorpicker_bg'))) continue;
482
+			if (in_array($component_name, array('colorpicker_text', 'colorpicker_bg'))) continue;
483 483
 			// Pass if configured
484
-			if($component_list->{$component_name}) continue;
484
+			if ($component_list->{$component_name}) continue;
485 485
 			// Insert data into the DB
486 486
 			$oEditorController = getAdminController('editor');
487 487
 			$oEditorController->insertComponent($component_name, false, $site_srl);
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
 		}
495 495
 
496 496
 		$cache_file = $oEditorModel->getCacheFile($filter_enabled, $site_srl);
497
-		$buff = sprintf('<?php if(!defined("__XE__")) exit(); $component_list = unserialize("%s"); ?>', str_replace('"','\\"',serialize($component_list)));
497
+		$buff = sprintf('<?php if(!defined("__XE__")) exit(); $component_list = unserialize("%s"); ?>', str_replace('"', '\\"', serialize($component_list)));
498 498
 		FileHandler::writeFile($cache_file, $buff);
499 499
 
500 500
 		return $component_list;
@@ -516,9 +516,9 @@  discard block
 block discarded – undo
516 516
 		$editorConfig = $oModuleModel->getModulePartConfig('editor', $obj->originModuleSrl);
517 517
 
518 518
 		$oModuleController = getController('module');
519
-		if(is_array($obj->moduleSrlList))
519
+		if (is_array($obj->moduleSrlList))
520 520
 		{
521
-			foreach($obj->moduleSrlList AS $key=>$moduleSrl)
521
+			foreach ($obj->moduleSrlList AS $key=>$moduleSrl)
522 522
 			{
523 523
 				$oModuleController->insertModulePartConfig('editor', $moduleSrl, $editorConfig);
524 524
 			}
Please login to merge, or discard this patch.
Braces   +92 added lines, -40 removed lines patch added patch discarded remove patch
@@ -47,20 +47,31 @@  discard block
 block discarded – undo
47 47
 	{
48 48
 		$component = Context::get('component');
49 49
 		$method = Context::get('method');
50
-		if(!$component) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component));
50
+		if(!$component) {
51
+			return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component));
52
+		}
51 53
 
52 54
 		$oEditorModel = getModel('editor');
53 55
 		$oComponent = &$oEditorModel->getComponentObject($component);
54
-		if(!$oComponent->toBool()) return $oComponent;
56
+		if(!$oComponent->toBool()) {
57
+			return $oComponent;
58
+		}
55 59
 
56
-		if(!method_exists($oComponent, $method)) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component));
60
+		if(!method_exists($oComponent, $method)) {
61
+			return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component));
62
+		}
57 63
 
58 64
 		//$output = call_user_method($method, $oComponent);
59 65
 		//$output = call_user_func(array($oComponent, $method));
60
-		if(method_exists($oComponent, $method)) $output = $oComponent->{$method}();
61
-		else return new Object(-1,sprintf('%s method is not exists', $method));
66
+		if(method_exists($oComponent, $method)) {
67
+			$output = $oComponent->{$method}();
68
+		} else {
69
+			return new Object(-1,sprintf('%s method is not exists', $method));
70
+		}
62 71
 
63
-		if((is_a($output, 'Object') || is_subclass_of($output, 'Object')) && !$output->toBool()) return $output;
72
+		if((is_a($output, 'Object') || is_subclass_of($output, 'Object')) && !$output->toBool()) {
73
+			return $output;
74
+		}
64 75
 
65 76
 		$this->setError($oComponent->getError());
66 77
 		$this->setMessage($oComponent->getMessage());
@@ -88,7 +99,9 @@  discard block
 block discarded – undo
88 99
 
89 100
 		foreach($target_module_srl as $srl)
90 101
 		{
91
-			if(!$srl) continue;
102
+			if(!$srl) {
103
+				continue;
104
+			}
92 105
 
93 106
 			$module_info = $oModuleModel->getModuleInfoByModuleSrl($srl);
94 107
 			if(!$module_info->module_srl)
@@ -118,10 +131,14 @@  discard block
 block discarded – undo
118 131
 			for($i=0,$c=count($fonts);$i<$c;$i++)
119 132
 			{
120 133
 				$font = trim(str_replace(array('"','\''),'',$fonts[$i]));
121
-				if(!$font) continue;
134
+				if(!$font) {
135
+					continue;
136
+				}
122 137
 				$font_list[] = $font;
123 138
 			}
124
-			if(count($font_list)) $editor_config->content_font = '"'.implode('","',$font_list).'"';
139
+			if(count($font_list)) {
140
+				$editor_config->content_font = '"'.implode('","',$font_list).'"';
141
+			}
125 142
 		}
126 143
 		$editor_config->content_font_size = Context::get('content_font_size');
127 144
 		$editor_config->sel_editor_colorset = Context::get('sel_editor_colorset');
@@ -135,12 +152,10 @@  discard block
 block discarded – undo
135 152
 			if(!$grant)
136 153
 			{
137 154
 				$editor_config->{$key} = array();
138
-			}
139
-			else if(is_array($grant))
155
+			} else if(is_array($grant))
140 156
 			{
141 157
 				$editor_config->{$key} = $grant;
142
-			}
143
-			else
158
+			} else
144 159
 			{
145 160
 				$editor_config->{$key} = explode('|@|', $grant);
146 161
 			}
@@ -149,7 +164,9 @@  discard block
 block discarded – undo
149 164
 		$editor_config->editor_height = (int)Context::get('editor_height');
150 165
 		$editor_config->comment_editor_height = (int)Context::get('comment_editor_height');
151 166
 		$editor_config->enable_autosave = Context::get('enable_autosave');
152
-		if($editor_config->enable_autosave != 'Y') $editor_config->enable_autosave = 'N';
167
+		if($editor_config->enable_autosave != 'Y') {
168
+			$editor_config->enable_autosave = 'N';
169
+		}
153 170
 
154 171
 		$oModuleController = getController('module');
155 172
 		foreach($module_srl as $srl)
@@ -169,7 +186,9 @@  discard block
 block discarded – undo
169 186
 	 */
170 187
 	function triggerEditorComponentCompile(&$content)
171 188
 	{
172
-		if(Context::getResponseMethod()!='HTML') return new Object();
189
+		if(Context::getResponseMethod()!='HTML') {
190
+			return new Object();
191
+		}
173 192
 
174 193
 		$module_info = Context::get('module_info');
175 194
 		$module_srl = $module_info->module_srl;
@@ -187,13 +206,14 @@  discard block
 block discarded – undo
187 206
 					for($i = 0, $c = count($ini); $i < $c; $i++)
188 207
 					{
189 208
 						$file = trim($ini[$i]);
190
-						if(!$file) continue;
209
+						if(!$file) {
210
+							continue;
211
+						}
191 212
 
192 213
 						if(substr_compare($file, '.css', -4) === 0)
193 214
 						{
194 215
 							Context::addCSSFile('./modules/editor/styles/'.$content_style.'/'.$file, false);
195
-						}
196
-						elseif(substr_compare($file, '.js', -3) === 0)
216
+						} elseif(substr_compare($file, '.js', -3) === 0)
197 217
 						{
198 218
 							Context::addJsFile('./modules/editor/styles/'.$content_style.'/'.$file, false);
199 219
 						}
@@ -206,8 +226,12 @@  discard block
 block discarded – undo
206 226
 			{
207 227
 				$buff = array();
208 228
 				$buff[] = '<style> .xe_content { ';
209
-				if($content_font) $buff[] = 'font-family:'.$content_font.';';
210
-				if($content_font_size) $buff[] = 'font-size:'.$content_font_size.';';
229
+				if($content_font) {
230
+					$buff[] = 'font-family:'.$content_font.';';
231
+				}
232
+				if($content_font_size) {
233
+					$buff[] = 'font-size:'.$content_font_size.';';
234
+				}
211 235
 				$buff[] = ' }</style>';
212 236
 				Context::addHtmlHeader(implode('', $buff));
213 237
 			}
@@ -239,17 +263,23 @@  discard block
 block discarded – undo
239 263
 		$xml_obj->attrs = new stdClass;
240 264
 		for($i=0,$c=count($m[0]);$i<$c;$i++)
241 265
 		{
242
-			if(!isset($xml_obj->attrs)) $xml_obj->attrs = new stdClass;
266
+			if(!isset($xml_obj->attrs)) {
267
+				$xml_obj->attrs = new stdClass;
268
+			}
243 269
 			$xml_obj->attrs->{$m[1][$i]} = $m[2][$i];
244 270
 		}
245 271
 		$xml_obj->body = $match[4];
246 272
 
247
-		if(!$xml_obj->attrs->editor_component) return $match[0];
273
+		if(!$xml_obj->attrs->editor_component) {
274
+			return $match[0];
275
+		}
248 276
 
249 277
 		// Get converted codes by using component::transHTML()
250 278
 		$oEditorModel = getModel('editor');
251 279
 		$oComponent = &$oEditorModel->getComponentObject($xml_obj->attrs->editor_component, 0);
252
-		if(!is_object($oComponent)||!method_exists($oComponent, 'transHTML')) return $match[0];
280
+		if(!is_object($oComponent)||!method_exists($oComponent, 'transHTML')) {
281
+			return $match[0];
282
+		}
253 283
 
254 284
 		return $oComponent->transHTML($xml_obj);
255 285
 	}
@@ -259,13 +289,14 @@  discard block
 block discarded – undo
259 289
 	 */
260 290
 	function doSaveDoc($args)
261 291
 	{
262
-		if(!$args->document_srl) $args->document_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
292
+		if(!$args->document_srl) {
293
+			$args->document_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
294
+		}
263 295
 		if(Context::get('is_logged'))
264 296
 		{
265 297
 			$logged_info = Context::get('logged_info');
266 298
 			$args->member_srl = $logged_info->member_srl;
267
-		}
268
-		else
299
+		} else
269 300
 		{
270 301
 			$args->ipaddress = $_SERVER['REMOTE_ADDR'];
271 302
 		}
@@ -325,8 +356,7 @@  discard block
 block discarded – undo
325 356
 		{
326 357
 			$logged_info = Context::get('logged_info');
327 358
 			$args->member_srl = $logged_info->member_srl;
328
-		}
329
-		else
359
+		} else
330 360
 		{
331 361
 			$args->ipaddress = $_SERVER['REMOTE_ADDR'];
332 362
 		}
@@ -340,7 +370,9 @@  discard block
 block discarded – undo
340 370
 		// Check if the auto-saved document already exists
341 371
 		$output = executeQuery('editor.getSavedDocument', $args);
342 372
 		$saved_doc = $output->data;
343
-		if(!$saved_doc) return;
373
+		if(!$saved_doc) {
374
+			return;
375
+		}
344 376
 
345 377
 		$oDocumentModel = getModel('document');
346 378
 		$oSaved = $oDocumentModel->getDocument($saved_doc->document_srl);
@@ -374,14 +406,17 @@  discard block
 block discarded – undo
374 406
 		$oEditorModel = getModel('editor');
375 407
 		$args = new stdClass;
376 408
 
377
-		if($filter_enabled) $args->enabled = "Y";
409
+		if($filter_enabled) {
410
+			$args->enabled = "Y";
411
+		}
378 412
 
379 413
 		if($site_srl)
380 414
 		{
381 415
 			$args->site_srl = $site_srl;
382 416
 			$output = executeQuery('editor.getSiteComponentList', $args);
417
+		} else {
418
+			$output = executeQuery('editor.getComponentList', $args);
383 419
 		}
384
-		else $output = executeQuery('editor.getComponentList', $args);
385 420
 		$db_list = $output->data;
386 421
 
387 422
 		// Get a list of files
@@ -395,21 +430,30 @@  discard block
 block discarded – undo
395 430
 			if($logged_info->group_list && is_array($logged_info->group_list))
396 431
 			{
397 432
 				$group_list = array_keys($logged_info->group_list);
433
+			} else {
434
+				$group_list = array();
398 435
 			}
399
-			else $group_list = array();
400 436
 		}
401 437
 
402 438
 		// Get xml information for looping DB list
403
-		if(!is_array($db_list)) $db_list = array($db_list);
439
+		if(!is_array($db_list)) {
440
+			$db_list = array($db_list);
441
+		}
404 442
 		$component_list = new stdClass();
405 443
 		foreach($db_list as $component)
406 444
 		{
407
-			if(in_array($component->component_name, array('colorpicker_text','colorpicker_bg'))) continue;
445
+			if(in_array($component->component_name, array('colorpicker_text','colorpicker_bg'))) {
446
+				continue;
447
+			}
408 448
 
409 449
 			$component_name = $component->component_name;
410
-			if(!$component_name) continue;
450
+			if(!$component_name) {
451
+				continue;
452
+			}
411 453
 
412
-			if(!in_array($component_name, $downloaded_list)) continue;
454
+			if(!in_array($component_name, $downloaded_list)) {
455
+				continue;
456
+			}
413 457
 
414 458
 			unset($xml_info);
415 459
 			$xml_info = $oEditorModel->getComponentXmlInfo($component_name);
@@ -463,8 +507,12 @@  discard block
 block discarded – undo
463 507
 			// Get buttons, icons, images
464 508
 			$icon_file = _XE_PATH_.'modules/editor/components/'.$component_name.'/icon.gif';
465 509
 			$component_icon_file = _XE_PATH_.'modules/editor/components/'.$component_name.'/component_icon.gif';
466
-			if(file_exists($icon_file)) $component_list->{$component_name}->icon = true;
467
-			if(file_exists($component_icon_file)) $component_list->{$component_name}->component_icon = true;
510
+			if(file_exists($icon_file)) {
511
+				$component_list->{$component_name}->icon = true;
512
+			}
513
+			if(file_exists($component_icon_file)) {
514
+				$component_list->{$component_name}->component_icon = true;
515
+			}
468 516
 		}
469 517
 
470 518
 		// Return if it checks enabled only
@@ -479,9 +527,13 @@  discard block
 block discarded – undo
479 527
 		// Get xml_info of downloaded list
480 528
 		foreach($downloaded_list as $component_name)
481 529
 		{
482
-			if(in_array($component_name, array('colorpicker_text','colorpicker_bg'))) continue;
530
+			if(in_array($component_name, array('colorpicker_text','colorpicker_bg'))) {
531
+				continue;
532
+			}
483 533
 			// Pass if configured
484
-			if($component_list->{$component_name}) continue;
534
+			if($component_list->{$component_name}) {
535
+				continue;
536
+			}
485 537
 			// Insert data into the DB
486 538
 			$oEditorController = getAdminController('editor');
487 539
 			$oEditorController->insertComponent($component_name, false, $site_srl);
Please login to merge, or discard this patch.
modules/file/file.admin.controller.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	/**
57 57
 	 * Delete selected files from the administrator page
58 58
 	 *
59
-	 * @return Object
59
+	 * @return ModuleObject|null
60 60
 	 */
61 61
 	function procFileAdminDeleteChecked()
62 62
 	{
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	/**
111 111
 	 * Add file information for each module
112 112
 	 *
113
-	 * @return void
113
+	 * @return Object|null
114 114
 	 */
115 115
 	function procFileAdminInsertModuleConfig()
116 116
 	{
Please login to merge, or discard this patch.
Braces   +47 added lines, -18 removed lines patch added patch discarded remove patch
@@ -27,12 +27,16 @@  discard block
 block discarded – undo
27 27
 		$args->module_srl = $module_srl;
28 28
 		$columnList = array('file_srl', 'uploaded_filename');
29 29
 		$output = executeQueryArray('file.getModuleFiles',$args, $columnList);
30
-		if(!$output) return $output;
30
+		if(!$output) {
31
+			return $output;
32
+		}
31 33
 		$files = $output->data;
32 34
 		// Remove from the DB
33 35
 		$args->module_srl = $module_srl;
34 36
 		$output = executeQuery('file.deleteModuleFiles', $args);
35
-		if(!$output->toBool()) return $output;
37
+		if(!$output->toBool()) {
38
+			return $output;
39
+		}
36 40
 		// Remove the file
37 41
 		FileHandler::removeDir( sprintf("./files/attach/images/%s/", $module_srl) ) ;
38 42
 		FileHandler::removeDir( sprintf("./files/attach/binaries/%s/", $module_srl) );
@@ -45,10 +49,14 @@  discard block
 block discarded – undo
45 49
 			FileHandler::removeFile($uploaded_filename);
46 50
 
47 51
 			$path_info = pathinfo($uploaded_filename);
48
-			if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname'];
52
+			if(!in_array($path_info['dirname'], $path)) {
53
+				$path[] = $path_info['dirname'];
54
+			}
49 55
 		}
50 56
 		// Remove a file directory of the document
51
-		for($i=0;$i<count($path);$i++) FileHandler::removeBlankDir($path[$i]);
57
+		for($i=0;$i<count($path);$i++) {
58
+			FileHandler::removeBlankDir($path[$i]);
59
+		}
52 60
 
53 61
 		return $output;
54 62
 	}
@@ -62,18 +70,27 @@  discard block
 block discarded – undo
62 70
 	{
63 71
 		// An error appears if no document is selected
64 72
 		$cart = Context::get('cart');
65
-		if(!$cart) return $this->stop('msg_file_cart_is_null');
66
-		if(!is_array($cart)) $file_srl_list= explode('|@|', $cart);
67
-		else $file_srl_list = $cart;
73
+		if(!$cart) {
74
+			return $this->stop('msg_file_cart_is_null');
75
+		}
76
+		if(!is_array($cart)) {
77
+			$file_srl_list= explode('|@|', $cart);
78
+		} else {
79
+			$file_srl_list = $cart;
80
+		}
68 81
 		$file_count = count($file_srl_list);
69
-		if(!$file_count) return $this->stop('msg_file_cart_is_null');
82
+		if(!$file_count) {
83
+			return $this->stop('msg_file_cart_is_null');
84
+		}
70 85
 
71 86
 		$oFileController = getController('file');
72 87
 		// Delete the post
73 88
 		for($i=0;$i<$file_count;$i++)
74 89
 		{
75 90
 			$file_srl = trim($file_srl_list[$i]);
76
-			if(!$file_srl) continue;
91
+			if(!$file_srl) {
92
+				continue;
93
+			}
77 94
 
78 95
 			$oFileController->deleteFile($file_srl);
79 96
 		}
@@ -117,8 +134,11 @@  discard block
 block discarded – undo
117 134
 		// Get variables
118 135
 		$module_srl = Context::get('target_module_srl');
119 136
 		// In order to configure multiple modules at once
120
-		if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl);
121
-		else $module_srl = array($module_srl);
137
+		if(preg_match('/^([0-9,]+)$/',$module_srl)) {
138
+			$module_srl = explode(',',$module_srl);
139
+		} else {
140
+			$module_srl = array($module_srl);
141
+		}
122 142
 
123 143
 		$download_grant = Context::get('download_grant');
124 144
 
@@ -130,8 +150,11 @@  discard block
 block discarded – undo
130 150
 		$file_config->allowed_attach_size = Context::get('allowed_attach_size');
131 151
 		$file_config->allowed_filetypes = str_replace(' ', '', Context::get('allowed_filetypes'));
132 152
 
133
-		if(!is_array($download_grant)) $file_config->download_grant = explode('|@|',$download_grant);
134
-		else $file_config->download_grant = $download_grant;
153
+		if(!is_array($download_grant)) {
154
+			$file_config->download_grant = explode('|@|',$download_grant);
155
+		} else {
156
+			$file_config->download_grant = $download_grant;
157
+		}
135 158
 
136 159
 		//관리자가 허용한 첨부파일의 사이즈가 php.ini의 값보다 큰지 확인하기 - by ovclas
137 160
 		$userFileAllowSize = FileHandler::returnbytes($file_config->allowed_filesize.'M');
@@ -140,14 +163,17 @@  discard block
 block discarded – undo
140 163
 		$iniUploadMaxSize = FileHandler::returnbytes(ini_get('upload_max_filesize'));
141 164
 		$iniMinSzie = min($iniPostMaxSize, $iniUploadMaxSize);
142 165
 
143
-		if($userFileAllowSize > $iniMinSzie || $userAttachAllowSize > $iniMinSzie)
144
-			return new Object(-1, 'input size over than config in php.ini');
166
+		if($userFileAllowSize > $iniMinSzie || $userAttachAllowSize > $iniMinSzie) {
167
+					return new Object(-1, 'input size over than config in php.ini');
168
+		}
145 169
 
146 170
 		$oModuleController = getController('module');
147 171
 		for($i=0;$i<count($module_srl);$i++)
148 172
 		{
149 173
 			$srl = trim($module_srl[$i]);
150
-			if(!$srl) continue;
174
+			if(!$srl) {
175
+				continue;
176
+			}
151 177
 			$oModuleController->insertModulePartConfig('file',$srl,$file_config);
152 178
 		}
153 179
 
@@ -174,8 +200,11 @@  discard block
 block discarded – undo
174 200
 
175 201
 		if($output->file_srl)
176 202
 		{
177
-			if($_SESSION['file_management'][$output->file_srl]) unset($_SESSION['file_management'][$output->file_srl]);
178
-			else $_SESSION['file_management'][$output->file_srl] = true;
203
+			if($_SESSION['file_management'][$output->file_srl]) {
204
+				unset($_SESSION['file_management'][$output->file_srl]);
205
+			} else {
206
+				$_SESSION['file_management'][$output->file_srl] = true;
207
+			}
179 208
 		}
180 209
 	}
181 210
 }
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -26,29 +26,29 @@  discard block
 block discarded – undo
26 26
 		$args = new stdClass();
27 27
 		$args->module_srl = $module_srl;
28 28
 		$columnList = array('file_srl', 'uploaded_filename');
29
-		$output = executeQueryArray('file.getModuleFiles',$args, $columnList);
30
-		if(!$output) return $output;
29
+		$output = executeQueryArray('file.getModuleFiles', $args, $columnList);
30
+		if (!$output) return $output;
31 31
 		$files = $output->data;
32 32
 		// Remove from the DB
33 33
 		$args->module_srl = $module_srl;
34 34
 		$output = executeQuery('file.deleteModuleFiles', $args);
35
-		if(!$output->toBool()) return $output;
35
+		if (!$output->toBool()) return $output;
36 36
 		// Remove the file
37
-		FileHandler::removeDir( sprintf("./files/attach/images/%s/", $module_srl) ) ;
38
-		FileHandler::removeDir( sprintf("./files/attach/binaries/%s/", $module_srl) );
37
+		FileHandler::removeDir(sprintf("./files/attach/images/%s/", $module_srl));
38
+		FileHandler::removeDir(sprintf("./files/attach/binaries/%s/", $module_srl));
39 39
 		// Remove the file list obtained from the DB
40 40
 		$path = array();
41 41
 		$cnt = count($files);
42
-		for($i=0;$i<$cnt;$i++)
42
+		for ($i = 0; $i < $cnt; $i++)
43 43
 		{
44 44
 			$uploaded_filename = $files[$i]->uploaded_filename;
45 45
 			FileHandler::removeFile($uploaded_filename);
46 46
 
47 47
 			$path_info = pathinfo($uploaded_filename);
48
-			if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname'];
48
+			if (!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname'];
49 49
 		}
50 50
 		// Remove a file directory of the document
51
-		for($i=0;$i<count($path);$i++) FileHandler::removeBlankDir($path[$i]);
51
+		for ($i = 0; $i < count($path); $i++) FileHandler::removeBlankDir($path[$i]);
52 52
 
53 53
 		return $output;
54 54
 	}
@@ -62,23 +62,23 @@  discard block
 block discarded – undo
62 62
 	{
63 63
 		// An error appears if no document is selected
64 64
 		$cart = Context::get('cart');
65
-		if(!$cart) return $this->stop('msg_file_cart_is_null');
66
-		if(!is_array($cart)) $file_srl_list= explode('|@|', $cart);
65
+		if (!$cart) return $this->stop('msg_file_cart_is_null');
66
+		if (!is_array($cart)) $file_srl_list = explode('|@|', $cart);
67 67
 		else $file_srl_list = $cart;
68 68
 		$file_count = count($file_srl_list);
69
-		if(!$file_count) return $this->stop('msg_file_cart_is_null');
69
+		if (!$file_count) return $this->stop('msg_file_cart_is_null');
70 70
 
71 71
 		$oFileController = getController('file');
72 72
 		// Delete the post
73
-		for($i=0;$i<$file_count;$i++)
73
+		for ($i = 0; $i < $file_count; $i++)
74 74
 		{
75 75
 			$file_srl = trim($file_srl_list[$i]);
76
-			if(!$file_srl) continue;
76
+			if (!$file_srl) continue;
77 77
 
78 78
 			$oFileController->deleteFile($file_srl);
79 79
 		}
80 80
 
81
-		$this->setMessage( sprintf(Context::getLang('msg_checked_file_is_deleted'), $file_count) );
81
+		$this->setMessage(sprintf(Context::getLang('msg_checked_file_is_deleted'), $file_count));
82 82
 
83 83
 		$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispFileAdminList');
84 84
 		$this->setRedirectUrl($returnUrl);
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 		$config->allow_outlink_site = Context::get('allow_outlink_site');
102 102
 		// Create module Controller object
103 103
 		$oModuleController = getController('module');
104
-		$output = $oModuleController->insertModuleConfig('file',$config);
104
+		$output = $oModuleController->insertModuleConfig('file', $config);
105 105
 
106 106
 		$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispFileAdminConfig');
107 107
 		return $this->setRedirectUrl($returnUrl, $output);
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 		// Get variables
118 118
 		$module_srl = Context::get('target_module_srl');
119 119
 		// In order to configure multiple modules at once
120
-		if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl);
120
+		if (preg_match('/^([0-9,]+)$/', $module_srl)) $module_srl = explode(',', $module_srl);
121 121
 		else $module_srl = array($module_srl);
122 122
 
123 123
 		$download_grant = Context::get('download_grant');
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 		$file_config->allowed_attach_size = Context::get('allowed_attach_size');
131 131
 		$file_config->allowed_filetypes = str_replace(' ', '', Context::get('allowed_filetypes'));
132 132
 
133
-		if(!is_array($download_grant)) $file_config->download_grant = explode('|@|',$download_grant);
133
+		if (!is_array($download_grant)) $file_config->download_grant = explode('|@|', $download_grant);
134 134
 		else $file_config->download_grant = $download_grant;
135 135
 
136 136
 		//관리자가 허용한 첨부파일의 사이즈가 php.ini의 값보다 큰지 확인하기 - by ovclas
@@ -140,15 +140,15 @@  discard block
 block discarded – undo
140 140
 		$iniUploadMaxSize = FileHandler::returnbytes(ini_get('upload_max_filesize'));
141 141
 		$iniMinSzie = min($iniPostMaxSize, $iniUploadMaxSize);
142 142
 
143
-		if($userFileAllowSize > $iniMinSzie || $userAttachAllowSize > $iniMinSzie)
143
+		if ($userFileAllowSize > $iniMinSzie || $userAttachAllowSize > $iniMinSzie)
144 144
 			return new Object(-1, 'input size over than config in php.ini');
145 145
 
146 146
 		$oModuleController = getController('module');
147
-		for($i=0;$i<count($module_srl);$i++)
147
+		for ($i = 0; $i < count($module_srl); $i++)
148 148
 		{
149 149
 			$srl = trim($module_srl[$i]);
150
-			if(!$srl) continue;
151
-			$oModuleController->insertModulePartConfig('file',$srl,$file_config);
150
+			if (!$srl) continue;
151
+			$oModuleController->insertModulePartConfig('file', $srl, $file_config);
152 152
 		}
153 153
 
154 154
 		$this->setError(-1);
@@ -165,16 +165,16 @@  discard block
 block discarded – undo
165 165
 	 */
166 166
 	function procFileAdminAddCart()
167 167
 	{
168
-		$file_srl = (int)Context::get('file_srl');
168
+		$file_srl = (int) Context::get('file_srl');
169 169
 		//$fileSrlList = array(500, 502);
170 170
 
171 171
 		$oFileModel = getModel('file');
172 172
 		$output = $oFileModel->getFile($file_srl);
173 173
 		//$output = $oFileModel->getFile($fileSrlList);
174 174
 
175
-		if($output->file_srl)
175
+		if ($output->file_srl)
176 176
 		{
177
-			if($_SESSION['file_management'][$output->file_srl]) unset($_SESSION['file_management'][$output->file_srl]);
177
+			if ($_SESSION['file_management'][$output->file_srl]) unset($_SESSION['file_management'][$output->file_srl]);
178 178
 			else $_SESSION['file_management'][$output->file_srl] = true;
179 179
 		}
180 180
 	}
Please login to merge, or discard this patch.
modules/file/file.admin.model.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -144,7 +144,7 @@
 block discarded – undo
144 144
 	 * Make search parameters from object(private)
145 145
 	 *
146 146
 	 * @param object $obj Original searach options
147
-	 * @param object $args Result searach options
147
+	 * @param stdClass $args Result searach options
148 148
 	 * @return void
149 149
 	 */
150 150
 	function _makeSearchParam(&$obj, &$args)
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -68,28 +68,28 @@  discard block
 block discarded – undo
68 68
 		$this->_makeSearchParam($obj, $args);
69 69
 
70 70
 		// Set valid/invalid state
71
-		if($obj->isvalid == 'Y') $args->isvalid = 'Y';
72
-		elseif($obj->isvalid == 'N') $args->isvalid = 'N';
71
+		if ($obj->isvalid == 'Y') $args->isvalid = 'Y';
72
+		elseif ($obj->isvalid == 'N') $args->isvalid = 'N';
73 73
 		// Set multimedia/common file
74
-		if($obj->direct_download == 'Y') $args->direct_download = 'Y';
75
-		elseif($obj->direct_download == 'N') $args->direct_download= 'N';
74
+		if ($obj->direct_download == 'Y') $args->direct_download = 'Y';
75
+		elseif ($obj->direct_download == 'N') $args->direct_download = 'N';
76 76
 		// Set variables
77 77
 		$args->sort_index = $obj->sort_index;
78
-		$args->page = $obj->page?$obj->page:1;
79
-		$args->list_count = $obj->list_count?$obj->list_count:20;
80
-		$args->page_count = $obj->page_count?$obj->page_count:10;
78
+		$args->page = $obj->page ? $obj->page : 1;
79
+		$args->list_count = $obj->list_count ? $obj->list_count : 20;
80
+		$args->page_count = $obj->page_count ? $obj->page_count : 10;
81 81
 		$args->s_module_srl = $obj->module_srl;
82 82
 		$args->exclude_module_srl = $obj->exclude_module_srl;
83 83
 		// Execute the file.getFileList query
84 84
 		$output = executeQuery('file.getFileList', $args, $columnList);
85 85
 		// Return if no result or an error occurs
86
-		if(!$output->toBool()||!count($output->data)) return $output;
86
+		if (!$output->toBool() || !count($output->data)) return $output;
87 87
 
88 88
 		$oFileModel = getModel('file');
89 89
 
90
-		foreach($output->data as $key => $file)
90
+		foreach ($output->data as $key => $file)
91 91
 		{
92
-			if($_SESSION['file_management'][$file->file_srl]) $file->isCarted = true;
92
+			if ($_SESSION['file_management'][$file->file_srl]) $file->isCarted = true;
93 93
 			else $file->isCarted = false;
94 94
 
95 95
 			$file->download_url = $oFileModel->getDownloadUrl($file->file_srl, $file->sid, $file->module_srl);
@@ -132,10 +132,10 @@  discard block
 block discarded – undo
132 132
 	 */
133 133
 	function getFilesCountByDate($date = '')
134 134
 	{
135
-		if($date) $args->regDate = date('Ymd', strtotime($date));
135
+		if ($date) $args->regDate = date('Ymd', strtotime($date));
136 136
 
137 137
 		$output = executeQuery('file.getFilesCount', $args);
138
-		if(!$output->toBool()) return 0;
138
+		if (!$output->toBool()) return 0;
139 139
 
140 140
 		return $output->data->count;
141 141
 	}
@@ -150,31 +150,31 @@  discard block
 block discarded – undo
150 150
 	function _makeSearchParam(&$obj, &$args)
151 151
 	{
152 152
 		// Search options
153
-		$search_target = $obj->search_target?$obj->search_target:trim(Context::get('search_target'));
154
-		$search_keyword = $obj->search_keyword?$obj->search_keyword:trim(Context::get('search_keyword'));
153
+		$search_target = $obj->search_target ? $obj->search_target : trim(Context::get('search_target'));
154
+		$search_keyword = $obj->search_keyword ? $obj->search_keyword : trim(Context::get('search_keyword'));
155 155
 
156
-		if($search_target && $search_keyword)
156
+		if ($search_target && $search_keyword)
157 157
 		{
158
-			switch($search_target)
158
+			switch ($search_target)
159 159
 			{
160 160
 				case 'filename' :
161
-					if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword);
161
+					if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword);
162 162
 					$args->s_filename = $search_keyword;
163 163
 					break;
164 164
 				case 'filesize_more' :
165
-					$args->s_filesize_more = (int)$search_keyword;
165
+					$args->s_filesize_more = (int) $search_keyword;
166 166
 					break;
167 167
 				case 'filesize_mega_more' :
168
-					$args->s_filesize_more = (int)$search_keyword * 1024 * 1024;
168
+					$args->s_filesize_more = (int) $search_keyword * 1024 * 1024;
169 169
 					break;
170 170
 				case 'filesize_less' :
171
-					$args->s_filesize_less = (int)$search_keyword;
171
+					$args->s_filesize_less = (int) $search_keyword;
172 172
 					break;
173 173
 				case 'filesize_mega_less' :
174
-					$args->s_filesize_less = (int)$search_keyword * 1024 * 1024;
174
+					$args->s_filesize_less = (int) $search_keyword * 1024 * 1024;
175 175
 					break;
176 176
 				case 'download_count' :
177
-					$args->s_download_count = (int)$search_keyword;
177
+					$args->s_download_count = (int) $search_keyword;
178 178
 					break;
179 179
 				case 'regdate' :
180 180
 					$args->s_regdate = $search_keyword;
Please login to merge, or discard this patch.
Braces   +27 added lines, -10 removed lines patch added patch discarded remove patch
@@ -68,11 +68,17 @@  discard block
 block discarded – undo
68 68
 		$this->_makeSearchParam($obj, $args);
69 69
 
70 70
 		// Set valid/invalid state
71
-		if($obj->isvalid == 'Y') $args->isvalid = 'Y';
72
-		elseif($obj->isvalid == 'N') $args->isvalid = 'N';
71
+		if($obj->isvalid == 'Y') {
72
+			$args->isvalid = 'Y';
73
+		} elseif($obj->isvalid == 'N') {
74
+			$args->isvalid = 'N';
75
+		}
73 76
 		// Set multimedia/common file
74
-		if($obj->direct_download == 'Y') $args->direct_download = 'Y';
75
-		elseif($obj->direct_download == 'N') $args->direct_download= 'N';
77
+		if($obj->direct_download == 'Y') {
78
+			$args->direct_download = 'Y';
79
+		} elseif($obj->direct_download == 'N') {
80
+			$args->direct_download= 'N';
81
+		}
76 82
 		// Set variables
77 83
 		$args->sort_index = $obj->sort_index;
78 84
 		$args->page = $obj->page?$obj->page:1;
@@ -83,14 +89,19 @@  discard block
 block discarded – undo
83 89
 		// Execute the file.getFileList query
84 90
 		$output = executeQuery('file.getFileList', $args, $columnList);
85 91
 		// Return if no result or an error occurs
86
-		if(!$output->toBool()||!count($output->data)) return $output;
92
+		if(!$output->toBool()||!count($output->data)) {
93
+			return $output;
94
+		}
87 95
 
88 96
 		$oFileModel = getModel('file');
89 97
 
90 98
 		foreach($output->data as $key => $file)
91 99
 		{
92
-			if($_SESSION['file_management'][$file->file_srl]) $file->isCarted = true;
93
-			else $file->isCarted = false;
100
+			if($_SESSION['file_management'][$file->file_srl]) {
101
+				$file->isCarted = true;
102
+			} else {
103
+				$file->isCarted = false;
104
+			}
94 105
 
95 106
 			$file->download_url = $oFileModel->getDownloadUrl($file->file_srl, $file->sid, $file->module_srl);
96 107
 			$output->data[$key] = $file;
@@ -132,10 +143,14 @@  discard block
 block discarded – undo
132 143
 	 */
133 144
 	function getFilesCountByDate($date = '')
134 145
 	{
135
-		if($date) $args->regDate = date('Ymd', strtotime($date));
146
+		if($date) {
147
+			$args->regDate = date('Ymd', strtotime($date));
148
+		}
136 149
 
137 150
 		$output = executeQuery('file.getFilesCount', $args);
138
-		if(!$output->toBool()) return 0;
151
+		if(!$output->toBool()) {
152
+			return 0;
153
+		}
139 154
 
140 155
 		return $output->data->count;
141 156
 	}
@@ -158,7 +173,9 @@  discard block
 block discarded – undo
158 173
 			switch($search_target)
159 174
 			{
160 175
 				case 'filename' :
161
-					if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword);
176
+					if($search_keyword) {
177
+						$search_keyword = str_replace(' ','%',$search_keyword);
178
+					}
162 179
 					$args->s_filename = $search_keyword;
163 180
 					break;
164 181
 				case 'filesize_more' :
Please login to merge, or discard this patch.
modules/file/file.controller.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	/**
90 90
 	 * Image resize
91 91
 	 *
92
-	 * @return Object
92
+	 * @return Object|null
93 93
 	 */
94 94
 	function procFileImageResize()
95 95
 	{
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 	/**
397 397
 	 * get file list
398 398
 	 *
399
-	 * @return Object
399
+	 * @return Object|null
400 400
 	 */
401 401
 	function procFileGetList()
402 402
 	{
Please login to merge, or discard this patch.
Spacing   +168 added lines, -168 removed lines patch added patch discarded remove patch
@@ -29,30 +29,30 @@  discard block
 block discarded – undo
29 29
 		$file_info = $_FILES['Filedata'];
30 30
 
31 31
 		// An error appears if not a normally uploaded file
32
-		if(!is_uploaded_file($file_info['tmp_name'])) exit();
32
+		if (!is_uploaded_file($file_info['tmp_name'])) exit();
33 33
 
34 34
 		// Basic variables setting
35 35
 		$oFileModel = getModel('file');
36 36
 		$editor_sequence = Context::get('editor_sequence');
37 37
 		$upload_target_srl = intval(Context::get('uploadTargetSrl'));
38
-		if(!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl'));
38
+		if (!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl'));
39 39
 		$module_srl = $this->module_srl;
40 40
 		// Exit a session if there is neither upload permission nor information
41
-		if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit();
41
+		if (!$_SESSION['upload_info'][$editor_sequence]->enabled) exit();
42 42
 		// Extract from session information if upload_target_srl is not specified
43
-		if(!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
43
+		if (!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
44 44
 		// Create if upload_target_srl is not defined in the session information
45
-		if(!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence();
45
+		if (!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence();
46 46
 
47 47
 		$output = $this->insertFile($file_info, $module_srl, $upload_target_srl);
48 48
 		Context::setResponseMethod('JSON');
49
-		$this->add('file_srl',$output->get('file_srl'));
50
-		$this->add('file_size',$output->get('file_size'));
51
-		$this->add('direct_download',$output->get('direct_download'));
52
-		$this->add('source_filename',$output->get('source_filename'));
53
-		$this->add('download_url',$output->get('uploaded_filename'));
54
-		$this->add('upload_target_srl',$output->get('upload_target_srl'));
55
-		if($output->error != '0') $this->stop($output->message);
49
+		$this->add('file_srl', $output->get('file_srl'));
50
+		$this->add('file_size', $output->get('file_size'));
51
+		$this->add('direct_download', $output->get('direct_download'));
52
+		$this->add('source_filename', $output->get('source_filename'));
53
+		$this->add('download_url', $output->get('uploaded_filename'));
54
+		$this->add('upload_target_srl', $output->get('upload_target_srl'));
55
+		if ($output->error != '0') $this->stop($output->message);
56 56
 	}
57 57
 
58 58
 	/**
@@ -67,24 +67,24 @@  discard block
 block discarded – undo
67 67
 		$callback = Context::get('callback');
68 68
 		$module_srl = $this->module_srl;
69 69
 		$upload_target_srl = intval(Context::get('uploadTargetSrl'));
70
-		if(!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl'));
70
+		if (!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl'));
71 71
 
72 72
 		// Exit a session if there is neither upload permission nor information
73
-		if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit();
73
+		if (!$_SESSION['upload_info'][$editor_sequence]->enabled) exit();
74 74
 		// Extract from session information if upload_target_srl is not specified
75
-		if(!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
75
+		if (!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
76 76
 		// Create if upload_target_srl is not defined in the session information
77
-		if(!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence();
77
+		if (!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence();
78 78
 
79 79
 		// Delete and then attempt to re-upload if file_srl is requested
80 80
 		$file_srl = Context::get('file_srl');
81
-		if($file_srl)
81
+		if ($file_srl)
82 82
 		{
83 83
 			$oFileModel = getModel('file');
84 84
 			$logged_info = Context::get('logged_info');
85 85
 			$file_info = $oFileModel->getFile($file_srl);
86 86
 			$file_grant = $oFileModel->getFileGrant($file_info, $logged_info);
87
-			if($file_info->file_srl == $file_srl && $file_grant->is_deletable)
87
+			if ($file_info->file_srl == $file_srl && $file_grant->is_deletable)
88 88
 			{
89 89
 				$this->deleteFile($file_srl);
90 90
 			}
@@ -92,12 +92,12 @@  discard block
 block discarded – undo
92 92
 
93 93
 		$file_info = Context::get('Filedata');
94 94
 		// An error appears if not a normally uploaded file
95
-		if(is_uploaded_file($file_info['tmp_name'])) {
95
+		if (is_uploaded_file($file_info['tmp_name'])) {
96 96
 			$output = $this->insertFile($file_info, $module_srl, $upload_target_srl);
97
-			Context::set('uploaded_fileinfo',$output);
97
+			Context::set('uploaded_fileinfo', $output);
98 98
 		}
99 99
 
100
-		Context::set('layout','none');
100
+		Context::set('layout', 'none');
101 101
 
102 102
 		$this->setTemplatePath($this->module_path.'tpl');
103 103
 		$this->setTemplateFile('iframe');
@@ -114,24 +114,24 @@  discard block
 block discarded – undo
114 114
 		$width = Context::get('width');
115 115
 		$height = Context::get('height');
116 116
 
117
-		if(!$file_srl || !$width)
117
+		if (!$file_srl || !$width)
118 118
 		{
119
-			return new Object(-1,'msg_invalid_request');
119
+			return new Object(-1, 'msg_invalid_request');
120 120
 		}
121 121
 
122 122
 		$oFileModel = getModel('file');
123 123
 		$fileInfo = $oFileModel->getFile($file_srl);
124
-		if(!$fileInfo || $fileInfo->direct_download != 'Y')
124
+		if (!$fileInfo || $fileInfo->direct_download != 'Y')
125 125
 		{
126
-			return new Object(-1,'msg_invalid_request');
126
+			return new Object(-1, 'msg_invalid_request');
127 127
 		}
128 128
 
129 129
 		$source_src = $fileInfo->uploaded_filename;
130
-		$output_src = $source_src . '.resized' . strrchr($source_src,'.');
130
+		$output_src = $source_src.'.resized'.strrchr($source_src, '.');
131 131
 
132
-		if(!$height) $height = $width-1;
132
+		if (!$height) $height = $width - 1;
133 133
 
134
-		if(FileHandler::createImageFile($source_src,$output_src,$width,$height,'','ratio'))
134
+		if (FileHandler::createImageFile($source_src, $output_src, $width, $height, '', 'ratio'))
135 135
 		{
136 136
 			$output = new stdClass();
137 137
 			$output->info = getimagesize($output_src);
@@ -139,10 +139,10 @@  discard block
 block discarded – undo
139 139
 		}
140 140
 		else
141 141
 		{
142
-			return new Object(-1,'msg_invalid_request');
142
+			return new Object(-1, 'msg_invalid_request');
143 143
 		}
144 144
 
145
-		$this->add('resized_info',$output);
145
+		$this->add('resized_info', $output);
146 146
 	}
147 147
 
148 148
 	/**
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 	{
181 181
 		$oFileModel = getModel('file');
182 182
 
183
-		if(isset($this->grant->access) && $this->grant->access !== true) return new Object(-1, 'msg_not_permitted');
183
+		if (isset($this->grant->access) && $this->grant->access !== true) return new Object(-1, 'msg_not_permitted');
184 184
 
185 185
 		$file_srl = Context::get('file_srl');
186 186
 		$sid = Context::get('sid');
@@ -189,26 +189,26 @@  discard block
 block discarded – undo
189 189
 		$columnList = array('file_srl', 'sid', 'isvalid', 'source_filename', 'module_srl', 'uploaded_filename', 'file_size', 'member_srl', 'upload_target_srl', 'upload_target_type');
190 190
 		$file_obj = $oFileModel->getFile($file_srl, $columnList);
191 191
 		// If the requested file information is incorrect, an error that file cannot be found appears
192
-		if($file_obj->file_srl!=$file_srl || $file_obj->sid!=$sid) return $this->stop('msg_file_not_found');
192
+		if ($file_obj->file_srl != $file_srl || $file_obj->sid != $sid) return $this->stop('msg_file_not_found');
193 193
 		// Notify that file download is not allowed when standing-by(Only a top-administrator is permitted)
194
-		if($logged_info->is_admin != 'Y' && $file_obj->isvalid!='Y') return $this->stop('msg_not_permitted_download');
194
+		if ($logged_info->is_admin != 'Y' && $file_obj->isvalid != 'Y') return $this->stop('msg_not_permitted_download');
195 195
 		// File name
196 196
 		$filename = $file_obj->source_filename;
197 197
 		$file_module_config = $oFileModel->getFileModuleConfig($file_obj->module_srl);
198 198
 		// Not allow the file outlink
199
-		if($file_module_config->allow_outlink == 'N')
199
+		if ($file_module_config->allow_outlink == 'N')
200 200
 		{
201 201
 			// Handles extension to allow outlink
202
-			if($file_module_config->allow_outlink_format)
202
+			if ($file_module_config->allow_outlink_format)
203 203
 			{
204 204
 				$allow_outlink_format_array = array();
205 205
 				$allow_outlink_format_array = explode(',', $file_module_config->allow_outlink_format);
206
-				if(!is_array($allow_outlink_format_array)) $allow_outlink_format_array[0] = $file_module_config->allow_outlink_format;
206
+				if (!is_array($allow_outlink_format_array)) $allow_outlink_format_array[0] = $file_module_config->allow_outlink_format;
207 207
 
208
-				foreach($allow_outlink_format_array as $val)
208
+				foreach ($allow_outlink_format_array as $val)
209 209
 				{
210 210
 					$val = trim($val);
211
-					if(preg_match("/\.{$val}$/i", $filename))
211
+					if (preg_match("/\.{$val}$/i", $filename))
212 212
 					{
213 213
 						$file_module_config->allow_outlink = 'Y';
214 214
 						break;
@@ -216,21 +216,21 @@  discard block
 block discarded – undo
216 216
 				}
217 217
 			}
218 218
 			// Sites that outlink is allowed
219
-			if($file_module_config->allow_outlink != 'Y')
219
+			if ($file_module_config->allow_outlink != 'Y')
220 220
 			{
221 221
 				$referer = parse_url($_SERVER["HTTP_REFERER"]);
222
-				if($referer['host'] != $_SERVER['HTTP_HOST'])
222
+				if ($referer['host'] != $_SERVER['HTTP_HOST'])
223 223
 				{
224
-					if($file_module_config->allow_outlink_site)
224
+					if ($file_module_config->allow_outlink_site)
225 225
 					{
226 226
 						$allow_outlink_site_array = array();
227 227
 						$allow_outlink_site_array = explode("\n", $file_module_config->allow_outlink_site);
228
-						if(!is_array($allow_outlink_site_array)) $allow_outlink_site_array[0] = $file_module_config->allow_outlink_site;
228
+						if (!is_array($allow_outlink_site_array)) $allow_outlink_site_array[0] = $file_module_config->allow_outlink_site;
229 229
 
230
-						foreach($allow_outlink_site_array as $val)
230
+						foreach ($allow_outlink_site_array as $val)
231 231
 						{
232 232
 							$site = parse_url(trim($val));
233
-							if($site['host'] == $referer['host'])
233
+							if ($site['host'] == $referer['host'])
234 234
 							{
235 235
 								$file_module_config->allow_outlink = 'Y';
236 236
 								break;
@@ -240,49 +240,49 @@  discard block
 block discarded – undo
240 240
 				}
241 241
 				else $file_module_config->allow_outlink = 'Y';
242 242
 			}
243
-			if($file_module_config->allow_outlink != 'Y') return $this->stop('msg_not_allowed_outlink');
243
+			if ($file_module_config->allow_outlink != 'Y') return $this->stop('msg_not_allowed_outlink');
244 244
 		}
245 245
 
246 246
 		// Check if a permission for file download is granted
247 247
 		$downloadGrantCount = 0;
248
-		if(is_array($file_module_config->download_grant))
248
+		if (is_array($file_module_config->download_grant))
249 249
 		{
250
-			foreach($file_module_config->download_grant AS $value)
251
-				if($value) $downloadGrantCount++;
250
+			foreach ($file_module_config->download_grant AS $value)
251
+				if ($value) $downloadGrantCount++;
252 252
 		}
253 253
 
254
-		if(is_array($file_module_config->download_grant) && $downloadGrantCount>0)
254
+		if (is_array($file_module_config->download_grant) && $downloadGrantCount > 0)
255 255
 		{
256
-			if(!Context::get('is_logged')) return $this->stop('msg_not_permitted_download');
256
+			if (!Context::get('is_logged')) return $this->stop('msg_not_permitted_download');
257 257
 			$logged_info = Context::get('logged_info');
258
-			if($logged_info->is_admin != 'Y')
258
+			if ($logged_info->is_admin != 'Y')
259 259
 			{
260
-				$oModuleModel =& getModel('module');
260
+				$oModuleModel = & getModel('module');
261 261
 				$columnList = array('module_srl', 'site_srl');
262 262
 				$module_info = $oModuleModel->getModuleInfoByModuleSrl($file_obj->module_srl, $columnList);
263 263
 
264
-				if(!$oModuleModel->isSiteAdmin($logged_info, $module_info->site_srl))
264
+				if (!$oModuleModel->isSiteAdmin($logged_info, $module_info->site_srl))
265 265
 				{
266
-					$oMemberModel =& getModel('member');
266
+					$oMemberModel = & getModel('member');
267 267
 					$member_groups = $oMemberModel->getMemberGroups($logged_info->member_srl, $module_info->site_srl);
268 268
 
269 269
 					$is_permitted = false;
270
-					for($i=0;$i<count($file_module_config->download_grant);$i++)
270
+					for ($i = 0; $i < count($file_module_config->download_grant); $i++)
271 271
 					{
272 272
 						$group_srl = $file_module_config->download_grant[$i];
273
-						if($member_groups[$group_srl])
273
+						if ($member_groups[$group_srl])
274 274
 						{
275 275
 							$is_permitted = true;
276 276
 							break;
277 277
 						}
278 278
 					}
279
-					if(!$is_permitted) return $this->stop('msg_not_permitted_download');
279
+					if (!$is_permitted) return $this->stop('msg_not_permitted_download');
280 280
 				}
281 281
 			}
282 282
 		}
283 283
 		// Call a trigger (before)
284 284
 		$output = ModuleHandler::triggerCall('file.downloadFile', 'before', $file_obj);
285
-		if(!$output->toBool()) return $this->stop(($output->message)?$output->message:'msg_not_permitted_download');
285
+		if (!$output->toBool()) return $this->stop(($output->message) ? $output->message : 'msg_not_permitted_download');
286 286
 
287 287
 
288 288
 		// 다운로드 후 (가상)
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 
296 296
 		$random = new Password();
297 297
 		$file_key = $_SESSION['__XE_FILE_KEY__'][$file_srl] = $random->createSecureSalt(32, 'hex');
298
-		header('Location: '.getNotEncodedUrl('', 'act', 'procFileOutput','file_srl',$file_srl,'file_key',$file_key));
298
+		header('Location: '.getNotEncodedUrl('', 'act', 'procFileOutput', 'file_srl', $file_srl, 'file_key', $file_key));
299 299
 		Context::close();
300 300
 		exit();
301 301
 
@@ -306,18 +306,18 @@  discard block
 block discarded – undo
306 306
 		$oFileModel = getModel('file');
307 307
 		$file_srl = Context::get('file_srl');
308 308
 		$file_key = Context::get('file_key');
309
-		if(strstr($_SERVER['HTTP_USER_AGENT'], "Android")) $is_android = true;
309
+		if (strstr($_SERVER['HTTP_USER_AGENT'], "Android")) $is_android = true;
310 310
 
311
-		if($is_android && $_SESSION['__XE_FILE_KEY_AND__'][$file_srl]) $session_key = '__XE_FILE_KEY_AND__';
311
+		if ($is_android && $_SESSION['__XE_FILE_KEY_AND__'][$file_srl]) $session_key = '__XE_FILE_KEY_AND__';
312 312
 		else $session_key = '__XE_FILE_KEY__';
313 313
 		$columnList = array('source_filename', 'uploaded_filename', 'file_size');
314 314
 		$file_obj = $oFileModel->getFile($file_srl, $columnList);
315 315
 
316 316
 		$uploaded_filename = $file_obj->uploaded_filename;
317 317
 
318
-		if(!file_exists($uploaded_filename)) return $this->stop('msg_file_not_found');
318
+		if (!file_exists($uploaded_filename)) return $this->stop('msg_file_not_found');
319 319
 
320
-		if(!$file_key || $_SESSION[$session_key][$file_srl] != $file_key)
320
+		if (!$file_key || $_SESSION[$session_key][$file_srl] != $file_key)
321 321
 		{
322 322
 			unset($_SESSION[$session_key][$file_srl]);
323 323
 			return $this->stop('msg_invalid_request');
@@ -326,34 +326,34 @@  discard block
 block discarded – undo
326 326
 		$file_size = $file_obj->file_size;
327 327
 		$filename = $file_obj->source_filename;
328 328
 		
329
-		if(preg_match('#(?:Chrome|Edge)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 11)
329
+		if (preg_match('#(?:Chrome|Edge)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 11)
330 330
 		{
331
-			if($is_android && preg_match('#\bwv\b|(?:Version|Browser)/\d+#', $_SERVER['HTTP_USER_AGENT']))
331
+			if ($is_android && preg_match('#\bwv\b|(?:Version|Browser)/\d+#', $_SERVER['HTTP_USER_AGENT']))
332 332
 			{
333
-				$filename_param = 'filename="' . $filename . '"';
333
+				$filename_param = 'filename="'.$filename.'"';
334 334
 			}
335 335
 			else
336 336
 			{
337
-				$filename_param = "filename*=UTF-8''" . rawurlencode($filename) . '; filename="' . rawurlencode($filename) . '"';
337
+				$filename_param = "filename*=UTF-8''".rawurlencode($filename).'; filename="'.rawurlencode($filename).'"';
338 338
 			}
339 339
 		}
340
-		elseif(preg_match('#(?:Firefox|Safari|Trident)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 6)
340
+		elseif (preg_match('#(?:Firefox|Safari|Trident)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 6)
341 341
 		{
342
-			$filename_param = "filename*=UTF-8''" . rawurlencode($filename) . '; filename="' . rawurlencode($filename) . '"';
342
+			$filename_param = "filename*=UTF-8''".rawurlencode($filename).'; filename="'.rawurlencode($filename).'"';
343 343
 		}
344
-		elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE)
344
+		elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE)
345 345
 		{
346 346
 			$filename = rawurlencode($filename);
347
-			$filename_param = 'filename="' . preg_replace('/\./', '%2e', $filename, substr_count($filename, '.') - 1) . '"';
347
+			$filename_param = 'filename="'.preg_replace('/\./', '%2e', $filename, substr_count($filename, '.') - 1).'"';
348 348
 		}
349 349
 		else
350 350
 		{
351
-			$filename_param = 'filename="' . $filename . '"';
351
+			$filename_param = 'filename="'.$filename.'"';
352 352
 		}
353 353
 
354
-		if($is_android)
354
+		if ($is_android)
355 355
 		{
356
-			if($_SESSION['__XE_FILE_KEY__'][$file_srl]) $_SESSION['__XE_FILE_KEY_AND__'][$file_srl] = $file_key;
356
+			if ($_SESSION['__XE_FILE_KEY__'][$file_srl]) $_SESSION['__XE_FILE_KEY_AND__'][$file_srl] = $file_key;
357 357
 		}
358 358
 
359 359
 		unset($_SESSION[$session_key][$file_srl]);
@@ -361,21 +361,21 @@  discard block
 block discarded – undo
361 361
 		Context::close();
362 362
 
363 363
 		$fp = fopen($uploaded_filename, 'rb');
364
-		if(!$fp) return $this->stop('msg_file_not_found');
364
+		if (!$fp) return $this->stop('msg_file_not_found');
365 365
 
366 366
 		header("Cache-Control: ");
367 367
 		header("Pragma: ");
368 368
 		header("Content-Type: application/octet-stream");
369
-		header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
369
+		header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
370 370
 
371
-		header("Content-Length: " .(string)($file_size));
372
-		header('Content-Disposition: attachment; ' . $filename_param);
371
+		header("Content-Length: ".(string) ($file_size));
372
+		header('Content-Disposition: attachment; '.$filename_param);
373 373
 		header("Content-Transfer-Encoding: binary\n");
374 374
 
375 375
 		// if file size is lager than 10MB, use fread function (#18675748)
376
-		if($file_size > 1024 * 1024)
376
+		if ($file_size > 1024 * 1024)
377 377
 		{
378
-			while(!feof($fp)) echo fread($fp, 1024);
378
+			while (!feof($fp)) echo fread($fp, 1024);
379 379
 			fclose($fp);
380 380
 		}
381 381
 		else
@@ -397,36 +397,36 @@  discard block
 block discarded – undo
397 397
 		$editor_sequence = Context::get('editor_sequence');
398 398
 		$file_srl = Context::get('file_srl');
399 399
 		$file_srls = Context::get('file_srls');
400
-		if($file_srls) $file_srl = $file_srls;
400
+		if ($file_srls) $file_srl = $file_srls;
401 401
 		// Exit a session if there is neither upload permission nor information
402
-		if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit();
402
+		if (!$_SESSION['upload_info'][$editor_sequence]->enabled) exit();
403 403
 
404 404
 		$upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
405 405
 
406 406
 		$logged_info = Context::get('logged_info');
407 407
 		$oFileModel = getModel('file');
408 408
 
409
-		$srls = explode(',',$file_srl);
410
-		if(!count($srls)) return;
409
+		$srls = explode(',', $file_srl);
410
+		if (!count($srls)) return;
411 411
 
412
-		for($i=0;$i<count($srls);$i++)
412
+		for ($i = 0; $i < count($srls); $i++)
413 413
 		{
414
-			$srl = (int)$srls[$i];
415
-			if(!$srl) continue;
414
+			$srl = (int) $srls[$i];
415
+			if (!$srl) continue;
416 416
 
417 417
 			$args = new stdClass;
418 418
 			$args->file_srl = $srl;
419 419
 			$output = executeQuery('file.getFile', $args);
420
-			if(!$output->toBool()) continue;
420
+			if (!$output->toBool()) continue;
421 421
 
422 422
 			$file_info = $output->data;
423
-			if(!$file_info) continue;
423
+			if (!$file_info) continue;
424 424
 
425 425
 			$file_grant = $oFileModel->getFileGrant($file_info, $logged_info);
426 426
 
427
-			if(!$file_grant->is_deletable) continue;
427
+			if (!$file_grant->is_deletable) continue;
428 428
 
429
-			if($upload_target_srl && $file_srl) $output = $this->deleteFile($file_srl);
429
+			if ($upload_target_srl && $file_srl) $output = $this->deleteFile($file_srl);
430 430
 		}
431 431
 	}
432 432
 
@@ -437,32 +437,32 @@  discard block
 block discarded – undo
437 437
 	 */
438 438
 	function procFileGetList()
439 439
 	{
440
-		if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted');
440
+		if (!Context::get('is_logged')) return new Object(-1, 'msg_not_permitted');
441 441
 
442 442
 		$oModuleModel = getModel('module');
443 443
 
444 444
 		$logged_info = Context::get('logged_info');
445
-		if($logged_info->is_admin !== 'Y' && !$oModuleModel->isSiteAdmin($logged_info))
445
+		if ($logged_info->is_admin !== 'Y' && !$oModuleModel->isSiteAdmin($logged_info))
446 446
 		{
447 447
 			return new Object(-1, 'msg_not_permitted');
448 448
 		}
449 449
 
450 450
 		$fileSrls = Context::get('file_srls');
451
-		if($fileSrls) $fileSrlList = explode(',', $fileSrls);
451
+		if ($fileSrls) $fileSrlList = explode(',', $fileSrls);
452 452
 
453 453
 		global $lang;
454
-		if(count($fileSrlList) > 0)
454
+		if (count($fileSrlList) > 0)
455 455
 		{
456 456
 			$oFileModel = getModel('file');
457 457
 			$fileList = $oFileModel->getFile($fileSrlList);
458
-			if(!is_array($fileList)) $fileList = array($fileList);
458
+			if (!is_array($fileList)) $fileList = array($fileList);
459 459
 
460
-			if(is_array($fileList))
460
+			if (is_array($fileList))
461 461
 			{
462
-				foreach($fileList AS $key=>$value)
462
+				foreach ($fileList AS $key=>$value)
463 463
 				{
464 464
 					$value->human_file_size = FileHandler::filesize($value->file_size);
465
-					if($value->isvalid=='Y') $value->validName = $lang->is_valid;
465
+					if ($value->isvalid == 'Y') $value->validName = $lang->is_valid;
466 466
 					else $value->validName = $lang->is_stand_by;
467 467
 				}
468 468
 			}
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 	function triggerCheckAttached(&$obj)
485 485
 	{
486 486
 		$document_srl = $obj->document_srl;
487
-		if(!$document_srl) return new Object();
487
+		if (!$document_srl) return new Object();
488 488
 		// Get numbers of attachments
489 489
 		$oFileModel = getModel('file');
490 490
 		$obj->uploaded_count = $oFileModel->getFilesCount($document_srl);
@@ -501,10 +501,10 @@  discard block
 block discarded – undo
501 501
 	function triggerAttachFiles(&$obj)
502 502
 	{
503 503
 		$document_srl = $obj->document_srl;
504
-		if(!$document_srl) return new Object();
504
+		if (!$document_srl) return new Object();
505 505
 
506 506
 		$output = $this->setFilesValid($document_srl);
507
-		if(!$output->toBool()) return $output;
507
+		if (!$output->toBool()) return $output;
508 508
 
509 509
 		return new Object();
510 510
 	}
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
 	function triggerDeleteAttached(&$obj)
519 519
 	{
520 520
 		$document_srl = $obj->document_srl;
521
-		if(!$document_srl) return new Object();
521
+		if (!$document_srl) return new Object();
522 522
 
523 523
 		$output = $this->deleteFiles($document_srl);
524 524
 		return $output;
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
 	function triggerCommentCheckAttached(&$obj)
534 534
 	{
535 535
 		$comment_srl = $obj->comment_srl;
536
-		if(!$comment_srl) return new Object();
536
+		if (!$comment_srl) return new Object();
537 537
 		// Get numbers of attachments
538 538
 		$oFileModel = getModel('file');
539 539
 		$obj->uploaded_count = $oFileModel->getFilesCount($comment_srl);
@@ -551,10 +551,10 @@  discard block
 block discarded – undo
551 551
 	{
552 552
 		$comment_srl = $obj->comment_srl;
553 553
 		$uploaded_count = $obj->uploaded_count;
554
-		if(!$comment_srl || !$uploaded_count) return new Object();
554
+		if (!$comment_srl || !$uploaded_count) return new Object();
555 555
 
556 556
 		$output = $this->setFilesValid($comment_srl);
557
-		if(!$output->toBool()) return $output;
557
+		if (!$output->toBool()) return $output;
558 558
 
559 559
 		return new Object();
560 560
 	}
@@ -568,9 +568,9 @@  discard block
 block discarded – undo
568 568
 	function triggerCommentDeleteAttached(&$obj)
569 569
 	{
570 570
 		$comment_srl = $obj->comment_srl;
571
-		if(!$comment_srl) return new Object();
571
+		if (!$comment_srl) return new Object();
572 572
 
573
-		if($obj->isMoveToTrash) return new Object();
573
+		if ($obj->isMoveToTrash) return new Object();
574 574
 
575 575
 		$output = $this->deleteFiles($comment_srl);
576 576
 		return $output;
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
 	function triggerDeleteModuleFiles(&$obj)
586 586
 	{
587 587
 		$module_srl = $obj->module_srl;
588
-		if(!$module_srl) return new Object();
588
+		if (!$module_srl) return new Object();
589 589
 
590 590
 		$oFileController = getAdminController('file');
591 591
 		return $oFileController->deleteModuleFiles($module_srl);
@@ -598,9 +598,9 @@  discard block
 block discarded – undo
598 598
 	 * @param int $upload_target_srl
599 599
 	 * @return void
600 600
 	 */
601
-	function setUploadInfo($editor_sequence, $upload_target_srl=0)
601
+	function setUploadInfo($editor_sequence, $upload_target_srl = 0)
602 602
 	{
603
-		if(!isset($_SESSION['upload_info'][$editor_sequence]))
603
+		if (!isset($_SESSION['upload_info'][$editor_sequence]))
604 604
 		{
605 605
 			$_SESSION['upload_info'][$editor_sequence] = new stdClass();
606 606
 		}
@@ -660,36 +660,36 @@  discard block
 block discarded – undo
660 660
 		$trigger_obj->module_srl = $module_srl;
661 661
 		$trigger_obj->upload_target_srl = $upload_target_srl;
662 662
 		$output = ModuleHandler::triggerCall('file.insertFile', 'before', $trigger_obj);
663
-		if(!$output->toBool()) return $output;
663
+		if (!$output->toBool()) return $output;
664 664
 
665 665
 		// A workaround for Firefox upload bug
666
-		if(preg_match('/^=\?UTF-8\?B\?(.+)\?=$/i', $file_info['name'], $match))
666
+		if (preg_match('/^=\?UTF-8\?B\?(.+)\?=$/i', $file_info['name'], $match))
667 667
 		{
668 668
 			$file_info['name'] = base64_decode(strtr($match[1], ':', '/'));
669 669
 		}
670 670
 
671
-		if(!$manual_insert)
671
+		if (!$manual_insert)
672 672
 		{
673 673
 			// Get the file configurations
674 674
 			$logged_info = Context::get('logged_info');
675
-			if($logged_info->is_admin != 'Y')
675
+			if ($logged_info->is_admin != 'Y')
676 676
 			{
677 677
 				$oFileModel = getModel('file');
678 678
 				$config = $oFileModel->getFileConfig($module_srl);
679 679
 
680 680
 				// check file type
681
-				if(isset($config->allowed_filetypes) && $config->allowed_filetypes !== '*.*')
681
+				if (isset($config->allowed_filetypes) && $config->allowed_filetypes !== '*.*')
682 682
 				{
683 683
 					$filetypes = explode(';', $config->allowed_filetypes);
684 684
 					$ext = array();
685
-					foreach($filetypes as $item) {
685
+					foreach ($filetypes as $item) {
686 686
 						$item = explode('.', $item);
687 687
 						$ext[] = strtolower($item[1]);
688 688
 					}
689 689
 					$uploaded_ext = explode('.', $file_info['name']);
690 690
 					$uploaded_ext = strtolower(array_pop($uploaded_ext));
691 691
 
692
-					if(!in_array($uploaded_ext, $ext))
692
+					if (!in_array($uploaded_ext, $ext))
693 693
 					{
694 694
 						return $this->stop('msg_not_allowed_filetype');
695 695
 					}
@@ -698,63 +698,63 @@  discard block
 block discarded – undo
698 698
 				$allowed_filesize = $config->allowed_filesize * 1024 * 1024;
699 699
 				$allowed_attach_size = $config->allowed_attach_size * 1024 * 1024;
700 700
 				// An error appears if file size exceeds a limit
701
-				if($allowed_filesize < filesize($file_info['tmp_name'])) return new Object(-1, 'msg_exceeds_limit_size');
701
+				if ($allowed_filesize < filesize($file_info['tmp_name'])) return new Object(-1, 'msg_exceeds_limit_size');
702 702
 				// Get total file size of all attachements (from DB)
703 703
 				$size_args = new stdClass;
704 704
 				$size_args->upload_target_srl = $upload_target_srl;
705 705
 				$output = executeQuery('file.getAttachedFileSize', $size_args);
706
-				$attached_size = (int)$output->data->attached_size + filesize($file_info['tmp_name']);
707
-				if($attached_size > $allowed_attach_size) return new Object(-1, 'msg_exceeds_limit_size');
706
+				$attached_size = (int) $output->data->attached_size + filesize($file_info['tmp_name']);
707
+				if ($attached_size > $allowed_attach_size) return new Object(-1, 'msg_exceeds_limit_size');
708 708
 			}
709 709
 		}
710 710
 
711 711
 		// https://github.com/xpressengine/xe-core/issues/1713
712
-		$file_info['name'] = preg_replace('/\.(php|phtm|phar|html?|cgi|pl|exe|jsp|asp|inc)/i', '$0-x',$file_info['name']);
712
+		$file_info['name'] = preg_replace('/\.(php|phtm|phar|html?|cgi|pl|exe|jsp|asp|inc)/i', '$0-x', $file_info['name']);
713 713
 		$file_info['name'] = removeHackTag($file_info['name']);
714
-		$file_info['name'] = str_replace(array('<','>'),array('%3C','%3E'),$file_info['name']);
714
+		$file_info['name'] = str_replace(array('<', '>'), array('%3C', '%3E'), $file_info['name']);
715 715
 
716 716
 		// Get random number generator
717 717
 		$random = new Password();
718 718
 
719 719
 		// Set upload path by checking if the attachement is an image or other kinds of file
720
-		if(preg_match("/\.(jpe?g|gif|png|wm[va]|mpe?g|avi|flv|mp[1-4]|as[fx]|wav|midi?|moo?v|qt|r[am]{1,2}|m4v)$/i", $file_info['name']))
720
+		if (preg_match("/\.(jpe?g|gif|png|wm[va]|mpe?g|avi|flv|mp[1-4]|as[fx]|wav|midi?|moo?v|qt|r[am]{1,2}|m4v)$/i", $file_info['name']))
721 721
 		{
722
-			$path = sprintf("./files/attach/images/%s/%s", $module_srl,getNumberingPath($upload_target_srl,3));
722
+			$path = sprintf("./files/attach/images/%s/%s", $module_srl, getNumberingPath($upload_target_srl, 3));
723 723
 
724 724
 			// special character to '_'
725 725
 			// change to random file name. because window php bug. window php is not recognize unicode character file name - by cherryfilter
726
-			$ext = substr(strrchr($file_info['name'],'.'),1);
726
+			$ext = substr(strrchr($file_info['name'], '.'), 1);
727 727
 			//$_filename = preg_replace('/[#$&*?+%"\']/', '_', $file_info['name']);
728 728
 			$_filename = $random->createSecureSalt(32, 'hex').'.'.$ext;
729 729
 			$filename  = $path.$_filename;
730 730
 			$idx = 1;
731
-			while(file_exists($filename))
731
+			while (file_exists($filename))
732 732
 			{
733
-				$filename = $path.preg_replace('/\.([a-z0-9]+)$/i','_'.$idx.'.$1',$_filename);
733
+				$filename = $path.preg_replace('/\.([a-z0-9]+)$/i', '_'.$idx.'.$1', $_filename);
734 734
 				$idx++;
735 735
 			}
736 736
 			$direct_download = 'Y';
737 737
 		}
738 738
 		else
739 739
 		{
740
-			$path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl,3));
740
+			$path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl, 3));
741 741
 			$filename = $path.$random->createSecureSalt(32, 'hex');
742 742
 			$direct_download = 'N';
743 743
 		}
744 744
 		// Create a directory
745
-		if(!FileHandler::makeDir($path)) return new Object(-1,'msg_not_permitted_create');
745
+		if (!FileHandler::makeDir($path)) return new Object(-1, 'msg_not_permitted_create');
746 746
 
747 747
 		// Check uploaded file
748
-		if(!checkUploadedFile($file_info['tmp_name']))  return new Object(-1,'msg_file_upload_error');
748
+		if (!checkUploadedFile($file_info['tmp_name']))  return new Object(-1, 'msg_file_upload_error');
749 749
 
750 750
 		// Get random number generator
751 751
 		$random = new Password();
752 752
 		
753 753
 		// Move the file
754
-		if($manual_insert)
754
+		if ($manual_insert)
755 755
 		{
756 756
 			@copy($file_info['tmp_name'], $filename);
757
-			if(!file_exists($filename))
757
+			if (!file_exists($filename))
758 758
 			{
759 759
 				$filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext;
760 760
 				@copy($file_info['tmp_name'], $filename);
@@ -762,10 +762,10 @@  discard block
 block discarded – undo
762 762
 		}
763 763
 		else
764 764
 		{
765
-			if(!@move_uploaded_file($file_info['tmp_name'], $filename))
765
+			if (!@move_uploaded_file($file_info['tmp_name'], $filename))
766 766
 			{
767 767
 				$filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext;
768
-				if(!@move_uploaded_file($file_info['tmp_name'], $filename))  return new Object(-1,'msg_file_upload_error');
768
+				if (!@move_uploaded_file($file_info['tmp_name'], $filename))  return new Object(-1, 'msg_file_upload_error');
769 769
 			}
770 770
 		}
771 771
 		// Get member information
@@ -786,10 +786,10 @@  discard block
 block discarded – undo
786 786
 		$args->sid = $random->createSecureSalt(32, 'hex');
787 787
 
788 788
 		$output = executeQuery('file.insertFile', $args);
789
-		if(!$output->toBool()) return $output;
789
+		if (!$output->toBool()) return $output;
790 790
 		// Call a trigger (after)
791 791
 		$trigger_output = ModuleHandler::triggerCall('file.insertFile', 'after', $args);
792
-		if(!$trigger_output->toBool()) return $trigger_output;
792
+		if (!$trigger_output->toBool()) return $trigger_output;
793 793
 
794 794
 		$_SESSION['__XE_UPLOADING_FILES_INFO__'][$args->file_srl] = true;
795 795
 
@@ -832,18 +832,18 @@  discard block
 block discarded – undo
832 832
 	 */
833 833
 	function deleteFile($file_srl)
834 834
 	{
835
-		if(!$file_srl) return;
835
+		if (!$file_srl) return;
836 836
 
837 837
 		$srls = (is_array($file_srl)) ? $file_srl : explode(',', $file_srl);
838
-		if(!count($srls)) return;
838
+		if (!count($srls)) return;
839 839
 
840 840
 		$oDocumentController = getController('document');
841 841
 		$documentSrlList = array();
842 842
 
843
-		foreach($srls as $srl)
843
+		foreach ($srls as $srl)
844 844
 		{
845
-			$srl = (int)$srl;
846
-			if(!$srl) 
845
+			$srl = (int) $srl;
846
+			if (!$srl) 
847 847
 			{
848 848
 				continue;
849 849
 			}
@@ -852,14 +852,14 @@  discard block
 block discarded – undo
852 852
 			$args->file_srl = $srl;
853 853
 			$output = executeQuery('file.getFile', $args);
854 854
 
855
-			if(!$output->toBool() || !$output->data) 
855
+			if (!$output->toBool() || !$output->data) 
856 856
 			{
857 857
 				continue;
858 858
 			}
859 859
 
860 860
 			$file_info = $output->data;
861 861
 
862
-			if($file_info->upload_target_srl)
862
+			if ($file_info->upload_target_srl)
863 863
 			{
864 864
 				$documentSrlList[] = $file_info->upload_target_srl;
865 865
 			}
@@ -870,15 +870,15 @@  discard block
 block discarded – undo
870 870
 			// Call a trigger (before)
871 871
 			$trigger_obj = $output->data;
872 872
 			$output = ModuleHandler::triggerCall('file.deleteFile', 'before', $trigger_obj);
873
-			if(!$output->toBool()) return $output;
873
+			if (!$output->toBool()) return $output;
874 874
 
875 875
 			// Remove from the DB
876 876
 			$output = executeQuery('file.deleteFile', $args);
877
-			if(!$output->toBool()) return $output;
877
+			if (!$output->toBool()) return $output;
878 878
 
879 879
 			// Call a trigger (after)
880 880
 			$trigger_output = ModuleHandler::triggerCall('file.deleteFile', 'after', $trigger_obj);
881
-			if(!$trigger_output->toBool()) return $trigger_output;
881
+			if (!$trigger_output->toBool()) return $trigger_output;
882 882
 
883 883
 			// If successfully deleted, remove the file
884 884
 			FileHandler::removeFile($uploaded_filename);
@@ -902,28 +902,28 @@  discard block
 block discarded – undo
902 902
 		$columnList = array('file_srl', 'uploaded_filename', 'module_srl');
903 903
 		$file_list = $oFileModel->getFiles($upload_target_srl, $columnList);
904 904
 		// Success returned if no attachement exists
905
-		if(!is_array($file_list)||!count($file_list)) return new Object();
905
+		if (!is_array($file_list) || !count($file_list)) return new Object();
906 906
 
907 907
 		// Delete the file
908 908
 		$path = array();
909 909
 		$file_count = count($file_list);
910
-		for($i=0;$i<$file_count;$i++)
910
+		for ($i = 0; $i < $file_count; $i++)
911 911
 		{
912 912
 			$this->deleteFile($file_list[$i]->file_srl);
913 913
 
914 914
 			$uploaded_filename = $file_list[$i]->uploaded_filename;
915 915
 			$path_info = pathinfo($uploaded_filename);
916
-			if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname'];
916
+			if (!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname'];
917 917
 		}
918 918
 
919 919
 		// Remove from the DB
920 920
 		$args = new stdClass();
921 921
 		$args->upload_target_srl = $upload_target_srl;
922 922
 		$output = executeQuery('file.deleteFiles', $args);
923
-		if(!$output->toBool()) return $output;
923
+		if (!$output->toBool()) return $output;
924 924
 		
925 925
 		// Remove a file directory of the document
926
-		for($i=0, $c=count($path); $i<$c; $i++)
926
+		for ($i = 0, $c = count($path); $i < $c; $i++)
927 927
 		{
928 928
 			FileHandler::removeBlankDir($path[$i]);
929 929
 		}
@@ -941,23 +941,23 @@  discard block
 block discarded – undo
941 941
 	 */
942 942
 	function moveFile($source_srl, $target_module_srl, $target_srl)
943 943
 	{
944
-		if($source_srl == $target_srl) return;
944
+		if ($source_srl == $target_srl) return;
945 945
 
946 946
 		$oFileModel = getModel('file');
947 947
 		$file_list = $oFileModel->getFiles($source_srl);
948
-		if(!$file_list) return;
948
+		if (!$file_list) return;
949 949
 
950 950
 		$file_count = count($file_list);
951 951
  
952
-		for($i=0;$i<$file_count;$i++)
952
+		for ($i = 0; $i < $file_count; $i++)
953 953
 		{
954 954
 			unset($file_info);
955 955
 			$file_info = $file_list[$i];
956 956
 			$old_file = $file_info->uploaded_filename;
957 957
 			// Determine the file path by checking if the file is an image or other kinds
958
-			if(preg_match("/\.(asf|asf|asx|avi|flv|gif|jpeg|jpg|m4a|m4v|mid|midi|moov|mov|mp1|mp2|mp3|mp4|mpeg|mpg|ogg|png|qt|ra|ram|rm|rmm|wav|webm|webp|wma|wmv)$/i", $file_info->source_filename))
958
+			if (preg_match("/\.(asf|asf|asx|avi|flv|gif|jpeg|jpg|m4a|m4v|mid|midi|moov|mov|mp1|mp2|mp3|mp4|mpeg|mpg|ogg|png|qt|ra|ram|rm|rmm|wav|webm|webp|wma|wmv)$/i", $file_info->source_filename))
959 959
 			{
960
-				$path = sprintf("./files/attach/images/%s/%s/", $target_module_srl,$target_srl);
960
+				$path = sprintf("./files/attach/images/%s/%s/", $target_module_srl, $target_srl);
961 961
 				$new_file = $path.$file_info->source_filename;
962 962
 			}
963 963
 			else
@@ -967,7 +967,7 @@  discard block
 block discarded – undo
967 967
 				$new_file = $path.$random->createSecureSalt(32, 'hex');
968 968
 			}
969 969
 			// Pass if a target document to move is same
970
-			if($old_file == $new_file) continue;
970
+			if ($old_file == $new_file) continue;
971 971
 			// Create a directory
972 972
 			FileHandler::makeDir($path);
973 973
 			// Move the file
@@ -987,18 +987,18 @@  discard block
 block discarded – undo
987 987
 		$vars = Context::getRequestVars();
988 988
 		$logged_info = Context::get('logged_info');
989 989
 
990
-		if(!$vars->editor_sequence) return new Object(-1, 'msg_invalid_request');
990
+		if (!$vars->editor_sequence) return new Object(-1, 'msg_invalid_request');
991 991
 
992 992
 		$upload_target_srl = $_SESSION['upload_info'][$vars->editor_sequence]->upload_target_srl;
993 993
 
994 994
 		$oFileModel = getModel('file');
995 995
 		$file_info = $oFileModel->getFile($vars->file_srl);
996 996
 
997
-		if(!$file_info) return new Object(-1, 'msg_not_founded');
997
+		if (!$file_info) return new Object(-1, 'msg_not_founded');
998 998
 
999
-		if(!$this->manager && !$file_info->member_srl === $logged_info->member_srl) return new Object(-1, 'msg_not_permitted');
999
+		if (!$this->manager && !$file_info->member_srl === $logged_info->member_srl) return new Object(-1, 'msg_not_permitted');
1000 1000
 
1001
-		$args =  new stdClass();
1001
+		$args = new stdClass();
1002 1002
 		$args->file_srl = $vars->file_srl;
1003 1003
 		$args->upload_target_srl = $upload_target_srl;
1004 1004
 
@@ -1007,18 +1007,18 @@  discard block
 block discarded – undo
1007 1007
 		
1008 1008
 		$args->cover_image = 'N';
1009 1009
 		$output = executeQuery('file.updateClearCoverImage', $args);
1010
-		if(!$output->toBool())
1010
+		if (!$output->toBool())
1011 1011
 		{
1012 1012
 				$oDB->rollback();
1013 1013
 				return $output;
1014 1014
 		}
1015 1015
 
1016
-		if($file_info->cover_image != 'Y')
1016
+		if ($file_info->cover_image != 'Y')
1017 1017
 		{
1018 1018
 
1019 1019
 			$args->cover_image = 'Y';
1020 1020
 			$output = executeQuery('file.updateCoverImage', $args);
1021
-			if(!$output->toBool())
1021
+			if (!$output->toBool())
1022 1022
 			{
1023 1023
 				$oDB->rollback();
1024 1024
 				return $output;
@@ -1028,7 +1028,7 @@  discard block
 block discarded – undo
1028 1028
 
1029 1029
 		$oDB->commit();
1030 1030
 
1031
-		$this->add('is_cover',$args->cover_image);
1031
+		$this->add('is_cover', $args->cover_image);
1032 1032
 
1033 1033
 		// 썸네일 삭제
1034 1034
 		$thumbnail_path = sprintf('files/thumbnails/%s', getNumberingPath($upload_target_srl, 3));
@@ -1054,9 +1054,9 @@  discard block
 block discarded – undo
1054 1054
 		$fileConfig = $oModuleModel->getModulePartConfig('file', $obj->originModuleSrl);
1055 1055
 
1056 1056
 		$oModuleController = getController('module');
1057
-		if(is_array($obj->moduleSrlList))
1057
+		if (is_array($obj->moduleSrlList))
1058 1058
 		{
1059
-			foreach($obj->moduleSrlList AS $key=>$moduleSrl)
1059
+			foreach ($obj->moduleSrlList AS $key=>$moduleSrl)
1060 1060
 			{
1061 1061
 				$oModuleController->insertModulePartConfig('file', $moduleSrl, $fileConfig);
1062 1062
 			}
Please login to merge, or discard this patch.
Braces   +229 added lines, -95 removed lines patch added patch discarded remove patch
@@ -29,20 +29,30 @@  discard block
 block discarded – undo
29 29
 		$file_info = $_FILES['Filedata'];
30 30
 
31 31
 		// An error appears if not a normally uploaded file
32
-		if(!is_uploaded_file($file_info['tmp_name'])) exit();
32
+		if(!is_uploaded_file($file_info['tmp_name'])) {
33
+			exit();
34
+		}
33 35
 
34 36
 		// Basic variables setting
35 37
 		$oFileModel = getModel('file');
36 38
 		$editor_sequence = Context::get('editor_sequence');
37 39
 		$upload_target_srl = intval(Context::get('uploadTargetSrl'));
38
-		if(!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl'));
40
+		if(!$upload_target_srl) {
41
+			$upload_target_srl = intval(Context::get('upload_target_srl'));
42
+		}
39 43
 		$module_srl = $this->module_srl;
40 44
 		// Exit a session if there is neither upload permission nor information
41
-		if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit();
45
+		if(!$_SESSION['upload_info'][$editor_sequence]->enabled) {
46
+			exit();
47
+		}
42 48
 		// Extract from session information if upload_target_srl is not specified
43
-		if(!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
49
+		if(!$upload_target_srl) {
50
+			$upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
51
+		}
44 52
 		// Create if upload_target_srl is not defined in the session information
45
-		if(!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence();
53
+		if(!$upload_target_srl) {
54
+			$_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence();
55
+		}
46 56
 
47 57
 		$output = $this->insertFile($file_info, $module_srl, $upload_target_srl);
48 58
 		Context::setResponseMethod('JSON');
@@ -52,7 +62,9 @@  discard block
 block discarded – undo
52 62
 		$this->add('source_filename',$output->get('source_filename'));
53 63
 		$this->add('download_url',$output->get('uploaded_filename'));
54 64
 		$this->add('upload_target_srl',$output->get('upload_target_srl'));
55
-		if($output->error != '0') $this->stop($output->message);
65
+		if($output->error != '0') {
66
+			$this->stop($output->message);
67
+		}
56 68
 	}
57 69
 
58 70
 	/**
@@ -67,14 +79,22 @@  discard block
 block discarded – undo
67 79
 		$callback = Context::get('callback');
68 80
 		$module_srl = $this->module_srl;
69 81
 		$upload_target_srl = intval(Context::get('uploadTargetSrl'));
70
-		if(!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl'));
82
+		if(!$upload_target_srl) {
83
+			$upload_target_srl = intval(Context::get('upload_target_srl'));
84
+		}
71 85
 
72 86
 		// Exit a session if there is neither upload permission nor information
73
-		if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit();
87
+		if(!$_SESSION['upload_info'][$editor_sequence]->enabled) {
88
+			exit();
89
+		}
74 90
 		// Extract from session information if upload_target_srl is not specified
75
-		if(!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
91
+		if(!$upload_target_srl) {
92
+			$upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
93
+		}
76 94
 		// Create if upload_target_srl is not defined in the session information
77
-		if(!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence();
95
+		if(!$upload_target_srl) {
96
+			$_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence();
97
+		}
78 98
 
79 99
 		// Delete and then attempt to re-upload if file_srl is requested
80 100
 		$file_srl = Context::get('file_srl');
@@ -129,15 +149,16 @@  discard block
 block discarded – undo
129 149
 		$source_src = $fileInfo->uploaded_filename;
130 150
 		$output_src = $source_src . '.resized' . strrchr($source_src,'.');
131 151
 
132
-		if(!$height) $height = $width-1;
152
+		if(!$height) {
153
+			$height = $width-1;
154
+		}
133 155
 
134 156
 		if(FileHandler::createImageFile($source_src,$output_src,$width,$height,'','ratio'))
135 157
 		{
136 158
 			$output = new stdClass();
137 159
 			$output->info = getimagesize($output_src);
138 160
 			$output->src = $output_src;
139
-		}
140
-		else
161
+		} else
141 162
 		{
142 163
 			return new Object(-1,'msg_invalid_request');
143 164
 		}
@@ -180,7 +201,9 @@  discard block
 block discarded – undo
180 201
 	{
181 202
 		$oFileModel = getModel('file');
182 203
 
183
-		if(isset($this->grant->access) && $this->grant->access !== true) return new Object(-1, 'msg_not_permitted');
204
+		if(isset($this->grant->access) && $this->grant->access !== true) {
205
+			return new Object(-1, 'msg_not_permitted');
206
+		}
184 207
 
185 208
 		$file_srl = Context::get('file_srl');
186 209
 		$sid = Context::get('sid');
@@ -189,9 +212,13 @@  discard block
 block discarded – undo
189 212
 		$columnList = array('file_srl', 'sid', 'isvalid', 'source_filename', 'module_srl', 'uploaded_filename', 'file_size', 'member_srl', 'upload_target_srl', 'upload_target_type');
190 213
 		$file_obj = $oFileModel->getFile($file_srl, $columnList);
191 214
 		// If the requested file information is incorrect, an error that file cannot be found appears
192
-		if($file_obj->file_srl!=$file_srl || $file_obj->sid!=$sid) return $this->stop('msg_file_not_found');
215
+		if($file_obj->file_srl!=$file_srl || $file_obj->sid!=$sid) {
216
+			return $this->stop('msg_file_not_found');
217
+		}
193 218
 		// Notify that file download is not allowed when standing-by(Only a top-administrator is permitted)
194
-		if($logged_info->is_admin != 'Y' && $file_obj->isvalid!='Y') return $this->stop('msg_not_permitted_download');
219
+		if($logged_info->is_admin != 'Y' && $file_obj->isvalid!='Y') {
220
+			return $this->stop('msg_not_permitted_download');
221
+		}
195 222
 		// File name
196 223
 		$filename = $file_obj->source_filename;
197 224
 		$file_module_config = $oFileModel->getFileModuleConfig($file_obj->module_srl);
@@ -203,7 +230,9 @@  discard block
 block discarded – undo
203 230
 			{
204 231
 				$allow_outlink_format_array = array();
205 232
 				$allow_outlink_format_array = explode(',', $file_module_config->allow_outlink_format);
206
-				if(!is_array($allow_outlink_format_array)) $allow_outlink_format_array[0] = $file_module_config->allow_outlink_format;
233
+				if(!is_array($allow_outlink_format_array)) {
234
+					$allow_outlink_format_array[0] = $file_module_config->allow_outlink_format;
235
+				}
207 236
 
208 237
 				foreach($allow_outlink_format_array as $val)
209 238
 				{
@@ -225,7 +254,9 @@  discard block
 block discarded – undo
225 254
 					{
226 255
 						$allow_outlink_site_array = array();
227 256
 						$allow_outlink_site_array = explode("\n", $file_module_config->allow_outlink_site);
228
-						if(!is_array($allow_outlink_site_array)) $allow_outlink_site_array[0] = $file_module_config->allow_outlink_site;
257
+						if(!is_array($allow_outlink_site_array)) {
258
+							$allow_outlink_site_array[0] = $file_module_config->allow_outlink_site;
259
+						}
229 260
 
230 261
 						foreach($allow_outlink_site_array as $val)
231 262
 						{
@@ -237,23 +268,29 @@  discard block
 block discarded – undo
237 268
 							}
238 269
 						}
239 270
 					}
271
+				} else {
272
+					$file_module_config->allow_outlink = 'Y';
240 273
 				}
241
-				else $file_module_config->allow_outlink = 'Y';
242 274
 			}
243
-			if($file_module_config->allow_outlink != 'Y') return $this->stop('msg_not_allowed_outlink');
275
+			if($file_module_config->allow_outlink != 'Y') {
276
+				return $this->stop('msg_not_allowed_outlink');
277
+			}
244 278
 		}
245 279
 
246 280
 		// Check if a permission for file download is granted
247 281
 		$downloadGrantCount = 0;
248 282
 		if(is_array($file_module_config->download_grant))
249 283
 		{
250
-			foreach($file_module_config->download_grant AS $value)
251
-				if($value) $downloadGrantCount++;
284
+			foreach($file_module_config->download_grant AS $value) {
285
+							if($value) $downloadGrantCount++;
286
+			}
252 287
 		}
253 288
 
254 289
 		if(is_array($file_module_config->download_grant) && $downloadGrantCount>0)
255 290
 		{
256
-			if(!Context::get('is_logged')) return $this->stop('msg_not_permitted_download');
291
+			if(!Context::get('is_logged')) {
292
+				return $this->stop('msg_not_permitted_download');
293
+			}
257 294
 			$logged_info = Context::get('logged_info');
258 295
 			if($logged_info->is_admin != 'Y')
259 296
 			{
@@ -276,13 +313,17 @@  discard block
 block discarded – undo
276 313
 							break;
277 314
 						}
278 315
 					}
279
-					if(!$is_permitted) return $this->stop('msg_not_permitted_download');
316
+					if(!$is_permitted) {
317
+						return $this->stop('msg_not_permitted_download');
318
+					}
280 319
 				}
281 320
 			}
282 321
 		}
283 322
 		// Call a trigger (before)
284 323
 		$output = ModuleHandler::triggerCall('file.downloadFile', 'before', $file_obj);
285
-		if(!$output->toBool()) return $this->stop(($output->message)?$output->message:'msg_not_permitted_download');
324
+		if(!$output->toBool()) {
325
+			return $this->stop(($output->message)?$output->message:'msg_not_permitted_download');
326
+		}
286 327
 
287 328
 
288 329
 		// 다운로드 후 (가상)
@@ -306,16 +347,23 @@  discard block
 block discarded – undo
306 347
 		$oFileModel = getModel('file');
307 348
 		$file_srl = Context::get('file_srl');
308 349
 		$file_key = Context::get('file_key');
309
-		if(strstr($_SERVER['HTTP_USER_AGENT'], "Android")) $is_android = true;
350
+		if(strstr($_SERVER['HTTP_USER_AGENT'], "Android")) {
351
+			$is_android = true;
352
+		}
310 353
 
311
-		if($is_android && $_SESSION['__XE_FILE_KEY_AND__'][$file_srl]) $session_key = '__XE_FILE_KEY_AND__';
312
-		else $session_key = '__XE_FILE_KEY__';
354
+		if($is_android && $_SESSION['__XE_FILE_KEY_AND__'][$file_srl]) {
355
+			$session_key = '__XE_FILE_KEY_AND__';
356
+		} else {
357
+			$session_key = '__XE_FILE_KEY__';
358
+		}
313 359
 		$columnList = array('source_filename', 'uploaded_filename', 'file_size');
314 360
 		$file_obj = $oFileModel->getFile($file_srl, $columnList);
315 361
 
316 362
 		$uploaded_filename = $file_obj->uploaded_filename;
317 363
 
318
-		if(!file_exists($uploaded_filename)) return $this->stop('msg_file_not_found');
364
+		if(!file_exists($uploaded_filename)) {
365
+			return $this->stop('msg_file_not_found');
366
+		}
319 367
 
320 368
 		if(!$file_key || $_SESSION[$session_key][$file_srl] != $file_key)
321 369
 		{
@@ -331,29 +379,27 @@  discard block
 block discarded – undo
331 379
 			if($is_android && preg_match('#\bwv\b|(?:Version|Browser)/\d+#', $_SERVER['HTTP_USER_AGENT']))
332 380
 			{
333 381
 				$filename_param = 'filename="' . $filename . '"';
334
-			}
335
-			else
382
+			} else
336 383
 			{
337 384
 				$filename_param = "filename*=UTF-8''" . rawurlencode($filename) . '; filename="' . rawurlencode($filename) . '"';
338 385
 			}
339
-		}
340
-		elseif(preg_match('#(?:Firefox|Safari|Trident)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 6)
386
+		} elseif(preg_match('#(?:Firefox|Safari|Trident)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 6)
341 387
 		{
342 388
 			$filename_param = "filename*=UTF-8''" . rawurlencode($filename) . '; filename="' . rawurlencode($filename) . '"';
343
-		}
344
-		elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE)
389
+		} elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE)
345 390
 		{
346 391
 			$filename = rawurlencode($filename);
347 392
 			$filename_param = 'filename="' . preg_replace('/\./', '%2e', $filename, substr_count($filename, '.') - 1) . '"';
348
-		}
349
-		else
393
+		} else
350 394
 		{
351 395
 			$filename_param = 'filename="' . $filename . '"';
352 396
 		}
353 397
 
354 398
 		if($is_android)
355 399
 		{
356
-			if($_SESSION['__XE_FILE_KEY__'][$file_srl]) $_SESSION['__XE_FILE_KEY_AND__'][$file_srl] = $file_key;
400
+			if($_SESSION['__XE_FILE_KEY__'][$file_srl]) {
401
+				$_SESSION['__XE_FILE_KEY_AND__'][$file_srl] = $file_key;
402
+			}
357 403
 		}
358 404
 
359 405
 		unset($_SESSION[$session_key][$file_srl]);
@@ -361,7 +407,9 @@  discard block
 block discarded – undo
361 407
 		Context::close();
362 408
 
363 409
 		$fp = fopen($uploaded_filename, 'rb');
364
-		if(!$fp) return $this->stop('msg_file_not_found');
410
+		if(!$fp) {
411
+			return $this->stop('msg_file_not_found');
412
+		}
365 413
 
366 414
 		header("Cache-Control: ");
367 415
 		header("Pragma: ");
@@ -375,10 +423,11 @@  discard block
 block discarded – undo
375 423
 		// if file size is lager than 10MB, use fread function (#18675748)
376 424
 		if($file_size > 1024 * 1024)
377 425
 		{
378
-			while(!feof($fp)) echo fread($fp, 1024);
426
+			while(!feof($fp)) {
427
+				echo fread($fp, 1024);
428
+			}
379 429
 			fclose($fp);
380
-		}
381
-		else
430
+		} else
382 431
 		{
383 432
 			fpassthru($fp);
384 433
 		}
@@ -397,9 +446,13 @@  discard block
 block discarded – undo
397 446
 		$editor_sequence = Context::get('editor_sequence');
398 447
 		$file_srl = Context::get('file_srl');
399 448
 		$file_srls = Context::get('file_srls');
400
-		if($file_srls) $file_srl = $file_srls;
449
+		if($file_srls) {
450
+			$file_srl = $file_srls;
451
+		}
401 452
 		// Exit a session if there is neither upload permission nor information
402
-		if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit();
453
+		if(!$_SESSION['upload_info'][$editor_sequence]->enabled) {
454
+			exit();
455
+		}
403 456
 
404 457
 		$upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
405 458
 
@@ -407,26 +460,38 @@  discard block
 block discarded – undo
407 460
 		$oFileModel = getModel('file');
408 461
 
409 462
 		$srls = explode(',',$file_srl);
410
-		if(!count($srls)) return;
463
+		if(!count($srls)) {
464
+			return;
465
+		}
411 466
 
412 467
 		for($i=0;$i<count($srls);$i++)
413 468
 		{
414 469
 			$srl = (int)$srls[$i];
415
-			if(!$srl) continue;
470
+			if(!$srl) {
471
+				continue;
472
+			}
416 473
 
417 474
 			$args = new stdClass;
418 475
 			$args->file_srl = $srl;
419 476
 			$output = executeQuery('file.getFile', $args);
420
-			if(!$output->toBool()) continue;
477
+			if(!$output->toBool()) {
478
+				continue;
479
+			}
421 480
 
422 481
 			$file_info = $output->data;
423
-			if(!$file_info) continue;
482
+			if(!$file_info) {
483
+				continue;
484
+			}
424 485
 
425 486
 			$file_grant = $oFileModel->getFileGrant($file_info, $logged_info);
426 487
 
427
-			if(!$file_grant->is_deletable) continue;
488
+			if(!$file_grant->is_deletable) {
489
+				continue;
490
+			}
428 491
 
429
-			if($upload_target_srl && $file_srl) $output = $this->deleteFile($file_srl);
492
+			if($upload_target_srl && $file_srl) {
493
+				$output = $this->deleteFile($file_srl);
494
+			}
430 495
 		}
431 496
 	}
432 497
 
@@ -437,7 +502,9 @@  discard block
 block discarded – undo
437 502
 	 */
438 503
 	function procFileGetList()
439 504
 	{
440
-		if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted');
505
+		if(!Context::get('is_logged')) {
506
+			return new Object(-1,'msg_not_permitted');
507
+		}
441 508
 
442 509
 		$oModuleModel = getModel('module');
443 510
 
@@ -448,26 +515,32 @@  discard block
 block discarded – undo
448 515
 		}
449 516
 
450 517
 		$fileSrls = Context::get('file_srls');
451
-		if($fileSrls) $fileSrlList = explode(',', $fileSrls);
518
+		if($fileSrls) {
519
+			$fileSrlList = explode(',', $fileSrls);
520
+		}
452 521
 
453 522
 		global $lang;
454 523
 		if(count($fileSrlList) > 0)
455 524
 		{
456 525
 			$oFileModel = getModel('file');
457 526
 			$fileList = $oFileModel->getFile($fileSrlList);
458
-			if(!is_array($fileList)) $fileList = array($fileList);
527
+			if(!is_array($fileList)) {
528
+				$fileList = array($fileList);
529
+			}
459 530
 
460 531
 			if(is_array($fileList))
461 532
 			{
462 533
 				foreach($fileList AS $key=>$value)
463 534
 				{
464 535
 					$value->human_file_size = FileHandler::filesize($value->file_size);
465
-					if($value->isvalid=='Y') $value->validName = $lang->is_valid;
466
-					else $value->validName = $lang->is_stand_by;
536
+					if($value->isvalid=='Y') {
537
+						$value->validName = $lang->is_valid;
538
+					} else {
539
+						$value->validName = $lang->is_stand_by;
540
+					}
467 541
 				}
468 542
 			}
469
-		}
470
-		else
543
+		} else
471 544
 		{
472 545
 			$fileList = array();
473 546
 			$this->setMessage($lang->no_files);
@@ -484,7 +557,9 @@  discard block
 block discarded – undo
484 557
 	function triggerCheckAttached(&$obj)
485 558
 	{
486 559
 		$document_srl = $obj->document_srl;
487
-		if(!$document_srl) return new Object();
560
+		if(!$document_srl) {
561
+			return new Object();
562
+		}
488 563
 		// Get numbers of attachments
489 564
 		$oFileModel = getModel('file');
490 565
 		$obj->uploaded_count = $oFileModel->getFilesCount($document_srl);
@@ -501,10 +576,14 @@  discard block
 block discarded – undo
501 576
 	function triggerAttachFiles(&$obj)
502 577
 	{
503 578
 		$document_srl = $obj->document_srl;
504
-		if(!$document_srl) return new Object();
579
+		if(!$document_srl) {
580
+			return new Object();
581
+		}
505 582
 
506 583
 		$output = $this->setFilesValid($document_srl);
507
-		if(!$output->toBool()) return $output;
584
+		if(!$output->toBool()) {
585
+			return $output;
586
+		}
508 587
 
509 588
 		return new Object();
510 589
 	}
@@ -518,7 +597,9 @@  discard block
 block discarded – undo
518 597
 	function triggerDeleteAttached(&$obj)
519 598
 	{
520 599
 		$document_srl = $obj->document_srl;
521
-		if(!$document_srl) return new Object();
600
+		if(!$document_srl) {
601
+			return new Object();
602
+		}
522 603
 
523 604
 		$output = $this->deleteFiles($document_srl);
524 605
 		return $output;
@@ -533,7 +614,9 @@  discard block
 block discarded – undo
533 614
 	function triggerCommentCheckAttached(&$obj)
534 615
 	{
535 616
 		$comment_srl = $obj->comment_srl;
536
-		if(!$comment_srl) return new Object();
617
+		if(!$comment_srl) {
618
+			return new Object();
619
+		}
537 620
 		// Get numbers of attachments
538 621
 		$oFileModel = getModel('file');
539 622
 		$obj->uploaded_count = $oFileModel->getFilesCount($comment_srl);
@@ -551,10 +634,14 @@  discard block
 block discarded – undo
551 634
 	{
552 635
 		$comment_srl = $obj->comment_srl;
553 636
 		$uploaded_count = $obj->uploaded_count;
554
-		if(!$comment_srl || !$uploaded_count) return new Object();
637
+		if(!$comment_srl || !$uploaded_count) {
638
+			return new Object();
639
+		}
555 640
 
556 641
 		$output = $this->setFilesValid($comment_srl);
557
-		if(!$output->toBool()) return $output;
642
+		if(!$output->toBool()) {
643
+			return $output;
644
+		}
558 645
 
559 646
 		return new Object();
560 647
 	}
@@ -568,9 +655,13 @@  discard block
 block discarded – undo
568 655
 	function triggerCommentDeleteAttached(&$obj)
569 656
 	{
570 657
 		$comment_srl = $obj->comment_srl;
571
-		if(!$comment_srl) return new Object();
658
+		if(!$comment_srl) {
659
+			return new Object();
660
+		}
572 661
 
573
-		if($obj->isMoveToTrash) return new Object();
662
+		if($obj->isMoveToTrash) {
663
+			return new Object();
664
+		}
574 665
 
575 666
 		$output = $this->deleteFiles($comment_srl);
576 667
 		return $output;
@@ -585,7 +676,9 @@  discard block
 block discarded – undo
585 676
 	function triggerDeleteModuleFiles(&$obj)
586 677
 	{
587 678
 		$module_srl = $obj->module_srl;
588
-		if(!$module_srl) return new Object();
679
+		if(!$module_srl) {
680
+			return new Object();
681
+		}
589 682
 
590 683
 		$oFileController = getAdminController('file');
591 684
 		return $oFileController->deleteModuleFiles($module_srl);
@@ -660,7 +753,9 @@  discard block
 block discarded – undo
660 753
 		$trigger_obj->module_srl = $module_srl;
661 754
 		$trigger_obj->upload_target_srl = $upload_target_srl;
662 755
 		$output = ModuleHandler::triggerCall('file.insertFile', 'before', $trigger_obj);
663
-		if(!$output->toBool()) return $output;
756
+		if(!$output->toBool()) {
757
+			return $output;
758
+		}
664 759
 
665 760
 		// A workaround for Firefox upload bug
666 761
 		if(preg_match('/^=\?UTF-8\?B\?(.+)\?=$/i', $file_info['name'], $match))
@@ -698,13 +793,17 @@  discard block
 block discarded – undo
698 793
 				$allowed_filesize = $config->allowed_filesize * 1024 * 1024;
699 794
 				$allowed_attach_size = $config->allowed_attach_size * 1024 * 1024;
700 795
 				// An error appears if file size exceeds a limit
701
-				if($allowed_filesize < filesize($file_info['tmp_name'])) return new Object(-1, 'msg_exceeds_limit_size');
796
+				if($allowed_filesize < filesize($file_info['tmp_name'])) {
797
+					return new Object(-1, 'msg_exceeds_limit_size');
798
+				}
702 799
 				// Get total file size of all attachements (from DB)
703 800
 				$size_args = new stdClass;
704 801
 				$size_args->upload_target_srl = $upload_target_srl;
705 802
 				$output = executeQuery('file.getAttachedFileSize', $size_args);
706 803
 				$attached_size = (int)$output->data->attached_size + filesize($file_info['tmp_name']);
707
-				if($attached_size > $allowed_attach_size) return new Object(-1, 'msg_exceeds_limit_size');
804
+				if($attached_size > $allowed_attach_size) {
805
+					return new Object(-1, 'msg_exceeds_limit_size');
806
+				}
708 807
 			}
709 808
 		}
710 809
 
@@ -734,18 +833,21 @@  discard block
 block discarded – undo
734 833
 				$idx++;
735 834
 			}
736 835
 			$direct_download = 'Y';
737
-		}
738
-		else
836
+		} else
739 837
 		{
740 838
 			$path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl,3));
741 839
 			$filename = $path.$random->createSecureSalt(32, 'hex');
742 840
 			$direct_download = 'N';
743 841
 		}
744 842
 		// Create a directory
745
-		if(!FileHandler::makeDir($path)) return new Object(-1,'msg_not_permitted_create');
843
+		if(!FileHandler::makeDir($path)) {
844
+			return new Object(-1,'msg_not_permitted_create');
845
+		}
746 846
 
747 847
 		// Check uploaded file
748
-		if(!checkUploadedFile($file_info['tmp_name']))  return new Object(-1,'msg_file_upload_error');
848
+		if(!checkUploadedFile($file_info['tmp_name'])) {
849
+			return new Object(-1,'msg_file_upload_error');
850
+		}
749 851
 
750 852
 		// Get random number generator
751 853
 		$random = new Password();
@@ -759,13 +861,14 @@  discard block
 block discarded – undo
759 861
 				$filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext;
760 862
 				@copy($file_info['tmp_name'], $filename);
761 863
 			}
762
-		}
763
-		else
864
+		} else
764 865
 		{
765 866
 			if(!@move_uploaded_file($file_info['tmp_name'], $filename))
766 867
 			{
767 868
 				$filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext;
768
-				if(!@move_uploaded_file($file_info['tmp_name'], $filename))  return new Object(-1,'msg_file_upload_error');
869
+				if(!@move_uploaded_file($file_info['tmp_name'], $filename)) {
870
+					return new Object(-1,'msg_file_upload_error');
871
+				}
769 872
 			}
770 873
 		}
771 874
 		// Get member information
@@ -786,10 +889,14 @@  discard block
 block discarded – undo
786 889
 		$args->sid = $random->createSecureSalt(32, 'hex');
787 890
 
788 891
 		$output = executeQuery('file.insertFile', $args);
789
-		if(!$output->toBool()) return $output;
892
+		if(!$output->toBool()) {
893
+			return $output;
894
+		}
790 895
 		// Call a trigger (after)
791 896
 		$trigger_output = ModuleHandler::triggerCall('file.insertFile', 'after', $args);
792
-		if(!$trigger_output->toBool()) return $trigger_output;
897
+		if(!$trigger_output->toBool()) {
898
+			return $trigger_output;
899
+		}
793 900
 
794 901
 		$_SESSION['__XE_UPLOADING_FILES_INFO__'][$args->file_srl] = true;
795 902
 
@@ -832,10 +939,14 @@  discard block
 block discarded – undo
832 939
 	 */
833 940
 	function deleteFile($file_srl)
834 941
 	{
835
-		if(!$file_srl) return;
942
+		if(!$file_srl) {
943
+			return;
944
+		}
836 945
 
837 946
 		$srls = (is_array($file_srl)) ? $file_srl : explode(',', $file_srl);
838
-		if(!count($srls)) return;
947
+		if(!count($srls)) {
948
+			return;
949
+		}
839 950
 
840 951
 		$oDocumentController = getController('document');
841 952
 		$documentSrlList = array();
@@ -870,15 +981,21 @@  discard block
 block discarded – undo
870 981
 			// Call a trigger (before)
871 982
 			$trigger_obj = $output->data;
872 983
 			$output = ModuleHandler::triggerCall('file.deleteFile', 'before', $trigger_obj);
873
-			if(!$output->toBool()) return $output;
984
+			if(!$output->toBool()) {
985
+				return $output;
986
+			}
874 987
 
875 988
 			// Remove from the DB
876 989
 			$output = executeQuery('file.deleteFile', $args);
877
-			if(!$output->toBool()) return $output;
990
+			if(!$output->toBool()) {
991
+				return $output;
992
+			}
878 993
 
879 994
 			// Call a trigger (after)
880 995
 			$trigger_output = ModuleHandler::triggerCall('file.deleteFile', 'after', $trigger_obj);
881
-			if(!$trigger_output->toBool()) return $trigger_output;
996
+			if(!$trigger_output->toBool()) {
997
+				return $trigger_output;
998
+			}
882 999
 
883 1000
 			// If successfully deleted, remove the file
884 1001
 			FileHandler::removeFile($uploaded_filename);
@@ -902,7 +1019,9 @@  discard block
 block discarded – undo
902 1019
 		$columnList = array('file_srl', 'uploaded_filename', 'module_srl');
903 1020
 		$file_list = $oFileModel->getFiles($upload_target_srl, $columnList);
904 1021
 		// Success returned if no attachement exists
905
-		if(!is_array($file_list)||!count($file_list)) return new Object();
1022
+		if(!is_array($file_list)||!count($file_list)) {
1023
+			return new Object();
1024
+		}
906 1025
 
907 1026
 		// Delete the file
908 1027
 		$path = array();
@@ -913,14 +1032,18 @@  discard block
 block discarded – undo
913 1032
 
914 1033
 			$uploaded_filename = $file_list[$i]->uploaded_filename;
915 1034
 			$path_info = pathinfo($uploaded_filename);
916
-			if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname'];
1035
+			if(!in_array($path_info['dirname'], $path)) {
1036
+				$path[] = $path_info['dirname'];
1037
+			}
917 1038
 		}
918 1039
 
919 1040
 		// Remove from the DB
920 1041
 		$args = new stdClass();
921 1042
 		$args->upload_target_srl = $upload_target_srl;
922 1043
 		$output = executeQuery('file.deleteFiles', $args);
923
-		if(!$output->toBool()) return $output;
1044
+		if(!$output->toBool()) {
1045
+			return $output;
1046
+		}
924 1047
 		
925 1048
 		// Remove a file directory of the document
926 1049
 		for($i=0, $c=count($path); $i<$c; $i++)
@@ -941,11 +1064,15 @@  discard block
 block discarded – undo
941 1064
 	 */
942 1065
 	function moveFile($source_srl, $target_module_srl, $target_srl)
943 1066
 	{
944
-		if($source_srl == $target_srl) return;
1067
+		if($source_srl == $target_srl) {
1068
+			return;
1069
+		}
945 1070
 
946 1071
 		$oFileModel = getModel('file');
947 1072
 		$file_list = $oFileModel->getFiles($source_srl);
948
-		if(!$file_list) return;
1073
+		if(!$file_list) {
1074
+			return;
1075
+		}
949 1076
 
950 1077
 		$file_count = count($file_list);
951 1078
  
@@ -959,15 +1086,16 @@  discard block
 block discarded – undo
959 1086
 			{
960 1087
 				$path = sprintf("./files/attach/images/%s/%s/", $target_module_srl,$target_srl);
961 1088
 				$new_file = $path.$file_info->source_filename;
962
-			}
963
-			else
1089
+			} else
964 1090
 			{
965 1091
 				$path = sprintf("./files/attach/binaries/%s/%s/", $target_module_srl, $target_srl);
966 1092
 				$random = new Password();
967 1093
 				$new_file = $path.$random->createSecureSalt(32, 'hex');
968 1094
 			}
969 1095
 			// Pass if a target document to move is same
970
-			if($old_file == $new_file) continue;
1096
+			if($old_file == $new_file) {
1097
+				continue;
1098
+			}
971 1099
 			// Create a directory
972 1100
 			FileHandler::makeDir($path);
973 1101
 			// Move the file
@@ -987,16 +1115,22 @@  discard block
 block discarded – undo
987 1115
 		$vars = Context::getRequestVars();
988 1116
 		$logged_info = Context::get('logged_info');
989 1117
 
990
-		if(!$vars->editor_sequence) return new Object(-1, 'msg_invalid_request');
1118
+		if(!$vars->editor_sequence) {
1119
+			return new Object(-1, 'msg_invalid_request');
1120
+		}
991 1121
 
992 1122
 		$upload_target_srl = $_SESSION['upload_info'][$vars->editor_sequence]->upload_target_srl;
993 1123
 
994 1124
 		$oFileModel = getModel('file');
995 1125
 		$file_info = $oFileModel->getFile($vars->file_srl);
996 1126
 
997
-		if(!$file_info) return new Object(-1, 'msg_not_founded');
1127
+		if(!$file_info) {
1128
+			return new Object(-1, 'msg_not_founded');
1129
+		}
998 1130
 
999
-		if(!$this->manager && !$file_info->member_srl === $logged_info->member_srl) return new Object(-1, 'msg_not_permitted');
1131
+		if(!$this->manager && !$file_info->member_srl === $logged_info->member_srl) {
1132
+			return new Object(-1, 'msg_not_permitted');
1133
+		}
1000 1134
 
1001 1135
 		$args =  new stdClass();
1002 1136
 		$args->file_srl = $vars->file_srl;
Please login to merge, or discard this patch.
modules/importer/extract.class.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -216,6 +216,7 @@  discard block
 block discarded – undo
216 216
 
217 217
 	/**
218 218
 	 * Merge item
219
+	 * @param string $filename
219 220
 	 * @return void
220 221
 	 */
221 222
 	function mergeItems($filename)
@@ -310,6 +311,11 @@  discard block
 block discarded – undo
310 311
 		return $this->key;
311 312
 	}
312 313
 
314
+	/**
315
+	 * @param string $str
316
+	 *
317
+	 * @return string
318
+	 */
313 319
 	function _addTagCRTail($str) {
314 320
 		$str = preg_replace('/<\/([^>]*)></i', "</$1>\r\n<", $str);
315 321
 		return $str;
Please login to merge, or discard this patch.
Braces   +33 added lines, -16 removed lines patch added patch discarded remove patch
@@ -99,7 +99,9 @@  discard block
 block discarded – undo
99 99
 		$this->filename = $filename;
100 100
 
101 101
 		$this->startTag = $startTag;
102
-		if($endTag) $this->endTag = $endTag;
102
+		if($endTag) {
103
+			$this->endTag = $endTag;
104
+		}
103 105
 		$this->itemStartTag = $itemTag;
104 106
 		$this->itemEndTag = $itemEndTag;
105 107
 
@@ -108,7 +110,9 @@  discard block
 block discarded – undo
108 110
 		$this->cache_path = './files/cache/importer/'.$this->key;
109 111
 		$this->cache_index_file = $this->cache_path.'/index';
110 112
 
111
-		if(!is_dir($this->cache_path)) FileHandler::makeDir($this->cache_path);
113
+		if(!is_dir($this->cache_path)) {
114
+			FileHandler::makeDir($this->cache_path);
115
+		}
112 116
 
113 117
 		return $this->openFile();
114 118
 	}
@@ -124,18 +128,25 @@  discard block
 block discarded – undo
124 128
 		// If local file
125 129
 		if(strncasecmp('http://', $this->filename, 7) !== 0)
126 130
 		{
127
-			if(!file_exists($this->filename)) return new Object(-1,'msg_no_xml_file');
131
+			if(!file_exists($this->filename)) {
132
+				return new Object(-1,'msg_no_xml_file');
133
+			}
128 134
 			$this->fd = fopen($this->filename,"r");
129 135
 			// If remote file
130
-		}
131
-		else
136
+		} else
132 137
 		{
133 138
 			$url_info = parse_url($this->filename);
134
-			if(!$url_info['port']) $url_info['port'] = 80;
135
-			if(!$url_info['path']) $url_info['path'] = '/';
139
+			if(!$url_info['port']) {
140
+				$url_info['port'] = 80;
141
+			}
142
+			if(!$url_info['path']) {
143
+				$url_info['path'] = '/';
144
+			}
136 145
 
137 146
 			$this->fd = @fsockopen($url_info['host'], $url_info['port']);
138
-			if(!$this->fd) return new Object(-1,'msg_no_xml_file');
147
+			if(!$this->fd) {
148
+				return new Object(-1,'msg_no_xml_file');
149
+			}
139 150
 			// If the file name contains Korean, do urlencode(iconv required)
140 151
 			$path = $url_info['path'];
141 152
 			if(preg_match('/[\xEA-\xED][\x80-\xFF]{2}/', $path)&&function_exists('iconv'))
@@ -155,9 +166,13 @@  discard block
 block discarded – undo
155 166
 			while(!feof($this->fd))
156 167
 			{
157 168
 				$buff .= $str = fgets($this->fd, 1024);
158
-				if(!trim($str)) break;
169
+				if(!trim($str)) {
170
+					break;
171
+				}
172
+			}
173
+			if(preg_match('/404 Not Found/i',$buff)) {
174
+				return new Object(-1,'msg_no_xml_file');
159 175
 			}
160
-			if(preg_match('/404 Not Found/i',$buff)) return new Object(-1,'msg_no_xml_file');
161 176
 		}
162 177
 
163 178
 		if($this->startTag)
@@ -174,8 +189,7 @@  discard block
 block discarded – undo
174 189
 					break;
175 190
 				}
176 191
 			}
177
-		}
178
-		else
192
+		} else
179 193
 		{
180 194
 			$this->isStarted = true;
181 195
 			$this->isFinished = false;
@@ -231,7 +245,9 @@  discard block
 block discarded – undo
231 245
 		while(!feof($index_fd))
232 246
 		{
233 247
 			$target_file = trim(fgets($index_fd,1024));
234
-			if(!file_exists($target_file)) continue;
248
+			if(!file_exists($target_file)) {
249
+				continue;
250
+			}
235 251
 			$buff = FileHandler::readFile($target_file);
236 252
 			fwrite($fd, FileHandler::readFile($target_file));
237 253
 
@@ -247,7 +263,9 @@  discard block
 block discarded – undo
247 263
 	 */
248 264
 	function getItem()
249 265
 	{
250
-		if($this->isFinished()) return;
266
+		if($this->isFinished()) {
267
+			return;
268
+		}
251 269
 
252 270
 		while(!feof($this->fd))
253 271
 		{
@@ -257,8 +275,7 @@  discard block
 block discarded – undo
257 275
 				$this->buff = substr($this->buff, $startPos);
258 276
 				$this->buff = preg_replace("/\>/",">\r\n",$this->buff,1);
259 277
 				break;
260
-			}
261
-			elseif($this->endTag)
278
+			} elseif($this->endTag)
262 279
 			{
263 280
 				$endPos = strpos($this->buff, $this->endTag);
264 281
 				if($endPos !== false)
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 		$this->filename = $filename;
100 100
 
101 101
 		$this->startTag = $startTag;
102
-		if($endTag) $this->endTag = $endTag;
102
+		if ($endTag) $this->endTag = $endTag;
103 103
 		$this->itemStartTag = $itemTag;
104 104
 		$this->itemEndTag = $itemEndTag;
105 105
 
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 		$this->cache_path = './files/cache/importer/'.$this->key;
109 109
 		$this->cache_index_file = $this->cache_path.'/index';
110 110
 
111
-		if(!is_dir($this->cache_path)) FileHandler::makeDir($this->cache_path);
111
+		if (!is_dir($this->cache_path)) FileHandler::makeDir($this->cache_path);
112 112
 
113 113
 		return $this->openFile();
114 114
 	}
@@ -120,55 +120,55 @@  discard block
 block discarded – undo
120 120
 	function openFile()
121 121
 	{
122 122
 		FileHandler::removeFile($this->cache_index_file);
123
-		$this->index_fd = fopen($this->cache_index_file,"a");
123
+		$this->index_fd = fopen($this->cache_index_file, "a");
124 124
 		// If local file
125
-		if(strncasecmp('http://', $this->filename, 7) !== 0)
125
+		if (strncasecmp('http://', $this->filename, 7) !== 0)
126 126
 		{
127
-			if(!file_exists($this->filename)) return new Object(-1,'msg_no_xml_file');
128
-			$this->fd = fopen($this->filename,"r");
127
+			if (!file_exists($this->filename)) return new Object(-1, 'msg_no_xml_file');
128
+			$this->fd = fopen($this->filename, "r");
129 129
 			// If remote file
130 130
 		}
131 131
 		else
132 132
 		{
133 133
 			$url_info = parse_url($this->filename);
134
-			if(!$url_info['port']) $url_info['port'] = 80;
135
-			if(!$url_info['path']) $url_info['path'] = '/';
134
+			if (!$url_info['port']) $url_info['port'] = 80;
135
+			if (!$url_info['path']) $url_info['path'] = '/';
136 136
 
137 137
 			$this->fd = @fsockopen($url_info['host'], $url_info['port']);
138
-			if(!$this->fd) return new Object(-1,'msg_no_xml_file');
138
+			if (!$this->fd) return new Object(-1, 'msg_no_xml_file');
139 139
 			// If the file name contains Korean, do urlencode(iconv required)
140 140
 			$path = $url_info['path'];
141
-			if(preg_match('/[\xEA-\xED][\x80-\xFF]{2}/', $path)&&function_exists('iconv'))
141
+			if (preg_match('/[\xEA-\xED][\x80-\xFF]{2}/', $path) && function_exists('iconv'))
142 142
 			{
143
-				$path_list = explode('/',$path);
143
+				$path_list = explode('/', $path);
144 144
 				$cnt = count($path_list);
145
-				$filename = $path_list[$cnt-1];
146
-				$filename = urlencode(iconv("UTF-8","EUC-KR",$filename));
147
-				$path_list[$cnt-1] = $filename;
148
-				$path = implode('/',$path_list);
145
+				$filename = $path_list[$cnt - 1];
146
+				$filename = urlencode(iconv("UTF-8", "EUC-KR", $filename));
147
+				$path_list[$cnt - 1] = $filename;
148
+				$path = implode('/', $path_list);
149 149
 				$url_info['path'] = $path;
150 150
 			}
151 151
 
152 152
 			$header = sprintf("GET %s?%s HTTP/1.0\r\nHost: %s\r\nReferer: %s://%s\r\nConnection: Close\r\n\r\n", $url_info['path'], $url_info['query'], $url_info['host'], $url_info['scheme'], $url_info['host']);
153 153
 			@fwrite($this->fd, $header);
154 154
 			$buff = '';
155
-			while(!feof($this->fd))
155
+			while (!feof($this->fd))
156 156
 			{
157 157
 				$buff .= $str = fgets($this->fd, 1024);
158
-				if(!trim($str)) break;
158
+				if (!trim($str)) break;
159 159
 			}
160
-			if(preg_match('/404 Not Found/i',$buff)) return new Object(-1,'msg_no_xml_file');
160
+			if (preg_match('/404 Not Found/i', $buff)) return new Object(-1, 'msg_no_xml_file');
161 161
 		}
162 162
 
163
-		if($this->startTag)
163
+		if ($this->startTag)
164 164
 		{
165
-			while(!feof($this->fd))
165
+			while (!feof($this->fd))
166 166
 			{
167 167
 				$str = fgets($this->fd, 1024);
168 168
 				$pos = strpos($str, $this->startTag);
169
-				if($pos !== false)
169
+				if ($pos !== false)
170 170
 				{
171
-					$this->buff = substr($this->buff, $pos+strlen($this->startTag));
171
+					$this->buff = substr($this->buff, $pos + strlen($this->startTag));
172 172
 					$this->isStarted = true;
173 173
 					$this->isFinished = false;
174 174
 					break;
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 	{
209 209
 		FileHandler::removeDir($this->cache_path.$this->key);
210 210
 		$this->index = 0;
211
-		while(!$this->isFinished())
211
+		while (!$this->isFinished())
212 212
 		{
213 213
 			$this->getItem();
214 214
 		}
@@ -224,14 +224,14 @@  discard block
 block discarded – undo
224 224
 
225 225
 		$filename = sprintf('%s/%s', $this->cache_path, $filename);
226 226
 
227
-		$index_fd = fopen($this->cache_index_file,"r");
228
-		$fd = fopen($filename,'w');
227
+		$index_fd = fopen($this->cache_index_file, "r");
228
+		$fd = fopen($filename, 'w');
229 229
 
230 230
 		fwrite($fd, '<items>');
231
-		while(!feof($index_fd))
231
+		while (!feof($index_fd))
232 232
 		{
233
-			$target_file = trim(fgets($index_fd,1024));
234
-			if(!file_exists($target_file)) continue;
233
+			$target_file = trim(fgets($index_fd, 1024));
234
+			if (!file_exists($target_file)) continue;
235 235
 			$buff = FileHandler::readFile($target_file);
236 236
 			fwrite($fd, FileHandler::readFile($target_file));
237 237
 
@@ -247,21 +247,21 @@  discard block
 block discarded – undo
247 247
 	 */
248 248
 	function getItem()
249 249
 	{
250
-		if($this->isFinished()) return;
250
+		if ($this->isFinished()) return;
251 251
 
252
-		while(!feof($this->fd))
252
+		while (!feof($this->fd))
253 253
 		{
254 254
 			$startPos = strpos($this->buff, $this->itemStartTag);
255
-			if($startPos !== false)
255
+			if ($startPos !== false)
256 256
 			{
257 257
 				$this->buff = substr($this->buff, $startPos);
258
-				$this->buff = preg_replace("/\>/",">\r\n",$this->buff,1);
258
+				$this->buff = preg_replace("/\>/", ">\r\n", $this->buff, 1);
259 259
 				break;
260 260
 			}
261
-			elseif($this->endTag)
261
+			elseif ($this->endTag)
262 262
 			{
263 263
 				$endPos = strpos($this->buff, $this->endTag);
264
-				if($endPos !== false)
264
+				if ($endPos !== false)
265 265
 				{
266 266
 					$this->closeFile();
267 267
 					return;
@@ -271,21 +271,21 @@  discard block
 block discarded – undo
271 271
 		}
272 272
 
273 273
 		$startPos = strpos($this->buff, $this->itemStartTag);
274
-		if($startPos === false)
274
+		if ($startPos === false)
275 275
 		{
276 276
 			$this->closeFile();
277 277
 			return;
278 278
 		}
279 279
 
280
-		$filename = sprintf('%s/%s.xml',$this->cache_path, $this->index++);
280
+		$filename = sprintf('%s/%s.xml', $this->cache_path, $this->index++);
281 281
 		fwrite($this->index_fd, $filename."\r\n");
282 282
 
283
-		$fd = fopen($filename,'w');
283
+		$fd = fopen($filename, 'w');
284 284
 
285
-		while(!feof($this->fd))
285
+		while (!feof($this->fd))
286 286
 		{
287 287
 			$endPos = strpos($this->buff, $this->itemEndTag);
288
-			if($endPos !== false)
288
+			if ($endPos !== false)
289 289
 			{
290 290
 				$endPos += strlen($this->itemEndTag);
291 291
 				$buff = substr($this->buff, 0, $endPos);
Please login to merge, or discard this patch.
modules/importer/importer.admin.controller.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -276,7 +276,7 @@
 block discarded – undo
276 276
 
277 277
 	/**
278 278
 	 * Migrate data after completing xml file extraction
279
-	 * @return void
279
+	 * @return Object|null
280 280
 	 */
281 281
 	function procImporterAdminImport()
282 282
 	{
Please login to merge, or discard this patch.
Braces   +256 added lines, -111 removed lines patch added patch discarded remove patch
@@ -55,24 +55,29 @@  discard block
 block discarded – undo
55 55
 					{
56 56
 						$isExists = 'true';
57 57
 						$type = 'XML';
58
-						if(stristr($str, 'tattertools')) $type = 'TTXML';
58
+						if(stristr($str, 'tattertools')) {
59
+							$type = 'TTXML';
60
+						}
59 61
 
60 62
 						$this->add('type', $type);
61 63
 					}
62 64
 					fclose($fp);
63 65
 					$resultMessage = $lang->found_xml_file;
66
+				} else {
67
+					$resultMessage = $lang->cannot_url_file;
64 68
 				}
65
-				else $resultMessage = $lang->cannot_url_file;
69
+			} else {
70
+				$resultMessage = $lang->cannot_allow_fopen_in_phpini;
66 71
 			}
67
-			else $resultMessage = $lang->cannot_allow_fopen_in_phpini;
68 72
 
69 73
 			$this->add('exists', $isExists);
70
-		}
71
-		else
74
+		} else
72 75
 		{
73 76
 			$realPath = FileHandler::getRealPath($filename);
74 77
 
75
-			if(file_exists($realPath) && is_file($realPath)) $isExists = 'true';
78
+			if(file_exists($realPath) && is_file($realPath)) {
79
+				$isExists = 'true';
80
+			}
76 81
 			$this->add('exists', $isExists);
77 82
 
78 83
 			if($isExists == 'true')
@@ -81,13 +86,16 @@  discard block
 block discarded – undo
81 86
 
82 87
 				$fp = fopen($realPath, "r");
83 88
 				$str = fgets($fp, 100);
84
-				if(stristr($str, 'tattertools')) $type = 'TTXML';
89
+				if(stristr($str, 'tattertools')) {
90
+					$type = 'TTXML';
91
+				}
85 92
 				fclose($fp);
86 93
 
87 94
 				$this->add('type', $type);
88 95
 				$resultMessage = $lang->found_xml_file;
96
+			} else {
97
+				$resultMessage = $lang->not_found_xml_file;
89 98
 			}
90
-			else $resultMessage = $lang->not_found_xml_file;
91 99
 		}
92 100
 		$this->add('result_message', $resultMessage);
93 101
 	}
@@ -112,8 +120,7 @@  discard block
 block discarded – undo
112 120
 		{
113 121
 			$output = executeQuery('importer.updateDocumentSync'.$postFix);
114 122
 			$output = executeQuery('importer.updateCommentSync'.$postFix);
115
-		}
116
-		else
123
+		} else
117 124
 		{
118 125
 			$output = executeQueryArray ('importer.getDocumentMemberSrlWithUserID'.$postFix);
119 126
 			if(is_array ($output->data) && count ($output->data))
@@ -129,8 +136,7 @@  discard block
 block discarded – undo
129 136
 					if($tmp->toBool () === true)
130 137
 					{
131 138
 						$success_count++;
132
-					}
133
-					else
139
+					} else
134 140
 					{
135 141
 						$error_count++;
136 142
 					}
@@ -152,8 +158,7 @@  discard block
 block discarded – undo
152 158
 					if($tmp->toBool () === true)
153 159
 					{
154 160
 						$success_count++;
155
-					}
156
-					else
161
+					} else
157 162
 					{
158 163
 						$error_count++;
159 164
 					}
@@ -182,11 +187,15 @@  discard block
 block discarded – undo
182 187
 		{
183 188
 			case 'member' :
184 189
 				$output = $oExtract->set($xml_file,'<members ', '</members>', '<member>', '</member>');
185
-				if($output->toBool()) $oExtract->saveItems();
190
+				if($output->toBool()) {
191
+					$oExtract->saveItems();
192
+				}
186 193
 				break;
187 194
 			case 'message' :
188 195
 				$output = $oExtract->set($xml_file,'<messages ', '</messages>', '<message>','</message>');
189
-				if($output->toBool()) $oExtract->saveItems();
196
+				if($output->toBool()) {
197
+					$oExtract->saveItems();
198
+				}
190 199
 				break;
191 200
 			case 'ttxml' :
192 201
 				// Category information
@@ -204,8 +213,12 @@  discard block
 block discarded – undo
204 213
 							$started = true;
205 214
 							$str = strstr($str, '<category>');
206 215
 						}
207
-						if(substr($str,0,strlen('<post ')) == '<post ') break;
208
-						if ($started) $buff .= $str;
216
+						if(substr($str,0,strlen('<post ')) == '<post ') {
217
+							break;
218
+						}
219
+						if ($started) {
220
+							$buff .= $str;
221
+						}
209 222
 					}
210 223
 					$buff = '<categories>'.$buff.'</categories>';
211 224
 					$oExtract->closeFile();
@@ -242,7 +255,9 @@  discard block
 block discarded – undo
242 255
 						FileHandler::writeFile($guestbook_filename, $buff);
243 256
 						// Individual items
244 257
 						$output = $oExtract->set($xml_file,'<blog', '</blog>', '<post ', '</post>');
245
-						if($output->toBool()) $oExtract->saveItems();
258
+						if($output->toBool()) {
259
+							$oExtract->saveItems();
260
+						}
246 261
 					}
247 262
 				}
248 263
 				break;
@@ -254,7 +269,9 @@  discard block
 block discarded – undo
254 269
 					$oExtract->mergeItems('category.xml');
255 270
 					// Get each item
256 271
 					$output = $oExtract->set($xml_file,'<posts ', '</posts>', '<post>', '</post>');
257
-					if($output->toBool()) $oExtract->saveItems();
272
+					if($output->toBool()) {
273
+						$oExtract->saveItems();
274
+					}
258 275
 				}
259 276
 				break;
260 277
 		}
@@ -291,19 +308,25 @@  discard block
 block discarded – undo
291 308
 		$this->unit_count = Context::get('unit_count');
292 309
 		// Check if an index file exists
293 310
 		$index_file = './files/cache/importer/'.$key.'/index';
294
-		if(!file_exists($index_file)) return new Object(-1, 'msg_invalid_xml_file');
311
+		if(!file_exists($index_file)) {
312
+			return new Object(-1, 'msg_invalid_xml_file');
313
+		}
295 314
 
296 315
 		switch($type)
297 316
 		{
298 317
 			case 'ttxml' :
299
-				if(!$target_module) return new Object(-1,'msg_invalid_request');
318
+				if(!$target_module) {
319
+					return new Object(-1,'msg_invalid_request');
320
+				}
300 321
 
301 322
 				$oModuleModel = getModel('module');
302 323
 				$columnList = array('module_srl', 'module');
303 324
 				$target_module_info = $oModuleModel->getModuleInfoByModuleSrl($target_module, $columnList);
304 325
 
305 326
 				$ttimporter = FileHandler::exists(_XE_PATH_ . 'modules/importer/ttimport.class.php');
306
-				if($ttimporter) require_once($ttimporter);
327
+				if($ttimporter) {
328
+					require_once($ttimporter);
329
+				}
307 330
 
308 331
 				$oTT = new ttimport();
309 332
 				$cur = $oTT->importModule($key, $cur, $index_file, $this->unit_count, $target_module, $guestbook_target_module, $user_id, $target_module_info->module);
@@ -316,7 +339,9 @@  discard block
 block discarded – undo
316 339
 				break;
317 340
 			case 'module' :
318 341
 				// Check if the target module exists
319
-				if(!$target_module) return new Object(-1,'msg_invalid_request');
342
+				if(!$target_module) {
343
+					return new Object(-1,'msg_invalid_request');
344
+				}
320 345
 				$cur = $this->importModule($key, $cur, $index_file, $target_module);
321 346
 				break;
322 347
 		}
@@ -331,8 +356,9 @@  discard block
 block discarded – undo
331 356
 		{
332 357
 			$this->setMessage( sprintf(Context::getLang('msg_import_finished'), $cur, $total) );
333 358
 			FileHandler::removeDir('./files/cache/importer/'.$key);
359
+		} else {
360
+			$this->setMessage( sprintf(Context::getLang('msg_importing'), $total, $cur) );
334 361
 		}
335
-		else $this->setMessage( sprintf(Context::getLang('msg_importing'), $total, $cur) );
336 362
 	}
337 363
 
338 364
 	/**
@@ -344,7 +370,9 @@  discard block
 block discarded – undo
344 370
 	 */
345 371
 	function importMember($key, $cur, $index_file)
346 372
 	{
347
-		if(!$cur) $cur = 0;
373
+		if(!$cur) {
374
+			$cur = 0;
375
+		}
348 376
 		// Create the xmlParser object
349 377
 		$oXmlParser = new XmlParser();
350 378
 		// Create objects for importing member information
@@ -359,24 +387,32 @@  discard block
 block discarded – undo
359 387
 		// Open an index file
360 388
 		$f = fopen($index_file,"r");
361 389
 		// Pass if already read
362
-		for($i=0;$i<$cur;$i++) fgets($f, 1024);
390
+		for($i=0;$i<$cur;$i++) {
391
+			fgets($f, 1024);
392
+		}
363 393
 		// Read by each line until the condition meets
364 394
 		for($idx=$cur;$idx<$cur+$this->unit_count;$idx++)
365 395
 		{
366
-			if(feof($f)) break;
396
+			if(feof($f)) {
397
+				break;
398
+			}
367 399
 			// Find a given location
368 400
 			$target_file = trim(fgets($f, 1024));
369 401
 			// Load and parse the file
370 402
 			$xmlObj = $oXmlParser->loadXmlFile($target_file);
371 403
 			FileHandler::removeFile($target_file);
372
-			if(!$xmlObj) continue;
404
+			if(!$xmlObj) {
405
+				continue;
406
+			}
373 407
 			// List Objects
374 408
 			$obj = null;
375 409
 			$obj->user_id = base64_decode($xmlObj->member->user_id->body);
376 410
 			$obj->password = base64_decode($xmlObj->member->password->body);
377 411
 			$obj->user_name = base64_decode($xmlObj->member->user_name->body);
378 412
 			$obj->nick_name = base64_decode($xmlObj->member->nick_name->body);
379
-			if(!$obj->user_name) $obj->user_name = $obj->nick_name;
413
+			if(!$obj->user_name) {
414
+				$obj->user_name = $obj->nick_name;
415
+			}
380 416
 			$obj->email = base64_decode($xmlObj->member->email->body);
381 417
 			$obj->homepage = base64_decode($xmlObj->member->homepage->body);
382 418
 			$obj->blog = base64_decode($xmlObj->member->blog->body);
@@ -394,22 +430,32 @@  discard block
 block discarded – undo
394 430
 			{
395 431
 				foreach($xmlObj->member->extra_vars as $key => $val)
396 432
 				{
397
-					if(in_array($key, array('node_name','attrs','body'))) continue;
433
+					if(in_array($key, array('node_name','attrs','body'))) {
434
+						continue;
435
+					}
398 436
 					$obj->extra_vars->{$key} = base64_decode($val->body);
399 437
 				}
400 438
 			}
401 439
 			// Create url for homepage and blog
402
-			if($obj->homepage && strncasecmp('http://', $obj->homepage, 7) !== 0 && strncasecmp('https://', $obj->homepage, 8) !== 0) $obj->homepage = 'http://'.$obj->homepage;
440
+			if($obj->homepage && strncasecmp('http://', $obj->homepage, 7) !== 0 && strncasecmp('https://', $obj->homepage, 8) !== 0) {
441
+				$obj->homepage = 'http://'.$obj->homepage;
442
+			}
403 443
 			// email address column
404 444
 			$obj->email_address = $obj->email;
405 445
 			list($obj->email_id, $obj->email_host) = explode('@', $obj->email);
406 446
 			// Set the mailing option
407
-			if($obj->allow_mailing!='Y') $obj->allow_mailing = 'N';
447
+			if($obj->allow_mailing!='Y') {
448
+				$obj->allow_mailing = 'N';
449
+			}
408 450
 			// Set the message option
409 451
 			$obj->allow_message = 'Y';
410
-			if(!in_array($obj->allow_message, array('Y','N','F'))) $obj->allow_message= 'Y';
452
+			if(!in_array($obj->allow_message, array('Y','N','F'))) {
453
+				$obj->allow_message= 'Y';
454
+			}
411 455
 			// Get member-join date if the last login time is not found
412
-			if(!$obj->last_login) $obj->last_login = $obj->regdate;
456
+			if(!$obj->last_login) {
457
+				$obj->last_login = $obj->regdate;
458
+			}
413 459
 			// Get a member_srl
414 460
 			$obj->member_srl = getNextSequence();
415 461
 			$obj->list_order = -1 * $obj->member_srl;
@@ -421,7 +467,9 @@  discard block
 block discarded – undo
421 467
 			$nick_args = new stdClass;
422 468
 			$nick_args->nick_name = $obj->nick_name;
423 469
 			$nick_output = executeQuery('member.getMemberSrl', $nick_args);
424
-			if(!$nick_output->toBool()) $obj->nick_name .= '_'.$obj->member_srl;
470
+			if(!$nick_output->toBool()) {
471
+				$obj->nick_name .= '_'.$obj->member_srl;
472
+			}
425 473
 			// Add a member
426 474
 			$output = executeQuery('member.insertMember', $obj);
427 475
 
@@ -477,7 +525,9 @@  discard block
 block discarded – undo
477 525
 					$signature_buff = sprintf('<?php if(!defined("__XE__")) exit();?>%s', $signature);
478 526
 
479 527
 					$target_path = sprintf('files/member_extra_info/signature/%s/', getNumberingPath($obj->member_srl));
480
-					if(!is_dir($target_path)) FileHandler::makeDir($target_path);
528
+					if(!is_dir($target_path)) {
529
+						FileHandler::makeDir($target_path);
530
+					}
481 531
 					$target_filename = sprintf('%s%d.signature.php', $target_path, $obj->member_srl);
482 532
 
483 533
 					FileHandler::writeFile($target_filename, $signature_buff);
@@ -499,23 +549,31 @@  discard block
 block discarded – undo
499 549
 	 */
500 550
 	function importMessage($key, $cur, $index_file)
501 551
 	{
502
-		if(!$cur) $cur = 0;
552
+		if(!$cur) {
553
+			$cur = 0;
554
+		}
503 555
 		// Create the xmlParser object
504 556
 		$oXmlParser = new XmlParser();
505 557
 		// Open an index file
506 558
 		$f = fopen($index_file,"r");
507 559
 		// Pass if already read
508
-		for($i=0;$i<$cur;$i++) fgets($f, 1024);
560
+		for($i=0;$i<$cur;$i++) {
561
+			fgets($f, 1024);
562
+		}
509 563
 		// Read each line until the condition meets
510 564
 		for($idx=$cur;$idx<$cur+$this->unit_count;$idx++)
511 565
 		{
512
-			if(feof($f)) break;
566
+			if(feof($f)) {
567
+				break;
568
+			}
513 569
 			// Find a location
514 570
 			$target_file = trim(fgets($f, 1024));
515 571
 			// Load and parse the file
516 572
 			$xmlObj = $oXmlParser->loadXmlFile($target_file);
517 573
 			FileHandler::removeFile($target_file);
518
-			if(!$xmlObj) continue;
574
+			if(!$xmlObj) {
575
+				continue;
576
+			}
519 577
 			// List objects
520 578
 			$obj = null;
521 579
 			$obj->receiver = base64_decode($xmlObj->message->receiver->body);
@@ -526,7 +584,9 @@  discard block
 block discarded – undo
526 584
 			$obj->regdate = base64_decode($xmlObj->message->regdate->body);
527 585
 			$obj->readed_date = base64_decode($xmlObj->message->readed_date->body);
528 586
 			// Get member_srl of sender/recipient (If not exists, pass)
529
-			if(!$obj->sender) continue;
587
+			if(!$obj->sender) {
588
+				continue;
589
+			}
530 590
 			$sender_args->user_id = $obj->sender;
531 591
 			$sender_output = executeQuery('member.getMemberInfo',$sender_args);
532 592
 			$sender_srl = $sender_output->data->member_srl;
@@ -537,10 +597,14 @@  discard block
 block discarded – undo
537 597
 				$sender_output = executeQuery('member.getMemberInfoByEmailAddress',$sender_args);
538 598
 				$sender_srl = $sender_output->data->member_srl;
539 599
 			}
540
-			if(!$sender_srl) continue;
600
+			if(!$sender_srl) {
601
+				continue;
602
+			}
541 603
 
542 604
 			$receiver_args->user_id = $obj->receiver;
543
-			if(!$obj->receiver) continue;
605
+			if(!$obj->receiver) {
606
+				continue;
607
+			}
544 608
 			$receiver_output = executeQuery('member.getMemberInfo',$receiver_args);
545 609
 			$receiver_srl = $receiver_output->data->member_srl;
546 610
 			if(!$receiver_srl)
@@ -550,7 +614,9 @@  discard block
 block discarded – undo
550 614
 				$receiver_output = executeQuery('member.getMemberInfoByEmailAddress',$receiver_args);
551 615
 				$receiver_srl = $receiver_output->data->member_srl;
552 616
 			}
553
-			if(!$receiver_srl) continue;
617
+			if(!$receiver_srl) {
618
+				continue;
619
+			}
554 620
 			// Message to save into sender's message box
555 621
 			$sender_args->sender_srl = $sender_srl;
556 622
 			$sender_args->receiver_srl = $receiver_srl;
@@ -571,7 +637,9 @@  discard block
 block discarded – undo
571 637
 				$receiver_args->message_srl = $sender_args->related_srl;
572 638
 				$receiver_args->list_order = $sender_args->related_srl*-1;
573 639
 				$receiver_args->sender_srl = $sender_srl;
574
-				if(!$receiver_args->sender_srl) $receiver_args->sender_srl = $receiver_srl;
640
+				if(!$receiver_args->sender_srl) {
641
+					$receiver_args->sender_srl = $receiver_srl;
642
+				}
575 643
 				$receiver_args->receiver_srl = $receiver_srl;
576 644
 				$receiver_args->message_type = 'R';
577 645
 				$receiver_args->title = $obj->title;
@@ -605,7 +673,9 @@  discard block
 block discarded – undo
605 673
 		$oDocumentModel = getModel('document');
606 674
 		$category_list = $category_titles = array();
607 675
 		$category_list = $oDocumentModel->getCategoryList($module_srl);
608
-		if(count($category_list)) foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl;
676
+		if(count($category_list)) {
677
+			foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl;
678
+		}
609 679
 		// Extract category information
610 680
 		$category_file = preg_replace('/index$/i', 'category.xml', $index_file);
611 681
 		if(file_exists($category_file))
@@ -618,12 +688,16 @@  discard block
 block discarded – undo
618 688
 			$categories = $xmlDoc->items->category;
619 689
 			if($categories)
620 690
 			{
621
-				if(!is_array($categories)) $categories = array($categories);
691
+				if(!is_array($categories)) {
692
+					$categories = array($categories);
693
+				}
622 694
 				$match_sequence = array();
623 695
 				foreach($categories as $k => $v)
624 696
 				{
625 697
 					$category = trim(base64_decode($v->body));
626
-					if(!$category || $category_titles[$category]) continue;
698
+					if(!$category || $category_titles[$category]) {
699
+						continue;
700
+					}
627 701
 
628 702
 					$sequence = $v->attrs->sequence;
629 703
 					$parent = $v->attrs->parent;
@@ -631,10 +705,14 @@  discard block
 block discarded – undo
631 705
 					$obj = null;
632 706
 					$obj->title = $category;
633 707
 					$obj->module_srl = $module_srl;
634
-					if($parent) $obj->parent_srl = $match_sequence[$parent];
708
+					if($parent) {
709
+						$obj->parent_srl = $match_sequence[$parent];
710
+					}
635 711
 
636 712
 					$output = $oDocumentController->insertCategory($obj);
637
-					if($output->toBool()) $match_sequence[$sequence] = $output->get('category_srl');
713
+					if($output->toBool()) {
714
+						$match_sequence[$sequence] = $output->get('category_srl');
715
+					}
638 716
 				}
639 717
 				$oDocumentController = getController('document');
640 718
 				$oDocumentController->makeCategoryFile($module_srl);
@@ -644,31 +722,45 @@  discard block
 block discarded – undo
644 722
 
645 723
 		$category_list = $category_titles = array();
646 724
 		$category_list = $oDocumentModel->getCategoryList($module_srl);
647
-		if(count($category_list)) foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl;
725
+		if(count($category_list)) {
726
+			foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl;
727
+		}
648 728
 
649 729
 		$ek_args->module_srl = $module_srl;
650 730
 		$output = executeQueryArray('document.getDocumentExtraKeys', $ek_args);
651 731
 		if($output->data)
652 732
 		{
653
-			foreach($output->data as $key => $val) $extra_keys[$val->eid] = true;
733
+			foreach($output->data as $key => $val) {
734
+				$extra_keys[$val->eid] = true;
735
+			}
654 736
 		}
655 737
 
656
-		if(!$cur) $cur = 0;
738
+		if(!$cur) {
739
+			$cur = 0;
740
+		}
657 741
 		// Open an index file
658 742
 		$f = fopen($index_file,"r");
659 743
 		// Pass if already read
660
-		for($i=0;$i<$cur;$i++) fgets($f, 1024);
744
+		for($i=0;$i<$cur;$i++) {
745
+			fgets($f, 1024);
746
+		}
661 747
 		// Read each line until the condition meets
662 748
 		for($idx=$cur;$idx<$cur+$this->unit_count;$idx++)
663 749
 		{
664
-			if(feof($f)) break;
750
+			if(feof($f)) {
751
+				break;
752
+			}
665 753
 			// Find a location
666 754
 			$target_file = trim(fgets($f, 1024));
667 755
 
668
-			if(!file_exists($target_file)) continue;
756
+			if(!file_exists($target_file)) {
757
+				continue;
758
+			}
669 759
 			// Importing data from now on
670 760
 			$fp = fopen($target_file,"r");
671
-			if(!$fp) continue;
761
+			if(!$fp) {
762
+				continue;
763
+			}
672 764
 
673 765
 			$obj = new stdClass;
674 766
 			$obj->module_srl = $module_srl;
@@ -688,38 +780,38 @@  discard block
 block discarded – undo
688 780
 				{
689 781
 					$started = true;
690 782
 					// Trackback inserted
691
-				}
692
-				else if(substr($str,0,11) == '<trackbacks')
783
+				} else if(substr($str,0,11) == '<trackbacks')
693 784
 				{
694 785
 					$obj->trackback_count = $this->importTrackbacks($fp, $module_srl, $obj->document_srl);
695 786
 					continue;
696 787
 					// Comments inserted
697
-				}
698
-				else if(substr($str,0,9) == '<comments')
788
+				} else if(substr($str,0,9) == '<comments')
699 789
 				{
700 790
 					$obj->comment_count = $this->importComments($fp, $module_srl, $obj->document_srl);
701 791
 					continue;
702 792
 					// Attachment inserted
703
-				}
704
-				else if(substr($str,0,9) == '<attaches')
793
+				} else if(substr($str,0,9) == '<attaches')
705 794
 				{
706 795
 					$obj->uploaded_count = $this->importAttaches($fp, $module_srl, $obj->document_srl, $files);
707 796
 					continue;
708 797
 					// When starting extra variabls
709
-				}
710
-				elseif(trim($str) == '<extra_vars>')
798
+				} elseif(trim($str) == '<extra_vars>')
711 799
 				{
712 800
 					$extra_vars = $this->importExtraVars($fp);
713 801
 					continue;
714 802
 				}
715 803
 
716
-				if($started) $buff[] = $str;
804
+				if($started) {
805
+					$buff[] = $str;
806
+				}
717 807
 			}
718 808
 
719 809
 			$xmlDoc = $this->oXmlParser->parse(implode('', $buff));
720 810
 
721 811
 			$category = base64_decode($xmlDoc->post->category->body);
722
-			if($category_titles[$category]) $obj->category_srl = $category_titles[$category];
812
+			if($category_titles[$category]) {
813
+				$obj->category_srl = $category_titles[$category];
814
+			}
723 815
 
724 816
 			$obj->member_srl = 0;
725 817
 
@@ -733,16 +825,22 @@  discard block
 block discarded – undo
733 825
 			$obj->password = base64_decode($xmlDoc->post->password->body);
734 826
 			$obj->user_name = base64_decode($xmlDoc->post->user_name->body);
735 827
 			$obj->nick_name = base64_decode($xmlDoc->post->nick_name->body);
736
-			if(!$obj->user_name) $obj->user_name = $obj->nick_name;
828
+			if(!$obj->user_name) {
829
+				$obj->user_name = $obj->nick_name;
830
+			}
737 831
 			$obj->user_id = base64_decode($xmlDoc->post->user_id->body);
738 832
 			$obj->email_address = base64_decode($xmlDoc->post->email->body);
739 833
 			$obj->homepage = base64_decode($xmlDoc->post->homepage->body);
740
-			if($obj->homepage && strncasecmp('http://', $obj->homepage, 7) !== 0 && strncasecmp('https://', $obj->homepage, 8) !== 0) $obj->homepage = 'http://'.$obj->homepage;
834
+			if($obj->homepage && strncasecmp('http://', $obj->homepage, 7) !== 0 && strncasecmp('https://', $obj->homepage, 8) !== 0) {
835
+				$obj->homepage = 'http://'.$obj->homepage;
836
+			}
741 837
 			$obj->tags = base64_decode($xmlDoc->post->tags->body);
742 838
 			$obj->regdate = base64_decode($xmlDoc->post->regdate->body);
743 839
 			$obj->last_update = base64_decode($xmlDoc->post->update->body);
744 840
 			$obj->last_updater = base64_decode($xmlDoc->post->last_updater->body);
745
-			if(!$obj->last_update) $obj->last_update = $obj->regdate;
841
+			if(!$obj->last_update) {
842
+				$obj->last_update = $obj->regdate;
843
+			}
746 844
 			$obj->ipaddress = base64_decode($xmlDoc->post->ipaddress->body);
747 845
 			$obj->list_order = $obj->update_order = $obj->document_srl*-1;
748 846
 			$obj->commentStatus = base64_decode($xmlDoc->post->allow_comment->body)!='N'?'ALLOW':'DENY';
@@ -773,7 +871,9 @@  discard block
 block discarded – undo
773 871
 					$args->document_srl = $obj->document_srl;
774 872
 					$args->tag = trim($tag_list[$i]);
775 873
 					$args->regdate = $obj->regdate;
776
-					if(!$args->tag) continue;
874
+					if(!$args->tag) {
875
+						continue;
876
+					}
777 877
 					$output = executeQuery('tag.insertTag', $args);
778 878
 				}
779 879
 
@@ -783,7 +883,9 @@  discard block
 block discarded – undo
783 883
 			{
784 884
 				foreach($extra_vars as $key => $val)
785 885
 				{
786
-					if(!$val->value) continue;
886
+					if(!$val->value) {
887
+						continue;
888
+					}
787 889
 					unset($e_args);
788 890
 					$e_args->module_srl = $module_srl;
789 891
 					$e_args->document_srl = $obj->document_srl;
@@ -816,7 +918,9 @@  discard block
 block discarded – undo
816 918
 
817 919
 		fclose($f);
818 920
 		// Sync category counts
819
-		if(count($category_list)) foreach($category_list as $key => $val) $oDocumentController->updateCategoryCount($module_srl, $val->category_srl);
921
+		if(count($category_list)) {
922
+			foreach($category_list as $key => $val) $oDocumentController->updateCategoryCount($module_srl, $val->category_srl);
923
+		}
820 924
 
821 925
 		return $idx-1;
822 926
 	}
@@ -838,11 +942,17 @@  discard block
 block discarded – undo
838 942
 		{
839 943
 			$str = fgets($fp, 1024);
840 944
 			// If </trackbacks> is, break
841
-			if(trim($str) == '</trackbacks>') break;
945
+			if(trim($str) == '</trackbacks>') {
946
+				break;
947
+			}
842 948
 			// If <trackback>, start importing
843
-			if(trim($str) == '<trackback>') $started = true;
949
+			if(trim($str) == '<trackback>') {
950
+				$started = true;
951
+			}
844 952
 
845
-			if($started) $buff .= $str;
953
+			if($started) {
954
+				$buff .= $str;
955
+			}
846 956
 			// If </trackback>, insert to the DB
847 957
 			if(trim($str) == '</trackback>')
848 958
 			{
@@ -860,7 +970,9 @@  discard block
 block discarded – undo
860 970
 				$obj->ipaddress = base64_decode($xmlDoc->trackback->ipaddress->body);
861 971
 				$obj->list_order = -1*$obj->trackback_srl;
862 972
 				$output = executeQuery('trackback.insertTrackback', $obj);
863
-				if($output->toBool()) $cnt++;
973
+				if($output->toBool()) {
974
+					$cnt++;
975
+				}
864 976
 
865 977
 				$buff = null;
866 978
 				$started = false;
@@ -888,7 +1000,9 @@  discard block
 block discarded – undo
888 1000
 		{
889 1001
 			$str = fgets($fp, 1024);
890 1002
 			// If </comments> is, break
891
-			if(trim($str) == '</comments>') break;
1003
+			if(trim($str) == '</comments>') {
1004
+				break;
1005
+			}
892 1006
 			// If <comment> is, start importing
893 1007
 			if(trim($str) == '<comment>')
894 1008
 			{
@@ -904,7 +1018,9 @@  discard block
 block discarded – undo
904 1018
 				continue;
905 1019
 			}
906 1020
 
907
-			if($started) $buff .= $str;
1021
+			if($started) {
1022
+				$buff .= $str;
1023
+			}
908 1024
 			// If </comment> is, insert to the DB
909 1025
 			if(trim($str) == '</comment>')
910 1026
 			{
@@ -916,8 +1032,11 @@  discard block
 block discarded – undo
916 1032
 
917 1033
 				$obj->module_srl = $module_srl;
918 1034
 
919
-				if($parent) $obj->parent_srl = $sequences[$parent];
920
-				else $obj->parent_srl = 0;
1035
+				if($parent) {
1036
+					$obj->parent_srl = $sequences[$parent];
1037
+				} else {
1038
+					$obj->parent_srl = 0;
1039
+				}
921 1040
 
922 1041
 				$obj->document_srl = $document_srl;
923 1042
 				$obj->is_secret = base64_decode($xmlDoc->comment->is_secret->body)=='Y'?'Y':'N';
@@ -928,14 +1047,18 @@  discard block
 block discarded – undo
928 1047
 				$obj->password = base64_decode($xmlDoc->comment->password->body);
929 1048
 				$obj->user_name =base64_decode($xmlDoc->comment->user_name->body);
930 1049
 				$obj->nick_name = base64_decode($xmlDoc->comment->nick_name->body);
931
-				if(!$obj->user_name) $obj->user_name = $obj->nick_name;
1050
+				if(!$obj->user_name) {
1051
+					$obj->user_name = $obj->nick_name;
1052
+				}
932 1053
 				$obj->user_id = base64_decode($xmlDoc->comment->user_id->body);
933 1054
 				$obj->member_srl = 0;
934 1055
 				$obj->email_address = base64_decode($xmlDoc->comment->email->body);
935 1056
 				$obj->homepage = base64_decode($xmlDoc->comment->homepage->body);
936 1057
 				$obj->regdate = base64_decode($xmlDoc->comment->regdate->body);
937 1058
 				$obj->last_update = base64_decode($xmlDoc->comment->update->body);
938
-				if(!$obj->last_update) $obj->last_update = $obj->regdate;
1059
+				if(!$obj->last_update) {
1060
+					$obj->last_update = $obj->regdate;
1061
+				}
939 1062
 				$obj->ipaddress = base64_decode($xmlDoc->comment->ipaddress->body);
940 1063
 				$obj->status = base64_decode($xmlDoc->comment->status->body)==''?'1':base64_decode($xmlDoc->comment->status->body);
941 1064
 				$obj->list_order = $obj->comment_srl*-1;
@@ -959,24 +1082,28 @@  discard block
 block discarded – undo
959 1082
 					$list_args->head = $list_args->arrange = $obj->comment_srl;
960 1083
 					$list_args->depth = 0;
961 1084
 					// Get parent_srl if parent comment exists
962
-				}
963
-				else
1085
+				} else
964 1086
 				{
965 1087
 					// Get parent comment infomation
966 1088
 					$parent_args->comment_srl = $obj->parent_srl;
967 1089
 					$parent_output = executeQuery('comment.getCommentListItem', $parent_args);
968 1090
 					// Return if parent comment doesn't exist
969
-					if(!$parent_output->toBool() || !$parent_output->data) continue;
1091
+					if(!$parent_output->toBool() || !$parent_output->data) {
1092
+						continue;
1093
+					}
970 1094
 					$parent = $parent_output->data;
971 1095
 
972 1096
 					$list_args->head = $parent->head;
973 1097
 					$list_args->depth = $parent->depth+1;
974
-					if($list_args->depth<2) $list_args->arrange = $obj->comment_srl;
975
-					else
1098
+					if($list_args->depth<2) {
1099
+						$list_args->arrange = $obj->comment_srl;
1100
+					} else
976 1101
 					{
977 1102
 						$list_args->arrange = $parent->arrange;
978 1103
 						$output = executeQuery('comment.updateCommentListArrange', $list_args);
979
-						if(!$output->toBool()) return $output;
1104
+						if(!$output->toBool()) {
1105
+							return $output;
1106
+						}
980 1107
 					}
981 1108
 				}
982 1109
 
@@ -984,7 +1111,9 @@  discard block
 block discarded – undo
984 1111
 				if($output->toBool())
985 1112
 				{
986 1113
 					$output = executeQuery('comment.insertComment', $obj);
987
-					if($output->toBool()) $cnt++;
1114
+					if($output->toBool()) {
1115
+						$cnt++;
1116
+					}
988 1117
 				}
989 1118
 
990 1119
 				$buff = null;
@@ -1014,7 +1143,9 @@  discard block
 block discarded – undo
1014 1143
 		{
1015 1144
 			$str = trim(fgets($fp, 1024));
1016 1145
 			// If it ends with </attaches>, break
1017
-			if(trim($str) == '</attaches>') break;
1146
+			if(trim($str) == '</attaches>') {
1147
+				break;
1148
+			}
1018 1149
 			// If it starts with <attach>, collect attachments
1019 1150
 			if(trim($str) == '<attach>')
1020 1151
 			{
@@ -1025,14 +1156,15 @@  discard block
 block discarded – undo
1025 1156
 				$started = true;
1026 1157
 				$buff = null;
1027 1158
 				// If it starts with <file>, handle the attachement in xml file
1028
-			}
1029
-			else if(trim($str) == '<file>')
1159
+			} else if(trim($str) == '<file>')
1030 1160
 			{
1031 1161
 				$file_obj->file = $this->saveTemporaryFile($fp);
1032 1162
 				continue;
1033 1163
 			}
1034 1164
 
1035
-			if($started) $buff .= $str;
1165
+			if($started) {
1166
+				$buff .= $str;
1167
+			}
1036 1168
 			// If it ends with </attach>, handle attachements
1037 1169
 			if(trim($str) == '</attach>')
1038 1170
 			{
@@ -1045,8 +1177,9 @@  discard block
 block discarded – undo
1045 1177
 				{
1046 1178
 					$url = base64_decode($xmlDoc->attach->url->body);
1047 1179
 					$path = base64_decode($xmlDoc->attach->path->body);
1048
-					if($path && file_exists($path)) $file_obj->file = $path;
1049
-					else
1180
+					if($path && file_exists($path)) {
1181
+						$file_obj->file = $path;
1182
+					} else
1050 1183
 					{
1051 1184
 						$file_obj->file = $this->getTmpFilename();
1052 1185
 						FileHandler::getRemoteFile($url, $file_obj->file);
@@ -1077,21 +1210,21 @@  discard block
 block discarded – undo
1077 1210
 						}
1078 1211
 
1079 1212
 						$file_obj->direct_download = 'Y';
1080
-					}
1081
-					else
1213
+					} else
1082 1214
 					{
1083 1215
 						$path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl,3));
1084 1216
 						$filename = $path.$random->createSecureSalt(32, 'hex');
1085 1217
 						$file_obj->direct_download = 'N';
1086 1218
 					}
1087 1219
 					// Create a directory
1088
-					if(!FileHandler::makeDir($path)) continue;
1220
+					if(!FileHandler::makeDir($path)) {
1221
+						continue;
1222
+					}
1089 1223
 
1090 1224
 					if(strncmp('./files/cache/importer/', $file_obj->file, 23) === 0)
1091 1225
 					{
1092 1226
 						FileHandler::rename($file_obj->file, $filename);
1093
-					}
1094
-					else
1227
+					} else
1095 1228
 					{
1096 1229
 						copy($file_obj->file, $filename);
1097 1230
 					}
@@ -1113,8 +1246,11 @@  discard block
 block discarded – undo
1113 1246
 							$uploaded_count++;
1114 1247
 							$tmp_obj = null;
1115 1248
 							$tmp_obj->source_filename = $file_obj->source_filename;
1116
-							if($file_obj->direct_download == 'Y') $files[$file_obj->source_filename] = $file_obj->uploaded_filename;
1117
-							else $files[$file_obj->source_filename] = getUrl('','module','file','act','procFileDownload','file_srl',$file_obj->file_srl,'sid',$file_obj->sid);
1249
+							if($file_obj->direct_download == 'Y') {
1250
+								$files[$file_obj->source_filename] = $file_obj->uploaded_filename;
1251
+							} else {
1252
+								$files[$file_obj->source_filename] = getUrl('','module','file','act','procFileDownload','file_srl',$file_obj->file_srl,'sid',$file_obj->sid);
1253
+							}
1118 1254
 						}
1119 1255
 					}
1120 1256
 				}
@@ -1132,7 +1268,9 @@  discard block
 block discarded – undo
1132 1268
 		$path = "./files/cache/importer";
1133 1269
 		FileHandler::makeDir($path);
1134 1270
 		$filename = sprintf("%s/%d", $path, rand(11111111,99999999));
1135
-		if(file_exists($filename)) $filename .= rand(111,999);
1271
+		if(file_exists($filename)) {
1272
+			$filename .= rand(111,999);
1273
+		}
1136 1274
 		return $filename;
1137 1275
 	}
1138 1276
 
@@ -1150,7 +1288,9 @@  discard block
 block discarded – undo
1150 1288
 		while(!feof($fp))
1151 1289
 		{
1152 1290
 			$str = trim(fgets($fp, 1024));
1153
-			if(trim($str) == '</file>') break;
1291
+			if(trim($str) == '</file>') {
1292
+				break;
1293
+			}
1154 1294
 
1155 1295
 			$buff .= $str;
1156 1296
 
@@ -1176,14 +1316,20 @@  discard block
 block discarded – undo
1176 1316
 		while(!feof($fp))
1177 1317
 		{
1178 1318
 			$buff .= $str = trim(fgets($fp, 1024));
1179
-			if(trim($str) == '</extra_vars>') break;
1319
+			if(trim($str) == '</extra_vars>') {
1320
+				break;
1321
+			}
1322
+		}
1323
+		if(!$buff) {
1324
+			return array();
1180 1325
 		}
1181
-		if(!$buff) return array();
1182 1326
 
1183 1327
 		$buff = '<extra_vars>'.$buff;
1184 1328
 		$oXmlParser = new XmlParser();
1185 1329
 		$xmlDoc = $this->oXmlParser->parse($buff);
1186
-		if(!count($xmlDoc->extra_vars->key)) return array();
1330
+		if(!count($xmlDoc->extra_vars->key)) {
1331
+			return array();
1332
+		}
1187 1333
 
1188 1334
 		$index = 1;
1189 1335
 		foreach($xmlDoc->extra_vars->key as $k => $v)
@@ -1196,8 +1342,7 @@  discard block
 block discarded – undo
1196 1342
 				$vobj->value = base64_decode($v->value->body);
1197 1343
 				$vobj->eid = base64_decode($v->eid->body);
1198 1344
 
1199
-			}
1200
-			else if($v->body)
1345
+			} else if($v->body)
1201 1346
 			{
1202 1347
 				$vobj->var_idx = $index;
1203 1348
 				$vobj->lang_code = Context::getLangType();
Please login to merge, or discard this patch.
Spacing   +217 added lines, -217 removed lines patch added patch discarded remove patch
@@ -43,19 +43,19 @@  discard block
 block discarded – undo
43 43
 		$filename = Context::get('filename');
44 44
 		$isExists = 'false';
45 45
 
46
-		if(strncasecmp('http://', $filename, 7) === 0)
46
+		if (strncasecmp('http://', $filename, 7) === 0)
47 47
 		{
48
-			if(ini_get('allow_url_fopen'))
48
+			if (ini_get('allow_url_fopen'))
49 49
 			{
50 50
 				$fp = @fopen($filename, "r");
51
-				if($fp)
51
+				if ($fp)
52 52
 				{
53 53
 					$str = fgets($fp, 100);
54
-					if(strlen($str) > 0)
54
+					if (strlen($str) > 0)
55 55
 					{
56 56
 						$isExists = 'true';
57 57
 						$type = 'XML';
58
-						if(stristr($str, 'tattertools')) $type = 'TTXML';
58
+						if (stristr($str, 'tattertools')) $type = 'TTXML';
59 59
 
60 60
 						$this->add('type', $type);
61 61
 					}
@@ -72,16 +72,16 @@  discard block
 block discarded – undo
72 72
 		{
73 73
 			$realPath = FileHandler::getRealPath($filename);
74 74
 
75
-			if(file_exists($realPath) && is_file($realPath)) $isExists = 'true';
75
+			if (file_exists($realPath) && is_file($realPath)) $isExists = 'true';
76 76
 			$this->add('exists', $isExists);
77 77
 
78
-			if($isExists == 'true')
78
+			if ($isExists == 'true')
79 79
 			{
80 80
 				$type = 'XML';
81 81
 
82 82
 				$fp = fopen($realPath, "r");
83 83
 				$str = fgets($fp, 100);
84
-				if(stristr($str, 'tattertools')) $type = 'TTXML';
84
+				if (stristr($str, 'tattertools')) $type = 'TTXML';
85 85
 				fclose($fp);
86 86
 
87 87
 				$this->add('type', $type);
@@ -107,16 +107,16 @@  discard block
 block discarded – undo
107 107
 
108 108
 		/* DBMS가 CUBRID인 경우 MySQL과 동일한 방법으로는 문서 및 댓글에 대한 사용자 정보를 동기화 할 수 없으므로 예외 처리 합니다.
109 109
 		   CUBRID를 사용하지 않는 경우에만 보편적인 기존 질의문을 사용합니다. */
110
-		$db_info = Context::getDBInfo ();
111
-		if($db_info->db_type != "cubrid")
110
+		$db_info = Context::getDBInfo();
111
+		if ($db_info->db_type != "cubrid")
112 112
 		{
113 113
 			$output = executeQuery('importer.updateDocumentSync'.$postFix);
114 114
 			$output = executeQuery('importer.updateCommentSync'.$postFix);
115 115
 		}
116 116
 		else
117 117
 		{
118
-			$output = executeQueryArray ('importer.getDocumentMemberSrlWithUserID'.$postFix);
119
-			if(is_array ($output->data) && count ($output->data))
118
+			$output = executeQueryArray('importer.getDocumentMemberSrlWithUserID'.$postFix);
119
+			if (is_array($output->data) && count($output->data))
120 120
 			{
121 121
 				$success_count = 0;
122 122
 				$error_count = 0;
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
 				{
126 126
 					$args->user_id = $val->user_id;
127 127
 					$args->member_srl = $val->member_srl;
128
-					$tmp = executeQuery ('importer.updateDocumentSyncForCUBRID'.$postFix, $args);
129
-					if($tmp->toBool () === true)
128
+					$tmp = executeQuery('importer.updateDocumentSyncForCUBRID'.$postFix, $args);
129
+					if ($tmp->toBool() === true)
130 130
 					{
131 131
 						$success_count++;
132 132
 					}
@@ -138,8 +138,8 @@  discard block
 block discarded – undo
138 138
 				}
139 139
 			} // documents section
140 140
 
141
-			$output = executeQueryArray ('importer.getCommentMemberSrlWithUserID'.$postFix);
142
-			if(is_array ($output->data) && count ($output->data))
141
+			$output = executeQueryArray('importer.getCommentMemberSrlWithUserID'.$postFix);
142
+			if (is_array($output->data) && count($output->data))
143 143
 			{
144 144
 				$success_count = 0;
145 145
 				$error_count = 0;
@@ -148,8 +148,8 @@  discard block
 block discarded – undo
148 148
 				{
149 149
 					$args->user_id = $val->user_id;
150 150
 					$args->member_srl = $val->member_srl;
151
-					$tmp = executeQuery ('importer.updateCommentSyncForCUBRID'.$postFix, $args);
152
-					if($tmp->toBool () === true)
151
+					$tmp = executeQuery('importer.updateCommentSyncForCUBRID'.$postFix, $args);
152
+					if ($tmp->toBool() === true)
153 153
 					{
154 154
 						$success_count++;
155 155
 					}
@@ -178,15 +178,15 @@  discard block
 block discarded – undo
178 178
 		// Extract and cache information from the xml file
179 179
 		$oExtract = new extract();
180 180
 
181
-		switch($type)
181
+		switch ($type)
182 182
 		{
183 183
 			case 'member' :
184
-				$output = $oExtract->set($xml_file,'<members ', '</members>', '<member>', '</member>');
185
-				if($output->toBool()) $oExtract->saveItems();
184
+				$output = $oExtract->set($xml_file, '<members ', '</members>', '<member>', '</member>');
185
+				if ($output->toBool()) $oExtract->saveItems();
186 186
 				break;
187 187
 			case 'message' :
188
-				$output = $oExtract->set($xml_file,'<messages ', '</messages>', '<message>','</message>');
189
-				if($output->toBool()) $oExtract->saveItems();
188
+				$output = $oExtract->set($xml_file, '<messages ', '</messages>', '<message>', '</message>');
189
+				if ($output->toBool()) $oExtract->saveItems();
190 190
 				break;
191 191
 			case 'ttxml' :
192 192
 				// Category information
@@ -199,12 +199,12 @@  discard block
 block discarded – undo
199 199
 					while (!feof($oExtract->fd))
200 200
 					{
201 201
 						$str = fgets($oExtract->fd, 1024);
202
-						if(strstr($str, '<category>'))
202
+						if (strstr($str, '<category>'))
203 203
 						{
204 204
 							$started = true;
205 205
 							$str = strstr($str, '<category>');
206 206
 						}
207
-						if(substr($str,0,strlen('<post ')) == '<post ') break;
207
+						if (substr($str, 0, strlen('<post ')) == '<post ') break;
208 208
 						if ($started) $buff .= $str;
209 209
 					}
210 210
 					$buff = '<categories>'.$buff.'</categories>';
@@ -214,22 +214,22 @@  discard block
 block discarded – undo
214 214
 
215 215
 					// Guestbook information
216 216
 					$output = $oExtract->set($xml_file, '', '', '', '');
217
-					if($output->toBool())
217
+					if ($output->toBool())
218 218
 					{
219 219
 						$started = false;
220 220
 						$buff = '';
221 221
 						while (!feof($oExtract->fd))
222 222
 						{
223 223
 							$str = fgets($oExtract->fd, 1024);
224
-							if(strstr($str, '<guestbook>'))
224
+							if (strstr($str, '<guestbook>'))
225 225
 							{
226 226
 								$started = true;
227 227
 								$str = strstr($str, '<guestbook>');
228 228
 							}
229
-							if($started)
229
+							if ($started)
230 230
 							{
231 231
 								$pos = strpos($str, '</guestbook>');
232
-								if($pos !== false)
232
+								if ($pos !== false)
233 233
 								{
234 234
 									$buff .= substr($str, 0, $pos + strlen('</guestbook>'));
235 235
 									break;
@@ -241,37 +241,37 @@  discard block
 block discarded – undo
241 241
 						$guestbook_filename = sprintf('%s/%s', $oExtract->cache_path, 'guestbook.xml');
242 242
 						FileHandler::writeFile($guestbook_filename, $buff);
243 243
 						// Individual items
244
-						$output = $oExtract->set($xml_file,'<blog', '</blog>', '<post ', '</post>');
245
-						if($output->toBool()) $oExtract->saveItems();
244
+						$output = $oExtract->set($xml_file, '<blog', '</blog>', '<post ', '</post>');
245
+						if ($output->toBool()) $oExtract->saveItems();
246 246
 					}
247 247
 				}
248 248
 				break;
249 249
 			default :
250 250
 				// First get category information
251
-				$output = $oExtract->set($xml_file,'<categories>', '</categories>', '<category','</category>');
252
-				if($output->toBool())
251
+				$output = $oExtract->set($xml_file, '<categories>', '</categories>', '<category', '</category>');
252
+				if ($output->toBool())
253 253
 				{
254 254
 					$oExtract->mergeItems('category.xml');
255 255
 					// Get each item
256
-					$output = $oExtract->set($xml_file,'<posts ', '</posts>', '<post>', '</post>');
257
-					if($output->toBool()) $oExtract->saveItems();
256
+					$output = $oExtract->set($xml_file, '<posts ', '</posts>', '<post>', '</post>');
257
+					if ($output->toBool()) $oExtract->saveItems();
258 258
 				}
259 259
 				break;
260 260
 		}
261 261
 
262
-		if(!$output->toBool())
262
+		if (!$output->toBool())
263 263
 		{
264
-			$this->add('error',0);
265
-			$this->add('status',-1);
264
+			$this->add('error', 0);
265
+			$this->add('status', -1);
266 266
 			$this->setMessage($output->getMessage());
267 267
 			return;
268 268
 		}
269 269
 		// Notify that all data completely extracted
270
-		$this->add('type',$type);
271
-		$this->add('total',$oExtract->getTotalCount());
272
-		$this->add('cur',0);
270
+		$this->add('type', $type);
271
+		$this->add('total', $oExtract->getTotalCount());
272
+		$this->add('cur', 0);
273 273
 		$this->add('key', $oExtract->getKey());
274
-		$this->add('status',0);
274
+		$this->add('status', 0);
275 275
 	}
276 276
 
277 277
 	/**
@@ -291,19 +291,19 @@  discard block
 block discarded – undo
291 291
 		$this->unit_count = Context::get('unit_count');
292 292
 		// Check if an index file exists
293 293
 		$index_file = './files/cache/importer/'.$key.'/index';
294
-		if(!file_exists($index_file)) return new Object(-1, 'msg_invalid_xml_file');
294
+		if (!file_exists($index_file)) return new Object(-1, 'msg_invalid_xml_file');
295 295
 
296
-		switch($type)
296
+		switch ($type)
297 297
 		{
298 298
 			case 'ttxml' :
299
-				if(!$target_module) return new Object(-1,'msg_invalid_request');
299
+				if (!$target_module) return new Object(-1, 'msg_invalid_request');
300 300
 
301 301
 				$oModuleModel = getModel('module');
302 302
 				$columnList = array('module_srl', 'module');
303 303
 				$target_module_info = $oModuleModel->getModuleInfoByModuleSrl($target_module, $columnList);
304 304
 
305
-				$ttimporter = FileHandler::exists(_XE_PATH_ . 'modules/importer/ttimport.class.php');
306
-				if($ttimporter) require_once($ttimporter);
305
+				$ttimporter = FileHandler::exists(_XE_PATH_.'modules/importer/ttimport.class.php');
306
+				if ($ttimporter) require_once($ttimporter);
307 307
 
308 308
 				$oTT = new ttimport();
309 309
 				$cur = $oTT->importModule($key, $cur, $index_file, $this->unit_count, $target_module, $guestbook_target_module, $user_id, $target_module_info->module);
@@ -316,23 +316,23 @@  discard block
 block discarded – undo
316 316
 				break;
317 317
 			case 'module' :
318 318
 				// Check if the target module exists
319
-				if(!$target_module) return new Object(-1,'msg_invalid_request');
319
+				if (!$target_module) return new Object(-1, 'msg_invalid_request');
320 320
 				$cur = $this->importModule($key, $cur, $index_file, $target_module);
321 321
 				break;
322 322
 		}
323 323
 		// Notify that all data completely extracted
324
-		$this->add('type',$type);
325
-		$this->add('total',$total);
326
-		$this->add('cur',$cur);
324
+		$this->add('type', $type);
325
+		$this->add('total', $total);
326
+		$this->add('cur', $cur);
327 327
 		$this->add('key', $key);
328 328
 		$this->add('target_module', $target_module);
329 329
 		// When completing, success message appears and remove the cache files
330
-		if($total <= $cur)
330
+		if ($total <= $cur)
331 331
 		{
332
-			$this->setMessage( sprintf(Context::getLang('msg_import_finished'), $cur, $total) );
332
+			$this->setMessage(sprintf(Context::getLang('msg_import_finished'), $cur, $total));
333 333
 			FileHandler::removeDir('./files/cache/importer/'.$key);
334 334
 		}
335
-		else $this->setMessage( sprintf(Context::getLang('msg_importing'), $total, $cur) );
335
+		else $this->setMessage(sprintf(Context::getLang('msg_importing'), $total, $cur));
336 336
 	}
337 337
 
338 338
 	/**
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 	 */
345 345
 	function importMember($key, $cur, $index_file)
346 346
 	{
347
-		if(!$cur) $cur = 0;
347
+		if (!$cur) $cur = 0;
348 348
 		// Create the xmlParser object
349 349
 		$oXmlParser = new XmlParser();
350 350
 		// Create objects for importing member information
@@ -357,30 +357,30 @@  discard block
 block discarded – undo
357 357
 		$oModuleModel = getModel('module');
358 358
 		$member_config = $oModuleModel->getModuleConfig('member');
359 359
 		// Open an index file
360
-		$f = fopen($index_file,"r");
360
+		$f = fopen($index_file, "r");
361 361
 		// Pass if already read
362
-		for($i=0;$i<$cur;$i++) fgets($f, 1024);
362
+		for ($i = 0; $i < $cur; $i++) fgets($f, 1024);
363 363
 		// Read by each line until the condition meets
364
-		for($idx=$cur;$idx<$cur+$this->unit_count;$idx++)
364
+		for ($idx = $cur; $idx < $cur + $this->unit_count; $idx++)
365 365
 		{
366
-			if(feof($f)) break;
366
+			if (feof($f)) break;
367 367
 			// Find a given location
368 368
 			$target_file = trim(fgets($f, 1024));
369 369
 			// Load and parse the file
370 370
 			$xmlObj = $oXmlParser->loadXmlFile($target_file);
371 371
 			FileHandler::removeFile($target_file);
372
-			if(!$xmlObj) continue;
372
+			if (!$xmlObj) continue;
373 373
 			// List Objects
374 374
 			$obj = null;
375 375
 			$obj->user_id = base64_decode($xmlObj->member->user_id->body);
376 376
 			$obj->password = base64_decode($xmlObj->member->password->body);
377 377
 			$obj->user_name = base64_decode($xmlObj->member->user_name->body);
378 378
 			$obj->nick_name = base64_decode($xmlObj->member->nick_name->body);
379
-			if(!$obj->user_name) $obj->user_name = $obj->nick_name;
379
+			if (!$obj->user_name) $obj->user_name = $obj->nick_name;
380 380
 			$obj->email = base64_decode($xmlObj->member->email->body);
381 381
 			$obj->homepage = base64_decode($xmlObj->member->homepage->body);
382 382
 			$obj->blog = base64_decode($xmlObj->member->blog->body);
383
-			$obj->birthday = substr(base64_decode($xmlObj->member->birthday->body),0,8);
383
+			$obj->birthday = substr(base64_decode($xmlObj->member->birthday->body), 0, 8);
384 384
 			$obj->allow_mailing = base64_decode($xmlObj->member->allow_mailing->body);
385 385
 			$obj->point = base64_decode($xmlObj->member->point->body);
386 386
 			$obj->image_nickname = base64_decode($xmlObj->member->image_nickname->buff->body);
@@ -390,26 +390,26 @@  discard block
 block discarded – undo
390 390
 			$obj->regdate = base64_decode($xmlObj->member->regdate->body);
391 391
 			$obj->last_login = base64_decode($xmlObj->member->last_login->body);
392 392
 
393
-			if($xmlObj->member->extra_vars)
393
+			if ($xmlObj->member->extra_vars)
394 394
 			{
395
-				foreach($xmlObj->member->extra_vars as $key => $val)
395
+				foreach ($xmlObj->member->extra_vars as $key => $val)
396 396
 				{
397
-					if(in_array($key, array('node_name','attrs','body'))) continue;
397
+					if (in_array($key, array('node_name', 'attrs', 'body'))) continue;
398 398
 					$obj->extra_vars->{$key} = base64_decode($val->body);
399 399
 				}
400 400
 			}
401 401
 			// Create url for homepage and blog
402
-			if($obj->homepage && strncasecmp('http://', $obj->homepage, 7) !== 0 && strncasecmp('https://', $obj->homepage, 8) !== 0) $obj->homepage = 'http://'.$obj->homepage;
402
+			if ($obj->homepage && strncasecmp('http://', $obj->homepage, 7) !== 0 && strncasecmp('https://', $obj->homepage, 8) !== 0) $obj->homepage = 'http://'.$obj->homepage;
403 403
 			// email address column
404 404
 			$obj->email_address = $obj->email;
405 405
 			list($obj->email_id, $obj->email_host) = explode('@', $obj->email);
406 406
 			// Set the mailing option
407
-			if($obj->allow_mailing!='Y') $obj->allow_mailing = 'N';
407
+			if ($obj->allow_mailing != 'Y') $obj->allow_mailing = 'N';
408 408
 			// Set the message option
409 409
 			$obj->allow_message = 'Y';
410
-			if(!in_array($obj->allow_message, array('Y','N','F'))) $obj->allow_message= 'Y';
410
+			if (!in_array($obj->allow_message, array('Y', 'N', 'F'))) $obj->allow_message = 'Y';
411 411
 			// Get member-join date if the last login time is not found
412
-			if(!$obj->last_login) $obj->last_login = $obj->regdate;
412
+			if (!$obj->last_login) $obj->last_login = $obj->regdate;
413 413
 			// Get a member_srl
414 414
 			$obj->member_srl = getNextSequence();
415 415
 			$obj->list_order = -1 * $obj->member_srl;
@@ -421,63 +421,63 @@  discard block
 block discarded – undo
421 421
 			$nick_args = new stdClass;
422 422
 			$nick_args->nick_name = $obj->nick_name;
423 423
 			$nick_output = executeQuery('member.getMemberSrl', $nick_args);
424
-			if(!$nick_output->toBool()) $obj->nick_name .= '_'.$obj->member_srl;
424
+			if (!$nick_output->toBool()) $obj->nick_name .= '_'.$obj->member_srl;
425 425
 			// Add a member
426 426
 			$output = executeQuery('member.insertMember', $obj);
427 427
 
428
-			if($output->toBool() && !($obj->password))
428
+			if ($output->toBool() && !($obj->password))
429 429
 			{
430 430
 				// Send a mail telling the user to reset his password.
431 431
 				$oMail = new Mail();
432
-				$oMail->setTitle("Password update for your " . getFullSiteUrl() . " account");
433
-				$webmaster_name = $member_config->webmaster_name?$member_config->webmaster_name:'Webmaster';
432
+				$oMail->setTitle("Password update for your ".getFullSiteUrl()." account");
433
+				$webmaster_name = $member_config->webmaster_name ? $member_config->webmaster_name : 'Webmaster';
434 434
 				$oMail->setContent("Dear $obj->user_name, <br /><br />
435 435
 						We recently migrated our phpBB forum to XpressEngine. Since you password was encrypted we could not migrate it too, so please reset it by following this link:
436
-						<a href='" . getFullSiteUrl() . "/?act=dispMemberFindAccount' >" . getFullSiteUrl() . "?act=dispMemberFindAccount</a>. You need to enter you email address and hit the 'Find account' button. You will then receive an email with a new, generated password that you can change after login. <br /><br />
436
+						<a href='".getFullSiteUrl()."/?act=dispMemberFindAccount' >".getFullSiteUrl()."?act=dispMemberFindAccount</a>. You need to enter you email address and hit the 'Find account' button. You will then receive an email with a new, generated password that you can change after login. <br /><br />
437 437
 
438 438
 						Thank you for your understanding,<br />
439 439
 						{$webmaster_name}"
440 440
 				);
441 441
 				$oMail->setSender($webmaster_name, $member_config->webmaster_email);
442
-				$oMail->setReceiptor( $obj->user_name, $obj->email);
442
+				$oMail->setReceiptor($obj->user_name, $obj->email);
443 443
 				$oMail->send();
444 444
 			}
445 445
 
446 446
 			// add group join/image name-mark-signiture and so on if a new member successfully added
447
-			if($output->toBool())
447
+			if ($output->toBool())
448 448
 			{
449 449
 				// Join to the default group
450 450
 				$obj->group_srl = $default_group_srl;
451
-				executeQuery('member.addMemberToGroup',$obj);
451
+				executeQuery('member.addMemberToGroup', $obj);
452 452
 				// Image name
453
-				if($obj->image_nickname)
453
+				if ($obj->image_nickname)
454 454
 				{
455 455
 					$target_path = sprintf('files/member_extra_info/image_name/%s/', getNumberingPath($obj->member_srl));
456 456
 					$target_filename = sprintf('%s%d.gif', $target_path, $obj->member_srl);
457 457
 					FileHandler::writeFile($target_filename, $obj->image_nickname);
458 458
 				}
459 459
 				// Image mark
460
-				if($obj->image_mark && file_exists($obj->image_mark))
460
+				if ($obj->image_mark && file_exists($obj->image_mark))
461 461
 				{
462 462
 					$target_path = sprintf('files/member_extra_info/image_mark/%s/', getNumberingPath($obj->member_srl));
463 463
 					$target_filename = sprintf('%s%d.gif', $target_path, $obj->member_srl);
464 464
 					FileHandler::writeFile($target_filename, $obj->image_mark);
465 465
 				}
466 466
 				// Profile image
467
-				if($obj->profile_image)
467
+				if ($obj->profile_image)
468 468
 				{
469 469
 					$target_path = sprintf('files/member_extra_info/profile_image/%s/', getNumberingPath($obj->member_srl));
470 470
 					$target_filename = sprintf('%s%d.gif', $target_path, $obj->member_srl);
471 471
 					FileHandler::writeFile($target_filename, $obj->profile_image);
472 472
 				}
473 473
 				// Signiture
474
-				if($obj->signature)
474
+				if ($obj->signature)
475 475
 				{
476 476
 					$signature = removeHackTag($obj->signature);
477 477
 					$signature_buff = sprintf('<?php if(!defined("__XE__")) exit();?>%s', $signature);
478 478
 
479 479
 					$target_path = sprintf('files/member_extra_info/signature/%s/', getNumberingPath($obj->member_srl));
480
-					if(!is_dir($target_path)) FileHandler::makeDir($target_path);
480
+					if (!is_dir($target_path)) FileHandler::makeDir($target_path);
481 481
 					$target_filename = sprintf('%s%d.signature.php', $target_path, $obj->member_srl);
482 482
 
483 483
 					FileHandler::writeFile($target_filename, $signature_buff);
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
 
488 488
 		fclose($f);
489 489
 
490
-		return $idx-1;
490
+		return $idx - 1;
491 491
 	}
492 492
 
493 493
 	/**
@@ -499,58 +499,58 @@  discard block
 block discarded – undo
499 499
 	 */
500 500
 	function importMessage($key, $cur, $index_file)
501 501
 	{
502
-		if(!$cur) $cur = 0;
502
+		if (!$cur) $cur = 0;
503 503
 		// Create the xmlParser object
504 504
 		$oXmlParser = new XmlParser();
505 505
 		// Open an index file
506
-		$f = fopen($index_file,"r");
506
+		$f = fopen($index_file, "r");
507 507
 		// Pass if already read
508
-		for($i=0;$i<$cur;$i++) fgets($f, 1024);
508
+		for ($i = 0; $i < $cur; $i++) fgets($f, 1024);
509 509
 		// Read each line until the condition meets
510
-		for($idx=$cur;$idx<$cur+$this->unit_count;$idx++)
510
+		for ($idx = $cur; $idx < $cur + $this->unit_count; $idx++)
511 511
 		{
512
-			if(feof($f)) break;
512
+			if (feof($f)) break;
513 513
 			// Find a location
514 514
 			$target_file = trim(fgets($f, 1024));
515 515
 			// Load and parse the file
516 516
 			$xmlObj = $oXmlParser->loadXmlFile($target_file);
517 517
 			FileHandler::removeFile($target_file);
518
-			if(!$xmlObj) continue;
518
+			if (!$xmlObj) continue;
519 519
 			// List objects
520 520
 			$obj = null;
521 521
 			$obj->receiver = base64_decode($xmlObj->message->receiver->body);
522 522
 			$obj->sender = base64_decode($xmlObj->message->sender->body);
523 523
 			$obj->title = base64_decode($xmlObj->message->title->body);
524 524
 			$obj->content = base64_decode($xmlObj->message->content->body);
525
-			$obj->readed = base64_decode($xmlObj->message->readed->body)=='Y'?'Y':'N';
525
+			$obj->readed = base64_decode($xmlObj->message->readed->body) == 'Y' ? 'Y' : 'N';
526 526
 			$obj->regdate = base64_decode($xmlObj->message->regdate->body);
527 527
 			$obj->readed_date = base64_decode($xmlObj->message->readed_date->body);
528 528
 			// Get member_srl of sender/recipient (If not exists, pass)
529
-			if(!$obj->sender) continue;
529
+			if (!$obj->sender) continue;
530 530
 			$sender_args->user_id = $obj->sender;
531
-			$sender_output = executeQuery('member.getMemberInfo',$sender_args);
531
+			$sender_output = executeQuery('member.getMemberInfo', $sender_args);
532 532
 			$sender_srl = $sender_output->data->member_srl;
533
-			if(!$sender_srl)
533
+			if (!$sender_srl)
534 534
 			{
535 535
 				unset($sender_args);
536 536
 				$sender_args->email_address = $obj->sender;
537
-				$sender_output = executeQuery('member.getMemberInfoByEmailAddress',$sender_args);
537
+				$sender_output = executeQuery('member.getMemberInfoByEmailAddress', $sender_args);
538 538
 				$sender_srl = $sender_output->data->member_srl;
539 539
 			}
540
-			if(!$sender_srl) continue;
540
+			if (!$sender_srl) continue;
541 541
 
542 542
 			$receiver_args->user_id = $obj->receiver;
543
-			if(!$obj->receiver) continue;
544
-			$receiver_output = executeQuery('member.getMemberInfo',$receiver_args);
543
+			if (!$obj->receiver) continue;
544
+			$receiver_output = executeQuery('member.getMemberInfo', $receiver_args);
545 545
 			$receiver_srl = $receiver_output->data->member_srl;
546
-			if(!$receiver_srl)
546
+			if (!$receiver_srl)
547 547
 			{
548 548
 				unset($receiver_args);
549 549
 				$receiver_args->email_address = $obj->receiver;
550
-				$receiver_output = executeQuery('member.getMemberInfoByEmailAddress',$receiver_args);
550
+				$receiver_output = executeQuery('member.getMemberInfoByEmailAddress', $receiver_args);
551 551
 				$receiver_srl = $receiver_output->data->member_srl;
552 552
 			}
553
-			if(!$receiver_srl) continue;
553
+			if (!$receiver_srl) continue;
554 554
 			// Message to save into sender's message box
555 555
 			$sender_args->sender_srl = $sender_srl;
556 556
 			$sender_args->receiver_srl = $receiver_srl;
@@ -565,13 +565,13 @@  discard block
 block discarded – undo
565 565
 			$sender_args->list_order = $sender_args->message_srl * -1;
566 566
 
567 567
 			$output = executeQuery('communication.sendMessage', $sender_args);
568
-			if($output->toBool())
568
+			if ($output->toBool())
569 569
 			{
570 570
 				// Message to save into recipient's massage box
571 571
 				$receiver_args->message_srl = $sender_args->related_srl;
572
-				$receiver_args->list_order = $sender_args->related_srl*-1;
572
+				$receiver_args->list_order = $sender_args->related_srl * -1;
573 573
 				$receiver_args->sender_srl = $sender_srl;
574
-				if(!$receiver_args->sender_srl) $receiver_args->sender_srl = $receiver_srl;
574
+				if (!$receiver_args->sender_srl) $receiver_args->sender_srl = $receiver_srl;
575 575
 				$receiver_args->receiver_srl = $receiver_srl;
576 576
 				$receiver_args->message_type = 'R';
577 577
 				$receiver_args->title = $obj->title;
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
 
586 586
 		fclose($f);
587 587
 
588
-		return $idx-1;
588
+		return $idx - 1;
589 589
 	}
590 590
 
591 591
 	/**
@@ -605,10 +605,10 @@  discard block
 block discarded – undo
605 605
 		$oDocumentModel = getModel('document');
606 606
 		$category_list = $category_titles = array();
607 607
 		$category_list = $oDocumentModel->getCategoryList($module_srl);
608
-		if(count($category_list)) foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl;
608
+		if (count($category_list)) foreach ($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl;
609 609
 		// Extract category information
610 610
 		$category_file = preg_replace('/index$/i', 'category.xml', $index_file);
611
-		if(file_exists($category_file))
611
+		if (file_exists($category_file))
612 612
 		{
613 613
 			$buff = FileHandler::readFile($category_file);
614 614
 
@@ -616,14 +616,14 @@  discard block
 block discarded – undo
616 616
 			$xmlDoc = $this->oXmlParser->loadXmlFile($category_file);
617 617
 
618 618
 			$categories = $xmlDoc->items->category;
619
-			if($categories)
619
+			if ($categories)
620 620
 			{
621
-				if(!is_array($categories)) $categories = array($categories);
621
+				if (!is_array($categories)) $categories = array($categories);
622 622
 				$match_sequence = array();
623
-				foreach($categories as $k => $v)
623
+				foreach ($categories as $k => $v)
624 624
 				{
625 625
 					$category = trim(base64_decode($v->body));
626
-					if(!$category || $category_titles[$category]) continue;
626
+					if (!$category || $category_titles[$category]) continue;
627 627
 
628 628
 					$sequence = $v->attrs->sequence;
629 629
 					$parent = $v->attrs->parent;
@@ -631,10 +631,10 @@  discard block
 block discarded – undo
631 631
 					$obj = null;
632 632
 					$obj->title = $category;
633 633
 					$obj->module_srl = $module_srl;
634
-					if($parent) $obj->parent_srl = $match_sequence[$parent];
634
+					if ($parent) $obj->parent_srl = $match_sequence[$parent];
635 635
 
636 636
 					$output = $oDocumentController->insertCategory($obj);
637
-					if($output->toBool()) $match_sequence[$sequence] = $output->get('category_srl');
637
+					if ($output->toBool()) $match_sequence[$sequence] = $output->get('category_srl');
638 638
 				}
639 639
 				$oDocumentController = getController('document');
640 640
 				$oDocumentController->makeCategoryFile($module_srl);
@@ -644,31 +644,31 @@  discard block
 block discarded – undo
644 644
 
645 645
 		$category_list = $category_titles = array();
646 646
 		$category_list = $oDocumentModel->getCategoryList($module_srl);
647
-		if(count($category_list)) foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl;
647
+		if (count($category_list)) foreach ($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl;
648 648
 
649 649
 		$ek_args->module_srl = $module_srl;
650 650
 		$output = executeQueryArray('document.getDocumentExtraKeys', $ek_args);
651
-		if($output->data)
651
+		if ($output->data)
652 652
 		{
653
-			foreach($output->data as $key => $val) $extra_keys[$val->eid] = true;
653
+			foreach ($output->data as $key => $val) $extra_keys[$val->eid] = true;
654 654
 		}
655 655
 
656
-		if(!$cur) $cur = 0;
656
+		if (!$cur) $cur = 0;
657 657
 		// Open an index file
658
-		$f = fopen($index_file,"r");
658
+		$f = fopen($index_file, "r");
659 659
 		// Pass if already read
660
-		for($i=0;$i<$cur;$i++) fgets($f, 1024);
660
+		for ($i = 0; $i < $cur; $i++) fgets($f, 1024);
661 661
 		// Read each line until the condition meets
662
-		for($idx=$cur;$idx<$cur+$this->unit_count;$idx++)
662
+		for ($idx = $cur; $idx < $cur + $this->unit_count; $idx++)
663 663
 		{
664
-			if(feof($f)) break;
664
+			if (feof($f)) break;
665 665
 			// Find a location
666 666
 			$target_file = trim(fgets($f, 1024));
667 667
 
668
-			if(!file_exists($target_file)) continue;
668
+			if (!file_exists($target_file)) continue;
669 669
 			// Importing data from now on
670
-			$fp = fopen($target_file,"r");
671
-			if(!$fp) continue;
670
+			$fp = fopen($target_file, "r");
671
+			if (!$fp) continue;
672 672
 
673 673
 			$obj = new stdClass;
674 674
 			$obj->module_srl = $module_srl;
@@ -680,51 +680,51 @@  discard block
 block discarded – undo
680 680
 			$started = false;
681 681
 			$buff = array();
682 682
 			// Start from the body data
683
-			while(!feof($fp))
683
+			while (!feof($fp))
684 684
 			{
685 685
 				$str = fgets($fp, 1024);
686 686
 				// Prepare an item
687
-				if(trim($str) == '<post>')
687
+				if (trim($str) == '<post>')
688 688
 				{
689 689
 					$started = true;
690 690
 					// Trackback inserted
691 691
 				}
692
-				else if(substr($str,0,11) == '<trackbacks')
692
+				else if (substr($str, 0, 11) == '<trackbacks')
693 693
 				{
694 694
 					$obj->trackback_count = $this->importTrackbacks($fp, $module_srl, $obj->document_srl);
695 695
 					continue;
696 696
 					// Comments inserted
697 697
 				}
698
-				else if(substr($str,0,9) == '<comments')
698
+				else if (substr($str, 0, 9) == '<comments')
699 699
 				{
700 700
 					$obj->comment_count = $this->importComments($fp, $module_srl, $obj->document_srl);
701 701
 					continue;
702 702
 					// Attachment inserted
703 703
 				}
704
-				else if(substr($str,0,9) == '<attaches')
704
+				else if (substr($str, 0, 9) == '<attaches')
705 705
 				{
706 706
 					$obj->uploaded_count = $this->importAttaches($fp, $module_srl, $obj->document_srl, $files);
707 707
 					continue;
708 708
 					// When starting extra variabls
709 709
 				}
710
-				elseif(trim($str) == '<extra_vars>')
710
+				elseif (trim($str) == '<extra_vars>')
711 711
 				{
712 712
 					$extra_vars = $this->importExtraVars($fp);
713 713
 					continue;
714 714
 				}
715 715
 
716
-				if($started) $buff[] = $str;
716
+				if ($started) $buff[] = $str;
717 717
 			}
718 718
 
719 719
 			$xmlDoc = $this->oXmlParser->parse(implode('', $buff));
720 720
 
721 721
 			$category = base64_decode($xmlDoc->post->category->body);
722
-			if($category_titles[$category]) $obj->category_srl = $category_titles[$category];
722
+			if ($category_titles[$category]) $obj->category_srl = $category_titles[$category];
723 723
 
724 724
 			$obj->member_srl = 0;
725 725
 
726
-			$obj->is_notice = base64_decode($xmlDoc->post->is_notice->body)=='Y'?'Y':'N';
727
-			$obj->status = base64_decode($xmlDoc->post->is_secret->body)=='Y'?$oDocumentModel->getConfigStatus('secret'):$oDocumentModel->getConfigStatus('public');
726
+			$obj->is_notice = base64_decode($xmlDoc->post->is_notice->body) == 'Y' ? 'Y' : 'N';
727
+			$obj->status = base64_decode($xmlDoc->post->is_secret->body) == 'Y' ? $oDocumentModel->getConfigStatus('secret') : $oDocumentModel->getConfigStatus('public');
728 728
 			$obj->title = base64_decode($xmlDoc->post->title->body);
729 729
 			$obj->content = base64_decode($xmlDoc->post->content->body);
730 730
 			$obj->readed_count = base64_decode($xmlDoc->post->readed_count->body);
@@ -733,39 +733,39 @@  discard block
 block discarded – undo
733 733
 			$obj->password = base64_decode($xmlDoc->post->password->body);
734 734
 			$obj->user_name = base64_decode($xmlDoc->post->user_name->body);
735 735
 			$obj->nick_name = base64_decode($xmlDoc->post->nick_name->body);
736
-			if(!$obj->user_name) $obj->user_name = $obj->nick_name;
736
+			if (!$obj->user_name) $obj->user_name = $obj->nick_name;
737 737
 			$obj->user_id = base64_decode($xmlDoc->post->user_id->body);
738 738
 			$obj->email_address = base64_decode($xmlDoc->post->email->body);
739 739
 			$obj->homepage = base64_decode($xmlDoc->post->homepage->body);
740
-			if($obj->homepage && strncasecmp('http://', $obj->homepage, 7) !== 0 && strncasecmp('https://', $obj->homepage, 8) !== 0) $obj->homepage = 'http://'.$obj->homepage;
740
+			if ($obj->homepage && strncasecmp('http://', $obj->homepage, 7) !== 0 && strncasecmp('https://', $obj->homepage, 8) !== 0) $obj->homepage = 'http://'.$obj->homepage;
741 741
 			$obj->tags = base64_decode($xmlDoc->post->tags->body);
742 742
 			$obj->regdate = base64_decode($xmlDoc->post->regdate->body);
743 743
 			$obj->last_update = base64_decode($xmlDoc->post->update->body);
744 744
 			$obj->last_updater = base64_decode($xmlDoc->post->last_updater->body);
745
-			if(!$obj->last_update) $obj->last_update = $obj->regdate;
745
+			if (!$obj->last_update) $obj->last_update = $obj->regdate;
746 746
 			$obj->ipaddress = base64_decode($xmlDoc->post->ipaddress->body);
747
-			$obj->list_order = $obj->update_order = $obj->document_srl*-1;
748
-			$obj->commentStatus = base64_decode($xmlDoc->post->allow_comment->body)!='N'?'ALLOW':'DENY';
749
-			$obj->allow_trackback = base64_decode($xmlDoc->post->allow_trackback->body)!='N'?'Y':'N';
747
+			$obj->list_order = $obj->update_order = $obj->document_srl * -1;
748
+			$obj->commentStatus = base64_decode($xmlDoc->post->allow_comment->body) != 'N' ? 'ALLOW' : 'DENY';
749
+			$obj->allow_trackback = base64_decode($xmlDoc->post->allow_trackback->body) != 'N' ? 'Y' : 'N';
750 750
 			$obj->notify_message = base64_decode($xmlDoc->post->is_notice->body);
751 751
 			// Change content information (attachment)
752
-			if(count($files))
752
+			if (count($files))
753 753
 			{
754
-				foreach($files as $key => $val)
754
+				foreach ($files as $key => $val)
755 755
 				{
756
-					$obj->content = preg_replace('/(src|href)\=(["\']?)'.preg_quote($key).'(["\']?)/i','$1="'.$val.'"',$obj->content);
757
-					$obj->content = preg_replace('/(["\']?).\/files\/(.+)\/'.preg_quote($key).'([^"\']+)(["\']?)/i','"'.$val.'"',$obj->content);
758
-					$obj->content = preg_replace('/(["\']?)files\/(.+)\/'.preg_quote($key).'([^"\']+)(["\']?)/i','"'.$val.'"',$obj->content);
756
+					$obj->content = preg_replace('/(src|href)\=(["\']?)'.preg_quote($key).'(["\']?)/i', '$1="'.$val.'"', $obj->content);
757
+					$obj->content = preg_replace('/(["\']?).\/files\/(.+)\/'.preg_quote($key).'([^"\']+)(["\']?)/i', '"'.$val.'"', $obj->content);
758
+					$obj->content = preg_replace('/(["\']?)files\/(.+)\/'.preg_quote($key).'([^"\']+)(["\']?)/i', '"'.$val.'"', $obj->content);
759 759
 				}
760 760
 			}
761 761
 
762 762
 			$output = executeQuery('document.insertDocument', $obj);
763 763
 
764
-			if($output->toBool() && $obj->tags)
764
+			if ($output->toBool() && $obj->tags)
765 765
 			{
766
-				$tag_list = explode(',',$obj->tags);
766
+				$tag_list = explode(',', $obj->tags);
767 767
 				$tag_count = count($tag_list);
768
-				for($i=0;$i<$tag_count;$i++)
768
+				for ($i = 0; $i < $tag_count; $i++)
769 769
 				{
770 770
 					$args = new stdClass;
771 771
 					$args->tag_srl = getNextSequence();
@@ -773,17 +773,17 @@  discard block
 block discarded – undo
773 773
 					$args->document_srl = $obj->document_srl;
774 774
 					$args->tag = trim($tag_list[$i]);
775 775
 					$args->regdate = $obj->regdate;
776
-					if(!$args->tag) continue;
776
+					if (!$args->tag) continue;
777 777
 					$output = executeQuery('tag.insertTag', $args);
778 778
 				}
779 779
 
780 780
 			}
781 781
 			// Add extra variables
782
-			if(count($extra_vars))
782
+			if (count($extra_vars))
783 783
 			{
784
-				foreach($extra_vars as $key => $val)
784
+				foreach ($extra_vars as $key => $val)
785 785
 				{
786
-					if(!$val->value) continue;
786
+					if (!$val->value) continue;
787 787
 					unset($e_args);
788 788
 					$e_args->module_srl = $module_srl;
789 789
 					$e_args->document_srl = $obj->document_srl;
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
 					$e_args->lang_code = $val->lang_code;
793 793
 					$e_args->eid = $val->eid;
794 794
 					// Create a key for extra vars if not exists (except vars for title and content)
795
-					if(!preg_match('/^(title|content)_(.+)$/i',$e_args->eid) && !$extra_keys[$e_args->eid])
795
+					if (!preg_match('/^(title|content)_(.+)$/i', $e_args->eid) && !$extra_keys[$e_args->eid])
796 796
 					{
797 797
 						unset($ek_args);
798 798
 						$ek_args->module_srl = $module_srl;
@@ -816,9 +816,9 @@  discard block
 block discarded – undo
816 816
 
817 817
 		fclose($f);
818 818
 		// Sync category counts
819
-		if(count($category_list)) foreach($category_list as $key => $val) $oDocumentController->updateCategoryCount($module_srl, $val->category_srl);
819
+		if (count($category_list)) foreach ($category_list as $key => $val) $oDocumentController->updateCategoryCount($module_srl, $val->category_srl);
820 820
 
821
-		return $idx-1;
821
+		return $idx - 1;
822 822
 	}
823 823
 
824 824
 	/**
@@ -834,17 +834,17 @@  discard block
 block discarded – undo
834 834
 		$buff = null;
835 835
 		$cnt = 0;
836 836
 
837
-		while(!feof($fp))
837
+		while (!feof($fp))
838 838
 		{
839 839
 			$str = fgets($fp, 1024);
840 840
 			// If </trackbacks> is, break
841
-			if(trim($str) == '</trackbacks>') break;
841
+			if (trim($str) == '</trackbacks>') break;
842 842
 			// If <trackback>, start importing
843
-			if(trim($str) == '<trackback>') $started = true;
843
+			if (trim($str) == '<trackback>') $started = true;
844 844
 
845
-			if($started) $buff .= $str;
845
+			if ($started) $buff .= $str;
846 846
 			// If </trackback>, insert to the DB
847
-			if(trim($str) == '</trackback>')
847
+			if (trim($str) == '</trackback>')
848 848
 			{
849 849
 				$xmlDoc = $this->oXmlParser->parse($buff);
850 850
 
@@ -858,9 +858,9 @@  discard block
 block discarded – undo
858 858
 				$obj->excerpt = base64_decode($xmlDoc->trackback->excerpt->body);
859 859
 				$obj->regdate = base64_decode($xmlDoc->trackback->regdate->body);
860 860
 				$obj->ipaddress = base64_decode($xmlDoc->trackback->ipaddress->body);
861
-				$obj->list_order = -1*$obj->trackback_srl;
861
+				$obj->list_order = -1 * $obj->trackback_srl;
862 862
 				$output = executeQuery('trackback.insertTrackback', $obj);
863
-				if($output->toBool()) $cnt++;
863
+				if ($output->toBool()) $cnt++;
864 864
 
865 865
 				$buff = null;
866 866
 				$started = false;
@@ -884,13 +884,13 @@  discard block
 block discarded – undo
884 884
 
885 885
 		$sequences = array();
886 886
 
887
-		while(!feof($fp))
887
+		while (!feof($fp))
888 888
 		{
889 889
 			$str = fgets($fp, 1024);
890 890
 			// If </comments> is, break
891
-			if(trim($str) == '</comments>') break;
891
+			if (trim($str) == '</comments>') break;
892 892
 			// If <comment> is, start importing
893
-			if(trim($str) == '<comment>')
893
+			if (trim($str) == '<comment>')
894 894
 			{
895 895
 				$started = true;
896 896
 				$obj = new stdClass;
@@ -898,15 +898,15 @@  discard block
 block discarded – undo
898 898
 				$files = array();
899 899
 			}
900 900
 			// If <attaches is, start importing attachments
901
-			if(substr($str,0,9) == '<attaches')
901
+			if (substr($str, 0, 9) == '<attaches')
902 902
 			{
903 903
 				$obj->uploaded_count = $this->importAttaches($fp, $module_srl, $obj->comment_srl, $files);
904 904
 				continue;
905 905
 			}
906 906
 
907
-			if($started) $buff .= $str;
907
+			if ($started) $buff .= $str;
908 908
 			// If </comment> is, insert to the DB
909
-			if(trim($str) == '</comment>')
909
+			if (trim($str) == '</comment>')
910 910
 			{
911 911
 				$xmlDoc = $this->oXmlParser->parse($buff);
912 912
 
@@ -916,35 +916,35 @@  discard block
 block discarded – undo
916 916
 
917 917
 				$obj->module_srl = $module_srl;
918 918
 
919
-				if($parent) $obj->parent_srl = $sequences[$parent];
919
+				if ($parent) $obj->parent_srl = $sequences[$parent];
920 920
 				else $obj->parent_srl = 0;
921 921
 
922 922
 				$obj->document_srl = $document_srl;
923
-				$obj->is_secret = base64_decode($xmlDoc->comment->is_secret->body)=='Y'?'Y':'N';
924
-				$obj->notify_message = base64_decode($xmlDoc->comment->notify_message->body)=='Y'?'Y':'N';
923
+				$obj->is_secret = base64_decode($xmlDoc->comment->is_secret->body) == 'Y' ? 'Y' : 'N';
924
+				$obj->notify_message = base64_decode($xmlDoc->comment->notify_message->body) == 'Y' ? 'Y' : 'N';
925 925
 				$obj->content = base64_decode($xmlDoc->comment->content->body);
926 926
 				$obj->voted_count = base64_decode($xmlDoc->comment->voted_count->body);
927 927
 				$obj->blamed_count = base64_decode($xmlDoc->comment->blamed_count->body);
928 928
 				$obj->password = base64_decode($xmlDoc->comment->password->body);
929
-				$obj->user_name =base64_decode($xmlDoc->comment->user_name->body);
929
+				$obj->user_name = base64_decode($xmlDoc->comment->user_name->body);
930 930
 				$obj->nick_name = base64_decode($xmlDoc->comment->nick_name->body);
931
-				if(!$obj->user_name) $obj->user_name = $obj->nick_name;
931
+				if (!$obj->user_name) $obj->user_name = $obj->nick_name;
932 932
 				$obj->user_id = base64_decode($xmlDoc->comment->user_id->body);
933 933
 				$obj->member_srl = 0;
934 934
 				$obj->email_address = base64_decode($xmlDoc->comment->email->body);
935 935
 				$obj->homepage = base64_decode($xmlDoc->comment->homepage->body);
936 936
 				$obj->regdate = base64_decode($xmlDoc->comment->regdate->body);
937 937
 				$obj->last_update = base64_decode($xmlDoc->comment->update->body);
938
-				if(!$obj->last_update) $obj->last_update = $obj->regdate;
938
+				if (!$obj->last_update) $obj->last_update = $obj->regdate;
939 939
 				$obj->ipaddress = base64_decode($xmlDoc->comment->ipaddress->body);
940
-				$obj->status = base64_decode($xmlDoc->comment->status->body)==''?'1':base64_decode($xmlDoc->comment->status->body);
941
-				$obj->list_order = $obj->comment_srl*-1;
940
+				$obj->status = base64_decode($xmlDoc->comment->status->body) == '' ? '1' : base64_decode($xmlDoc->comment->status->body);
941
+				$obj->list_order = $obj->comment_srl * -1;
942 942
 				// Change content information (attachment)
943
-				if(count($files))
943
+				if (count($files))
944 944
 				{
945
-					foreach($files as $key => $val)
945
+					foreach ($files as $key => $val)
946 946
 					{
947
-						$obj->content = preg_replace('/(src|href)\=(["\']?)'.preg_quote($key).'(["\']?)/i','$1="'.$val.'"',$obj->content);
947
+						$obj->content = preg_replace('/(src|href)\=(["\']?)'.preg_quote($key).'(["\']?)/i', '$1="'.$val.'"', $obj->content);
948 948
 					}
949 949
 				}
950 950
 				// Comment list first
@@ -954,7 +954,7 @@  discard block
 block discarded – undo
954 954
 				$list_args->module_srl = $obj->module_srl;
955 955
 				$list_args->regdate = $obj->regdate;
956 956
 				// Set data directly if parent comment doesn't exist
957
-				if(!$obj->parent_srl)
957
+				if (!$obj->parent_srl)
958 958
 				{
959 959
 					$list_args->head = $list_args->arrange = $obj->comment_srl;
960 960
 					$list_args->depth = 0;
@@ -966,25 +966,25 @@  discard block
 block discarded – undo
966 966
 					$parent_args->comment_srl = $obj->parent_srl;
967 967
 					$parent_output = executeQuery('comment.getCommentListItem', $parent_args);
968 968
 					// Return if parent comment doesn't exist
969
-					if(!$parent_output->toBool() || !$parent_output->data) continue;
969
+					if (!$parent_output->toBool() || !$parent_output->data) continue;
970 970
 					$parent = $parent_output->data;
971 971
 
972 972
 					$list_args->head = $parent->head;
973
-					$list_args->depth = $parent->depth+1;
974
-					if($list_args->depth<2) $list_args->arrange = $obj->comment_srl;
973
+					$list_args->depth = $parent->depth + 1;
974
+					if ($list_args->depth < 2) $list_args->arrange = $obj->comment_srl;
975 975
 					else
976 976
 					{
977 977
 						$list_args->arrange = $parent->arrange;
978 978
 						$output = executeQuery('comment.updateCommentListArrange', $list_args);
979
-						if(!$output->toBool()) return $output;
979
+						if (!$output->toBool()) return $output;
980 980
 					}
981 981
 				}
982 982
 
983 983
 				$output = executeQuery('comment.insertCommentList', $list_args);
984
-				if($output->toBool())
984
+				if ($output->toBool())
985 985
 				{
986 986
 					$output = executeQuery('comment.insertComment', $obj);
987
-					if($output->toBool()) $cnt++;
987
+					if ($output->toBool()) $cnt++;
988 988
 				}
989 989
 
990 990
 				$buff = null;
@@ -1010,13 +1010,13 @@  discard block
 block discarded – undo
1010 1010
 		$buff = null;
1011 1011
 
1012 1012
 		$file_obj = new stdClass;
1013
-		while(!feof($fp))
1013
+		while (!feof($fp))
1014 1014
 		{
1015 1015
 			$str = trim(fgets($fp, 1024));
1016 1016
 			// If it ends with </attaches>, break
1017
-			if(trim($str) == '</attaches>') break;
1017
+			if (trim($str) == '</attaches>') break;
1018 1018
 			// If it starts with <attach>, collect attachments
1019
-			if(trim($str) == '<attach>')
1019
+			if (trim($str) == '<attach>')
1020 1020
 			{
1021 1021
 				$file_obj->file_srl = getNextSequence();
1022 1022
 				$file_obj->upload_target_srl = $upload_target_srl;
@@ -1026,26 +1026,26 @@  discard block
 block discarded – undo
1026 1026
 				$buff = null;
1027 1027
 				// If it starts with <file>, handle the attachement in xml file
1028 1028
 			}
1029
-			else if(trim($str) == '<file>')
1029
+			else if (trim($str) == '<file>')
1030 1030
 			{
1031 1031
 				$file_obj->file = $this->saveTemporaryFile($fp);
1032 1032
 				continue;
1033 1033
 			}
1034 1034
 
1035
-			if($started) $buff .= $str;
1035
+			if ($started) $buff .= $str;
1036 1036
 			// If it ends with </attach>, handle attachements
1037
-			if(trim($str) == '</attach>')
1037
+			if (trim($str) == '</attach>')
1038 1038
 			{
1039 1039
 				$xmlDoc = $this->oXmlParser->parse($buff.$str);
1040 1040
 
1041 1041
 				$file_obj->source_filename = base64_decode($xmlDoc->attach->filename->body);
1042 1042
 				$file_obj->download_count = base64_decode($xmlDoc->attach->download_count->body);
1043 1043
 
1044
-				if(!$file_obj->file)
1044
+				if (!$file_obj->file)
1045 1045
 				{
1046 1046
 					$url = base64_decode($xmlDoc->attach->url->body);
1047 1047
 					$path = base64_decode($xmlDoc->attach->path->body);
1048
-					if($path && file_exists($path)) $file_obj->file = $path;
1048
+					if ($path && file_exists($path)) $file_obj->file = $path;
1049 1049
 					else
1050 1050
 					{
1051 1051
 						$file_obj->file = $this->getTmpFilename();
@@ -1053,11 +1053,11 @@  discard block
 block discarded – undo
1053 1053
 					}
1054 1054
 				}
1055 1055
 
1056
-				if(file_exists($file_obj->file))
1056
+				if (file_exists($file_obj->file))
1057 1057
 				{
1058 1058
 					$random = new Password();
1059 1059
 					// Set upload path by checking if the attachement is an image or other kind of file
1060
-					if(preg_match("/\.(jpe?g|gif|png|wm[va]|mpe?g|avi|flv|mp[1-4]|as[fx]|wav|midi?|moo?v|qt|r[am]{1,2}|m4v)$/i", $file_obj->source_filename))
1060
+					if (preg_match("/\.(jpe?g|gif|png|wm[va]|mpe?g|avi|flv|mp[1-4]|as[fx]|wav|midi?|moo?v|qt|r[am]{1,2}|m4v)$/i", $file_obj->source_filename))
1061 1061
 					{
1062 1062
 						// Immediately remove the direct file if it has any kind of extensions for hacking
1063 1063
 						$file_obj->source_filename = preg_replace('/\.(php|phtm|phar|html?|cgi|pl|exe|jsp|asp|inc)/i', '$0-x', $file_obj->source_filename);
@@ -1065,14 +1065,14 @@  discard block
 block discarded – undo
1065 1065
 
1066 1066
 						$path = sprintf("./files/attach/images/%s/%s", $module_srl, getNumberingPath($upload_target_srl, 3));
1067 1067
 
1068
-						$ext = substr(strrchr($file_obj->source_filename,'.'),1);
1068
+						$ext = substr(strrchr($file_obj->source_filename, '.'), 1);
1069 1069
 						$_filename = $random->createSecureSalt(32, 'hex').'.'.$ext;
1070 1070
 						$filename  = $path.$_filename;
1071 1071
 
1072 1072
 						$idx = 1;
1073
-						while(file_exists($filename))
1073
+						while (file_exists($filename))
1074 1074
 						{
1075
-							$filename = $path.preg_replace('/\.([a-z0-9]+)$/i','_'.$idx.'.$1', $_filename);
1075
+							$filename = $path.preg_replace('/\.([a-z0-9]+)$/i', '_'.$idx.'.$1', $_filename);
1076 1076
 							$idx++;
1077 1077
 						}
1078 1078
 
@@ -1080,14 +1080,14 @@  discard block
 block discarded – undo
1080 1080
 					}
1081 1081
 					else
1082 1082
 					{
1083
-						$path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl,3));
1083
+						$path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl, 3));
1084 1084
 						$filename = $path.$random->createSecureSalt(32, 'hex');
1085 1085
 						$file_obj->direct_download = 'N';
1086 1086
 					}
1087 1087
 					// Create a directory
1088
-					if(!FileHandler::makeDir($path)) continue;
1088
+					if (!FileHandler::makeDir($path)) continue;
1089 1089
 
1090
-					if(strncmp('./files/cache/importer/', $file_obj->file, 23) === 0)
1090
+					if (strncmp('./files/cache/importer/', $file_obj->file, 23) === 0)
1091 1091
 					{
1092 1092
 						FileHandler::rename($file_obj->file, $filename);
1093 1093
 					}
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
 
1099 1099
 					// Insert the file to the DB
1100 1100
 					unset($file_obj->file);
1101
-					if(file_exists($filename))
1101
+					if (file_exists($filename))
1102 1102
 					{
1103 1103
 						$file_obj->uploaded_filename = $filename;
1104 1104
 						$file_obj->file_size = filesize($filename);
@@ -1108,13 +1108,13 @@  discard block
 block discarded – undo
1108 1108
 						$file_obj->isvalid = 'Y';
1109 1109
 						$output = executeQuery('file.insertFile', $file_obj);
1110 1110
 
1111
-						if($output->toBool())
1111
+						if ($output->toBool())
1112 1112
 						{
1113 1113
 							$uploaded_count++;
1114 1114
 							$tmp_obj = null;
1115 1115
 							$tmp_obj->source_filename = $file_obj->source_filename;
1116
-							if($file_obj->direct_download == 'Y') $files[$file_obj->source_filename] = $file_obj->uploaded_filename;
1117
-							else $files[$file_obj->source_filename] = getUrl('','module','file','act','procFileDownload','file_srl',$file_obj->file_srl,'sid',$file_obj->sid);
1116
+							if ($file_obj->direct_download == 'Y') $files[$file_obj->source_filename] = $file_obj->uploaded_filename;
1117
+							else $files[$file_obj->source_filename] = getUrl('', 'module', 'file', 'act', 'procFileDownload', 'file_srl', $file_obj->file_srl, 'sid', $file_obj->sid);
1118 1118
 						}
1119 1119
 					}
1120 1120
 				}
@@ -1131,8 +1131,8 @@  discard block
 block discarded – undo
1131 1131
 	{
1132 1132
 		$path = "./files/cache/importer";
1133 1133
 		FileHandler::makeDir($path);
1134
-		$filename = sprintf("%s/%d", $path, rand(11111111,99999999));
1135
-		if(file_exists($filename)) $filename .= rand(111,999);
1134
+		$filename = sprintf("%s/%d", $path, rand(11111111, 99999999));
1135
+		if (file_exists($filename)) $filename .= rand(111, 999);
1136 1136
 		return $filename;
1137 1137
 	}
1138 1138
 
@@ -1147,14 +1147,14 @@  discard block
 block discarded – undo
1147 1147
 		$f = fopen($temp_filename, "w");
1148 1148
 
1149 1149
 		$buff = '';
1150
-		while(!feof($fp))
1150
+		while (!feof($fp))
1151 1151
 		{
1152 1152
 			$str = trim(fgets($fp, 1024));
1153
-			if(trim($str) == '</file>') break;
1153
+			if (trim($str) == '</file>') break;
1154 1154
 
1155 1155
 			$buff .= $str;
1156 1156
 
1157
-			if(substr($buff,-7)=='</buff>')
1157
+			if (substr($buff, -7) == '</buff>')
1158 1158
 			{
1159 1159
 				fwrite($f, base64_decode(substr($buff, 6, -7)));
1160 1160
 				$buff = '';
@@ -1173,23 +1173,23 @@  discard block
 block discarded – undo
1173 1173
 	function importExtraVars($fp)
1174 1174
 	{
1175 1175
 		$buff = null;
1176
-		while(!feof($fp))
1176
+		while (!feof($fp))
1177 1177
 		{
1178 1178
 			$buff .= $str = trim(fgets($fp, 1024));
1179
-			if(trim($str) == '</extra_vars>') break;
1179
+			if (trim($str) == '</extra_vars>') break;
1180 1180
 		}
1181
-		if(!$buff) return array();
1181
+		if (!$buff) return array();
1182 1182
 
1183 1183
 		$buff = '<extra_vars>'.$buff;
1184 1184
 		$oXmlParser = new XmlParser();
1185 1185
 		$xmlDoc = $this->oXmlParser->parse($buff);
1186
-		if(!count($xmlDoc->extra_vars->key)) return array();
1186
+		if (!count($xmlDoc->extra_vars->key)) return array();
1187 1187
 
1188 1188
 		$index = 1;
1189
-		foreach($xmlDoc->extra_vars->key as $k => $v)
1189
+		foreach ($xmlDoc->extra_vars->key as $k => $v)
1190 1190
 		{
1191 1191
 			unset($vobj);
1192
-			if($v->var_idx)
1192
+			if ($v->var_idx)
1193 1193
 			{
1194 1194
 				$vobj->var_idx = base64_decode($v->var_idx->body);
1195 1195
 				$vobj->lang_code = base64_decode($v->lang_code->body);
@@ -1197,7 +1197,7 @@  discard block
 block discarded – undo
1197 1197
 				$vobj->eid = base64_decode($v->eid->body);
1198 1198
 
1199 1199
 			}
1200
-			else if($v->body)
1200
+			else if ($v->body)
1201 1201
 			{
1202 1202
 				$vobj->var_idx = $index;
1203 1203
 				$vobj->lang_code = Context::getLangType();
Please login to merge, or discard this patch.
modules/importer/ttimport.class.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -450,7 +450,7 @@
 block discarded – undo
450 450
 	 * @param int $upload_target_srl
451 451
 	 * @param array $files
452 452
 	 * @param string $buff
453
-	 * @return bool
453
+	 * @return null|boolean
454 454
 	 */
455 455
 	function importAttaches($fp, $module_srl, $upload_target_srl, &$files, $buff)
456 456
 	{
Please login to merge, or discard this patch.
Braces   +153 added lines, -71 removed lines patch added patch discarded remove patch
@@ -40,7 +40,9 @@  discard block
 block discarded – undo
40 40
 		$oDocumentModel = getModel('document');
41 41
 		$category_list = $category_titles = array();
42 42
 		$category_list = $oDocumentModel->getCategoryList($module_srl);
43
-		if(count($category_list)) foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl;
43
+		if(count($category_list)) {
44
+			foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl;
45
+		}
44 46
 		// First handle categorty information
45 47
 		$category_file = preg_replace('/index$/i', 'category.xml', $index_file);
46 48
 		if(file_exists($category_file))
@@ -58,15 +60,21 @@  discard block
 block discarded – undo
58 60
 				foreach($categories as $k => $v)
59 61
 				{
60 62
 					$category = $v->name;
61
-					if(!$category || $category_titles[$category]) continue;
63
+					if(!$category || $category_titles[$category]) {
64
+						continue;
65
+					}
62 66
 
63 67
 					$obj = null;
64 68
 					$obj->title = $category;
65 69
 					$obj->module_srl = $module_srl; 
66
-					if($v->parent) $obj->parent_srl = $match_sequence[$v->parent];
70
+					if($v->parent) {
71
+						$obj->parent_srl = $match_sequence[$v->parent];
72
+					}
67 73
 					$output = $oDocumentController->insertCategory($obj);
68 74
 
69
-					if($output->toBool()) $match_sequence[$v->sequence] = $category_titles[$category] = $output->get('category_srl');
75
+					if($output->toBool()) {
76
+						$match_sequence[$v->sequence] = $category_titles[$category] = $output->get('category_srl');
77
+					}
70 78
 				}
71 79
 				$oDocumentController->makeCategoryFile($module_srl);
72 80
 			}
@@ -74,28 +82,40 @@  discard block
 block discarded – undo
74 82
 		}
75 83
 		$category_list = $category_titles = array();
76 84
 		$category_list = $oDocumentModel->getCategoryList($module_srl);
77
-		if(count($category_list)) foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl;
85
+		if(count($category_list)) {
86
+			foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl;
87
+		}
78 88
 		// Get administrator information
79 89
 		$oMemberModel = getModel('member');
80 90
 		$member_info = $oMemberModel->getMemberInfoByUserID($user_id);
81 91
 		$author_xml_id = 0;
82 92
 
83
-		if(!$cur) $cur = 0;
93
+		if(!$cur) {
94
+			$cur = 0;
95
+		}
84 96
 		// Open an index file
85 97
 		$f = fopen($index_file,"r");
86 98
 		// Pass if already read
87
-		for($i=0;$i<$cur;$i++) fgets($f, 1024);
99
+		for($i=0;$i<$cur;$i++) {
100
+			fgets($f, 1024);
101
+		}
88 102
 		// Read each line until the codition meets
89 103
 		for($idx=$cur;$idx<$cur+$unit_count;$idx++)
90 104
 		{
91
-			if(feof($f)) break;
105
+			if(feof($f)) {
106
+				break;
107
+			}
92 108
 			// Find a location
93 109
 			$target_file = trim(fgets($f, 1024));
94 110
 
95
-			if(!file_exists($target_file)) continue;
111
+			if(!file_exists($target_file)) {
112
+				continue;
113
+			}
96 114
 			// Start importing data
97 115
 			$fp = fopen($target_file,"r");
98
-			if(!$fp) continue;
116
+			if(!$fp) {
117
+				continue;
118
+			}
99 119
 
100 120
 			$obj = null;
101 121
 			$obj->module_srl = $module_srl;
@@ -116,14 +136,17 @@  discard block
 block discarded – undo
116 136
 					$started = true;
117 137
 					continue;
118 138
 					// Import the attachment
119
-				}
120
-				else if(substr($str,0,12) == '<attachment ')
139
+				} else if(substr($str,0,12) == '<attachment ')
121 140
 				{
122
-					if($this->importAttaches($fp, $module_srl, $obj->document_srl, $files, $str)) $obj->uploaded_count++;
141
+					if($this->importAttaches($fp, $module_srl, $obj->document_srl, $files, $str)) {
142
+						$obj->uploaded_count++;
143
+					}
123 144
 					continue;
124 145
 				}
125 146
 
126
-				if($started) $buff .= $str;
147
+				if($started) {
148
+					$buff .= $str;
149
+				}
127 150
 			}
128 151
 
129 152
 			$xmlDoc = $this->oXmlParser->parse('<post>'.$buff);
@@ -134,7 +157,9 @@  discard block
 block discarded – undo
134 157
 			{
135 158
 				$tmp_arr = explode('/',$xmlDoc->post->category->body);
136 159
 				$category = trim($tmp_arr[count($tmp_arr)-1]);
137
-				if($category_titles[$category]) $obj->category_srl = $category_titles[$category];
160
+				if($category_titles[$category]) {
161
+					$obj->category_srl = $category_titles[$category];
162
+				}
138 163
 			}
139 164
 
140 165
 			$obj->is_notice = 'N';
@@ -148,15 +173,21 @@  discard block
 block discarded – undo
148 173
 			//$obj->allow_trackback = $xmlDoc->post->acceptTrackback->body=='1'?'Y':'N';
149 174
 			$obj->regdate = date("YmdHis",$xmlDoc->post->published->body);
150 175
 			$obj->last_update = date("YmdHis", $xmlDoc->post->modified->body);
151
-			if(!$obj->last_update) $obj->last_update = $obj->regdate;
176
+			if(!$obj->last_update) {
177
+				$obj->last_update = $obj->regdate;
178
+			}
152 179
 
153 180
 			$tag = null;
154 181
 			$tmp_tags = null;
155 182
 			$tag = $xmlDoc->post->tag;
156 183
 			if($tag)
157 184
 			{
158
-				if(!is_array($tag)) $tag = array($tag);
159
-				foreach($tag as $key => $val) $tmp_tags[] = $val->body;
185
+				if(!is_array($tag)) {
186
+					$tag = array($tag);
187
+				}
188
+				foreach($tag as $key => $val) {
189
+					$tmp_tags[] = $val->body;
190
+				}
160 191
 				$obj->tags = implode(',',$tmp_tags);
161 192
 			}
162 193
 
@@ -192,7 +223,9 @@  discard block
 block discarded – undo
192 223
 			if($xmlDoc->post->trackback)
193 224
 			{
194 225
 				$trackbacks = $xmlDoc->post->trackback;
195
-				if(!is_array($trackbacks)) $trackbacks = array($trackbacks);
226
+				if(!is_array($trackbacks)) {
227
+					$trackbacks = array($trackbacks);
228
+				}
196 229
 				if(count($trackbacks))
197 230
 				{
198 231
 					foreach($trackbacks as $key => $val)
@@ -209,7 +242,9 @@  discard block
 block discarded – undo
209 242
 						$tobj->ipaddress = $val->ip->body;
210 243
 						$tobj->list_order = -1*$tobj->trackback_srl;
211 244
 						$output = executeQuery('trackback.insertTrackback', $tobj);
212
-						if($output->toBool()) $obj->trackback_count++;
245
+						if($output->toBool()) {
246
+							$obj->trackback_count++;
247
+						}
213 248
 					}
214 249
 				}
215 250
 			}
@@ -218,21 +253,29 @@  discard block
 block discarded – undo
218 253
 			if($xmlDoc->post->comment)
219 254
 			{
220 255
 				$comment = $xmlDoc->post->comment;
221
-				if(!is_array($comment)) $comment = array($comment);
256
+				if(!is_array($comment)) {
257
+					$comment = array($comment);
258
+				}
222 259
 				foreach($comment as $key => $val)
223 260
 				{
224 261
 					$parent_srl = $this->insertComment($val, $module_srl, $obj->document_srl, $member_info, 0, $author_xml_id);
225
-					if($parent_srl === false) continue;
262
+					if($parent_srl === false) {
263
+						continue;
264
+					}
226 265
 
227 266
 					$obj->comment_count++;
228 267
 					if($val->comment)
229 268
 					{
230 269
 						$child_comment = $val->comment;
231
-						if(!is_array($child_comment)) $child_comment = array($child_comment);
270
+						if(!is_array($child_comment)) {
271
+							$child_comment = array($child_comment);
272
+						}
232 273
 						foreach($child_comment as $k => $v)
233 274
 						{
234 275
 							$result = $this->insertComment($v, $module_srl, $obj->document_srl, $member_info, $parent_srl, $author_xml_id);
235
-							if($result !== false) $obj->comment_count++;
276
+							if($result !== false) {
277
+								$obj->comment_count++;
278
+							}
236 279
 						}
237 280
 					}
238 281
 				}
@@ -270,7 +313,9 @@  discard block
 block discarded – undo
270 313
 						$args->document_srl = $obj->document_srl;
271 314
 						$args->tag = trim($tag_list[$i]);
272 315
 						$args->regdate = $obj->regdate;
273
-						if(!$args->tag) continue;
316
+						if(!$args->tag) {
317
+							continue;
318
+						}
274 319
 						$output = executeQuery('tag.insertTag', $args);
275 320
 					}
276 321
 				}
@@ -282,7 +327,9 @@  discard block
 block discarded – undo
282 327
 
283 328
 		fclose($f);
284 329
 
285
-		if(count($category_list)) foreach($category_list as $key => $val) $oDocumentController->updateCategoryCount($module_srl, $val->category_srl);
330
+		if(count($category_list)) {
331
+			foreach($category_list as $key => $val) $oDocumentController->updateCategoryCount($module_srl, $val->category_srl);
332
+		}
286 333
 		// Guestbook information
287 334
 		$guestbook_file = preg_replace('/index$/i', 'guestbook.xml', $index_file);
288 335
 		if(file_exists($guestbook_file))
@@ -293,7 +340,9 @@  discard block
 block discarded – undo
293 340
 			if($guestbook_module_srl && $xmlDoc->guestbook->comment)
294 341
 			{
295 342
 				$comment = $xmlDoc->guestbook->comment;
296
-				if(!is_array($comment)) $comment = array($comment);
343
+				if(!is_array($comment)) {
344
+					$comment = array($comment);
345
+				}
297 346
 
298 347
 				if($module_name =='textyle')
299 348
 				{
@@ -304,7 +353,9 @@  discard block
 block discarded – undo
304 353
 						if($val->comment)
305 354
 						{
306 355
 							$child_comment = $val->comment;
307
-							if(!is_array($child_comment)) $child_comment = array($child_comment);
356
+							if(!is_array($child_comment)) {
357
+								$child_comment = array($child_comment);
358
+							}
308 359
 							foreach($child_comment as $k => $v)
309 360
 							{
310 361
 								$result = $this->insertTextyleGuestbookItem($v, $module_srl, $member_info,0,$textyle_guestbook_srl,$author_xml_id);
@@ -313,8 +364,7 @@  discard block
 block discarded – undo
313 364
 
314 365
 						$result = $this->insertTextyleGuestbookItem($val, $module_srl, $member_info,$textyle_guestbook_srl,0,$author_xml_id);
315 366
 					}
316
-				}
317
-				else
367
+				} else
318 368
 				{
319 369
 					foreach($comment as $key => $val)
320 370
 					{
@@ -328,13 +378,17 @@  discard block
 block discarded – undo
328 378
 
329 379
 						// Extract a title form the bocy
330 380
 						$obj->title = cut_str(strip_tags($obj->content),20,'...');
331
-						if ($obj->title == '') $obj->title = 'Untitled';
381
+						if ($obj->title == '') {
382
+							$obj->title = 'Untitled';
383
+						}
332 384
 
333 385
 						$obj->commentStatus = 'ALLOW';
334 386
 						$obj->allow_trackback = 'N';
335 387
 						$obj->regdate = date("YmdHis",$val->written->body);
336 388
 						$obj->last_update = date("YmdHis", $val->written->body);
337
-						if(!$obj->last_update) $obj->last_update = $obj->regdate;
389
+						if(!$obj->last_update) {
390
+							$obj->last_update = $obj->regdate;
391
+						}
338 392
 						$obj->tags = '';
339 393
 						$obj->readed_count = 0;
340 394
 						$obj->voted_count = 0;
@@ -347,8 +401,7 @@  discard block
 block discarded – undo
347 401
 							$obj->member_srl = $member_info->member_srl;
348 402
 							$obj->email_address = $member_info->email_address;
349 403
 							$obj->homepage = $member_info->homepage;
350
-						}
351
-						else
404
+						} else
352 405
 						{
353 406
 							$obj->password = $val->password->body;
354 407
 							$obj->nick_name = $val->commenter->name->body;
@@ -364,11 +417,15 @@  discard block
 block discarded – undo
364 417
 						if($val->comment)
365 418
 						{
366 419
 							$child_comment = $val->comment;
367
-							if(!is_array($child_comment)) $child_comment = array($child_comment);
420
+							if(!is_array($child_comment)) {
421
+								$child_comment = array($child_comment);
422
+							}
368 423
 							foreach($child_comment as $k => $v)
369 424
 							{
370 425
 								$result = $this->insertComment($v, $module_srl, $obj->document_srl, $member_info, 0,$author_xml_id);
371
-								if($result !== false) $obj->comment_count++;
426
+								if($result !== false) {
427
+									$obj->comment_count++;
428
+								}
372 429
 							}
373 430
 						}
374 431
 
@@ -399,8 +456,7 @@  discard block
 block discarded – undo
399 456
 		if($textyle_guestbook_srl>0)
400 457
 		{
401 458
 			$tobj->textyle_guestbook_srl = $textyle_guestbook_srl;
402
-		}
403
-		else
459
+		} else
404 460
 		{
405 461
 			$tobj->textyle_guestbook_srl = getNextSequence();
406 462
 		}
@@ -416,8 +472,7 @@  discard block
 block discarded – undo
416 472
 			$tobj->member_srl = $member_info->member_srl;
417 473
 			$tobj->homepage = $member_info->homepage;
418 474
 			$tobj->email_address = $member_info->email_address;
419
-		}
420
-		else
475
+		} else
421 476
 		{
422 477
 			$tobj->password = $val->password->body;
423 478
 			$tobj->nick_name = $val->commenter->name->body;
@@ -431,15 +486,16 @@  discard block
 block discarded – undo
431 486
 		{
432 487
 			$tobj->parent_srl = $parent_srl;
433 488
 			$tobj->list_order = $tobj->parent_srl * -1;
434
-		}
435
-		else
489
+		} else
436 490
 		{
437 491
 			$tobj->list_order = $tobj->textyle_guestbook_srl*-1;
438 492
 		}
439 493
 
440 494
 		$output = executeQuery('textyle.insertTextyleGuestbook', $tobj);
441 495
 
442
-		if($output->toBool()) return $tobj->textyle_guestbook_srl;
496
+		if($output->toBool()) {
497
+			return $tobj->textyle_guestbook_srl;
498
+		}
443 499
 		return false;
444 500
 	}
445 501
 
@@ -465,7 +521,9 @@  discard block
 block discarded – undo
465 521
 		{
466 522
 			$str = fgets($fp, 1024);
467 523
 			// If it ends with </attaches>, break
468
-			if(trim($str) == '</attachment>') break;
524
+			if(trim($str) == '</attachment>') {
525
+				break;
526
+			}
469 527
 			// If it starts with <file>, handle the attachement in the xml file
470 528
 			if(substr($str, 0, 9)=='<content>')
471 529
 			{
@@ -475,7 +533,9 @@  discard block
 block discarded – undo
475 533
 
476 534
 			$buff .= $str;
477 535
 		}
478
-		if(!file_exists($file_obj->file)) return false;
536
+		if(!file_exists($file_obj->file)) {
537
+			return false;
538
+		}
479 539
 
480 540
 		$buff .= '</attachment>';
481 541
 
@@ -490,15 +550,16 @@  discard block
 block discarded – undo
490 550
 			$path = sprintf("./files/attach/images/%s/%s", $module_srl,getNumberingPath($upload_target_srl,3));
491 551
 			$filename = $path.$file_obj->source_filename;
492 552
 			$file_obj->direct_download = 'Y';
493
-		}
494
-		else
553
+		} else
495 554
 		{
496 555
 			$path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl,3));
497 556
 			$filename = $path.md5(crypt(rand(1000000,900000), rand(0,100)));
498 557
 			$file_obj->direct_download = 'N';
499 558
 		}
500 559
 		// Create a directory
501
-		if(!FileHandler::makeDir($path)) return;
560
+		if(!FileHandler::makeDir($path)) {
561
+			return;
562
+		}
502 563
 
503 564
 		FileHandler::rename($file_obj->file, $filename);
504 565
 		// Insert to the DB
@@ -515,8 +576,11 @@  discard block
 block discarded – undo
515 576
 		{
516 577
 			$uploaded_count++;
517 578
 			$tmp_obj = null;
518
-			if($file_obj->direct_download == 'Y') $files[$name]->url = $file_obj->uploaded_filename; 
519
-			else $files[$name]->url = getUrl('','module','file','act','procFileDownload','file_srl',$file_obj->file_srl,'sid',$file_obj->sid);
579
+			if($file_obj->direct_download == 'Y') {
580
+				$files[$name]->url = $file_obj->uploaded_filename;
581
+			} else {
582
+				$files[$name]->url = getUrl('','module','file','act','procFileDownload','file_srl',$file_obj->file_srl,'sid',$file_obj->sid);
583
+			}
520 584
 			$files[$name]->direct_download = $file_obj->direct_download;
521 585
 			$files[$name]->source_filename = $file_obj->source_filename;
522 586
 			return true;
@@ -532,9 +596,13 @@  discard block
 block discarded – undo
532 596
 	function getTmpFilename()
533 597
 	{
534 598
 		$path = "./files/cache/importer";
535
-		if(!is_dir($path)) FileHandler::makeDir($path);
599
+		if(!is_dir($path)) {
600
+			FileHandler::makeDir($path);
601
+		}
536 602
 		$filename = sprintf("%s/%d", $path, rand(11111111,99999999));
537
-		if(file_exists($filename)) $filename .= rand(111,999);
603
+		if(file_exists($filename)) {
604
+			$filename .= rand(111,999);
605
+		}
538 606
 		return $filename;
539 607
 	}
540 608
 
@@ -553,7 +621,9 @@  discard block
 block discarded – undo
553 621
 		{
554 622
 			$str = trim(fgets($fp, 1024));
555 623
 			$buff .= $str;
556
-			if(substr($str, -10) == '</content>') break;
624
+			if(substr($str, -10) == '</content>') {
625
+				break;
626
+			}
557 627
 		}
558 628
 
559 629
 		$buff = substr($buff, 0, -10);
@@ -572,7 +642,9 @@  discard block
 block discarded – undo
572 642
 	function _replaceTTAttach($matches)
573 643
 	{
574 644
 		$name = $matches[2];
575
-		if(!$name) return $matches[0];
645
+		if(!$name) {
646
+			return $matches[0];
647
+		}
576 648
 
577 649
 		$obj = $this->files[$name];
578 650
 		// If multimedia file is,
@@ -583,14 +655,12 @@  discard block
 block discarded – undo
583 655
 			{
584 656
 				return sprintf('<img editor_component="image_link" src="%s" alt="%s" />', $obj->url, str_replace('"','\\"',$matches[4]));
585 657
 				// If other multimedia file but image is, 
586
-			}
587
-			else
658
+			} else
588 659
 			{
589 660
 				return sprintf('<img src="./common/img/blank.gif" editor_component="multimedia_link" multimedia_src="%s" width="400" height="320" style="display:block;width:400px;height:320px;border:2px dotted #4371B9;background:url(./modules/editor/components/multimedia_link/tpl/multimedia_link_component.gif) no-repeat center;" auto_start="false" alt="" />', $obj->url);
590 661
 			}
591 662
 			// If binary file is
592
-		}
593
-		else
663
+		} else
594 664
 		{
595 665
 			return sprintf('<a href="%s">%s</a>', $obj->url, $obj->source_filename);
596 666
 		}
@@ -603,7 +673,9 @@  discard block
 block discarded – undo
603 673
 	function _replaceTTMovie($matches)
604 674
 	{
605 675
 		$key = $matches[1];
606
-		if(!$key) return $matches[0];
676
+		if(!$key) {
677
+			return $matches[0];
678
+		}
607 679
 
608 680
 		return 
609 681
 			'<object type="application/x-shockwave-flash" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="100%" height="402">'.
@@ -645,8 +717,7 @@  discard block
 block discarded – undo
645 717
 			$tobj->member_srl = $member_info->member_srl;
646 718
 			$tobj->homepage = $member_info->homepage;
647 719
 			$tobj->email_address = $member_info->email_address;
648
-		}
649
-		else
720
+		} else
650 721
 		{
651 722
 			$tobj->password = $val->password->body;
652 723
 			$tobj->nick_name = $val->commenter->name->body;
@@ -670,24 +741,28 @@  discard block
 block discarded – undo
670 741
 			$list_args->head = $list_args->arrange = $tobj->comment_srl;
671 742
 			$list_args->depth = 0;
672 743
 			// Get parent_srl if parent comment exists
673
-		}
674
-		else
744
+		} else
675 745
 		{
676 746
 			// Get parent_srl
677 747
 			$parent_args->comment_srl = $tobj->parent_srl;
678 748
 			$parent_output = executeQuery('comment.getCommentListItem', $parent_args);
679 749
 			// Return if parent comment doesn't exist
680
-			if(!$parent_output->toBool() || !$parent_output->data) return false;
750
+			if(!$parent_output->toBool() || !$parent_output->data) {
751
+				return false;
752
+			}
681 753
 			$parent = $parent_output->data;
682 754
 
683 755
 			$list_args->head = $parent->head;
684 756
 			$list_args->depth = $parent->depth+1;
685
-			if($list_args->depth<2) $list_args->arrange = $tobj->comment_srl;
686
-			else
757
+			if($list_args->depth<2) {
758
+				$list_args->arrange = $tobj->comment_srl;
759
+			} else
687 760
 			{
688 761
 				$list_args->arrange = $parent->arrange;
689 762
 				$output = executeQuery('comment.updateCommentListArrange', $list_args);
690
-				if(!$output->toBool()) return $output;
763
+				if(!$output->toBool()) {
764
+					return $output;
765
+				}
691 766
 			}
692 767
 		}
693 768
 
@@ -695,7 +770,9 @@  discard block
 block discarded – undo
695 770
 		if($output->toBool())
696 771
 		{
697 772
 			$output = executeQuery('comment.insertComment', $tobj);
698
-			if($output->toBool()) return $tobj->comment_srl;
773
+			if($output->toBool()) {
774
+				return $tobj->comment_srl;
775
+			}
699 776
 		}
700 777
 		return false;
701 778
 	}
@@ -710,9 +787,14 @@  discard block
 block discarded – undo
710 787
 	 */
711 788
 	function arrangeCategory($obj, &$category, &$idx, $parent = 0)
712 789
 	{
713
-		if(!$obj->category) return;
714
-		if(!is_array($obj->category)) $c = array($obj->category);
715
-		else $c = $obj->category;
790
+		if(!$obj->category) {
791
+			return;
792
+		}
793
+		if(!is_array($obj->category)) {
794
+			$c = array($obj->category);
795
+		} else {
796
+			$c = $obj->category;
797
+		}
716 798
 		foreach($c as $val)
717 799
 		{
718 800
 			$idx++;
Please login to merge, or discard this patch.
Spacing   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 * @param string $module_name
32 32
 	 * @return int
33 33
 	 */
34
-	function importModule($key, $cur, $index_file, $unit_count, $module_srl, $guestbook_module_srl, $user_id, $module_name=null)
34
+	function importModule($key, $cur, $index_file, $unit_count, $module_srl, $guestbook_module_srl, $user_id, $module_name = null)
35 35
 	{
36 36
 		// Pre-create the objects needed
37 37
 		$this->oXmlParser = new XmlParser();
@@ -40,33 +40,33 @@  discard block
 block discarded – undo
40 40
 		$oDocumentModel = getModel('document');
41 41
 		$category_list = $category_titles = array();
42 42
 		$category_list = $oDocumentModel->getCategoryList($module_srl);
43
-		if(count($category_list)) foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl;
43
+		if (count($category_list)) foreach ($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl;
44 44
 		// First handle categorty information
45 45
 		$category_file = preg_replace('/index$/i', 'category.xml', $index_file);
46
-		if(file_exists($category_file))
46
+		if (file_exists($category_file))
47 47
 		{
48 48
 			// Create the xmlParser object
49 49
 			$xmlDoc = $this->oXmlParser->loadXmlFile($category_file);
50 50
 			// List category information
51
-			if($xmlDoc->categories->category)
51
+			if ($xmlDoc->categories->category)
52 52
 			{
53 53
 				$categories = array();
54 54
 				$idx = 0;
55 55
 				$this->arrangeCategory($xmlDoc->categories, $categories, $idx, 0);
56 56
 
57 57
 				$match_sequence = array();
58
-				foreach($categories as $k => $v)
58
+				foreach ($categories as $k => $v)
59 59
 				{
60 60
 					$category = $v->name;
61
-					if(!$category || $category_titles[$category]) continue;
61
+					if (!$category || $category_titles[$category]) continue;
62 62
 
63 63
 					$obj = null;
64 64
 					$obj->title = $category;
65 65
 					$obj->module_srl = $module_srl; 
66
-					if($v->parent) $obj->parent_srl = $match_sequence[$v->parent];
66
+					if ($v->parent) $obj->parent_srl = $match_sequence[$v->parent];
67 67
 					$output = $oDocumentController->insertCategory($obj);
68 68
 
69
-					if($output->toBool()) $match_sequence[$v->sequence] = $category_titles[$category] = $output->get('category_srl');
69
+					if ($output->toBool()) $match_sequence[$v->sequence] = $category_titles[$category] = $output->get('category_srl');
70 70
 				}
71 71
 				$oDocumentController->makeCategoryFile($module_srl);
72 72
 			}
@@ -74,28 +74,28 @@  discard block
 block discarded – undo
74 74
 		}
75 75
 		$category_list = $category_titles = array();
76 76
 		$category_list = $oDocumentModel->getCategoryList($module_srl);
77
-		if(count($category_list)) foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl;
77
+		if (count($category_list)) foreach ($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl;
78 78
 		// Get administrator information
79 79
 		$oMemberModel = getModel('member');
80 80
 		$member_info = $oMemberModel->getMemberInfoByUserID($user_id);
81 81
 		$author_xml_id = 0;
82 82
 
83
-		if(!$cur) $cur = 0;
83
+		if (!$cur) $cur = 0;
84 84
 		// Open an index file
85
-		$f = fopen($index_file,"r");
85
+		$f = fopen($index_file, "r");
86 86
 		// Pass if already read
87
-		for($i=0;$i<$cur;$i++) fgets($f, 1024);
87
+		for ($i = 0; $i < $cur; $i++) fgets($f, 1024);
88 88
 		// Read each line until the codition meets
89
-		for($idx=$cur;$idx<$cur+$unit_count;$idx++)
89
+		for ($idx = $cur; $idx < $cur + $unit_count; $idx++)
90 90
 		{
91
-			if(feof($f)) break;
91
+			if (feof($f)) break;
92 92
 			// Find a location
93 93
 			$target_file = trim(fgets($f, 1024));
94 94
 
95
-			if(!file_exists($target_file)) continue;
95
+			if (!file_exists($target_file)) continue;
96 96
 			// Start importing data
97
-			$fp = fopen($target_file,"r");
98
-			if(!$fp) continue;
97
+			$fp = fopen($target_file, "r");
98
+			if (!$fp) continue;
99 99
 
100 100
 			$obj = null;
101 101
 			$obj->module_srl = $module_srl;
@@ -107,57 +107,57 @@  discard block
 block discarded – undo
107 107
 			$started = false;
108 108
 			$buff = null;
109 109
 			// Start importing from the body data
110
-			while(!feof($fp))
110
+			while (!feof($fp))
111 111
 			{
112 112
 				$str = fgets($fp, 1024);
113 113
 				// Prepare an item
114
-				if(substr($str,0,5) == '<post')
114
+				if (substr($str, 0, 5) == '<post')
115 115
 				{
116 116
 					$started = true;
117 117
 					continue;
118 118
 					// Import the attachment
119 119
 				}
120
-				else if(substr($str,0,12) == '<attachment ')
120
+				else if (substr($str, 0, 12) == '<attachment ')
121 121
 				{
122
-					if($this->importAttaches($fp, $module_srl, $obj->document_srl, $files, $str)) $obj->uploaded_count++;
122
+					if ($this->importAttaches($fp, $module_srl, $obj->document_srl, $files, $str)) $obj->uploaded_count++;
123 123
 					continue;
124 124
 				}
125 125
 
126
-				if($started) $buff .= $str;
126
+				if ($started) $buff .= $str;
127 127
 			}
128 128
 
129 129
 			$xmlDoc = $this->oXmlParser->parse('<post>'.$buff);
130 130
 
131 131
 			$author_xml_id = $xmlDoc->post->author->body;
132 132
 
133
-			if($xmlDoc->post->category->body)
133
+			if ($xmlDoc->post->category->body)
134 134
 			{
135
-				$tmp_arr = explode('/',$xmlDoc->post->category->body);
136
-				$category = trim($tmp_arr[count($tmp_arr)-1]);
137
-				if($category_titles[$category]) $obj->category_srl = $category_titles[$category];
135
+				$tmp_arr = explode('/', $xmlDoc->post->category->body);
136
+				$category = trim($tmp_arr[count($tmp_arr) - 1]);
137
+				if ($category_titles[$category]) $obj->category_srl = $category_titles[$category];
138 138
 			}
139 139
 
140 140
 			$obj->is_notice = 'N';
141
-			$obj->status = in_array($xmlDoc->post->visibility->body, array('public','syndicated'))?$oDocumentModel->getConfigStatus('public'):$oDocumentModel->getConfigStatus('secret');
141
+			$obj->status = in_array($xmlDoc->post->visibility->body, array('public', 'syndicated')) ? $oDocumentModel->getConfigStatus('public') : $oDocumentModel->getConfigStatus('secret');
142 142
 			$obj->title = $xmlDoc->post->title->body;
143 143
 			$obj->content = $xmlDoc->post->content->body;
144 144
 			$obj->password = md5($xmlDoc->post->password->body);
145
-			$obj->commentStatus = $xmlDoc->post->acceptcomment->body=='1'?'ALLOW':'DENY';
146
-			$obj->allow_trackback = $xmlDoc->post->accepttrackback->body=='1'?'Y':'N';
145
+			$obj->commentStatus = $xmlDoc->post->acceptcomment->body == '1' ? 'ALLOW' : 'DENY';
146
+			$obj->allow_trackback = $xmlDoc->post->accepttrackback->body == '1' ? 'Y' : 'N';
147 147
 			//$obj->allow_comment = $xmlDoc->post->acceptComment->body=='1'?'Y':'N';
148 148
 			//$obj->allow_trackback = $xmlDoc->post->acceptTrackback->body=='1'?'Y':'N';
149
-			$obj->regdate = date("YmdHis",$xmlDoc->post->published->body);
149
+			$obj->regdate = date("YmdHis", $xmlDoc->post->published->body);
150 150
 			$obj->last_update = date("YmdHis", $xmlDoc->post->modified->body);
151
-			if(!$obj->last_update) $obj->last_update = $obj->regdate;
151
+			if (!$obj->last_update) $obj->last_update = $obj->regdate;
152 152
 
153 153
 			$tag = null;
154 154
 			$tmp_tags = null;
155 155
 			$tag = $xmlDoc->post->tag;
156
-			if($tag)
156
+			if ($tag)
157 157
 			{
158
-				if(!is_array($tag)) $tag = array($tag);
159
-				foreach($tag as $key => $val) $tmp_tags[] = $val->body;
160
-				$obj->tags = implode(',',$tmp_tags);
158
+				if (!is_array($tag)) $tag = array($tag);
159
+				foreach ($tag as $key => $val) $tmp_tags[] = $val->body;
160
+				$obj->tags = implode(',', $tmp_tags);
161 161
 			}
162 162
 
163 163
 			$obj->readed_count = 0;
@@ -169,33 +169,33 @@  discard block
 block discarded – undo
169 169
 			$obj->email_address = $member_info->email_address;
170 170
 			$obj->homepage = $member_info->homepage;
171 171
 			$obj->ipaddress = $_REMOTE['SERVER_ADDR'];
172
-			$obj->list_order = $obj->update_order = $obj->document_srl*-1;
172
+			$obj->list_order = $obj->update_order = $obj->document_srl * -1;
173 173
 			$obj->notify_message = 'N';
174 174
 			// Change content information (attachment)
175
-			$obj->content = str_replace('[##_ATTACH_PATH_##]/','',$obj->content);
176
-			if(count($files))
175
+			$obj->content = str_replace('[##_ATTACH_PATH_##]/', '', $obj->content);
176
+			if (count($files))
177 177
 			{
178
-				foreach($files as $key => $val) {
179
-					$obj->content = preg_replace('/(src|href)\=(["\']?)'.preg_quote($key).'(["\']?)/i','$1="'.$val->url.'"',$obj->content);
178
+				foreach ($files as $key => $val) {
179
+					$obj->content = preg_replace('/(src|href)\=(["\']?)'.preg_quote($key).'(["\']?)/i', '$1="'.$val->url.'"', $obj->content);
180 180
 				}
181 181
 			}
182 182
 
183 183
 			$obj->content = preg_replace_callback('!\[##_Movie\|([^\|]*)\|(.*?)_##\]!is', array($this, '_replaceTTMovie'), $obj->content);
184 184
 
185
-			if(count($files))
185
+			if (count($files))
186 186
 			{
187 187
 				$this->files = $files;
188 188
 				$obj->content = preg_replace_callback('!\[##_([a-z0-9]+)\|([^\|]*)\|([^\|]*)\|(.*?)_##\]!is', array($this, '_replaceTTAttach'), $obj->content);
189 189
 			}
190 190
 			// Trackback inserted
191 191
 			$obj->trackback_count = 0;
192
-			if($xmlDoc->post->trackback)
192
+			if ($xmlDoc->post->trackback)
193 193
 			{
194 194
 				$trackbacks = $xmlDoc->post->trackback;
195
-				if(!is_array($trackbacks)) $trackbacks = array($trackbacks);
196
-				if(count($trackbacks))
195
+				if (!is_array($trackbacks)) $trackbacks = array($trackbacks);
196
+				if (count($trackbacks))
197 197
 				{
198
-					foreach($trackbacks as $key => $val)
198
+					foreach ($trackbacks as $key => $val)
199 199
 					{
200 200
 						$tobj = null;
201 201
 						$tobj->trackback_srl = getNextSequence();
@@ -205,40 +205,40 @@  discard block
 block discarded – undo
205 205
 						$tobj->title = $val->title->body;
206 206
 						$tobj->blog_name = $val->site->body;
207 207
 						$tobj->excerpt = $val->excerpt->body;
208
-						$tobj->regdate = date("YmdHis",$val->received->body);
208
+						$tobj->regdate = date("YmdHis", $val->received->body);
209 209
 						$tobj->ipaddress = $val->ip->body;
210
-						$tobj->list_order = -1*$tobj->trackback_srl;
210
+						$tobj->list_order = -1 * $tobj->trackback_srl;
211 211
 						$output = executeQuery('trackback.insertTrackback', $tobj);
212
-						if($output->toBool()) $obj->trackback_count++;
212
+						if ($output->toBool()) $obj->trackback_count++;
213 213
 					}
214 214
 				}
215 215
 			}
216 216
 			// Comment
217 217
 			$obj->comment_count = 0;
218
-			if($xmlDoc->post->comment)
218
+			if ($xmlDoc->post->comment)
219 219
 			{
220 220
 				$comment = $xmlDoc->post->comment;
221
-				if(!is_array($comment)) $comment = array($comment);
222
-				foreach($comment as $key => $val)
221
+				if (!is_array($comment)) $comment = array($comment);
222
+				foreach ($comment as $key => $val)
223 223
 				{
224 224
 					$parent_srl = $this->insertComment($val, $module_srl, $obj->document_srl, $member_info, 0, $author_xml_id);
225
-					if($parent_srl === false) continue;
225
+					if ($parent_srl === false) continue;
226 226
 
227 227
 					$obj->comment_count++;
228
-					if($val->comment)
228
+					if ($val->comment)
229 229
 					{
230 230
 						$child_comment = $val->comment;
231
-						if(!is_array($child_comment)) $child_comment = array($child_comment);
232
-						foreach($child_comment as $k => $v)
231
+						if (!is_array($child_comment)) $child_comment = array($child_comment);
232
+						foreach ($child_comment as $k => $v)
233 233
 						{
234 234
 							$result = $this->insertComment($v, $module_srl, $obj->document_srl, $member_info, $parent_srl, $author_xml_id);
235
-							if($result !== false) $obj->comment_count++;
235
+							if ($result !== false) $obj->comment_count++;
236 236
 						}
237 237
 					}
238 238
 				}
239 239
 			}
240 240
 
241
-			if($module_name == 'textyle')
241
+			if ($module_name == 'textyle')
242 242
 			{
243 243
 				$args->document_srl = $obj->document_srl;
244 244
 				$args->module_srl = $obj->module_srl;
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 				// Visibility value of published state
248 248
 				$status_published = array('public', 'syndicated');
249 249
 				// Save state if not published
250
-				if(!in_array($xmlDoc->post->visibility->body, $status_published))
250
+				if (!in_array($xmlDoc->post->visibility->body, $status_published))
251 251
 				{
252 252
 					$obj->module_srl = $member_info->member_srl; 
253 253
 				}
@@ -255,14 +255,14 @@  discard block
 block discarded – undo
255 255
 			// Document
256 256
 			$output = executeQuery('document.insertDocument', $obj);
257 257
 
258
-			if($output->toBool())
258
+			if ($output->toBool())
259 259
 			{
260 260
 				// Tags
261
-				if($obj->tags)
261
+				if ($obj->tags)
262 262
 				{
263
-					$tag_list = explode(',',$obj->tags);
263
+					$tag_list = explode(',', $obj->tags);
264 264
 					$tag_count = count($tag_list);
265
-					for($i=0;$i<$tag_count;$i++)
265
+					for ($i = 0; $i < $tag_count; $i++)
266 266
 					{
267 267
 						$args = new stdClass;
268 268
 						$args->tag_srl = getNextSequence();
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 						$args->document_srl = $obj->document_srl;
271 271
 						$args->tag = trim($tag_list[$i]);
272 272
 						$args->regdate = $obj->regdate;
273
-						if(!$args->tag) continue;
273
+						if (!$args->tag) continue;
274 274
 						$output = executeQuery('tag.insertTag', $args);
275 275
 					}
276 276
 				}
@@ -282,63 +282,63 @@  discard block
 block discarded – undo
282 282
 
283 283
 		fclose($f);
284 284
 
285
-		if(count($category_list)) foreach($category_list as $key => $val) $oDocumentController->updateCategoryCount($module_srl, $val->category_srl);
285
+		if (count($category_list)) foreach ($category_list as $key => $val) $oDocumentController->updateCategoryCount($module_srl, $val->category_srl);
286 286
 		// Guestbook information
287 287
 		$guestbook_file = preg_replace('/index$/i', 'guestbook.xml', $index_file);
288
-		if(file_exists($guestbook_file))
288
+		if (file_exists($guestbook_file))
289 289
 		{
290 290
 			// Create the xmlParser object
291 291
 			$xmlDoc = $this->oXmlParser->loadXmlFile($guestbook_file);
292 292
 			// Handle guest book information
293
-			if($guestbook_module_srl && $xmlDoc->guestbook->comment)
293
+			if ($guestbook_module_srl && $xmlDoc->guestbook->comment)
294 294
 			{
295 295
 				$comment = $xmlDoc->guestbook->comment;
296
-				if(!is_array($comment)) $comment = array($comment);
296
+				if (!is_array($comment)) $comment = array($comment);
297 297
 
298
-				if($module_name =='textyle')
298
+				if ($module_name == 'textyle')
299 299
 				{
300
-					foreach($comment as $key => $val)
300
+					foreach ($comment as $key => $val)
301 301
 					{
302
-						$textyle_guestbook_srl  = getNextSequence();
302
+						$textyle_guestbook_srl = getNextSequence();
303 303
 
304
-						if($val->comment)
304
+						if ($val->comment)
305 305
 						{
306 306
 							$child_comment = $val->comment;
307
-							if(!is_array($child_comment)) $child_comment = array($child_comment);
308
-							foreach($child_comment as $k => $v)
307
+							if (!is_array($child_comment)) $child_comment = array($child_comment);
308
+							foreach ($child_comment as $k => $v)
309 309
 							{
310
-								$result = $this->insertTextyleGuestbookItem($v, $module_srl, $member_info,0,$textyle_guestbook_srl,$author_xml_id);
310
+								$result = $this->insertTextyleGuestbookItem($v, $module_srl, $member_info, 0, $textyle_guestbook_srl, $author_xml_id);
311 311
 							}
312 312
 						}
313 313
 
314
-						$result = $this->insertTextyleGuestbookItem($val, $module_srl, $member_info,$textyle_guestbook_srl,0,$author_xml_id);
314
+						$result = $this->insertTextyleGuestbookItem($val, $module_srl, $member_info, $textyle_guestbook_srl, 0, $author_xml_id);
315 315
 					}
316 316
 				}
317 317
 				else
318 318
 				{
319
-					foreach($comment as $key => $val)
319
+					foreach ($comment as $key => $val)
320 320
 					{
321 321
 						$obj = null;
322 322
 						$obj->module_srl = $guestbook_module_srl;
323 323
 						$obj->document_srl = getNextSequence();
324 324
 						$obj->uploaded_count = 0;
325 325
 						$obj->is_notice = 'N';
326
-						$obj->status = $val->secret->body=='1'?$oDocumentModel->getConfigStatus('secret'):$oDocumentModel->getConfigStatus('public');
326
+						$obj->status = $val->secret->body == '1' ? $oDocumentModel->getConfigStatus('secret') : $oDocumentModel->getConfigStatus('public');
327 327
 						$obj->content = nl2br($val->content->body);
328 328
 
329 329
 						// Extract a title form the bocy
330
-						$obj->title = cut_str(strip_tags($obj->content),20,'...');
330
+						$obj->title = cut_str(strip_tags($obj->content), 20, '...');
331 331
 						if ($obj->title == '') $obj->title = 'Untitled';
332 332
 
333 333
 						$obj->commentStatus = 'ALLOW';
334 334
 						$obj->allow_trackback = 'N';
335
-						$obj->regdate = date("YmdHis",$val->written->body);
335
+						$obj->regdate = date("YmdHis", $val->written->body);
336 336
 						$obj->last_update = date("YmdHis", $val->written->body);
337
-						if(!$obj->last_update) $obj->last_update = $obj->regdate;
337
+						if (!$obj->last_update) $obj->last_update = $obj->regdate;
338 338
 						$obj->tags = '';
339 339
 						$obj->readed_count = 0;
340 340
 						$obj->voted_count = 0;
341
-						if($author_xml_id && $val->commenter->attrs->id == $author_xml_id)
341
+						if ($author_xml_id && $val->commenter->attrs->id == $author_xml_id)
342 342
 						{
343 343
 							$obj->password = '';
344 344
 							$obj->nick_name = $member_info->nick_name;
@@ -356,19 +356,19 @@  discard block
 block discarded – undo
356 356
 							$homepage = $val->commenter->homepage->body;
357 357
 						}
358 358
 						$obj->ipaddress = $val->commenter->ip->body;
359
-						$obj->list_order = $obj->update_order = $obj->document_srl*-1;
359
+						$obj->list_order = $obj->update_order = $obj->document_srl * -1;
360 360
 						$obj->notify_message = 'N';
361 361
 						$obj->trackback_count = 0;
362 362
 
363 363
 						$obj->comment_count = 0;
364
-						if($val->comment)
364
+						if ($val->comment)
365 365
 						{
366 366
 							$child_comment = $val->comment;
367
-							if(!is_array($child_comment)) $child_comment = array($child_comment);
368
-							foreach($child_comment as $k => $v)
367
+							if (!is_array($child_comment)) $child_comment = array($child_comment);
368
+							foreach ($child_comment as $k => $v)
369 369
 							{
370
-								$result = $this->insertComment($v, $module_srl, $obj->document_srl, $member_info, 0,$author_xml_id);
371
-								if($result !== false) $obj->comment_count++;
370
+								$result = $this->insertComment($v, $module_srl, $obj->document_srl, $member_info, 0, $author_xml_id);
371
+								if ($result !== false) $obj->comment_count++;
372 372
 							}
373 373
 						}
374 374
 
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 			FileHandler::removeFile($guestbook_file);
381 381
 		}
382 382
 
383
-		return $idx-1;
383
+		return $idx - 1;
384 384
 	}
385 385
 
386 386
 	/**
@@ -393,10 +393,10 @@  discard block
 block discarded – undo
393 393
 	 * @param int $author_xml_id
394 394
 	 * @return int|bool
395 395
 	 */
396
-	function insertTextyleGuestbookItem($val, $module_srl, $member_info, $textyle_guestbook_srl,$parent_srl = 0, $author_xml_id=null)
396
+	function insertTextyleGuestbookItem($val, $module_srl, $member_info, $textyle_guestbook_srl, $parent_srl = 0, $author_xml_id = null)
397 397
 	{
398 398
 		$tobj = null;
399
-		if($textyle_guestbook_srl>0)
399
+		if ($textyle_guestbook_srl > 0)
400 400
 		{
401 401
 			$tobj->textyle_guestbook_srl = $textyle_guestbook_srl;
402 402
 		}
@@ -405,9 +405,9 @@  discard block
 block discarded – undo
405 405
 			$tobj->textyle_guestbook_srl = getNextSequence();
406 406
 		}
407 407
 		$tobj->module_srl = $module_srl;
408
-		$tobj->is_secret = $val->secret->body=='1'?1:-1;
408
+		$tobj->is_secret = $val->secret->body == '1' ? 1 : -1;
409 409
 		$tobj->content = nl2br($val->content->body);
410
-		if($author_xml_id && $val->commenter->attrs->id == $author_xml_id)
410
+		if ($author_xml_id && $val->commenter->attrs->id == $author_xml_id)
411 411
 		{
412 412
 			$tobj->password = '';
413 413
 			$tobj->nick_name = $member_info->nick_name;
@@ -424,22 +424,22 @@  discard block
 block discarded – undo
424 424
 			$tobj->homepage = $val->commenter->homepage->body;
425 425
 			$tobj->member_srl = 0;
426 426
 		}
427
-		$tobj->last_update = $tobj->regdate = date("YmdHis",$val->written->body);
427
+		$tobj->last_update = $tobj->regdate = date("YmdHis", $val->written->body);
428 428
 		$tobj->ipaddress = $val->commenter->ip->body;
429 429
 
430
-		if($parent_srl>0)
430
+		if ($parent_srl > 0)
431 431
 		{
432 432
 			$tobj->parent_srl = $parent_srl;
433 433
 			$tobj->list_order = $tobj->parent_srl * -1;
434 434
 		}
435 435
 		else
436 436
 		{
437
-			$tobj->list_order = $tobj->textyle_guestbook_srl*-1;
437
+			$tobj->list_order = $tobj->textyle_guestbook_srl * -1;
438 438
 		}
439 439
 
440 440
 		$output = executeQuery('textyle.insertTextyleGuestbook', $tobj);
441 441
 
442
-		if($output->toBool()) return $tobj->textyle_guestbook_srl;
442
+		if ($output->toBool()) return $tobj->textyle_guestbook_srl;
443 443
 		return false;
444 444
 	}
445 445
 
@@ -456,18 +456,18 @@  discard block
 block discarded – undo
456 456
 	{
457 457
 		$uploaded_count = 0;
458 458
 
459
-		$file_obj  = null;
459
+		$file_obj = null;
460 460
 		$file_obj->file_srl = getNextSequence();
461 461
 		$file_obj->upload_target_srl = $upload_target_srl;
462 462
 		$file_obj->module_srl = $module_srl;
463 463
 
464
-		while(!feof($fp))
464
+		while (!feof($fp))
465 465
 		{
466 466
 			$str = fgets($fp, 1024);
467 467
 			// If it ends with </attaches>, break
468
-			if(trim($str) == '</attachment>') break;
468
+			if (trim($str) == '</attachment>') break;
469 469
 			// If it starts with <file>, handle the attachement in the xml file
470
-			if(substr($str, 0, 9)=='<content>')
470
+			if (substr($str, 0, 9) == '<content>')
471 471
 			{
472 472
 				$file_obj->file = $this->saveTemporaryFile($fp, $str);
473 473
 				continue;
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
 
476 476
 			$buff .= $str;
477 477
 		}
478
-		if(!file_exists($file_obj->file)) return false;
478
+		if (!file_exists($file_obj->file)) return false;
479 479
 
480 480
 		$buff .= '</attachment>';
481 481
 
@@ -485,20 +485,20 @@  discard block
 block discarded – undo
485 485
 		$file_obj->download_count = $xmlDoc->attachment->downloads->body;
486 486
 		$name = $xmlDoc->attachment->name->body;
487 487
 		// Set upload path by checking if the attachement is an image or other kind of file
488
-		if(preg_match("/\.(asf|asf|asx|avi|flv|gif|jpeg|jpg|m4a|m4v|mid|midi|moov|mov|mp1|mp2|mp3|mp4|mpeg|mpg|ogg|png|qt|ra|ram|rm|rmm|wav|webm|webp|wma|wmv)$/i", $file_obj->source_filename))
488
+		if (preg_match("/\.(asf|asf|asx|avi|flv|gif|jpeg|jpg|m4a|m4v|mid|midi|moov|mov|mp1|mp2|mp3|mp4|mpeg|mpg|ogg|png|qt|ra|ram|rm|rmm|wav|webm|webp|wma|wmv)$/i", $file_obj->source_filename))
489 489
 		{
490
-			$path = sprintf("./files/attach/images/%s/%s", $module_srl,getNumberingPath($upload_target_srl,3));
490
+			$path = sprintf("./files/attach/images/%s/%s", $module_srl, getNumberingPath($upload_target_srl, 3));
491 491
 			$filename = $path.$file_obj->source_filename;
492 492
 			$file_obj->direct_download = 'Y';
493 493
 		}
494 494
 		else
495 495
 		{
496
-			$path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl,3));
497
-			$filename = $path.md5(crypt(rand(1000000,900000), rand(0,100)));
496
+			$path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl, 3));
497
+			$filename = $path.md5(crypt(rand(1000000, 900000), rand(0, 100)));
498 498
 			$file_obj->direct_download = 'N';
499 499
 		}
500 500
 		// Create a directory
501
-		if(!FileHandler::makeDir($path)) return;
501
+		if (!FileHandler::makeDir($path)) return;
502 502
 
503 503
 		FileHandler::rename($file_obj->file, $filename);
504 504
 		// Insert to the DB
@@ -507,16 +507,16 @@  discard block
 block discarded – undo
507 507
 		$file_obj->file_size = filesize($filename);
508 508
 		$file_obj->comment = NULL;
509 509
 		$file_obj->member_srl = 0;
510
-		$file_obj->sid = md5(rand(rand(1111111,4444444),rand(4444445,9999999)));
510
+		$file_obj->sid = md5(rand(rand(1111111, 4444444), rand(4444445, 9999999)));
511 511
 		$file_obj->isvalid = 'Y';
512 512
 		$output = executeQuery('file.insertFile', $file_obj);
513 513
 
514
-		if($output->toBool())
514
+		if ($output->toBool())
515 515
 		{
516 516
 			$uploaded_count++;
517 517
 			$tmp_obj = null;
518
-			if($file_obj->direct_download == 'Y') $files[$name]->url = $file_obj->uploaded_filename; 
519
-			else $files[$name]->url = getUrl('','module','file','act','procFileDownload','file_srl',$file_obj->file_srl,'sid',$file_obj->sid);
518
+			if ($file_obj->direct_download == 'Y') $files[$name]->url = $file_obj->uploaded_filename; 
519
+			else $files[$name]->url = getUrl('', 'module', 'file', 'act', 'procFileDownload', 'file_srl', $file_obj->file_srl, 'sid', $file_obj->sid);
520 520
 			$files[$name]->direct_download = $file_obj->direct_download;
521 521
 			$files[$name]->source_filename = $file_obj->source_filename;
522 522
 			return true;
@@ -532,9 +532,9 @@  discard block
 block discarded – undo
532 532
 	function getTmpFilename()
533 533
 	{
534 534
 		$path = "./files/cache/importer";
535
-		if(!is_dir($path)) FileHandler::makeDir($path);
536
-		$filename = sprintf("%s/%d", $path, rand(11111111,99999999));
537
-		if(file_exists($filename)) $filename .= rand(111,999);
535
+		if (!is_dir($path)) FileHandler::makeDir($path);
536
+		$filename = sprintf("%s/%d", $path, rand(11111111, 99999999));
537
+		if (file_exists($filename)) $filename .= rand(111, 999);
538 538
 		return $filename;
539 539
 	}
540 540
 
@@ -549,11 +549,11 @@  discard block
 block discarded – undo
549 549
 		$temp_filename = $this->getTmpFilename();
550 550
 		$buff = substr($buff, 9);
551 551
 
552
-		while(!feof($fp))
552
+		while (!feof($fp))
553 553
 		{
554 554
 			$str = trim(fgets($fp, 1024));
555 555
 			$buff .= $str;
556
-			if(substr($str, -10) == '</content>') break;
556
+			if (substr($str, -10) == '</content>') break;
557 557
 		}
558 558
 
559 559
 		$buff = substr($buff, 0, -10);
@@ -572,16 +572,16 @@  discard block
 block discarded – undo
572 572
 	function _replaceTTAttach($matches)
573 573
 	{
574 574
 		$name = $matches[2];
575
-		if(!$name) return $matches[0];
575
+		if (!$name) return $matches[0];
576 576
 
577 577
 		$obj = $this->files[$name];
578 578
 		// If multimedia file is,
579
-		if($obj->direct_download == 'Y')
579
+		if ($obj->direct_download == 'Y')
580 580
 		{
581 581
 			// If image file is
582
-			if(preg_match('/\.(jpg|gif|jpeg|png)$/i', $obj->source_filename))
582
+			if (preg_match('/\.(jpg|gif|jpeg|png)$/i', $obj->source_filename))
583 583
 			{
584
-				return sprintf('<img editor_component="image_link" src="%s" alt="%s" />', $obj->url, str_replace('"','\\"',$matches[4]));
584
+				return sprintf('<img editor_component="image_link" src="%s" alt="%s" />', $obj->url, str_replace('"', '\\"', $matches[4]));
585 585
 				// If other multimedia file but image is, 
586 586
 			}
587 587
 			else
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
 	function _replaceTTMovie($matches)
604 604
 	{
605 605
 		$key = $matches[1];
606
-		if(!$key) return $matches[0];
606
+		if (!$key) return $matches[0];
607 607
 
608 608
 		return 
609 609
 			'<object type="application/x-shockwave-flash" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="100%" height="402">'.
@@ -631,12 +631,12 @@  discard block
 block discarded – undo
631 631
 		$tobj->comment_srl = getNextSequence();
632 632
 		$tobj->module_srl = $module_srl;
633 633
 		$tobj->document_srl = $document_srl;
634
-		$tobj->is_secret = $val->secret->body=='1'?'Y':'N';
634
+		$tobj->is_secret = $val->secret->body == '1' ? 'Y' : 'N';
635 635
 		$tobj->notify_message = 'N';
636 636
 		$tobj->content = nl2br($val->content->body);
637 637
 		$tobj->voted_count = 0;
638 638
 		$tobj->status = 1;
639
-		if($author_xml_id && $val->commenter->attrs->id == $author_xml_id)
639
+		if ($author_xml_id && $val->commenter->attrs->id == $author_xml_id)
640 640
 		{
641 641
 			$tobj->password = '';
642 642
 			$tobj->nick_name = $member_info->nick_name;
@@ -653,9 +653,9 @@  discard block
 block discarded – undo
653 653
 			$tobj->homepage = $val->commenter->homepage->body;
654 654
 			$tobj->member_srl = 0;
655 655
 		}
656
-		$tobj->last_update = $tobj->regdate = date("YmdHis",$val->written->body);
656
+		$tobj->last_update = $tobj->regdate = date("YmdHis", $val->written->body);
657 657
 		$tobj->ipaddress = $val->commenter->ip->body;
658
-		$tobj->list_order = $tobj->comment_srl*-1;
658
+		$tobj->list_order = $tobj->comment_srl * -1;
659 659
 		$tobj->sequence = $sequence;
660 660
 		$tobj->parent_srl = $parent_srl;
661 661
 		// Comment list first
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
 		$list_args->module_srl = $tobj->module_srl;
666 666
 		$list_args->regdate = $tobj->regdate;
667 667
 		// Set data directly if parent comment doesn't exist
668
-		if(!$tobj->parent_srl)
668
+		if (!$tobj->parent_srl)
669 669
 		{
670 670
 			$list_args->head = $list_args->arrange = $tobj->comment_srl;
671 671
 			$list_args->depth = 0;
@@ -677,25 +677,25 @@  discard block
 block discarded – undo
677 677
 			$parent_args->comment_srl = $tobj->parent_srl;
678 678
 			$parent_output = executeQuery('comment.getCommentListItem', $parent_args);
679 679
 			// Return if parent comment doesn't exist
680
-			if(!$parent_output->toBool() || !$parent_output->data) return false;
680
+			if (!$parent_output->toBool() || !$parent_output->data) return false;
681 681
 			$parent = $parent_output->data;
682 682
 
683 683
 			$list_args->head = $parent->head;
684
-			$list_args->depth = $parent->depth+1;
685
-			if($list_args->depth<2) $list_args->arrange = $tobj->comment_srl;
684
+			$list_args->depth = $parent->depth + 1;
685
+			if ($list_args->depth < 2) $list_args->arrange = $tobj->comment_srl;
686 686
 			else
687 687
 			{
688 688
 				$list_args->arrange = $parent->arrange;
689 689
 				$output = executeQuery('comment.updateCommentListArrange', $list_args);
690
-				if(!$output->toBool()) return $output;
690
+				if (!$output->toBool()) return $output;
691 691
 			}
692 692
 		}
693 693
 
694 694
 		$output = executeQuery('comment.insertCommentList', $list_args);
695
-		if($output->toBool())
695
+		if ($output->toBool())
696 696
 		{
697 697
 			$output = executeQuery('comment.insertComment', $tobj);
698
-			if($output->toBool()) return $tobj->comment_srl;
698
+			if ($output->toBool()) return $tobj->comment_srl;
699 699
 		}
700 700
 		return false;
701 701
 	}
@@ -710,10 +710,10 @@  discard block
 block discarded – undo
710 710
 	 */
711 711
 	function arrangeCategory($obj, &$category, &$idx, $parent = 0)
712 712
 	{
713
-		if(!$obj->category) return;
714
-		if(!is_array($obj->category)) $c = array($obj->category);
713
+		if (!$obj->category) return;
714
+		if (!is_array($obj->category)) $c = array($obj->category);
715 715
 		else $c = $obj->category;
716
-		foreach($c as $val)
716
+		foreach ($c as $val)
717 717
 		{
718 718
 			$idx++;
719 719
 			$priority = $val->priority->body;
Please login to merge, or discard this patch.