@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | function &getInstance() |
163 | 163 | { |
164 | 164 | static $theInstance = null; |
165 | - if(!$theInstance) |
|
165 | + if (!$theInstance) |
|
166 | 166 | { |
167 | 167 | $theInstance = new Context(); |
168 | 168 | } |
@@ -182,10 +182,10 @@ discard block |
||
182 | 182 | |
183 | 183 | // include ssl action cache file |
184 | 184 | $this->sslActionCacheFile = FileHandler::getRealPath($this->sslActionCacheFile); |
185 | - if(is_readable($this->sslActionCacheFile)) |
|
185 | + if (is_readable($this->sslActionCacheFile)) |
|
186 | 186 | { |
187 | 187 | require($this->sslActionCacheFile); |
188 | - if(isset($sslActions)) |
|
188 | + if (isset($sslActions)) |
|
189 | 189 | { |
190 | 190 | $this->ssl_actions = $sslActions; |
191 | 191 | } |
@@ -201,12 +201,12 @@ discard block |
||
201 | 201 | function init() |
202 | 202 | { |
203 | 203 | // fix missing HTTP_RAW_POST_DATA in PHP 5.6 and above |
204 | - if(!isset($GLOBALS['HTTP_RAW_POST_DATA']) && version_compare(PHP_VERSION, '5.6.0', '>=') === TRUE) |
|
204 | + if (!isset($GLOBALS['HTTP_RAW_POST_DATA']) && version_compare(PHP_VERSION, '5.6.0', '>=') === TRUE) |
|
205 | 205 | { |
206 | 206 | $GLOBALS['HTTP_RAW_POST_DATA'] = file_get_contents("php://input"); |
207 | 207 | |
208 | 208 | // If content is not XML JSON, unset |
209 | - if(!preg_match('/^[\<\{\[]/', $GLOBALS['HTTP_RAW_POST_DATA']) && strpos($_SERVER['CONTENT_TYPE'], 'json') === FALSE && strpos($_SERVER['HTTP_CONTENT_TYPE'], 'json') === FALSE) |
|
209 | + if (!preg_match('/^[\<\{\[]/', $GLOBALS['HTTP_RAW_POST_DATA']) && strpos($_SERVER['CONTENT_TYPE'], 'json') === FALSE && strpos($_SERVER['HTTP_CONTENT_TYPE'], 'json') === FALSE) |
|
210 | 210 | { |
211 | 211 | unset($GLOBALS['HTTP_RAW_POST_DATA']); |
212 | 212 | } |
@@ -228,11 +228,11 @@ discard block |
||
228 | 228 | $this->_setUploadedArgument(); |
229 | 229 | |
230 | 230 | $this->loadDBInfo(); |
231 | - if($this->db_info->use_sitelock == 'Y') |
|
231 | + if ($this->db_info->use_sitelock == 'Y') |
|
232 | 232 | { |
233 | - if(is_array($this->db_info->sitelock_whitelist)) $whitelist = $this->db_info->sitelock_whitelist; |
|
233 | + if (is_array($this->db_info->sitelock_whitelist)) $whitelist = $this->db_info->sitelock_whitelist; |
|
234 | 234 | |
235 | - if(!IpFilter::filter($whitelist)) |
|
235 | + if (!IpFilter::filter($whitelist)) |
|
236 | 236 | { |
237 | 237 | $title = ($this->db_info->sitelock_title) ? $this->db_info->sitelock_title : 'Maintenance in progress...'; |
238 | 238 | $message = $this->db_info->sitelock_message; |
@@ -242,52 +242,52 @@ discard block |
||
242 | 242 | define('_XE_SITELOCK_MESSAGE_', $message); |
243 | 243 | |
244 | 244 | header("HTTP/1.1 403 Forbidden"); |
245 | - if(FileHandler::exists(_XE_PATH_ . 'common/tpl/sitelock.user.html')) |
|
245 | + if (FileHandler::exists(_XE_PATH_.'common/tpl/sitelock.user.html')) |
|
246 | 246 | { |
247 | - include _XE_PATH_ . 'common/tpl/sitelock.user.html'; |
|
247 | + include _XE_PATH_.'common/tpl/sitelock.user.html'; |
|
248 | 248 | } |
249 | 249 | else |
250 | 250 | { |
251 | - include _XE_PATH_ . 'common/tpl/sitelock.html'; |
|
251 | + include _XE_PATH_.'common/tpl/sitelock.html'; |
|
252 | 252 | } |
253 | 253 | exit; |
254 | 254 | } |
255 | 255 | } |
256 | 256 | |
257 | 257 | // If XE is installed, get virtual site information |
258 | - if(self::isInstalled()) |
|
258 | + if (self::isInstalled()) |
|
259 | 259 | { |
260 | 260 | $oModuleModel = getModel('module'); |
261 | 261 | $site_module_info = $oModuleModel->getDefaultMid(); |
262 | 262 | |
263 | - if(!isset($site_module_info)) |
|
263 | + if (!isset($site_module_info)) |
|
264 | 264 | { |
265 | 265 | $site_module_info = new stdClass(); |
266 | 266 | } |
267 | 267 | |
268 | 268 | // if site_srl of site_module_info is 0 (default site), compare the domain to default_url of db_config |
269 | - if($site_module_info->site_srl == 0 && $site_module_info->domain != $this->db_info->default_url) |
|
269 | + if ($site_module_info->site_srl == 0 && $site_module_info->domain != $this->db_info->default_url) |
|
270 | 270 | { |
271 | 271 | $site_module_info->domain = $this->db_info->default_url; |
272 | 272 | } |
273 | 273 | |
274 | 274 | $this->set('site_module_info', $site_module_info); |
275 | - if($site_module_info->site_srl && isSiteID($site_module_info->domain)) |
|
275 | + if ($site_module_info->site_srl && isSiteID($site_module_info->domain)) |
|
276 | 276 | { |
277 | 277 | $this->set('vid', $site_module_info->domain, TRUE); |
278 | 278 | } |
279 | 279 | |
280 | - if(!isset($this->db_info)) |
|
280 | + if (!isset($this->db_info)) |
|
281 | 281 | { |
282 | 282 | $this->db_info = new stdClass(); |
283 | 283 | } |
284 | 284 | |
285 | 285 | $this->db_info->lang_type = $site_module_info->default_language; |
286 | - if(!$this->db_info->lang_type) |
|
286 | + if (!$this->db_info->lang_type) |
|
287 | 287 | { |
288 | 288 | $this->db_info->lang_type = 'en'; |
289 | 289 | } |
290 | - if(!$this->db_info->use_db_session) |
|
290 | + if (!$this->db_info->use_db_session) |
|
291 | 291 | { |
292 | 292 | $this->db_info->use_db_session = 'N'; |
293 | 293 | } |
@@ -297,30 +297,30 @@ discard block |
||
297 | 297 | $lang_supported = $this->loadLangSelected(); |
298 | 298 | |
299 | 299 | // Retrieve language type set in user's cookie |
300 | - if($this->lang_type = $this->get('l')) |
|
300 | + if ($this->lang_type = $this->get('l')) |
|
301 | 301 | { |
302 | - if($_COOKIE['lang_type'] != $this->lang_type) |
|
302 | + if ($_COOKIE['lang_type'] != $this->lang_type) |
|
303 | 303 | { |
304 | 304 | setcookie('lang_type', $this->lang_type, $_SERVER['REQUEST_TIME'] + 3600 * 24 * 1000); |
305 | 305 | } |
306 | 306 | } |
307 | - elseif($_COOKIE['lang_type']) |
|
307 | + elseif ($_COOKIE['lang_type']) |
|
308 | 308 | { |
309 | 309 | $this->lang_type = $_COOKIE['lang_type']; |
310 | 310 | } |
311 | 311 | |
312 | 312 | // If it's not exists, follow default language type set in db_info |
313 | - if(!$this->lang_type) |
|
313 | + if (!$this->lang_type) |
|
314 | 314 | { |
315 | 315 | $this->lang_type = $this->db_info->lang_type; |
316 | 316 | } |
317 | 317 | |
318 | 318 | // if still lang_type has not been set or has not-supported type , set as English. |
319 | - if(!$this->lang_type) |
|
319 | + if (!$this->lang_type) |
|
320 | 320 | { |
321 | 321 | $this->lang_type = 'en'; |
322 | 322 | } |
323 | - if(is_array($lang_supported) && !isset($lang_supported[$this->lang_type])) |
|
323 | + if (is_array($lang_supported) && !isset($lang_supported[$this->lang_type])) |
|
324 | 324 | { |
325 | 325 | $this->lang_type = 'en'; |
326 | 326 | } |
@@ -329,10 +329,10 @@ discard block |
||
329 | 329 | $this->setLangType($this->lang_type); |
330 | 330 | |
331 | 331 | // load module module's language file according to language setting |
332 | - $this->loadLang(_XE_PATH_ . 'modules/module/lang'); |
|
332 | + $this->loadLang(_XE_PATH_.'modules/module/lang'); |
|
333 | 333 | |
334 | 334 | // set session handler |
335 | - if(self::isInstalled() && $this->db_info->use_db_session == 'Y') |
|
335 | + if (self::isInstalled() && $this->db_info->use_db_session == 'Y') |
|
336 | 336 | { |
337 | 337 | $oSessionModel = getModel('session'); |
338 | 338 | $oSessionController = getController('session'); |
@@ -342,11 +342,11 @@ discard block |
||
342 | 342 | ); |
343 | 343 | } |
344 | 344 | |
345 | - if($sess = $_POST[session_name()]) session_id($sess); |
|
345 | + if ($sess = $_POST[session_name()]) session_id($sess); |
|
346 | 346 | session_start(); |
347 | 347 | |
348 | 348 | // set authentication information in Context and session |
349 | - if(self::isInstalled()) |
|
349 | + if (self::isInstalled()) |
|
350 | 350 | { |
351 | 351 | $oModuleModel = getModel('module'); |
352 | 352 | $oModuleModel->loadModuleExtends(); |
@@ -354,15 +354,15 @@ discard block |
||
354 | 354 | $oMemberModel = getModel('member'); |
355 | 355 | $oMemberController = getController('member'); |
356 | 356 | |
357 | - if($oMemberController && $oMemberModel) |
|
357 | + if ($oMemberController && $oMemberModel) |
|
358 | 358 | { |
359 | 359 | // if signed in, validate it. |
360 | - if($oMemberModel->isLogged()) |
|
360 | + if ($oMemberModel->isLogged()) |
|
361 | 361 | { |
362 | 362 | $oMemberController->setSessionInfo(); |
363 | 363 | } |
364 | 364 | // check auto sign-in |
365 | - elseif($_COOKIE['xeak']) |
|
365 | + elseif ($_COOKIE['xeak']) |
|
366 | 366 | { |
367 | 367 | $oMemberController->doAutologin(); |
368 | 368 | } |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | |
375 | 375 | // load common language file |
376 | 376 | $this->lang = &$GLOBALS['lang']; |
377 | - $this->loadLang(_XE_PATH_ . 'common/lang/'); |
|
377 | + $this->loadLang(_XE_PATH_.'common/lang/'); |
|
378 | 378 | |
379 | 379 | // check if using rewrite module |
380 | 380 | $this->allow_rewrite = ($this->db_info->use_rewrite == 'Y' ? TRUE : FALSE); |
@@ -382,28 +382,28 @@ discard block |
||
382 | 382 | // set locations for javascript use |
383 | 383 | $url = array(); |
384 | 384 | $current_url = self::getRequestUri(); |
385 | - if($_SERVER['REQUEST_METHOD'] == 'GET') |
|
385 | + if ($_SERVER['REQUEST_METHOD'] == 'GET') |
|
386 | 386 | { |
387 | - if($this->get_vars) |
|
387 | + if ($this->get_vars) |
|
388 | 388 | { |
389 | 389 | $url = array(); |
390 | - foreach($this->get_vars as $key => $val) |
|
390 | + foreach ($this->get_vars as $key => $val) |
|
391 | 391 | { |
392 | - if(is_array($val) && count($val) > 0) |
|
392 | + if (is_array($val) && count($val) > 0) |
|
393 | 393 | { |
394 | - foreach($val as $k => $v) |
|
394 | + foreach ($val as $k => $v) |
|
395 | 395 | { |
396 | - $url[] = $key . '[' . $k . ']=' . urlencode($v); |
|
396 | + $url[] = $key.'['.$k.']='.urlencode($v); |
|
397 | 397 | } |
398 | 398 | } |
399 | - elseif($val) |
|
399 | + elseif ($val) |
|
400 | 400 | { |
401 | - $url[] = $key . '=' . urlencode($val); |
|
401 | + $url[] = $key.'='.urlencode($val); |
|
402 | 402 | } |
403 | 403 | } |
404 | 404 | |
405 | 405 | $current_url = self::getRequestUri(); |
406 | - if($url) $current_url .= '?' . join('&', $url); |
|
406 | + if ($url) $current_url .= '?'.join('&', $url); |
|
407 | 407 | } |
408 | 408 | else |
409 | 409 | { |
@@ -418,12 +418,12 @@ discard block |
||
418 | 418 | $this->set('current_url', $current_url); |
419 | 419 | $this->set('request_uri', self::getRequestUri()); |
420 | 420 | |
421 | - if(strpos($current_url, 'xn--') !== FALSE) |
|
421 | + if (strpos($current_url, 'xn--') !== FALSE) |
|
422 | 422 | { |
423 | 423 | $this->set('current_url', self::decodeIdna($current_url)); |
424 | 424 | } |
425 | 425 | |
426 | - if(strpos(self::getRequestUri(), 'xn--') !== FALSE) |
|
426 | + if (strpos(self::getRequestUri(), 'xn--') !== FALSE) |
|
427 | 427 | { |
428 | 428 | $this->set('request_uri', self::decodeIdna(self::getRequestUri())); |
429 | 429 | } |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | { |
449 | 449 | $self = self::getInstance(); |
450 | 450 | |
451 | - if(!$self->isInstalled()) |
|
451 | + if (!$self->isInstalled()) |
|
452 | 452 | { |
453 | 453 | return; |
454 | 454 | } |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | ob_end_clean(); |
459 | 459 | |
460 | 460 | // If master_db information does not exist, the config file needs to be updated |
461 | - if(!isset($db_info->master_db)) |
|
461 | + if (!isset($db_info->master_db)) |
|
462 | 462 | { |
463 | 463 | $db_info->master_db = array(); |
464 | 464 | $db_info->master_db["db_type"] = $db_info->db_type; |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | $db_info->master_db["db_table_prefix"] = $db_info->db_table_prefix; |
477 | 477 | unset($db_info->db_table_prefix); |
478 | 478 | |
479 | - if(isset($db_info->master_db["db_table_prefix"]) && substr_compare($db_info->master_db["db_table_prefix"], '_', -1) !== 0) |
|
479 | + if (isset($db_info->master_db["db_table_prefix"]) && substr_compare($db_info->master_db["db_table_prefix"], '_', -1) !== 0) |
|
480 | 480 | { |
481 | 481 | $db_info->master_db["db_table_prefix"] .= '_'; |
482 | 482 | } |
@@ -488,42 +488,42 @@ discard block |
||
488 | 488 | $oInstallController->makeConfigFile(); |
489 | 489 | } |
490 | 490 | |
491 | - if(version_compare(PHP_VERSION, '7.0', '>=')) |
|
491 | + if (version_compare(PHP_VERSION, '7.0', '>=')) |
|
492 | 492 | { |
493 | 493 | $db_info->master_db["db_type"] = preg_replace('/^mysql(_.+)?$/', 'mysqli$1', $db_info->master_db["db_type"]); |
494 | - foreach($db_info->slave_db as &$slave_db_info) |
|
494 | + foreach ($db_info->slave_db as &$slave_db_info) |
|
495 | 495 | { |
496 | 496 | $slave_db_info["db_type"] = preg_replace('/^mysql(_.+)?$/', 'mysqli$1', $slave_db_info["db_type"]); |
497 | 497 | } |
498 | 498 | } |
499 | 499 | |
500 | - if(!$db_info->use_prepared_statements) |
|
500 | + if (!$db_info->use_prepared_statements) |
|
501 | 501 | { |
502 | 502 | $db_info->use_prepared_statements = 'Y'; |
503 | 503 | } |
504 | 504 | |
505 | - if(!$db_info->time_zone) |
|
505 | + if (!$db_info->time_zone) |
|
506 | 506 | $db_info->time_zone = date('O'); |
507 | 507 | $GLOBALS['_time_zone'] = $db_info->time_zone; |
508 | 508 | |
509 | - if($db_info->qmail_compatibility != 'Y') |
|
509 | + if ($db_info->qmail_compatibility != 'Y') |
|
510 | 510 | $db_info->qmail_compatibility = 'N'; |
511 | 511 | $GLOBALS['_qmail_compatibility'] = $db_info->qmail_compatibility; |
512 | 512 | |
513 | - if(!$db_info->use_db_session) |
|
513 | + if (!$db_info->use_db_session) |
|
514 | 514 | $db_info->use_db_session = 'N'; |
515 | - if(!$db_info->use_ssl) |
|
515 | + if (!$db_info->use_ssl) |
|
516 | 516 | $db_info->use_ssl = 'none'; |
517 | 517 | $this->set('_use_ssl', $db_info->use_ssl); |
518 | 518 | |
519 | 519 | $self->set('_http_port', ($db_info->http_port) ? $db_info->http_port : NULL); |
520 | 520 | $self->set('_https_port', ($db_info->https_port) ? $db_info->https_port : NULL); |
521 | 521 | |
522 | - if(!$db_info->sitelock_whitelist) { |
|
522 | + if (!$db_info->sitelock_whitelist) { |
|
523 | 523 | $db_info->sitelock_whitelist = '127.0.0.1'; |
524 | 524 | } |
525 | 525 | |
526 | - if(is_string($db_info->sitelock_whitelist)) { |
|
526 | + if (is_string($db_info->sitelock_whitelist)) { |
|
527 | 527 | $db_info->sitelock_whitelist = explode(',', $db_info->sitelock_whitelist); |
528 | 528 | } |
529 | 529 | |
@@ -594,10 +594,10 @@ discard block |
||
594 | 594 | function loadLangSupported() |
595 | 595 | { |
596 | 596 | static $lang_supported = null; |
597 | - if(!$lang_supported) |
|
597 | + if (!$lang_supported) |
|
598 | 598 | { |
599 | - $langs = file(_XE_PATH_ . 'common/lang/lang.info'); |
|
600 | - foreach($langs as $val) |
|
599 | + $langs = file(_XE_PATH_.'common/lang/lang.info'); |
|
600 | + foreach ($langs as $val) |
|
601 | 601 | { |
602 | 602 | list($lang_prefix, $lang_text) = explode(',', $val); |
603 | 603 | $lang_text = trim($lang_text); |
@@ -615,17 +615,17 @@ discard block |
||
615 | 615 | function loadLangSelected() |
616 | 616 | { |
617 | 617 | static $lang_selected = null; |
618 | - if(!$lang_selected) |
|
618 | + if (!$lang_selected) |
|
619 | 619 | { |
620 | - $orig_lang_file = _XE_PATH_ . 'common/lang/lang.info'; |
|
621 | - $selected_lang_file = _XE_PATH_ . 'files/config/lang_selected.info'; |
|
622 | - if(!FileHandler::hasContent($selected_lang_file)) |
|
620 | + $orig_lang_file = _XE_PATH_.'common/lang/lang.info'; |
|
621 | + $selected_lang_file = _XE_PATH_.'files/config/lang_selected.info'; |
|
622 | + if (!FileHandler::hasContent($selected_lang_file)) |
|
623 | 623 | { |
624 | - $old_selected_lang_file = _XE_PATH_ . 'files/cache/lang_selected.info'; |
|
624 | + $old_selected_lang_file = _XE_PATH_.'files/cache/lang_selected.info'; |
|
625 | 625 | FileHandler::moveFile($old_selected_lang_file, $selected_lang_file); |
626 | 626 | } |
627 | 627 | |
628 | - if(!FileHandler::hasContent($selected_lang_file)) |
|
628 | + if (!FileHandler::hasContent($selected_lang_file)) |
|
629 | 629 | { |
630 | 630 | $buff = FileHandler::readFile($orig_lang_file); |
631 | 631 | FileHandler::writeFile($selected_lang_file, $buff); |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | else |
635 | 635 | { |
636 | 636 | $langs = file($selected_lang_file); |
637 | - foreach($langs as $val) |
|
637 | + foreach ($langs as $val) |
|
638 | 638 | { |
639 | 639 | list($lang_prefix, $lang_text) = explode(',', $val); |
640 | 640 | $lang_text = trim($lang_text); |
@@ -653,56 +653,56 @@ discard block |
||
653 | 653 | function checkSSO() |
654 | 654 | { |
655 | 655 | // pass if it's not GET request or XE is not yet installed |
656 | - if($this->db_info->use_sso != 'Y' || isCrawler()) |
|
656 | + if ($this->db_info->use_sso != 'Y' || isCrawler()) |
|
657 | 657 | { |
658 | 658 | return TRUE; |
659 | 659 | } |
660 | 660 | $checkActList = array('rss' => 1, 'atom' => 1); |
661 | - if(self::getRequestMethod() != 'GET' || !self::isInstalled() || isset($checkActList[self::get('act')])) |
|
661 | + if (self::getRequestMethod() != 'GET' || !self::isInstalled() || isset($checkActList[self::get('act')])) |
|
662 | 662 | { |
663 | 663 | return TRUE; |
664 | 664 | } |
665 | 665 | |
666 | 666 | // pass if default URL is not set |
667 | 667 | $default_url = trim($this->db_info->default_url); |
668 | - if(!$default_url) |
|
668 | + if (!$default_url) |
|
669 | 669 | { |
670 | 670 | return TRUE; |
671 | 671 | } |
672 | 672 | |
673 | - if(substr_compare($default_url, '/', -1) !== 0) |
|
673 | + if (substr_compare($default_url, '/', -1) !== 0) |
|
674 | 674 | { |
675 | 675 | $default_url .= '/'; |
676 | 676 | } |
677 | 677 | |
678 | 678 | // for sites recieving SSO valdiation |
679 | - if($default_url == self::getRequestUri()) |
|
679 | + if ($default_url == self::getRequestUri()) |
|
680 | 680 | { |
681 | - if(self::get('url')) |
|
681 | + if (self::get('url')) |
|
682 | 682 | { |
683 | 683 | $url = base64_decode(self::get('url')); |
684 | 684 | $url_info = parse_url($url); |
685 | - if(!Password::checkSignature($url, self::get('sig'))) |
|
685 | + if (!Password::checkSignature($url, self::get('sig'))) |
|
686 | 686 | { |
687 | 687 | echo self::get('lang')->msg_invalid_request; |
688 | 688 | return false; |
689 | 689 | } |
690 | 690 | |
691 | 691 | $oModuleModel = getModel('module'); |
692 | - $domain = $url_info['host'] . $url_info['path']; |
|
693 | - if(substr_compare($domain, '/', -1) === 0) $domain = substr($domain, 0, -1); |
|
692 | + $domain = $url_info['host'].$url_info['path']; |
|
693 | + if (substr_compare($domain, '/', -1) === 0) $domain = substr($domain, 0, -1); |
|
694 | 694 | $site_info = $oModuleModel->getSiteInfoByDomain($domain); |
695 | 695 | |
696 | - if($site_info->site_srl) |
|
696 | + if ($site_info->site_srl) |
|
697 | 697 | { |
698 | - $url_info['query'].= ($url_info['query'] ? '&' : '') . 'SSOID=' . urlencode(session_id()) . '&sig=' . urlencode(Password::createSignature(session_id())); |
|
699 | - $redirect_url = sprintf('%s://%s%s%s?%s', $url_info['scheme'], $url_info['host'], $url_info['port'] ? ':' . $url_info['port'] : '', $url_info['path'], $url_info['query']); |
|
698 | + $url_info['query'] .= ($url_info['query'] ? '&' : '').'SSOID='.urlencode(session_id()).'&sig='.urlencode(Password::createSignature(session_id())); |
|
699 | + $redirect_url = sprintf('%s://%s%s%s?%s', $url_info['scheme'], $url_info['host'], $url_info['port'] ? ':'.$url_info['port'] : '', $url_info['path'], $url_info['query']); |
|
700 | 700 | } |
701 | 701 | else |
702 | 702 | { |
703 | 703 | $redirect_url = $url; |
704 | 704 | } |
705 | - header('location:' . $redirect_url); |
|
705 | + header('location:'.$redirect_url); |
|
706 | 706 | |
707 | 707 | return FALSE; |
708 | 708 | } |
@@ -711,9 +711,9 @@ discard block |
||
711 | 711 | else |
712 | 712 | { |
713 | 713 | // result handling : set session_name() |
714 | - if($session_name = self::get('SSOID')) |
|
714 | + if ($session_name = self::get('SSOID')) |
|
715 | 715 | { |
716 | - if(!Password::checkSignature($session_name, self::get('sig'))) |
|
716 | + if (!Password::checkSignature($session_name, self::get('sig'))) |
|
717 | 717 | { |
718 | 718 | echo self::get('lang')->msg_invalid_request; |
719 | 719 | return false; |
@@ -722,17 +722,17 @@ discard block |
||
722 | 722 | setcookie(session_name(), $session_name); |
723 | 723 | |
724 | 724 | $url = preg_replace('/[\?\&]SSOID=.+$/', '', self::getRequestUrl()); |
725 | - header('location:' . $url); |
|
725 | + header('location:'.$url); |
|
726 | 726 | return FALSE; |
727 | 727 | // send SSO request |
728 | 728 | } |
729 | - else if(!self::get('SSOID') && $_COOKIE['sso'] != md5(self::getRequestUri())) |
|
729 | + else if (!self::get('SSOID') && $_COOKIE['sso'] != md5(self::getRequestUri())) |
|
730 | 730 | { |
731 | 731 | setcookie('sso', md5(self::getRequestUri())); |
732 | 732 | $origin_url = self::getRequestUrl(); |
733 | 733 | $origin_sig = Password::createSignature($origin_url); |
734 | 734 | $url = sprintf("%s?url=%s&sig=%s", $default_url, urlencode(base64_encode($origin_url)), urlencode($origin_sig)); |
735 | - header('location:' . $url); |
|
735 | + header('location:'.$url); |
|
736 | 736 | return FALSE; |
737 | 737 | } |
738 | 738 | } |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | { |
760 | 760 | $self = self::getInstance(); |
761 | 761 | |
762 | - if(!$self->isFTPRegisted()) |
|
762 | + if (!$self->isFTPRegisted()) |
|
763 | 763 | { |
764 | 764 | return null; |
765 | 765 | } |
@@ -777,15 +777,15 @@ discard block |
||
777 | 777 | */ |
778 | 778 | function addBrowserTitle($site_title) |
779 | 779 | { |
780 | - if(!$site_title) |
|
780 | + if (!$site_title) |
|
781 | 781 | { |
782 | 782 | return; |
783 | 783 | } |
784 | 784 | $self = self::getInstance(); |
785 | 785 | |
786 | - if($self->site_title) |
|
786 | + if ($self->site_title) |
|
787 | 787 | { |
788 | - $self->site_title .= ' - ' . $site_title; |
|
788 | + $self->site_title .= ' - '.$site_title; |
|
789 | 789 | } |
790 | 790 | else |
791 | 791 | { |
@@ -801,7 +801,7 @@ discard block |
||
801 | 801 | */ |
802 | 802 | function setBrowserTitle($site_title) |
803 | 803 | { |
804 | - if(!$site_title) |
|
804 | + if (!$site_title) |
|
805 | 805 | { |
806 | 806 | return; |
807 | 807 | } |
@@ -833,7 +833,7 @@ discard block |
||
833 | 833 | $oModuleModel = getModel('module'); |
834 | 834 | $moduleConfig = $oModuleModel->getModuleConfig('module'); |
835 | 835 | |
836 | - if(isset($moduleConfig->siteTitle)) |
|
836 | + if (isset($moduleConfig->siteTitle)) |
|
837 | 837 | { |
838 | 838 | return $moduleConfig->siteTitle; |
839 | 839 | } |
@@ -860,30 +860,30 @@ discard block |
||
860 | 860 | global $lang; |
861 | 861 | |
862 | 862 | $self = self::getInstance(); |
863 | - if(!$self->lang_type) |
|
863 | + if (!$self->lang_type) |
|
864 | 864 | { |
865 | 865 | return; |
866 | 866 | } |
867 | - if(!is_object($lang)) |
|
867 | + if (!is_object($lang)) |
|
868 | 868 | { |
869 | 869 | $lang = new stdClass; |
870 | 870 | } |
871 | 871 | |
872 | - if(!($filename = $self->_loadXmlLang($path))) |
|
872 | + if (!($filename = $self->_loadXmlLang($path))) |
|
873 | 873 | { |
874 | 874 | $filename = $self->_loadPhpLang($path); |
875 | 875 | } |
876 | 876 | |
877 | - if(!is_array($self->loaded_lang_files)) |
|
877 | + if (!is_array($self->loaded_lang_files)) |
|
878 | 878 | { |
879 | 879 | $self->loaded_lang_files = array(); |
880 | 880 | } |
881 | - if(in_array($filename, $self->loaded_lang_files)) |
|
881 | + if (in_array($filename, $self->loaded_lang_files)) |
|
882 | 882 | { |
883 | 883 | return; |
884 | 884 | } |
885 | 885 | |
886 | - if($filename && is_readable($filename)) |
|
886 | + if ($filename && is_readable($filename)) |
|
887 | 887 | { |
888 | 888 | $self->loaded_lang_files[] = $filename; |
889 | 889 | include($filename); |
@@ -904,24 +904,24 @@ discard block |
||
904 | 904 | { |
905 | 905 | global $lang; |
906 | 906 | |
907 | - if(!$path) return; |
|
907 | + if (!$path) return; |
|
908 | 908 | |
909 | - $_path = 'eval://' . $path; |
|
909 | + $_path = 'eval://'.$path; |
|
910 | 910 | |
911 | - if(in_array($_path, $this->loaded_lang_files)) |
|
911 | + if (in_array($_path, $this->loaded_lang_files)) |
|
912 | 912 | { |
913 | 913 | return; |
914 | 914 | } |
915 | 915 | |
916 | - if(substr_compare($path, '/', -1) !== 0) |
|
916 | + if (substr_compare($path, '/', -1) !== 0) |
|
917 | 917 | { |
918 | 918 | $path .= '/'; |
919 | 919 | } |
920 | 920 | |
921 | - $oXmlLangParser = new XmlLangParser($path . 'lang.xml', $this->lang_type); |
|
921 | + $oXmlLangParser = new XmlLangParser($path.'lang.xml', $this->lang_type); |
|
922 | 922 | $content = $oXmlLangParser->getCompileContent(); |
923 | 923 | |
924 | - if($content) |
|
924 | + if ($content) |
|
925 | 925 | { |
926 | 926 | $this->loaded_lang_files[] = $_path; |
927 | 927 | eval($content); |
@@ -936,9 +936,9 @@ discard block |
||
936 | 936 | */ |
937 | 937 | function _loadXmlLang($path) |
938 | 938 | { |
939 | - if(!$path) return; |
|
939 | + if (!$path) return; |
|
940 | 940 | |
941 | - $oXmlLangParser = new XmlLangParser($path . ((substr_compare($path, '/', -1) !== 0) ? '/' : '') . 'lang.xml', $this->lang_type); |
|
941 | + $oXmlLangParser = new XmlLangParser($path.((substr_compare($path, '/', -1) !== 0) ? '/' : '').'lang.xml', $this->lang_type); |
|
942 | 942 | return $oXmlLangParser->compile(); |
943 | 943 | } |
944 | 944 | |
@@ -950,22 +950,22 @@ discard block |
||
950 | 950 | */ |
951 | 951 | function _loadPhpLang($path) |
952 | 952 | { |
953 | - if(!$path) return; |
|
953 | + if (!$path) return; |
|
954 | 954 | |
955 | - if(substr_compare($path, '/', -1) !== 0) |
|
955 | + if (substr_compare($path, '/', -1) !== 0) |
|
956 | 956 | { |
957 | 957 | $path .= '/'; |
958 | 958 | } |
959 | - $path_tpl = $path . '%s.lang.php'; |
|
959 | + $path_tpl = $path.'%s.lang.php'; |
|
960 | 960 | $file = sprintf($path_tpl, $this->lang_type); |
961 | 961 | |
962 | 962 | $langs = array('ko', 'en'); // this will be configurable. |
963 | - while(!is_readable($file) && $langs[0]) |
|
963 | + while (!is_readable($file) && $langs[0]) |
|
964 | 964 | { |
965 | 965 | $file = sprintf($path_tpl, array_shift($langs)); |
966 | 966 | } |
967 | 967 | |
968 | - if(!is_readable($file)) |
|
968 | + if (!is_readable($file)) |
|
969 | 969 | { |
970 | 970 | return FALSE; |
971 | 971 | } |
@@ -1007,11 +1007,11 @@ discard block |
||
1007 | 1007 | */ |
1008 | 1008 | function getLang($code) |
1009 | 1009 | { |
1010 | - if(!$code) |
|
1010 | + if (!$code) |
|
1011 | 1011 | { |
1012 | 1012 | return; |
1013 | 1013 | } |
1014 | - if($GLOBALS['lang']->{$code}) |
|
1014 | + if ($GLOBALS['lang']->{$code}) |
|
1015 | 1015 | { |
1016 | 1016 | return $GLOBALS['lang']->{$code}; |
1017 | 1017 | } |
@@ -1027,7 +1027,7 @@ discard block |
||
1027 | 1027 | */ |
1028 | 1028 | function setLang($code, $val) |
1029 | 1029 | { |
1030 | - if(!isset($GLOBALS['lang'])) |
|
1030 | + if (!isset($GLOBALS['lang'])) |
|
1031 | 1031 | { |
1032 | 1032 | $GLOBALS['lang'] = new stdClass(); |
1033 | 1033 | } |
@@ -1052,17 +1052,17 @@ discard block |
||
1052 | 1052 | |
1053 | 1053 | $obj = clone $source_obj; |
1054 | 1054 | |
1055 | - foreach($charset_list as $charset) |
|
1055 | + foreach ($charset_list as $charset) |
|
1056 | 1056 | { |
1057 | - array_walk($obj,'Context::checkConvertFlag',$charset); |
|
1057 | + array_walk($obj, 'Context::checkConvertFlag', $charset); |
|
1058 | 1058 | $flag = self::checkConvertFlag($flag = TRUE); |
1059 | - if($flag) |
|
1059 | + if ($flag) |
|
1060 | 1060 | { |
1061 | - if($charset == 'UTF-8') |
|
1061 | + if ($charset == 'UTF-8') |
|
1062 | 1062 | { |
1063 | 1063 | return $obj; |
1064 | 1064 | } |
1065 | - array_walk($obj,'Context::doConvertEncoding',$charset); |
|
1065 | + array_walk($obj, 'Context::doConvertEncoding', $charset); |
|
1066 | 1066 | return $obj; |
1067 | 1067 | } |
1068 | 1068 | } |
@@ -1081,11 +1081,11 @@ discard block |
||
1081 | 1081 | function checkConvertFlag(&$val, $key = null, $charset = null) |
1082 | 1082 | { |
1083 | 1083 | static $flag = TRUE; |
1084 | - if($charset) |
|
1084 | + if ($charset) |
|
1085 | 1085 | { |
1086 | - if(is_array($val)) |
|
1087 | - array_walk($val,'Context::checkConvertFlag',$charset); |
|
1088 | - else if($val && iconv($charset,$charset,$val)!=$val) $flag = FALSE; |
|
1086 | + if (is_array($val)) |
|
1087 | + array_walk($val, 'Context::checkConvertFlag', $charset); |
|
1088 | + else if ($val && iconv($charset, $charset, $val) != $val) $flag = FALSE; |
|
1089 | 1089 | else $flag = FALSE; |
1090 | 1090 | } |
1091 | 1091 | else |
@@ -1109,9 +1109,9 @@ discard block |
||
1109 | 1109 | { |
1110 | 1110 | if (is_array($val)) |
1111 | 1111 | { |
1112 | - array_walk($val,'Context::doConvertEncoding',$charset); |
|
1112 | + array_walk($val, 'Context::doConvertEncoding', $charset); |
|
1113 | 1113 | } |
1114 | - else $val = iconv($charset,'UTF-8',$val); |
|
1114 | + else $val = iconv($charset, 'UTF-8', $val); |
|
1115 | 1115 | } |
1116 | 1116 | |
1117 | 1117 | /** |
@@ -1122,7 +1122,7 @@ discard block |
||
1122 | 1122 | */ |
1123 | 1123 | function convertEncodingStr($str) |
1124 | 1124 | { |
1125 | - if(!$str) return null; |
|
1125 | + if (!$str) return null; |
|
1126 | 1126 | $obj = new stdClass(); |
1127 | 1127 | $obj->str = $str; |
1128 | 1128 | $obj = self::convertEncoding($obj); |
@@ -1131,9 +1131,9 @@ discard block |
||
1131 | 1131 | |
1132 | 1132 | function decodeIdna($domain) |
1133 | 1133 | { |
1134 | - if(strpos($domain, 'xn--') !== FALSE) |
|
1134 | + if (strpos($domain, 'xn--') !== FALSE) |
|
1135 | 1135 | { |
1136 | - require_once(_XE_PATH_ . 'libs/idna_convert/idna_convert.class.php'); |
|
1136 | + require_once(_XE_PATH_.'libs/idna_convert/idna_convert.class.php'); |
|
1137 | 1137 | $IDN = new idna_convert(array('idn_version' => 2008)); |
1138 | 1138 | $domain = $IDN->decode($domain); |
1139 | 1139 | } |
@@ -1164,7 +1164,7 @@ discard block |
||
1164 | 1164 | { |
1165 | 1165 | $self = self::getInstance(); |
1166 | 1166 | |
1167 | - if($self->response_method) |
|
1167 | + if ($self->response_method) |
|
1168 | 1168 | { |
1169 | 1169 | return $self->response_method; |
1170 | 1170 | } |
@@ -1204,7 +1204,7 @@ discard block |
||
1204 | 1204 | $this->_recursiveCheckVar($_SERVER['HTTP_HOST']); |
1205 | 1205 | |
1206 | 1206 | $pattern = "/[\,\"\'\{\}\[\]\(\);$]/"; |
1207 | - if(preg_match($pattern, $_SERVER['HTTP_HOST'])) |
|
1207 | + if (preg_match($pattern, $_SERVER['HTTP_HOST'])) |
|
1208 | 1208 | { |
1209 | 1209 | $this->isSuccessInit = FALSE; |
1210 | 1210 | } |
@@ -1217,30 +1217,30 @@ discard block |
||
1217 | 1217 | */ |
1218 | 1218 | function _setRequestArgument() |
1219 | 1219 | { |
1220 | - if(!count($_REQUEST)) |
|
1220 | + if (!count($_REQUEST)) |
|
1221 | 1221 | { |
1222 | 1222 | return; |
1223 | 1223 | } |
1224 | 1224 | |
1225 | 1225 | $requestMethod = $this->getRequestMethod(); |
1226 | - foreach($_REQUEST as $key => $val) |
|
1226 | + foreach ($_REQUEST as $key => $val) |
|
1227 | 1227 | { |
1228 | - if($val === '' || self::get($key)) |
|
1228 | + if ($val === '' || self::get($key)) |
|
1229 | 1229 | { |
1230 | 1230 | continue; |
1231 | 1231 | } |
1232 | 1232 | $key = htmlentities($key); |
1233 | 1233 | $val = $this->_filterRequestVar($key, $val, false, ($requestMethod == 'GET')); |
1234 | 1234 | |
1235 | - if($requestMethod == 'GET' && isset($_GET[$key])) |
|
1235 | + if ($requestMethod == 'GET' && isset($_GET[$key])) |
|
1236 | 1236 | { |
1237 | 1237 | $set_to_vars = TRUE; |
1238 | 1238 | } |
1239 | - elseif($requestMethod == 'POST' && isset($_POST[$key])) |
|
1239 | + elseif ($requestMethod == 'POST' && isset($_POST[$key])) |
|
1240 | 1240 | { |
1241 | 1241 | $set_to_vars = TRUE; |
1242 | 1242 | } |
1243 | - elseif($requestMethod == 'JS_CALLBACK' && (isset($_GET[$key]) || isset($_POST[$key]))) |
|
1243 | + elseif ($requestMethod == 'JS_CALLBACK' && (isset($_GET[$key]) || isset($_POST[$key]))) |
|
1244 | 1244 | { |
1245 | 1245 | $set_to_vars = TRUE; |
1246 | 1246 | } |
@@ -1249,7 +1249,7 @@ discard block |
||
1249 | 1249 | $set_to_vars = FALSE; |
1250 | 1250 | } |
1251 | 1251 | |
1252 | - if($set_to_vars) |
|
1252 | + if ($set_to_vars) |
|
1253 | 1253 | { |
1254 | 1254 | $this->_recursiveCheckVar($val); |
1255 | 1255 | } |
@@ -1260,20 +1260,20 @@ discard block |
||
1260 | 1260 | |
1261 | 1261 | function _recursiveCheckVar($val) |
1262 | 1262 | { |
1263 | - if(is_string($val)) |
|
1263 | + if (is_string($val)) |
|
1264 | 1264 | { |
1265 | - foreach($this->patterns as $pattern) |
|
1265 | + foreach ($this->patterns as $pattern) |
|
1266 | 1266 | { |
1267 | - if(preg_match($pattern, $val)) |
|
1267 | + if (preg_match($pattern, $val)) |
|
1268 | 1268 | { |
1269 | 1269 | $this->isSuccessInit = FALSE; |
1270 | 1270 | return; |
1271 | 1271 | } |
1272 | 1272 | } |
1273 | 1273 | } |
1274 | - else if(is_array($val)) |
|
1274 | + else if (is_array($val)) |
|
1275 | 1275 | { |
1276 | - foreach($val as $val2) |
|
1276 | + foreach ($val as $val2) |
|
1277 | 1277 | { |
1278 | 1278 | $this->_recursiveCheckVar($val2); |
1279 | 1279 | } |
@@ -1287,7 +1287,7 @@ discard block |
||
1287 | 1287 | */ |
1288 | 1288 | function _setJSONRequestArgument() |
1289 | 1289 | { |
1290 | - if($this->getRequestMethod() != 'JSON') |
|
1290 | + if ($this->getRequestMethod() != 'JSON') |
|
1291 | 1291 | { |
1292 | 1292 | return; |
1293 | 1293 | } |
@@ -1295,7 +1295,7 @@ discard block |
||
1295 | 1295 | $params = array(); |
1296 | 1296 | parse_str($GLOBALS['HTTP_RAW_POST_DATA'], $params); |
1297 | 1297 | |
1298 | - foreach($params as $key => $val) |
|
1298 | + foreach ($params as $key => $val) |
|
1299 | 1299 | { |
1300 | 1300 | $key = htmlentities($key); |
1301 | 1301 | $this->set($key, $this->_filterRequestVar($key, $val, 1), TRUE); |
@@ -1309,13 +1309,13 @@ discard block |
||
1309 | 1309 | */ |
1310 | 1310 | function _setXmlRpcArgument() |
1311 | 1311 | { |
1312 | - if($this->getRequestMethod() != 'XMLRPC') |
|
1312 | + if ($this->getRequestMethod() != 'XMLRPC') |
|
1313 | 1313 | { |
1314 | 1314 | return; |
1315 | 1315 | } |
1316 | 1316 | |
1317 | 1317 | $xml = $GLOBALS['HTTP_RAW_POST_DATA']; |
1318 | - if(Security::detectingXEE($xml)) |
|
1318 | + if (Security::detectingXEE($xml)) |
|
1319 | 1319 | { |
1320 | 1320 | header("HTTP/1.0 400 Bad Request"); |
1321 | 1321 | exit; |
@@ -1327,12 +1327,12 @@ discard block |
||
1327 | 1327 | $params = $xml_obj->methodcall->params; |
1328 | 1328 | unset($params->node_name, $params->attrs, $params->body); |
1329 | 1329 | |
1330 | - if(!count(get_object_vars($params))) |
|
1330 | + if (!count(get_object_vars($params))) |
|
1331 | 1331 | { |
1332 | 1332 | return; |
1333 | 1333 | } |
1334 | 1334 | |
1335 | - foreach($params as $key => $val) |
|
1335 | + foreach ($params as $key => $val) |
|
1336 | 1336 | { |
1337 | 1337 | $this->set($key, $this->_filterXmlVars($key, $val), TRUE); |
1338 | 1338 | } |
@@ -1347,10 +1347,10 @@ discard block |
||
1347 | 1347 | */ |
1348 | 1348 | function _filterXmlVars($key, $val) |
1349 | 1349 | { |
1350 | - if(is_array($val)) |
|
1350 | + if (is_array($val)) |
|
1351 | 1351 | { |
1352 | 1352 | $stack = array(); |
1353 | - foreach($val as $k => $v) |
|
1353 | + foreach ($val as $k => $v) |
|
1354 | 1354 | { |
1355 | 1355 | $stack[$k] = $this->_filterXmlVars($k, $v); |
1356 | 1356 | } |
@@ -1360,20 +1360,20 @@ discard block |
||
1360 | 1360 | |
1361 | 1361 | $body = $val->body; |
1362 | 1362 | unset($val->node_name, $val->attrs, $val->body); |
1363 | - if(!count(get_object_vars($val))) |
|
1363 | + if (!count(get_object_vars($val))) |
|
1364 | 1364 | { |
1365 | 1365 | return $this->_filterRequestVar($key, $body, 0); |
1366 | 1366 | } |
1367 | 1367 | |
1368 | 1368 | $stack = new stdClass(); |
1369 | - foreach($val as $k => $v) |
|
1369 | + foreach ($val as $k => $v) |
|
1370 | 1370 | { |
1371 | 1371 | $output = $this->_filterXmlVars($k, $v); |
1372 | - if(is_object($v) && $v->attrs->type == 'array') |
|
1372 | + if (is_object($v) && $v->attrs->type == 'array') |
|
1373 | 1373 | { |
1374 | 1374 | $output = array($output); |
1375 | 1375 | } |
1376 | - if($k == 'value' && (is_array($v) || $v->attrs->type == 'array')) |
|
1376 | + if ($k == 'value' && (is_array($v) || $v->attrs->type == 'array')) |
|
1377 | 1377 | { |
1378 | 1378 | return $output; |
1379 | 1379 | } |
@@ -1381,7 +1381,7 @@ discard block |
||
1381 | 1381 | $stack->{$k} = $output; |
1382 | 1382 | } |
1383 | 1383 | |
1384 | - if(!count(get_object_vars($stack))) |
|
1384 | + if (!count(get_object_vars($stack))) |
|
1385 | 1385 | { |
1386 | 1386 | return NULL; |
1387 | 1387 | } |
@@ -1400,16 +1400,16 @@ discard block |
||
1400 | 1400 | */ |
1401 | 1401 | function _filterRequestVar($key, $val, $do_stripslashes = true, $remove_hack = false) |
1402 | 1402 | { |
1403 | - if(!($isArray = is_array($val))) |
|
1403 | + if (!($isArray = is_array($val))) |
|
1404 | 1404 | { |
1405 | 1405 | $val = array($val); |
1406 | 1406 | } |
1407 | 1407 | |
1408 | 1408 | $result = array(); |
1409 | - foreach($val as $k => $v) |
|
1409 | + foreach ($val as $k => $v) |
|
1410 | 1410 | { |
1411 | - if($remove_hack && !is_array($v)) { |
|
1412 | - if(stripos($v, '<script') || stripos($v, 'lt;script') || stripos($v, '%3Cscript')) |
|
1411 | + if ($remove_hack && !is_array($v)) { |
|
1412 | + if (stripos($v, '<script') || stripos($v, 'lt;script') || stripos($v, '%3Cscript')) |
|
1413 | 1413 | { |
1414 | 1414 | $result[$k] = escape($v); |
1415 | 1415 | continue; |
@@ -1417,18 +1417,18 @@ discard block |
||
1417 | 1417 | } |
1418 | 1418 | |
1419 | 1419 | $k = htmlentities($k); |
1420 | - if($key === 'page' || $key === 'cpage' || substr_compare($key, 'srl', -3) === 0) |
|
1420 | + if ($key === 'page' || $key === 'cpage' || substr_compare($key, 'srl', -3) === 0) |
|
1421 | 1421 | { |
1422 | 1422 | $result[$k] = !preg_match('/^[0-9,]+$/', $v) ? (int) $v : $v; |
1423 | 1423 | } |
1424 | - elseif(in_array($key, array('mid','search_keyword','search_target','xe_validator_id'))) { |
|
1424 | + elseif (in_array($key, array('mid', 'search_keyword', 'search_target', 'xe_validator_id'))) { |
|
1425 | 1425 | $result[$k] = escape($v, false); |
1426 | 1426 | } |
1427 | - elseif($key === 'vid') |
|
1427 | + elseif ($key === 'vid') |
|
1428 | 1428 | { |
1429 | 1429 | $result[$k] = urlencode($v); |
1430 | 1430 | } |
1431 | - elseif(stripos($key, 'XE_VALIDATOR', 0) === 0) |
|
1431 | + elseif (stripos($key, 'XE_VALIDATOR', 0) === 0) |
|
1432 | 1432 | { |
1433 | 1433 | unset($result[$k]); |
1434 | 1434 | } |
@@ -1436,7 +1436,7 @@ discard block |
||
1436 | 1436 | { |
1437 | 1437 | $result[$k] = $v; |
1438 | 1438 | |
1439 | - if($do_stripslashes && version_compare(PHP_VERSION, '5.4.0', '<') && get_magic_quotes_gpc()) |
|
1439 | + if ($do_stripslashes && version_compare(PHP_VERSION, '5.4.0', '<') && get_magic_quotes_gpc()) |
|
1440 | 1440 | { |
1441 | 1441 | if (is_array($result[$k])) |
1442 | 1442 | { |
@@ -1448,7 +1448,7 @@ discard block |
||
1448 | 1448 | } |
1449 | 1449 | } |
1450 | 1450 | |
1451 | - if(is_array($result[$k])) |
|
1451 | + if (is_array($result[$k])) |
|
1452 | 1452 | { |
1453 | 1453 | array_walk_recursive($result[$k], function(&$val) { $val = trim($val); }); |
1454 | 1454 | } |
@@ -1457,7 +1457,7 @@ discard block |
||
1457 | 1457 | $result[$k] = trim($result[$k]); |
1458 | 1458 | } |
1459 | 1459 | |
1460 | - if($remove_hack) |
|
1460 | + if ($remove_hack) |
|
1461 | 1461 | { |
1462 | 1462 | $result[$k] = escape($result[$k], false); |
1463 | 1463 | } |
@@ -1485,17 +1485,17 @@ discard block |
||
1485 | 1485 | */ |
1486 | 1486 | function _setUploadedArgument() |
1487 | 1487 | { |
1488 | - if($_SERVER['REQUEST_METHOD'] != 'POST' || !$_FILES || (stripos($_SERVER['CONTENT_TYPE'], 'multipart/form-data') === FALSE && stripos($_SERVER['HTTP_CONTENT_TYPE'], 'multipart/form-data') === FALSE)) |
|
1488 | + if ($_SERVER['REQUEST_METHOD'] != 'POST' || !$_FILES || (stripos($_SERVER['CONTENT_TYPE'], 'multipart/form-data') === FALSE && stripos($_SERVER['HTTP_CONTENT_TYPE'], 'multipart/form-data') === FALSE)) |
|
1489 | 1489 | { |
1490 | 1490 | return; |
1491 | 1491 | } |
1492 | 1492 | |
1493 | - foreach($_FILES as $key => $val) |
|
1493 | + foreach ($_FILES as $key => $val) |
|
1494 | 1494 | { |
1495 | 1495 | $tmp_name = $val['tmp_name']; |
1496 | - if(!is_array($tmp_name)) |
|
1496 | + if (!is_array($tmp_name)) |
|
1497 | 1497 | { |
1498 | - if(!UploadFileFilter::check($tmp_name, $val['name'])) |
|
1498 | + if (!UploadFileFilter::check($tmp_name, $val['name'])) |
|
1499 | 1499 | { |
1500 | 1500 | continue; |
1501 | 1501 | } |
@@ -1508,7 +1508,7 @@ discard block |
||
1508 | 1508 | $files = array(); |
1509 | 1509 | foreach ($tmp_name as $i => $j) |
1510 | 1510 | { |
1511 | - if(!UploadFileFilter::check($val['tmp_name'][$i], $val['name'][$i])) |
|
1511 | + if (!UploadFileFilter::check($val['tmp_name'][$i], $val['name'][$i])) |
|
1512 | 1512 | { |
1513 | 1513 | $files = array(); |
1514 | 1514 | unset($_FILES[$key]); |
@@ -1522,7 +1522,7 @@ discard block |
||
1522 | 1522 | $file['size'] = $val['size'][$i]; |
1523 | 1523 | $files[] = $file; |
1524 | 1524 | } |
1525 | - if(count($files)) |
|
1525 | + if (count($files)) |
|
1526 | 1526 | { |
1527 | 1527 | self::set($key, $files, true); |
1528 | 1528 | } |
@@ -1547,16 +1547,16 @@ discard block |
||
1547 | 1547 | function getRequestUrl() |
1548 | 1548 | { |
1549 | 1549 | static $url = null; |
1550 | - if(is_null($url)) |
|
1550 | + if (is_null($url)) |
|
1551 | 1551 | { |
1552 | 1552 | $url = self::getRequestUri(); |
1553 | - if(count($_GET) > 0) |
|
1553 | + if (count($_GET) > 0) |
|
1554 | 1554 | { |
1555 | - foreach($_GET as $key => $val) |
|
1555 | + foreach ($_GET as $key => $val) |
|
1556 | 1556 | { |
1557 | - $vars[] = $key . '=' . ($val ? urlencode(self::convertEncodingStr($val)) : ''); |
|
1557 | + $vars[] = $key.'='.($val ? urlencode(self::convertEncodingStr($val)) : ''); |
|
1558 | 1558 | } |
1559 | - $url .= '?' . join('&', $vars); |
|
1559 | + $url .= '?'.join('&', $vars); |
|
1560 | 1560 | } |
1561 | 1561 | } |
1562 | 1562 | return $url; |
@@ -1571,7 +1571,7 @@ discard block |
||
1571 | 1571 | $self = self::getInstance(); |
1572 | 1572 | $js_callback_func = isset($_GET['xe_js_callback']) ? $_GET['xe_js_callback'] : $_POST['xe_js_callback']; |
1573 | 1573 | |
1574 | - if(!preg_match('/^[a-z0-9\.]+$/i', $js_callback_func)) |
|
1574 | + if (!preg_match('/^[a-z0-9\.]+$/i', $js_callback_func)) |
|
1575 | 1575 | { |
1576 | 1576 | unset($js_callback_func); |
1577 | 1577 | unset($_GET['xe_js_callback']); |
@@ -1599,22 +1599,22 @@ discard block |
||
1599 | 1599 | $self = self::getInstance(); |
1600 | 1600 | |
1601 | 1601 | // retrieve virtual site information |
1602 | - if(is_null($site_module_info)) |
|
1602 | + if (is_null($site_module_info)) |
|
1603 | 1603 | { |
1604 | 1604 | $site_module_info = self::get('site_module_info'); |
1605 | 1605 | } |
1606 | 1606 | |
1607 | 1607 | // If $domain is set, handle it (if $domain is vid type, remove $domain and handle with $vid) |
1608 | - if($domain && isSiteID($domain)) |
|
1608 | + if ($domain && isSiteID($domain)) |
|
1609 | 1609 | { |
1610 | 1610 | $vid = $domain; |
1611 | 1611 | $domain = ''; |
1612 | 1612 | } |
1613 | 1613 | |
1614 | 1614 | // If $domain, $vid are not set, use current site information |
1615 | - if(!$domain && !$vid) |
|
1615 | + if (!$domain && !$vid) |
|
1616 | 1616 | { |
1617 | - if($site_module_info->domain && isSiteID($site_module_info->domain)) |
|
1617 | + if ($site_module_info->domain && isSiteID($site_module_info->domain)) |
|
1618 | 1618 | { |
1619 | 1619 | $vid = $site_module_info->domain; |
1620 | 1620 | } |
@@ -1625,21 +1625,21 @@ discard block |
||
1625 | 1625 | } |
1626 | 1626 | |
1627 | 1627 | // if $domain is set, compare current URL. If they are same, remove the domain, otherwise link to the domain. |
1628 | - if($domain) |
|
1628 | + if ($domain) |
|
1629 | 1629 | { |
1630 | 1630 | $domain_info = parse_url($domain); |
1631 | - if(is_null($current_info)) |
|
1631 | + if (is_null($current_info)) |
|
1632 | 1632 | { |
1633 | - $current_info = parse_url(($_SERVER['HTTPS'] == 'on' ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . getScriptPath()); |
|
1633 | + $current_info = parse_url(($_SERVER['HTTPS'] == 'on' ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST'].getScriptPath()); |
|
1634 | 1634 | } |
1635 | - if($domain_info['host'] . $domain_info['path'] == $current_info['host'] . $current_info['path']) |
|
1635 | + if ($domain_info['host'].$domain_info['path'] == $current_info['host'].$current_info['path']) |
|
1636 | 1636 | { |
1637 | 1637 | unset($domain); |
1638 | 1638 | } |
1639 | 1639 | else |
1640 | 1640 | { |
1641 | 1641 | $domain = preg_replace('/^(http|https):\/\//i', '', trim($domain)); |
1642 | - if(substr_compare($domain, '/', -1) !== 0) |
|
1642 | + if (substr_compare($domain, '/', -1) !== 0) |
|
1643 | 1643 | { |
1644 | 1644 | $domain .= '/'; |
1645 | 1645 | } |
@@ -1649,41 +1649,41 @@ discard block |
||
1649 | 1649 | $get_vars = array(); |
1650 | 1650 | |
1651 | 1651 | // If there is no GET variables or first argument is '' to reset variables |
1652 | - if(!$self->get_vars || $args_list[0] == '') |
|
1652 | + if (!$self->get_vars || $args_list[0] == '') |
|
1653 | 1653 | { |
1654 | 1654 | // rearrange args_list |
1655 | - if(is_array($args_list) && $args_list[0] == '') |
|
1655 | + if (is_array($args_list) && $args_list[0] == '') |
|
1656 | 1656 | { |
1657 | 1657 | array_shift($args_list); |
1658 | 1658 | } |
1659 | 1659 | } |
1660 | - elseif($_SERVER['REQUEST_METHOD'] == 'GET') |
|
1660 | + elseif ($_SERVER['REQUEST_METHOD'] == 'GET') |
|
1661 | 1661 | { |
1662 | 1662 | // Otherwise, make GET variables into array |
1663 | 1663 | $get_vars = get_object_vars($self->get_vars); |
1664 | 1664 | } |
1665 | 1665 | else |
1666 | 1666 | { |
1667 | - if(!!$self->get_vars->module) $get_vars['module'] = $self->get_vars->module; |
|
1668 | - if(!!$self->get_vars->mid) $get_vars['mid'] = $self->get_vars->mid; |
|
1669 | - if(!!$self->get_vars->act) $get_vars['act'] = $self->get_vars->act; |
|
1670 | - if(!!$self->get_vars->page) $get_vars['page'] = $self->get_vars->page; |
|
1671 | - if(!!$self->get_vars->search_target) $get_vars['search_target'] = $self->get_vars->search_target; |
|
1672 | - if(!!$self->get_vars->search_keyword) $get_vars['search_keyword'] = $self->get_vars->search_keyword; |
|
1673 | - if($get_vars['act'] == 'IS') |
|
1667 | + if (!!$self->get_vars->module) $get_vars['module'] = $self->get_vars->module; |
|
1668 | + if (!!$self->get_vars->mid) $get_vars['mid'] = $self->get_vars->mid; |
|
1669 | + if (!!$self->get_vars->act) $get_vars['act'] = $self->get_vars->act; |
|
1670 | + if (!!$self->get_vars->page) $get_vars['page'] = $self->get_vars->page; |
|
1671 | + if (!!$self->get_vars->search_target) $get_vars['search_target'] = $self->get_vars->search_target; |
|
1672 | + if (!!$self->get_vars->search_keyword) $get_vars['search_keyword'] = $self->get_vars->search_keyword; |
|
1673 | + if ($get_vars['act'] == 'IS') |
|
1674 | 1674 | { |
1675 | - if(!!$self->get_vars->is_keyword) $get_vars['is_keyword'] = $self->get_vars->is_keyword; |
|
1675 | + if (!!$self->get_vars->is_keyword) $get_vars['is_keyword'] = $self->get_vars->is_keyword; |
|
1676 | 1676 | } |
1677 | 1677 | } |
1678 | 1678 | |
1679 | 1679 | // arrange args_list |
1680 | - for($i = 0, $c = count($args_list); $i < $c; $i += 2) |
|
1680 | + for ($i = 0, $c = count($args_list); $i < $c; $i += 2) |
|
1681 | 1681 | { |
1682 | 1682 | $key = $args_list[$i]; |
1683 | 1683 | $val = trim($args_list[$i + 1]); |
1684 | 1684 | |
1685 | 1685 | // If value is not set, remove the key |
1686 | - if(!isset($val) || !strlen($val)) |
|
1686 | + if (!isset($val) || !strlen($val)) |
|
1687 | 1687 | { |
1688 | 1688 | unset($get_vars[$key]); |
1689 | 1689 | continue; |
@@ -1694,7 +1694,7 @@ discard block |
||
1694 | 1694 | |
1695 | 1695 | // remove vid, rnd |
1696 | 1696 | unset($get_vars['rnd']); |
1697 | - if($vid) |
|
1697 | + if ($vid) |
|
1698 | 1698 | { |
1699 | 1699 | $get_vars['vid'] = $vid; |
1700 | 1700 | } |
@@ -1711,17 +1711,17 @@ discard block |
||
1711 | 1711 | 'dispDocumentAdminManageDocument' => 'dispDocumentManageDocument', |
1712 | 1712 | 'dispModuleAdminSelectList' => 'dispModuleSelectList' |
1713 | 1713 | ); |
1714 | - if($act_alias[$act]) |
|
1714 | + if ($act_alias[$act]) |
|
1715 | 1715 | { |
1716 | 1716 | $get_vars['act'] = $act_alias[$act]; |
1717 | 1717 | } |
1718 | 1718 | |
1719 | 1719 | // organize URL |
1720 | 1720 | $query = ''; |
1721 | - if(count($get_vars) > 0) |
|
1721 | + if (count($get_vars) > 0) |
|
1722 | 1722 | { |
1723 | 1723 | // if using rewrite mod |
1724 | - if($self->allow_rewrite) |
|
1724 | + if ($self->allow_rewrite) |
|
1725 | 1725 | { |
1726 | 1726 | $var_keys = array_keys($get_vars); |
1727 | 1727 | sort($var_keys); |
@@ -1741,8 +1741,8 @@ discard block |
||
1741 | 1741 | 'vid' => $vid, |
1742 | 1742 | 'mid' => $mid, |
1743 | 1743 | 'mid.vid' => "$vid/$mid", |
1744 | - 'entry.mid' => "$mid/entry/" . $get_vars['entry'], |
|
1745 | - 'entry.mid.vid' => "$vid/$mid/entry/" . $get_vars['entry'], |
|
1744 | + 'entry.mid' => "$mid/entry/".$get_vars['entry'], |
|
1745 | + 'entry.mid.vid' => "$vid/$mid/entry/".$get_vars['entry'], |
|
1746 | 1746 | 'document_srl' => $srl, |
1747 | 1747 | 'document_srl.mid' => "$mid/$srl", |
1748 | 1748 | 'document_srl.vid' => "$vid/$srl", |
@@ -1759,66 +1759,66 @@ discard block |
||
1759 | 1759 | $query = $target_map[$target]; |
1760 | 1760 | } |
1761 | 1761 | |
1762 | - if(!$query) |
|
1762 | + if (!$query) |
|
1763 | 1763 | { |
1764 | 1764 | $queries = array(); |
1765 | - foreach($get_vars as $key => $val) |
|
1765 | + foreach ($get_vars as $key => $val) |
|
1766 | 1766 | { |
1767 | - if(is_array($val) && count($val) > 0) |
|
1767 | + if (is_array($val) && count($val) > 0) |
|
1768 | 1768 | { |
1769 | - foreach($val as $k => $v) |
|
1769 | + foreach ($val as $k => $v) |
|
1770 | 1770 | { |
1771 | - $queries[] = $key . '[' . $k . ']=' . urlencode($v); |
|
1771 | + $queries[] = $key.'['.$k.']='.urlencode($v); |
|
1772 | 1772 | } |
1773 | 1773 | } |
1774 | - elseif(!is_array($val)) |
|
1774 | + elseif (!is_array($val)) |
|
1775 | 1775 | { |
1776 | - $queries[] = $key . '=' . urlencode($val); |
|
1776 | + $queries[] = $key.'='.urlencode($val); |
|
1777 | 1777 | } |
1778 | 1778 | } |
1779 | - if(count($queries) > 0) |
|
1779 | + if (count($queries) > 0) |
|
1780 | 1780 | { |
1781 | - $query = 'index.php?' . join('&', $queries); |
|
1781 | + $query = 'index.php?'.join('&', $queries); |
|
1782 | 1782 | } |
1783 | 1783 | } |
1784 | 1784 | } |
1785 | 1785 | |
1786 | 1786 | // If using SSL always |
1787 | 1787 | $_use_ssl = $self->get('_use_ssl'); |
1788 | - if($_use_ssl == 'always') |
|
1788 | + if ($_use_ssl == 'always') |
|
1789 | 1789 | { |
1790 | - $query = $self->getRequestUri(ENFORCE_SSL, $domain) . $query; |
|
1790 | + $query = $self->getRequestUri(ENFORCE_SSL, $domain).$query; |
|
1791 | 1791 | // optional SSL use |
1792 | 1792 | } |
1793 | - elseif($_use_ssl == 'optional') |
|
1793 | + elseif ($_use_ssl == 'optional') |
|
1794 | 1794 | { |
1795 | 1795 | $ssl_mode = (($self->get('module') === 'admin') || ($get_vars['module'] === 'admin') || (isset($get_vars['act']) && $self->isExistsSSLAction($get_vars['act']))) ? ENFORCE_SSL : RELEASE_SSL; |
1796 | - $query = $self->getRequestUri($ssl_mode, $domain) . $query; |
|
1796 | + $query = $self->getRequestUri($ssl_mode, $domain).$query; |
|
1797 | 1797 | // no SSL |
1798 | 1798 | } |
1799 | 1799 | else |
1800 | 1800 | { |
1801 | 1801 | // currently on SSL but target is not based on SSL |
1802 | - if($_SERVER['HTTPS'] == 'on') |
|
1802 | + if ($_SERVER['HTTPS'] == 'on') |
|
1803 | 1803 | { |
1804 | - $query = $self->getRequestUri(ENFORCE_SSL, $domain) . $query; |
|
1804 | + $query = $self->getRequestUri(ENFORCE_SSL, $domain).$query; |
|
1805 | 1805 | } |
1806 | - else if($domain) // if $domain is set |
|
1806 | + else if ($domain) // if $domain is set |
|
1807 | 1807 | { |
1808 | - $query = $self->getRequestUri(FOLLOW_REQUEST_SSL, $domain) . $query; |
|
1808 | + $query = $self->getRequestUri(FOLLOW_REQUEST_SSL, $domain).$query; |
|
1809 | 1809 | } |
1810 | 1810 | else |
1811 | 1811 | { |
1812 | - $query = getScriptPath() . $query; |
|
1812 | + $query = getScriptPath().$query; |
|
1813 | 1813 | } |
1814 | 1814 | } |
1815 | 1815 | |
1816 | - if(!$encode) |
|
1816 | + if (!$encode) |
|
1817 | 1817 | { |
1818 | 1818 | return $query; |
1819 | 1819 | } |
1820 | 1820 | |
1821 | - if(!$autoEncode) |
|
1821 | + if (!$autoEncode) |
|
1822 | 1822 | { |
1823 | 1823 | return htmlspecialchars($query, ENT_COMPAT | ENT_HTML401, 'UTF-8', FALSE); |
1824 | 1824 | } |
@@ -1827,16 +1827,16 @@ discard block |
||
1827 | 1827 | $encode_queries = array(); |
1828 | 1828 | $parsedUrl = parse_url($query); |
1829 | 1829 | parse_str($parsedUrl['query'], $output); |
1830 | - foreach($output as $key => $value) |
|
1830 | + foreach ($output as $key => $value) |
|
1831 | 1831 | { |
1832 | - if(preg_match('/&([a-z]{2,}|#\d+);/', urldecode($value))) |
|
1832 | + if (preg_match('/&([a-z]{2,}|#\d+);/', urldecode($value))) |
|
1833 | 1833 | { |
1834 | 1834 | $value = urlencode(htmlspecialchars_decode(urldecode($value))); |
1835 | 1835 | } |
1836 | - $encode_queries[] = $key . '=' . $value; |
|
1836 | + $encode_queries[] = $key.'='.$value; |
|
1837 | 1837 | } |
1838 | 1838 | |
1839 | - return htmlspecialchars($parsedUrl['path'] . '?' . join('&', $encode_queries), ENT_COMPAT | ENT_HTML401, 'UTF-8', FALSE); |
|
1839 | + return htmlspecialchars($parsedUrl['path'].'?'.join('&', $encode_queries), ENT_COMPAT | ENT_HTML401, 'UTF-8', FALSE); |
|
1840 | 1840 | } |
1841 | 1841 | |
1842 | 1842 | /** |
@@ -1851,17 +1851,17 @@ discard block |
||
1851 | 1851 | static $url = array(); |
1852 | 1852 | |
1853 | 1853 | // Check HTTP Request |
1854 | - if(!isset($_SERVER['SERVER_PROTOCOL'])) |
|
1854 | + if (!isset($_SERVER['SERVER_PROTOCOL'])) |
|
1855 | 1855 | { |
1856 | 1856 | return; |
1857 | 1857 | } |
1858 | 1858 | |
1859 | - if(self::get('_use_ssl') == 'always') |
|
1859 | + if (self::get('_use_ssl') == 'always') |
|
1860 | 1860 | { |
1861 | 1861 | $ssl_mode = ENFORCE_SSL; |
1862 | 1862 | } |
1863 | 1863 | |
1864 | - if($domain) |
|
1864 | + if ($domain) |
|
1865 | 1865 | { |
1866 | 1866 | $domain_key = md5($domain); |
1867 | 1867 | } |
@@ -1870,14 +1870,14 @@ discard block |
||
1870 | 1870 | $domain_key = 'default'; |
1871 | 1871 | } |
1872 | 1872 | |
1873 | - if(isset($url[$ssl_mode][$domain_key])) |
|
1873 | + if (isset($url[$ssl_mode][$domain_key])) |
|
1874 | 1874 | { |
1875 | 1875 | return $url[$ssl_mode][$domain_key]; |
1876 | 1876 | } |
1877 | 1877 | |
1878 | 1878 | $current_use_ssl = ($_SERVER['HTTPS'] == 'on'); |
1879 | 1879 | |
1880 | - switch($ssl_mode) |
|
1880 | + switch ($ssl_mode) |
|
1881 | 1881 | { |
1882 | 1882 | case FOLLOW_REQUEST_SSL: $use_ssl = $current_use_ssl; |
1883 | 1883 | break; |
@@ -1887,34 +1887,34 @@ discard block |
||
1887 | 1887 | break; |
1888 | 1888 | } |
1889 | 1889 | |
1890 | - if($domain) |
|
1890 | + if ($domain) |
|
1891 | 1891 | { |
1892 | 1892 | $target_url = trim($domain); |
1893 | - if(substr_compare($target_url, '/', -1) !== 0) |
|
1893 | + if (substr_compare($target_url, '/', -1) !== 0) |
|
1894 | 1894 | { |
1895 | - $target_url.= '/'; |
|
1895 | + $target_url .= '/'; |
|
1896 | 1896 | } |
1897 | 1897 | } |
1898 | 1898 | else |
1899 | 1899 | { |
1900 | - $target_url = $_SERVER['HTTP_HOST'] . getScriptPath(); |
|
1900 | + $target_url = $_SERVER['HTTP_HOST'].getScriptPath(); |
|
1901 | 1901 | } |
1902 | 1902 | |
1903 | - $url_info = parse_url('http://' . $target_url); |
|
1903 | + $url_info = parse_url('http://'.$target_url); |
|
1904 | 1904 | |
1905 | - if($current_use_ssl != $use_ssl) |
|
1905 | + if ($current_use_ssl != $use_ssl) |
|
1906 | 1906 | { |
1907 | 1907 | unset($url_info['port']); |
1908 | 1908 | } |
1909 | 1909 | |
1910 | - if($use_ssl) |
|
1910 | + if ($use_ssl) |
|
1911 | 1911 | { |
1912 | 1912 | $port = self::get('_https_port'); |
1913 | - if($port && $port != 443) |
|
1913 | + if ($port && $port != 443) |
|
1914 | 1914 | { |
1915 | 1915 | $url_info['port'] = $port; |
1916 | 1916 | } |
1917 | - elseif($url_info['port'] == 443) |
|
1917 | + elseif ($url_info['port'] == 443) |
|
1918 | 1918 | { |
1919 | 1919 | unset($url_info['port']); |
1920 | 1920 | } |
@@ -1922,17 +1922,17 @@ discard block |
||
1922 | 1922 | else |
1923 | 1923 | { |
1924 | 1924 | $port = self::get('_http_port'); |
1925 | - if($port && $port != 80) |
|
1925 | + if ($port && $port != 80) |
|
1926 | 1926 | { |
1927 | 1927 | $url_info['port'] = $port; |
1928 | 1928 | } |
1929 | - elseif($url_info['port'] == 80) |
|
1929 | + elseif ($url_info['port'] == 80) |
|
1930 | 1930 | { |
1931 | 1931 | unset($url_info['port']); |
1932 | 1932 | } |
1933 | 1933 | } |
1934 | 1934 | |
1935 | - $url[$ssl_mode][$domain_key] = sprintf('%s://%s%s%s', $use_ssl ? 'https' : $url_info['scheme'], $url_info['host'], $url_info['port'] && $url_info['port'] != 80 ? ':' . $url_info['port'] : '', $url_info['path']); |
|
1935 | + $url[$ssl_mode][$domain_key] = sprintf('%s://%s%s%s', $use_ssl ? 'https' : $url_info['scheme'], $url_info['host'], $url_info['port'] && $url_info['port'] != 80 ? ':'.$url_info['port'] : '', $url_info['path']); |
|
1936 | 1936 | |
1937 | 1937 | return $url[$ssl_mode][$domain_key]; |
1938 | 1938 | } |
@@ -1949,16 +1949,16 @@ discard block |
||
1949 | 1949 | { |
1950 | 1950 | $self = self::getInstance(); |
1951 | 1951 | $self->context->{$key} = $val; |
1952 | - if($set_to_get_vars === FALSE) |
|
1952 | + if ($set_to_get_vars === FALSE) |
|
1953 | 1953 | { |
1954 | 1954 | return; |
1955 | 1955 | } |
1956 | - if($val === NULL || $val === '') |
|
1956 | + if ($val === NULL || $val === '') |
|
1957 | 1957 | { |
1958 | 1958 | unset($self->get_vars->{$key}); |
1959 | 1959 | return; |
1960 | 1960 | } |
1961 | - if($set_to_get_vars || $self->get_vars->{$key}) |
|
1961 | + if ($set_to_get_vars || $self->get_vars->{$key}) |
|
1962 | 1962 | { |
1963 | 1963 | $self->get_vars->{$key} = $val; |
1964 | 1964 | } |
@@ -1974,7 +1974,7 @@ discard block |
||
1974 | 1974 | { |
1975 | 1975 | $self = self::getInstance(); |
1976 | 1976 | |
1977 | - if(!isset($self->context->{$key})) |
|
1977 | + if (!isset($self->context->{$key})) |
|
1978 | 1978 | { |
1979 | 1979 | return null; |
1980 | 1980 | } |
@@ -1989,7 +1989,7 @@ discard block |
||
1989 | 1989 | function gets() |
1990 | 1990 | { |
1991 | 1991 | $num_args = func_num_args(); |
1992 | - if($num_args < 1) |
|
1992 | + if ($num_args < 1) |
|
1993 | 1993 | { |
1994 | 1994 | return; |
1995 | 1995 | } |
@@ -1997,7 +1997,7 @@ discard block |
||
1997 | 1997 | |
1998 | 1998 | $args_list = func_get_args(); |
1999 | 1999 | $output = new stdClass(); |
2000 | - foreach($args_list as $v) |
|
2000 | + foreach ($args_list as $v) |
|
2001 | 2001 | { |
2002 | 2002 | $output->{$v} = $self->get($v); |
2003 | 2003 | } |
@@ -2023,7 +2023,7 @@ discard block |
||
2023 | 2023 | function getRequestVars() |
2024 | 2024 | { |
2025 | 2025 | $self = self::getInstance(); |
2026 | - if($self->get_vars) |
|
2026 | + if ($self->get_vars) |
|
2027 | 2027 | { |
2028 | 2028 | return clone($self->get_vars); |
2029 | 2029 | } |
@@ -2040,13 +2040,13 @@ discard block |
||
2040 | 2040 | { |
2041 | 2041 | $self = self::getInstance(); |
2042 | 2042 | |
2043 | - if(!is_readable($self->sslActionCacheFile)) |
|
2043 | + if (!is_readable($self->sslActionCacheFile)) |
|
2044 | 2044 | { |
2045 | 2045 | $buff = '<?php if(!defined("__XE__"))exit;'; |
2046 | 2046 | FileHandler::writeFile($self->sslActionCacheFile, $buff); |
2047 | 2047 | } |
2048 | 2048 | |
2049 | - if(!isset($self->ssl_actions[$action])) |
|
2049 | + if (!isset($self->ssl_actions[$action])) |
|
2050 | 2050 | { |
2051 | 2051 | $self->ssl_actions[$action] = 1; |
2052 | 2052 | $sslActionCacheString = sprintf('$sslActions[\'%s\'] = 1;', $action); |
@@ -2064,16 +2064,16 @@ discard block |
||
2064 | 2064 | { |
2065 | 2065 | $self = self::getInstance(); |
2066 | 2066 | |
2067 | - if(!is_readable($self->sslActionCacheFile)) |
|
2067 | + if (!is_readable($self->sslActionCacheFile)) |
|
2068 | 2068 | { |
2069 | 2069 | unset($self->ssl_actions); |
2070 | 2070 | $buff = '<?php if(!defined("__XE__"))exit;'; |
2071 | 2071 | FileHandler::writeFile($self->sslActionCacheFile, $buff); |
2072 | 2072 | } |
2073 | 2073 | |
2074 | - foreach($action_array as $action) |
|
2074 | + foreach ($action_array as $action) |
|
2075 | 2075 | { |
2076 | - if(!isset($self->ssl_actions[$action])) |
|
2076 | + if (!isset($self->ssl_actions[$action])) |
|
2077 | 2077 | { |
2078 | 2078 | $self->ssl_actions[$action] = 1; |
2079 | 2079 | $sslActionCacheString = sprintf('$sslActions[\'%s\'] = 1;', $action); |
@@ -2092,7 +2092,7 @@ discard block |
||
2092 | 2092 | { |
2093 | 2093 | $self = self::getInstance(); |
2094 | 2094 | |
2095 | - if($self->isExistsSSLAction($action)) |
|
2095 | + if ($self->isExistsSSLAction($action)) |
|
2096 | 2096 | { |
2097 | 2097 | $sslActionCacheString = sprintf('$sslActions[\'%s\'] = 1;', $action); |
2098 | 2098 | $buff = FileHandler::readFile($self->sslActionCacheFile); |
@@ -2109,7 +2109,7 @@ discard block |
||
2109 | 2109 | function getSSLActions() |
2110 | 2110 | { |
2111 | 2111 | $self = self::getInstance(); |
2112 | - if($self->getSslStatus() == 'optional') |
|
2112 | + if ($self->getSslStatus() == 'optional') |
|
2113 | 2113 | { |
2114 | 2114 | return $self->ssl_actions; |
2115 | 2115 | } |
@@ -2136,12 +2136,12 @@ discard block |
||
2136 | 2136 | */ |
2137 | 2137 | function normalizeFilePath($file) |
2138 | 2138 | { |
2139 | - if($file{0} != '/' && $file{0} != '.' && strpos($file, '://') === FALSE) |
|
2139 | + if ($file{0} != '/' && $file{0} != '.' && strpos($file, '://') === FALSE) |
|
2140 | 2140 | { |
2141 | - $file = './' . $file; |
|
2141 | + $file = './'.$file; |
|
2142 | 2142 | } |
2143 | 2143 | $file = preg_replace('@/\./|(?<!:)\/\/@', '/', $file); |
2144 | - while(strpos($file, '/../') !== FALSE) |
|
2144 | + while (strpos($file, '/../') !== FALSE) |
|
2145 | 2145 | { |
2146 | 2146 | $file = preg_replace('/\/([^\/]+)\/\.\.\//s', '/', $file, 1); |
2147 | 2147 | } |
@@ -2160,13 +2160,13 @@ discard block |
||
2160 | 2160 | { |
2161 | 2161 | $file = self::normalizeFilePath($file); |
2162 | 2162 | $script_path = getScriptPath(); |
2163 | - if(strpos($file, './') === 0) |
|
2163 | + if (strpos($file, './') === 0) |
|
2164 | 2164 | { |
2165 | - $file = $script_path . substr($file, 2); |
|
2165 | + $file = $script_path.substr($file, 2); |
|
2166 | 2166 | } |
2167 | - elseif(strpos($file, '../') === 0) |
|
2167 | + elseif (strpos($file, '../') === 0) |
|
2168 | 2168 | { |
2169 | - $file = self::normalizeFilePath($script_path . $file); |
|
2169 | + $file = self::normalizeFilePath($script_path.$file); |
|
2170 | 2170 | } |
2171 | 2171 | |
2172 | 2172 | return $file; |
@@ -2236,12 +2236,12 @@ discard block |
||
2236 | 2236 | */ |
2237 | 2237 | function addJsFile($file, $optimized = FALSE, $targetie = '', $index = 0, $type = 'head', $isRuleset = FALSE, $autoPath = null) |
2238 | 2238 | { |
2239 | - if($isRuleset) |
|
2239 | + if ($isRuleset) |
|
2240 | 2240 | { |
2241 | - if(strpos($file, '#') !== FALSE) |
|
2241 | + if (strpos($file, '#') !== FALSE) |
|
2242 | 2242 | { |
2243 | 2243 | $file = str_replace('#', '', $file); |
2244 | - if(!is_readable($file)) |
|
2244 | + if (!is_readable($file)) |
|
2245 | 2245 | { |
2246 | 2246 | $file = $autoPath; |
2247 | 2247 | } |
@@ -2306,9 +2306,9 @@ discard block |
||
2306 | 2306 | ksort($files); |
2307 | 2307 | $files = array_values($files); |
2308 | 2308 | $filenames = array(); |
2309 | - for($i = 0, $c = count($files); $i < $c; ++$i) |
|
2309 | + for ($i = 0, $c = count($files); $i < $c; ++$i) |
|
2310 | 2310 | { |
2311 | - if(in_array($files[$i]['file'], $filenames)) |
|
2311 | + if (in_array($files[$i]['file'], $filenames)) |
|
2312 | 2312 | { |
2313 | 2313 | unset($files[$i]); |
2314 | 2314 | } |
@@ -2393,14 +2393,14 @@ discard block |
||
2393 | 2393 | */ |
2394 | 2394 | function getJavascriptPluginInfo($pluginName) |
2395 | 2395 | { |
2396 | - if($plugin_name == 'ui.datepicker') |
|
2396 | + if ($plugin_name == 'ui.datepicker') |
|
2397 | 2397 | { |
2398 | 2398 | $plugin_name = 'ui'; |
2399 | 2399 | } |
2400 | 2400 | |
2401 | - $plugin_path = './common/js/plugins/' . $pluginName . '/'; |
|
2402 | - $info_file = $plugin_path . 'plugin.load'; |
|
2403 | - if(!is_readable($info_file)) |
|
2401 | + $plugin_path = './common/js/plugins/'.$pluginName.'/'; |
|
2402 | + $info_file = $plugin_path.'plugin.load'; |
|
2403 | + if (!is_readable($info_file)) |
|
2404 | 2404 | { |
2405 | 2405 | return; |
2406 | 2406 | } |
@@ -2410,32 +2410,32 @@ discard block |
||
2410 | 2410 | $result->jsList = array(); |
2411 | 2411 | $result->cssList = array(); |
2412 | 2412 | |
2413 | - foreach($list as $filename) |
|
2413 | + foreach ($list as $filename) |
|
2414 | 2414 | { |
2415 | 2415 | $filename = trim($filename); |
2416 | - if(!$filename) |
|
2416 | + if (!$filename) |
|
2417 | 2417 | { |
2418 | 2418 | continue; |
2419 | 2419 | } |
2420 | 2420 | |
2421 | - if(strncasecmp('./', $filename, 2) === 0) |
|
2421 | + if (strncasecmp('./', $filename, 2) === 0) |
|
2422 | 2422 | { |
2423 | 2423 | $filename = substr($filename, 2); |
2424 | 2424 | } |
2425 | 2425 | |
2426 | - if(substr_compare($filename, '.js', -3) === 0) |
|
2426 | + if (substr_compare($filename, '.js', -3) === 0) |
|
2427 | 2427 | { |
2428 | - $result->jsList[] = $plugin_path . $filename; |
|
2428 | + $result->jsList[] = $plugin_path.$filename; |
|
2429 | 2429 | } |
2430 | - elseif(substr_compare($filename, '.css', -4) === 0) |
|
2430 | + elseif (substr_compare($filename, '.css', -4) === 0) |
|
2431 | 2431 | { |
2432 | - $result->cssList[] = $plugin_path . $filename; |
|
2432 | + $result->cssList[] = $plugin_path.$filename; |
|
2433 | 2433 | } |
2434 | 2434 | } |
2435 | 2435 | |
2436 | - if(is_dir($plugin_path . 'lang')) |
|
2436 | + if (is_dir($plugin_path.'lang')) |
|
2437 | 2437 | { |
2438 | - $result->langPath = $plugin_path . 'lang'; |
|
2438 | + $result->langPath = $plugin_path.'lang'; |
|
2439 | 2439 | } |
2440 | 2440 | |
2441 | 2441 | return $result; |
@@ -2451,50 +2451,50 @@ discard block |
||
2451 | 2451 | static $loaded_plugins = array(); |
2452 | 2452 | |
2453 | 2453 | $self = self::getInstance(); |
2454 | - if($plugin_name == 'ui.datepicker') |
|
2454 | + if ($plugin_name == 'ui.datepicker') |
|
2455 | 2455 | { |
2456 | 2456 | $plugin_name = 'ui'; |
2457 | 2457 | } |
2458 | 2458 | |
2459 | - if($loaded_plugins[$plugin_name]) |
|
2459 | + if ($loaded_plugins[$plugin_name]) |
|
2460 | 2460 | { |
2461 | 2461 | return; |
2462 | 2462 | } |
2463 | 2463 | $loaded_plugins[$plugin_name] = TRUE; |
2464 | 2464 | |
2465 | - $plugin_path = './common/js/plugins/' . $plugin_name . '/'; |
|
2466 | - $info_file = $plugin_path . 'plugin.load'; |
|
2467 | - if(!is_readable($info_file)) |
|
2465 | + $plugin_path = './common/js/plugins/'.$plugin_name.'/'; |
|
2466 | + $info_file = $plugin_path.'plugin.load'; |
|
2467 | + if (!is_readable($info_file)) |
|
2468 | 2468 | { |
2469 | 2469 | return; |
2470 | 2470 | } |
2471 | 2471 | |
2472 | 2472 | $list = file($info_file); |
2473 | - foreach($list as $filename) |
|
2473 | + foreach ($list as $filename) |
|
2474 | 2474 | { |
2475 | 2475 | $filename = trim($filename); |
2476 | - if(!$filename) |
|
2476 | + if (!$filename) |
|
2477 | 2477 | { |
2478 | 2478 | continue; |
2479 | 2479 | } |
2480 | 2480 | |
2481 | - if(strncasecmp('./', $filename, 2) === 0) |
|
2481 | + if (strncasecmp('./', $filename, 2) === 0) |
|
2482 | 2482 | { |
2483 | 2483 | $filename = substr($filename, 2); |
2484 | 2484 | } |
2485 | - if(substr_compare($filename, '.js', -3) === 0) |
|
2485 | + if (substr_compare($filename, '.js', -3) === 0) |
|
2486 | 2486 | { |
2487 | - $self->loadFile(array($plugin_path . $filename, 'body', '', 0), TRUE); |
|
2487 | + $self->loadFile(array($plugin_path.$filename, 'body', '', 0), TRUE); |
|
2488 | 2488 | } |
2489 | - if(substr_compare($filename, '.css', -4) === 0) |
|
2489 | + if (substr_compare($filename, '.css', -4) === 0) |
|
2490 | 2490 | { |
2491 | - $self->loadFile(array($plugin_path . $filename, 'all', '', 0), TRUE); |
|
2491 | + $self->loadFile(array($plugin_path.$filename, 'all', '', 0), TRUE); |
|
2492 | 2492 | } |
2493 | 2493 | } |
2494 | 2494 | |
2495 | - if(is_dir($plugin_path . 'lang')) |
|
2495 | + if (is_dir($plugin_path.'lang')) |
|
2496 | 2496 | { |
2497 | - $self->loadLang($plugin_path . 'lang'); |
|
2497 | + $self->loadLang($plugin_path.'lang'); |
|
2498 | 2498 | } |
2499 | 2499 | } |
2500 | 2500 | |
@@ -2507,7 +2507,7 @@ discard block |
||
2507 | 2507 | function addHtmlHeader($header) |
2508 | 2508 | { |
2509 | 2509 | $self = self::getInstance(); |
2510 | - $self->html_header .= "\n" . $header; |
|
2510 | + $self->html_header .= "\n".$header; |
|
2511 | 2511 | } |
2512 | 2512 | |
2513 | 2513 | function clearHtmlHeader() |
@@ -2559,7 +2559,7 @@ discard block |
||
2559 | 2559 | function addBodyHeader($header) |
2560 | 2560 | { |
2561 | 2561 | $self = self::getInstance(); |
2562 | - $self->body_header .= "\n" . $header; |
|
2562 | + $self->body_header .= "\n".$header; |
|
2563 | 2563 | } |
2564 | 2564 | |
2565 | 2565 | /** |
@@ -2581,7 +2581,7 @@ discard block |
||
2581 | 2581 | function addHtmlFooter($footer) |
2582 | 2582 | { |
2583 | 2583 | $self = self::getInstance(); |
2584 | - $self->html_footer .= ($self->Htmlfooter ? "\n" : '') . $footer; |
|
2584 | + $self->html_footer .= ($self->Htmlfooter ? "\n" : '').$footer; |
|
2585 | 2585 | } |
2586 | 2586 | |
2587 | 2587 | /** |
@@ -2602,7 +2602,7 @@ discard block |
||
2602 | 2602 | */ |
2603 | 2603 | function getConfigFile() |
2604 | 2604 | { |
2605 | - return _XE_PATH_ . 'files/config/db.config.php'; |
|
2605 | + return _XE_PATH_.'files/config/db.config.php'; |
|
2606 | 2606 | } |
2607 | 2607 | |
2608 | 2608 | /** |
@@ -2612,7 +2612,7 @@ discard block |
||
2612 | 2612 | */ |
2613 | 2613 | function getFTPConfigFile() |
2614 | 2614 | { |
2615 | - return _XE_PATH_ . 'files/config/ftp.config.php'; |
|
2615 | + return _XE_PATH_.'files/config/ftp.config.php'; |
|
2616 | 2616 | } |
2617 | 2617 | |
2618 | 2618 | /** |
@@ -2664,14 +2664,14 @@ discard block |
||
2664 | 2664 | $_path = explode('/', $path); |
2665 | 2665 | $_base = explode('/', $base_url); |
2666 | 2666 | |
2667 | - if(!$_base[count($_base) - 1]) |
|
2667 | + if (!$_base[count($_base) - 1]) |
|
2668 | 2668 | { |
2669 | 2669 | array_pop($_base); |
2670 | 2670 | } |
2671 | 2671 | |
2672 | - foreach($_xe as $idx => $dir) |
|
2672 | + foreach ($_xe as $idx => $dir) |
|
2673 | 2673 | { |
2674 | - if($_path[0] != $dir) |
|
2674 | + if ($_path[0] != $dir) |
|
2675 | 2675 | { |
2676 | 2676 | break; |
2677 | 2677 | } |
@@ -2679,9 +2679,9 @@ discard block |
||
2679 | 2679 | } |
2680 | 2680 | |
2681 | 2681 | $idx = count($_xe) - $idx - 1; |
2682 | - while($idx--) |
|
2682 | + while ($idx--) |
|
2683 | 2683 | { |
2684 | - if(count($_base) > 0) |
|
2684 | + if (count($_base) > 0) |
|
2685 | 2685 | { |
2686 | 2686 | array_shift($_base); |
2687 | 2687 | } |
@@ -2691,13 +2691,13 @@ discard block |
||
2691 | 2691 | } |
2692 | 2692 | } |
2693 | 2693 | |
2694 | - if(count($_base) > 0) |
|
2694 | + if (count($_base) > 0) |
|
2695 | 2695 | { |
2696 | 2696 | array_unshift($_path, join('/', $_base)); |
2697 | 2697 | } |
2698 | 2698 | |
2699 | - $path = '/' . join('/', $_path); |
|
2700 | - if(substr_compare($path, '/', -1) !== 0) |
|
2699 | + $path = '/'.join('/', $_path); |
|
2700 | + if (substr_compare($path, '/', -1) !== 0) |
|
2701 | 2701 | { |
2702 | 2702 | $path .= '/'; |
2703 | 2703 | } |
@@ -2712,13 +2712,13 @@ discard block |
||
2712 | 2712 | { |
2713 | 2713 | $self = self::getInstance(); |
2714 | 2714 | |
2715 | - if(!is_array($self->meta_tags)) |
|
2715 | + if (!is_array($self->meta_tags)) |
|
2716 | 2716 | { |
2717 | 2717 | $self->meta_tags = array(); |
2718 | 2718 | } |
2719 | 2719 | |
2720 | 2720 | $ret = array(); |
2721 | - foreach($self->meta_tags as $key => $val) |
|
2721 | + foreach ($self->meta_tags as $key => $val) |
|
2722 | 2722 | { |
2723 | 2723 | list($name, $is_http_equiv) = explode("\t", $key); |
2724 | 2724 | $ret[] = array('name' => $name, 'is_http_equiv' => $is_http_equiv, 'content' => $val); |
@@ -2738,7 +2738,7 @@ discard block |
||
2738 | 2738 | function addMetaTag($name, $content, $is_http_equiv = FALSE) |
2739 | 2739 | { |
2740 | 2740 | $self = self::getInstance(); |
2741 | - $self->meta_tags[$name . "\t" . ($is_http_equiv ? '1' : '0')] = $content; |
|
2741 | + $self->meta_tags[$name."\t".($is_http_equiv ? '1' : '0')] = $content; |
|
2742 | 2742 | } |
2743 | 2743 | |
2744 | 2744 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | function getInstance() |
25 | 25 | { |
26 | - if(!$GLOBALS['__CacheFile__']) |
|
26 | + if (!$GLOBALS['__CacheFile__']) |
|
27 | 27 | { |
28 | 28 | $GLOBALS['__CacheFile__'] = new CacheFile(); |
29 | 29 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | function __construct() |
39 | 39 | { |
40 | - $this->cache_dir = _XE_PATH_ . $this->cache_dir; |
|
40 | + $this->cache_dir = _XE_PATH_.$this->cache_dir; |
|
41 | 41 | FileHandler::makeDir($this->cache_dir); |
42 | 42 | } |
43 | 43 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | */ |
50 | 50 | function getCacheFileName($key) |
51 | 51 | { |
52 | - return $this->cache_dir . str_replace(':', DIRECTORY_SEPARATOR, $key) . '.php'; |
|
52 | + return $this->cache_dir.str_replace(':', DIRECTORY_SEPARATOR, $key).'.php'; |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | $content = array(); |
80 | 80 | $content[] = '<?php'; |
81 | 81 | $content[] = 'if(!defined(\'__XE__\')) { exit(); }'; |
82 | - $content[] = 'return \'' . $data . '\';'; |
|
82 | + $content[] = 'return \''.$data.'\';'; |
|
83 | 83 | FileHandler::writeFile($cache_file, implode(PHP_EOL, $content)); |
84 | - if(function_exists('opcache_invalidate')) |
|
84 | + if (function_exists('opcache_invalidate')) |
|
85 | 85 | { |
86 | 86 | @opcache_invalidate($cache_file, true); |
87 | 87 | } |
@@ -98,9 +98,9 @@ discard block |
||
98 | 98 | { |
99 | 99 | $cache_file = $this->getCacheFileName($key); |
100 | 100 | |
101 | - if(file_exists($cache_file)) |
|
101 | + if (file_exists($cache_file)) |
|
102 | 102 | { |
103 | - if($modified_time > 0 && filemtime($cache_file) < $modified_time) |
|
103 | + if ($modified_time > 0 && filemtime($cache_file) < $modified_time) |
|
104 | 104 | { |
105 | 105 | FileHandler::removeFile($cache_file); |
106 | 106 | return false; |
@@ -121,12 +121,12 @@ discard block |
||
121 | 121 | */ |
122 | 122 | function get($key, $modified_time = 0) |
123 | 123 | { |
124 | - if(!$cache_file = FileHandler::exists($this->getCacheFileName($key))) |
|
124 | + if (!$cache_file = FileHandler::exists($this->getCacheFileName($key))) |
|
125 | 125 | { |
126 | 126 | return false; |
127 | 127 | } |
128 | 128 | |
129 | - if($modified_time > 0 && filemtime($cache_file) < $modified_time) |
|
129 | + if ($modified_time > 0 && filemtime($cache_file) < $modified_time) |
|
130 | 130 | { |
131 | 131 | FileHandler::removeFile($cache_file); |
132 | 132 | return false; |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | function _delete($_key) |
147 | 147 | { |
148 | 148 | $cache_file = $this->getCacheFileName($_key); |
149 | - if(function_exists('opcache_invalidate')) |
|
149 | + if (function_exists('opcache_invalidate')) |
|
150 | 150 | { |
151 | 151 | @opcache_invalidate($cache_file, true); |
152 | 152 | } |
@@ -37,7 +37,7 @@ discard block |
||
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 BaseObject(-1, 'msg_invalid_request'); |
43 | 43 | } |
@@ -58,52 +58,52 @@ discard block |
||
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,9 +113,9 @@ discard block |
||
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 | 120 | // static 데이터를 갱신해주기 위해 들어간 코드같으나 어차피 언어 변경 자체는 페이지 전환이 일어나면서 발생하는게 대부분이라 효용이 없음. 또한 예기치않게 권한이 없는 다국어 문서 내용을 보여주는 부효과가 일어남 |
121 | 121 | /* |
@@ -137,21 +137,21 @@ discard block |
||
137 | 137 | * @param array $columnList |
138 | 138 | * @return documentItem |
139 | 139 | */ |
140 | - function getDocument($document_srl=0, $is_admin = false, $load_extra_vars=true, $columnList = array()) |
|
140 | + function getDocument($document_srl = 0, $is_admin = false, $load_extra_vars = true, $columnList = array()) |
|
141 | 141 | { |
142 | - if(!$document_srl) return new documentItem(); |
|
142 | + if (!$document_srl) return new documentItem(); |
|
143 | 143 | |
144 | - if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
|
144 | + if (!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
|
145 | 145 | { |
146 | 146 | $oDocument = new documentItem($document_srl, $load_extra_vars, $columnList); |
147 | - if(!$oDocument->isExists()) |
|
147 | + if (!$oDocument->isExists()) |
|
148 | 148 | { |
149 | 149 | return $oDocument; |
150 | 150 | } |
151 | 151 | $GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument; |
152 | - if($load_extra_vars) $this->setToAllDocumentExtraVars(); |
|
152 | + if ($load_extra_vars) $this->setToAllDocumentExtraVars(); |
|
153 | 153 | } |
154 | - if($is_admin) $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]->setGrant(); |
|
154 | + if ($is_admin) $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]->setGrant(); |
|
155 | 155 | |
156 | 156 | return $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]; |
157 | 157 | } |
@@ -164,12 +164,12 @@ discard block |
||
164 | 164 | * @param array $columnList |
165 | 165 | * @return array value type is documentItem |
166 | 166 | */ |
167 | - function getDocuments($document_srls, $is_admin = false, $load_extra_vars=true, $columnList = array()) |
|
167 | + function getDocuments($document_srls, $is_admin = false, $load_extra_vars = true, $columnList = array()) |
|
168 | 168 | { |
169 | - if(is_array($document_srls)) |
|
169 | + if (is_array($document_srls)) |
|
170 | 170 | { |
171 | 171 | $list_count = count($document_srls); |
172 | - $document_srls = implode(',',$document_srls); |
|
172 | + $document_srls = implode(',', $document_srls); |
|
173 | 173 | } |
174 | 174 | else |
175 | 175 | { |
@@ -182,33 +182,33 @@ discard block |
||
182 | 182 | |
183 | 183 | $output = executeQuery('document.getDocuments', $args, $columnList); |
184 | 184 | $document_list = $output->data; |
185 | - if(!$document_list) return; |
|
186 | - if(!is_array($document_list)) $document_list = array($document_list); |
|
185 | + if (!$document_list) return; |
|
186 | + if (!is_array($document_list)) $document_list = array($document_list); |
|
187 | 187 | |
188 | 188 | $document_count = count($document_list); |
189 | - foreach($document_list as $key => $attribute) |
|
189 | + foreach ($document_list as $key => $attribute) |
|
190 | 190 | { |
191 | 191 | $document_srl = $attribute->document_srl; |
192 | - if(!$document_srl) continue; |
|
192 | + if (!$document_srl) continue; |
|
193 | 193 | |
194 | - if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
|
194 | + if (!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
|
195 | 195 | { |
196 | 196 | $oDocument = null; |
197 | 197 | $oDocument = new documentItem(); |
198 | 198 | $oDocument->setAttribute($attribute, false); |
199 | - if($is_admin) $oDocument->setGrant(); |
|
199 | + if ($is_admin) $oDocument->setGrant(); |
|
200 | 200 | $GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument; |
201 | 201 | } |
202 | 202 | |
203 | 203 | $result[$attribute->document_srl] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]; |
204 | 204 | } |
205 | 205 | |
206 | - if($load_extra_vars) $this->setToAllDocumentExtraVars(); |
|
206 | + if ($load_extra_vars) $this->setToAllDocumentExtraVars(); |
|
207 | 207 | |
208 | 208 | $output = null; |
209 | - if(count($result)) |
|
209 | + if (count($result)) |
|
210 | 210 | { |
211 | - foreach($result as $document_srl => $val) |
|
211 | + foreach ($result as $document_srl => $val) |
|
212 | 212 | { |
213 | 213 | $output[$document_srl] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]; |
214 | 214 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | * @param array $columnList |
226 | 226 | * @return BaseObject |
227 | 227 | */ |
228 | - function getDocumentList($obj, $except_notice = false, $load_extra_vars=true, $columnList = array()) |
|
228 | + function getDocumentList($obj, $except_notice = false, $load_extra_vars = true, $columnList = array()) |
|
229 | 229 | { |
230 | 230 | $sort_check = $this->_setSortIndex($obj, $load_extra_vars); |
231 | 231 | $obj->sort_index = $sort_check->sort_index; |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | // Call trigger (before) |
236 | 236 | // This trigger can be used to set an alternative output using a different search method |
237 | 237 | $output = ModuleHandler::triggerCall('document.getDocumentList', 'before', $obj); |
238 | - if($output instanceof BaseObject && !$output->toBool()) |
|
238 | + if ($output instanceof BaseObject && !$output->toBool()) |
|
239 | 239 | { |
240 | 240 | return $output; |
241 | 241 | } |
@@ -252,10 +252,10 @@ discard block |
||
252 | 252 | $output = $obj->use_alternate_output; |
253 | 253 | unset($obj->use_alternate_output); |
254 | 254 | } |
255 | - elseif ($sort_check->isExtraVars && substr_count($obj->search_target,'extra_vars')) |
|
255 | + elseif ($sort_check->isExtraVars && substr_count($obj->search_target, 'extra_vars')) |
|
256 | 256 | { |
257 | 257 | $query_id = 'document.getDocumentListWithinExtraVarsExtraSort'; |
258 | - $args->sort_index = str_replace('documents.','',$args->sort_index); |
|
258 | + $args->sort_index = str_replace('documents.', '', $args->sort_index); |
|
259 | 259 | $output = executeQueryArray($query_id, $args); |
260 | 260 | } |
261 | 261 | elseif ($sort_check->isExtraVars) |
@@ -267,16 +267,16 @@ discard block |
||
267 | 267 | // document.getDocumentList query execution |
268 | 268 | // Query_id if you have a group by clause getDocumentListWithinTag getDocumentListWithinComment or used again to perform the query because |
269 | 269 | $groupByQuery = array('document.getDocumentListWithinComment' => 1, 'document.getDocumentListWithinTag' => 1, 'document.getDocumentListWithinExtraVars' => 1); |
270 | - if(isset($groupByQuery[$query_id])) |
|
270 | + if (isset($groupByQuery[$query_id])) |
|
271 | 271 | { |
272 | 272 | $group_args = clone($args); |
273 | 273 | $group_args->sort_index = 'documents.'.$args->sort_index; |
274 | 274 | $output = executeQueryArray($query_id, $group_args); |
275 | - if(!$output->toBool()||!count($output->data)) return $output; |
|
275 | + if (!$output->toBool() || !count($output->data)) return $output; |
|
276 | 276 | |
277 | - foreach($output->data as $key => $val) |
|
277 | + foreach ($output->data as $key => $val) |
|
278 | 278 | { |
279 | - if($val->document_srl) $target_srls[] = $val->document_srl; |
|
279 | + if ($val->document_srl) $target_srls[] = $val->document_srl; |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | $page_navigation = $output->page_navigation; |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | $virtual_number = $keys[0]; |
285 | 285 | |
286 | 286 | $target_args = new stdClass(); |
287 | - $target_args->document_srls = implode(',',$target_srls); |
|
287 | + $target_args->document_srls = implode(',', $target_srls); |
|
288 | 288 | $target_args->list_order = $args->sort_index; |
289 | 289 | $target_args->order_type = $args->order_type; |
290 | 290 | $target_args->list_count = $args->list_count; |
@@ -301,35 +301,35 @@ discard block |
||
301 | 301 | } |
302 | 302 | } |
303 | 303 | // Return if no result or an error occurs |
304 | - if(!$output->toBool()||!count($output->data)) return $output; |
|
304 | + if (!$output->toBool() || !count($output->data)) return $output; |
|
305 | 305 | $idx = 0; |
306 | 306 | $data = $output->data; |
307 | 307 | unset($output->data); |
308 | 308 | |
309 | - if(!isset($virtual_number)) |
|
309 | + if (!isset($virtual_number)) |
|
310 | 310 | { |
311 | 311 | $keys = array_keys($data); |
312 | 312 | $virtual_number = $keys[0]; |
313 | 313 | } |
314 | 314 | |
315 | - if($except_notice) |
|
315 | + if ($except_notice) |
|
316 | 316 | { |
317 | - foreach($data as $key => $attribute) |
|
317 | + foreach ($data as $key => $attribute) |
|
318 | 318 | { |
319 | - if($attribute->is_notice == 'Y') $virtual_number --; |
|
319 | + if ($attribute->is_notice == 'Y') $virtual_number--; |
|
320 | 320 | } |
321 | 321 | } |
322 | 322 | |
323 | - foreach($data as $key => $attribute) |
|
323 | + foreach ($data as $key => $attribute) |
|
324 | 324 | { |
325 | - if($except_notice && $attribute->is_notice == 'Y') continue; |
|
325 | + if ($except_notice && $attribute->is_notice == 'Y') continue; |
|
326 | 326 | $document_srl = $attribute->document_srl; |
327 | - if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
|
327 | + if (!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
|
328 | 328 | { |
329 | 329 | $oDocument = null; |
330 | 330 | $oDocument = new documentItem(); |
331 | 331 | $oDocument->setAttribute($attribute, false); |
332 | - if($is_admin) $oDocument->setGrant(); |
|
332 | + if ($is_admin) $oDocument->setGrant(); |
|
333 | 333 | $GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument; |
334 | 334 | } |
335 | 335 | |
@@ -337,11 +337,11 @@ discard block |
||
337 | 337 | $virtual_number--; |
338 | 338 | } |
339 | 339 | |
340 | - if($load_extra_vars) $this->setToAllDocumentExtraVars(); |
|
340 | + if ($load_extra_vars) $this->setToAllDocumentExtraVars(); |
|
341 | 341 | |
342 | - if(count($output->data)) |
|
342 | + if (count($output->data)) |
|
343 | 343 | { |
344 | - foreach($output->data as $number => $document) |
|
344 | + foreach ($output->data as $number => $document) |
|
345 | 345 | { |
346 | 346 | $output->data[$number] = $GLOBALS['XE_DOCUMENT_LIST'][$document->document_srl]; |
347 | 347 | } |
@@ -363,16 +363,16 @@ discard block |
||
363 | 363 | { |
364 | 364 | $args = new stdClass(); |
365 | 365 | $args->module_srl = $obj->module_srl; |
366 | - $args->category_srl= $obj->category_srl; |
|
366 | + $args->category_srl = $obj->category_srl; |
|
367 | 367 | $output = executeQueryArray('document.getNoticeList', $args, $columnList); |
368 | - if(!$output->toBool()||!$output->data) return; |
|
368 | + if (!$output->toBool() || !$output->data) return; |
|
369 | 369 | |
370 | - foreach($output->data as $key => $val) |
|
370 | + foreach ($output->data as $key => $val) |
|
371 | 371 | { |
372 | 372 | $document_srl = $val->document_srl; |
373 | - if(!$document_srl) continue; |
|
373 | + if (!$document_srl) continue; |
|
374 | 374 | |
375 | - if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
|
375 | + if (!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
|
376 | 376 | { |
377 | 377 | $oDocument = null; |
378 | 378 | $oDocument = new documentItem(); |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | } |
384 | 384 | $this->setToAllDocumentExtraVars(); |
385 | 385 | |
386 | - foreach($result->data as $document_srl => $val) |
|
386 | + foreach ($result->data as $document_srl => $val) |
|
387 | 387 | { |
388 | 388 | $result->data[$document_srl] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]; |
389 | 389 | } |
@@ -399,20 +399,20 @@ discard block |
||
399 | 399 | */ |
400 | 400 | function getExtraKeys($module_srl) |
401 | 401 | { |
402 | - if(!isset($GLOBALS['XE_EXTRA_KEYS'][$module_srl])) |
|
402 | + if (!isset($GLOBALS['XE_EXTRA_KEYS'][$module_srl])) |
|
403 | 403 | { |
404 | 404 | $keys = false; |
405 | 405 | $oCacheHandler = CacheHandler::getInstance('object', null, true); |
406 | - if($oCacheHandler->isSupport()) |
|
406 | + if ($oCacheHandler->isSupport()) |
|
407 | 407 | { |
408 | - $object_key = 'module_document_extra_keys:' . $module_srl; |
|
408 | + $object_key = 'module_document_extra_keys:'.$module_srl; |
|
409 | 409 | $cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); |
410 | 410 | $keys = $oCacheHandler->get($cache_key); |
411 | 411 | } |
412 | 412 | |
413 | 413 | $oExtraVar = ExtraVar::getInstance($module_srl); |
414 | 414 | |
415 | - if($keys === false) |
|
415 | + if ($keys === false) |
|
416 | 416 | { |
417 | 417 | $obj = new stdClass(); |
418 | 418 | $obj->module_srl = $module_srl; |
@@ -422,13 +422,13 @@ discard block |
||
422 | 422 | |
423 | 423 | // correcting index order |
424 | 424 | $isFixed = FALSE; |
425 | - if(is_array($output->data)) |
|
425 | + if (is_array($output->data)) |
|
426 | 426 | { |
427 | 427 | $prevIdx = 0; |
428 | - foreach($output->data as $no => $value) |
|
428 | + foreach ($output->data as $no => $value) |
|
429 | 429 | { |
430 | 430 | // case first |
431 | - if($prevIdx == 0 && $value->idx != 1) |
|
431 | + if ($prevIdx == 0 && $value->idx != 1) |
|
432 | 432 | { |
433 | 433 | $args = new stdClass(); |
434 | 434 | $args->module_srl = $module_srl; |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | } |
443 | 443 | |
444 | 444 | // case others |
445 | - if($prevIdx > 0 && $prevIdx + 1 != $value->idx) |
|
445 | + if ($prevIdx > 0 && $prevIdx + 1 != $value->idx) |
|
446 | 446 | { |
447 | 447 | $args = new stdClass(); |
448 | 448 | $args->module_srl = $module_srl; |
@@ -459,16 +459,16 @@ discard block |
||
459 | 459 | } |
460 | 460 | } |
461 | 461 | |
462 | - if($isFixed) |
|
462 | + if ($isFixed) |
|
463 | 463 | { |
464 | 464 | $output = executeQueryArray('document.getDocumentExtraKeys', $obj); |
465 | 465 | } |
466 | 466 | |
467 | 467 | $oExtraVar->setExtraVarKeys($output->data); |
468 | 468 | $keys = $oExtraVar->getExtraVars(); |
469 | - if(!$keys) $keys = array(); |
|
469 | + if (!$keys) $keys = array(); |
|
470 | 470 | |
471 | - if($oCacheHandler->isSupport()) |
|
471 | + if ($oCacheHandler->isSupport()) |
|
472 | 472 | { |
473 | 473 | $oCacheHandler->put($cache_key, $keys); |
474 | 474 | } |
@@ -489,14 +489,14 @@ discard block |
||
489 | 489 | */ |
490 | 490 | function getExtraVars($module_srl, $document_srl) |
491 | 491 | { |
492 | - if(!isset($GLOBALS['XE_EXTRA_VARS'][$document_srl])) |
|
492 | + if (!isset($GLOBALS['XE_EXTRA_VARS'][$document_srl])) |
|
493 | 493 | { |
494 | 494 | // Extended to extract the values of variables set |
495 | 495 | $oDocument = $this->getDocument($document_srl, false); |
496 | 496 | $GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument; |
497 | 497 | $this->setToAllDocumentExtraVars(); |
498 | 498 | } |
499 | - if(is_array($GLOBALS['XE_EXTRA_VARS'][$document_srl])) ksort($GLOBALS['XE_EXTRA_VARS'][$document_srl]); |
|
499 | + if (is_array($GLOBALS['XE_EXTRA_VARS'][$document_srl])) ksort($GLOBALS['XE_EXTRA_VARS'][$document_srl]); |
|
500 | 500 | return $GLOBALS['XE_EXTRA_VARS'][$document_srl]; |
501 | 501 | } |
502 | 502 | |
@@ -519,71 +519,71 @@ discard block |
||
519 | 519 | |
520 | 520 | $oDocumentController = getController('document'); |
521 | 521 | // Members must be a possible feature |
522 | - if($logged_info->member_srl) |
|
522 | + if ($logged_info->member_srl) |
|
523 | 523 | { |
524 | 524 | $oDocumentModel = getModel('document'); |
525 | 525 | $columnList = array('document_srl', 'module_srl', 'member_srl', 'ipaddress'); |
526 | 526 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false, $columnList); |
527 | 527 | $module_srl = $oDocument->get('module_srl'); |
528 | 528 | $member_srl = $oDocument->get('member_srl'); |
529 | - if(!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
529 | + if (!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
530 | 530 | |
531 | 531 | $oModuleModel = getModel('module'); |
532 | - $document_config = $oModuleModel->getModulePartConfig('document',$module_srl); |
|
533 | - if($document_config->use_vote_up!='N' && $member_srl!=$logged_info->member_srl) |
|
532 | + $document_config = $oModuleModel->getModulePartConfig('document', $module_srl); |
|
533 | + if ($document_config->use_vote_up != 'N' && $member_srl != $logged_info->member_srl) |
|
534 | 534 | { |
535 | 535 | // Add a Referral Button |
536 | 536 | $url = sprintf("doCallModuleAction('document','procDocumentVoteUp','%s')", $document_srl); |
537 | - $oDocumentController->addDocumentPopupMenu($url,'cmd_vote','','javascript'); |
|
537 | + $oDocumentController->addDocumentPopupMenu($url, 'cmd_vote', '', 'javascript'); |
|
538 | 538 | } |
539 | 539 | |
540 | - if($document_config->use_vote_down!='N' && $member_srl!=$logged_info->member_srl) |
|
540 | + if ($document_config->use_vote_down != 'N' && $member_srl != $logged_info->member_srl) |
|
541 | 541 | { |
542 | 542 | // Add button to negative |
543 | - $url= sprintf("doCallModuleAction('document','procDocumentVoteDown','%s')", $document_srl); |
|
544 | - $oDocumentController->addDocumentPopupMenu($url,'cmd_vote_down','','javascript'); |
|
543 | + $url = sprintf("doCallModuleAction('document','procDocumentVoteDown','%s')", $document_srl); |
|
544 | + $oDocumentController->addDocumentPopupMenu($url, 'cmd_vote_down', '', 'javascript'); |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | // Adding Report |
548 | 548 | $url = sprintf("doCallModuleAction('document','procDocumentDeclare','%s')", $document_srl); |
549 | - $oDocumentController->addDocumentPopupMenu($url,'cmd_declare','','javascript'); |
|
549 | + $oDocumentController->addDocumentPopupMenu($url, 'cmd_declare', '', 'javascript'); |
|
550 | 550 | |
551 | 551 | // Add Bookmark button |
552 | 552 | $url = sprintf("doCallModuleAction('member','procMemberScrapDocument','%s')", $document_srl); |
553 | - $oDocumentController->addDocumentPopupMenu($url,'cmd_scrap','','javascript'); |
|
553 | + $oDocumentController->addDocumentPopupMenu($url, 'cmd_scrap', '', 'javascript'); |
|
554 | 554 | } |
555 | 555 | // Add print button |
556 | - $url = getUrl('','module','document','act','dispDocumentPrint','document_srl',$document_srl); |
|
557 | - $oDocumentController->addDocumentPopupMenu($url,'cmd_print','','printDocument'); |
|
556 | + $url = getUrl('', 'module', 'document', 'act', 'dispDocumentPrint', 'document_srl', $document_srl); |
|
557 | + $oDocumentController->addDocumentPopupMenu($url, 'cmd_print', '', 'printDocument'); |
|
558 | 558 | // Call a trigger (after) |
559 | 559 | ModuleHandler::triggerCall('document.getDocumentMenu', 'after', $menu_list); |
560 | - if($this->grant->manager) |
|
560 | + if ($this->grant->manager) |
|
561 | 561 | { |
562 | 562 | $str_confirm = Context::getLang('confirm_move'); |
563 | 563 | $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); |
564 | - $oDocumentController->addDocumentPopupMenu($url,'cmd_trash','','javascript'); |
|
564 | + $oDocumentController->addDocumentPopupMenu($url, 'cmd_trash', '', 'javascript'); |
|
565 | 565 | } |
566 | 566 | |
567 | 567 | // If you are managing to find posts by ip |
568 | - if($logged_info->is_admin == 'Y') |
|
568 | + if ($logged_info->is_admin == 'Y') |
|
569 | 569 | { |
570 | 570 | $oDocumentModel = getModel('document'); |
571 | - $oDocument = $oDocumentModel->getDocument($document_srl); //before setting document recycle |
|
571 | + $oDocument = $oDocumentModel->getDocument($document_srl); //before setting document recycle |
|
572 | 572 | |
573 | - if($oDocument->isExists()) |
|
573 | + if ($oDocument->isExists()) |
|
574 | 574 | { |
575 | 575 | // Find a post equivalent to ip address |
576 | - $url = getUrl('','module','admin','act','dispDocumentAdminList','search_target','ipaddress','search_keyword',$oDocument->getIpAddress()); |
|
577 | - $oDocumentController->addDocumentPopupMenu($url,'cmd_search_by_ipaddress',$icon_path,'TraceByIpaddress'); |
|
576 | + $url = getUrl('', 'module', 'admin', 'act', 'dispDocumentAdminList', 'search_target', 'ipaddress', 'search_keyword', $oDocument->getIpAddress()); |
|
577 | + $oDocumentController->addDocumentPopupMenu($url, 'cmd_search_by_ipaddress', $icon_path, 'TraceByIpaddress'); |
|
578 | 578 | |
579 | 579 | $url = sprintf("var params = new Array(); params['ipaddress_list']='%s'; exec_xml('spamfilter', 'procSpamfilterAdminInsertDeniedIP', params, completeCallModuleAction)", $oDocument->getIpAddress()); |
580 | - $oDocumentController->addDocumentPopupMenu($url,'cmd_add_ip_to_spamfilter','','javascript'); |
|
580 | + $oDocumentController->addDocumentPopupMenu($url, 'cmd_add_ip_to_spamfilter', '', 'javascript'); |
|
581 | 581 | } |
582 | 582 | } |
583 | 583 | // Changing the language of pop-up menu |
584 | 584 | $menus = Context::get('document_popup_menu_list'); |
585 | 585 | $menus_count = count($menus); |
586 | - for($i=0;$i<$menus_count;$i++) |
|
586 | + for ($i = 0; $i < $menus_count; $i++) |
|
587 | 587 | { |
588 | 588 | $menus[$i]->str = Context::getLang($menus[$i]->str); |
589 | 589 | } |
@@ -599,13 +599,13 @@ discard block |
||
599 | 599 | */ |
600 | 600 | function getDocumentCount($module_srl, $search_obj = NULL) |
601 | 601 | { |
602 | - if(is_null($search_obj)) $search_obj = new stdClass(); |
|
602 | + if (is_null($search_obj)) $search_obj = new stdClass(); |
|
603 | 603 | $search_obj->module_srl = $module_srl; |
604 | 604 | |
605 | 605 | $output = executeQuery('document.getDocumentCount', $search_obj); |
606 | 606 | // Return total number of |
607 | 607 | $total_count = $output->data->count; |
608 | - return (int)$total_count; |
|
608 | + return (int) $total_count; |
|
609 | 609 | } |
610 | 610 | |
611 | 611 | /** |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | function getDocumentCountByGroupStatus($search_obj = NULL) |
617 | 617 | { |
618 | 618 | $output = executeQuery('document.getDocumentCountByGroupStatus', $search_obj); |
619 | - if(!$output->toBool()) return array(); |
|
619 | + if (!$output->toBool()) return array(); |
|
620 | 620 | |
621 | 621 | return $output->data; |
622 | 622 | } |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | $output = executeQuery('document.getDocumentExtraVarsCount', $args); |
636 | 636 | // Return total number of |
637 | 637 | $total_count = $output->data->count; |
638 | - return (int)$total_count; |
|
638 | + return (int) $total_count; |
|
639 | 639 | } |
640 | 640 | |
641 | 641 | /** |
@@ -652,29 +652,29 @@ discard block |
||
652 | 652 | |
653 | 653 | $this->_setSearchOption($opt, $args, $query_id, $use_division); |
654 | 654 | |
655 | - if($sort_check->isExtraVars) |
|
655 | + if ($sort_check->isExtraVars) |
|
656 | 656 | { |
657 | 657 | return 1; |
658 | 658 | } |
659 | 659 | else |
660 | 660 | { |
661 | - if($sort_check->sort_index === 'list_order' || $sort_check->sort_index === 'update_order') |
|
661 | + if ($sort_check->sort_index === 'list_order' || $sort_check->sort_index === 'update_order') |
|
662 | 662 | { |
663 | - if($args->order_type === 'desc') |
|
663 | + if ($args->order_type === 'desc') |
|
664 | 664 | { |
665 | - $args->{'rev_' . $sort_check->sort_index} = $oDocument->get($sort_check->sort_index); |
|
665 | + $args->{'rev_'.$sort_check->sort_index} = $oDocument->get($sort_check->sort_index); |
|
666 | 666 | } |
667 | 667 | else |
668 | 668 | { |
669 | 669 | $args->{$sort_check->sort_index} = $oDocument->get($sort_check->sort_index); |
670 | 670 | } |
671 | 671 | } |
672 | - elseif($sort_check->sort_index === 'regdate') |
|
672 | + elseif ($sort_check->sort_index === 'regdate') |
|
673 | 673 | { |
674 | 674 | |
675 | - if($args->order_type === 'asc') |
|
675 | + if ($args->order_type === 'asc') |
|
676 | 676 | { |
677 | - $args->{'rev_' . $sort_check->sort_index} = $oDocument->get($sort_check->sort_index); |
|
677 | + $args->{'rev_'.$sort_check->sort_index} = $oDocument->get($sort_check->sort_index); |
|
678 | 678 | } |
679 | 679 | else |
680 | 680 | { |
@@ -689,9 +689,9 @@ discard block |
||
689 | 689 | } |
690 | 690 | |
691 | 691 | // Guhanhu total number of the article search page |
692 | - $output = executeQuery($query_id . 'Page', $args); |
|
692 | + $output = executeQuery($query_id.'Page', $args); |
|
693 | 693 | $count = $output->data->count; |
694 | - $page = (int)(($count-1)/$opt->list_count)+1; |
|
694 | + $page = (int) (($count - 1) / $opt->list_count) + 1; |
|
695 | 695 | return $page; |
696 | 696 | } |
697 | 697 | |
@@ -703,16 +703,16 @@ discard block |
||
703 | 703 | */ |
704 | 704 | function getCategory($category_srl, $columnList = array()) |
705 | 705 | { |
706 | - $args =new stdClass(); |
|
706 | + $args = new stdClass(); |
|
707 | 707 | $args->category_srl = $category_srl; |
708 | 708 | $output = executeQuery('document.getCategory', $args, $columnList); |
709 | 709 | |
710 | 710 | $node = $output->data; |
711 | - if(!$node) return; |
|
711 | + if (!$node) return; |
|
712 | 712 | |
713 | - if($node->group_srls) |
|
713 | + if ($node->group_srls) |
|
714 | 714 | { |
715 | - $group_srls = explode(',',$node->group_srls); |
|
715 | + $group_srls = explode(',', $node->group_srls); |
|
716 | 716 | unset($node->group_srls); |
717 | 717 | $node->group_srls = $group_srls; |
718 | 718 | } |
@@ -733,8 +733,8 @@ discard block |
||
733 | 733 | { |
734 | 734 | $args = new stdClass(); |
735 | 735 | $args->category_srl = $category_srl; |
736 | - $output = executeQuery('document.getChildCategoryCount',$args); |
|
737 | - if($output->data->count > 0) return true; |
|
736 | + $output = executeQuery('document.getChildCategoryCount', $args); |
|
737 | + if ($output->data->count > 0) return true; |
|
738 | 738 | return false; |
739 | 739 | } |
740 | 740 | |
@@ -747,15 +747,15 @@ discard block |
||
747 | 747 | */ |
748 | 748 | function getCategoryList($module_srl, $columnList = array()) |
749 | 749 | { |
750 | - $module_srl = (int)$module_srl; |
|
750 | + $module_srl = (int) $module_srl; |
|
751 | 751 | |
752 | 752 | // Category of the target module file swollen |
753 | 753 | $filename = sprintf("%sfiles/cache/document_category/%s.php", _XE_PATH_, $module_srl); |
754 | 754 | // If the target file to the cache file regeneration category |
755 | - if(!file_exists($filename)) |
|
755 | + if (!file_exists($filename)) |
|
756 | 756 | { |
757 | 757 | $oDocumentController = getController('document'); |
758 | - if(!$oDocumentController->makeCategoryFile($module_srl)) return array(); |
|
758 | + if (!$oDocumentController->makeCategoryFile($module_srl)) return array(); |
|
759 | 759 | } |
760 | 760 | |
761 | 761 | include($filename); |
@@ -775,10 +775,10 @@ discard block |
||
775 | 775 | */ |
776 | 776 | function _arrangeCategory(&$document_category, $list, $depth) |
777 | 777 | { |
778 | - if(!count($list)) return; |
|
778 | + if (!count($list)) return; |
|
779 | 779 | $idx = 0; |
780 | 780 | $list_order = array(); |
781 | - foreach($list as $key => $val) |
|
781 | + foreach ($list as $key => $val) |
|
782 | 782 | { |
783 | 783 | $obj = new stdClass; |
784 | 784 | $obj->mid = $val['mid']; |
@@ -787,7 +787,7 @@ discard block |
||
787 | 787 | $obj->parent_srl = $val['parent_srl']; |
788 | 788 | $obj->title = $obj->text = $val['text']; |
789 | 789 | $obj->description = $val['description']; |
790 | - $obj->expand = $val['expand']=='Y'?true:false; |
|
790 | + $obj->expand = $val['expand'] == 'Y' ?true:false; |
|
791 | 791 | $obj->color = $val['color']; |
792 | 792 | $obj->document_count = $val['document_count']; |
793 | 793 | $obj->depth = $depth; |
@@ -795,26 +795,26 @@ discard block |
||
795 | 795 | $obj->childs = array(); |
796 | 796 | $obj->grant = $val['grant']; |
797 | 797 | |
798 | - if(Context::get('mid') == $obj->mid && Context::get('category') == $obj->category_srl) $selected = true; |
|
798 | + if (Context::get('mid') == $obj->mid && Context::get('category') == $obj->category_srl) $selected = true; |
|
799 | 799 | else $selected = false; |
800 | 800 | |
801 | 801 | $obj->selected = $selected; |
802 | 802 | |
803 | 803 | $list_order[$idx++] = $obj->category_srl; |
804 | 804 | // If you have a parent category of child nodes apply data |
805 | - if($obj->parent_srl) |
|
805 | + if ($obj->parent_srl) |
|
806 | 806 | { |
807 | 807 | $parent_srl = $obj->parent_srl; |
808 | 808 | $document_count = $obj->document_count; |
809 | 809 | $expand = $obj->expand; |
810 | - if($selected) $expand = true; |
|
810 | + if ($selected) $expand = true; |
|
811 | 811 | |
812 | - while($parent_srl) |
|
812 | + while ($parent_srl) |
|
813 | 813 | { |
814 | 814 | $document_category[$parent_srl]->document_count += $document_count; |
815 | 815 | $document_category[$parent_srl]->childs[] = $obj->category_srl; |
816 | 816 | $document_category[$parent_srl]->child_count = count($document_category[$parent_srl]->childs); |
817 | - if($expand) $document_category[$parent_srl]->expand = $expand; |
|
817 | + if ($expand) $document_category[$parent_srl]->expand = $expand; |
|
818 | 818 | |
819 | 819 | $parent_srl = $document_category[$parent_srl]->parent_srl; |
820 | 820 | } |
@@ -822,10 +822,10 @@ discard block |
||
822 | 822 | |
823 | 823 | $document_category[$key] = $obj; |
824 | 824 | |
825 | - if(count($val['list'])) $this->_arrangeCategory($document_category, $val['list'], $depth+1); |
|
825 | + if (count($val['list'])) $this->_arrangeCategory($document_category, $val['list'], $depth + 1); |
|
826 | 826 | } |
827 | 827 | $document_category[$list_order[0]]->first = true; |
828 | - $document_category[$list_order[count($list_order)-1]]->last = true; |
|
828 | + $document_category[$list_order[count($list_order) - 1]]->last = true; |
|
829 | 829 | } |
830 | 830 | |
831 | 831 | /** |
@@ -840,7 +840,7 @@ discard block |
||
840 | 840 | $args->module_srl = $module_srl; |
841 | 841 | $args->category_srl = $category_srl; |
842 | 842 | $output = executeQuery('document.getCategoryDocumentCount', $args); |
843 | - return (int)$output->data->count; |
|
843 | + return (int) $output->data->count; |
|
844 | 844 | } |
845 | 845 | |
846 | 846 | /** |
@@ -850,8 +850,8 @@ discard block |
||
850 | 850 | */ |
851 | 851 | function getCategoryXmlFile($module_srl) |
852 | 852 | { |
853 | - $xml_file = sprintf('files/cache/document_category/%s.xml.php',$module_srl); |
|
854 | - if(!file_exists($xml_file)) |
|
853 | + $xml_file = sprintf('files/cache/document_category/%s.xml.php', $module_srl); |
|
854 | + if (!file_exists($xml_file)) |
|
855 | 855 | { |
856 | 856 | $oDocumentController = getController('document'); |
857 | 857 | $oDocumentController->makeCategoryFile($module_srl); |
@@ -866,8 +866,8 @@ discard block |
||
866 | 866 | */ |
867 | 867 | function getCategoryPhpFile($module_srl) |
868 | 868 | { |
869 | - $php_file = sprintf('files/cache/document_category/%s.php',$module_srl); |
|
870 | - if(!file_exists($php_file)) |
|
869 | + $php_file = sprintf('files/cache/document_category/%s.php', $module_srl); |
|
870 | + if (!file_exists($php_file)) |
|
871 | 871 | { |
872 | 872 | $oDocumentController = getController('document'); |
873 | 873 | $oDocumentController->makeCategoryFile($module_srl); |
@@ -882,7 +882,7 @@ discard block |
||
882 | 882 | */ |
883 | 883 | function getMonthlyArchivedList($obj) |
884 | 884 | { |
885 | - if($obj->mid) |
|
885 | + if ($obj->mid) |
|
886 | 886 | { |
887 | 887 | $oModuleModel = getModel('module'); |
888 | 888 | $obj->module_srl = $oModuleModel->getModuleSrlByMid($obj->mid); |
@@ -890,13 +890,13 @@ discard block |
||
890 | 890 | } |
891 | 891 | // Module_srl passed the array may be a check whether the array |
892 | 892 | $args = new stdClass; |
893 | - if(is_array($obj->module_srl)) $args->module_srl = implode(',', $obj->module_srl); |
|
893 | + if (is_array($obj->module_srl)) $args->module_srl = implode(',', $obj->module_srl); |
|
894 | 894 | else $args->module_srl = $obj->module_srl; |
895 | 895 | |
896 | 896 | $output = executeQuery('document.getMonthlyArchivedList', $args); |
897 | - if(!$output->toBool()||!$output->data) return $output; |
|
897 | + if (!$output->toBool() || !$output->data) return $output; |
|
898 | 898 | |
899 | - if(!is_array($output->data)) $output->data = array($output->data); |
|
899 | + if (!is_array($output->data)) $output->data = array($output->data); |
|
900 | 900 | |
901 | 901 | return $output; |
902 | 902 | } |
@@ -908,7 +908,7 @@ discard block |
||
908 | 908 | */ |
909 | 909 | function getDailyArchivedList($obj) |
910 | 910 | { |
911 | - if($obj->mid) |
|
911 | + if ($obj->mid) |
|
912 | 912 | { |
913 | 913 | $oModuleModel = getModel('module'); |
914 | 914 | $obj->module_srl = $oModuleModel->getModuleSrlByMid($obj->mid); |
@@ -916,14 +916,14 @@ discard block |
||
916 | 916 | } |
917 | 917 | // Module_srl passed the array may be a check whether the array |
918 | 918 | $args = new stdClass; |
919 | - if(is_array($obj->module_srl)) $args->module_srl = implode(',', $obj->module_srl); |
|
919 | + if (is_array($obj->module_srl)) $args->module_srl = implode(',', $obj->module_srl); |
|
920 | 920 | else $args->module_srl = $obj->module_srl; |
921 | 921 | $args->regdate = $obj->regdate; |
922 | 922 | |
923 | 923 | $output = executeQuery('document.getDailyArchivedList', $args); |
924 | - if(!$output->toBool()) return $output; |
|
924 | + if (!$output->toBool()) return $output; |
|
925 | 925 | |
926 | - if(!is_array($output->data)) $output->data = array($output->data); |
|
926 | + if (!is_array($output->data)) $output->data = array($output->data); |
|
927 | 927 | |
928 | 928 | return $output; |
929 | 929 | } |
@@ -934,17 +934,17 @@ discard block |
||
934 | 934 | */ |
935 | 935 | function getDocumentCategories() |
936 | 936 | { |
937 | - if(!Context::get('is_logged')) return new BaseObject(-1,'msg_not_permitted'); |
|
937 | + if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_permitted'); |
|
938 | 938 | $module_srl = Context::get('module_srl'); |
939 | - $categories= $this->getCategoryList($module_srl); |
|
939 | + $categories = $this->getCategoryList($module_srl); |
|
940 | 940 | $lang = Context::get('lang'); |
941 | 941 | // No additional category |
942 | 942 | $output = "0,0,{$lang->none_category}\n"; |
943 | - if($categories) |
|
943 | + if ($categories) |
|
944 | 944 | { |
945 | - foreach($categories as $category_srl => $category) |
|
945 | + foreach ($categories as $category_srl => $category) |
|
946 | 946 | { |
947 | - $output .= sprintf("%d,%d,%s\n",$category_srl, $category->depth,$category->title); |
|
947 | + $output .= sprintf("%d,%d,%s\n", $category_srl, $category->depth, $category->title); |
|
948 | 948 | } |
949 | 949 | } |
950 | 950 | $this->add('categories', $output); |
@@ -956,7 +956,7 @@ discard block |
||
956 | 956 | */ |
957 | 957 | function getDocumentConfig() |
958 | 958 | { |
959 | - if($this->documentConfig === NULL) |
|
959 | + if ($this->documentConfig === NULL) |
|
960 | 960 | { |
961 | 961 | $oModuleModel = getModel('module'); |
962 | 962 | $config = $oModuleModel->getModuleConfig('document'); |
@@ -1029,11 +1029,11 @@ discard block |
||
1029 | 1029 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl); |
1030 | 1030 | // Check permissions |
1031 | 1031 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
1032 | - if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted'); |
|
1032 | + if (!$grant->manager) return new BaseObject(-1, 'msg_not_permitted'); |
|
1033 | 1033 | |
1034 | 1034 | $category_srl = Context::get('category_srl'); |
1035 | 1035 | $category_info = $this->getCategory($category_srl); |
1036 | - if(!$category_info) |
|
1036 | + if (!$category_info) |
|
1037 | 1037 | { |
1038 | 1038 | return new BaseObject(-1, 'msg_invalid_request'); |
1039 | 1039 | } |
@@ -1049,14 +1049,14 @@ discard block |
||
1049 | 1049 | */ |
1050 | 1050 | function getDocumentSrlByAlias($mid, $alias) |
1051 | 1051 | { |
1052 | - if(!$mid || !$alias) return null; |
|
1052 | + if (!$mid || !$alias) return null; |
|
1053 | 1053 | $site_module_info = Context::get('site_module_info'); |
1054 | 1054 | $args = new stdClass; |
1055 | 1055 | $args->mid = $mid; |
1056 | 1056 | $args->alias_title = $alias; |
1057 | 1057 | $args->site_srl = $site_module_info->site_srl; |
1058 | 1058 | $output = executeQuery('document.getDocumentSrlByAlias', $args); |
1059 | - if(!$output->data) return null; |
|
1059 | + if (!$output->data) return null; |
|
1060 | 1060 | else return $output->data->document_srl; |
1061 | 1061 | } |
1062 | 1062 | |
@@ -1068,15 +1068,15 @@ discard block |
||
1068 | 1068 | */ |
1069 | 1069 | function getDocumentSrlByTitle($module_srl, $title) |
1070 | 1070 | { |
1071 | - if(!$module_srl || !$title) return null; |
|
1071 | + if (!$module_srl || !$title) return null; |
|
1072 | 1072 | $args = new stdClass; |
1073 | 1073 | $args->module_srl = $module_srl; |
1074 | 1074 | $args->title = $title; |
1075 | 1075 | $output = executeQuery('document.getDocumentSrlByTitle', $args); |
1076 | - if(!$output->data) return null; |
|
1076 | + if (!$output->data) return null; |
|
1077 | 1077 | else |
1078 | 1078 | { |
1079 | - if(is_array($output->data)) return $output->data[0]->document_srl; |
|
1079 | + if (is_array($output->data)) return $output->data[0]->document_srl; |
|
1080 | 1080 | return $output->data->document_srl; |
1081 | 1081 | } |
1082 | 1082 | } |
@@ -1088,12 +1088,12 @@ discard block |
||
1088 | 1088 | */ |
1089 | 1089 | function getAlias($document_srl) |
1090 | 1090 | { |
1091 | - if(!$document_srl) return null; |
|
1091 | + if (!$document_srl) return null; |
|
1092 | 1092 | $args = new stdClass; |
1093 | 1093 | $args->document_srl = $document_srl; |
1094 | 1094 | $output = executeQueryArray('document.getAliases', $args); |
1095 | 1095 | |
1096 | - if(!$output->data) return null; |
|
1096 | + if (!$output->data) return null; |
|
1097 | 1097 | else return $output->data[0]->alias_title; |
1098 | 1098 | } |
1099 | 1099 | |
@@ -1136,32 +1136,32 @@ discard block |
||
1136 | 1136 | { |
1137 | 1137 | // Variable check |
1138 | 1138 | $args = new stdClass; |
1139 | - $args->category_srl = $obj->category_srl?$obj->category_srl:null; |
|
1139 | + $args->category_srl = $obj->category_srl ? $obj->category_srl : null; |
|
1140 | 1140 | $args->sort_index = $obj->sort_index; |
1141 | - $args->order_type = $obj->order_type?$obj->order_type:'desc'; |
|
1142 | - $args->page = $obj->page?$obj->page:1; |
|
1143 | - $args->list_count = $obj->list_count?$obj->list_count:20; |
|
1144 | - $args->page_count = $obj->page_count?$obj->page_count:10; |
|
1141 | + $args->order_type = $obj->order_type ? $obj->order_type : 'desc'; |
|
1142 | + $args->page = $obj->page ? $obj->page : 1; |
|
1143 | + $args->list_count = $obj->list_count ? $obj->list_count : 20; |
|
1144 | + $args->page_count = $obj->page_count ? $obj->page_count : 10; |
|
1145 | 1145 | // Search options |
1146 | 1146 | $search_target = $obj->search_target; |
1147 | 1147 | $search_keyword = $obj->search_keyword; |
1148 | - if($search_target && $search_keyword) |
|
1148 | + if ($search_target && $search_keyword) |
|
1149 | 1149 | { |
1150 | - switch($search_target) |
|
1150 | + switch ($search_target) |
|
1151 | 1151 | { |
1152 | 1152 | case 'title' : |
1153 | 1153 | case 'content' : |
1154 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
1154 | + if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword); |
|
1155 | 1155 | $args->{"s_".$search_target} = $search_keyword; |
1156 | 1156 | $use_division = true; |
1157 | 1157 | break; |
1158 | 1158 | case 'title_content' : |
1159 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
1159 | + if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword); |
|
1160 | 1160 | $args->s_title = $search_keyword; |
1161 | 1161 | $args->s_content = $search_keyword; |
1162 | 1162 | break; |
1163 | 1163 | case 'user_id' : |
1164 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
1164 | + if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword); |
|
1165 | 1165 | $args->s_user_id = $search_keyword; |
1166 | 1166 | $args->sort_index = 'documents.'.$args->sort_index; |
1167 | 1167 | break; |
@@ -1169,13 +1169,13 @@ discard block |
||
1169 | 1169 | case 'nick_name' : |
1170 | 1170 | case 'email_address' : |
1171 | 1171 | case 'homepage' : |
1172 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
1172 | + if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword); |
|
1173 | 1173 | $args->{"s_".$search_target} = $search_keyword; |
1174 | 1174 | break; |
1175 | 1175 | case 'is_notice' : |
1176 | 1176 | case 'is_secret' : |
1177 | - if($search_keyword=='N') $args->statusList = array($this->getConfigStatus('public')); |
|
1178 | - elseif($search_keyword=='Y') $args->statusList = array($this->getConfigStatus('secret')); |
|
1177 | + if ($search_keyword == 'N') $args->statusList = array($this->getConfigStatus('public')); |
|
1178 | + elseif ($search_keyword == 'Y') $args->statusList = array($this->getConfigStatus('secret')); |
|
1179 | 1179 | break; |
1180 | 1180 | case 'member_srl' : |
1181 | 1181 | case 'readed_count' : |
@@ -1184,7 +1184,7 @@ discard block |
||
1184 | 1184 | case 'comment_count' : |
1185 | 1185 | case 'trackback_count' : |
1186 | 1186 | case 'uploaded_count' : |
1187 | - $args->{"s_".$search_target} = (int)$search_keyword; |
|
1187 | + $args->{"s_".$search_target} = (int) $search_keyword; |
|
1188 | 1188 | break; |
1189 | 1189 | case 'regdate' : |
1190 | 1190 | case 'last_update' : |
@@ -1196,9 +1196,9 @@ discard block |
||
1196 | 1196 | } |
1197 | 1197 | |
1198 | 1198 | $output = executeQueryArray('document.getTrashList', $args); |
1199 | - if($output->data) |
|
1199 | + if ($output->data) |
|
1200 | 1200 | { |
1201 | - foreach($output->data as $key => $attribute) |
|
1201 | + foreach ($output->data as $key => $attribute) |
|
1202 | 1202 | { |
1203 | 1203 | $oDocument = null; |
1204 | 1204 | $oDocument = new documentItem(); |
@@ -1217,46 +1217,46 @@ discard block |
||
1217 | 1217 | { |
1218 | 1218 | $args = new stdClass; |
1219 | 1219 | $document_srl = Context::get('document_srl'); |
1220 | - if(!$document_srl) return new BaseObject(-1,'msg_invalid_request'); |
|
1220 | + if (!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
1221 | 1221 | |
1222 | 1222 | $point = Context::get('point'); |
1223 | - if($point != -1) $point = 1; |
|
1223 | + if ($point != -1) $point = 1; |
|
1224 | 1224 | |
1225 | 1225 | $oDocumentModel = getModel('document'); |
1226 | 1226 | $columnList = array('document_srl', 'module_srl'); |
1227 | 1227 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false, $columnList); |
1228 | 1228 | $module_srl = $oDocument->get('module_srl'); |
1229 | - if(!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
1229 | + if (!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
1230 | 1230 | |
1231 | 1231 | $oModuleModel = getModel('module'); |
1232 | - $document_config = $oModuleModel->getModulePartConfig('document',$module_srl); |
|
1233 | - if($point == -1) |
|
1232 | + $document_config = $oModuleModel->getModulePartConfig('document', $module_srl); |
|
1233 | + if ($point == -1) |
|
1234 | 1234 | { |
1235 | - if($document_config->use_vote_down!='S') return new BaseObject(-1, 'msg_invalid_request'); |
|
1235 | + if ($document_config->use_vote_down != 'S') return new BaseObject(-1, 'msg_invalid_request'); |
|
1236 | 1236 | $args->below_point = 0; |
1237 | 1237 | } |
1238 | 1238 | else |
1239 | 1239 | { |
1240 | - if($document_config->use_vote_up!='S') return new BaseObject(-1, 'msg_invalid_request'); |
|
1240 | + if ($document_config->use_vote_up != 'S') return new BaseObject(-1, 'msg_invalid_request'); |
|
1241 | 1241 | $args->more_point = 0; |
1242 | 1242 | } |
1243 | 1243 | |
1244 | 1244 | $args->document_srl = $document_srl; |
1245 | 1245 | |
1246 | - $output = executeQueryArray('document.getVotedMemberList',$args); |
|
1247 | - if(!$output->toBool()) return $output; |
|
1246 | + $output = executeQueryArray('document.getVotedMemberList', $args); |
|
1247 | + if (!$output->toBool()) return $output; |
|
1248 | 1248 | |
1249 | 1249 | $oMemberModel = getModel('member'); |
1250 | - if($output->data) |
|
1250 | + if ($output->data) |
|
1251 | 1251 | { |
1252 | - foreach($output->data as $k => $d) |
|
1252 | + foreach ($output->data as $k => $d) |
|
1253 | 1253 | { |
1254 | 1254 | $profile_image = $oMemberModel->getProfileImage($d->member_srl); |
1255 | 1255 | $output->data[$k]->src = $profile_image->src; |
1256 | 1256 | } |
1257 | 1257 | } |
1258 | 1258 | |
1259 | - $this->add('voted_member_list',$output->data); |
|
1259 | + $this->add('voted_member_list', $output->data); |
|
1260 | 1260 | } |
1261 | 1261 | |
1262 | 1262 | /** |
@@ -1266,7 +1266,7 @@ discard block |
||
1266 | 1266 | function getStatusNameList() |
1267 | 1267 | { |
1268 | 1268 | global $lang; |
1269 | - if(!isset($lang->status_name_list)) |
|
1269 | + if (!isset($lang->status_name_list)) |
|
1270 | 1270 | return array_flip($this->getStatusList()); |
1271 | 1271 | else return $lang->status_name_list; |
1272 | 1272 | } |
@@ -1281,7 +1281,7 @@ discard block |
||
1281 | 1281 | { |
1282 | 1282 | $sortIndex = $obj->sort_index; |
1283 | 1283 | $isExtraVars = false; |
1284 | - 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'))) |
|
1284 | + 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'))) |
|
1285 | 1285 | { |
1286 | 1286 | // get module_srl extra_vars list |
1287 | 1287 | if ($load_extra_vars) |
@@ -1296,11 +1296,11 @@ discard block |
||
1296 | 1296 | else |
1297 | 1297 | { |
1298 | 1298 | $check_array = array(); |
1299 | - foreach($extra_output->data as $val) |
|
1299 | + foreach ($extra_output->data as $val) |
|
1300 | 1300 | { |
1301 | 1301 | $check_array[] = $val->eid; |
1302 | 1302 | } |
1303 | - if(!in_array($sortIndex, $check_array)) $sortIndex = 'list_order'; |
|
1303 | + if (!in_array($sortIndex, $check_array)) $sortIndex = 'list_order'; |
|
1304 | 1304 | else $isExtraVars = true; |
1305 | 1305 | } |
1306 | 1306 | } |
@@ -1328,13 +1328,13 @@ discard block |
||
1328 | 1328 | { |
1329 | 1329 | // Variable check |
1330 | 1330 | $args = new stdClass(); |
1331 | - $args->category_srl = $searchOpt->category_srl?$searchOpt->category_srl:null; |
|
1331 | + $args->category_srl = $searchOpt->category_srl ? $searchOpt->category_srl : null; |
|
1332 | 1332 | $args->order_type = $searchOpt->order_type; |
1333 | - $args->page = $searchOpt->page?$searchOpt->page:1; |
|
1334 | - $args->list_count = $searchOpt->list_count?$searchOpt->list_count:20; |
|
1335 | - $args->page_count = $searchOpt->page_count?$searchOpt->page_count:10; |
|
1336 | - $args->start_date = $searchOpt->start_date?$searchOpt->start_date:null; |
|
1337 | - $args->end_date = $searchOpt->end_date?$searchOpt->end_date:null; |
|
1333 | + $args->page = $searchOpt->page ? $searchOpt->page : 1; |
|
1334 | + $args->list_count = $searchOpt->list_count ? $searchOpt->list_count : 20; |
|
1335 | + $args->page_count = $searchOpt->page_count ? $searchOpt->page_count : 10; |
|
1336 | + $args->start_date = $searchOpt->start_date ? $searchOpt->start_date : null; |
|
1337 | + $args->end_date = $searchOpt->end_date ? $searchOpt->end_date : null; |
|
1338 | 1338 | $args->member_srl = $searchOpt->member_srl; |
1339 | 1339 | $args->member_srls = $searchOpt->member_srls; |
1340 | 1340 | |
@@ -1344,10 +1344,10 @@ discard block |
||
1344 | 1344 | |
1345 | 1345 | // Check the target and sequence alignment |
1346 | 1346 | $orderType = array('desc' => 1, 'asc' => 1); |
1347 | - if(!isset($orderType[$args->order_type])) $args->order_type = 'asc'; |
|
1347 | + if (!isset($orderType[$args->order_type])) $args->order_type = 'asc'; |
|
1348 | 1348 | |
1349 | 1349 | // If that came across mid module_srl instead of a direct module_srl guhaejum |
1350 | - if($searchOpt->mid) |
|
1350 | + if ($searchOpt->mid) |
|
1351 | 1351 | { |
1352 | 1352 | $oModuleModel = getModel('module'); |
1353 | 1353 | $args->module_srl = $oModuleModel->getModuleSrlByMid($obj->mid); |
@@ -1355,30 +1355,30 @@ discard block |
||
1355 | 1355 | } |
1356 | 1356 | |
1357 | 1357 | // Module_srl passed the array may be a check whether the array |
1358 | - if(is_array($searchOpt->module_srl)) $args->module_srl = implode(',', $searchOpt->module_srl); |
|
1358 | + if (is_array($searchOpt->module_srl)) $args->module_srl = implode(',', $searchOpt->module_srl); |
|
1359 | 1359 | else $args->module_srl = $searchOpt->module_srl; |
1360 | 1360 | |
1361 | 1361 | // Except for the test module_srl |
1362 | - if(is_array($searchOpt->exclude_module_srl)) $args->exclude_module_srl = implode(',', $searchOpt->exclude_module_srl); |
|
1362 | + if (is_array($searchOpt->exclude_module_srl)) $args->exclude_module_srl = implode(',', $searchOpt->exclude_module_srl); |
|
1363 | 1363 | else $args->exclude_module_srl = $searchOpt->exclude_module_srl; |
1364 | 1364 | |
1365 | 1365 | // only admin document list, temp document showing |
1366 | - if($searchOpt->statusList) $args->statusList = $searchOpt->statusList; |
|
1366 | + if ($searchOpt->statusList) $args->statusList = $searchOpt->statusList; |
|
1367 | 1367 | else |
1368 | 1368 | { |
1369 | - if($logged_info->is_admin == 'Y' && !$searchOpt->module_srl) |
|
1369 | + if ($logged_info->is_admin == 'Y' && !$searchOpt->module_srl) |
|
1370 | 1370 | $args->statusList = array($this->getConfigStatus('secret'), $this->getConfigStatus('public'), $this->getConfigStatus('temp')); |
1371 | 1371 | else |
1372 | 1372 | $args->statusList = array($this->getConfigStatus('secret'), $this->getConfigStatus('public')); |
1373 | 1373 | } |
1374 | 1374 | |
1375 | 1375 | // Category is selected, further sub-categories until all conditions |
1376 | - if($args->category_srl) |
|
1376 | + if ($args->category_srl) |
|
1377 | 1377 | { |
1378 | 1378 | $category_list = $this->getCategoryList($args->module_srl); |
1379 | 1379 | $category_info = $category_list[$args->category_srl]; |
1380 | 1380 | $category_info->childs[] = $args->category_srl; |
1381 | - $args->category_srl = implode(',',$category_info->childs); |
|
1381 | + $args->category_srl = implode(',', $category_info->childs); |
|
1382 | 1382 | } |
1383 | 1383 | |
1384 | 1384 | // Used to specify the default query id (based on several search options to query id modified) |
@@ -1391,24 +1391,24 @@ discard block |
||
1391 | 1391 | $search_target = $searchOpt->search_target; |
1392 | 1392 | $search_keyword = $searchOpt->search_keyword; |
1393 | 1393 | |
1394 | - if($search_target && $search_keyword) |
|
1394 | + if ($search_target && $search_keyword) |
|
1395 | 1395 | { |
1396 | - switch($search_target) |
|
1396 | + switch ($search_target) |
|
1397 | 1397 | { |
1398 | 1398 | case 'title' : |
1399 | 1399 | case 'content' : |
1400 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
1400 | + if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword); |
|
1401 | 1401 | $args->{"s_".$search_target} = $search_keyword; |
1402 | 1402 | $use_division = true; |
1403 | 1403 | break; |
1404 | 1404 | case 'title_content' : |
1405 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
1405 | + if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword); |
|
1406 | 1406 | $args->s_title = $search_keyword; |
1407 | 1407 | $args->s_content = $search_keyword; |
1408 | 1408 | $use_division = true; |
1409 | 1409 | break; |
1410 | 1410 | case 'user_id' : |
1411 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
1411 | + if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword); |
|
1412 | 1412 | $args->s_user_id = $search_keyword; |
1413 | 1413 | $args->sort_index = 'documents.'.$args->sort_index; |
1414 | 1414 | break; |
@@ -1416,18 +1416,18 @@ discard block |
||
1416 | 1416 | case 'nick_name' : |
1417 | 1417 | case 'email_address' : |
1418 | 1418 | case 'homepage' : |
1419 | - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
1419 | + if ($search_keyword) $search_keyword = str_replace(' ', '%', $search_keyword); |
|
1420 | 1420 | $args->{"s_".$search_target} = $search_keyword; |
1421 | 1421 | break; |
1422 | 1422 | case 'is_notice' : |
1423 | - if($search_keyword=='N') $args->{"s_".$search_target} = 'N'; |
|
1424 | - elseif($search_keyword=='Y') $args->{"s_".$search_target} = 'Y'; |
|
1423 | + if ($search_keyword == 'N') $args->{"s_".$search_target} = 'N'; |
|
1424 | + elseif ($search_keyword == 'Y') $args->{"s_".$search_target} = 'Y'; |
|
1425 | 1425 | else $args->{"s_".$search_target} = ''; |
1426 | 1426 | break; |
1427 | 1427 | case 'is_secret' : |
1428 | - if($search_keyword=='N') $args->statusList = array($this->getConfigStatus('public')); |
|
1429 | - elseif($search_keyword=='Y') $args->statusList = array($this->getConfigStatus('secret')); |
|
1430 | - elseif($search_keyword=='temp') $args->statusList = array($this->getConfigStatus('temp')); |
|
1428 | + if ($search_keyword == 'N') $args->statusList = array($this->getConfigStatus('public')); |
|
1429 | + elseif ($search_keyword == 'Y') $args->statusList = array($this->getConfigStatus('secret')); |
|
1430 | + elseif ($search_keyword == 'temp') $args->statusList = array($this->getConfigStatus('temp')); |
|
1431 | 1431 | break; |
1432 | 1432 | case 'member_srl' : |
1433 | 1433 | case 'readed_count' : |
@@ -1435,17 +1435,17 @@ discard block |
||
1435 | 1435 | case 'comment_count' : |
1436 | 1436 | case 'trackback_count' : |
1437 | 1437 | case 'uploaded_count' : |
1438 | - $args->{"s_".$search_target} = (int)$search_keyword; |
|
1438 | + $args->{"s_".$search_target} = (int) $search_keyword; |
|
1439 | 1439 | break; |
1440 | 1440 | case 'member_srls' : |
1441 | - $args->{"s_".$search_target} = (int)$search_keyword; |
|
1441 | + $args->{"s_".$search_target} = (int) $search_keyword; |
|
1442 | 1442 | |
1443 | - if($logged_info->member_srl) |
|
1443 | + if ($logged_info->member_srl) |
|
1444 | 1444 | { |
1445 | 1445 | $srls = explode(',', $search_keyword); |
1446 | - foreach($srls as $srl) |
|
1446 | + foreach ($srls as $srl) |
|
1447 | 1447 | { |
1448 | - if(abs($srl) != $logged_info->member_srl) |
|
1448 | + if (abs($srl) != $logged_info->member_srl) |
|
1449 | 1449 | { |
1450 | 1450 | break; // foreach |
1451 | 1451 | } |
@@ -1456,7 +1456,7 @@ discard block |
||
1456 | 1456 | } |
1457 | 1457 | break; |
1458 | 1458 | case 'blamed_count' : |
1459 | - $args->{"s_".$search_target} = (int)$search_keyword * -1; |
|
1459 | + $args->{"s_".$search_target} = (int) $search_keyword * -1; |
|
1460 | 1460 | break; |
1461 | 1461 | case 'regdate' : |
1462 | 1462 | case 'last_update' : |
@@ -1469,7 +1469,7 @@ discard block |
||
1469 | 1469 | $use_division = true; |
1470 | 1470 | break; |
1471 | 1471 | case 'tag' : |
1472 | - $args->s_tags = str_replace(' ','%',$search_keyword); |
|
1472 | + $args->s_tags = str_replace(' ', '%', $search_keyword); |
|
1473 | 1473 | $query_id = 'document.getDocumentListWithinTag'; |
1474 | 1474 | break; |
1475 | 1475 | case 'extra_vars': |
@@ -1477,9 +1477,9 @@ discard block |
||
1477 | 1477 | $query_id = 'document.getDocumentListWithinExtraVars'; |
1478 | 1478 | break; |
1479 | 1479 | default : |
1480 | - if(strpos($search_target,'extra_vars')!==false) { |
|
1480 | + if (strpos($search_target, 'extra_vars') !== false) { |
|
1481 | 1481 | $args->var_idx = substr($search_target, strlen('extra_vars')); |
1482 | - $args->var_value = str_replace(' ','%',$search_keyword); |
|
1482 | + $args->var_value = str_replace(' ', '%', $search_keyword); |
|
1483 | 1483 | $args->sort_index = 'documents.'.$args->sort_index; |
1484 | 1484 | $query_id = 'document.getDocumentListWithExtraVars'; |
1485 | 1485 | } |
@@ -1496,18 +1496,18 @@ discard block |
||
1496 | 1496 | /** |
1497 | 1497 | * list_order asc sort of division that can be used only when |
1498 | 1498 | */ |
1499 | - if($args->sort_index != 'list_order' || $args->order_type != 'asc') $use_division = false; |
|
1499 | + if ($args->sort_index != 'list_order' || $args->order_type != 'asc') $use_division = false; |
|
1500 | 1500 | |
1501 | 1501 | /** |
1502 | 1502 | * If it is true, use_division changed to use the document division |
1503 | 1503 | */ |
1504 | - if($use_division) |
|
1504 | + if ($use_division) |
|
1505 | 1505 | { |
1506 | 1506 | // Division begins |
1507 | - $division = (int)Context::get('division'); |
|
1507 | + $division = (int) Context::get('division'); |
|
1508 | 1508 | |
1509 | 1509 | // order by list_order and (module_srl===0 or module_srl may count), therefore case table full scan |
1510 | - if($args->sort_index == 'list_order' && ($args->exclude_module_srl === '0' || count(explode(',', $args->module_srl)) > 5)) |
|
1510 | + if ($args->sort_index == 'list_order' && ($args->exclude_module_srl === '0' || count(explode(',', $args->module_srl)) > 5)) |
|
1511 | 1511 | { |
1512 | 1512 | $listSqlID = 'document.getDocumentListUseIndex'; |
1513 | 1513 | $divisionSqlID = 'document.getDocumentDivisionUseIndex'; |
@@ -1519,7 +1519,7 @@ discard block |
||
1519 | 1519 | } |
1520 | 1520 | |
1521 | 1521 | // If you do not value the best division top |
1522 | - if(!$division) |
|
1522 | + if (!$division) |
|
1523 | 1523 | { |
1524 | 1524 | $division_args = new stdClass(); |
1525 | 1525 | $division_args->module_srl = $args->module_srl; |
@@ -1530,7 +1530,7 @@ discard block |
||
1530 | 1530 | $division_args->statusList = $args->statusList; |
1531 | 1531 | |
1532 | 1532 | $output = executeQuery($divisionSqlID, $division_args, array('list_order')); |
1533 | - if($output->data) |
|
1533 | + if ($output->data) |
|
1534 | 1534 | { |
1535 | 1535 | $item = array_pop($output->data); |
1536 | 1536 | $division = $item->list_order; |
@@ -1539,10 +1539,10 @@ discard block |
||
1539 | 1539 | } |
1540 | 1540 | |
1541 | 1541 | // The last division |
1542 | - $last_division = (int)Context::get('last_division'); |
|
1542 | + $last_division = (int) Context::get('last_division'); |
|
1543 | 1543 | |
1544 | 1544 | // Division after division from the 5000 value of the specified Wanted |
1545 | - if(!$last_division) |
|
1545 | + if (!$last_division) |
|
1546 | 1546 | { |
1547 | 1547 | $last_division_args = new stdClass(); |
1548 | 1548 | $last_division_args->module_srl = $args->module_srl; |
@@ -1554,7 +1554,7 @@ discard block |
||
1554 | 1554 | $last_division_args->page = 5001; |
1555 | 1555 | |
1556 | 1556 | $output = executeQuery($divisionSqlID, $last_division_args, array('list_order')); |
1557 | - if($output->data) |
|
1557 | + if ($output->data) |
|
1558 | 1558 | { |
1559 | 1559 | $item = array_pop($output->data); |
1560 | 1560 | $last_division = $item->list_order; |
@@ -1562,14 +1562,14 @@ discard block |
||
1562 | 1562 | } |
1563 | 1563 | |
1564 | 1564 | // Make sure that after last_division article |
1565 | - if($last_division) |
|
1565 | + if ($last_division) |
|
1566 | 1566 | { |
1567 | 1567 | $last_division_args = new stdClass(); |
1568 | 1568 | $last_division_args->module_srl = $args->module_srl; |
1569 | 1569 | $last_division_args->exclude_module_srl = $args->exclude_module_srl; |
1570 | 1570 | $last_division_args->list_order = $last_division; |
1571 | 1571 | $output = executeQuery('document.getDocumentDivisionCount', $last_division_args); |
1572 | - if($output->data->count<1) $last_division = null; |
|
1572 | + if ($output->data->count < 1) $last_division = null; |
|
1573 | 1573 | } |
1574 | 1574 | |
1575 | 1575 | $args->division = $division; |
@@ -1602,7 +1602,7 @@ discard block |
||
1602 | 1602 | * @param int $count |
1603 | 1603 | * @return object |
1604 | 1604 | */ |
1605 | - function getDocumentListByMemberSrl($member_srl, $columnList = array(), $page = 0, $is_admin = FALSE, $count = 0 ) |
|
1605 | + function getDocumentListByMemberSrl($member_srl, $columnList = array(), $page = 0, $is_admin = FALSE, $count = 0) |
|
1606 | 1606 | { |
1607 | 1607 | $args = new stdClass(); |
1608 | 1608 | $args->member_srl = $member_srl; |
@@ -1610,8 +1610,8 @@ discard block |
||
1610 | 1610 | $output = executeQuery('document.getDocumentListByMemberSrl', $args, $columnList); |
1611 | 1611 | $document_list = $output->data; |
1612 | 1612 | |
1613 | - if(!$document_list) return array(); |
|
1614 | - if(!is_array($document_list)) $document_list = array($document_list); |
|
1613 | + if (!$document_list) return array(); |
|
1614 | + if (!is_array($document_list)) $document_list = array($document_list); |
|
1615 | 1615 | |
1616 | 1616 | return $document_list; |
1617 | 1617 | } |
@@ -1623,7 +1623,7 @@ discard block |
||
1623 | 1623 | function getDocumentExtraImagePath() |
1624 | 1624 | { |
1625 | 1625 | $documentConfig = getModel('document')->getDocumentConfig(); |
1626 | - if(Mobile::isFromMobilePhone()) |
|
1626 | + if (Mobile::isFromMobilePhone()) |
|
1627 | 1627 | { |
1628 | 1628 | $iconSkin = $documentConfig->micons; |
1629 | 1629 | } |
@@ -1631,7 +1631,7 @@ discard block |
||
1631 | 1631 | { |
1632 | 1632 | $iconSkin = $documentConfig->icons; |
1633 | 1633 | } |
1634 | - $path = sprintf('%s%s',getUrl(), "modules/document/tpl/icons/$iconSkin/"); |
|
1634 | + $path = sprintf('%s%s', getUrl(), "modules/document/tpl/icons/$iconSkin/"); |
|
1635 | 1635 | |
1636 | 1636 | return $path; |
1637 | 1637 | } |
@@ -24,19 +24,19 @@ discard block |
||
24 | 24 | */ |
25 | 25 | function procDocumentVoteUp() |
26 | 26 | { |
27 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request'); |
|
27 | + if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request'); |
|
28 | 28 | |
29 | 29 | $document_srl = Context::get('target_srl'); |
30 | - if(!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
30 | + if (!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
31 | 31 | |
32 | 32 | $oDocumentModel = getModel('document'); |
33 | 33 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false); |
34 | 34 | $module_srl = $oDocument->get('module_srl'); |
35 | - if(!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
35 | + if (!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
36 | 36 | |
37 | 37 | $oModuleModel = getModel('module'); |
38 | - $document_config = $oModuleModel->getModulePartConfig('document',$module_srl); |
|
39 | - if($document_config->use_vote_up=='N') return new BaseObject(-1, 'msg_invalid_request'); |
|
38 | + $document_config = $oModuleModel->getModulePartConfig('document', $module_srl); |
|
39 | + if ($document_config->use_vote_up == 'N') return new BaseObject(-1, 'msg_invalid_request'); |
|
40 | 40 | |
41 | 41 | $point = 1; |
42 | 42 | $output = $this->updateVotedCount($document_srl, $point); |
@@ -69,19 +69,19 @@ discard block |
||
69 | 69 | */ |
70 | 70 | function procDocumentVoteDown() |
71 | 71 | { |
72 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request'); |
|
72 | + if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request'); |
|
73 | 73 | |
74 | 74 | $document_srl = Context::get('target_srl'); |
75 | - if(!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
75 | + if (!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
76 | 76 | |
77 | 77 | $oDocumentModel = getModel('document'); |
78 | 78 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false); |
79 | 79 | $module_srl = $oDocument->get('module_srl'); |
80 | - if(!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
80 | + if (!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
81 | 81 | |
82 | 82 | $oModuleModel = getModel('module'); |
83 | - $document_config = $oModuleModel->getModulePartConfig('document',$module_srl); |
|
84 | - if($document_config->use_vote_down=='N') return new BaseObject(-1, 'msg_invalid_request'); |
|
83 | + $document_config = $oModuleModel->getModulePartConfig('document', $module_srl); |
|
84 | + if ($document_config->use_vote_down == 'N') return new BaseObject(-1, 'msg_invalid_request'); |
|
85 | 85 | |
86 | 86 | $point = -1; |
87 | 87 | $output = $this->updateVotedCount($document_srl, $point); |
@@ -95,10 +95,10 @@ discard block |
||
95 | 95 | */ |
96 | 96 | function procDocumentDeclare() |
97 | 97 | { |
98 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request'); |
|
98 | + if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request'); |
|
99 | 99 | |
100 | 100 | $document_srl = Context::get('target_srl'); |
101 | - if(!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
101 | + if (!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
102 | 102 | |
103 | 103 | return $this->declaredDocument($document_srl); |
104 | 104 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | $args->history_srl = $history_srl; |
141 | 141 | $args->module_srl = $module_srl; |
142 | 142 | $args->document_srl = $document_srl; |
143 | - if(!$args->history_srl && !$args->module_srl && !$args->document_srl) return; |
|
143 | + if (!$args->history_srl && !$args->module_srl && !$args->document_srl) return; |
|
144 | 144 | executeQuery("document.deleteHistory", $args); |
145 | 145 | } |
146 | 146 | |
@@ -152,15 +152,15 @@ discard block |
||
152 | 152 | function triggerDeleteModuleDocuments(&$obj) |
153 | 153 | { |
154 | 154 | $module_srl = $obj->module_srl; |
155 | - if(!$module_srl) return new BaseObject(); |
|
155 | + if (!$module_srl) return new BaseObject(); |
|
156 | 156 | // Delete the document |
157 | 157 | $oDocumentAdminController = getAdminController('document'); |
158 | 158 | $output = $oDocumentAdminController->deleteModuleDocument($module_srl); |
159 | - if(!$output->toBool()) return $output; |
|
159 | + if (!$output->toBool()) return $output; |
|
160 | 160 | // Delete the category |
161 | 161 | $oDocumentController = getController('document'); |
162 | 162 | $output = $oDocumentController->deleteModuleCategory($module_srl); |
163 | - if(!$output->toBool()) return $output; |
|
163 | + if (!$output->toBool()) return $output; |
|
164 | 164 | // Delete extra key and variable, because module deleted |
165 | 165 | $this->deleteDocumentExtraKeys($module_srl); |
166 | 166 | |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | */ |
194 | 194 | function insertDocument($obj, $manual_inserted = false, $isRestore = false, $isLatest = true) |
195 | 195 | { |
196 | - if(!$manual_inserted && !checkCSRF()) |
|
196 | + if (!$manual_inserted && !checkCSRF()) |
|
197 | 197 | { |
198 | 198 | return new BaseObject(-1, 'msg_invalid_request'); |
199 | 199 | } |
@@ -202,32 +202,32 @@ discard block |
||
202 | 202 | $oDB = &DB::getInstance(); |
203 | 203 | $oDB->begin(); |
204 | 204 | // List variables |
205 | - if($obj->comment_status) $obj->commentStatus = $obj->comment_status; |
|
206 | - if(!$obj->commentStatus) $obj->commentStatus = 'DENY'; |
|
207 | - if($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj); |
|
208 | - if($obj->allow_trackback!='Y') $obj->allow_trackback = 'N'; |
|
209 | - if($obj->homepage) |
|
205 | + if ($obj->comment_status) $obj->commentStatus = $obj->comment_status; |
|
206 | + if (!$obj->commentStatus) $obj->commentStatus = 'DENY'; |
|
207 | + if ($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj); |
|
208 | + if ($obj->allow_trackback != 'Y') $obj->allow_trackback = 'N'; |
|
209 | + if ($obj->homepage) |
|
210 | 210 | { |
211 | 211 | $obj->homepage = removeHackTag($obj->homepage); |
212 | - if(!preg_match('/^[a-z]+:\/\//i',$obj->homepage)) |
|
212 | + if (!preg_match('/^[a-z]+:\/\//i', $obj->homepage)) |
|
213 | 213 | { |
214 | 214 | $obj->homepage = 'http://'.$obj->homepage; |
215 | 215 | } |
216 | 216 | } |
217 | 217 | |
218 | - if($obj->notify_message != 'Y') $obj->notify_message = 'N'; |
|
219 | - if(!$obj->email_address) $obj->email_address = ''; |
|
220 | - if(!$isRestore) $obj->ipaddress = $_SERVER['REMOTE_ADDR']; |
|
218 | + if ($obj->notify_message != 'Y') $obj->notify_message = 'N'; |
|
219 | + if (!$obj->email_address) $obj->email_address = ''; |
|
220 | + if (!$isRestore) $obj->ipaddress = $_SERVER['REMOTE_ADDR']; |
|
221 | 221 | |
222 | 222 | // can modify regdate only manager |
223 | 223 | $grant = Context::get('grant'); |
224 | - if(!$grant->manager) |
|
224 | + if (!$grant->manager) |
|
225 | 225 | { |
226 | 226 | unset($obj->regdate); |
227 | 227 | } |
228 | 228 | |
229 | 229 | // Serialize the $extra_vars, check the extra_vars type, because duplicate serialized avoid |
230 | - if(!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars); |
|
230 | + if (!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars); |
|
231 | 231 | // Remove the columns for automatic saving |
232 | 232 | unset($obj->_saved_doc_srl); |
233 | 233 | unset($obj->_saved_doc_title); |
@@ -235,34 +235,34 @@ discard block |
||
235 | 235 | unset($obj->_saved_doc_message); |
236 | 236 | // Call a trigger (before) |
237 | 237 | $output = ModuleHandler::triggerCall('document.insertDocument', 'before', $obj); |
238 | - if(!$output->toBool()) return $output; |
|
238 | + if (!$output->toBool()) return $output; |
|
239 | 239 | // Register it if no given document_srl exists |
240 | - if(!$obj->document_srl) $obj->document_srl = getNextSequence(); |
|
241 | - elseif(!$manual_inserted && !$isRestore && !checkUserSequence($obj->document_srl)) return new BaseObject(-1, 'msg_not_permitted'); |
|
240 | + if (!$obj->document_srl) $obj->document_srl = getNextSequence(); |
|
241 | + elseif (!$manual_inserted && !$isRestore && !checkUserSequence($obj->document_srl)) return new BaseObject(-1, 'msg_not_permitted'); |
|
242 | 242 | |
243 | 243 | $oDocumentModel = getModel('document'); |
244 | 244 | // Set to 0 if the category_srl doesn't exist |
245 | - if($obj->category_srl) |
|
245 | + if ($obj->category_srl) |
|
246 | 246 | { |
247 | 247 | $category_list = $oDocumentModel->getCategoryList($obj->module_srl); |
248 | - if(count($category_list) > 0 && !$category_list[$obj->category_srl]->grant) |
|
248 | + if (count($category_list) > 0 && !$category_list[$obj->category_srl]->grant) |
|
249 | 249 | { |
250 | 250 | return new BaseObject(-1, 'msg_not_permitted'); |
251 | 251 | } |
252 | - if(count($category_list) > 0 && !$category_list[$obj->category_srl]) $obj->category_srl = 0; |
|
252 | + if (count($category_list) > 0 && !$category_list[$obj->category_srl]) $obj->category_srl = 0; |
|
253 | 253 | } |
254 | 254 | // Set the read counts and update order. |
255 | - if(!$obj->readed_count) $obj->readed_count = 0; |
|
256 | - if($isLatest) $obj->update_order = $obj->list_order = $obj->document_srl * -1; |
|
255 | + if (!$obj->readed_count) $obj->readed_count = 0; |
|
256 | + if ($isLatest) $obj->update_order = $obj->list_order = $obj->document_srl * -1; |
|
257 | 257 | else $obj->update_order = $obj->list_order; |
258 | 258 | // Check the status of password hash for manually inserting. Apply hashing for otherwise. |
259 | - if($obj->password && !$obj->password_is_hashed) |
|
259 | + if ($obj->password && !$obj->password_is_hashed) |
|
260 | 260 | { |
261 | 261 | $obj->password = getModel('member')->hashPassword($obj->password); |
262 | 262 | } |
263 | 263 | // Insert member's information only if the member is logged-in and not manually registered. |
264 | 264 | $logged_info = Context::get('logged_info'); |
265 | - if(Context::get('is_logged') && !$manual_inserted && !$isRestore) |
|
265 | + if (Context::get('is_logged') && !$manual_inserted && !$isRestore) |
|
266 | 266 | { |
267 | 267 | $obj->member_srl = $logged_info->member_srl; |
268 | 268 | |
@@ -276,61 +276,61 @@ discard block |
||
276 | 276 | // If the tile is empty, extract string from the contents. |
277 | 277 | $obj->title = htmlspecialchars($obj->title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
278 | 278 | settype($obj->title, "string"); |
279 | - if($obj->title == '') $obj->title = cut_str(trim(strip_tags(nl2br($obj->content))),20,'...'); |
|
279 | + if ($obj->title == '') $obj->title = cut_str(trim(strip_tags(nl2br($obj->content))), 20, '...'); |
|
280 | 280 | // If no tile extracted from the contents, leave it untitled. |
281 | - if($obj->title == '') $obj->title = 'Untitled'; |
|
281 | + if ($obj->title == '') $obj->title = 'Untitled'; |
|
282 | 282 | // Remove XE's own tags from the contents. |
283 | 283 | $obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content); |
284 | - if(Mobile::isFromMobilePhone() && $obj->use_editor != 'Y') |
|
284 | + if (Mobile::isFromMobilePhone() && $obj->use_editor != 'Y') |
|
285 | 285 | { |
286 | - if($obj->use_html != 'Y') |
|
286 | + if ($obj->use_html != 'Y') |
|
287 | 287 | { |
288 | 288 | $obj->content = htmlspecialchars($obj->content, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
289 | 289 | } |
290 | 290 | $obj->content = nl2br($obj->content); |
291 | 291 | } |
292 | 292 | // Remove iframe and script if not a top adminisrator in the session. |
293 | - if($logged_info->is_admin != 'Y') $obj->content = removeHackTag($obj->content); |
|
293 | + if ($logged_info->is_admin != 'Y') $obj->content = removeHackTag($obj->content); |
|
294 | 294 | // An error appears if both log-in info and user name don't exist. |
295 | - if(!$logged_info->member_srl && !$obj->nick_name) return new BaseObject(-1,'msg_invalid_request'); |
|
295 | + if (!$logged_info->member_srl && !$obj->nick_name) return new BaseObject(-1, 'msg_invalid_request'); |
|
296 | 296 | |
297 | 297 | $obj->lang_code = Context::getLangType(); |
298 | 298 | // Insert data into the DB |
299 | - if(!$obj->status) $this->_checkDocumentStatusForOldVersion($obj); |
|
299 | + if (!$obj->status) $this->_checkDocumentStatusForOldVersion($obj); |
|
300 | 300 | $output = executeQuery('document.insertDocument', $obj); |
301 | - if(!$output->toBool()) |
|
301 | + if (!$output->toBool()) |
|
302 | 302 | { |
303 | 303 | $oDB->rollback(); |
304 | 304 | return $output; |
305 | 305 | } |
306 | 306 | // Insert extra variables if the document successfully inserted. |
307 | 307 | $extra_keys = $oDocumentModel->getExtraKeys($obj->module_srl); |
308 | - if(count($extra_keys)) |
|
308 | + if (count($extra_keys)) |
|
309 | 309 | { |
310 | - foreach($extra_keys as $idx => $extra_item) |
|
310 | + foreach ($extra_keys as $idx => $extra_item) |
|
311 | 311 | { |
312 | 312 | $value = NULL; |
313 | - if(isset($obj->{'extra_vars'.$idx})) |
|
313 | + if (isset($obj->{'extra_vars'.$idx})) |
|
314 | 314 | { |
315 | 315 | $tmp = $obj->{'extra_vars'.$idx}; |
316 | - if(is_array($tmp)) |
|
316 | + if (is_array($tmp)) |
|
317 | 317 | $value = implode('|@|', $tmp); |
318 | 318 | else |
319 | 319 | $value = trim($tmp); |
320 | 320 | } |
321 | - else if(isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name}); |
|
322 | - if($value == NULL) continue; |
|
321 | + else if (isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name}); |
|
322 | + if ($value == NULL) continue; |
|
323 | 323 | |
324 | 324 | $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid); |
325 | 325 | } |
326 | 326 | } |
327 | 327 | // Update the category if the category_srl exists. |
328 | - if($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
328 | + if ($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
329 | 329 | // Call a trigger (after) |
330 | - if($output->toBool()) |
|
330 | + if ($output->toBool()) |
|
331 | 331 | { |
332 | 332 | $trigger_output = ModuleHandler::triggerCall('document.insertDocument', 'after', $obj); |
333 | - if(!$trigger_output->toBool()) |
|
333 | + if (!$trigger_output->toBool()) |
|
334 | 334 | { |
335 | 335 | $oDB->rollback(); |
336 | 336 | return $trigger_output; |
@@ -341,12 +341,12 @@ discard block |
||
341 | 341 | $oDB->commit(); |
342 | 342 | |
343 | 343 | // return |
344 | - if(!$manual_inserted) |
|
344 | + if (!$manual_inserted) |
|
345 | 345 | { |
346 | 346 | $this->addGrant($obj->document_srl); |
347 | 347 | } |
348 | - $output->add('document_srl',$obj->document_srl); |
|
349 | - $output->add('category_srl',$obj->category_srl); |
|
348 | + $output->add('document_srl', $obj->document_srl); |
|
349 | + $output->add('category_srl', $obj->category_srl); |
|
350 | 350 | |
351 | 351 | return $output; |
352 | 352 | } |
@@ -362,41 +362,41 @@ discard block |
||
362 | 362 | { |
363 | 363 | $logged_info = Context::get('logged_info'); |
364 | 364 | |
365 | - if(!$manual_updated && !checkCSRF()) |
|
365 | + if (!$manual_updated && !checkCSRF()) |
|
366 | 366 | { |
367 | 367 | return new BaseObject(-1, 'msg_invalid_request'); |
368 | 368 | } |
369 | 369 | |
370 | - if(!$source_obj->document_srl || !$obj->document_srl) return new BaseObject(-1,'msg_invalied_request'); |
|
371 | - if(!$obj->status && $obj->is_secret == 'Y') $obj->status = 'SECRET'; |
|
372 | - if(!$obj->status) $obj->status = 'PUBLIC'; |
|
370 | + if (!$source_obj->document_srl || !$obj->document_srl) return new BaseObject(-1, 'msg_invalied_request'); |
|
371 | + if (!$obj->status && $obj->is_secret == 'Y') $obj->status = 'SECRET'; |
|
372 | + if (!$obj->status) $obj->status = 'PUBLIC'; |
|
373 | 373 | |
374 | 374 | // Call a trigger (before) |
375 | 375 | $output = ModuleHandler::triggerCall('document.updateDocument', 'before', $obj); |
376 | - if(!$output->toBool()) return $output; |
|
376 | + if (!$output->toBool()) return $output; |
|
377 | 377 | |
378 | 378 | // begin transaction |
379 | 379 | $oDB = &DB::getInstance(); |
380 | 380 | $oDB->begin(); |
381 | 381 | |
382 | 382 | $oModuleModel = getModel('module'); |
383 | - if(!$obj->module_srl) $obj->module_srl = $source_obj->get('module_srl'); |
|
383 | + if (!$obj->module_srl) $obj->module_srl = $source_obj->get('module_srl'); |
|
384 | 384 | $module_srl = $obj->module_srl; |
385 | 385 | $document_config = $oModuleModel->getModulePartConfig('document', $module_srl); |
386 | - if(!$document_config) |
|
386 | + if (!$document_config) |
|
387 | 387 | { |
388 | 388 | $document_config = new stdClass(); |
389 | 389 | } |
390 | - if(!isset($document_config->use_history)) $document_config->use_history = 'N'; |
|
390 | + if (!isset($document_config->use_history)) $document_config->use_history = 'N'; |
|
391 | 391 | $bUseHistory = $document_config->use_history == 'Y' || $document_config->use_history == 'Trace'; |
392 | 392 | |
393 | - if($bUseHistory) |
|
393 | + if ($bUseHistory) |
|
394 | 394 | { |
395 | 395 | $args = new stdClass; |
396 | 396 | $args->history_srl = getNextSequence(); |
397 | 397 | $args->document_srl = $obj->document_srl; |
398 | 398 | $args->module_srl = $module_srl; |
399 | - if($document_config->use_history == 'Y') $args->content = $source_obj->get('content'); |
|
399 | + if ($document_config->use_history == 'Y') $args->content = $source_obj->get('content'); |
|
400 | 400 | $args->nick_name = $logged_info->nick_name; |
401 | 401 | $args->member_srl = $logged_info->member_srl; |
402 | 402 | $args->regdate = $source_obj->get('last_update'); |
@@ -408,30 +408,30 @@ discard block |
||
408 | 408 | $obj->ipaddress = $source_obj->get('ipaddress'); |
409 | 409 | } |
410 | 410 | // List variables |
411 | - if($obj->comment_status) $obj->commentStatus = $obj->comment_status; |
|
412 | - if(!$obj->commentStatus) $obj->commentStatus = 'DENY'; |
|
413 | - if($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj); |
|
414 | - if($obj->allow_trackback!='Y') $obj->allow_trackback = 'N'; |
|
415 | - if($obj->homepage) |
|
411 | + if ($obj->comment_status) $obj->commentStatus = $obj->comment_status; |
|
412 | + if (!$obj->commentStatus) $obj->commentStatus = 'DENY'; |
|
413 | + if ($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj); |
|
414 | + if ($obj->allow_trackback != 'Y') $obj->allow_trackback = 'N'; |
|
415 | + if ($obj->homepage) |
|
416 | 416 | { |
417 | 417 | $obj->homepage = removeHackTag($obj->homepage); |
418 | - if(!preg_match('/^[a-z]+:\/\//i',$obj->homepage)) |
|
418 | + if (!preg_match('/^[a-z]+:\/\//i', $obj->homepage)) |
|
419 | 419 | { |
420 | 420 | $obj->homepage = 'http://'.$obj->homepage; |
421 | 421 | } |
422 | 422 | } |
423 | 423 | |
424 | - if($obj->notify_message != 'Y') $obj->notify_message = 'N'; |
|
424 | + if ($obj->notify_message != 'Y') $obj->notify_message = 'N'; |
|
425 | 425 | |
426 | 426 | // can modify regdate only manager |
427 | 427 | $grant = Context::get('grant'); |
428 | - if(!$grant->manager) |
|
428 | + if (!$grant->manager) |
|
429 | 429 | { |
430 | 430 | unset($obj->regdate); |
431 | 431 | } |
432 | 432 | |
433 | 433 | // Serialize the $extra_vars |
434 | - if(!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars); |
|
434 | + if (!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars); |
|
435 | 435 | // Remove the columns for automatic saving |
436 | 436 | unset($obj->_saved_doc_srl); |
437 | 437 | unset($obj->_saved_doc_title); |
@@ -440,23 +440,23 @@ discard block |
||
440 | 440 | |
441 | 441 | $oDocumentModel = getModel('document'); |
442 | 442 | // Set the category_srl to 0 if the changed category is not exsiting. |
443 | - if($source_obj->get('category_srl')!=$obj->category_srl) |
|
443 | + if ($source_obj->get('category_srl') != $obj->category_srl) |
|
444 | 444 | { |
445 | 445 | $category_list = $oDocumentModel->getCategoryList($obj->module_srl); |
446 | - if(!$category_list[$obj->category_srl]) $obj->category_srl = 0; |
|
446 | + if (!$category_list[$obj->category_srl]) $obj->category_srl = 0; |
|
447 | 447 | } |
448 | 448 | // Change the update order |
449 | 449 | $obj->update_order = getNextSequence() * -1; |
450 | 450 | // Hash the password if it exists |
451 | - if($obj->password) |
|
451 | + if ($obj->password) |
|
452 | 452 | { |
453 | 453 | $obj->password = getModel('member')->hashPassword($obj->password); |
454 | 454 | } |
455 | 455 | |
456 | 456 | // If an author is identical to the modifier or history is used, use the logged-in user's information. |
457 | - if(Context::get('is_logged') && !$manual_updated) |
|
457 | + if (Context::get('is_logged') && !$manual_updated) |
|
458 | 458 | { |
459 | - if($source_obj->get('member_srl')==$logged_info->member_srl) |
|
459 | + if ($source_obj->get('member_srl') == $logged_info->member_srl) |
|
460 | 460 | { |
461 | 461 | $obj->member_srl = $logged_info->member_srl; |
462 | 462 | $obj->user_name = htmlspecialchars_decode($logged_info->user_name); |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | } |
468 | 468 | |
469 | 469 | // For the document written by logged-in user however no nick_name exists |
470 | - if($source_obj->get('member_srl')&& !$obj->nick_name) |
|
470 | + if ($source_obj->get('member_srl') && !$obj->nick_name) |
|
471 | 471 | { |
472 | 472 | $obj->member_srl = $source_obj->get('member_srl'); |
473 | 473 | $obj->user_name = $source_obj->get('user_name'); |
@@ -478,24 +478,24 @@ discard block |
||
478 | 478 | // If the tile is empty, extract string from the contents. |
479 | 479 | $obj->title = htmlspecialchars($obj->title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
480 | 480 | settype($obj->title, "string"); |
481 | - if($obj->title == '') $obj->title = cut_str(strip_tags($obj->content),20,'...'); |
|
481 | + if ($obj->title == '') $obj->title = cut_str(strip_tags($obj->content), 20, '...'); |
|
482 | 482 | // If no tile extracted from the contents, leave it untitled. |
483 | - if($obj->title == '') $obj->title = 'Untitled'; |
|
483 | + if ($obj->title == '') $obj->title = 'Untitled'; |
|
484 | 484 | // Remove XE's own tags from the contents. |
485 | 485 | $obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content); |
486 | - if(Mobile::isFromMobilePhone() && $obj->use_editor != 'Y') |
|
486 | + if (Mobile::isFromMobilePhone() && $obj->use_editor != 'Y') |
|
487 | 487 | { |
488 | - if($obj->use_html != 'Y') |
|
488 | + if ($obj->use_html != 'Y') |
|
489 | 489 | { |
490 | 490 | $obj->content = htmlspecialchars($obj->content, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
491 | 491 | } |
492 | 492 | $obj->content = nl2br($obj->content); |
493 | 493 | } |
494 | 494 | // Change not extra vars but language code of the original document if document's lang_code is different from author's setting. |
495 | - if($source_obj->get('lang_code') != Context::getLangType()) |
|
495 | + if ($source_obj->get('lang_code') != Context::getLangType()) |
|
496 | 496 | { |
497 | 497 | // Change not extra vars but language code of the original document if document's lang_code doesn't exist. |
498 | - if(!$source_obj->get('lang_code')) |
|
498 | + if (!$source_obj->get('lang_code')) |
|
499 | 499 | { |
500 | 500 | $lang_code_args->document_srl = $source_obj->get('document_srl'); |
501 | 501 | $lang_code_args->lang_code = Context::getLangType(); |
@@ -515,59 +515,59 @@ discard block |
||
515 | 515 | } |
516 | 516 | } |
517 | 517 | // Remove iframe and script if not a top adminisrator in the session. |
518 | - if($logged_info->is_admin != 'Y') |
|
518 | + if ($logged_info->is_admin != 'Y') |
|
519 | 519 | { |
520 | 520 | $obj->content = removeHackTag($obj->content); |
521 | 521 | } |
522 | 522 | // if temporary document, regdate is now setting |
523 | - if($source_obj->get('status') == $this->getConfigStatus('temp')) $obj->regdate = date('YmdHis'); |
|
523 | + if ($source_obj->get('status') == $this->getConfigStatus('temp')) $obj->regdate = date('YmdHis'); |
|
524 | 524 | |
525 | 525 | // Insert data into the DB |
526 | 526 | $output = executeQuery('document.updateDocument', $obj); |
527 | - if(!$output->toBool()) |
|
527 | + if (!$output->toBool()) |
|
528 | 528 | { |
529 | 529 | $oDB->rollback(); |
530 | 530 | return $output; |
531 | 531 | } |
532 | 532 | // Remove all extra variables |
533 | - if(Context::get('act')!='procFileDelete') |
|
533 | + if (Context::get('act') != 'procFileDelete') |
|
534 | 534 | { |
535 | 535 | $this->deleteDocumentExtraVars($source_obj->get('module_srl'), $obj->document_srl, null, Context::getLangType()); |
536 | 536 | // Insert extra variables if the document successfully inserted. |
537 | 537 | $extra_keys = $oDocumentModel->getExtraKeys($obj->module_srl); |
538 | - if(count($extra_keys)) |
|
538 | + if (count($extra_keys)) |
|
539 | 539 | { |
540 | - foreach($extra_keys as $idx => $extra_item) |
|
540 | + foreach ($extra_keys as $idx => $extra_item) |
|
541 | 541 | { |
542 | 542 | $value = NULL; |
543 | - if(isset($obj->{'extra_vars'.$idx})) |
|
543 | + if (isset($obj->{'extra_vars'.$idx})) |
|
544 | 544 | { |
545 | 545 | $tmp = $obj->{'extra_vars'.$idx}; |
546 | - if(is_array($tmp)) |
|
546 | + if (is_array($tmp)) |
|
547 | 547 | $value = implode('|@|', $tmp); |
548 | 548 | else |
549 | 549 | $value = trim($tmp); |
550 | 550 | } |
551 | - else if(isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name}); |
|
552 | - if($value == NULL) continue; |
|
551 | + else if (isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name}); |
|
552 | + if ($value == NULL) continue; |
|
553 | 553 | $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid); |
554 | 554 | } |
555 | 555 | } |
556 | 556 | // Inert extra vars for multi-language support of title and contents. |
557 | - if($extra_content->title) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -1, $extra_content->title, 'title_'.Context::getLangType()); |
|
558 | - if($extra_content->content) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -2, $extra_content->content, 'content_'.Context::getLangType()); |
|
557 | + if ($extra_content->title) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -1, $extra_content->title, 'title_'.Context::getLangType()); |
|
558 | + if ($extra_content->content) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -2, $extra_content->content, 'content_'.Context::getLangType()); |
|
559 | 559 | } |
560 | 560 | // Update the category if the category_srl exists. |
561 | - if($source_obj->get('category_srl') != $obj->category_srl || $source_obj->get('module_srl') == $logged_info->member_srl) |
|
561 | + if ($source_obj->get('category_srl') != $obj->category_srl || $source_obj->get('module_srl') == $logged_info->member_srl) |
|
562 | 562 | { |
563 | - if($source_obj->get('category_srl') != $obj->category_srl) $this->updateCategoryCount($obj->module_srl, $source_obj->get('category_srl')); |
|
564 | - if($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
563 | + if ($source_obj->get('category_srl') != $obj->category_srl) $this->updateCategoryCount($obj->module_srl, $source_obj->get('category_srl')); |
|
564 | + if ($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
565 | 565 | } |
566 | 566 | // Call a trigger (after) |
567 | - if($output->toBool()) |
|
567 | + if ($output->toBool()) |
|
568 | 568 | { |
569 | 569 | $trigger_output = ModuleHandler::triggerCall('document.updateDocument', 'after', $obj); |
570 | - if(!$trigger_output->toBool()) |
|
570 | + if (!$trigger_output->toBool()) |
|
571 | 571 | { |
572 | 572 | $oDB->rollback(); |
573 | 573 | return $trigger_output; |
@@ -577,15 +577,15 @@ discard block |
||
577 | 577 | // commit |
578 | 578 | $oDB->commit(); |
579 | 579 | // Remove the thumbnail file |
580 | - FileHandler::removeDir(sprintf('files/thumbnails/%s',getNumberingPath($obj->document_srl, 3))); |
|
580 | + FileHandler::removeDir(sprintf('files/thumbnails/%s', getNumberingPath($obj->document_srl, 3))); |
|
581 | 581 | |
582 | - $output->add('document_srl',$obj->document_srl); |
|
582 | + $output->add('document_srl', $obj->document_srl); |
|
583 | 583 | //remove from cache |
584 | 584 | $oCacheHandler = CacheHandler::getInstance('object'); |
585 | - if($oCacheHandler->isSupport()) |
|
585 | + if ($oCacheHandler->isSupport()) |
|
586 | 586 | { |
587 | 587 | //remove document item from cache |
588 | - $cache_key = 'document_item:'. getNumberingPath($obj->document_srl) . $obj->document_srl; |
|
588 | + $cache_key = 'document_item:'.getNumberingPath($obj->document_srl).$obj->document_srl; |
|
589 | 589 | $oCacheHandler->delete($cache_key); |
590 | 590 | } |
591 | 591 | |
@@ -606,33 +606,33 @@ discard block |
||
606 | 606 | $trigger_obj = new stdClass(); |
607 | 607 | $trigger_obj->document_srl = $document_srl; |
608 | 608 | $output = ModuleHandler::triggerCall('document.deleteDocument', 'before', $trigger_obj); |
609 | - if(!$output->toBool()) return $output; |
|
609 | + if (!$output->toBool()) return $output; |
|
610 | 610 | |
611 | 611 | // begin transaction |
612 | 612 | $oDB = &DB::getInstance(); |
613 | 613 | $oDB->begin(); |
614 | 614 | |
615 | - if(!$isEmptyTrash) |
|
615 | + if (!$isEmptyTrash) |
|
616 | 616 | { |
617 | 617 | // get model object of the document |
618 | 618 | $oDocumentModel = getModel('document'); |
619 | 619 | // Check if the documnet exists |
620 | 620 | $oDocument = $oDocumentModel->getDocument($document_srl, $is_admin); |
621 | 621 | } |
622 | - else if($isEmptyTrash && $oDocument == null) return new BaseObject(-1, 'document is not exists'); |
|
622 | + else if ($isEmptyTrash && $oDocument == null) return new BaseObject(-1, 'document is not exists'); |
|
623 | 623 | |
624 | - if(!$oDocument->isExists() || $oDocument->document_srl != $document_srl) return new BaseObject(-1, 'msg_invalid_document'); |
|
624 | + if (!$oDocument->isExists() || $oDocument->document_srl != $document_srl) return new BaseObject(-1, 'msg_invalid_document'); |
|
625 | 625 | // Check if a permossion is granted |
626 | - if(!$oDocument->isGranted()) return new BaseObject(-1, 'msg_not_permitted'); |
|
626 | + if (!$oDocument->isGranted()) return new BaseObject(-1, 'msg_not_permitted'); |
|
627 | 627 | |
628 | 628 | //if empty trash, document already deleted, therefore document not delete |
629 | 629 | $args = new stdClass(); |
630 | 630 | $args->document_srl = $document_srl; |
631 | - if(!$isEmptyTrash) |
|
631 | + if (!$isEmptyTrash) |
|
632 | 632 | { |
633 | 633 | // Delete the document |
634 | 634 | $output = executeQuery('document.deleteDocument', $args); |
635 | - if(!$output->toBool()) |
|
635 | + if (!$output->toBool()) |
|
636 | 636 | { |
637 | 637 | $oDB->rollback(); |
638 | 638 | return $output; |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | |
644 | 644 | $this->deleteDocumentHistory(null, $document_srl, null); |
645 | 645 | // Update category information if the category_srl exists. |
646 | - if($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl')); |
|
646 | + if ($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'), $oDocument->get('category_srl')); |
|
647 | 647 | // Delete a declared list |
648 | 648 | executeQuery('document.deleteDeclared', $args); |
649 | 649 | // Delete extra variable |
@@ -651,11 +651,11 @@ discard block |
||
651 | 651 | |
652 | 652 | //this |
653 | 653 | // Call a trigger (after) |
654 | - if($output->toBool()) |
|
654 | + if ($output->toBool()) |
|
655 | 655 | { |
656 | 656 | $trigger_obj = $oDocument->getObjectVars(); |
657 | 657 | $trigger_output = ModuleHandler::triggerCall('document.deleteDocument', 'after', $trigger_obj); |
658 | - if(!$trigger_output->toBool()) |
|
658 | + if (!$trigger_output->toBool()) |
|
659 | 659 | { |
660 | 660 | $oDB->rollback(); |
661 | 661 | return $trigger_output; |
@@ -667,16 +667,16 @@ discard block |
||
667 | 667 | $this->_deleteDocumentVotedLog($args); |
668 | 668 | |
669 | 669 | // Remove the thumbnail file |
670 | - FileHandler::removeDir(sprintf('files/thumbnails/%s',getNumberingPath($document_srl, 3))); |
|
670 | + FileHandler::removeDir(sprintf('files/thumbnails/%s', getNumberingPath($document_srl, 3))); |
|
671 | 671 | |
672 | 672 | // commit |
673 | 673 | $oDB->commit(); |
674 | 674 | |
675 | 675 | //remove from cache |
676 | 676 | $oCacheHandler = CacheHandler::getInstance('object'); |
677 | - if($oCacheHandler->isSupport()) |
|
677 | + if ($oCacheHandler->isSupport()) |
|
678 | 678 | { |
679 | - $cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl; |
|
679 | + $cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl; |
|
680 | 680 | $oCacheHandler->delete($cache_key); |
681 | 681 | } |
682 | 682 | |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | { |
724 | 724 | $trash_args = new stdClass(); |
725 | 725 | // Get trash_srl if a given trash_srl doesn't exist |
726 | - if(!$obj->trash_srl) $trash_args->trash_srl = getNextSequence(); |
|
726 | + if (!$obj->trash_srl) $trash_args->trash_srl = getNextSequence(); |
|
727 | 727 | else $trash_args->trash_srl = $obj->trash_srl; |
728 | 728 | // Get its module_srl which the document belongs to |
729 | 729 | $oDocumentModel = getModel('document'); |
@@ -732,12 +732,12 @@ discard block |
||
732 | 732 | $trash_args->module_srl = $oDocument->get('module_srl'); |
733 | 733 | $obj->module_srl = $oDocument->get('module_srl'); |
734 | 734 | // Cannot throw data from the trash to the trash |
735 | - if($trash_args->module_srl == 0) return false; |
|
735 | + if ($trash_args->module_srl == 0) return false; |
|
736 | 736 | // Data setting |
737 | 737 | $trash_args->document_srl = $obj->document_srl; |
738 | 738 | $trash_args->description = $obj->description; |
739 | 739 | // Insert member's information only if the member is logged-in and not manually registered. |
740 | - if(Context::get('is_logged')&&!$manual_inserted) |
|
740 | + if (Context::get('is_logged') && !$manual_inserted) |
|
741 | 741 | { |
742 | 742 | $logged_info = Context::get('logged_info'); |
743 | 743 | $trash_args->member_srl = $logged_info->member_srl; |
@@ -773,14 +773,14 @@ discard block |
||
773 | 773 | |
774 | 774 | $oTrashAdminController = getAdminController('trash'); |
775 | 775 | $output = $oTrashAdminController->insertTrash($oTrashVO); |
776 | - if(!$output->toBool()) |
|
776 | + if (!$output->toBool()) |
|
777 | 777 | { |
778 | 778 | $oDB->rollback(); |
779 | 779 | return $output; |
780 | 780 | } |
781 | 781 | |
782 | 782 | $output = executeQuery('document.deleteDocument', $trash_args); |
783 | - if(!$output->toBool()) |
|
783 | + if (!$output->toBool()) |
|
784 | 784 | { |
785 | 785 | $oDB->rollback(); |
786 | 786 | return $output; |
@@ -793,12 +793,12 @@ discard block |
||
793 | 793 | }*/ |
794 | 794 | |
795 | 795 | // update category |
796 | - if($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl')); |
|
796 | + if ($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'), $oDocument->get('category_srl')); |
|
797 | 797 | |
798 | 798 | // remove thumbnails |
799 | - FileHandler::removeDir(sprintf('files/thumbnails/%s',getNumberingPath($obj->document_srl, 3))); |
|
799 | + FileHandler::removeDir(sprintf('files/thumbnails/%s', getNumberingPath($obj->document_srl, 3))); |
|
800 | 800 | // Set the attachment to be invalid state |
801 | - if($oDocument->hasUploadedFiles()) |
|
801 | + if ($oDocument->hasUploadedFiles()) |
|
802 | 802 | { |
803 | 803 | $args = new stdClass(); |
804 | 804 | $args->upload_target_srl = $oDocument->document_srl; |
@@ -806,10 +806,10 @@ discard block |
||
806 | 806 | executeQuery('file.updateFileValid', $args); |
807 | 807 | } |
808 | 808 | // Call a trigger (after) |
809 | - if($output->toBool()) |
|
809 | + if ($output->toBool()) |
|
810 | 810 | { |
811 | 811 | $trigger_output = ModuleHandler::triggerCall('document.moveDocumentToTrash', 'after', $obj); |
812 | - if(!$trigger_output->toBool()) |
|
812 | + if (!$trigger_output->toBool()) |
|
813 | 813 | { |
814 | 814 | $oDB->rollback(); |
815 | 815 | return $trigger_output; |
@@ -821,9 +821,9 @@ discard block |
||
821 | 821 | |
822 | 822 | // Clear cache |
823 | 823 | $oCacheHandler = CacheHandler::getInstance('object'); |
824 | - if($oCacheHandler->isSupport()) |
|
824 | + if ($oCacheHandler->isSupport()) |
|
825 | 825 | { |
826 | - $cache_key = 'document_item:'. getNumberingPath($oDocument->document_srl) . $oDocument->document_srl; |
|
826 | + $cache_key = 'document_item:'.getNumberingPath($oDocument->document_srl).$oDocument->document_srl; |
|
827 | 827 | $oCacheHandler->delete($cache_key); |
828 | 828 | } |
829 | 829 | |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | function updateReadedCount(&$oDocument) |
839 | 839 | { |
840 | 840 | // Pass if Crawler access |
841 | - if(isCrawler()) return false; |
|
841 | + if (isCrawler()) return false; |
|
842 | 842 | |
843 | 843 | $document_srl = $oDocument->document_srl; |
844 | 844 | $member_srl = $oDocument->get('member_srl'); |
@@ -846,19 +846,19 @@ discard block |
||
846 | 846 | |
847 | 847 | // Call a trigger when the read count is updated (before) |
848 | 848 | $trigger_output = ModuleHandler::triggerCall('document.updateReadedCount', 'before', $oDocument); |
849 | - if(!$trigger_output->toBool()) return $trigger_output; |
|
849 | + if (!$trigger_output->toBool()) return $trigger_output; |
|
850 | 850 | |
851 | 851 | // Pass if read count is increaded on the session information |
852 | - if($_SESSION['readed_document'][$document_srl]) return false; |
|
852 | + if ($_SESSION['readed_document'][$document_srl]) return false; |
|
853 | 853 | |
854 | 854 | // Pass if the author's IP address is as same as visitor's. |
855 | - if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) |
|
855 | + if ($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) |
|
856 | 856 | { |
857 | 857 | $_SESSION['readed_document'][$document_srl] = true; |
858 | 858 | return false; |
859 | 859 | } |
860 | 860 | // Pass ater registering sesscion if the author is a member and has same information as the currently logged-in user. |
861 | - if($member_srl && $logged_info->member_srl == $member_srl) |
|
861 | + if ($member_srl && $logged_info->member_srl == $member_srl) |
|
862 | 862 | { |
863 | 863 | $_SESSION['readed_document'][$document_srl] = true; |
864 | 864 | return false; |
@@ -874,7 +874,7 @@ discard block |
||
874 | 874 | |
875 | 875 | // Call a trigger when the read count is updated (after) |
876 | 876 | $trigger_output = ModuleHandler::triggerCall('document.updateReadedCount', 'after', $oDocument); |
877 | - if(!$trigger_output->toBool()) |
|
877 | + if (!$trigger_output->toBool()) |
|
878 | 878 | { |
879 | 879 | $oDB->rollback(); |
880 | 880 | return $trigger_output; |
@@ -883,15 +883,15 @@ discard block |
||
883 | 883 | $oDB->commit(); |
884 | 884 | |
885 | 885 | $oCacheHandler = CacheHandler::getInstance('object'); |
886 | - if($oCacheHandler->isSupport()) |
|
886 | + if ($oCacheHandler->isSupport()) |
|
887 | 887 | { |
888 | 888 | //remove document item from cache |
889 | - $cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl; |
|
889 | + $cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl; |
|
890 | 890 | $oCacheHandler->delete($cache_key); |
891 | 891 | } |
892 | 892 | |
893 | 893 | // Register session |
894 | - if(!$_SESSION['banned_document'][$document_srl]) |
|
894 | + if (!$_SESSION['banned_document'][$document_srl]) |
|
895 | 895 | { |
896 | 896 | $_SESSION['readed_document'][$document_srl] = true; |
897 | 897 | } |
@@ -914,21 +914,21 @@ discard block |
||
914 | 914 | */ |
915 | 915 | function insertDocumentExtraKey($module_srl, $var_idx, $var_name, $var_type, $var_is_required = 'N', $var_search = 'N', $var_default = '', $var_desc = '', $eid) |
916 | 916 | { |
917 | - if(!$module_srl || !$var_idx || !$var_name || !$var_type || !$eid) return new BaseObject(-1,'msg_invalid_request'); |
|
917 | + if (!$module_srl || !$var_idx || !$var_name || !$var_type || !$eid) return new BaseObject(-1, 'msg_invalid_request'); |
|
918 | 918 | |
919 | 919 | $obj = new stdClass(); |
920 | 920 | $obj->module_srl = $module_srl; |
921 | 921 | $obj->var_idx = $var_idx; |
922 | 922 | $obj->var_name = $var_name; |
923 | 923 | $obj->var_type = $var_type; |
924 | - $obj->var_is_required = $var_is_required=='Y'?'Y':'N'; |
|
925 | - $obj->var_search = $var_search=='Y'?'Y':'N'; |
|
924 | + $obj->var_is_required = $var_is_required == 'Y' ? 'Y' : 'N'; |
|
925 | + $obj->var_search = $var_search == 'Y' ? 'Y' : 'N'; |
|
926 | 926 | $obj->var_default = $var_default; |
927 | 927 | $obj->var_desc = $var_desc; |
928 | 928 | $obj->eid = $eid; |
929 | 929 | |
930 | 930 | $output = executeQuery('document.getDocumentExtraKeys', $obj); |
931 | - if(!$output->data) |
|
931 | + if (!$output->data) |
|
932 | 932 | { |
933 | 933 | $output = executeQuery('document.insertDocumentExtraKey', $obj); |
934 | 934 | } |
@@ -940,7 +940,7 @@ discard block |
||
940 | 940 | } |
941 | 941 | |
942 | 942 | $oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE); |
943 | - if($oCacheHandler->isSupport()) |
|
943 | + if ($oCacheHandler->isSupport()) |
|
944 | 944 | { |
945 | 945 | $object_key = 'module_document_extra_keys:'.$module_srl; |
946 | 946 | $cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); |
@@ -958,42 +958,42 @@ discard block |
||
958 | 958 | */ |
959 | 959 | function deleteDocumentExtraKeys($module_srl, $var_idx = null) |
960 | 960 | { |
961 | - if(!$module_srl) return new BaseObject(-1,'msg_invalid_request'); |
|
961 | + if (!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
962 | 962 | $obj = new stdClass(); |
963 | 963 | $obj->module_srl = $module_srl; |
964 | - if(!is_null($var_idx)) $obj->var_idx = $var_idx; |
|
964 | + if (!is_null($var_idx)) $obj->var_idx = $var_idx; |
|
965 | 965 | |
966 | 966 | $oDB = DB::getInstance(); |
967 | 967 | $oDB->begin(); |
968 | 968 | |
969 | 969 | $output = $oDB->executeQuery('document.deleteDocumentExtraKeys', $obj); |
970 | - if(!$output->toBool()) |
|
970 | + if (!$output->toBool()) |
|
971 | 971 | { |
972 | 972 | $oDB->rollback(); |
973 | 973 | return $output; |
974 | 974 | } |
975 | 975 | |
976 | - if($var_idx != NULL) |
|
976 | + if ($var_idx != NULL) |
|
977 | 977 | { |
978 | 978 | $output = $oDB->executeQuery('document.updateDocumentExtraKeyIdxOrder', $obj); |
979 | - if(!$output->toBool()) |
|
979 | + if (!$output->toBool()) |
|
980 | 980 | { |
981 | 981 | $oDB->rollback(); |
982 | 982 | return $output; |
983 | 983 | } |
984 | 984 | } |
985 | 985 | |
986 | - $output = executeQuery('document.deleteDocumentExtraVars', $obj); |
|
987 | - if(!$output->toBool()) |
|
986 | + $output = executeQuery('document.deleteDocumentExtraVars', $obj); |
|
987 | + if (!$output->toBool()) |
|
988 | 988 | { |
989 | 989 | $oDB->rollback(); |
990 | 990 | return $output; |
991 | 991 | } |
992 | 992 | |
993 | - if($var_idx != NULL) |
|
993 | + if ($var_idx != NULL) |
|
994 | 994 | { |
995 | 995 | $output = $oDB->executeQuery('document.updateDocumentExtraVarIdxOrder', $obj); |
996 | - if(!$output->toBool()) |
|
996 | + if (!$output->toBool()) |
|
997 | 997 | { |
998 | 998 | $oDB->rollback(); |
999 | 999 | return $output; |
@@ -1003,7 +1003,7 @@ discard block |
||
1003 | 1003 | $oDB->commit(); |
1004 | 1004 | |
1005 | 1005 | $oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE); |
1006 | - if($oCacheHandler->isSupport()) |
|
1006 | + if ($oCacheHandler->isSupport()) |
|
1007 | 1007 | { |
1008 | 1008 | $object_key = 'module_document_extra_keys:'.$module_srl; |
1009 | 1009 | $cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); |
@@ -1025,8 +1025,8 @@ discard block |
||
1025 | 1025 | */ |
1026 | 1026 | function insertDocumentExtraVar($module_srl, $document_srl, $var_idx, $value, $eid = null, $lang_code = '') |
1027 | 1027 | { |
1028 | - if(!$module_srl || !$document_srl || !$var_idx || !isset($value)) return new BaseObject(-1,'msg_invalid_request'); |
|
1029 | - if(!$lang_code) $lang_code = Context::getLangType(); |
|
1028 | + if (!$module_srl || !$document_srl || !$var_idx || !isset($value)) return new BaseObject(-1, 'msg_invalid_request'); |
|
1029 | + if (!$lang_code) $lang_code = Context::getLangType(); |
|
1030 | 1030 | |
1031 | 1031 | $obj = new stdClass; |
1032 | 1032 | $obj->module_srl = $module_srl; |
@@ -1052,10 +1052,10 @@ discard block |
||
1052 | 1052 | { |
1053 | 1053 | $obj = new stdClass(); |
1054 | 1054 | $obj->module_srl = $module_srl; |
1055 | - if(!is_null($document_srl)) $obj->document_srl = $document_srl; |
|
1056 | - if(!is_null($var_idx)) $obj->var_idx = $var_idx; |
|
1057 | - if(!is_null($lang_code)) $obj->lang_code = $lang_code; |
|
1058 | - if(!is_null($eid)) $obj->eid = $eid; |
|
1055 | + if (!is_null($document_srl)) $obj->document_srl = $document_srl; |
|
1056 | + if (!is_null($var_idx)) $obj->var_idx = $var_idx; |
|
1057 | + if (!is_null($lang_code)) $obj->lang_code = $lang_code; |
|
1058 | + if (!is_null($eid)) $obj->eid = $eid; |
|
1059 | 1059 | $output = executeQuery('document.deleteDocumentExtraVars', $obj); |
1060 | 1060 | return $output; |
1061 | 1061 | } |
@@ -1069,10 +1069,10 @@ discard block |
||
1069 | 1069 | */ |
1070 | 1070 | function updateVotedCount($document_srl, $point = 1) |
1071 | 1071 | { |
1072 | - if($point > 0) $failed_voted = 'failed_voted'; |
|
1072 | + if ($point > 0) $failed_voted = 'failed_voted'; |
|
1073 | 1073 | else $failed_voted = 'failed_blamed'; |
1074 | 1074 | // Return fail if session already has information about votes |
1075 | - if($_SESSION['voted_document'][$document_srl]) |
|
1075 | + if ($_SESSION['voted_document'][$document_srl]) |
|
1076 | 1076 | { |
1077 | 1077 | return new BaseObject(-1, $failed_voted); |
1078 | 1078 | } |
@@ -1080,7 +1080,7 @@ discard block |
||
1080 | 1080 | $oDocumentModel = getModel('document'); |
1081 | 1081 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false); |
1082 | 1082 | // Pass if the author's IP address is as same as visitor's. |
1083 | - if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) |
|
1083 | + if ($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) |
|
1084 | 1084 | { |
1085 | 1085 | $_SESSION['voted_document'][$document_srl] = true; |
1086 | 1086 | return new BaseObject(-1, $failed_voted); |
@@ -1091,10 +1091,10 @@ discard block |
||
1091 | 1091 | $member_srl = $oMemberModel->getLoggedMemberSrl(); |
1092 | 1092 | |
1093 | 1093 | // Check if document's author is a member. |
1094 | - if($oDocument->get('member_srl')) |
|
1094 | + if ($oDocument->get('member_srl')) |
|
1095 | 1095 | { |
1096 | 1096 | // Pass after registering a session if author's information is same as the currently logged-in user's. |
1097 | - if($member_srl && $member_srl == abs($oDocument->get('member_srl'))) |
|
1097 | + if ($member_srl && $member_srl == abs($oDocument->get('member_srl'))) |
|
1098 | 1098 | { |
1099 | 1099 | $_SESSION['voted_document'][$document_srl] = true; |
1100 | 1100 | return new BaseObject(-1, $failed_voted); |
@@ -1103,7 +1103,7 @@ discard block |
||
1103 | 1103 | |
1104 | 1104 | // Use member_srl for logged-in members and IP address for non-members. |
1105 | 1105 | $args = new stdClass; |
1106 | - if($member_srl) |
|
1106 | + if ($member_srl) |
|
1107 | 1107 | { |
1108 | 1108 | $args->member_srl = $member_srl; |
1109 | 1109 | } |
@@ -1114,7 +1114,7 @@ discard block |
||
1114 | 1114 | $args->document_srl = $document_srl; |
1115 | 1115 | $output = executeQuery('document.getDocumentVotedLogInfo', $args); |
1116 | 1116 | // Pass after registering a session if log information has vote-up logs |
1117 | - if($output->data->count) |
|
1117 | + if ($output->data->count) |
|
1118 | 1118 | { |
1119 | 1119 | $_SESSION['voted_document'][$document_srl] = true; |
1120 | 1120 | return new BaseObject(-1, $failed_voted); |
@@ -1130,7 +1130,7 @@ discard block |
||
1130 | 1130 | $trigger_obj->before_point = ($point < 0) ? $oDocument->get('blamed_count') : $oDocument->get('voted_count'); |
1131 | 1131 | $trigger_obj->after_point = $trigger_obj->before_point + $point; |
1132 | 1132 | $trigger_output = ModuleHandler::triggerCall('document.updateVotedCount', 'before', $trigger_obj); |
1133 | - if(!$trigger_output->toBool()) |
|
1133 | + if (!$trigger_output->toBool()) |
|
1134 | 1134 | { |
1135 | 1135 | return $trigger_output; |
1136 | 1136 | } |
@@ -1140,7 +1140,7 @@ discard block |
||
1140 | 1140 | $oDB->begin(); |
1141 | 1141 | |
1142 | 1142 | // Update the voted count |
1143 | - if($trigger_obj->update_target === 'blamed_count') |
|
1143 | + if ($trigger_obj->update_target === 'blamed_count') |
|
1144 | 1144 | { |
1145 | 1145 | $args->blamed_count = $trigger_obj->after_point; |
1146 | 1146 | $output = executeQuery('document.updateBlamedCount', $args); |
@@ -1150,16 +1150,16 @@ discard block |
||
1150 | 1150 | $args->voted_count = $trigger_obj->after_point; |
1151 | 1151 | $output = executeQuery('document.updateVotedCount', $args); |
1152 | 1152 | } |
1153 | - if(!$output->toBool()) return $output; |
|
1153 | + if (!$output->toBool()) return $output; |
|
1154 | 1154 | |
1155 | 1155 | // Leave logs |
1156 | 1156 | $args->point = $trigger_obj->point; |
1157 | 1157 | $output = executeQuery('document.insertDocumentVotedLog', $args); |
1158 | - if(!$output->toBool()) return $output; |
|
1158 | + if (!$output->toBool()) return $output; |
|
1159 | 1159 | |
1160 | 1160 | // Call a trigger (after) |
1161 | 1161 | $trigger_output = ModuleHandler::triggerCall('document.updateVotedCount', 'after', $trigger_obj); |
1162 | - if(!$trigger_output->toBool()) |
|
1162 | + if (!$trigger_output->toBool()) |
|
1163 | 1163 | { |
1164 | 1164 | $oDB->rollback(); |
1165 | 1165 | return $trigger_output; |
@@ -1168,10 +1168,10 @@ discard block |
||
1168 | 1168 | $oDB->commit(); |
1169 | 1169 | |
1170 | 1170 | $oCacheHandler = CacheHandler::getInstance('object'); |
1171 | - if($oCacheHandler->isSupport()) |
|
1171 | + if ($oCacheHandler->isSupport()) |
|
1172 | 1172 | { |
1173 | 1173 | //remove document item from cache |
1174 | - $cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl; |
|
1174 | + $cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl; |
|
1175 | 1175 | $oCacheHandler->delete($cache_key); |
1176 | 1176 | } |
1177 | 1177 | |
@@ -1180,7 +1180,7 @@ discard block |
||
1180 | 1180 | |
1181 | 1181 | // Return result |
1182 | 1182 | $output = new BaseObject(); |
1183 | - if($trigger_obj->update_target === 'voted_count') |
|
1183 | + if ($trigger_obj->update_target === 'voted_count') |
|
1184 | 1184 | { |
1185 | 1185 | $output->setMessage('success_voted'); |
1186 | 1186 | $output->add('voted_count', $trigger_obj->after_point); |
@@ -1202,13 +1202,13 @@ discard block |
||
1202 | 1202 | function declaredDocument($document_srl) |
1203 | 1203 | { |
1204 | 1204 | // Fail if session information already has a reported document |
1205 | - if($_SESSION['declared_document'][$document_srl]) return new BaseObject(-1, 'failed_declared'); |
|
1205 | + if ($_SESSION['declared_document'][$document_srl]) return new BaseObject(-1, 'failed_declared'); |
|
1206 | 1206 | |
1207 | 1207 | // Check if previously reported |
1208 | 1208 | $args = new stdClass(); |
1209 | 1209 | $args->document_srl = $document_srl; |
1210 | 1210 | $output = executeQuery('document.getDeclaredDocument', $args); |
1211 | - if(!$output->toBool()) return $output; |
|
1211 | + if (!$output->toBool()) return $output; |
|
1212 | 1212 | |
1213 | 1213 | $declared_count = ($output->data->declared_count) ? $output->data->declared_count : 0; |
1214 | 1214 | |
@@ -1218,7 +1218,7 @@ discard block |
||
1218 | 1218 | |
1219 | 1219 | // Call a trigger (before) |
1220 | 1220 | $trigger_output = ModuleHandler::triggerCall('document.declaredDocument', 'before', $trigger_obj); |
1221 | - if(!$trigger_output->toBool()) |
|
1221 | + if (!$trigger_output->toBool()) |
|
1222 | 1222 | { |
1223 | 1223 | return $trigger_output; |
1224 | 1224 | } |
@@ -1228,19 +1228,19 @@ discard block |
||
1228 | 1228 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false); |
1229 | 1229 | |
1230 | 1230 | // Pass if the author's IP address is as same as visitor's. |
1231 | - if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) { |
|
1231 | + if ($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) { |
|
1232 | 1232 | $_SESSION['declared_document'][$document_srl] = true; |
1233 | 1233 | return new BaseObject(-1, 'failed_declared'); |
1234 | 1234 | } |
1235 | 1235 | |
1236 | 1236 | // Check if document's author is a member. |
1237 | - if($oDocument->get('member_srl')) |
|
1237 | + if ($oDocument->get('member_srl')) |
|
1238 | 1238 | { |
1239 | 1239 | // Create a member model object |
1240 | 1240 | $oMemberModel = getModel('member'); |
1241 | 1241 | $member_srl = $oMemberModel->getLoggedMemberSrl(); |
1242 | 1242 | // Pass after registering a session if author's information is same as the currently logged-in user's. |
1243 | - if($member_srl && $member_srl == abs($oDocument->get('member_srl'))) |
|
1243 | + if ($member_srl && $member_srl == abs($oDocument->get('member_srl'))) |
|
1244 | 1244 | { |
1245 | 1245 | $_SESSION['declared_document'][$document_srl] = true; |
1246 | 1246 | return new BaseObject(-1, 'failed_declared'); |
@@ -1249,7 +1249,7 @@ discard block |
||
1249 | 1249 | |
1250 | 1250 | // Use member_srl for logged-in members and IP address for non-members. |
1251 | 1251 | $args = new stdClass; |
1252 | - if($member_srl) |
|
1252 | + if ($member_srl) |
|
1253 | 1253 | { |
1254 | 1254 | $args->member_srl = $member_srl; |
1255 | 1255 | } |
@@ -1262,7 +1262,7 @@ discard block |
||
1262 | 1262 | $output = executeQuery('document.getDocumentDeclaredLogInfo', $args); |
1263 | 1263 | |
1264 | 1264 | // Pass after registering a sesson if reported/declared documents are in the logs. |
1265 | - if($output->data->count) |
|
1265 | + if ($output->data->count) |
|
1266 | 1266 | { |
1267 | 1267 | $_SESSION['declared_document'][$document_srl] = true; |
1268 | 1268 | return new BaseObject(-1, 'failed_declared'); |
@@ -1273,23 +1273,23 @@ discard block |
||
1273 | 1273 | $oDB->begin(); |
1274 | 1274 | |
1275 | 1275 | // Add the declared document |
1276 | - if($declared_count > 0) $output = executeQuery('document.updateDeclaredDocument', $args); |
|
1276 | + if ($declared_count > 0) $output = executeQuery('document.updateDeclaredDocument', $args); |
|
1277 | 1277 | else $output = executeQuery('document.insertDeclaredDocument', $args); |
1278 | - if(!$output->toBool()) return $output; |
|
1278 | + if (!$output->toBool()) return $output; |
|
1279 | 1279 | // Leave logs |
1280 | 1280 | $output = executeQuery('document.insertDocumentDeclaredLog', $args); |
1281 | - if(!$output->toBool()) |
|
1281 | + if (!$output->toBool()) |
|
1282 | 1282 | { |
1283 | 1283 | $oDB->rollback(); |
1284 | 1284 | return $output; |
1285 | 1285 | } |
1286 | 1286 | |
1287 | - $this->add('declared_count', $declared_count+1); |
|
1287 | + $this->add('declared_count', $declared_count + 1); |
|
1288 | 1288 | |
1289 | 1289 | // Call a trigger (after) |
1290 | 1290 | $trigger_obj->declared_count = $declared_count + 1; |
1291 | 1291 | $trigger_output = ModuleHandler::triggerCall('document.declaredDocument', 'after', $trigger_obj); |
1292 | - if(!$trigger_output->toBool()) |
|
1292 | + if (!$trigger_output->toBool()) |
|
1293 | 1293 | { |
1294 | 1294 | $oDB->rollback(); |
1295 | 1295 | return $trigger_output; |
@@ -1319,16 +1319,16 @@ discard block |
||
1319 | 1319 | $args->document_srl = $document_srl; |
1320 | 1320 | $args->comment_count = $comment_count; |
1321 | 1321 | |
1322 | - if($comment_inserted) |
|
1322 | + if ($comment_inserted) |
|
1323 | 1323 | { |
1324 | - $args->update_order = -1*getNextSequence(); |
|
1324 | + $args->update_order = -1 * getNextSequence(); |
|
1325 | 1325 | $args->last_updater = $last_updater; |
1326 | 1326 | |
1327 | 1327 | $oCacheHandler = CacheHandler::getInstance('object'); |
1328 | - if($oCacheHandler->isSupport()) |
|
1328 | + if ($oCacheHandler->isSupport()) |
|
1329 | 1329 | { |
1330 | 1330 | //remove document item from cache |
1331 | - $cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl; |
|
1331 | + $cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl; |
|
1332 | 1332 | $oCacheHandler->delete($cache_key); |
1333 | 1333 | } |
1334 | 1334 | } |
@@ -1349,10 +1349,10 @@ discard block |
||
1349 | 1349 | $args->trackback_count = $trackback_count; |
1350 | 1350 | |
1351 | 1351 | $oCacheHandler = CacheHandler::getInstance('object'); |
1352 | - if($oCacheHandler->isSupport()) |
|
1352 | + if ($oCacheHandler->isSupport()) |
|
1353 | 1353 | { |
1354 | 1354 | //remove document item from cache |
1355 | - $cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl; |
|
1355 | + $cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl; |
|
1356 | 1356 | $oCacheHandler->delete($cache_key); |
1357 | 1357 | } |
1358 | 1358 | |
@@ -1367,14 +1367,14 @@ discard block |
||
1367 | 1367 | function insertCategory($obj) |
1368 | 1368 | { |
1369 | 1369 | // Sort the order to display if a child category is added |
1370 | - if($obj->parent_srl) |
|
1370 | + if ($obj->parent_srl) |
|
1371 | 1371 | { |
1372 | 1372 | // Get its parent category |
1373 | 1373 | $oDocumentModel = getModel('document'); |
1374 | 1374 | $parent_category = $oDocumentModel->getCategory($obj->parent_srl); |
1375 | 1375 | $obj->list_order = $parent_category->list_order; |
1376 | - $this->updateCategoryListOrder($parent_category->module_srl, $parent_category->list_order+1); |
|
1377 | - if(!$obj->category_srl) $obj->category_srl = getNextSequence(); |
|
1376 | + $this->updateCategoryListOrder($parent_category->module_srl, $parent_category->list_order + 1); |
|
1377 | + if (!$obj->category_srl) $obj->category_srl = getNextSequence(); |
|
1378 | 1378 | } |
1379 | 1379 | else |
1380 | 1380 | { |
@@ -1382,7 +1382,7 @@ discard block |
||
1382 | 1382 | } |
1383 | 1383 | |
1384 | 1384 | $output = executeQuery('document.insertCategory', $obj); |
1385 | - if($output->toBool()) |
|
1385 | + if ($output->toBool()) |
|
1386 | 1386 | { |
1387 | 1387 | $output->add('category_srl', $obj->category_srl); |
1388 | 1388 | $this->makeCategoryFile($obj->module_srl); |
@@ -1416,13 +1416,13 @@ discard block |
||
1416 | 1416 | { |
1417 | 1417 | // Create a document model object |
1418 | 1418 | $oDocumentModel = getModel('document'); |
1419 | - if(!$document_count) $document_count = $oDocumentModel->getCategoryDocumentCount($module_srl,$category_srl); |
|
1419 | + if (!$document_count) $document_count = $oDocumentModel->getCategoryDocumentCount($module_srl, $category_srl); |
|
1420 | 1420 | |
1421 | 1421 | $args = new stdClass; |
1422 | 1422 | $args->category_srl = $category_srl; |
1423 | 1423 | $args->document_count = $document_count; |
1424 | 1424 | $output = executeQuery('document.updateCategoryCount', $args); |
1425 | - if($output->toBool()) $this->makeCategoryFile($module_srl); |
|
1425 | + if ($output->toBool()) $this->makeCategoryFile($module_srl); |
|
1426 | 1426 | |
1427 | 1427 | return $output; |
1428 | 1428 | } |
@@ -1435,7 +1435,7 @@ discard block |
||
1435 | 1435 | function updateCategory($obj) |
1436 | 1436 | { |
1437 | 1437 | $output = executeQuery('document.updateCategory', $obj); |
1438 | - if($output->toBool()) $this->makeCategoryFile($obj->module_srl); |
|
1438 | + if ($output->toBool()) $this->makeCategoryFile($obj->module_srl); |
|
1439 | 1439 | return $output; |
1440 | 1440 | } |
1441 | 1441 | |
@@ -1452,32 +1452,32 @@ discard block |
||
1452 | 1452 | $category_info = $oDocumentModel->getCategory($category_srl); |
1453 | 1453 | // Display an error that the category cannot be deleted if it has a child |
1454 | 1454 | $output = executeQuery('document.getChildCategoryCount', $args); |
1455 | - if(!$output->toBool()) return $output; |
|
1456 | - if($output->data->count>0) return new BaseObject(-1, 'msg_cannot_delete_for_child'); |
|
1455 | + if (!$output->toBool()) return $output; |
|
1456 | + if ($output->data->count > 0) return new BaseObject(-1, 'msg_cannot_delete_for_child'); |
|
1457 | 1457 | // Delete a category information |
1458 | 1458 | $output = executeQuery('document.deleteCategory', $args); |
1459 | - if(!$output->toBool()) return $output; |
|
1459 | + if (!$output->toBool()) return $output; |
|
1460 | 1460 | |
1461 | 1461 | $this->makeCategoryFile($category_info->module_srl); |
1462 | 1462 | // remvove cache |
1463 | 1463 | $oCacheHandler = CacheHandler::getInstance('object'); |
1464 | - if($oCacheHandler->isSupport()) |
|
1464 | + if ($oCacheHandler->isSupport()) |
|
1465 | 1465 | { |
1466 | 1466 | $page = 0; |
1467 | - while(true) { |
|
1467 | + while (true) { |
|
1468 | 1468 | $args = new stdClass(); |
1469 | 1469 | $args->category_srl = $category_srl; |
1470 | 1470 | $args->list_count = 100; |
1471 | 1471 | $args->page = ++$page; |
1472 | 1472 | $output = executeQuery('document.getDocumentList', $args, array('document_srl')); |
1473 | 1473 | |
1474 | - if($output->data == array()) |
|
1474 | + if ($output->data == array()) |
|
1475 | 1475 | break; |
1476 | 1476 | |
1477 | - foreach($output->data as $val) |
|
1477 | + foreach ($output->data as $val) |
|
1478 | 1478 | { |
1479 | 1479 | //remove document item from cache |
1480 | - $cache_key = 'document_item:'. getNumberingPath($val->document_srl) . $val->document_srl; |
|
1480 | + $cache_key = 'document_item:'.getNumberingPath($val->document_srl).$val->document_srl; |
|
1481 | 1481 | $oCacheHandler->delete($cache_key); |
1482 | 1482 | } |
1483 | 1483 | } |
@@ -1524,18 +1524,18 @@ discard block |
||
1524 | 1524 | // Seek a full list of categories |
1525 | 1525 | $category_list = $oDocumentModel->getCategoryList($module_srl); |
1526 | 1526 | $category_srl_list = array_keys($category_list); |
1527 | - if(count($category_srl_list)<2) return new BaseObject(); |
|
1527 | + if (count($category_srl_list) < 2) return new BaseObject(); |
|
1528 | 1528 | |
1529 | 1529 | $prev_category = NULL; |
1530 | - foreach($category_list as $key => $val) |
|
1530 | + foreach ($category_list as $key => $val) |
|
1531 | 1531 | { |
1532 | - if($key==$category_srl) break; |
|
1532 | + if ($key == $category_srl) break; |
|
1533 | 1533 | $prev_category = $val; |
1534 | 1534 | } |
1535 | 1535 | // Return if the previous category doesn't exist |
1536 | - if(!$prev_category) return new BaseObject(-1,Context::getLang('msg_category_not_moved')); |
|
1536 | + if (!$prev_category) return new BaseObject(-1, Context::getLang('msg_category_not_moved')); |
|
1537 | 1537 | // Return if the selected category is the top level |
1538 | - if($category_srl_list[0]==$category_srl) return new BaseObject(-1,Context::getLang('msg_category_not_moved')); |
|
1538 | + if ($category_srl_list[0] == $category_srl) return new BaseObject(-1, Context::getLang('msg_category_not_moved')); |
|
1539 | 1539 | // Information of the selected category |
1540 | 1540 | $cur_args = new stdClass; |
1541 | 1541 | $cur_args->category_srl = $category_srl; |
@@ -1571,15 +1571,15 @@ discard block |
||
1571 | 1571 | // Seek a full list of categories |
1572 | 1572 | $category_list = $oDocumentModel->getCategoryList($module_srl); |
1573 | 1573 | $category_srl_list = array_keys($category_list); |
1574 | - if(count($category_srl_list)<2) return new BaseObject(); |
|
1574 | + if (count($category_srl_list) < 2) return new BaseObject(); |
|
1575 | 1575 | |
1576 | - for($i=0;$i<count($category_srl_list);$i++) |
|
1576 | + for ($i = 0; $i < count($category_srl_list); $i++) |
|
1577 | 1577 | { |
1578 | - if($category_srl_list[$i]==$category_srl) break; |
|
1578 | + if ($category_srl_list[$i] == $category_srl) break; |
|
1579 | 1579 | } |
1580 | 1580 | |
1581 | - $next_category_srl = $category_srl_list[$i+1]; |
|
1582 | - if(!$category_list[$next_category_srl]) return new BaseObject(-1,Context::getLang('msg_category_not_moved')); |
|
1581 | + $next_category_srl = $category_srl_list[$i + 1]; |
|
1582 | + if (!$category_list[$next_category_srl]) return new BaseObject(-1, Context::getLang('msg_category_not_moved')); |
|
1583 | 1583 | $next_category = $category_list[$next_category_srl]; |
1584 | 1584 | // Information of the selected category |
1585 | 1585 | $cur_args = new stdClass; |
@@ -1606,7 +1606,7 @@ discard block |
||
1606 | 1606 | { |
1607 | 1607 | $oDocumentModel = getModel('document'); |
1608 | 1608 | $extra_keys = $oDocumentModel->getExtraKeys($module_srl); |
1609 | - if(!count($extra_keys)) return; |
|
1609 | + if (!count($extra_keys)) return; |
|
1610 | 1610 | |
1611 | 1611 | $js_code = array(); |
1612 | 1612 | $js_code[] = '<script>//<![CDATA['; |
@@ -1616,16 +1616,16 @@ discard block |
||
1616 | 1616 | |
1617 | 1617 | $logged_info = Context::get('logged_info'); |
1618 | 1618 | |
1619 | - foreach($extra_keys as $idx => $val) |
|
1619 | + foreach ($extra_keys as $idx => $val) |
|
1620 | 1620 | { |
1621 | 1621 | $idx = $val->idx; |
1622 | - if($val->type == 'kr_zip') |
|
1622 | + if ($val->type == 'kr_zip') |
|
1623 | 1623 | { |
1624 | 1624 | $idx .= '[]'; |
1625 | 1625 | } |
1626 | 1626 | $name = str_ireplace(array('<script', '</script'), array('<scr" + "ipt', '</scr" + "ipt'), $val->name); |
1627 | 1627 | $js_code[] = sprintf('validator.cast("ADD_MESSAGE", ["extra_vars%s","%s"]);', $idx, $name); |
1628 | - if($val->is_required == 'Y') $js_code[] = sprintf('validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx); |
|
1628 | + if ($val->is_required == 'Y') $js_code[] = sprintf('validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx); |
|
1629 | 1629 | } |
1630 | 1630 | |
1631 | 1631 | $js_code[] = '})(jQuery);'; |
@@ -1643,12 +1643,12 @@ discard block |
||
1643 | 1643 | function procDocumentInsertCategory($args = null) |
1644 | 1644 | { |
1645 | 1645 | // List variables |
1646 | - if(!$args) $args = Context::gets('module_srl','category_srl','parent_srl','category_title','category_description','expand','group_srls','category_color','mid'); |
|
1646 | + if (!$args) $args = Context::gets('module_srl', 'category_srl', 'parent_srl', 'category_title', 'category_description', 'expand', 'group_srls', 'category_color', 'mid'); |
|
1647 | 1647 | $args->title = $args->category_title; |
1648 | 1648 | $args->description = $args->category_description; |
1649 | 1649 | $args->color = $args->category_color; |
1650 | 1650 | |
1651 | - if(!$args->module_srl && $args->mid) |
|
1651 | + if (!$args->module_srl && $args->mid) |
|
1652 | 1652 | { |
1653 | 1653 | $mid = $args->mid; |
1654 | 1654 | unset($args->mid); |
@@ -1659,28 +1659,28 @@ discard block |
||
1659 | 1659 | $columnList = array('module_srl', 'module'); |
1660 | 1660 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList); |
1661 | 1661 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
1662 | - if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted'); |
|
1662 | + if (!$grant->manager) return new BaseObject(-1, 'msg_not_permitted'); |
|
1663 | 1663 | |
1664 | - if($args->expand !="Y") $args->expand = "N"; |
|
1665 | - if(!is_array($args->group_srls)) $args->group_srls = str_replace('|@|',',',$args->group_srls); |
|
1664 | + if ($args->expand != "Y") $args->expand = "N"; |
|
1665 | + if (!is_array($args->group_srls)) $args->group_srls = str_replace('|@|', ',', $args->group_srls); |
|
1666 | 1666 | else $args->group_srls = implode(',', $args->group_srls); |
1667 | - $args->parent_srl = (int)$args->parent_srl; |
|
1667 | + $args->parent_srl = (int) $args->parent_srl; |
|
1668 | 1668 | |
1669 | 1669 | $oDocumentModel = getModel('document'); |
1670 | 1670 | |
1671 | 1671 | $oDB = &DB::getInstance(); |
1672 | 1672 | $oDB->begin(); |
1673 | 1673 | // Check if already exists |
1674 | - if($args->category_srl) |
|
1674 | + if ($args->category_srl) |
|
1675 | 1675 | { |
1676 | 1676 | $category_info = $oDocumentModel->getCategory($args->category_srl); |
1677 | - if($category_info->category_srl != $args->category_srl) $args->category_srl = null; |
|
1677 | + if ($category_info->category_srl != $args->category_srl) $args->category_srl = null; |
|
1678 | 1678 | } |
1679 | 1679 | // Update if exists |
1680 | - if($args->category_srl) |
|
1680 | + if ($args->category_srl) |
|
1681 | 1681 | { |
1682 | 1682 | $output = $this->updateCategory($args); |
1683 | - if(!$output->toBool()) |
|
1683 | + if (!$output->toBool()) |
|
1684 | 1684 | { |
1685 | 1685 | $oDB->rollback(); |
1686 | 1686 | return $output; |
@@ -1690,7 +1690,7 @@ discard block |
||
1690 | 1690 | else |
1691 | 1691 | { |
1692 | 1692 | $output = $this->insertCategory($args); |
1693 | - if(!$output->toBool()) |
|
1693 | + if (!$output->toBool()) |
|
1694 | 1694 | { |
1695 | 1695 | $oDB->rollback(); |
1696 | 1696 | return $output; |
@@ -1729,11 +1729,11 @@ discard block |
||
1729 | 1729 | $columnList = array('module_srl', 'module'); |
1730 | 1730 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($source_category->module_srl, $columnList); |
1731 | 1731 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
1732 | - if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted'); |
|
1732 | + if (!$grant->manager) return new BaseObject(-1, 'msg_not_permitted'); |
|
1733 | 1733 | |
1734 | 1734 | // First child of the parent_category_srl |
1735 | 1735 | $source_args = new stdClass; |
1736 | - if($parent_category_srl > 0 || ($parent_category_srl == 0 && $target_category_srl == 0)) |
|
1736 | + if ($parent_category_srl > 0 || ($parent_category_srl == 0 && $target_category_srl == 0)) |
|
1737 | 1737 | { |
1738 | 1738 | $parent_category = $oDocumentModel->getCategory($parent_category_srl); |
1739 | 1739 | |
@@ -1742,30 +1742,30 @@ discard block |
||
1742 | 1742 | $args->parent_srl = $parent_category_srl; |
1743 | 1743 | $output = executeQuery('document.getChildCategoryMinListOrder', $args); |
1744 | 1744 | |
1745 | - if(!$output->toBool()) return $output; |
|
1746 | - $args->list_order = (int)$output->data->list_order; |
|
1747 | - if(!$args->list_order) $args->list_order = 0; |
|
1745 | + if (!$output->toBool()) return $output; |
|
1746 | + $args->list_order = (int) $output->data->list_order; |
|
1747 | + if (!$args->list_order) $args->list_order = 0; |
|
1748 | 1748 | $args->list_order--; |
1749 | 1749 | |
1750 | 1750 | $source_args->category_srl = $source_category_srl; |
1751 | 1751 | $source_args->parent_srl = $parent_category_srl; |
1752 | 1752 | $source_args->list_order = $args->list_order; |
1753 | 1753 | $output = $this->updateCategory($source_args); |
1754 | - if(!$output->toBool()) return $output; |
|
1754 | + if (!$output->toBool()) return $output; |
|
1755 | 1755 | // Sibling of the $target_category_srl |
1756 | 1756 | } |
1757 | - else if($target_category_srl > 0) |
|
1757 | + else if ($target_category_srl > 0) |
|
1758 | 1758 | { |
1759 | 1759 | $target_category = $oDocumentModel->getCategory($target_category_srl); |
1760 | 1760 | // Move all siblings of the $target_category down |
1761 | - $output = $this->updateCategoryListOrder($target_category->module_srl, $target_category->list_order+1); |
|
1762 | - if(!$output->toBool()) return $output; |
|
1761 | + $output = $this->updateCategoryListOrder($target_category->module_srl, $target_category->list_order + 1); |
|
1762 | + if (!$output->toBool()) return $output; |
|
1763 | 1763 | |
1764 | 1764 | $source_args->category_srl = $source_category_srl; |
1765 | 1765 | $source_args->parent_srl = $target_category->parent_srl; |
1766 | - $source_args->list_order = $target_category->list_order+1; |
|
1766 | + $source_args->list_order = $target_category->list_order + 1; |
|
1767 | 1767 | $output = $this->updateCategory($source_args); |
1768 | - if(!$output->toBool()) return $output; |
|
1768 | + if (!$output->toBool()) return $output; |
|
1769 | 1769 | } |
1770 | 1770 | // Re-generate the xml file |
1771 | 1771 | $xml_file = $this->makeCategoryFile($source_category->module_srl); |
@@ -1781,7 +1781,7 @@ discard block |
||
1781 | 1781 | function procDocumentDeleteCategory() |
1782 | 1782 | { |
1783 | 1783 | // List variables |
1784 | - $args = Context::gets('module_srl','category_srl'); |
|
1784 | + $args = Context::gets('module_srl', 'category_srl'); |
|
1785 | 1785 | |
1786 | 1786 | $oDB = &DB::getInstance(); |
1787 | 1787 | $oDB->begin(); |
@@ -1790,17 +1790,17 @@ discard block |
||
1790 | 1790 | $columnList = array('module_srl', 'module'); |
1791 | 1791 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList); |
1792 | 1792 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
1793 | - if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted'); |
|
1793 | + if (!$grant->manager) return new BaseObject(-1, 'msg_not_permitted'); |
|
1794 | 1794 | |
1795 | 1795 | $oDocumentModel = getModel('document'); |
1796 | 1796 | // Get original information |
1797 | 1797 | $category_info = $oDocumentModel->getCategory($args->category_srl); |
1798 | - if($category_info->parent_srl) $parent_srl = $category_info->parent_srl; |
|
1798 | + if ($category_info->parent_srl) $parent_srl = $category_info->parent_srl; |
|
1799 | 1799 | // Display an error that the category cannot be deleted if it has a child node |
1800 | - if($oDocumentModel->getCategoryChlidCount($args->category_srl)) return new BaseObject(-1, 'msg_cannot_delete_for_child'); |
|
1800 | + if ($oDocumentModel->getCategoryChlidCount($args->category_srl)) return new BaseObject(-1, 'msg_cannot_delete_for_child'); |
|
1801 | 1801 | // Remove from the DB |
1802 | 1802 | $output = $this->deleteCategory($args->category_srl); |
1803 | - if(!$output->toBool()) |
|
1803 | + if (!$output->toBool()) |
|
1804 | 1804 | { |
1805 | 1805 | $oDB->rollback(); |
1806 | 1806 | return $output; |
@@ -1831,11 +1831,11 @@ discard block |
||
1831 | 1831 | $columnList = array('module_srl', 'module'); |
1832 | 1832 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList); |
1833 | 1833 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
1834 | - if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted'); |
|
1834 | + if (!$grant->manager) return new BaseObject(-1, 'msg_not_permitted'); |
|
1835 | 1835 | |
1836 | 1836 | $xml_file = $this->makeCategoryFile($module_srl); |
1837 | 1837 | // Set return value |
1838 | - $this->add('xml_file',$xml_file); |
|
1838 | + $this->add('xml_file', $xml_file); |
|
1839 | 1839 | } |
1840 | 1840 | |
1841 | 1841 | /** |
@@ -1846,9 +1846,9 @@ discard block |
||
1846 | 1846 | function makeCategoryFile($module_srl) |
1847 | 1847 | { |
1848 | 1848 | // Return if there is no information you need for creating a cache file |
1849 | - if(!$module_srl) return false; |
|
1849 | + if (!$module_srl) return false; |
|
1850 | 1850 | |
1851 | - $module_srl = (int)$module_srl; |
|
1851 | + $module_srl = (int) $module_srl; |
|
1852 | 1852 | |
1853 | 1853 | // Get module information (to obtain mid) |
1854 | 1854 | $oModuleModel = getModel('module'); |
@@ -1856,7 +1856,7 @@ discard block |
||
1856 | 1856 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList); |
1857 | 1857 | $mid = $module_info->mid; |
1858 | 1858 | |
1859 | - if(!is_dir('./files/cache/document_category')) FileHandler::makeDir('./files/cache/document_category'); |
|
1859 | + if (!is_dir('./files/cache/document_category')) FileHandler::makeDir('./files/cache/document_category'); |
|
1860 | 1860 | // Cache file's name |
1861 | 1861 | $xml_file = sprintf("./files/cache/document_category/%s.xml.php", $module_srl); |
1862 | 1862 | $php_file = sprintf("./files/cache/document_category/%s.php", $module_srl); |
@@ -1868,17 +1868,17 @@ discard block |
||
1868 | 1868 | |
1869 | 1869 | $category_list = $output->data; |
1870 | 1870 | |
1871 | - if(!is_array($category_list)) $category_list = array($category_list); |
|
1871 | + if (!is_array($category_list)) $category_list = array($category_list); |
|
1872 | 1872 | |
1873 | 1873 | $category_count = count($category_list); |
1874 | - for($i=0;$i<$category_count;$i++) |
|
1874 | + for ($i = 0; $i < $category_count; $i++) |
|
1875 | 1875 | { |
1876 | 1876 | $category_srl = $category_list[$i]->category_srl; |
1877 | - if(!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) $category_list[$i]->group_srls = ''; |
|
1877 | + if (!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) $category_list[$i]->group_srls = ''; |
|
1878 | 1878 | $list[$category_srl] = $category_list[$i]; |
1879 | 1879 | } |
1880 | 1880 | // Create the xml file without node data if no data is obtained |
1881 | - if(!$list) |
|
1881 | + if (!$list) |
|
1882 | 1882 | { |
1883 | 1883 | $xml_buff = "<root />"; |
1884 | 1884 | FileHandler::writeFile($xml_file, $xml_buff); |
@@ -1886,12 +1886,12 @@ discard block |
||
1886 | 1886 | return $xml_file; |
1887 | 1887 | } |
1888 | 1888 | // Change to an array if only a single data is obtained |
1889 | - if(!is_array($list)) $list = array($list); |
|
1889 | + if (!is_array($list)) $list = array($list); |
|
1890 | 1890 | // Create a tree for loop |
1891 | - foreach($list as $category_srl => $node) |
|
1891 | + foreach ($list as $category_srl => $node) |
|
1892 | 1892 | { |
1893 | 1893 | $node->mid = $mid; |
1894 | - $parent_srl = (int)$node->parent_srl; |
|
1894 | + $parent_srl = (int) $node->parent_srl; |
|
1895 | 1895 | $tree[$parent_srl][$category_srl] = $node; |
1896 | 1896 | } |
1897 | 1897 | // A common header to set permissions and groups of the cache file |
@@ -1965,13 +1965,13 @@ discard block |
||
1965 | 1965 | */ |
1966 | 1966 | function getXmlTree($source_node, $tree, $site_srl, &$xml_header_buff) |
1967 | 1967 | { |
1968 | - if(!$source_node) return; |
|
1968 | + if (!$source_node) return; |
|
1969 | 1969 | |
1970 | - foreach($source_node as $category_srl => $node) |
|
1970 | + foreach ($source_node as $category_srl => $node) |
|
1971 | 1971 | { |
1972 | 1972 | $child_buff = ""; |
1973 | 1973 | // Get data of the child nodes |
1974 | - if($category_srl && $tree[$category_srl]) $child_buff = $this->getXmlTree($tree[$category_srl], $tree, $site_srl, $xml_header_buff); |
|
1974 | + if ($category_srl && $tree[$category_srl]) $child_buff = $this->getXmlTree($tree[$category_srl], $tree, $site_srl, $xml_header_buff); |
|
1975 | 1975 | // List variables |
1976 | 1976 | $expand = ($node->expand) ? $node->expand : 'N'; |
1977 | 1977 | $group_srls = ($node->group_srls) ? $node->group_srls : ''; |
@@ -1981,27 +1981,27 @@ discard block |
||
1981 | 1981 | $color = ($node->color) ? $node->color : ''; |
1982 | 1982 | $description = ($node->description) ? $node->description : ''; |
1983 | 1983 | // If node->group_srls value exists |
1984 | - if($group_srls) $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$group_srls); |
|
1984 | + if ($group_srls) $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))', $group_srls); |
|
1985 | 1985 | else $group_check_code = "true"; |
1986 | 1986 | |
1987 | 1987 | $title = $node->title; |
1988 | 1988 | $oModuleAdminModel = getAdminModel('module'); |
1989 | 1989 | |
1990 | 1990 | $langs = $oModuleAdminModel->getLangCode($site_srl, $title); |
1991 | - if(count($langs)) |
|
1991 | + if (count($langs)) |
|
1992 | 1992 | { |
1993 | - foreach($langs as $key => $val) |
|
1993 | + foreach ($langs as $key => $val) |
|
1994 | 1994 | { |
1995 | - $xml_header_buff .= sprintf('$_titles[%d]["%s"] = %s; ', $category_srl, $key, var_export(str_replace('"','\\"',htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)), true)); |
|
1995 | + $xml_header_buff .= sprintf('$_titles[%d]["%s"] = %s; ', $category_srl, $key, var_export(str_replace('"', '\\"', htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)), true)); |
|
1996 | 1996 | } |
1997 | 1997 | } |
1998 | 1998 | |
1999 | 1999 | $langx = $oModuleAdminModel->getLangCode($site_srl, $description); |
2000 | - if(count($langx)) |
|
2000 | + if (count($langx)) |
|
2001 | 2001 | { |
2002 | - foreach($langx as $key => $val) |
|
2002 | + foreach ($langx as $key => $val) |
|
2003 | 2003 | { |
2004 | - $xml_header_buff .= sprintf('$_descriptions[%d]["%s"] = %s; ', $category_srl, $key, var_export(str_replace('"','\\"',htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)), true)); |
|
2004 | + $xml_header_buff .= sprintf('$_descriptions[%d]["%s"] = %s; ', $category_srl, $key, var_export(str_replace('"', '\\"', htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)), true)); |
|
2005 | 2005 | } |
2006 | 2006 | } |
2007 | 2007 | |
@@ -2014,7 +2014,7 @@ discard block |
||
2014 | 2014 | $category_srl, |
2015 | 2015 | $group_check_code, |
2016 | 2016 | $category_srl, |
2017 | - var_export(getUrl('','mid',$node->mid,'category',$category_srl), true), |
|
2017 | + var_export(getUrl('', 'mid', $node->mid, 'category', $category_srl), true), |
|
2018 | 2018 | var_export($expand, true), |
2019 | 2019 | var_export($color, true), |
2020 | 2020 | $group_check_code, |
@@ -2022,8 +2022,8 @@ discard block |
||
2022 | 2022 | $node->document_count |
2023 | 2023 | ); |
2024 | 2024 | |
2025 | - if($child_buff) $buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff); |
|
2026 | - else $buff .= sprintf('<node %s />', $attribute); |
|
2025 | + if ($child_buff) $buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff); |
|
2026 | + else $buff .= sprintf('<node %s />', $attribute); |
|
2027 | 2027 | } |
2028 | 2028 | return $buff; |
2029 | 2029 | } |
@@ -2042,13 +2042,13 @@ discard block |
||
2042 | 2042 | function getPhpCacheCode($source_node, $tree, $site_srl, &$php_header_buff) |
2043 | 2043 | { |
2044 | 2044 | $output = array("buff"=>"", "category_srl_list"=>array()); |
2045 | - if(!$source_node) return $output; |
|
2045 | + if (!$source_node) return $output; |
|
2046 | 2046 | |
2047 | 2047 | // Set to an arraty for looping and then generate php script codes to be included |
2048 | - foreach($source_node as $category_srl => $node) |
|
2048 | + foreach ($source_node as $category_srl => $node) |
|
2049 | 2049 | { |
2050 | 2050 | // Get data from child nodes first if exist. |
2051 | - if($category_srl && $tree[$category_srl]){ |
|
2051 | + if ($category_srl && $tree[$category_srl]) { |
|
2052 | 2052 | $child_output = $this->getPhpCacheCode($tree[$category_srl], $tree, $site_srl, $php_header_buff); |
2053 | 2053 | } else { |
2054 | 2054 | $child_output = array("buff"=>"", "category_srl_list"=>array()); |
@@ -2059,14 +2059,14 @@ discard block |
||
2059 | 2059 | $output['category_srl_list'] = array_merge($output['category_srl_list'], $child_output['category_srl_list']); |
2060 | 2060 | |
2061 | 2061 | // If node->group_srls value exists |
2062 | - if($node->group_srls) { |
|
2063 | - $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$node->group_srls); |
|
2062 | + if ($node->group_srls) { |
|
2063 | + $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))', $node->group_srls); |
|
2064 | 2064 | } else { |
2065 | 2065 | $group_check_code = "true"; |
2066 | 2066 | } |
2067 | 2067 | |
2068 | 2068 | // List variables |
2069 | - $selected = '"' . implode('","', $child_output['category_srl_list']) . '"'; |
|
2069 | + $selected = '"'.implode('","', $child_output['category_srl_list']).'"'; |
|
2070 | 2070 | $child_buff = $child_output['buff']; |
2071 | 2071 | $expand = $node->expand; |
2072 | 2072 | |
@@ -2075,32 +2075,32 @@ discard block |
||
2075 | 2075 | $oModuleAdminModel = getAdminModel('module'); |
2076 | 2076 | $langs = $oModuleAdminModel->getLangCode($site_srl, $title); |
2077 | 2077 | |
2078 | - if(count($langs)) |
|
2078 | + if (count($langs)) |
|
2079 | 2079 | { |
2080 | - foreach($langs as $key => $val) |
|
2080 | + foreach ($langs as $key => $val) |
|
2081 | 2081 | { |
2082 | 2082 | $val = htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
2083 | 2083 | $php_header_buff .= sprintf( |
2084 | 2084 | '$_titles[%d]["%s"] = %s; ', |
2085 | 2085 | $category_srl, |
2086 | 2086 | $key, |
2087 | - var_export(str_replace('"','\\"', $val), true) |
|
2087 | + var_export(str_replace('"', '\\"', $val), true) |
|
2088 | 2088 | ); |
2089 | 2089 | } |
2090 | 2090 | } |
2091 | 2091 | |
2092 | 2092 | $langx = $oModuleAdminModel->getLangCode($site_srl, $description); |
2093 | 2093 | |
2094 | - if(count($langx)) |
|
2094 | + if (count($langx)) |
|
2095 | 2095 | { |
2096 | - foreach($langx as $key => $val) |
|
2096 | + foreach ($langx as $key => $val) |
|
2097 | 2097 | { |
2098 | 2098 | $val = htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
2099 | 2099 | $php_header_buff .= sprintf( |
2100 | 2100 | '$_descriptions[%d]["%s"] = %s; ', |
2101 | 2101 | $category_srl, |
2102 | 2102 | $key, |
2103 | - var_export(str_replace('"','\\"', $val), true) |
|
2103 | + var_export(str_replace('"', '\\"', $val), true) |
|
2104 | 2104 | ); |
2105 | 2105 | } |
2106 | 2106 | } |
@@ -2124,7 +2124,7 @@ discard block |
||
2124 | 2124 | ); |
2125 | 2125 | |
2126 | 2126 | // Generate buff data |
2127 | - $output['buff'] .= sprintf('%s=>array(%s),', $node->category_srl, $attribute); |
|
2127 | + $output['buff'] .= sprintf('%s=>array(%s),', $node->category_srl, $attribute); |
|
2128 | 2128 | } |
2129 | 2129 | |
2130 | 2130 | return $output; |
@@ -2141,7 +2141,7 @@ discard block |
||
2141 | 2141 | function addDocumentPopupMenu($url, $str, $icon = '', $target = 'self') |
2142 | 2142 | { |
2143 | 2143 | $document_popup_menu_list = Context::get('document_popup_menu_list'); |
2144 | - if(!is_array($document_popup_menu_list)) $document_popup_menu_list = array(); |
|
2144 | + if (!is_array($document_popup_menu_list)) $document_popup_menu_list = array(); |
|
2145 | 2145 | |
2146 | 2146 | $obj = new stdClass(); |
2147 | 2147 | $obj->url = $url; |
@@ -2159,68 +2159,68 @@ discard block |
||
2159 | 2159 | */ |
2160 | 2160 | function procDocumentAddCart() |
2161 | 2161 | { |
2162 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_permitted'); |
|
2162 | + if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_permitted'); |
|
2163 | 2163 | |
2164 | 2164 | // Get document_srl |
2165 | - $srls = explode(',',Context::get('srls')); |
|
2166 | - for($i = 0; $i < count($srls); $i++) |
|
2165 | + $srls = explode(',', Context::get('srls')); |
|
2166 | + for ($i = 0; $i < count($srls); $i++) |
|
2167 | 2167 | { |
2168 | 2168 | $srl = trim($srls[$i]); |
2169 | 2169 | |
2170 | - if(!$srl) continue; |
|
2170 | + if (!$srl) continue; |
|
2171 | 2171 | |
2172 | 2172 | $document_srls[] = $srl; |
2173 | 2173 | } |
2174 | - if(!count($document_srls)) return; |
|
2174 | + if (!count($document_srls)) return; |
|
2175 | 2175 | |
2176 | 2176 | // Get module_srl of the documents |
2177 | 2177 | $args = new stdClass; |
2178 | 2178 | $args->list_count = count($document_srls); |
2179 | - $args->document_srls = implode(',',$document_srls); |
|
2179 | + $args->document_srls = implode(',', $document_srls); |
|
2180 | 2180 | $args->order_type = 'asc'; |
2181 | 2181 | $output = executeQueryArray('document.getDocuments', $args); |
2182 | - if(!$output->data) return new BaseObject(); |
|
2182 | + if (!$output->data) return new BaseObject(); |
|
2183 | 2183 | |
2184 | 2184 | unset($document_srls); |
2185 | - foreach($output->data as $key => $val) |
|
2185 | + foreach ($output->data as $key => $val) |
|
2186 | 2186 | { |
2187 | 2187 | $document_srls[$val->module_srl][] = $val->document_srl; |
2188 | 2188 | } |
2189 | - if(!$document_srls || !count($document_srls)) return new BaseObject(); |
|
2189 | + if (!$document_srls || !count($document_srls)) return new BaseObject(); |
|
2190 | 2190 | |
2191 | 2191 | // Check if each of module administrators exists. Top-level administator will have a permission to modify every document of all modules.(Even to modify temporarily saved or trashed documents) |
2192 | 2192 | $oModuleModel = getModel('module'); |
2193 | 2193 | $module_srls = array_keys($document_srls); |
2194 | - for($i=0;$i<count($module_srls);$i++) |
|
2194 | + for ($i = 0; $i < count($module_srls); $i++) |
|
2195 | 2195 | { |
2196 | 2196 | $module_srl = $module_srls[$i]; |
2197 | 2197 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl); |
2198 | 2198 | $logged_info = Context::get('logged_info'); |
2199 | - if($logged_info->is_admin != 'Y') |
|
2199 | + if ($logged_info->is_admin != 'Y') |
|
2200 | 2200 | { |
2201 | - if(!$module_info) |
|
2201 | + if (!$module_info) |
|
2202 | 2202 | { |
2203 | 2203 | unset($document_srls[$module_srl]); |
2204 | 2204 | continue; |
2205 | 2205 | } |
2206 | 2206 | $grant = $oModuleModel->getGrant($module_info, $logged_info); |
2207 | - if(!$grant->manager) |
|
2207 | + if (!$grant->manager) |
|
2208 | 2208 | { |
2209 | 2209 | unset($document_srls[$module_srl]); |
2210 | 2210 | continue; |
2211 | 2211 | } |
2212 | 2212 | } |
2213 | 2213 | } |
2214 | - if(!count($document_srls)) return new BaseObject(); |
|
2214 | + if (!count($document_srls)) return new BaseObject(); |
|
2215 | 2215 | |
2216 | - foreach($document_srls as $module_srl => $documents) |
|
2216 | + foreach ($document_srls as $module_srl => $documents) |
|
2217 | 2217 | { |
2218 | 2218 | $cnt = count($documents); |
2219 | - for($i=0;$i<$cnt;$i++) |
|
2219 | + for ($i = 0; $i < $cnt; $i++) |
|
2220 | 2220 | { |
2221 | - $document_srl = (int)trim($documents[$i]); |
|
2222 | - if(!$document_srls) continue; |
|
2223 | - if($_SESSION['document_management'][$document_srl]) unset($_SESSION['document_management'][$document_srl]); |
|
2221 | + $document_srl = (int) trim($documents[$i]); |
|
2222 | + if (!$document_srls) continue; |
|
2223 | + if ($_SESSION['document_management'][$document_srl]) unset($_SESSION['document_management'][$document_srl]); |
|
2224 | 2224 | else $_SESSION['document_management'][$document_srl] = true; |
2225 | 2225 | } |
2226 | 2226 | } |
@@ -2233,9 +2233,9 @@ discard block |
||
2233 | 2233 | function procDocumentManageCheckedDocument() |
2234 | 2234 | { |
2235 | 2235 | @set_time_limit(0); |
2236 | - if(!Context::get('is_logged')) return new BaseObject(-1,'msg_not_permitted'); |
|
2236 | + if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_permitted'); |
|
2237 | 2237 | |
2238 | - if(!checkCSRF()) |
|
2238 | + if (!checkCSRF()) |
|
2239 | 2239 | { |
2240 | 2240 | return new BaseObject(-1, 'msg_invalid_request'); |
2241 | 2241 | } |
@@ -2243,45 +2243,45 @@ discard block |
||
2243 | 2243 | $type = Context::get('type'); |
2244 | 2244 | $target_module = Context::get('target_module_srl'); |
2245 | 2245 | $module_srl = Context::get('module_srl'); |
2246 | - if($target_module && !$module_srl) $module_srl = $target_module; |
|
2246 | + if ($target_module && !$module_srl) $module_srl = $target_module; |
|
2247 | 2247 | $category_srl = Context::get('target_category_srl'); |
2248 | 2248 | $message_content = strip_tags(Context::get('message_content')); |
2249 | - if($message_content) $message_content = nl2br($message_content); |
|
2249 | + if ($message_content) $message_content = nl2br($message_content); |
|
2250 | 2250 | |
2251 | 2251 | $cart = Context::get('cart'); |
2252 | 2252 | $document_srl_list = (!is_array($cart)) ? explode('|@|', $cart) : $cart; |
2253 | 2253 | |
2254 | - array_map(function ($value) { return (int)$value; }, $document_srl_list); |
|
2254 | + array_map(function($value) { return (int) $value; }, $document_srl_list); |
|
2255 | 2255 | |
2256 | 2256 | $document_srl_count = count($document_srl_list); |
2257 | 2257 | |
2258 | 2258 | $oDocumentModel = getModel('document'); |
2259 | 2259 | $document_items = array(); |
2260 | - foreach($document_srl_list as $document_srl) |
|
2260 | + foreach ($document_srl_list as $document_srl) |
|
2261 | 2261 | { |
2262 | 2262 | $oDocument = $oDocumentModel->getDocument($document_srl); |
2263 | 2263 | $document_items[] = $oDocument; |
2264 | - if(!$oDocument->isGranted()) return $this->stop('msg_not_permitted'); |
|
2264 | + if (!$oDocument->isGranted()) return $this->stop('msg_not_permitted'); |
|
2265 | 2265 | } |
2266 | 2266 | |
2267 | 2267 | // Send a message |
2268 | - if($message_content) |
|
2268 | + if ($message_content) |
|
2269 | 2269 | { |
2270 | 2270 | |
2271 | 2271 | $oCommunicationController = getController('communication'); |
2272 | 2272 | |
2273 | 2273 | $logged_info = Context::get('logged_info'); |
2274 | 2274 | |
2275 | - $title = cut_str($message_content,10,'...'); |
|
2275 | + $title = cut_str($message_content, 10, '...'); |
|
2276 | 2276 | $sender_member_srl = $logged_info->member_srl; |
2277 | 2277 | |
2278 | - foreach($document_items as $oDocument) |
|
2278 | + foreach ($document_items as $oDocument) |
|
2279 | 2279 | { |
2280 | - if(!$oDocument->get('member_srl') || $oDocument->get('member_srl')==$sender_member_srl) continue; |
|
2280 | + if (!$oDocument->get('member_srl') || $oDocument->get('member_srl') == $sender_member_srl) continue; |
|
2281 | 2281 | |
2282 | - if($type=='move') $purl = sprintf("<a href=\"%s\" target=\"_blank\">%s</a>", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl()); |
|
2282 | + if ($type == 'move') $purl = sprintf("<a href=\"%s\" target=\"_blank\">%s</a>", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl()); |
|
2283 | 2283 | else $purl = ""; |
2284 | - $content = sprintf("<div>%s</div><hr />%s<div style=\"font-weight:bold\">%s</div>%s",$message_content, $purl, $oDocument->getTitleText(), $oDocument->getContent(false, false, false)); |
|
2284 | + $content = sprintf("<div>%s</div><hr />%s<div style=\"font-weight:bold\">%s</div>%s", $message_content, $purl, $oDocument->getTitleText(), $oDocument->getContent(false, false, false)); |
|
2285 | 2285 | |
2286 | 2286 | $oCommunicationController->sendMessage($sender_member_srl, $oDocument->get('member_srl'), $title, $content, false); |
2287 | 2287 | } |
@@ -2291,54 +2291,54 @@ discard block |
||
2291 | 2291 | $oSpamController->setAvoidLog(); |
2292 | 2292 | |
2293 | 2293 | $oDocumentAdminController = getAdminController('document'); |
2294 | - if($type == 'move') |
|
2294 | + if ($type == 'move') |
|
2295 | 2295 | { |
2296 | - if(!$module_srl) return new BaseObject(-1, 'fail_to_move'); |
|
2296 | + if (!$module_srl) return new BaseObject(-1, 'fail_to_move'); |
|
2297 | 2297 | |
2298 | 2298 | $output = $oDocumentAdminController->moveDocumentModule($document_srl_list, $module_srl, $category_srl); |
2299 | - if(!$output->toBool()) return new BaseObject(-1, 'fail_to_move'); |
|
2299 | + if (!$output->toBool()) return new BaseObject(-1, 'fail_to_move'); |
|
2300 | 2300 | |
2301 | 2301 | $msg_code = 'success_moved'; |
2302 | 2302 | |
2303 | 2303 | } |
2304 | - else if($type == 'copy') |
|
2304 | + else if ($type == 'copy') |
|
2305 | 2305 | { |
2306 | - if(!$module_srl) return new BaseObject(-1, 'fail_to_move'); |
|
2306 | + if (!$module_srl) return new BaseObject(-1, 'fail_to_move'); |
|
2307 | 2307 | |
2308 | 2308 | $output = $oDocumentAdminController->copyDocumentModule($document_srl_list, $module_srl, $category_srl); |
2309 | - if(!$output->toBool()) return new BaseObject(-1, 'fail_to_move'); |
|
2309 | + if (!$output->toBool()) return new BaseObject(-1, 'fail_to_move'); |
|
2310 | 2310 | |
2311 | 2311 | $msg_code = 'success_copied'; |
2312 | 2312 | } |
2313 | - else if($type =='delete') |
|
2313 | + else if ($type == 'delete') |
|
2314 | 2314 | { |
2315 | 2315 | $oDB = &DB::getInstance(); |
2316 | 2316 | $oDB->begin(); |
2317 | - for($i=0;$i<$document_srl_count;$i++) |
|
2317 | + for ($i = 0; $i < $document_srl_count; $i++) |
|
2318 | 2318 | { |
2319 | 2319 | $document_srl = $document_srl_list[$i]; |
2320 | 2320 | $output = $this->deleteDocument($document_srl, true); |
2321 | - if(!$output->toBool()) return new BaseObject(-1, 'fail_to_delete'); |
|
2321 | + if (!$output->toBool()) return new BaseObject(-1, 'fail_to_delete'); |
|
2322 | 2322 | } |
2323 | 2323 | $oDB->commit(); |
2324 | 2324 | $msg_code = 'success_deleted'; |
2325 | 2325 | } |
2326 | - else if($type == 'trash') |
|
2326 | + else if ($type == 'trash') |
|
2327 | 2327 | { |
2328 | 2328 | $args = new stdClass(); |
2329 | 2329 | $args->description = $message_content; |
2330 | 2330 | |
2331 | 2331 | $oDB = &DB::getInstance(); |
2332 | 2332 | $oDB->begin(); |
2333 | - for($i=0;$i<$document_srl_count;$i++) { |
|
2333 | + for ($i = 0; $i < $document_srl_count; $i++) { |
|
2334 | 2334 | $args->document_srl = $document_srl_list[$i]; |
2335 | 2335 | $output = $this->moveDocumentToTrash($args); |
2336 | - if(!$output || !$output->toBool()) return new BaseObject(-1, 'fail_to_trash'); |
|
2336 | + if (!$output || !$output->toBool()) return new BaseObject(-1, 'fail_to_trash'); |
|
2337 | 2337 | } |
2338 | 2338 | $oDB->commit(); |
2339 | 2339 | $msg_code = 'success_trashed'; |
2340 | 2340 | } |
2341 | - else if($type == 'cancelDeclare') |
|
2341 | + else if ($type == 'cancelDeclare') |
|
2342 | 2342 | { |
2343 | 2343 | $args->document_srl = $document_srl_list; |
2344 | 2344 | $output = executeQuery('document.deleteDeclaredDocuments', $args); |
@@ -2360,27 +2360,27 @@ discard block |
||
2360 | 2360 | function procDocumentInsertModuleConfig() |
2361 | 2361 | { |
2362 | 2362 | $module_srl = Context::get('target_module_srl'); |
2363 | - if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl); |
|
2363 | + if (preg_match('/^([0-9,]+)$/', $module_srl)) $module_srl = explode(',', $module_srl); |
|
2364 | 2364 | else $module_srl = array($module_srl); |
2365 | 2365 | |
2366 | 2366 | $document_config = new stdClass(); |
2367 | 2367 | $document_config->use_history = Context::get('use_history'); |
2368 | - if(!$document_config->use_history) $document_config->use_history = 'N'; |
|
2368 | + if (!$document_config->use_history) $document_config->use_history = 'N'; |
|
2369 | 2369 | |
2370 | 2370 | $document_config->use_vote_up = Context::get('use_vote_up'); |
2371 | - if(!$document_config->use_vote_up) $document_config->use_vote_up = 'Y'; |
|
2371 | + if (!$document_config->use_vote_up) $document_config->use_vote_up = 'Y'; |
|
2372 | 2372 | |
2373 | 2373 | $document_config->use_vote_down = Context::get('use_vote_down'); |
2374 | - if(!$document_config->use_vote_down) $document_config->use_vote_down = 'Y'; |
|
2374 | + if (!$document_config->use_vote_down) $document_config->use_vote_down = 'Y'; |
|
2375 | 2375 | |
2376 | 2376 | $document_config->use_status = Context::get('use_status'); |
2377 | 2377 | |
2378 | 2378 | $oModuleController = getController('module'); |
2379 | - for($i=0;$i<count($module_srl);$i++) |
|
2379 | + for ($i = 0; $i < count($module_srl); $i++) |
|
2380 | 2380 | { |
2381 | 2381 | $srl = trim($module_srl[$i]); |
2382 | - if(!$srl) continue; |
|
2383 | - $output = $oModuleController->insertModulePartConfig('document',$srl,$document_config); |
|
2382 | + if (!$srl) continue; |
|
2383 | + $output = $oModuleController->insertModulePartConfig('document', $srl, $document_config); |
|
2384 | 2384 | } |
2385 | 2385 | $this->setError(-1); |
2386 | 2386 | $this->setMessage('success_updated', 'info'); |
@@ -2396,7 +2396,7 @@ discard block |
||
2396 | 2396 | function procDocumentTempSave() |
2397 | 2397 | { |
2398 | 2398 | // Check login information |
2399 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_logged'); |
|
2399 | + if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_logged'); |
|
2400 | 2400 | $module_info = Context::get('module_info'); |
2401 | 2401 | $logged_info = Context::get('logged_info'); |
2402 | 2402 | |
@@ -2408,7 +2408,7 @@ discard block |
||
2408 | 2408 | unset($obj->is_notice); |
2409 | 2409 | |
2410 | 2410 | // Extract from beginning part of contents in the guestbook |
2411 | - if(!$obj->title) |
|
2411 | + if (!$obj->title) |
|
2412 | 2412 | { |
2413 | 2413 | $obj->title = cut_str(strip_tags($obj->content), 20, '...'); |
2414 | 2414 | } |
@@ -2419,13 +2419,13 @@ discard block |
||
2419 | 2419 | $oDocument = $oDocumentModel->getDocument($obj->document_srl, $this->grant->manager); |
2420 | 2420 | |
2421 | 2421 | // Update if already exists |
2422 | - if($oDocument->isExists() && $oDocument->document_srl == $obj->document_srl) |
|
2422 | + if ($oDocument->isExists() && $oDocument->document_srl == $obj->document_srl) |
|
2423 | 2423 | { |
2424 | - if($oDocument->get('module_srl') != $obj->module_srl) |
|
2424 | + if ($oDocument->get('module_srl') != $obj->module_srl) |
|
2425 | 2425 | { |
2426 | 2426 | return new BaseObject(-1, 'msg_invalid_request'); |
2427 | 2427 | } |
2428 | - if(!$oDocument->isGranted()) |
|
2428 | + if (!$oDocument->isGranted()) |
|
2429 | 2429 | { |
2430 | 2430 | return new BaseObject(-1, 'msg_invalid_request'); |
2431 | 2431 | } |
@@ -2443,7 +2443,7 @@ discard block |
||
2443 | 2443 | $oDocument = $oDocumentModel->getDocument($obj->document_srl, $this->grant->manager); |
2444 | 2444 | } |
2445 | 2445 | // Set the attachment to be invalid state |
2446 | - if($oDocument->hasUploadedFiles()) |
|
2446 | + if ($oDocument->hasUploadedFiles()) |
|
2447 | 2447 | { |
2448 | 2448 | $args = new stdClass; |
2449 | 2449 | $args->upload_target_srl = $oDocument->document_srl; |
@@ -2461,11 +2461,11 @@ discard block |
||
2461 | 2461 | */ |
2462 | 2462 | function procDocumentGetList() |
2463 | 2463 | { |
2464 | - if(!Context::get('is_logged')) return new BaseObject(-1,'msg_not_permitted'); |
|
2464 | + if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_permitted'); |
|
2465 | 2465 | $documentSrls = Context::get('document_srls'); |
2466 | - if($documentSrls) $documentSrlList = explode(',', $documentSrls); |
|
2466 | + if ($documentSrls) $documentSrlList = explode(',', $documentSrls); |
|
2467 | 2467 | |
2468 | - if(count($documentSrlList) > 0) |
|
2468 | + if (count($documentSrlList) > 0) |
|
2469 | 2469 | { |
2470 | 2470 | $oDocumentModel = getModel('document'); |
2471 | 2471 | $columnList = array('document_srl', 'title', 'nick_name', 'status'); |
@@ -2489,10 +2489,10 @@ discard block |
||
2489 | 2489 | */ |
2490 | 2490 | function _checkCommentStatusForOldVersion(&$obj) |
2491 | 2491 | { |
2492 | - if(!isset($obj->allow_comment)) $obj->allow_comment = 'N'; |
|
2493 | - if(!isset($obj->lock_comment)) $obj->lock_comment = 'N'; |
|
2492 | + if (!isset($obj->allow_comment)) $obj->allow_comment = 'N'; |
|
2493 | + if (!isset($obj->lock_comment)) $obj->lock_comment = 'N'; |
|
2494 | 2494 | |
2495 | - if($obj->allow_comment == 'Y' && $obj->lock_comment == 'N') $obj->commentStatus = 'ALLOW'; |
|
2495 | + if ($obj->allow_comment == 'Y' && $obj->lock_comment == 'N') $obj->commentStatus = 'ALLOW'; |
|
2496 | 2496 | else $obj->commentStatus = 'DENY'; |
2497 | 2497 | } |
2498 | 2498 | |
@@ -2503,8 +2503,8 @@ discard block |
||
2503 | 2503 | */ |
2504 | 2504 | function _checkDocumentStatusForOldVersion(&$obj) |
2505 | 2505 | { |
2506 | - if(!$obj->status && $obj->is_secret == 'Y') $obj->status = $this->getConfigStatus('secret'); |
|
2507 | - if(!$obj->status && $obj->is_secret != 'Y') $obj->status = $this->getConfigStatus('public'); |
|
2506 | + if (!$obj->status && $obj->is_secret == 'Y') $obj->status = $this->getConfigStatus('secret'); |
|
2507 | + if (!$obj->status && $obj->is_secret != 'Y') $obj->status = $this->getConfigStatus('public'); |
|
2508 | 2508 | } |
2509 | 2509 | |
2510 | 2510 | public function updateUploaedCount($documentSrlList) |
@@ -2512,10 +2512,10 @@ discard block |
||
2512 | 2512 | $oDocumentModel = getModel('document'); |
2513 | 2513 | $oFileModel = getModel('file'); |
2514 | 2514 | |
2515 | - if(is_array($documentSrlList)) |
|
2515 | + if (is_array($documentSrlList)) |
|
2516 | 2516 | { |
2517 | 2517 | $documentSrlList = array_unique($documentSrlList); |
2518 | - foreach($documentSrlList AS $key => $documentSrl) |
|
2518 | + foreach ($documentSrlList AS $key => $documentSrl) |
|
2519 | 2519 | { |
2520 | 2520 | $fileCount = $oFileModel->getFilesCount($documentSrl); |
2521 | 2521 | $args = new stdClass(); |
@@ -2536,14 +2536,14 @@ discard block |
||
2536 | 2536 | $oDocumentModel = getModel('document'); |
2537 | 2537 | $documentExtraKeys = $oDocumentModel->getExtraKeys($obj->originModuleSrl); |
2538 | 2538 | |
2539 | - if(is_array($documentExtraKeys) && is_array($obj->moduleSrlList)) |
|
2539 | + if (is_array($documentExtraKeys) && is_array($obj->moduleSrlList)) |
|
2540 | 2540 | { |
2541 | - $oDocumentController=getController('document'); |
|
2542 | - foreach($obj->moduleSrlList AS $key=>$value) |
|
2541 | + $oDocumentController = getController('document'); |
|
2542 | + foreach ($obj->moduleSrlList AS $key=>$value) |
|
2543 | 2543 | { |
2544 | - foreach($documentExtraKeys AS $extraItem) |
|
2544 | + foreach ($documentExtraKeys AS $extraItem) |
|
2545 | 2545 | { |
2546 | - $oDocumentController->insertDocumentExtraKey($value, $extraItem->idx, $extraItem->name, $extraItem->type, $extraItem->is_required , $extraItem->search , $extraItem->default , $extraItem->desc, $extraItem->eid) ; |
|
2546 | + $oDocumentController->insertDocumentExtraKey($value, $extraItem->idx, $extraItem->name, $extraItem->type, $extraItem->is_required, $extraItem->search, $extraItem->default, $extraItem->desc, $extraItem->eid); |
|
2547 | 2547 | } |
2548 | 2548 | } |
2549 | 2549 | } |
@@ -2555,9 +2555,9 @@ discard block |
||
2555 | 2555 | $documentConfig = $oModuleModel->getModulePartConfig('document', $obj->originModuleSrl); |
2556 | 2556 | |
2557 | 2557 | $oModuleController = getController('module'); |
2558 | - if(is_array($obj->moduleSrlList)) |
|
2558 | + if (is_array($obj->moduleSrlList)) |
|
2559 | 2559 | { |
2560 | - foreach($obj->moduleSrlList AS $key=>$moduleSrl) |
|
2560 | + foreach ($obj->moduleSrlList AS $key=>$moduleSrl) |
|
2561 | 2561 | { |
2562 | 2562 | $oModuleController->insertModulePartConfig('document', $moduleSrl, $documentConfig); |
2563 | 2563 | } |
@@ -24,19 +24,27 @@ discard block |
||
24 | 24 | */ |
25 | 25 | function procDocumentVoteUp() |
26 | 26 | { |
27 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request'); |
|
27 | + if(!Context::get('is_logged')) { |
|
28 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
29 | + } |
|
28 | 30 | |
29 | 31 | $document_srl = Context::get('target_srl'); |
30 | - if(!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
32 | + if(!$document_srl) { |
|
33 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
34 | + } |
|
31 | 35 | |
32 | 36 | $oDocumentModel = getModel('document'); |
33 | 37 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false); |
34 | 38 | $module_srl = $oDocument->get('module_srl'); |
35 | - if(!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
39 | + if(!$module_srl) { |
|
40 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
41 | + } |
|
36 | 42 | |
37 | 43 | $oModuleModel = getModel('module'); |
38 | 44 | $document_config = $oModuleModel->getModulePartConfig('document',$module_srl); |
39 | - if($document_config->use_vote_up=='N') return new BaseObject(-1, 'msg_invalid_request'); |
|
45 | + if($document_config->use_vote_up=='N') { |
|
46 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
47 | + } |
|
40 | 48 | |
41 | 49 | $point = 1; |
42 | 50 | $output = $this->updateVotedCount($document_srl, $point); |
@@ -69,19 +77,27 @@ discard block |
||
69 | 77 | */ |
70 | 78 | function procDocumentVoteDown() |
71 | 79 | { |
72 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request'); |
|
80 | + if(!Context::get('is_logged')) { |
|
81 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
82 | + } |
|
73 | 83 | |
74 | 84 | $document_srl = Context::get('target_srl'); |
75 | - if(!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
85 | + if(!$document_srl) { |
|
86 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
87 | + } |
|
76 | 88 | |
77 | 89 | $oDocumentModel = getModel('document'); |
78 | 90 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false); |
79 | 91 | $module_srl = $oDocument->get('module_srl'); |
80 | - if(!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
92 | + if(!$module_srl) { |
|
93 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
94 | + } |
|
81 | 95 | |
82 | 96 | $oModuleModel = getModel('module'); |
83 | 97 | $document_config = $oModuleModel->getModulePartConfig('document',$module_srl); |
84 | - if($document_config->use_vote_down=='N') return new BaseObject(-1, 'msg_invalid_request'); |
|
98 | + if($document_config->use_vote_down=='N') { |
|
99 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
100 | + } |
|
85 | 101 | |
86 | 102 | $point = -1; |
87 | 103 | $output = $this->updateVotedCount($document_srl, $point); |
@@ -95,10 +111,14 @@ discard block |
||
95 | 111 | */ |
96 | 112 | function procDocumentDeclare() |
97 | 113 | { |
98 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request'); |
|
114 | + if(!Context::get('is_logged')) { |
|
115 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
116 | + } |
|
99 | 117 | |
100 | 118 | $document_srl = Context::get('target_srl'); |
101 | - if(!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
119 | + if(!$document_srl) { |
|
120 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
121 | + } |
|
102 | 122 | |
103 | 123 | return $this->declaredDocument($document_srl); |
104 | 124 | } |
@@ -140,7 +160,9 @@ discard block |
||
140 | 160 | $args->history_srl = $history_srl; |
141 | 161 | $args->module_srl = $module_srl; |
142 | 162 | $args->document_srl = $document_srl; |
143 | - if(!$args->history_srl && !$args->module_srl && !$args->document_srl) return; |
|
163 | + if(!$args->history_srl && !$args->module_srl && !$args->document_srl) { |
|
164 | + return; |
|
165 | + } |
|
144 | 166 | executeQuery("document.deleteHistory", $args); |
145 | 167 | } |
146 | 168 | |
@@ -152,15 +174,21 @@ discard block |
||
152 | 174 | function triggerDeleteModuleDocuments(&$obj) |
153 | 175 | { |
154 | 176 | $module_srl = $obj->module_srl; |
155 | - if(!$module_srl) return new BaseObject(); |
|
177 | + if(!$module_srl) { |
|
178 | + return new BaseObject(); |
|
179 | + } |
|
156 | 180 | // Delete the document |
157 | 181 | $oDocumentAdminController = getAdminController('document'); |
158 | 182 | $output = $oDocumentAdminController->deleteModuleDocument($module_srl); |
159 | - if(!$output->toBool()) return $output; |
|
183 | + if(!$output->toBool()) { |
|
184 | + return $output; |
|
185 | + } |
|
160 | 186 | // Delete the category |
161 | 187 | $oDocumentController = getController('document'); |
162 | 188 | $output = $oDocumentController->deleteModuleCategory($module_srl); |
163 | - if(!$output->toBool()) return $output; |
|
189 | + if(!$output->toBool()) { |
|
190 | + return $output; |
|
191 | + } |
|
164 | 192 | // Delete extra key and variable, because module deleted |
165 | 193 | $this->deleteDocumentExtraKeys($module_srl); |
166 | 194 | |
@@ -202,10 +230,18 @@ discard block |
||
202 | 230 | $oDB = &DB::getInstance(); |
203 | 231 | $oDB->begin(); |
204 | 232 | // List variables |
205 | - if($obj->comment_status) $obj->commentStatus = $obj->comment_status; |
|
206 | - if(!$obj->commentStatus) $obj->commentStatus = 'DENY'; |
|
207 | - if($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj); |
|
208 | - if($obj->allow_trackback!='Y') $obj->allow_trackback = 'N'; |
|
233 | + if($obj->comment_status) { |
|
234 | + $obj->commentStatus = $obj->comment_status; |
|
235 | + } |
|
236 | + if(!$obj->commentStatus) { |
|
237 | + $obj->commentStatus = 'DENY'; |
|
238 | + } |
|
239 | + if($obj->commentStatus == 'DENY') { |
|
240 | + $this->_checkCommentStatusForOldVersion($obj); |
|
241 | + } |
|
242 | + if($obj->allow_trackback!='Y') { |
|
243 | + $obj->allow_trackback = 'N'; |
|
244 | + } |
|
209 | 245 | if($obj->homepage) |
210 | 246 | { |
211 | 247 | $obj->homepage = removeHackTag($obj->homepage); |
@@ -215,9 +251,15 @@ discard block |
||
215 | 251 | } |
216 | 252 | } |
217 | 253 | |
218 | - if($obj->notify_message != 'Y') $obj->notify_message = 'N'; |
|
219 | - if(!$obj->email_address) $obj->email_address = ''; |
|
220 | - if(!$isRestore) $obj->ipaddress = $_SERVER['REMOTE_ADDR']; |
|
254 | + if($obj->notify_message != 'Y') { |
|
255 | + $obj->notify_message = 'N'; |
|
256 | + } |
|
257 | + if(!$obj->email_address) { |
|
258 | + $obj->email_address = ''; |
|
259 | + } |
|
260 | + if(!$isRestore) { |
|
261 | + $obj->ipaddress = $_SERVER['REMOTE_ADDR']; |
|
262 | + } |
|
221 | 263 | |
222 | 264 | // can modify regdate only manager |
223 | 265 | $grant = Context::get('grant'); |
@@ -227,7 +269,9 @@ discard block |
||
227 | 269 | } |
228 | 270 | |
229 | 271 | // Serialize the $extra_vars, check the extra_vars type, because duplicate serialized avoid |
230 | - if(!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars); |
|
272 | + if(!is_string($obj->extra_vars)) { |
|
273 | + $obj->extra_vars = serialize($obj->extra_vars); |
|
274 | + } |
|
231 | 275 | // Remove the columns for automatic saving |
232 | 276 | unset($obj->_saved_doc_srl); |
233 | 277 | unset($obj->_saved_doc_title); |
@@ -235,10 +279,15 @@ discard block |
||
235 | 279 | unset($obj->_saved_doc_message); |
236 | 280 | // Call a trigger (before) |
237 | 281 | $output = ModuleHandler::triggerCall('document.insertDocument', 'before', $obj); |
238 | - if(!$output->toBool()) return $output; |
|
282 | + if(!$output->toBool()) { |
|
283 | + return $output; |
|
284 | + } |
|
239 | 285 | // Register it if no given document_srl exists |
240 | - if(!$obj->document_srl) $obj->document_srl = getNextSequence(); |
|
241 | - elseif(!$manual_inserted && !$isRestore && !checkUserSequence($obj->document_srl)) return new BaseObject(-1, 'msg_not_permitted'); |
|
286 | + if(!$obj->document_srl) { |
|
287 | + $obj->document_srl = getNextSequence(); |
|
288 | + } elseif(!$manual_inserted && !$isRestore && !checkUserSequence($obj->document_srl)) { |
|
289 | + return new BaseObject(-1, 'msg_not_permitted'); |
|
290 | + } |
|
242 | 291 | |
243 | 292 | $oDocumentModel = getModel('document'); |
244 | 293 | // Set to 0 if the category_srl doesn't exist |
@@ -249,12 +298,19 @@ discard block |
||
249 | 298 | { |
250 | 299 | return new BaseObject(-1, 'msg_not_permitted'); |
251 | 300 | } |
252 | - if(count($category_list) > 0 && !$category_list[$obj->category_srl]) $obj->category_srl = 0; |
|
301 | + if(count($category_list) > 0 && !$category_list[$obj->category_srl]) { |
|
302 | + $obj->category_srl = 0; |
|
303 | + } |
|
253 | 304 | } |
254 | 305 | // Set the read counts and update order. |
255 | - if(!$obj->readed_count) $obj->readed_count = 0; |
|
256 | - if($isLatest) $obj->update_order = $obj->list_order = $obj->document_srl * -1; |
|
257 | - else $obj->update_order = $obj->list_order; |
|
306 | + if(!$obj->readed_count) { |
|
307 | + $obj->readed_count = 0; |
|
308 | + } |
|
309 | + if($isLatest) { |
|
310 | + $obj->update_order = $obj->list_order = $obj->document_srl * -1; |
|
311 | + } else { |
|
312 | + $obj->update_order = $obj->list_order; |
|
313 | + } |
|
258 | 314 | // Check the status of password hash for manually inserting. Apply hashing for otherwise. |
259 | 315 | if($obj->password && !$obj->password_is_hashed) |
260 | 316 | { |
@@ -276,9 +332,13 @@ discard block |
||
276 | 332 | // If the tile is empty, extract string from the contents. |
277 | 333 | $obj->title = htmlspecialchars($obj->title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
278 | 334 | settype($obj->title, "string"); |
279 | - if($obj->title == '') $obj->title = cut_str(trim(strip_tags(nl2br($obj->content))),20,'...'); |
|
335 | + if($obj->title == '') { |
|
336 | + $obj->title = cut_str(trim(strip_tags(nl2br($obj->content))),20,'...'); |
|
337 | + } |
|
280 | 338 | // If no tile extracted from the contents, leave it untitled. |
281 | - if($obj->title == '') $obj->title = 'Untitled'; |
|
339 | + if($obj->title == '') { |
|
340 | + $obj->title = 'Untitled'; |
|
341 | + } |
|
282 | 342 | // Remove XE's own tags from the contents. |
283 | 343 | $obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content); |
284 | 344 | if(Mobile::isFromMobilePhone() && $obj->use_editor != 'Y') |
@@ -290,13 +350,19 @@ discard block |
||
290 | 350 | $obj->content = nl2br($obj->content); |
291 | 351 | } |
292 | 352 | // Remove iframe and script if not a top adminisrator in the session. |
293 | - if($logged_info->is_admin != 'Y') $obj->content = removeHackTag($obj->content); |
|
353 | + if($logged_info->is_admin != 'Y') { |
|
354 | + $obj->content = removeHackTag($obj->content); |
|
355 | + } |
|
294 | 356 | // An error appears if both log-in info and user name don't exist. |
295 | - if(!$logged_info->member_srl && !$obj->nick_name) return new BaseObject(-1,'msg_invalid_request'); |
|
357 | + if(!$logged_info->member_srl && !$obj->nick_name) { |
|
358 | + return new BaseObject(-1,'msg_invalid_request'); |
|
359 | + } |
|
296 | 360 | |
297 | 361 | $obj->lang_code = Context::getLangType(); |
298 | 362 | // Insert data into the DB |
299 | - if(!$obj->status) $this->_checkDocumentStatusForOldVersion($obj); |
|
363 | + if(!$obj->status) { |
|
364 | + $this->_checkDocumentStatusForOldVersion($obj); |
|
365 | + } |
|
300 | 366 | $output = executeQuery('document.insertDocument', $obj); |
301 | 367 | if(!$output->toBool()) |
302 | 368 | { |
@@ -313,19 +379,25 @@ discard block |
||
313 | 379 | if(isset($obj->{'extra_vars'.$idx})) |
314 | 380 | { |
315 | 381 | $tmp = $obj->{'extra_vars'.$idx}; |
316 | - if(is_array($tmp)) |
|
317 | - $value = implode('|@|', $tmp); |
|
318 | - else |
|
319 | - $value = trim($tmp); |
|
382 | + if(is_array($tmp)) { |
|
383 | + $value = implode('|@|', $tmp); |
|
384 | + } else { |
|
385 | + $value = trim($tmp); |
|
386 | + } |
|
387 | + } else if(isset($obj->{$extra_item->name})) { |
|
388 | + $value = trim($obj->{$extra_item->name}); |
|
389 | + } |
|
390 | + if($value == NULL) { |
|
391 | + continue; |
|
320 | 392 | } |
321 | - else if(isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name}); |
|
322 | - if($value == NULL) continue; |
|
323 | 393 | |
324 | 394 | $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid); |
325 | 395 | } |
326 | 396 | } |
327 | 397 | // Update the category if the category_srl exists. |
328 | - if($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
398 | + if($obj->category_srl) { |
|
399 | + $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
400 | + } |
|
329 | 401 | // Call a trigger (after) |
330 | 402 | if($output->toBool()) |
331 | 403 | { |
@@ -367,27 +439,39 @@ discard block |
||
367 | 439 | return new BaseObject(-1, 'msg_invalid_request'); |
368 | 440 | } |
369 | 441 | |
370 | - if(!$source_obj->document_srl || !$obj->document_srl) return new BaseObject(-1,'msg_invalied_request'); |
|
371 | - if(!$obj->status && $obj->is_secret == 'Y') $obj->status = 'SECRET'; |
|
372 | - if(!$obj->status) $obj->status = 'PUBLIC'; |
|
442 | + if(!$source_obj->document_srl || !$obj->document_srl) { |
|
443 | + return new BaseObject(-1,'msg_invalied_request'); |
|
444 | + } |
|
445 | + if(!$obj->status && $obj->is_secret == 'Y') { |
|
446 | + $obj->status = 'SECRET'; |
|
447 | + } |
|
448 | + if(!$obj->status) { |
|
449 | + $obj->status = 'PUBLIC'; |
|
450 | + } |
|
373 | 451 | |
374 | 452 | // Call a trigger (before) |
375 | 453 | $output = ModuleHandler::triggerCall('document.updateDocument', 'before', $obj); |
376 | - if(!$output->toBool()) return $output; |
|
454 | + if(!$output->toBool()) { |
|
455 | + return $output; |
|
456 | + } |
|
377 | 457 | |
378 | 458 | // begin transaction |
379 | 459 | $oDB = &DB::getInstance(); |
380 | 460 | $oDB->begin(); |
381 | 461 | |
382 | 462 | $oModuleModel = getModel('module'); |
383 | - if(!$obj->module_srl) $obj->module_srl = $source_obj->get('module_srl'); |
|
463 | + if(!$obj->module_srl) { |
|
464 | + $obj->module_srl = $source_obj->get('module_srl'); |
|
465 | + } |
|
384 | 466 | $module_srl = $obj->module_srl; |
385 | 467 | $document_config = $oModuleModel->getModulePartConfig('document', $module_srl); |
386 | 468 | if(!$document_config) |
387 | 469 | { |
388 | 470 | $document_config = new stdClass(); |
389 | 471 | } |
390 | - if(!isset($document_config->use_history)) $document_config->use_history = 'N'; |
|
472 | + if(!isset($document_config->use_history)) { |
|
473 | + $document_config->use_history = 'N'; |
|
474 | + } |
|
391 | 475 | $bUseHistory = $document_config->use_history == 'Y' || $document_config->use_history == 'Trace'; |
392 | 476 | |
393 | 477 | if($bUseHistory) |
@@ -396,22 +480,31 @@ discard block |
||
396 | 480 | $args->history_srl = getNextSequence(); |
397 | 481 | $args->document_srl = $obj->document_srl; |
398 | 482 | $args->module_srl = $module_srl; |
399 | - if($document_config->use_history == 'Y') $args->content = $source_obj->get('content'); |
|
483 | + if($document_config->use_history == 'Y') { |
|
484 | + $args->content = $source_obj->get('content'); |
|
485 | + } |
|
400 | 486 | $args->nick_name = $logged_info->nick_name; |
401 | 487 | $args->member_srl = $logged_info->member_srl; |
402 | 488 | $args->regdate = $source_obj->get('last_update'); |
403 | 489 | $args->ipaddress = $_SERVER['REMOTE_ADDR']; |
404 | 490 | $output = executeQuery("document.insertHistory", $args); |
405 | - } |
|
406 | - else |
|
491 | + } else |
|
407 | 492 | { |
408 | 493 | $obj->ipaddress = $source_obj->get('ipaddress'); |
409 | 494 | } |
410 | 495 | // List variables |
411 | - if($obj->comment_status) $obj->commentStatus = $obj->comment_status; |
|
412 | - if(!$obj->commentStatus) $obj->commentStatus = 'DENY'; |
|
413 | - if($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj); |
|
414 | - if($obj->allow_trackback!='Y') $obj->allow_trackback = 'N'; |
|
496 | + if($obj->comment_status) { |
|
497 | + $obj->commentStatus = $obj->comment_status; |
|
498 | + } |
|
499 | + if(!$obj->commentStatus) { |
|
500 | + $obj->commentStatus = 'DENY'; |
|
501 | + } |
|
502 | + if($obj->commentStatus == 'DENY') { |
|
503 | + $this->_checkCommentStatusForOldVersion($obj); |
|
504 | + } |
|
505 | + if($obj->allow_trackback!='Y') { |
|
506 | + $obj->allow_trackback = 'N'; |
|
507 | + } |
|
415 | 508 | if($obj->homepage) |
416 | 509 | { |
417 | 510 | $obj->homepage = removeHackTag($obj->homepage); |
@@ -421,7 +514,9 @@ discard block |
||
421 | 514 | } |
422 | 515 | } |
423 | 516 | |
424 | - if($obj->notify_message != 'Y') $obj->notify_message = 'N'; |
|
517 | + if($obj->notify_message != 'Y') { |
|
518 | + $obj->notify_message = 'N'; |
|
519 | + } |
|
425 | 520 | |
426 | 521 | // can modify regdate only manager |
427 | 522 | $grant = Context::get('grant'); |
@@ -431,7 +526,9 @@ discard block |
||
431 | 526 | } |
432 | 527 | |
433 | 528 | // Serialize the $extra_vars |
434 | - if(!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars); |
|
529 | + if(!is_string($obj->extra_vars)) { |
|
530 | + $obj->extra_vars = serialize($obj->extra_vars); |
|
531 | + } |
|
435 | 532 | // Remove the columns for automatic saving |
436 | 533 | unset($obj->_saved_doc_srl); |
437 | 534 | unset($obj->_saved_doc_title); |
@@ -443,7 +540,9 @@ discard block |
||
443 | 540 | if($source_obj->get('category_srl')!=$obj->category_srl) |
444 | 541 | { |
445 | 542 | $category_list = $oDocumentModel->getCategoryList($obj->module_srl); |
446 | - if(!$category_list[$obj->category_srl]) $obj->category_srl = 0; |
|
543 | + if(!$category_list[$obj->category_srl]) { |
|
544 | + $obj->category_srl = 0; |
|
545 | + } |
|
447 | 546 | } |
448 | 547 | // Change the update order |
449 | 548 | $obj->update_order = getNextSequence() * -1; |
@@ -478,9 +577,13 @@ discard block |
||
478 | 577 | // If the tile is empty, extract string from the contents. |
479 | 578 | $obj->title = htmlspecialchars($obj->title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
480 | 579 | settype($obj->title, "string"); |
481 | - if($obj->title == '') $obj->title = cut_str(strip_tags($obj->content),20,'...'); |
|
580 | + if($obj->title == '') { |
|
581 | + $obj->title = cut_str(strip_tags($obj->content),20,'...'); |
|
582 | + } |
|
482 | 583 | // If no tile extracted from the contents, leave it untitled. |
483 | - if($obj->title == '') $obj->title = 'Untitled'; |
|
584 | + if($obj->title == '') { |
|
585 | + $obj->title = 'Untitled'; |
|
586 | + } |
|
484 | 587 | // Remove XE's own tags from the contents. |
485 | 588 | $obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content); |
486 | 589 | if(Mobile::isFromMobilePhone() && $obj->use_editor != 'Y') |
@@ -500,8 +603,7 @@ discard block |
||
500 | 603 | $lang_code_args->document_srl = $source_obj->get('document_srl'); |
501 | 604 | $lang_code_args->lang_code = Context::getLangType(); |
502 | 605 | $output = executeQuery('document.updateDocumentsLangCode', $lang_code_args); |
503 | - } |
|
504 | - else |
|
606 | + } else |
|
505 | 607 | { |
506 | 608 | $extra_content = new stdClass; |
507 | 609 | $extra_content->title = $obj->title; |
@@ -520,7 +622,9 @@ discard block |
||
520 | 622 | $obj->content = removeHackTag($obj->content); |
521 | 623 | } |
522 | 624 | // if temporary document, regdate is now setting |
523 | - if($source_obj->get('status') == $this->getConfigStatus('temp')) $obj->regdate = date('YmdHis'); |
|
625 | + if($source_obj->get('status') == $this->getConfigStatus('temp')) { |
|
626 | + $obj->regdate = date('YmdHis'); |
|
627 | + } |
|
524 | 628 | |
525 | 629 | // Insert data into the DB |
526 | 630 | $output = executeQuery('document.updateDocument', $obj); |
@@ -543,25 +647,37 @@ discard block |
||
543 | 647 | if(isset($obj->{'extra_vars'.$idx})) |
544 | 648 | { |
545 | 649 | $tmp = $obj->{'extra_vars'.$idx}; |
546 | - if(is_array($tmp)) |
|
547 | - $value = implode('|@|', $tmp); |
|
548 | - else |
|
549 | - $value = trim($tmp); |
|
650 | + if(is_array($tmp)) { |
|
651 | + $value = implode('|@|', $tmp); |
|
652 | + } else { |
|
653 | + $value = trim($tmp); |
|
654 | + } |
|
655 | + } else if(isset($obj->{$extra_item->name})) { |
|
656 | + $value = trim($obj->{$extra_item->name}); |
|
657 | + } |
|
658 | + if($value == NULL) { |
|
659 | + continue; |
|
550 | 660 | } |
551 | - else if(isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name}); |
|
552 | - if($value == NULL) continue; |
|
553 | 661 | $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid); |
554 | 662 | } |
555 | 663 | } |
556 | 664 | // Inert extra vars for multi-language support of title and contents. |
557 | - if($extra_content->title) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -1, $extra_content->title, 'title_'.Context::getLangType()); |
|
558 | - if($extra_content->content) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -2, $extra_content->content, 'content_'.Context::getLangType()); |
|
665 | + if($extra_content->title) { |
|
666 | + $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -1, $extra_content->title, 'title_'.Context::getLangType()); |
|
667 | + } |
|
668 | + if($extra_content->content) { |
|
669 | + $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -2, $extra_content->content, 'content_'.Context::getLangType()); |
|
670 | + } |
|
559 | 671 | } |
560 | 672 | // Update the category if the category_srl exists. |
561 | 673 | if($source_obj->get('category_srl') != $obj->category_srl || $source_obj->get('module_srl') == $logged_info->member_srl) |
562 | 674 | { |
563 | - if($source_obj->get('category_srl') != $obj->category_srl) $this->updateCategoryCount($obj->module_srl, $source_obj->get('category_srl')); |
|
564 | - if($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
675 | + if($source_obj->get('category_srl') != $obj->category_srl) { |
|
676 | + $this->updateCategoryCount($obj->module_srl, $source_obj->get('category_srl')); |
|
677 | + } |
|
678 | + if($obj->category_srl) { |
|
679 | + $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
680 | + } |
|
565 | 681 | } |
566 | 682 | // Call a trigger (after) |
567 | 683 | if($output->toBool()) |
@@ -606,7 +722,9 @@ discard block |
||
606 | 722 | $trigger_obj = new stdClass(); |
607 | 723 | $trigger_obj->document_srl = $document_srl; |
608 | 724 | $output = ModuleHandler::triggerCall('document.deleteDocument', 'before', $trigger_obj); |
609 | - if(!$output->toBool()) return $output; |
|
725 | + if(!$output->toBool()) { |
|
726 | + return $output; |
|
727 | + } |
|
610 | 728 | |
611 | 729 | // begin transaction |
612 | 730 | $oDB = &DB::getInstance(); |
@@ -618,12 +736,17 @@ discard block |
||
618 | 736 | $oDocumentModel = getModel('document'); |
619 | 737 | // Check if the documnet exists |
620 | 738 | $oDocument = $oDocumentModel->getDocument($document_srl, $is_admin); |
739 | + } else if($isEmptyTrash && $oDocument == null) { |
|
740 | + return new BaseObject(-1, 'document is not exists'); |
|
621 | 741 | } |
622 | - else if($isEmptyTrash && $oDocument == null) return new BaseObject(-1, 'document is not exists'); |
|
623 | 742 | |
624 | - if(!$oDocument->isExists() || $oDocument->document_srl != $document_srl) return new BaseObject(-1, 'msg_invalid_document'); |
|
743 | + if(!$oDocument->isExists() || $oDocument->document_srl != $document_srl) { |
|
744 | + return new BaseObject(-1, 'msg_invalid_document'); |
|
745 | + } |
|
625 | 746 | // Check if a permossion is granted |
626 | - if(!$oDocument->isGranted()) return new BaseObject(-1, 'msg_not_permitted'); |
|
747 | + if(!$oDocument->isGranted()) { |
|
748 | + return new BaseObject(-1, 'msg_not_permitted'); |
|
749 | + } |
|
627 | 750 | |
628 | 751 | //if empty trash, document already deleted, therefore document not delete |
629 | 752 | $args = new stdClass(); |
@@ -643,7 +766,9 @@ discard block |
||
643 | 766 | |
644 | 767 | $this->deleteDocumentHistory(null, $document_srl, null); |
645 | 768 | // Update category information if the category_srl exists. |
646 | - if($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl')); |
|
769 | + if($oDocument->get('category_srl')) { |
|
770 | + $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl')); |
|
771 | + } |
|
647 | 772 | // Delete a declared list |
648 | 773 | executeQuery('document.deleteDeclared', $args); |
649 | 774 | // Delete extra variable |
@@ -723,8 +848,11 @@ discard block |
||
723 | 848 | { |
724 | 849 | $trash_args = new stdClass(); |
725 | 850 | // Get trash_srl if a given trash_srl doesn't exist |
726 | - if(!$obj->trash_srl) $trash_args->trash_srl = getNextSequence(); |
|
727 | - else $trash_args->trash_srl = $obj->trash_srl; |
|
851 | + if(!$obj->trash_srl) { |
|
852 | + $trash_args->trash_srl = getNextSequence(); |
|
853 | + } else { |
|
854 | + $trash_args->trash_srl = $obj->trash_srl; |
|
855 | + } |
|
728 | 856 | // Get its module_srl which the document belongs to |
729 | 857 | $oDocumentModel = getModel('document'); |
730 | 858 | $oDocument = $oDocumentModel->getDocument($obj->document_srl); |
@@ -732,7 +860,9 @@ discard block |
||
732 | 860 | $trash_args->module_srl = $oDocument->get('module_srl'); |
733 | 861 | $obj->module_srl = $oDocument->get('module_srl'); |
734 | 862 | // Cannot throw data from the trash to the trash |
735 | - if($trash_args->module_srl == 0) return false; |
|
863 | + if($trash_args->module_srl == 0) { |
|
864 | + return false; |
|
865 | + } |
|
736 | 866 | // Data setting |
737 | 867 | $trash_args->document_srl = $obj->document_srl; |
738 | 868 | $trash_args->description = $obj->description; |
@@ -793,7 +923,9 @@ discard block |
||
793 | 923 | }*/ |
794 | 924 | |
795 | 925 | // update category |
796 | - if($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl')); |
|
926 | + if($oDocument->get('category_srl')) { |
|
927 | + $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl')); |
|
928 | + } |
|
797 | 929 | |
798 | 930 | // remove thumbnails |
799 | 931 | FileHandler::removeDir(sprintf('files/thumbnails/%s',getNumberingPath($obj->document_srl, 3))); |
@@ -838,7 +970,9 @@ discard block |
||
838 | 970 | function updateReadedCount(&$oDocument) |
839 | 971 | { |
840 | 972 | // Pass if Crawler access |
841 | - if(isCrawler()) return false; |
|
973 | + if(isCrawler()) { |
|
974 | + return false; |
|
975 | + } |
|
842 | 976 | |
843 | 977 | $document_srl = $oDocument->document_srl; |
844 | 978 | $member_srl = $oDocument->get('member_srl'); |
@@ -846,10 +980,14 @@ discard block |
||
846 | 980 | |
847 | 981 | // Call a trigger when the read count is updated (before) |
848 | 982 | $trigger_output = ModuleHandler::triggerCall('document.updateReadedCount', 'before', $oDocument); |
849 | - if(!$trigger_output->toBool()) return $trigger_output; |
|
983 | + if(!$trigger_output->toBool()) { |
|
984 | + return $trigger_output; |
|
985 | + } |
|
850 | 986 | |
851 | 987 | // Pass if read count is increaded on the session information |
852 | - if($_SESSION['readed_document'][$document_srl]) return false; |
|
988 | + if($_SESSION['readed_document'][$document_srl]) { |
|
989 | + return false; |
|
990 | + } |
|
853 | 991 | |
854 | 992 | // Pass if the author's IP address is as same as visitor's. |
855 | 993 | if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) |
@@ -914,7 +1052,9 @@ discard block |
||
914 | 1052 | */ |
915 | 1053 | function insertDocumentExtraKey($module_srl, $var_idx, $var_name, $var_type, $var_is_required = 'N', $var_search = 'N', $var_default = '', $var_desc = '', $eid) |
916 | 1054 | { |
917 | - if(!$module_srl || !$var_idx || !$var_name || !$var_type || !$eid) return new BaseObject(-1,'msg_invalid_request'); |
|
1055 | + if(!$module_srl || !$var_idx || !$var_name || !$var_type || !$eid) { |
|
1056 | + return new BaseObject(-1,'msg_invalid_request'); |
|
1057 | + } |
|
918 | 1058 | |
919 | 1059 | $obj = new stdClass(); |
920 | 1060 | $obj->module_srl = $module_srl; |
@@ -931,8 +1071,7 @@ discard block |
||
931 | 1071 | if(!$output->data) |
932 | 1072 | { |
933 | 1073 | $output = executeQuery('document.insertDocumentExtraKey', $obj); |
934 | - } |
|
935 | - else |
|
1074 | + } else |
|
936 | 1075 | { |
937 | 1076 | $output = executeQuery('document.updateDocumentExtraKey', $obj); |
938 | 1077 | // Update the extra var(eid) |
@@ -958,10 +1097,14 @@ discard block |
||
958 | 1097 | */ |
959 | 1098 | function deleteDocumentExtraKeys($module_srl, $var_idx = null) |
960 | 1099 | { |
961 | - if(!$module_srl) return new BaseObject(-1,'msg_invalid_request'); |
|
1100 | + if(!$module_srl) { |
|
1101 | + return new BaseObject(-1,'msg_invalid_request'); |
|
1102 | + } |
|
962 | 1103 | $obj = new stdClass(); |
963 | 1104 | $obj->module_srl = $module_srl; |
964 | - if(!is_null($var_idx)) $obj->var_idx = $var_idx; |
|
1105 | + if(!is_null($var_idx)) { |
|
1106 | + $obj->var_idx = $var_idx; |
|
1107 | + } |
|
965 | 1108 | |
966 | 1109 | $oDB = DB::getInstance(); |
967 | 1110 | $oDB->begin(); |
@@ -1025,8 +1168,12 @@ discard block |
||
1025 | 1168 | */ |
1026 | 1169 | function insertDocumentExtraVar($module_srl, $document_srl, $var_idx, $value, $eid = null, $lang_code = '') |
1027 | 1170 | { |
1028 | - if(!$module_srl || !$document_srl || !$var_idx || !isset($value)) return new BaseObject(-1,'msg_invalid_request'); |
|
1029 | - if(!$lang_code) $lang_code = Context::getLangType(); |
|
1171 | + if(!$module_srl || !$document_srl || !$var_idx || !isset($value)) { |
|
1172 | + return new BaseObject(-1,'msg_invalid_request'); |
|
1173 | + } |
|
1174 | + if(!$lang_code) { |
|
1175 | + $lang_code = Context::getLangType(); |
|
1176 | + } |
|
1030 | 1177 | |
1031 | 1178 | $obj = new stdClass; |
1032 | 1179 | $obj->module_srl = $module_srl; |
@@ -1052,10 +1199,18 @@ discard block |
||
1052 | 1199 | { |
1053 | 1200 | $obj = new stdClass(); |
1054 | 1201 | $obj->module_srl = $module_srl; |
1055 | - if(!is_null($document_srl)) $obj->document_srl = $document_srl; |
|
1056 | - if(!is_null($var_idx)) $obj->var_idx = $var_idx; |
|
1057 | - if(!is_null($lang_code)) $obj->lang_code = $lang_code; |
|
1058 | - if(!is_null($eid)) $obj->eid = $eid; |
|
1202 | + if(!is_null($document_srl)) { |
|
1203 | + $obj->document_srl = $document_srl; |
|
1204 | + } |
|
1205 | + if(!is_null($var_idx)) { |
|
1206 | + $obj->var_idx = $var_idx; |
|
1207 | + } |
|
1208 | + if(!is_null($lang_code)) { |
|
1209 | + $obj->lang_code = $lang_code; |
|
1210 | + } |
|
1211 | + if(!is_null($eid)) { |
|
1212 | + $obj->eid = $eid; |
|
1213 | + } |
|
1059 | 1214 | $output = executeQuery('document.deleteDocumentExtraVars', $obj); |
1060 | 1215 | return $output; |
1061 | 1216 | } |
@@ -1069,8 +1224,11 @@ discard block |
||
1069 | 1224 | */ |
1070 | 1225 | function updateVotedCount($document_srl, $point = 1) |
1071 | 1226 | { |
1072 | - if($point > 0) $failed_voted = 'failed_voted'; |
|
1073 | - else $failed_voted = 'failed_blamed'; |
|
1227 | + if($point > 0) { |
|
1228 | + $failed_voted = 'failed_voted'; |
|
1229 | + } else { |
|
1230 | + $failed_voted = 'failed_blamed'; |
|
1231 | + } |
|
1074 | 1232 | // Return fail if session already has information about votes |
1075 | 1233 | if($_SESSION['voted_document'][$document_srl]) |
1076 | 1234 | { |
@@ -1106,8 +1264,7 @@ discard block |
||
1106 | 1264 | if($member_srl) |
1107 | 1265 | { |
1108 | 1266 | $args->member_srl = $member_srl; |
1109 | - } |
|
1110 | - else |
|
1267 | + } else |
|
1111 | 1268 | { |
1112 | 1269 | $args->ipaddress = $_SERVER['REMOTE_ADDR']; |
1113 | 1270 | } |
@@ -1144,18 +1301,21 @@ discard block |
||
1144 | 1301 | { |
1145 | 1302 | $args->blamed_count = $trigger_obj->after_point; |
1146 | 1303 | $output = executeQuery('document.updateBlamedCount', $args); |
1147 | - } |
|
1148 | - else |
|
1304 | + } else |
|
1149 | 1305 | { |
1150 | 1306 | $args->voted_count = $trigger_obj->after_point; |
1151 | 1307 | $output = executeQuery('document.updateVotedCount', $args); |
1152 | 1308 | } |
1153 | - if(!$output->toBool()) return $output; |
|
1309 | + if(!$output->toBool()) { |
|
1310 | + return $output; |
|
1311 | + } |
|
1154 | 1312 | |
1155 | 1313 | // Leave logs |
1156 | 1314 | $args->point = $trigger_obj->point; |
1157 | 1315 | $output = executeQuery('document.insertDocumentVotedLog', $args); |
1158 | - if(!$output->toBool()) return $output; |
|
1316 | + if(!$output->toBool()) { |
|
1317 | + return $output; |
|
1318 | + } |
|
1159 | 1319 | |
1160 | 1320 | // Call a trigger (after) |
1161 | 1321 | $trigger_output = ModuleHandler::triggerCall('document.updateVotedCount', 'after', $trigger_obj); |
@@ -1184,8 +1344,7 @@ discard block |
||
1184 | 1344 | { |
1185 | 1345 | $output->setMessage('success_voted'); |
1186 | 1346 | $output->add('voted_count', $trigger_obj->after_point); |
1187 | - } |
|
1188 | - else |
|
1347 | + } else |
|
1189 | 1348 | { |
1190 | 1349 | $output->setMessage('success_blamed'); |
1191 | 1350 | $output->add('blamed_count', $trigger_obj->after_point); |
@@ -1202,13 +1361,17 @@ discard block |
||
1202 | 1361 | function declaredDocument($document_srl) |
1203 | 1362 | { |
1204 | 1363 | // Fail if session information already has a reported document |
1205 | - if($_SESSION['declared_document'][$document_srl]) return new BaseObject(-1, 'failed_declared'); |
|
1364 | + if($_SESSION['declared_document'][$document_srl]) { |
|
1365 | + return new BaseObject(-1, 'failed_declared'); |
|
1366 | + } |
|
1206 | 1367 | |
1207 | 1368 | // Check if previously reported |
1208 | 1369 | $args = new stdClass(); |
1209 | 1370 | $args->document_srl = $document_srl; |
1210 | 1371 | $output = executeQuery('document.getDeclaredDocument', $args); |
1211 | - if(!$output->toBool()) return $output; |
|
1372 | + if(!$output->toBool()) { |
|
1373 | + return $output; |
|
1374 | + } |
|
1212 | 1375 | |
1213 | 1376 | $declared_count = ($output->data->declared_count) ? $output->data->declared_count : 0; |
1214 | 1377 | |
@@ -1252,8 +1415,7 @@ discard block |
||
1252 | 1415 | if($member_srl) |
1253 | 1416 | { |
1254 | 1417 | $args->member_srl = $member_srl; |
1255 | - } |
|
1256 | - else |
|
1418 | + } else |
|
1257 | 1419 | { |
1258 | 1420 | $args->ipaddress = $_SERVER['REMOTE_ADDR']; |
1259 | 1421 | } |
@@ -1273,9 +1435,14 @@ discard block |
||
1273 | 1435 | $oDB->begin(); |
1274 | 1436 | |
1275 | 1437 | // Add the declared document |
1276 | - if($declared_count > 0) $output = executeQuery('document.updateDeclaredDocument', $args); |
|
1277 | - else $output = executeQuery('document.insertDeclaredDocument', $args); |
|
1278 | - if(!$output->toBool()) return $output; |
|
1438 | + if($declared_count > 0) { |
|
1439 | + $output = executeQuery('document.updateDeclaredDocument', $args); |
|
1440 | + } else { |
|
1441 | + $output = executeQuery('document.insertDeclaredDocument', $args); |
|
1442 | + } |
|
1443 | + if(!$output->toBool()) { |
|
1444 | + return $output; |
|
1445 | + } |
|
1279 | 1446 | // Leave logs |
1280 | 1447 | $output = executeQuery('document.insertDocumentDeclaredLog', $args); |
1281 | 1448 | if(!$output->toBool()) |
@@ -1374,9 +1541,10 @@ discard block |
||
1374 | 1541 | $parent_category = $oDocumentModel->getCategory($obj->parent_srl); |
1375 | 1542 | $obj->list_order = $parent_category->list_order; |
1376 | 1543 | $this->updateCategoryListOrder($parent_category->module_srl, $parent_category->list_order+1); |
1377 | - if(!$obj->category_srl) $obj->category_srl = getNextSequence(); |
|
1378 | - } |
|
1379 | - else |
|
1544 | + if(!$obj->category_srl) { |
|
1545 | + $obj->category_srl = getNextSequence(); |
|
1546 | + } |
|
1547 | + } else |
|
1380 | 1548 | { |
1381 | 1549 | $obj->list_order = $obj->category_srl = getNextSequence(); |
1382 | 1550 | } |
@@ -1416,13 +1584,17 @@ discard block |
||
1416 | 1584 | { |
1417 | 1585 | // Create a document model object |
1418 | 1586 | $oDocumentModel = getModel('document'); |
1419 | - if(!$document_count) $document_count = $oDocumentModel->getCategoryDocumentCount($module_srl,$category_srl); |
|
1587 | + if(!$document_count) { |
|
1588 | + $document_count = $oDocumentModel->getCategoryDocumentCount($module_srl,$category_srl); |
|
1589 | + } |
|
1420 | 1590 | |
1421 | 1591 | $args = new stdClass; |
1422 | 1592 | $args->category_srl = $category_srl; |
1423 | 1593 | $args->document_count = $document_count; |
1424 | 1594 | $output = executeQuery('document.updateCategoryCount', $args); |
1425 | - if($output->toBool()) $this->makeCategoryFile($module_srl); |
|
1595 | + if($output->toBool()) { |
|
1596 | + $this->makeCategoryFile($module_srl); |
|
1597 | + } |
|
1426 | 1598 | |
1427 | 1599 | return $output; |
1428 | 1600 | } |
@@ -1435,7 +1607,9 @@ discard block |
||
1435 | 1607 | function updateCategory($obj) |
1436 | 1608 | { |
1437 | 1609 | $output = executeQuery('document.updateCategory', $obj); |
1438 | - if($output->toBool()) $this->makeCategoryFile($obj->module_srl); |
|
1610 | + if($output->toBool()) { |
|
1611 | + $this->makeCategoryFile($obj->module_srl); |
|
1612 | + } |
|
1439 | 1613 | return $output; |
1440 | 1614 | } |
1441 | 1615 | |
@@ -1452,11 +1626,17 @@ discard block |
||
1452 | 1626 | $category_info = $oDocumentModel->getCategory($category_srl); |
1453 | 1627 | // Display an error that the category cannot be deleted if it has a child |
1454 | 1628 | $output = executeQuery('document.getChildCategoryCount', $args); |
1455 | - if(!$output->toBool()) return $output; |
|
1456 | - if($output->data->count>0) return new BaseObject(-1, 'msg_cannot_delete_for_child'); |
|
1629 | + if(!$output->toBool()) { |
|
1630 | + return $output; |
|
1631 | + } |
|
1632 | + if($output->data->count>0) { |
|
1633 | + return new BaseObject(-1, 'msg_cannot_delete_for_child'); |
|
1634 | + } |
|
1457 | 1635 | // Delete a category information |
1458 | 1636 | $output = executeQuery('document.deleteCategory', $args); |
1459 | - if(!$output->toBool()) return $output; |
|
1637 | + if(!$output->toBool()) { |
|
1638 | + return $output; |
|
1639 | + } |
|
1460 | 1640 | |
1461 | 1641 | $this->makeCategoryFile($category_info->module_srl); |
1462 | 1642 | // remvove cache |
@@ -1471,8 +1651,9 @@ discard block |
||
1471 | 1651 | $args->page = ++$page; |
1472 | 1652 | $output = executeQuery('document.getDocumentList', $args, array('document_srl')); |
1473 | 1653 | |
1474 | - if($output->data == array()) |
|
1475 | - break; |
|
1654 | + if($output->data == array()) { |
|
1655 | + break; |
|
1656 | + } |
|
1476 | 1657 | |
1477 | 1658 | foreach($output->data as $val) |
1478 | 1659 | { |
@@ -1524,18 +1705,26 @@ discard block |
||
1524 | 1705 | // Seek a full list of categories |
1525 | 1706 | $category_list = $oDocumentModel->getCategoryList($module_srl); |
1526 | 1707 | $category_srl_list = array_keys($category_list); |
1527 | - if(count($category_srl_list)<2) return new BaseObject(); |
|
1708 | + if(count($category_srl_list)<2) { |
|
1709 | + return new BaseObject(); |
|
1710 | + } |
|
1528 | 1711 | |
1529 | 1712 | $prev_category = NULL; |
1530 | 1713 | foreach($category_list as $key => $val) |
1531 | 1714 | { |
1532 | - if($key==$category_srl) break; |
|
1715 | + if($key==$category_srl) { |
|
1716 | + break; |
|
1717 | + } |
|
1533 | 1718 | $prev_category = $val; |
1534 | 1719 | } |
1535 | 1720 | // Return if the previous category doesn't exist |
1536 | - if(!$prev_category) return new BaseObject(-1,Context::getLang('msg_category_not_moved')); |
|
1721 | + if(!$prev_category) { |
|
1722 | + return new BaseObject(-1,Context::getLang('msg_category_not_moved')); |
|
1723 | + } |
|
1537 | 1724 | // Return if the selected category is the top level |
1538 | - if($category_srl_list[0]==$category_srl) return new BaseObject(-1,Context::getLang('msg_category_not_moved')); |
|
1725 | + if($category_srl_list[0]==$category_srl) { |
|
1726 | + return new BaseObject(-1,Context::getLang('msg_category_not_moved')); |
|
1727 | + } |
|
1539 | 1728 | // Information of the selected category |
1540 | 1729 | $cur_args = new stdClass; |
1541 | 1730 | $cur_args->category_srl = $category_srl; |
@@ -1571,15 +1760,21 @@ discard block |
||
1571 | 1760 | // Seek a full list of categories |
1572 | 1761 | $category_list = $oDocumentModel->getCategoryList($module_srl); |
1573 | 1762 | $category_srl_list = array_keys($category_list); |
1574 | - if(count($category_srl_list)<2) return new BaseObject(); |
|
1763 | + if(count($category_srl_list)<2) { |
|
1764 | + return new BaseObject(); |
|
1765 | + } |
|
1575 | 1766 | |
1576 | 1767 | for($i=0;$i<count($category_srl_list);$i++) |
1577 | 1768 | { |
1578 | - if($category_srl_list[$i]==$category_srl) break; |
|
1769 | + if($category_srl_list[$i]==$category_srl) { |
|
1770 | + break; |
|
1771 | + } |
|
1579 | 1772 | } |
1580 | 1773 | |
1581 | 1774 | $next_category_srl = $category_srl_list[$i+1]; |
1582 | - if(!$category_list[$next_category_srl]) return new BaseObject(-1,Context::getLang('msg_category_not_moved')); |
|
1775 | + if(!$category_list[$next_category_srl]) { |
|
1776 | + return new BaseObject(-1,Context::getLang('msg_category_not_moved')); |
|
1777 | + } |
|
1583 | 1778 | $next_category = $category_list[$next_category_srl]; |
1584 | 1779 | // Information of the selected category |
1585 | 1780 | $cur_args = new stdClass; |
@@ -1606,7 +1801,9 @@ discard block |
||
1606 | 1801 | { |
1607 | 1802 | $oDocumentModel = getModel('document'); |
1608 | 1803 | $extra_keys = $oDocumentModel->getExtraKeys($module_srl); |
1609 | - if(!count($extra_keys)) return; |
|
1804 | + if(!count($extra_keys)) { |
|
1805 | + return; |
|
1806 | + } |
|
1610 | 1807 | |
1611 | 1808 | $js_code = array(); |
1612 | 1809 | $js_code[] = '<script>//<![CDATA['; |
@@ -1625,7 +1822,9 @@ discard block |
||
1625 | 1822 | } |
1626 | 1823 | $name = str_ireplace(array('<script', '</script'), array('<scr" + "ipt', '</scr" + "ipt'), $val->name); |
1627 | 1824 | $js_code[] = sprintf('validator.cast("ADD_MESSAGE", ["extra_vars%s","%s"]);', $idx, $name); |
1628 | - if($val->is_required == 'Y') $js_code[] = sprintf('validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx); |
|
1825 | + if($val->is_required == 'Y') { |
|
1826 | + $js_code[] = sprintf('validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx); |
|
1827 | + } |
|
1629 | 1828 | } |
1630 | 1829 | |
1631 | 1830 | $js_code[] = '})(jQuery);'; |
@@ -1643,7 +1842,9 @@ discard block |
||
1643 | 1842 | function procDocumentInsertCategory($args = null) |
1644 | 1843 | { |
1645 | 1844 | // List variables |
1646 | - if(!$args) $args = Context::gets('module_srl','category_srl','parent_srl','category_title','category_description','expand','group_srls','category_color','mid'); |
|
1845 | + if(!$args) { |
|
1846 | + $args = Context::gets('module_srl','category_srl','parent_srl','category_title','category_description','expand','group_srls','category_color','mid'); |
|
1847 | + } |
|
1647 | 1848 | $args->title = $args->category_title; |
1648 | 1849 | $args->description = $args->category_description; |
1649 | 1850 | $args->color = $args->category_color; |
@@ -1659,11 +1860,18 @@ discard block |
||
1659 | 1860 | $columnList = array('module_srl', 'module'); |
1660 | 1861 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList); |
1661 | 1862 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
1662 | - if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted'); |
|
1863 | + if(!$grant->manager) { |
|
1864 | + return new BaseObject(-1,'msg_not_permitted'); |
|
1865 | + } |
|
1663 | 1866 | |
1664 | - if($args->expand !="Y") $args->expand = "N"; |
|
1665 | - if(!is_array($args->group_srls)) $args->group_srls = str_replace('|@|',',',$args->group_srls); |
|
1666 | - else $args->group_srls = implode(',', $args->group_srls); |
|
1867 | + if($args->expand !="Y") { |
|
1868 | + $args->expand = "N"; |
|
1869 | + } |
|
1870 | + if(!is_array($args->group_srls)) { |
|
1871 | + $args->group_srls = str_replace('|@|',',',$args->group_srls); |
|
1872 | + } else { |
|
1873 | + $args->group_srls = implode(',', $args->group_srls); |
|
1874 | + } |
|
1667 | 1875 | $args->parent_srl = (int)$args->parent_srl; |
1668 | 1876 | |
1669 | 1877 | $oDocumentModel = getModel('document'); |
@@ -1674,7 +1882,9 @@ discard block |
||
1674 | 1882 | if($args->category_srl) |
1675 | 1883 | { |
1676 | 1884 | $category_info = $oDocumentModel->getCategory($args->category_srl); |
1677 | - if($category_info->category_srl != $args->category_srl) $args->category_srl = null; |
|
1885 | + if($category_info->category_srl != $args->category_srl) { |
|
1886 | + $args->category_srl = null; |
|
1887 | + } |
|
1678 | 1888 | } |
1679 | 1889 | // Update if exists |
1680 | 1890 | if($args->category_srl) |
@@ -1686,8 +1896,7 @@ discard block |
||
1686 | 1896 | return $output; |
1687 | 1897 | } |
1688 | 1898 | // Insert if not exist |
1689 | - } |
|
1690 | - else |
|
1899 | + } else |
|
1691 | 1900 | { |
1692 | 1901 | $output = $this->insertCategory($args); |
1693 | 1902 | if(!$output->toBool()) |
@@ -1729,7 +1938,9 @@ discard block |
||
1729 | 1938 | $columnList = array('module_srl', 'module'); |
1730 | 1939 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($source_category->module_srl, $columnList); |
1731 | 1940 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
1732 | - if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted'); |
|
1941 | + if(!$grant->manager) { |
|
1942 | + return new BaseObject(-1,'msg_not_permitted'); |
|
1943 | + } |
|
1733 | 1944 | |
1734 | 1945 | // First child of the parent_category_srl |
1735 | 1946 | $source_args = new stdClass; |
@@ -1742,30 +1953,39 @@ discard block |
||
1742 | 1953 | $args->parent_srl = $parent_category_srl; |
1743 | 1954 | $output = executeQuery('document.getChildCategoryMinListOrder', $args); |
1744 | 1955 | |
1745 | - if(!$output->toBool()) return $output; |
|
1956 | + if(!$output->toBool()) { |
|
1957 | + return $output; |
|
1958 | + } |
|
1746 | 1959 | $args->list_order = (int)$output->data->list_order; |
1747 | - if(!$args->list_order) $args->list_order = 0; |
|
1960 | + if(!$args->list_order) { |
|
1961 | + $args->list_order = 0; |
|
1962 | + } |
|
1748 | 1963 | $args->list_order--; |
1749 | 1964 | |
1750 | 1965 | $source_args->category_srl = $source_category_srl; |
1751 | 1966 | $source_args->parent_srl = $parent_category_srl; |
1752 | 1967 | $source_args->list_order = $args->list_order; |
1753 | 1968 | $output = $this->updateCategory($source_args); |
1754 | - if(!$output->toBool()) return $output; |
|
1969 | + if(!$output->toBool()) { |
|
1970 | + return $output; |
|
1971 | + } |
|
1755 | 1972 | // Sibling of the $target_category_srl |
1756 | - } |
|
1757 | - else if($target_category_srl > 0) |
|
1973 | + } else if($target_category_srl > 0) |
|
1758 | 1974 | { |
1759 | 1975 | $target_category = $oDocumentModel->getCategory($target_category_srl); |
1760 | 1976 | // Move all siblings of the $target_category down |
1761 | 1977 | $output = $this->updateCategoryListOrder($target_category->module_srl, $target_category->list_order+1); |
1762 | - if(!$output->toBool()) return $output; |
|
1978 | + if(!$output->toBool()) { |
|
1979 | + return $output; |
|
1980 | + } |
|
1763 | 1981 | |
1764 | 1982 | $source_args->category_srl = $source_category_srl; |
1765 | 1983 | $source_args->parent_srl = $target_category->parent_srl; |
1766 | 1984 | $source_args->list_order = $target_category->list_order+1; |
1767 | 1985 | $output = $this->updateCategory($source_args); |
1768 | - if(!$output->toBool()) return $output; |
|
1986 | + if(!$output->toBool()) { |
|
1987 | + return $output; |
|
1988 | + } |
|
1769 | 1989 | } |
1770 | 1990 | // Re-generate the xml file |
1771 | 1991 | $xml_file = $this->makeCategoryFile($source_category->module_srl); |
@@ -1790,14 +2010,20 @@ discard block |
||
1790 | 2010 | $columnList = array('module_srl', 'module'); |
1791 | 2011 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList); |
1792 | 2012 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
1793 | - if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted'); |
|
2013 | + if(!$grant->manager) { |
|
2014 | + return new BaseObject(-1,'msg_not_permitted'); |
|
2015 | + } |
|
1794 | 2016 | |
1795 | 2017 | $oDocumentModel = getModel('document'); |
1796 | 2018 | // Get original information |
1797 | 2019 | $category_info = $oDocumentModel->getCategory($args->category_srl); |
1798 | - if($category_info->parent_srl) $parent_srl = $category_info->parent_srl; |
|
2020 | + if($category_info->parent_srl) { |
|
2021 | + $parent_srl = $category_info->parent_srl; |
|
2022 | + } |
|
1799 | 2023 | // Display an error that the category cannot be deleted if it has a child node |
1800 | - if($oDocumentModel->getCategoryChlidCount($args->category_srl)) return new BaseObject(-1, 'msg_cannot_delete_for_child'); |
|
2024 | + if($oDocumentModel->getCategoryChlidCount($args->category_srl)) { |
|
2025 | + return new BaseObject(-1, 'msg_cannot_delete_for_child'); |
|
2026 | + } |
|
1801 | 2027 | // Remove from the DB |
1802 | 2028 | $output = $this->deleteCategory($args->category_srl); |
1803 | 2029 | if(!$output->toBool()) |
@@ -1831,7 +2057,9 @@ discard block |
||
1831 | 2057 | $columnList = array('module_srl', 'module'); |
1832 | 2058 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList); |
1833 | 2059 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
1834 | - if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted'); |
|
2060 | + if(!$grant->manager) { |
|
2061 | + return new BaseObject(-1,'msg_not_permitted'); |
|
2062 | + } |
|
1835 | 2063 | |
1836 | 2064 | $xml_file = $this->makeCategoryFile($module_srl); |
1837 | 2065 | // Set return value |
@@ -1846,7 +2074,9 @@ discard block |
||
1846 | 2074 | function makeCategoryFile($module_srl) |
1847 | 2075 | { |
1848 | 2076 | // Return if there is no information you need for creating a cache file |
1849 | - if(!$module_srl) return false; |
|
2077 | + if(!$module_srl) { |
|
2078 | + return false; |
|
2079 | + } |
|
1850 | 2080 | |
1851 | 2081 | $module_srl = (int)$module_srl; |
1852 | 2082 | |
@@ -1856,7 +2086,9 @@ discard block |
||
1856 | 2086 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList); |
1857 | 2087 | $mid = $module_info->mid; |
1858 | 2088 | |
1859 | - if(!is_dir('./files/cache/document_category')) FileHandler::makeDir('./files/cache/document_category'); |
|
2089 | + if(!is_dir('./files/cache/document_category')) { |
|
2090 | + FileHandler::makeDir('./files/cache/document_category'); |
|
2091 | + } |
|
1860 | 2092 | // Cache file's name |
1861 | 2093 | $xml_file = sprintf("./files/cache/document_category/%s.xml.php", $module_srl); |
1862 | 2094 | $php_file = sprintf("./files/cache/document_category/%s.php", $module_srl); |
@@ -1868,13 +2100,17 @@ discard block |
||
1868 | 2100 | |
1869 | 2101 | $category_list = $output->data; |
1870 | 2102 | |
1871 | - if(!is_array($category_list)) $category_list = array($category_list); |
|
2103 | + if(!is_array($category_list)) { |
|
2104 | + $category_list = array($category_list); |
|
2105 | + } |
|
1872 | 2106 | |
1873 | 2107 | $category_count = count($category_list); |
1874 | 2108 | for($i=0;$i<$category_count;$i++) |
1875 | 2109 | { |
1876 | 2110 | $category_srl = $category_list[$i]->category_srl; |
1877 | - if(!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) $category_list[$i]->group_srls = ''; |
|
2111 | + if(!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) { |
|
2112 | + $category_list[$i]->group_srls = ''; |
|
2113 | + } |
|
1878 | 2114 | $list[$category_srl] = $category_list[$i]; |
1879 | 2115 | } |
1880 | 2116 | // Create the xml file without node data if no data is obtained |
@@ -1886,7 +2122,9 @@ discard block |
||
1886 | 2122 | return $xml_file; |
1887 | 2123 | } |
1888 | 2124 | // Change to an array if only a single data is obtained |
1889 | - if(!is_array($list)) $list = array($list); |
|
2125 | + if(!is_array($list)) { |
|
2126 | + $list = array($list); |
|
2127 | + } |
|
1890 | 2128 | // Create a tree for loop |
1891 | 2129 | foreach($list as $category_srl => $node) |
1892 | 2130 | { |
@@ -1965,13 +2203,17 @@ discard block |
||
1965 | 2203 | */ |
1966 | 2204 | function getXmlTree($source_node, $tree, $site_srl, &$xml_header_buff) |
1967 | 2205 | { |
1968 | - if(!$source_node) return; |
|
2206 | + if(!$source_node) { |
|
2207 | + return; |
|
2208 | + } |
|
1969 | 2209 | |
1970 | 2210 | foreach($source_node as $category_srl => $node) |
1971 | 2211 | { |
1972 | 2212 | $child_buff = ""; |
1973 | 2213 | // Get data of the child nodes |
1974 | - if($category_srl && $tree[$category_srl]) $child_buff = $this->getXmlTree($tree[$category_srl], $tree, $site_srl, $xml_header_buff); |
|
2214 | + if($category_srl && $tree[$category_srl]) { |
|
2215 | + $child_buff = $this->getXmlTree($tree[$category_srl], $tree, $site_srl, $xml_header_buff); |
|
2216 | + } |
|
1975 | 2217 | // List variables |
1976 | 2218 | $expand = ($node->expand) ? $node->expand : 'N'; |
1977 | 2219 | $group_srls = ($node->group_srls) ? $node->group_srls : ''; |
@@ -1981,8 +2223,11 @@ discard block |
||
1981 | 2223 | $color = ($node->color) ? $node->color : ''; |
1982 | 2224 | $description = ($node->description) ? $node->description : ''; |
1983 | 2225 | // If node->group_srls value exists |
1984 | - if($group_srls) $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$group_srls); |
|
1985 | - else $group_check_code = "true"; |
|
2226 | + if($group_srls) { |
|
2227 | + $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$group_srls); |
|
2228 | + } else { |
|
2229 | + $group_check_code = "true"; |
|
2230 | + } |
|
1986 | 2231 | |
1987 | 2232 | $title = $node->title; |
1988 | 2233 | $oModuleAdminModel = getAdminModel('module'); |
@@ -2022,8 +2267,11 @@ discard block |
||
2022 | 2267 | $node->document_count |
2023 | 2268 | ); |
2024 | 2269 | |
2025 | - if($child_buff) $buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff); |
|
2026 | - else $buff .= sprintf('<node %s />', $attribute); |
|
2270 | + if($child_buff) { |
|
2271 | + $buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff); |
|
2272 | + } else { |
|
2273 | + $buff .= sprintf('<node %s />', $attribute); |
|
2274 | + } |
|
2027 | 2275 | } |
2028 | 2276 | return $buff; |
2029 | 2277 | } |
@@ -2042,7 +2290,9 @@ discard block |
||
2042 | 2290 | function getPhpCacheCode($source_node, $tree, $site_srl, &$php_header_buff) |
2043 | 2291 | { |
2044 | 2292 | $output = array("buff"=>"", "category_srl_list"=>array()); |
2045 | - if(!$source_node) return $output; |
|
2293 | + if(!$source_node) { |
|
2294 | + return $output; |
|
2295 | + } |
|
2046 | 2296 | |
2047 | 2297 | // Set to an arraty for looping and then generate php script codes to be included |
2048 | 2298 | foreach($source_node as $category_srl => $node) |
@@ -2141,7 +2391,9 @@ discard block |
||
2141 | 2391 | function addDocumentPopupMenu($url, $str, $icon = '', $target = 'self') |
2142 | 2392 | { |
2143 | 2393 | $document_popup_menu_list = Context::get('document_popup_menu_list'); |
2144 | - if(!is_array($document_popup_menu_list)) $document_popup_menu_list = array(); |
|
2394 | + if(!is_array($document_popup_menu_list)) { |
|
2395 | + $document_popup_menu_list = array(); |
|
2396 | + } |
|
2145 | 2397 | |
2146 | 2398 | $obj = new stdClass(); |
2147 | 2399 | $obj->url = $url; |
@@ -2159,7 +2411,9 @@ discard block |
||
2159 | 2411 | */ |
2160 | 2412 | function procDocumentAddCart() |
2161 | 2413 | { |
2162 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_permitted'); |
|
2414 | + if(!Context::get('is_logged')) { |
|
2415 | + return new BaseObject(-1, 'msg_not_permitted'); |
|
2416 | + } |
|
2163 | 2417 | |
2164 | 2418 | // Get document_srl |
2165 | 2419 | $srls = explode(',',Context::get('srls')); |
@@ -2167,11 +2421,15 @@ discard block |
||
2167 | 2421 | { |
2168 | 2422 | $srl = trim($srls[$i]); |
2169 | 2423 | |
2170 | - if(!$srl) continue; |
|
2424 | + if(!$srl) { |
|
2425 | + continue; |
|
2426 | + } |
|
2171 | 2427 | |
2172 | 2428 | $document_srls[] = $srl; |
2173 | 2429 | } |
2174 | - if(!count($document_srls)) return; |
|
2430 | + if(!count($document_srls)) { |
|
2431 | + return; |
|
2432 | + } |
|
2175 | 2433 | |
2176 | 2434 | // Get module_srl of the documents |
2177 | 2435 | $args = new stdClass; |
@@ -2179,14 +2437,18 @@ discard block |
||
2179 | 2437 | $args->document_srls = implode(',',$document_srls); |
2180 | 2438 | $args->order_type = 'asc'; |
2181 | 2439 | $output = executeQueryArray('document.getDocuments', $args); |
2182 | - if(!$output->data) return new BaseObject(); |
|
2440 | + if(!$output->data) { |
|
2441 | + return new BaseObject(); |
|
2442 | + } |
|
2183 | 2443 | |
2184 | 2444 | unset($document_srls); |
2185 | 2445 | foreach($output->data as $key => $val) |
2186 | 2446 | { |
2187 | 2447 | $document_srls[$val->module_srl][] = $val->document_srl; |
2188 | 2448 | } |
2189 | - if(!$document_srls || !count($document_srls)) return new BaseObject(); |
|
2449 | + if(!$document_srls || !count($document_srls)) { |
|
2450 | + return new BaseObject(); |
|
2451 | + } |
|
2190 | 2452 | |
2191 | 2453 | // Check if each of module administrators exists. Top-level administator will have a permission to modify every document of all modules.(Even to modify temporarily saved or trashed documents) |
2192 | 2454 | $oModuleModel = getModel('module'); |
@@ -2211,7 +2473,9 @@ discard block |
||
2211 | 2473 | } |
2212 | 2474 | } |
2213 | 2475 | } |
2214 | - if(!count($document_srls)) return new BaseObject(); |
|
2476 | + if(!count($document_srls)) { |
|
2477 | + return new BaseObject(); |
|
2478 | + } |
|
2215 | 2479 | |
2216 | 2480 | foreach($document_srls as $module_srl => $documents) |
2217 | 2481 | { |
@@ -2219,9 +2483,14 @@ discard block |
||
2219 | 2483 | for($i=0;$i<$cnt;$i++) |
2220 | 2484 | { |
2221 | 2485 | $document_srl = (int)trim($documents[$i]); |
2222 | - if(!$document_srls) continue; |
|
2223 | - if($_SESSION['document_management'][$document_srl]) unset($_SESSION['document_management'][$document_srl]); |
|
2224 | - else $_SESSION['document_management'][$document_srl] = true; |
|
2486 | + if(!$document_srls) { |
|
2487 | + continue; |
|
2488 | + } |
|
2489 | + if($_SESSION['document_management'][$document_srl]) { |
|
2490 | + unset($_SESSION['document_management'][$document_srl]); |
|
2491 | + } else { |
|
2492 | + $_SESSION['document_management'][$document_srl] = true; |
|
2493 | + } |
|
2225 | 2494 | } |
2226 | 2495 | } |
2227 | 2496 | } |
@@ -2233,7 +2502,9 @@ discard block |
||
2233 | 2502 | function procDocumentManageCheckedDocument() |
2234 | 2503 | { |
2235 | 2504 | @set_time_limit(0); |
2236 | - if(!Context::get('is_logged')) return new BaseObject(-1,'msg_not_permitted'); |
|
2505 | + if(!Context::get('is_logged')) { |
|
2506 | + return new BaseObject(-1,'msg_not_permitted'); |
|
2507 | + } |
|
2237 | 2508 | |
2238 | 2509 | if(!checkCSRF()) |
2239 | 2510 | { |
@@ -2243,10 +2514,14 @@ discard block |
||
2243 | 2514 | $type = Context::get('type'); |
2244 | 2515 | $target_module = Context::get('target_module_srl'); |
2245 | 2516 | $module_srl = Context::get('module_srl'); |
2246 | - if($target_module && !$module_srl) $module_srl = $target_module; |
|
2517 | + if($target_module && !$module_srl) { |
|
2518 | + $module_srl = $target_module; |
|
2519 | + } |
|
2247 | 2520 | $category_srl = Context::get('target_category_srl'); |
2248 | 2521 | $message_content = strip_tags(Context::get('message_content')); |
2249 | - if($message_content) $message_content = nl2br($message_content); |
|
2522 | + if($message_content) { |
|
2523 | + $message_content = nl2br($message_content); |
|
2524 | + } |
|
2250 | 2525 | |
2251 | 2526 | $cart = Context::get('cart'); |
2252 | 2527 | $document_srl_list = (!is_array($cart)) ? explode('|@|', $cart) : $cart; |
@@ -2261,7 +2536,9 @@ discard block |
||
2261 | 2536 | { |
2262 | 2537 | $oDocument = $oDocumentModel->getDocument($document_srl); |
2263 | 2538 | $document_items[] = $oDocument; |
2264 | - if(!$oDocument->isGranted()) return $this->stop('msg_not_permitted'); |
|
2539 | + if(!$oDocument->isGranted()) { |
|
2540 | + return $this->stop('msg_not_permitted'); |
|
2541 | + } |
|
2265 | 2542 | } |
2266 | 2543 | |
2267 | 2544 | // Send a message |
@@ -2277,10 +2554,15 @@ discard block |
||
2277 | 2554 | |
2278 | 2555 | foreach($document_items as $oDocument) |
2279 | 2556 | { |
2280 | - if(!$oDocument->get('member_srl') || $oDocument->get('member_srl')==$sender_member_srl) continue; |
|
2557 | + if(!$oDocument->get('member_srl') || $oDocument->get('member_srl')==$sender_member_srl) { |
|
2558 | + continue; |
|
2559 | + } |
|
2281 | 2560 | |
2282 | - if($type=='move') $purl = sprintf("<a href=\"%s\" target=\"_blank\">%s</a>", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl()); |
|
2283 | - else $purl = ""; |
|
2561 | + if($type=='move') { |
|
2562 | + $purl = sprintf("<a href=\"%s\" target=\"_blank\">%s</a>", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl()); |
|
2563 | + } else { |
|
2564 | + $purl = ""; |
|
2565 | + } |
|
2284 | 2566 | $content = sprintf("<div>%s</div><hr />%s<div style=\"font-weight:bold\">%s</div>%s",$message_content, $purl, $oDocument->getTitleText(), $oDocument->getContent(false, false, false)); |
2285 | 2567 | |
2286 | 2568 | $oCommunicationController->sendMessage($sender_member_srl, $oDocument->get('member_srl'), $title, $content, false); |
@@ -2293,24 +2575,30 @@ discard block |
||
2293 | 2575 | $oDocumentAdminController = getAdminController('document'); |
2294 | 2576 | if($type == 'move') |
2295 | 2577 | { |
2296 | - if(!$module_srl) return new BaseObject(-1, 'fail_to_move'); |
|
2578 | + if(!$module_srl) { |
|
2579 | + return new BaseObject(-1, 'fail_to_move'); |
|
2580 | + } |
|
2297 | 2581 | |
2298 | 2582 | $output = $oDocumentAdminController->moveDocumentModule($document_srl_list, $module_srl, $category_srl); |
2299 | - if(!$output->toBool()) return new BaseObject(-1, 'fail_to_move'); |
|
2583 | + if(!$output->toBool()) { |
|
2584 | + return new BaseObject(-1, 'fail_to_move'); |
|
2585 | + } |
|
2300 | 2586 | |
2301 | 2587 | $msg_code = 'success_moved'; |
2302 | 2588 | |
2303 | - } |
|
2304 | - else if($type == 'copy') |
|
2589 | + } else if($type == 'copy') |
|
2305 | 2590 | { |
2306 | - if(!$module_srl) return new BaseObject(-1, 'fail_to_move'); |
|
2591 | + if(!$module_srl) { |
|
2592 | + return new BaseObject(-1, 'fail_to_move'); |
|
2593 | + } |
|
2307 | 2594 | |
2308 | 2595 | $output = $oDocumentAdminController->copyDocumentModule($document_srl_list, $module_srl, $category_srl); |
2309 | - if(!$output->toBool()) return new BaseObject(-1, 'fail_to_move'); |
|
2596 | + if(!$output->toBool()) { |
|
2597 | + return new BaseObject(-1, 'fail_to_move'); |
|
2598 | + } |
|
2310 | 2599 | |
2311 | 2600 | $msg_code = 'success_copied'; |
2312 | - } |
|
2313 | - else if($type =='delete') |
|
2601 | + } else if($type =='delete') |
|
2314 | 2602 | { |
2315 | 2603 | $oDB = &DB::getInstance(); |
2316 | 2604 | $oDB->begin(); |
@@ -2318,12 +2606,13 @@ discard block |
||
2318 | 2606 | { |
2319 | 2607 | $document_srl = $document_srl_list[$i]; |
2320 | 2608 | $output = $this->deleteDocument($document_srl, true); |
2321 | - if(!$output->toBool()) return new BaseObject(-1, 'fail_to_delete'); |
|
2609 | + if(!$output->toBool()) { |
|
2610 | + return new BaseObject(-1, 'fail_to_delete'); |
|
2611 | + } |
|
2322 | 2612 | } |
2323 | 2613 | $oDB->commit(); |
2324 | 2614 | $msg_code = 'success_deleted'; |
2325 | - } |
|
2326 | - else if($type == 'trash') |
|
2615 | + } else if($type == 'trash') |
|
2327 | 2616 | { |
2328 | 2617 | $args = new stdClass(); |
2329 | 2618 | $args->description = $message_content; |
@@ -2333,12 +2622,13 @@ discard block |
||
2333 | 2622 | for($i=0;$i<$document_srl_count;$i++) { |
2334 | 2623 | $args->document_srl = $document_srl_list[$i]; |
2335 | 2624 | $output = $this->moveDocumentToTrash($args); |
2336 | - if(!$output || !$output->toBool()) return new BaseObject(-1, 'fail_to_trash'); |
|
2625 | + if(!$output || !$output->toBool()) { |
|
2626 | + return new BaseObject(-1, 'fail_to_trash'); |
|
2627 | + } |
|
2337 | 2628 | } |
2338 | 2629 | $oDB->commit(); |
2339 | 2630 | $msg_code = 'success_trashed'; |
2340 | - } |
|
2341 | - else if($type == 'cancelDeclare') |
|
2631 | + } else if($type == 'cancelDeclare') |
|
2342 | 2632 | { |
2343 | 2633 | $args->document_srl = $document_srl_list; |
2344 | 2634 | $output = executeQuery('document.deleteDeclaredDocuments', $args); |
@@ -2360,18 +2650,27 @@ discard block |
||
2360 | 2650 | function procDocumentInsertModuleConfig() |
2361 | 2651 | { |
2362 | 2652 | $module_srl = Context::get('target_module_srl'); |
2363 | - if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl); |
|
2364 | - else $module_srl = array($module_srl); |
|
2653 | + if(preg_match('/^([0-9,]+)$/',$module_srl)) { |
|
2654 | + $module_srl = explode(',',$module_srl); |
|
2655 | + } else { |
|
2656 | + $module_srl = array($module_srl); |
|
2657 | + } |
|
2365 | 2658 | |
2366 | 2659 | $document_config = new stdClass(); |
2367 | 2660 | $document_config->use_history = Context::get('use_history'); |
2368 | - if(!$document_config->use_history) $document_config->use_history = 'N'; |
|
2661 | + if(!$document_config->use_history) { |
|
2662 | + $document_config->use_history = 'N'; |
|
2663 | + } |
|
2369 | 2664 | |
2370 | 2665 | $document_config->use_vote_up = Context::get('use_vote_up'); |
2371 | - if(!$document_config->use_vote_up) $document_config->use_vote_up = 'Y'; |
|
2666 | + if(!$document_config->use_vote_up) { |
|
2667 | + $document_config->use_vote_up = 'Y'; |
|
2668 | + } |
|
2372 | 2669 | |
2373 | 2670 | $document_config->use_vote_down = Context::get('use_vote_down'); |
2374 | - if(!$document_config->use_vote_down) $document_config->use_vote_down = 'Y'; |
|
2671 | + if(!$document_config->use_vote_down) { |
|
2672 | + $document_config->use_vote_down = 'Y'; |
|
2673 | + } |
|
2375 | 2674 | |
2376 | 2675 | $document_config->use_status = Context::get('use_status'); |
2377 | 2676 | |
@@ -2379,7 +2678,9 @@ discard block |
||
2379 | 2678 | for($i=0;$i<count($module_srl);$i++) |
2380 | 2679 | { |
2381 | 2680 | $srl = trim($module_srl[$i]); |
2382 | - if(!$srl) continue; |
|
2681 | + if(!$srl) { |
|
2682 | + continue; |
|
2683 | + } |
|
2383 | 2684 | $output = $oModuleController->insertModulePartConfig('document',$srl,$document_config); |
2384 | 2685 | } |
2385 | 2686 | $this->setError(-1); |
@@ -2396,7 +2697,9 @@ discard block |
||
2396 | 2697 | function procDocumentTempSave() |
2397 | 2698 | { |
2398 | 2699 | // Check login information |
2399 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_logged'); |
|
2700 | + if(!Context::get('is_logged')) { |
|
2701 | + return new BaseObject(-1, 'msg_not_logged'); |
|
2702 | + } |
|
2400 | 2703 | $module_info = Context::get('module_info'); |
2401 | 2704 | $logged_info = Context::get('logged_info'); |
2402 | 2705 | |
@@ -2434,8 +2737,7 @@ discard block |
||
2434 | 2737 | $output = $oDocumentController->updateDocument($oDocument, $obj); |
2435 | 2738 | $msg_code = 'success_updated'; |
2436 | 2739 | // Otherwise, get a new |
2437 | - } |
|
2438 | - else |
|
2740 | + } else |
|
2439 | 2741 | { |
2440 | 2742 | $output = $oDocumentController->insertDocument($obj); |
2441 | 2743 | $msg_code = 'success_registed'; |
@@ -2461,17 +2763,20 @@ discard block |
||
2461 | 2763 | */ |
2462 | 2764 | function procDocumentGetList() |
2463 | 2765 | { |
2464 | - if(!Context::get('is_logged')) return new BaseObject(-1,'msg_not_permitted'); |
|
2766 | + if(!Context::get('is_logged')) { |
|
2767 | + return new BaseObject(-1,'msg_not_permitted'); |
|
2768 | + } |
|
2465 | 2769 | $documentSrls = Context::get('document_srls'); |
2466 | - if($documentSrls) $documentSrlList = explode(',', $documentSrls); |
|
2770 | + if($documentSrls) { |
|
2771 | + $documentSrlList = explode(',', $documentSrls); |
|
2772 | + } |
|
2467 | 2773 | |
2468 | 2774 | if(count($documentSrlList) > 0) |
2469 | 2775 | { |
2470 | 2776 | $oDocumentModel = getModel('document'); |
2471 | 2777 | $columnList = array('document_srl', 'title', 'nick_name', 'status'); |
2472 | 2778 | $documentList = $oDocumentModel->getDocuments($documentSrlList, $this->grant->is_admin, false, $columnList); |
2473 | - } |
|
2474 | - else |
|
2779 | + } else |
|
2475 | 2780 | { |
2476 | 2781 | global $lang; |
2477 | 2782 | $documentList = array(); |
@@ -2489,11 +2794,18 @@ discard block |
||
2489 | 2794 | */ |
2490 | 2795 | function _checkCommentStatusForOldVersion(&$obj) |
2491 | 2796 | { |
2492 | - if(!isset($obj->allow_comment)) $obj->allow_comment = 'N'; |
|
2493 | - if(!isset($obj->lock_comment)) $obj->lock_comment = 'N'; |
|
2797 | + if(!isset($obj->allow_comment)) { |
|
2798 | + $obj->allow_comment = 'N'; |
|
2799 | + } |
|
2800 | + if(!isset($obj->lock_comment)) { |
|
2801 | + $obj->lock_comment = 'N'; |
|
2802 | + } |
|
2494 | 2803 | |
2495 | - if($obj->allow_comment == 'Y' && $obj->lock_comment == 'N') $obj->commentStatus = 'ALLOW'; |
|
2496 | - else $obj->commentStatus = 'DENY'; |
|
2804 | + if($obj->allow_comment == 'Y' && $obj->lock_comment == 'N') { |
|
2805 | + $obj->commentStatus = 'ALLOW'; |
|
2806 | + } else { |
|
2807 | + $obj->commentStatus = 'DENY'; |
|
2808 | + } |
|
2497 | 2809 | } |
2498 | 2810 | |
2499 | 2811 | /** |
@@ -2503,8 +2815,12 @@ discard block |
||
2503 | 2815 | */ |
2504 | 2816 | function _checkDocumentStatusForOldVersion(&$obj) |
2505 | 2817 | { |
2506 | - if(!$obj->status && $obj->is_secret == 'Y') $obj->status = $this->getConfigStatus('secret'); |
|
2507 | - if(!$obj->status && $obj->is_secret != 'Y') $obj->status = $this->getConfigStatus('public'); |
|
2818 | + if(!$obj->status && $obj->is_secret == 'Y') { |
|
2819 | + $obj->status = $this->getConfigStatus('secret'); |
|
2820 | + } |
|
2821 | + if(!$obj->status && $obj->is_secret != 'Y') { |
|
2822 | + $obj->status = $this->getConfigStatus('public'); |
|
2823 | + } |
|
2508 | 2824 | } |
2509 | 2825 | |
2510 | 2826 | public function updateUploaedCount($documentSrlList) |
@@ -47,28 +47,28 @@ discard block |
||
47 | 47 | { |
48 | 48 | $component = Context::get('component'); |
49 | 49 | $method = Context::get('method'); |
50 | - if(!$component) return new BaseObject(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
50 | + if (!$component) return new BaseObject(-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 BaseObject(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
56 | + if (!method_exists($oComponent, $method)) return new BaseObject(-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 BaseObject(-1,sprintf('%s method is not exists', $method)); |
|
60 | + if (method_exists($oComponent, $method)) $output = $oComponent->{$method}(); |
|
61 | + else return new BaseObject(-1, sprintf('%s method is not exists', $method)); |
|
62 | 62 | |
63 | - if((is_a($output, 'BaseObject') || is_subclass_of($output, 'BaseObject')) && !$output->toBool()) return $output; |
|
63 | + if ((is_a($output, 'BaseObject') || is_subclass_of($output, 'BaseObject')) && !$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 |
||
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 BaseObject(-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 BaseObject(-1, 'msg_not_permitted'); |
103 | 103 | } |
@@ -111,32 +111,32 @@ discard block |
||
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 |
||
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 |
||
169 | 169 | */ |
170 | 170 | function triggerEditorComponentCompile(&$content) |
171 | 171 | { |
172 | - if(Context::getResponseMethod()!='HTML') return new BaseObject(); |
|
172 | + if (Context::getResponseMethod() != 'HTML') return new BaseObject(); |
|
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 |
||
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 |
||
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 |
||
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,26 +259,26 @@ discard block |
||
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; |
|
262 | + if (!$args->document_srl) $args->document_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
263 | 263 | |
264 | 264 | // Get the current module if module_srl doesn't exist |
265 | - if(!$args->module_srl) $args->module_srl = Context::get('module_srl'); |
|
266 | - if(!$args->module_srl) |
|
265 | + if (!$args->module_srl) $args->module_srl = Context::get('module_srl'); |
|
266 | + if (!$args->module_srl) |
|
267 | 267 | { |
268 | 268 | $current_module_info = Context::get('current_module_info'); |
269 | 269 | $args->module_srl = $current_module_info->module_srl; |
270 | 270 | } |
271 | 271 | |
272 | - if(Context::get('is_logged')) |
|
272 | + if (Context::get('is_logged')) |
|
273 | 273 | { |
274 | 274 | $logged_info = Context::get('logged_info'); |
275 | 275 | $args->member_srl = $logged_info->member_srl; |
276 | 276 | } |
277 | 277 | else |
278 | 278 | { |
279 | - $args->certify_key = $_COOKIE['autosave_certify_key_' . $args->module_srl]; |
|
280 | - if(!$args->certify_key) $args->certify_key = Password::createSecureSalt(40); |
|
281 | - setcookie('autosave_certify_key_' . $args->module_srl, $args->certify_key, $_SERVER['REQUEST_TIME'] + 3600, '', '', false, true); |
|
279 | + $args->certify_key = $_COOKIE['autosave_certify_key_'.$args->module_srl]; |
|
280 | + if (!$args->certify_key) $args->certify_key = Password::createSecureSalt(40); |
|
281 | + setcookie('autosave_certify_key_'.$args->module_srl, $args->certify_key, $_SERVER['REQUEST_TIME'] + 3600, '', '', false, true); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | return executeQuery('editor.insertSavedDoc', $args); |
@@ -324,22 +324,22 @@ discard block |
||
324 | 324 | $args->module_srl = Context::get('module_srl'); |
325 | 325 | |
326 | 326 | // Get the current module if module_srl doesn't exist |
327 | - if(!$args->module_srl) |
|
327 | + if (!$args->module_srl) |
|
328 | 328 | { |
329 | 329 | $current_module_info = Context::get('current_module_info'); |
330 | 330 | $args->module_srl = $current_module_info->module_srl; |
331 | 331 | } |
332 | - if(Context::get('is_logged')) |
|
332 | + if (Context::get('is_logged')) |
|
333 | 333 | { |
334 | 334 | $logged_info = Context::get('logged_info'); |
335 | 335 | $args->member_srl = $logged_info->member_srl; |
336 | 336 | } |
337 | 337 | else |
338 | 338 | { |
339 | - $args->certify_key = $_COOKIE['autosave_certify_key_' . $args->module_srl]; |
|
339 | + $args->certify_key = $_COOKIE['autosave_certify_key_'.$args->module_srl]; |
|
340 | 340 | // @see https://github.com/xpressengine/xe-core/issues/2208 |
341 | 341 | // 변경 이전에 작성된 게시물 호환성 유지 |
342 | - if(!$args->certify_key) { |
|
342 | + if (!$args->certify_key) { |
|
343 | 343 | unset($args->certify_key); |
344 | 344 | $args->ipaddress = $_SERVER['REMOTE_ADDR']; |
345 | 345 | } |
@@ -347,13 +347,13 @@ discard block |
||
347 | 347 | // Check if the auto-saved document already exists |
348 | 348 | $output = executeQuery('editor.getSavedDocument', $args); |
349 | 349 | $saved_doc = $output->data; |
350 | - if(!$saved_doc) return; |
|
350 | + if (!$saved_doc) return; |
|
351 | 351 | |
352 | 352 | $oDocumentModel = getModel('document'); |
353 | 353 | $oSaved = $oDocumentModel->getDocument($saved_doc->document_srl); |
354 | - if(!$oSaved->isExists()) |
|
354 | + if (!$oSaved->isExists()) |
|
355 | 355 | { |
356 | - if($mode) |
|
356 | + if ($mode) |
|
357 | 357 | { |
358 | 358 | $output = executeQuery('editor.getSavedDocument', $args); |
359 | 359 | $output = ModuleHandler::triggerCall('editor.deleteSavedDoc', 'after', $saved_doc); |
@@ -382,9 +382,9 @@ discard block |
||
382 | 382 | $oEditorModel = getModel('editor'); |
383 | 383 | $args = new stdClass; |
384 | 384 | |
385 | - if($filter_enabled) $args->enabled = "Y"; |
|
385 | + if ($filter_enabled) $args->enabled = "Y"; |
|
386 | 386 | |
387 | - if($site_srl) |
|
387 | + if ($site_srl) |
|
388 | 388 | { |
389 | 389 | $args->site_srl = $site_srl; |
390 | 390 | $output = executeQuery('editor.getSiteComponentList', $args); |
@@ -397,10 +397,10 @@ discard block |
||
397 | 397 | |
398 | 398 | // Get information about log-in status and its group |
399 | 399 | $is_logged = Context::get('is_logged'); |
400 | - if($is_logged) |
|
400 | + if ($is_logged) |
|
401 | 401 | { |
402 | 402 | $logged_info = Context::get('logged_info'); |
403 | - if($logged_info->group_list && is_array($logged_info->group_list)) |
|
403 | + if ($logged_info->group_list && is_array($logged_info->group_list)) |
|
404 | 404 | { |
405 | 405 | $group_list = array_keys($logged_info->group_list); |
406 | 406 | } |
@@ -408,30 +408,30 @@ discard block |
||
408 | 408 | } |
409 | 409 | |
410 | 410 | // Get xml information for looping DB list |
411 | - if(!is_array($db_list)) $db_list = array($db_list); |
|
411 | + if (!is_array($db_list)) $db_list = array($db_list); |
|
412 | 412 | $component_list = new stdClass(); |
413 | - foreach($db_list as $component) |
|
413 | + foreach ($db_list as $component) |
|
414 | 414 | { |
415 | - if(in_array($component->component_name, array('colorpicker_text','colorpicker_bg'))) continue; |
|
415 | + if (in_array($component->component_name, array('colorpicker_text', 'colorpicker_bg'))) continue; |
|
416 | 416 | |
417 | 417 | $component_name = $component->component_name; |
418 | - if(!$component_name) continue; |
|
418 | + if (!$component_name) continue; |
|
419 | 419 | |
420 | - if(!in_array($component_name, $downloaded_list)) continue; |
|
420 | + if (!in_array($component_name, $downloaded_list)) continue; |
|
421 | 421 | |
422 | 422 | unset($xml_info); |
423 | 423 | $xml_info = $oEditorModel->getComponentXmlInfo($component_name); |
424 | 424 | $xml_info->enabled = $component->enabled; |
425 | 425 | |
426 | - if($component->extra_vars) |
|
426 | + if ($component->extra_vars) |
|
427 | 427 | { |
428 | 428 | $extra_vars = unserialize($component->extra_vars); |
429 | - if($extra_vars->target_group) |
|
429 | + if ($extra_vars->target_group) |
|
430 | 430 | { |
431 | 431 | $xml_info->target_group = $extra_vars->target_group; |
432 | 432 | } |
433 | 433 | |
434 | - if($extra_vars->mid_list && count($extra_vars->mid_list)) |
|
434 | + if ($extra_vars->mid_list && count($extra_vars->mid_list)) |
|
435 | 435 | { |
436 | 436 | $xml_info->mid_list = $extra_vars->mid_list; |
437 | 437 | } |
@@ -458,9 +458,9 @@ discard block |
||
458 | 458 | if(!in_array(Context::get('mid'), $extra_vars->mid_list)) continue; |
459 | 459 | }*/ |
460 | 460 | // Check the configuration of the editor component |
461 | - if($xml_info->extra_vars) |
|
461 | + if ($xml_info->extra_vars) |
|
462 | 462 | { |
463 | - foreach($xml_info->extra_vars as $key => $val) |
|
463 | + foreach ($xml_info->extra_vars as $key => $val) |
|
464 | 464 | { |
465 | 465 | $xml_info->extra_vars->{$key}->value = $extra_vars->{$key}; |
466 | 466 | } |
@@ -471,19 +471,19 @@ discard block |
||
471 | 471 | // Get buttons, icons, images |
472 | 472 | $icon_file = _XE_PATH_.'modules/editor/components/'.$component_name.'/icon.gif'; |
473 | 473 | $component_icon_file = _XE_PATH_.'modules/editor/components/'.$component_name.'/component_icon.gif'; |
474 | - if(file_exists($icon_file)) $component_list->{$component_name}->icon = true; |
|
475 | - if(file_exists($component_icon_file)) $component_list->{$component_name}->component_icon = true; |
|
474 | + if (file_exists($icon_file)) $component_list->{$component_name}->icon = true; |
|
475 | + if (file_exists($component_icon_file)) $component_list->{$component_name}->component_icon = true; |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | // Return if it checks enabled only |
479 | - if(!$filter_enabled) { |
|
479 | + if (!$filter_enabled) { |
|
480 | 480 | // Get xml_info of downloaded list |
481 | - foreach($downloaded_list as $component_name) |
|
481 | + foreach ($downloaded_list as $component_name) |
|
482 | 482 | { |
483 | - if(!is_dir(_XE_PATH_.'modules/editor/components/'.$component_name)) continue; |
|
484 | - if(in_array($component_name, array('colorpicker_text','colorpicker_bg'))) continue; |
|
483 | + if (!is_dir(_XE_PATH_.'modules/editor/components/'.$component_name)) continue; |
|
484 | + if (in_array($component_name, array('colorpicker_text', 'colorpicker_bg'))) continue; |
|
485 | 485 | // Pass if configured |
486 | - if($component_list->{$component_name}) continue; |
|
486 | + if ($component_list->{$component_name}) continue; |
|
487 | 487 | // Insert data into the DB |
488 | 488 | $oEditorController = getAdminController('editor'); |
489 | 489 | $oEditorController->insertComponent($component_name, false, $site_srl); |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | } |
498 | 498 | |
499 | 499 | $oCacheHandler = CacheHandler::getInstance('object', null, true); |
500 | - if($oCacheHandler->isSupport()) { |
|
500 | + if ($oCacheHandler->isSupport()) { |
|
501 | 501 | $cache_key = $oEditorModel->getComponentListCacheKey($filter_enabled, $site_srl); |
502 | 502 | $oCacheHandler->put($cache_key, $component_list); |
503 | 503 | } |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | FileHandler::removeFile($oEditorModel->getCacheFile(false, $site_srl)); |
516 | 516 | |
517 | 517 | $oCacheHandler = CacheHandler::getInstance('object', null, true); |
518 | - if($oCacheHandler->isSupport()) { |
|
518 | + if ($oCacheHandler->isSupport()) { |
|
519 | 519 | $cache_key = $oEditorModel->getComponentListCacheKey(true, $site_srl); |
520 | 520 | $oCacheHandler->delete($cache_key); |
521 | 521 | $cache_key = $oEditorModel->getComponentListCacheKey(false, $site_srl); |
@@ -529,9 +529,9 @@ discard block |
||
529 | 529 | $editorConfig = $oModuleModel->getModulePartConfig('editor', $obj->originModuleSrl); |
530 | 530 | |
531 | 531 | $oModuleController = getController('module'); |
532 | - if(is_array($obj->moduleSrlList)) |
|
532 | + if (is_array($obj->moduleSrlList)) |
|
533 | 533 | { |
534 | - foreach($obj->moduleSrlList AS $key=>$moduleSrl) |
|
534 | + foreach ($obj->moduleSrlList AS $key=>$moduleSrl) |
|
535 | 535 | { |
536 | 536 | $oModuleController->insertModulePartConfig('editor', $moduleSrl, $editorConfig); |
537 | 537 | } |
@@ -47,20 +47,31 @@ discard block |
||
47 | 47 | { |
48 | 48 | $component = Context::get('component'); |
49 | 49 | $method = Context::get('method'); |
50 | - if(!$component) return new BaseObject(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
50 | + if(!$component) { |
|
51 | + return new BaseObject(-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 BaseObject(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
60 | + if(!method_exists($oComponent, $method)) { |
|
61 | + return new BaseObject(-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 BaseObject(-1,sprintf('%s method is not exists', $method)); |
|
66 | + if(method_exists($oComponent, $method)) { |
|
67 | + $output = $oComponent->{$method}(); |
|
68 | + } else { |
|
69 | + return new BaseObject(-1,sprintf('%s method is not exists', $method)); |
|
70 | + } |
|
62 | 71 | |
63 | - if((is_a($output, 'BaseObject') || is_subclass_of($output, 'BaseObject')) && !$output->toBool()) return $output; |
|
72 | + if((is_a($output, 'BaseObject') || is_subclass_of($output, 'BaseObject')) && !$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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
169 | 186 | */ |
170 | 187 | function triggerEditorComponentCompile(&$content) |
171 | 188 | { |
172 | - if(Context::getResponseMethod()!='HTML') return new BaseObject(); |
|
189 | + if(Context::getResponseMethod()!='HTML') { |
|
190 | + return new BaseObject(); |
|
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 |
||
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 |
||
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 |
||
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,10 +289,14 @@ discard block |
||
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 | |
264 | 296 | // Get the current module if module_srl doesn't exist |
265 | - if(!$args->module_srl) $args->module_srl = Context::get('module_srl'); |
|
297 | + if(!$args->module_srl) { |
|
298 | + $args->module_srl = Context::get('module_srl'); |
|
299 | + } |
|
266 | 300 | if(!$args->module_srl) |
267 | 301 | { |
268 | 302 | $current_module_info = Context::get('current_module_info'); |
@@ -273,11 +307,12 @@ discard block |
||
273 | 307 | { |
274 | 308 | $logged_info = Context::get('logged_info'); |
275 | 309 | $args->member_srl = $logged_info->member_srl; |
276 | - } |
|
277 | - else |
|
310 | + } else |
|
278 | 311 | { |
279 | 312 | $args->certify_key = $_COOKIE['autosave_certify_key_' . $args->module_srl]; |
280 | - if(!$args->certify_key) $args->certify_key = Password::createSecureSalt(40); |
|
313 | + if(!$args->certify_key) { |
|
314 | + $args->certify_key = Password::createSecureSalt(40); |
|
315 | + } |
|
281 | 316 | setcookie('autosave_certify_key_' . $args->module_srl, $args->certify_key, $_SERVER['REQUEST_TIME'] + 3600, '', '', false, true); |
282 | 317 | } |
283 | 318 | |
@@ -333,8 +368,7 @@ discard block |
||
333 | 368 | { |
334 | 369 | $logged_info = Context::get('logged_info'); |
335 | 370 | $args->member_srl = $logged_info->member_srl; |
336 | - } |
|
337 | - else |
|
371 | + } else |
|
338 | 372 | { |
339 | 373 | $args->certify_key = $_COOKIE['autosave_certify_key_' . $args->module_srl]; |
340 | 374 | // @see https://github.com/xpressengine/xe-core/issues/2208 |
@@ -347,7 +381,9 @@ discard block |
||
347 | 381 | // Check if the auto-saved document already exists |
348 | 382 | $output = executeQuery('editor.getSavedDocument', $args); |
349 | 383 | $saved_doc = $output->data; |
350 | - if(!$saved_doc) return; |
|
384 | + if(!$saved_doc) { |
|
385 | + return; |
|
386 | + } |
|
351 | 387 | |
352 | 388 | $oDocumentModel = getModel('document'); |
353 | 389 | $oSaved = $oDocumentModel->getDocument($saved_doc->document_srl); |
@@ -382,14 +418,17 @@ discard block |
||
382 | 418 | $oEditorModel = getModel('editor'); |
383 | 419 | $args = new stdClass; |
384 | 420 | |
385 | - if($filter_enabled) $args->enabled = "Y"; |
|
421 | + if($filter_enabled) { |
|
422 | + $args->enabled = "Y"; |
|
423 | + } |
|
386 | 424 | |
387 | 425 | if($site_srl) |
388 | 426 | { |
389 | 427 | $args->site_srl = $site_srl; |
390 | 428 | $output = executeQuery('editor.getSiteComponentList', $args); |
429 | + } else { |
|
430 | + $output = executeQuery('editor.getComponentList', $args); |
|
391 | 431 | } |
392 | - else $output = executeQuery('editor.getComponentList', $args); |
|
393 | 432 | $db_list = $output->data; |
394 | 433 | |
395 | 434 | // Get a list of files |
@@ -403,21 +442,30 @@ discard block |
||
403 | 442 | if($logged_info->group_list && is_array($logged_info->group_list)) |
404 | 443 | { |
405 | 444 | $group_list = array_keys($logged_info->group_list); |
445 | + } else { |
|
446 | + $group_list = array(); |
|
406 | 447 | } |
407 | - else $group_list = array(); |
|
408 | 448 | } |
409 | 449 | |
410 | 450 | // Get xml information for looping DB list |
411 | - if(!is_array($db_list)) $db_list = array($db_list); |
|
451 | + if(!is_array($db_list)) { |
|
452 | + $db_list = array($db_list); |
|
453 | + } |
|
412 | 454 | $component_list = new stdClass(); |
413 | 455 | foreach($db_list as $component) |
414 | 456 | { |
415 | - if(in_array($component->component_name, array('colorpicker_text','colorpicker_bg'))) continue; |
|
457 | + if(in_array($component->component_name, array('colorpicker_text','colorpicker_bg'))) { |
|
458 | + continue; |
|
459 | + } |
|
416 | 460 | |
417 | 461 | $component_name = $component->component_name; |
418 | - if(!$component_name) continue; |
|
462 | + if(!$component_name) { |
|
463 | + continue; |
|
464 | + } |
|
419 | 465 | |
420 | - if(!in_array($component_name, $downloaded_list)) continue; |
|
466 | + if(!in_array($component_name, $downloaded_list)) { |
|
467 | + continue; |
|
468 | + } |
|
421 | 469 | |
422 | 470 | unset($xml_info); |
423 | 471 | $xml_info = $oEditorModel->getComponentXmlInfo($component_name); |
@@ -471,8 +519,12 @@ discard block |
||
471 | 519 | // Get buttons, icons, images |
472 | 520 | $icon_file = _XE_PATH_.'modules/editor/components/'.$component_name.'/icon.gif'; |
473 | 521 | $component_icon_file = _XE_PATH_.'modules/editor/components/'.$component_name.'/component_icon.gif'; |
474 | - if(file_exists($icon_file)) $component_list->{$component_name}->icon = true; |
|
475 | - if(file_exists($component_icon_file)) $component_list->{$component_name}->component_icon = true; |
|
522 | + if(file_exists($icon_file)) { |
|
523 | + $component_list->{$component_name}->icon = true; |
|
524 | + } |
|
525 | + if(file_exists($component_icon_file)) { |
|
526 | + $component_list->{$component_name}->component_icon = true; |
|
527 | + } |
|
476 | 528 | } |
477 | 529 | |
478 | 530 | // Return if it checks enabled only |
@@ -480,10 +532,16 @@ discard block |
||
480 | 532 | // Get xml_info of downloaded list |
481 | 533 | foreach($downloaded_list as $component_name) |
482 | 534 | { |
483 | - if(!is_dir(_XE_PATH_.'modules/editor/components/'.$component_name)) continue; |
|
484 | - if(in_array($component_name, array('colorpicker_text','colorpicker_bg'))) continue; |
|
535 | + if(!is_dir(_XE_PATH_.'modules/editor/components/'.$component_name)) { |
|
536 | + continue; |
|
537 | + } |
|
538 | + if(in_array($component_name, array('colorpicker_text','colorpicker_bg'))) { |
|
539 | + continue; |
|
540 | + } |
|
485 | 541 | // Pass if configured |
486 | - if($component_list->{$component_name}) continue; |
|
542 | + if($component_list->{$component_name}) { |
|
543 | + continue; |
|
544 | + } |
|
487 | 545 | // Insert data into the DB |
488 | 546 | $oEditorController = getAdminController('editor'); |
489 | 547 | $oEditorController->insertComponent($component_name, false, $site_srl); |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | function getEditorConfig($module_srl = null) |
25 | 25 | { |
26 | - if(!$GLOBALS['__editor_module_config__'][$module_srl] && $module_srl) |
|
26 | + if (!$GLOBALS['__editor_module_config__'][$module_srl] && $module_srl) |
|
27 | 27 | { |
28 | 28 | // Get trackback settings of the selected module |
29 | 29 | $oModuleModel = getModel('module'); |
@@ -34,55 +34,55 @@ discard block |
||
34 | 34 | $oModuleModel = getModel('module'); |
35 | 35 | $editor_default_config = $oModuleModel->getModuleConfig('editor'); |
36 | 36 | |
37 | - if(!is_object($editor_config)) $editor_config = new stdClass(); |
|
37 | + if (!is_object($editor_config)) $editor_config = new stdClass(); |
|
38 | 38 | |
39 | - if($editor_config->enable_autosave != 'N') $editor_config->enable_autosave = 'Y'; |
|
40 | - if(!is_array($editor_config->enable_html_grant)) $editor_config->enable_html_grant = array(); |
|
41 | - if(!is_array($editor_config->enable_comment_html_grant)) $editor_config->enable_comment_html_grant = array(); |
|
42 | - if(!is_array($editor_config->upload_file_grant)) $editor_config->upload_file_grant = array(); |
|
43 | - if(!is_array($editor_config->comment_upload_file_grant)) $editor_config->comment_upload_file_grant = array(); |
|
44 | - if(!is_array($editor_config->enable_default_component_grant)) $editor_config->enable_default_component_grant = array(); |
|
45 | - if(!is_array($editor_config->enable_comment_default_component_grant)) $editor_config->enable_comment_default_component_grant = array(); |
|
46 | - if(!is_array($editor_config->enable_component_grant)) $editor_config->enable_component_grant = array(); |
|
47 | - if(!is_array($editor_config->enable_comment_component_grant)) $editor_config->enable_comment_component_grant= array(); |
|
39 | + if ($editor_config->enable_autosave != 'N') $editor_config->enable_autosave = 'Y'; |
|
40 | + if (!is_array($editor_config->enable_html_grant)) $editor_config->enable_html_grant = array(); |
|
41 | + if (!is_array($editor_config->enable_comment_html_grant)) $editor_config->enable_comment_html_grant = array(); |
|
42 | + if (!is_array($editor_config->upload_file_grant)) $editor_config->upload_file_grant = array(); |
|
43 | + if (!is_array($editor_config->comment_upload_file_grant)) $editor_config->comment_upload_file_grant = array(); |
|
44 | + if (!is_array($editor_config->enable_default_component_grant)) $editor_config->enable_default_component_grant = array(); |
|
45 | + if (!is_array($editor_config->enable_comment_default_component_grant)) $editor_config->enable_comment_default_component_grant = array(); |
|
46 | + if (!is_array($editor_config->enable_component_grant)) $editor_config->enable_component_grant = array(); |
|
47 | + if (!is_array($editor_config->enable_comment_component_grant)) $editor_config->enable_comment_component_grant = array(); |
|
48 | 48 | |
49 | - if(!$editor_config->editor_height) |
|
49 | + if (!$editor_config->editor_height) |
|
50 | 50 | { |
51 | 51 | $editor_config->editor_height = ($editor_default_config->editor_height) ? $editor_default_config->editor_height : 500; |
52 | 52 | } |
53 | - if(!$editor_config->comment_editor_height) |
|
53 | + if (!$editor_config->comment_editor_height) |
|
54 | 54 | { |
55 | 55 | $editor_config->comment_editor_height = ($editor_default_config->comment_editor_height) ? $editor_default_config->comment_editor_height : 120; |
56 | 56 | } |
57 | - if(!$editor_config->editor_skin) |
|
57 | + if (!$editor_config->editor_skin) |
|
58 | 58 | { |
59 | 59 | $editor_config->editor_skin = ($editor_default_config->editor_skin) ? $editor_default_config->editor_skin : 'ckeditor'; |
60 | 60 | } |
61 | - if(!$editor_config->comment_editor_skin) |
|
61 | + if (!$editor_config->comment_editor_skin) |
|
62 | 62 | { |
63 | 63 | $editor_config->comment_editor_skin = ($editor_default_config->comment_editor_skin) ? $editor_default_config->comment_editor_skin : 'ckeditor'; |
64 | 64 | } |
65 | - if(!$editor_config->content_style) |
|
65 | + if (!$editor_config->content_style) |
|
66 | 66 | { |
67 | 67 | $editor_config->content_style = ($editor_default_config->content_style) ? $editor_default_config->content_style : 'ckeditor_light'; |
68 | 68 | } |
69 | - if(!$editor_config->content_font && $editor_default_config->content_font) |
|
69 | + if (!$editor_config->content_font && $editor_default_config->content_font) |
|
70 | 70 | { |
71 | 71 | $editor_config->content_font = $editor_default_config->content_font; |
72 | 72 | } |
73 | - if(!$editor_config->content_font_size && $editor_default_config->content_font_size) |
|
73 | + if (!$editor_config->content_font_size && $editor_default_config->content_font_size) |
|
74 | 74 | { |
75 | 75 | $editor_config->content_font_size = $editor_default_config->content_font_size; |
76 | 76 | } |
77 | - if(!$editor_config->sel_editor_colorset && $editor_default_config->sel_editor_colorset) |
|
77 | + if (!$editor_config->sel_editor_colorset && $editor_default_config->sel_editor_colorset) |
|
78 | 78 | { |
79 | 79 | $editor_config->sel_editor_colorset = $editor_default_config->sel_editor_colorset; |
80 | 80 | } |
81 | - if(!$editor_config->sel_comment_editor_colorset && $editor_default_config->sel_comment_editor_colorset) |
|
81 | + if (!$editor_config->sel_comment_editor_colorset && $editor_default_config->sel_comment_editor_colorset) |
|
82 | 82 | { |
83 | 83 | $editor_config->sel_comment_editor_colorset = $editor_default_config->sel_comment_editor_colorset; |
84 | 84 | } |
85 | - if(!$editor_config->comment_content_style && $editor_default_config->comment_content_style) |
|
85 | + if (!$editor_config->comment_content_style && $editor_default_config->comment_content_style) |
|
86 | 86 | { |
87 | 87 | $editor_config->comment_content_style = $editor_default_config->comment_content_style; |
88 | 88 | } |
@@ -92,25 +92,25 @@ discard block |
||
92 | 92 | |
93 | 93 | function loadDrComponents() |
94 | 94 | { |
95 | - $drComponentPath = _XE_PATH_ . 'modules/editor/skins/dreditor/drcomponents/'; |
|
95 | + $drComponentPath = _XE_PATH_.'modules/editor/skins/dreditor/drcomponents/'; |
|
96 | 96 | $drComponentList = FileHandler::readDir($drComponentPath); |
97 | 97 | |
98 | 98 | $oTemplate = &TemplateHandler::getInstance(); |
99 | 99 | |
100 | 100 | $drComponentInfo = array(); |
101 | - if($drComponentList) |
|
101 | + if ($drComponentList) |
|
102 | 102 | { |
103 | - foreach($drComponentList as $i => $drComponent) |
|
103 | + foreach ($drComponentList as $i => $drComponent) |
|
104 | 104 | { |
105 | 105 | unset($obj); |
106 | 106 | $obj = $this->getDrComponentXmlInfo($drComponent); |
107 | - Context::loadLang(sprintf('%s%s/lang/',$drComponentPath,$drComponent)); |
|
108 | - $path = sprintf('%s%s/tpl/',$drComponentPath,$drComponent); |
|
109 | - $obj->html = $oTemplate->compile($path,$drComponent); |
|
107 | + Context::loadLang(sprintf('%s%s/lang/', $drComponentPath, $drComponent)); |
|
108 | + $path = sprintf('%s%s/tpl/', $drComponentPath, $drComponent); |
|
109 | + $obj->html = $oTemplate->compile($path, $drComponent); |
|
110 | 110 | $drComponentInfo[$drComponent] = $obj; |
111 | 111 | } |
112 | 112 | } |
113 | - Context::set('drComponentList',$drComponentInfo); |
|
113 | + Context::set('drComponentList', $drComponentInfo); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | function getDrComponentXmlInfo($drComponentName) |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | $xml_file = sprintf('%sinfo.xml', $component_path); |
123 | 123 | $cache_file = sprintf('./files/cache/editor/dr_%s.%s.php', $drComponentName, $lang_type); |
124 | 124 | // Return information after including it after cached xml file exists |
125 | - if(file_exists($cache_file) && file_exists($xml_file) && filemtime($cache_file) > filemtime($xml_file)) |
|
125 | + if (file_exists($cache_file) && file_exists($xml_file) && filemtime($cache_file) > filemtime($xml_file)) |
|
126 | 126 | { |
127 | 127 | include($cache_file); |
128 | 128 | return $xml_info; |
@@ -151,10 +151,10 @@ discard block |
||
151 | 151 | $buff .= sprintf('$xml_info->license_link = "%s";', $component_info->license_link); |
152 | 152 | |
153 | 153 | // Author information |
154 | - if(!is_array($xml_doc->component->author)) $author_list[] = $xml_doc->component->author; |
|
154 | + if (!is_array($xml_doc->component->author)) $author_list[] = $xml_doc->component->author; |
|
155 | 155 | else $author_list = $xml_doc->component->author; |
156 | 156 | |
157 | - for($i=0; $i < count($author_list); $i++) |
|
157 | + for ($i = 0; $i < count($author_list); $i++) |
|
158 | 158 | { |
159 | 159 | $buff .= sprintf('$xml_info->author['.$i.']->name = "%s";', $author_list[$i]->name->body); |
160 | 160 | $buff .= sprintf('$xml_info->author['.$i.']->email_address = "%s";', $author_list[$i]->attrs->email_address); |
@@ -163,10 +163,10 @@ discard block |
||
163 | 163 | |
164 | 164 | // List extra variables (text type only in the editor component) |
165 | 165 | $extra_vars = $xml_doc->component->extra_vars->var; |
166 | - if($extra_vars) |
|
166 | + if ($extra_vars) |
|
167 | 167 | { |
168 | - if(!is_array($extra_vars)) $extra_vars = array($extra_vars); |
|
169 | - foreach($extra_vars as $key => $val) |
|
168 | + if (!is_array($extra_vars)) $extra_vars = array($extra_vars); |
|
169 | + foreach ($extra_vars as $key => $val) |
|
170 | 170 | { |
171 | 171 | unset($obj); |
172 | 172 | $key = $val->attrs->name; |
@@ -198,50 +198,50 @@ discard block |
||
198 | 198 | * Editor's default options |
199 | 199 | */ |
200 | 200 | // Option setting to allow file upload |
201 | - if($upload_target_srl) |
|
201 | + if ($upload_target_srl) |
|
202 | 202 | { |
203 | 203 | $option->editor_sequence = $upload_target_srl; |
204 | 204 | } |
205 | - if(!$option->allow_fileupload) $allow_fileupload = false; |
|
205 | + if (!$option->allow_fileupload) $allow_fileupload = false; |
|
206 | 206 | else $allow_fileupload = true; |
207 | 207 | // content_style setting |
208 | - if(!$option->content_style) $option->content_style = 'ckeditor_light'; |
|
208 | + if (!$option->content_style) $option->content_style = 'ckeditor_light'; |
|
209 | 209 | Context::set('content_style', $option->content_style); |
210 | - Context::set('content_style_path', getScriptPath() . ltrim($this->module_path, './') . 'styles/' . $option->content_style); |
|
210 | + Context::set('content_style_path', getScriptPath().ltrim($this->module_path, './').'styles/'.$option->content_style); |
|
211 | 211 | // Default font setting |
212 | 212 | Context::set('content_font', addslashes($option->content_font)); |
213 | 213 | Context::set('content_font_size', $option->content_font_size); |
214 | 214 | |
215 | 215 | // Option setting to allow auto-save |
216 | - if(!$option->enable_autosave) $enable_autosave = false; |
|
217 | - elseif(Context::get($option->primary_key_name)) $enable_autosave = false; |
|
216 | + if (!$option->enable_autosave) $enable_autosave = false; |
|
217 | + elseif (Context::get($option->primary_key_name)) $enable_autosave = false; |
|
218 | 218 | else $enable_autosave = true; |
219 | 219 | // Option setting to allow the default editor component |
220 | - if(!$option->enable_default_component) $enable_default_component = false; |
|
220 | + if (!$option->enable_default_component) $enable_default_component = false; |
|
221 | 221 | else $enable_default_component = true; |
222 | 222 | // Option setting to allow other extended components |
223 | - if(!$option->enable_component) $enable_component = false; |
|
223 | + if (!$option->enable_component) $enable_component = false; |
|
224 | 224 | else $enable_component = true; |
225 | 225 | // Setting for html-mode |
226 | - if($option->disable_html) $html_mode = false; |
|
226 | + if ($option->disable_html) $html_mode = false; |
|
227 | 227 | else $html_mode = true; |
228 | 228 | // Set Height |
229 | - if(!$option->height) $editor_height = 300; |
|
229 | + if (!$option->height) $editor_height = 300; |
|
230 | 230 | else $editor_height = $option->height; |
231 | - if(Mobile::isFromMobilePhone()) { |
|
231 | + if (Mobile::isFromMobilePhone()) { |
|
232 | 232 | $editor_height = 150; |
233 | 233 | } |
234 | 234 | // Skin Setting |
235 | 235 | $skin = $option->skin; |
236 | - if(!$skin) $skin = 'ckeditor'; |
|
236 | + if (!$skin) $skin = 'ckeditor'; |
|
237 | 237 | |
238 | 238 | $colorset = $option->colorset; |
239 | - if(!$colorset) $colorset = 'moono'; |
|
239 | + if (!$colorset) $colorset = 'moono'; |
|
240 | 240 | Context::set('colorset', $colorset); |
241 | 241 | Context::set('skin', $skin); |
242 | 242 | Context::set('module_type', $option->module_type); |
243 | 243 | |
244 | - if($skin=='dreditor') |
|
244 | + if ($skin == 'dreditor') |
|
245 | 245 | { |
246 | 246 | $this->loadDrComponents(); |
247 | 247 | } |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | /** |
250 | 250 | * Check the automatic backup feature (do not use if the post is edited) |
251 | 251 | */ |
252 | - if($enable_autosave) |
|
252 | + if ($enable_autosave) |
|
253 | 253 | { |
254 | 254 | // Extract auto-saved data |
255 | 255 | $saved_doc = $this->getSavedDoc($upload_target_srl); |
@@ -261,26 +261,26 @@ discard block |
||
261 | 261 | /** |
262 | 262 | * Extract editor's unique number (in order to display multiple editors on a single page) |
263 | 263 | */ |
264 | - if($option->editor_sequence) $editor_sequence = $option->editor_sequence; |
|
264 | + if ($option->editor_sequence) $editor_sequence = $option->editor_sequence; |
|
265 | 265 | else |
266 | 266 | { |
267 | - if(!$_SESSION['_editor_sequence_']) $_SESSION['_editor_sequence_'] = 1; |
|
268 | - $editor_sequence = $_SESSION['_editor_sequence_'] ++; |
|
267 | + if (!$_SESSION['_editor_sequence_']) $_SESSION['_editor_sequence_'] = 1; |
|
268 | + $editor_sequence = $_SESSION['_editor_sequence_']++; |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | /** |
272 | 272 | * Upload setting by using configuration of the file module internally |
273 | 273 | */ |
274 | 274 | $files_count = 0; |
275 | - if($allow_fileupload) |
|
275 | + if ($allow_fileupload) |
|
276 | 276 | { |
277 | 277 | $oFileModel = getModel('file'); |
278 | 278 | // Get upload configuration to set on SWFUploader |
279 | 279 | $file_config = $oFileModel->getUploadConfig(); |
280 | - $file_config->allowed_attach_size = $file_config->allowed_attach_size*1024*1024; |
|
281 | - $file_config->allowed_filesize = $file_config->allowed_filesize*1024*1024; |
|
280 | + $file_config->allowed_attach_size = $file_config->allowed_attach_size * 1024 * 1024; |
|
281 | + $file_config->allowed_filesize = $file_config->allowed_filesize * 1024 * 1024; |
|
282 | 282 | |
283 | - Context::set('file_config',$file_config); |
|
283 | + Context::set('file_config', $file_config); |
|
284 | 284 | // Configure upload status such as file size |
285 | 285 | $upload_status = $oFileModel->getUploadStatus(); |
286 | 286 | Context::set('upload_status', $upload_status); |
@@ -288,9 +288,9 @@ discard block |
||
288 | 288 | $oFileController = getController('file'); |
289 | 289 | $oFileController->setUploadInfo($editor_sequence, $upload_target_srl); |
290 | 290 | // Check if the file already exists |
291 | - if($upload_target_srl) $files_count = $oFileModel->getFilesCount($upload_target_srl); |
|
291 | + if ($upload_target_srl) $files_count = $oFileModel->getFilesCount($upload_target_srl); |
|
292 | 292 | } |
293 | - Context::set('files_count', (int)$files_count); |
|
293 | + Context::set('files_count', (int) $files_count); |
|
294 | 294 | |
295 | 295 | Context::set('allow_fileupload', $allow_fileupload); |
296 | 296 | // Set editor_sequence value |
@@ -307,10 +307,10 @@ discard block |
||
307 | 307 | * Check editor component |
308 | 308 | */ |
309 | 309 | $site_module_info = Context::get('site_module_info'); |
310 | - $site_srl = (int)$site_module_info->site_srl; |
|
311 | - if($enable_component) |
|
310 | + $site_srl = (int) $site_module_info->site_srl; |
|
311 | + if ($enable_component) |
|
312 | 312 | { |
313 | - if(!Context::get('component_list')) |
|
313 | + if (!Context::get('component_list')) |
|
314 | 314 | { |
315 | 315 | $component_list = $this->getComponentList(true, $site_srl); |
316 | 316 | Context::set('component_list', $component_list); |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | $tpl_path = sprintf('%sskins/%s/', $this->module_path, $skin); |
338 | 338 | $tpl_file = 'editor.html'; |
339 | 339 | |
340 | - if(!file_exists($tpl_path.$tpl_file)) |
|
340 | + if (!file_exists($tpl_path.$tpl_file)) |
|
341 | 341 | { |
342 | 342 | $skin = 'ckeditor'; |
343 | 343 | $tpl_path = sprintf('%sskins/%s/', $this->module_path, $skin); |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | $config->module_type = $type; |
368 | 368 | |
369 | 369 | // Configurations listed according to a type |
370 | - if($type == 'document') |
|
370 | + if ($type == 'document') |
|
371 | 371 | { |
372 | 372 | $config->editor_skin = $editor_config->editor_skin; |
373 | 373 | $config->content_style = $editor_config->content_style; |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | $config->enable_autosave = 'N'; |
397 | 397 | } |
398 | 398 | // Check a group_list of the currently logged-in user for permission check |
399 | - if(Context::get('is_logged')) |
|
399 | + if (Context::get('is_logged')) |
|
400 | 400 | { |
401 | 401 | $logged_info = Context::get('logged_info'); |
402 | 402 | $group_list = $logged_info->group_list; |
@@ -415,12 +415,12 @@ discard block |
||
415 | 415 | $option->colorset = $config->sel_editor_colorset; |
416 | 416 | // Permission check for file upload |
417 | 417 | $option->allow_fileupload = false; |
418 | - if($logged_info->is_admin=='Y') $option->allow_fileupload = true; |
|
419 | - elseif(count($config->upload_file_grant)) |
|
418 | + if ($logged_info->is_admin == 'Y') $option->allow_fileupload = true; |
|
419 | + elseif (count($config->upload_file_grant)) |
|
420 | 420 | { |
421 | - foreach($group_list as $group_srl => $group_info) |
|
421 | + foreach ($group_list as $group_srl => $group_info) |
|
422 | 422 | { |
423 | - if(in_array($group_srl, $config->upload_file_grant)) |
|
423 | + if (in_array($group_srl, $config->upload_file_grant)) |
|
424 | 424 | { |
425 | 425 | $option->allow_fileupload = true; |
426 | 426 | break; |
@@ -430,12 +430,12 @@ discard block |
||
430 | 430 | else $option->allow_fileupload = true; |
431 | 431 | // Permission check for using default components |
432 | 432 | $option->enable_default_component = false; |
433 | - if($logged_info->is_admin=='Y') $option->enable_default_component = true; |
|
434 | - elseif(count($config->enable_default_component_grant)) |
|
433 | + if ($logged_info->is_admin == 'Y') $option->enable_default_component = true; |
|
434 | + elseif (count($config->enable_default_component_grant)) |
|
435 | 435 | { |
436 | - foreach($group_list as $group_srl => $group_info) |
|
436 | + foreach ($group_list as $group_srl => $group_info) |
|
437 | 437 | { |
438 | - if(in_array($group_srl, $config->enable_default_component_grant)) |
|
438 | + if (in_array($group_srl, $config->enable_default_component_grant)) |
|
439 | 439 | { |
440 | 440 | $option->enable_default_component = true; |
441 | 441 | break; |
@@ -445,12 +445,12 @@ discard block |
||
445 | 445 | else $option->enable_default_component = true; |
446 | 446 | // Permisshion check for using extended components |
447 | 447 | $option->enable_component = false; |
448 | - if($logged_info->is_admin=='Y') $option->enable_component = true; |
|
449 | - elseif(count($config->enable_component_grant)) |
|
448 | + if ($logged_info->is_admin == 'Y') $option->enable_component = true; |
|
449 | + elseif (count($config->enable_component_grant)) |
|
450 | 450 | { |
451 | - foreach($group_list as $group_srl => $group_info) |
|
451 | + foreach ($group_list as $group_srl => $group_info) |
|
452 | 452 | { |
453 | - if(in_array($group_srl, $config->enable_component_grant)) |
|
453 | + if (in_array($group_srl, $config->enable_component_grant)) |
|
454 | 454 | { |
455 | 455 | $option->enable_component = true; |
456 | 456 | break; |
@@ -460,12 +460,12 @@ discard block |
||
460 | 460 | else $option->enable_component = true; |
461 | 461 | // HTML editing privileges |
462 | 462 | $enable_html = false; |
463 | - if($logged_info->is_admin=='Y') $enable_html = true; |
|
464 | - elseif(count($config->enable_html_grant)) |
|
463 | + if ($logged_info->is_admin == 'Y') $enable_html = true; |
|
464 | + elseif (count($config->enable_html_grant)) |
|
465 | 465 | { |
466 | - foreach($group_list as $group_srl => $group_info) |
|
466 | + foreach ($group_list as $group_srl => $group_info) |
|
467 | 467 | { |
468 | - if(in_array($group_srl, $config->enable_html_grant)) |
|
468 | + if (in_array($group_srl, $config->enable_html_grant)) |
|
469 | 469 | { |
470 | 470 | $enable_html = true; |
471 | 471 | break; |
@@ -474,12 +474,12 @@ discard block |
||
474 | 474 | } |
475 | 475 | else $enable_html = true; |
476 | 476 | |
477 | - if($enable_html) $option->disable_html = false; |
|
477 | + if ($enable_html) $option->disable_html = false; |
|
478 | 478 | else $option->disable_html = true; |
479 | 479 | // Set Height |
480 | 480 | $option->height = $config->editor_height; |
481 | 481 | // Set an option for Auto-save |
482 | - $option->enable_autosave = $config->enable_autosave=='Y'?true:false; |
|
482 | + $option->enable_autosave = $config->enable_autosave == 'Y' ?true:false; |
|
483 | 483 | // Other settings |
484 | 484 | $option->primary_key_name = $primary_key_name; |
485 | 485 | $option->content_key_name = $content_key_name; |
@@ -495,31 +495,31 @@ discard block |
||
495 | 495 | $auto_save_args = new stdClass(); |
496 | 496 | $auto_save_args->module_srl = Context::get('module_srl'); |
497 | 497 | // Get the current module if module_srl doesn't exist |
498 | - if(!$auto_save_args->module_srl) |
|
498 | + if (!$auto_save_args->module_srl) |
|
499 | 499 | { |
500 | 500 | $current_module_info = Context::get('current_module_info'); |
501 | 501 | $auto_save_args->module_srl = $current_module_info->module_srl; |
502 | 502 | } |
503 | 503 | // Find a document by using member_srl for logged-in user and ipaddress for non-logged user |
504 | - if(Context::get('is_logged')) |
|
504 | + if (Context::get('is_logged')) |
|
505 | 505 | { |
506 | 506 | $logged_info = Context::get('logged_info'); |
507 | 507 | $auto_save_args->member_srl = $logged_info->member_srl; |
508 | 508 | } |
509 | 509 | else |
510 | 510 | { |
511 | - $auto_save_args->certify_key = $_COOKIE['autosave_certify_key_' . $auto_save_args->module_srl]; |
|
511 | + $auto_save_args->certify_key = $_COOKIE['autosave_certify_key_'.$auto_save_args->module_srl]; |
|
512 | 512 | // @see https://github.com/xpressengine/xe-core/issues/2208 |
513 | 513 | // 변경 이전에 작성된 게시물 호환성 유지 |
514 | - if(!$auto_save_args->certify_key) $auto_save_args->ipaddress = $_SERVER['REMOTE_ADDR']; |
|
514 | + if (!$auto_save_args->certify_key) $auto_save_args->ipaddress = $_SERVER['REMOTE_ADDR']; |
|
515 | 515 | } |
516 | 516 | // Extract auto-saved data from the DB |
517 | 517 | $output = executeQuery('editor.getSavedDocument', $auto_save_args); |
518 | 518 | $saved_doc = $output->data; |
519 | 519 | // Return null if no result is auto-saved |
520 | - if(!$saved_doc) return; |
|
520 | + if (!$saved_doc) return; |
|
521 | 521 | |
522 | - if($saved_doc->certify_key && !isset($auto_save_args->certify_key)) |
|
522 | + if ($saved_doc->certify_key && !isset($auto_save_args->certify_key)) |
|
523 | 523 | { |
524 | 524 | return; |
525 | 525 | } |
@@ -527,16 +527,16 @@ discard block |
||
527 | 527 | // Check if the auto-saved document already exists |
528 | 528 | $oDocumentModel = getModel('document'); |
529 | 529 | $oSaved = $oDocumentModel->getDocument($saved_doc->document_srl); |
530 | - if($oSaved->isExists()) return; |
|
530 | + if ($oSaved->isExists()) return; |
|
531 | 531 | // Move all the files if the auto-saved data contains document_srl and file |
532 | 532 | // Then set document_srl to editor_sequence |
533 | - if($saved_doc->document_srl && $upload_target_srl && !Context::get('document_srl')) |
|
533 | + if ($saved_doc->document_srl && $upload_target_srl && !Context::get('document_srl')) |
|
534 | 534 | { |
535 | 535 | $saved_doc->module_srl = $auto_save_args->module_srl; |
536 | 536 | $oFileController = getController('file'); |
537 | 537 | $oFileController->moveFile($saved_doc->document_srl, $saved_doc->module_srl, $upload_target_srl); |
538 | 538 | } |
539 | - else if($upload_target_srl) $saved_doc->document_srl = $upload_target_srl; |
|
539 | + else if ($upload_target_srl) $saved_doc->document_srl = $upload_target_srl; |
|
540 | 540 | // Change auto-saved data |
541 | 541 | $saved_doc->certify_key = $auto_save_args->certify_key; |
542 | 542 | $oEditorController = getController('editor'); |
@@ -553,18 +553,18 @@ discard block |
||
553 | 553 | */ |
554 | 554 | function getComponentObject($component, $editor_sequence = 0, $site_srl = 0) |
555 | 555 | { |
556 | - if(!preg_match('/^[a-zA-Z0-9_-]+$/',$component) || !preg_match('/^[0-9]+$/', $editor_sequence . $site_srl)) return; |
|
556 | + if (!preg_match('/^[a-zA-Z0-9_-]+$/', $component) || !preg_match('/^[0-9]+$/', $editor_sequence.$site_srl)) return; |
|
557 | 557 | |
558 | - if(!$this->loaded_component_list[$component][$editor_sequence]) |
|
558 | + if (!$this->loaded_component_list[$component][$editor_sequence]) |
|
559 | 559 | { |
560 | 560 | // Create an object of the component and execute |
561 | 561 | $class_path = sprintf('%scomponents/%s/', $this->module_path, $component); |
562 | 562 | $class_file = sprintf('%s%s.class.php', $class_path, $component); |
563 | - if(!file_exists($class_file)) return new BaseObject(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
563 | + if (!file_exists($class_file)) return new BaseObject(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
564 | 564 | // Create an object after loading the class file |
565 | 565 | require_once($class_file); |
566 | 566 | $oComponent = new $component($editor_sequence, $class_path); |
567 | - if(!$oComponent) return new BaseObject(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
567 | + if (!$oComponent) return new BaseObject(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
568 | 568 | // Add configuration information |
569 | 569 | $component_info = $this->getComponent($component, $site_srl); |
570 | 570 | $oComponent->setInfo($component_info); |
@@ -585,14 +585,14 @@ discard block |
||
585 | 585 | /** |
586 | 586 | * @brief Return the cache file name of editor component list |
587 | 587 | */ |
588 | - function getCacheFile($filter_enabled= true, $site_srl = 0) |
|
588 | + function getCacheFile($filter_enabled = true, $site_srl = 0) |
|
589 | 589 | { |
590 | 590 | $lang = Context::getLangType(); |
591 | 591 | $cache_path = _XE_PATH_.'files/cache/editor/cache/'; |
592 | 592 | FileHandler::makeDir($cache_path); |
593 | - $cache_file = $cache_path.'component_list.' . $lang .'.'; |
|
594 | - if($filter_enabled) $cache_file .= 'filter.'; |
|
595 | - if($site_srl) $cache_file .= $site_srl.'.'; |
|
593 | + $cache_file = $cache_path.'component_list.'.$lang.'.'; |
|
594 | + if ($filter_enabled) $cache_file .= 'filter.'; |
|
595 | + if ($site_srl) $cache_file .= $site_srl.'.'; |
|
596 | 596 | $cache_file .= 'php'; |
597 | 597 | return $cache_file; |
598 | 598 | } |
@@ -604,33 +604,33 @@ discard block |
||
604 | 604 | if ($filter_enabled) $cache_key[] = 'filter'; |
605 | 605 | if ($site_srl) $cache_key[] = $site_srl; |
606 | 606 | |
607 | - return 'editor.component_list:' . implode('.', $cache_key); |
|
607 | + return 'editor.component_list:'.implode('.', $cache_key); |
|
608 | 608 | } |
609 | 609 | |
610 | 610 | /** |
611 | 611 | * @brief Return a component list (DB Information included) |
612 | 612 | */ |
613 | - function getComponentList($filter_enabled = true, $site_srl=0, $from_db=false) |
|
613 | + function getComponentList($filter_enabled = true, $site_srl = 0, $from_db = false) |
|
614 | 614 | { |
615 | 615 | $component_list = false; |
616 | 616 | |
617 | 617 | $oCacheHandler = CacheHandler::getInstance('object', null, true); |
618 | - if($oCacheHandler->isSupport()) { |
|
618 | + if ($oCacheHandler->isSupport()) { |
|
619 | 619 | $cache_key = $this->getComponentListCacheKey(false, $site_srl); |
620 | 620 | $component_list = $oCacheHandler->get($cache_key); |
621 | 621 | } |
622 | 622 | |
623 | - if($from_db || $component_list === false) |
|
623 | + if ($from_db || $component_list === false) |
|
624 | 624 | { |
625 | 625 | $oEditorController = getController('editor'); |
626 | 626 | $component_list = $oEditorController->makeCache(false, $site_srl); |
627 | 627 | |
628 | 628 | } |
629 | 629 | |
630 | - if(!$component_list) return array(); |
|
630 | + if (!$component_list) return array(); |
|
631 | 631 | |
632 | 632 | $logged_info = Context::get('logged_info'); |
633 | - if($logged_info && is_array($logged_info->group_list)) |
|
633 | + if ($logged_info && is_array($logged_info->group_list)) |
|
634 | 634 | { |
635 | 635 | $group_list = array_keys($logged_info->group_list); |
636 | 636 | } |
@@ -639,45 +639,45 @@ discard block |
||
639 | 639 | $group_list = array(); |
640 | 640 | } |
641 | 641 | |
642 | - if(count($component_list)) |
|
642 | + if (count($component_list)) |
|
643 | 643 | { |
644 | - foreach($component_list as $key => $val) |
|
644 | + foreach ($component_list as $key => $val) |
|
645 | 645 | { |
646 | - if(!trim($key)) continue; |
|
647 | - if(!is_dir(_XE_PATH_.'modules/editor/components/'.$key)) |
|
646 | + if (!trim($key)) continue; |
|
647 | + if (!is_dir(_XE_PATH_.'modules/editor/components/'.$key)) |
|
648 | 648 | { |
649 | 649 | FileHandler::removeFile($cache_file); |
650 | 650 | return $this->getComponentList($filter_enabled, $site_srl); |
651 | 651 | } |
652 | - if(!$filter_enabled) continue; |
|
653 | - if($val->enabled == "N") |
|
652 | + if (!$filter_enabled) continue; |
|
653 | + if ($val->enabled == "N") |
|
654 | 654 | { |
655 | 655 | unset($component_list->{$key}); |
656 | 656 | continue; |
657 | 657 | } |
658 | - if($logged_info->is_admin == "Y" || $logged_info->is_site_admin == "Y") continue; |
|
659 | - if($val->target_group) |
|
658 | + if ($logged_info->is_admin == "Y" || $logged_info->is_site_admin == "Y") continue; |
|
659 | + if ($val->target_group) |
|
660 | 660 | { |
661 | - if(!$logged_info) |
|
661 | + if (!$logged_info) |
|
662 | 662 | { |
663 | 663 | $val->enabled = "N"; |
664 | 664 | } |
665 | 665 | else |
666 | 666 | { |
667 | 667 | $is_granted = false; |
668 | - foreach($group_list as $group_srl) |
|
668 | + foreach ($group_list as $group_srl) |
|
669 | 669 | { |
670 | - if(in_array($group_srl, $val->target_group)) $is_granted = true; |
|
670 | + if (in_array($group_srl, $val->target_group)) $is_granted = true; |
|
671 | 671 | } |
672 | - if(!$is_granted) $val->enabled = "N"; |
|
672 | + if (!$is_granted) $val->enabled = "N"; |
|
673 | 673 | } |
674 | 674 | } |
675 | - if($val->enabled != "N" && $val->mid_list) |
|
675 | + if ($val->enabled != "N" && $val->mid_list) |
|
676 | 676 | { |
677 | 677 | $mid = Context::get('mid'); |
678 | - if(!in_array($mid, $val->mid_list)) $val->enabled = "N"; |
|
678 | + if (!in_array($mid, $val->mid_list)) $val->enabled = "N"; |
|
679 | 679 | } |
680 | - if($val->enabled == "N") |
|
680 | + if ($val->enabled == "N") |
|
681 | 681 | { |
682 | 682 | unset($component_list->{$key}); |
683 | 683 | continue; |
@@ -695,7 +695,7 @@ discard block |
||
695 | 695 | $args = new stdClass(); |
696 | 696 | $args->component_name = $component_name; |
697 | 697 | |
698 | - if($site_srl) |
|
698 | + if ($site_srl) |
|
699 | 699 | { |
700 | 700 | $args->site_srl = $site_srl; |
701 | 701 | $output = executeQuery('editor.getSiteComponent', $args); |
@@ -706,7 +706,7 @@ discard block |
||
706 | 706 | } |
707 | 707 | $component = $output->data; |
708 | 708 | |
709 | - if(!$output->data) return false; |
|
709 | + if (!$output->data) return false; |
|
710 | 710 | |
711 | 711 | $component_name = $component->component_name; |
712 | 712 | |
@@ -718,25 +718,25 @@ discard block |
||
718 | 718 | |
719 | 719 | $xml_info->mid_list = array(); |
720 | 720 | |
721 | - if($component->extra_vars) |
|
721 | + if ($component->extra_vars) |
|
722 | 722 | { |
723 | 723 | $extra_vars = unserialize($component->extra_vars); |
724 | 724 | |
725 | - if($extra_vars->target_group) |
|
725 | + if ($extra_vars->target_group) |
|
726 | 726 | { |
727 | 727 | $xml_info->target_group = $extra_vars->target_group; |
728 | 728 | unset($extra_vars->target_group); |
729 | 729 | } |
730 | 730 | |
731 | - if($extra_vars->mid_list) |
|
731 | + if ($extra_vars->mid_list) |
|
732 | 732 | { |
733 | 733 | $xml_info->mid_list = $extra_vars->mid_list; |
734 | 734 | unset($extra_vars->mid_list); |
735 | 735 | } |
736 | 736 | |
737 | - if($xml_info->extra_vars) |
|
737 | + if ($xml_info->extra_vars) |
|
738 | 738 | { |
739 | - foreach($xml_info->extra_vars as $key => $val) |
|
739 | + foreach ($xml_info->extra_vars as $key => $val) |
|
740 | 740 | { |
741 | 741 | $xml_info->extra_vars->{$key}->value = $extra_vars->{$key}; |
742 | 742 | } |
@@ -760,7 +760,7 @@ discard block |
||
760 | 760 | $cache_file = sprintf('./files/cache/editor/%s.%s.php', $component, $lang_type); |
761 | 761 | |
762 | 762 | // Include and return xml file information if cached file exists |
763 | - if(file_exists($cache_file) && file_exists($xml_file) && filemtime($cache_file) > filemtime($xml_file)) |
|
763 | + if (file_exists($cache_file) && file_exists($xml_file) && filemtime($cache_file) > filemtime($xml_file)) |
|
764 | 764 | { |
765 | 765 | include($cache_file); |
766 | 766 | |
@@ -777,7 +777,7 @@ discard block |
||
777 | 777 | $component_info->component_name = $component; |
778 | 778 | $component_info->title = $xml_doc->component->title->body; |
779 | 779 | |
780 | - if($xml_doc->component->version) |
|
780 | + if ($xml_doc->component->version) |
|
781 | 781 | { |
782 | 782 | $component_info->description = str_replace('\n', "\n", $xml_doc->component->description->body); |
783 | 783 | $component_info->version = $xml_doc->component->version->body; |
@@ -803,10 +803,10 @@ discard block |
||
803 | 803 | |
804 | 804 | // Author information |
805 | 805 | $author_list = array(); |
806 | - if(!is_array($xml_doc->component->author)) $author_list[] = $xml_doc->component->author; |
|
806 | + if (!is_array($xml_doc->component->author)) $author_list[] = $xml_doc->component->author; |
|
807 | 807 | else $author_list = $xml_doc->component->author; |
808 | 808 | |
809 | - for($i = 0; $i < count($author_list); $i++) |
|
809 | + for ($i = 0; $i < count($author_list); $i++) |
|
810 | 810 | { |
811 | 811 | $author = new stdClass; |
812 | 812 | $author->name = $author_list[$i]->name->body; |
@@ -817,39 +817,39 @@ discard block |
||
817 | 817 | |
818 | 818 | // List extra variables (text type only for editor component) |
819 | 819 | $extra_vars = $xml_doc->component->extra_vars; |
820 | - if($extra_vars) |
|
820 | + if ($extra_vars) |
|
821 | 821 | { |
822 | 822 | $extra_var_groups = $extra_vars->group; |
823 | - if(!$extra_var_groups) |
|
823 | + if (!$extra_var_groups) |
|
824 | 824 | { |
825 | 825 | $extra_var_groups = $extra_vars; |
826 | 826 | } |
827 | - if(!is_array($extra_var_groups)) |
|
827 | + if (!is_array($extra_var_groups)) |
|
828 | 828 | { |
829 | 829 | $extra_var_groups = array($extra_var_groups); |
830 | 830 | } |
831 | 831 | |
832 | - foreach($extra_var_groups as $group) |
|
832 | + foreach ($extra_var_groups as $group) |
|
833 | 833 | { |
834 | 834 | $extra_vars = $group->var; |
835 | - if(!is_array($group->var)) |
|
835 | + if (!is_array($group->var)) |
|
836 | 836 | { |
837 | 837 | $extra_vars = array($group->var); |
838 | 838 | } |
839 | 839 | |
840 | - foreach($extra_vars as $key => $val) |
|
840 | + foreach ($extra_vars as $key => $val) |
|
841 | 841 | { |
842 | - if(!$val) |
|
842 | + if (!$val) |
|
843 | 843 | { |
844 | 844 | continue; |
845 | 845 | } |
846 | 846 | |
847 | 847 | $obj = new stdClass(); |
848 | - if(!$val->attrs) |
|
848 | + if (!$val->attrs) |
|
849 | 849 | { |
850 | 850 | $val->attrs = new stdClass(); |
851 | 851 | } |
852 | - if(!$val->attrs->type) |
|
852 | + if (!$val->attrs->type) |
|
853 | 853 | { |
854 | 854 | $val->attrs->type = 'text'; |
855 | 855 | } |
@@ -859,26 +859,26 @@ discard block |
||
859 | 859 | $obj->title = $val->title->body; |
860 | 860 | $obj->type = $val->attrs->type; |
861 | 861 | $obj->description = $val->description->body; |
862 | - if($obj->name) |
|
862 | + if ($obj->name) |
|
863 | 863 | { |
864 | 864 | $obj->value = $extra_vals->{$obj->name}; |
865 | 865 | } |
866 | - if(strpos($obj->value, '|@|') != FALSE) |
|
866 | + if (strpos($obj->value, '|@|') != FALSE) |
|
867 | 867 | { |
868 | 868 | $obj->value = explode('|@|', $obj->value); |
869 | 869 | } |
870 | - if($obj->type == 'mid_list' && !is_array($obj->value)) |
|
870 | + if ($obj->type == 'mid_list' && !is_array($obj->value)) |
|
871 | 871 | { |
872 | 872 | $obj->value = array($obj->value); |
873 | 873 | } |
874 | 874 | |
875 | 875 | // 'Select'type obtained from the option list. |
876 | - if($val->options && !is_array($val->options)) |
|
876 | + if ($val->options && !is_array($val->options)) |
|
877 | 877 | { |
878 | 878 | $val->options = array($val->options); |
879 | 879 | } |
880 | 880 | |
881 | - for($i = 0, $c = count($val->options); $i < $c; $i++) |
|
881 | + for ($i = 0, $c = count($val->options); $i < $c; $i++) |
|
882 | 882 | { |
883 | 883 | $obj->options[$i] = new stdClass(); |
884 | 884 | $obj->options[$i]->title = $val->options[$i]->title->body; |
@@ -892,7 +892,7 @@ discard block |
||
892 | 892 | |
893 | 893 | $buff = array(); |
894 | 894 | $buff[] = '<?php if(!defined(\'__XE__\')) exit();'; |
895 | - $buff[] = '$xml_info = ' . var_export($component_info, TRUE) . ';'; |
|
895 | + $buff[] = '$xml_info = '.var_export($component_info, TRUE).';'; |
|
896 | 896 | $buff = str_replace('stdClass::__set_state', '(object)', implode(PHP_EOL, $buff)); |
897 | 897 | |
898 | 898 | FileHandler::writeFile($cache_file, $buff, 'w'); |
@@ -34,17 +34,37 @@ discard block |
||
34 | 34 | $oModuleModel = getModel('module'); |
35 | 35 | $editor_default_config = $oModuleModel->getModuleConfig('editor'); |
36 | 36 | |
37 | - if(!is_object($editor_config)) $editor_config = new stdClass(); |
|
38 | - |
|
39 | - if($editor_config->enable_autosave != 'N') $editor_config->enable_autosave = 'Y'; |
|
40 | - if(!is_array($editor_config->enable_html_grant)) $editor_config->enable_html_grant = array(); |
|
41 | - if(!is_array($editor_config->enable_comment_html_grant)) $editor_config->enable_comment_html_grant = array(); |
|
42 | - if(!is_array($editor_config->upload_file_grant)) $editor_config->upload_file_grant = array(); |
|
43 | - if(!is_array($editor_config->comment_upload_file_grant)) $editor_config->comment_upload_file_grant = array(); |
|
44 | - if(!is_array($editor_config->enable_default_component_grant)) $editor_config->enable_default_component_grant = array(); |
|
45 | - if(!is_array($editor_config->enable_comment_default_component_grant)) $editor_config->enable_comment_default_component_grant = array(); |
|
46 | - if(!is_array($editor_config->enable_component_grant)) $editor_config->enable_component_grant = array(); |
|
47 | - if(!is_array($editor_config->enable_comment_component_grant)) $editor_config->enable_comment_component_grant= array(); |
|
37 | + if(!is_object($editor_config)) { |
|
38 | + $editor_config = new stdClass(); |
|
39 | + } |
|
40 | + |
|
41 | + if($editor_config->enable_autosave != 'N') { |
|
42 | + $editor_config->enable_autosave = 'Y'; |
|
43 | + } |
|
44 | + if(!is_array($editor_config->enable_html_grant)) { |
|
45 | + $editor_config->enable_html_grant = array(); |
|
46 | + } |
|
47 | + if(!is_array($editor_config->enable_comment_html_grant)) { |
|
48 | + $editor_config->enable_comment_html_grant = array(); |
|
49 | + } |
|
50 | + if(!is_array($editor_config->upload_file_grant)) { |
|
51 | + $editor_config->upload_file_grant = array(); |
|
52 | + } |
|
53 | + if(!is_array($editor_config->comment_upload_file_grant)) { |
|
54 | + $editor_config->comment_upload_file_grant = array(); |
|
55 | + } |
|
56 | + if(!is_array($editor_config->enable_default_component_grant)) { |
|
57 | + $editor_config->enable_default_component_grant = array(); |
|
58 | + } |
|
59 | + if(!is_array($editor_config->enable_comment_default_component_grant)) { |
|
60 | + $editor_config->enable_comment_default_component_grant = array(); |
|
61 | + } |
|
62 | + if(!is_array($editor_config->enable_component_grant)) { |
|
63 | + $editor_config->enable_component_grant = array(); |
|
64 | + } |
|
65 | + if(!is_array($editor_config->enable_comment_component_grant)) { |
|
66 | + $editor_config->enable_comment_component_grant= array(); |
|
67 | + } |
|
48 | 68 | |
49 | 69 | if(!$editor_config->editor_height) |
50 | 70 | { |
@@ -151,8 +171,11 @@ discard block |
||
151 | 171 | $buff .= sprintf('$xml_info->license_link = "%s";', $component_info->license_link); |
152 | 172 | |
153 | 173 | // Author information |
154 | - if(!is_array($xml_doc->component->author)) $author_list[] = $xml_doc->component->author; |
|
155 | - else $author_list = $xml_doc->component->author; |
|
174 | + if(!is_array($xml_doc->component->author)) { |
|
175 | + $author_list[] = $xml_doc->component->author; |
|
176 | + } else { |
|
177 | + $author_list = $xml_doc->component->author; |
|
178 | + } |
|
156 | 179 | |
157 | 180 | for($i=0; $i < count($author_list); $i++) |
158 | 181 | { |
@@ -165,7 +188,9 @@ discard block |
||
165 | 188 | $extra_vars = $xml_doc->component->extra_vars->var; |
166 | 189 | if($extra_vars) |
167 | 190 | { |
168 | - if(!is_array($extra_vars)) $extra_vars = array($extra_vars); |
|
191 | + if(!is_array($extra_vars)) { |
|
192 | + $extra_vars = array($extra_vars); |
|
193 | + } |
|
169 | 194 | foreach($extra_vars as $key => $val) |
170 | 195 | { |
171 | 196 | unset($obj); |
@@ -202,10 +227,15 @@ discard block |
||
202 | 227 | { |
203 | 228 | $option->editor_sequence = $upload_target_srl; |
204 | 229 | } |
205 | - if(!$option->allow_fileupload) $allow_fileupload = false; |
|
206 | - else $allow_fileupload = true; |
|
230 | + if(!$option->allow_fileupload) { |
|
231 | + $allow_fileupload = false; |
|
232 | + } else { |
|
233 | + $allow_fileupload = true; |
|
234 | + } |
|
207 | 235 | // content_style setting |
208 | - if(!$option->content_style) $option->content_style = 'ckeditor_light'; |
|
236 | + if(!$option->content_style) { |
|
237 | + $option->content_style = 'ckeditor_light'; |
|
238 | + } |
|
209 | 239 | Context::set('content_style', $option->content_style); |
210 | 240 | Context::set('content_style_path', getScriptPath() . ltrim($this->module_path, './') . 'styles/' . $option->content_style); |
211 | 241 | // Default font setting |
@@ -213,30 +243,50 @@ discard block |
||
213 | 243 | Context::set('content_font_size', $option->content_font_size); |
214 | 244 | |
215 | 245 | // Option setting to allow auto-save |
216 | - if(!$option->enable_autosave) $enable_autosave = false; |
|
217 | - elseif(Context::get($option->primary_key_name)) $enable_autosave = false; |
|
218 | - else $enable_autosave = true; |
|
246 | + if(!$option->enable_autosave) { |
|
247 | + $enable_autosave = false; |
|
248 | + } elseif(Context::get($option->primary_key_name)) { |
|
249 | + $enable_autosave = false; |
|
250 | + } else { |
|
251 | + $enable_autosave = true; |
|
252 | + } |
|
219 | 253 | // Option setting to allow the default editor component |
220 | - if(!$option->enable_default_component) $enable_default_component = false; |
|
221 | - else $enable_default_component = true; |
|
254 | + if(!$option->enable_default_component) { |
|
255 | + $enable_default_component = false; |
|
256 | + } else { |
|
257 | + $enable_default_component = true; |
|
258 | + } |
|
222 | 259 | // Option setting to allow other extended components |
223 | - if(!$option->enable_component) $enable_component = false; |
|
224 | - else $enable_component = true; |
|
260 | + if(!$option->enable_component) { |
|
261 | + $enable_component = false; |
|
262 | + } else { |
|
263 | + $enable_component = true; |
|
264 | + } |
|
225 | 265 | // Setting for html-mode |
226 | - if($option->disable_html) $html_mode = false; |
|
227 | - else $html_mode = true; |
|
266 | + if($option->disable_html) { |
|
267 | + $html_mode = false; |
|
268 | + } else { |
|
269 | + $html_mode = true; |
|
270 | + } |
|
228 | 271 | // Set Height |
229 | - if(!$option->height) $editor_height = 300; |
|
230 | - else $editor_height = $option->height; |
|
272 | + if(!$option->height) { |
|
273 | + $editor_height = 300; |
|
274 | + } else { |
|
275 | + $editor_height = $option->height; |
|
276 | + } |
|
231 | 277 | if(Mobile::isFromMobilePhone()) { |
232 | 278 | $editor_height = 150; |
233 | 279 | } |
234 | 280 | // Skin Setting |
235 | 281 | $skin = $option->skin; |
236 | - if(!$skin) $skin = 'ckeditor'; |
|
282 | + if(!$skin) { |
|
283 | + $skin = 'ckeditor'; |
|
284 | + } |
|
237 | 285 | |
238 | 286 | $colorset = $option->colorset; |
239 | - if(!$colorset) $colorset = 'moono'; |
|
287 | + if(!$colorset) { |
|
288 | + $colorset = 'moono'; |
|
289 | + } |
|
240 | 290 | Context::set('colorset', $colorset); |
241 | 291 | Context::set('skin', $skin); |
242 | 292 | Context::set('module_type', $option->module_type); |
@@ -261,10 +311,13 @@ discard block |
||
261 | 311 | /** |
262 | 312 | * Extract editor's unique number (in order to display multiple editors on a single page) |
263 | 313 | */ |
264 | - if($option->editor_sequence) $editor_sequence = $option->editor_sequence; |
|
265 | - else |
|
314 | + if($option->editor_sequence) { |
|
315 | + $editor_sequence = $option->editor_sequence; |
|
316 | + } else |
|
266 | 317 | { |
267 | - if(!$_SESSION['_editor_sequence_']) $_SESSION['_editor_sequence_'] = 1; |
|
318 | + if(!$_SESSION['_editor_sequence_']) { |
|
319 | + $_SESSION['_editor_sequence_'] = 1; |
|
320 | + } |
|
268 | 321 | $editor_sequence = $_SESSION['_editor_sequence_'] ++; |
269 | 322 | } |
270 | 323 | |
@@ -288,7 +341,9 @@ discard block |
||
288 | 341 | $oFileController = getController('file'); |
289 | 342 | $oFileController->setUploadInfo($editor_sequence, $upload_target_srl); |
290 | 343 | // Check if the file already exists |
291 | - if($upload_target_srl) $files_count = $oFileModel->getFilesCount($upload_target_srl); |
|
344 | + if($upload_target_srl) { |
|
345 | + $files_count = $oFileModel->getFilesCount($upload_target_srl); |
|
346 | + } |
|
292 | 347 | } |
293 | 348 | Context::set('files_count', (int)$files_count); |
294 | 349 | |
@@ -380,8 +435,7 @@ discard block |
||
380 | 435 | $config->enable_html_grant = $editor_config->enable_html_grant; |
381 | 436 | $config->editor_height = $editor_config->editor_height; |
382 | 437 | $config->enable_autosave = $editor_config->enable_autosave; |
383 | - } |
|
384 | - else |
|
438 | + } else |
|
385 | 439 | { |
386 | 440 | $config->editor_skin = $editor_config->comment_editor_skin; |
387 | 441 | $config->content_style = $editor_config->comment_content_style; |
@@ -400,8 +454,7 @@ discard block |
||
400 | 454 | { |
401 | 455 | $logged_info = Context::get('logged_info'); |
402 | 456 | $group_list = $logged_info->group_list; |
403 | - } |
|
404 | - else |
|
457 | + } else |
|
405 | 458 | { |
406 | 459 | $group_list = array(); |
407 | 460 | } |
@@ -415,8 +468,9 @@ discard block |
||
415 | 468 | $option->colorset = $config->sel_editor_colorset; |
416 | 469 | // Permission check for file upload |
417 | 470 | $option->allow_fileupload = false; |
418 | - if($logged_info->is_admin=='Y') $option->allow_fileupload = true; |
|
419 | - elseif(count($config->upload_file_grant)) |
|
471 | + if($logged_info->is_admin=='Y') { |
|
472 | + $option->allow_fileupload = true; |
|
473 | + } elseif(count($config->upload_file_grant)) |
|
420 | 474 | { |
421 | 475 | foreach($group_list as $group_srl => $group_info) |
422 | 476 | { |
@@ -426,12 +480,14 @@ discard block |
||
426 | 480 | break; |
427 | 481 | } |
428 | 482 | } |
483 | + } else { |
|
484 | + $option->allow_fileupload = true; |
|
429 | 485 | } |
430 | - else $option->allow_fileupload = true; |
|
431 | 486 | // Permission check for using default components |
432 | 487 | $option->enable_default_component = false; |
433 | - if($logged_info->is_admin=='Y') $option->enable_default_component = true; |
|
434 | - elseif(count($config->enable_default_component_grant)) |
|
488 | + if($logged_info->is_admin=='Y') { |
|
489 | + $option->enable_default_component = true; |
|
490 | + } elseif(count($config->enable_default_component_grant)) |
|
435 | 491 | { |
436 | 492 | foreach($group_list as $group_srl => $group_info) |
437 | 493 | { |
@@ -441,12 +497,14 @@ discard block |
||
441 | 497 | break; |
442 | 498 | } |
443 | 499 | } |
500 | + } else { |
|
501 | + $option->enable_default_component = true; |
|
444 | 502 | } |
445 | - else $option->enable_default_component = true; |
|
446 | 503 | // Permisshion check for using extended components |
447 | 504 | $option->enable_component = false; |
448 | - if($logged_info->is_admin=='Y') $option->enable_component = true; |
|
449 | - elseif(count($config->enable_component_grant)) |
|
505 | + if($logged_info->is_admin=='Y') { |
|
506 | + $option->enable_component = true; |
|
507 | + } elseif(count($config->enable_component_grant)) |
|
450 | 508 | { |
451 | 509 | foreach($group_list as $group_srl => $group_info) |
452 | 510 | { |
@@ -456,12 +514,14 @@ discard block |
||
456 | 514 | break; |
457 | 515 | } |
458 | 516 | } |
517 | + } else { |
|
518 | + $option->enable_component = true; |
|
459 | 519 | } |
460 | - else $option->enable_component = true; |
|
461 | 520 | // HTML editing privileges |
462 | 521 | $enable_html = false; |
463 | - if($logged_info->is_admin=='Y') $enable_html = true; |
|
464 | - elseif(count($config->enable_html_grant)) |
|
522 | + if($logged_info->is_admin=='Y') { |
|
523 | + $enable_html = true; |
|
524 | + } elseif(count($config->enable_html_grant)) |
|
465 | 525 | { |
466 | 526 | foreach($group_list as $group_srl => $group_info) |
467 | 527 | { |
@@ -471,11 +531,15 @@ discard block |
||
471 | 531 | break; |
472 | 532 | } |
473 | 533 | } |
534 | + } else { |
|
535 | + $enable_html = true; |
|
474 | 536 | } |
475 | - else $enable_html = true; |
|
476 | 537 | |
477 | - if($enable_html) $option->disable_html = false; |
|
478 | - else $option->disable_html = true; |
|
538 | + if($enable_html) { |
|
539 | + $option->disable_html = false; |
|
540 | + } else { |
|
541 | + $option->disable_html = true; |
|
542 | + } |
|
479 | 543 | // Set Height |
480 | 544 | $option->height = $config->editor_height; |
481 | 545 | // Set an option for Auto-save |
@@ -505,19 +569,22 @@ discard block |
||
505 | 569 | { |
506 | 570 | $logged_info = Context::get('logged_info'); |
507 | 571 | $auto_save_args->member_srl = $logged_info->member_srl; |
508 | - } |
|
509 | - else |
|
572 | + } else |
|
510 | 573 | { |
511 | 574 | $auto_save_args->certify_key = $_COOKIE['autosave_certify_key_' . $auto_save_args->module_srl]; |
512 | 575 | // @see https://github.com/xpressengine/xe-core/issues/2208 |
513 | 576 | // 변경 이전에 작성된 게시물 호환성 유지 |
514 | - if(!$auto_save_args->certify_key) $auto_save_args->ipaddress = $_SERVER['REMOTE_ADDR']; |
|
577 | + if(!$auto_save_args->certify_key) { |
|
578 | + $auto_save_args->ipaddress = $_SERVER['REMOTE_ADDR']; |
|
579 | + } |
|
515 | 580 | } |
516 | 581 | // Extract auto-saved data from the DB |
517 | 582 | $output = executeQuery('editor.getSavedDocument', $auto_save_args); |
518 | 583 | $saved_doc = $output->data; |
519 | 584 | // Return null if no result is auto-saved |
520 | - if(!$saved_doc) return; |
|
585 | + if(!$saved_doc) { |
|
586 | + return; |
|
587 | + } |
|
521 | 588 | |
522 | 589 | if($saved_doc->certify_key && !isset($auto_save_args->certify_key)) |
523 | 590 | { |
@@ -527,7 +594,9 @@ discard block |
||
527 | 594 | // Check if the auto-saved document already exists |
528 | 595 | $oDocumentModel = getModel('document'); |
529 | 596 | $oSaved = $oDocumentModel->getDocument($saved_doc->document_srl); |
530 | - if($oSaved->isExists()) return; |
|
597 | + if($oSaved->isExists()) { |
|
598 | + return; |
|
599 | + } |
|
531 | 600 | // Move all the files if the auto-saved data contains document_srl and file |
532 | 601 | // Then set document_srl to editor_sequence |
533 | 602 | if($saved_doc->document_srl && $upload_target_srl && !Context::get('document_srl')) |
@@ -535,8 +604,9 @@ discard block |
||
535 | 604 | $saved_doc->module_srl = $auto_save_args->module_srl; |
536 | 605 | $oFileController = getController('file'); |
537 | 606 | $oFileController->moveFile($saved_doc->document_srl, $saved_doc->module_srl, $upload_target_srl); |
607 | + } else if($upload_target_srl) { |
|
608 | + $saved_doc->document_srl = $upload_target_srl; |
|
538 | 609 | } |
539 | - else if($upload_target_srl) $saved_doc->document_srl = $upload_target_srl; |
|
540 | 610 | // Change auto-saved data |
541 | 611 | $saved_doc->certify_key = $auto_save_args->certify_key; |
542 | 612 | $oEditorController = getController('editor'); |
@@ -553,18 +623,24 @@ discard block |
||
553 | 623 | */ |
554 | 624 | function getComponentObject($component, $editor_sequence = 0, $site_srl = 0) |
555 | 625 | { |
556 | - if(!preg_match('/^[a-zA-Z0-9_-]+$/',$component) || !preg_match('/^[0-9]+$/', $editor_sequence . $site_srl)) return; |
|
626 | + if(!preg_match('/^[a-zA-Z0-9_-]+$/',$component) || !preg_match('/^[0-9]+$/', $editor_sequence . $site_srl)) { |
|
627 | + return; |
|
628 | + } |
|
557 | 629 | |
558 | 630 | if(!$this->loaded_component_list[$component][$editor_sequence]) |
559 | 631 | { |
560 | 632 | // Create an object of the component and execute |
561 | 633 | $class_path = sprintf('%scomponents/%s/', $this->module_path, $component); |
562 | 634 | $class_file = sprintf('%s%s.class.php', $class_path, $component); |
563 | - if(!file_exists($class_file)) return new BaseObject(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
635 | + if(!file_exists($class_file)) { |
|
636 | + return new BaseObject(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
637 | + } |
|
564 | 638 | // Create an object after loading the class file |
565 | 639 | require_once($class_file); |
566 | 640 | $oComponent = new $component($editor_sequence, $class_path); |
567 | - if(!$oComponent) return new BaseObject(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
641 | + if(!$oComponent) { |
|
642 | + return new BaseObject(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); |
|
643 | + } |
|
568 | 644 | // Add configuration information |
569 | 645 | $component_info = $this->getComponent($component, $site_srl); |
570 | 646 | $oComponent->setInfo($component_info); |
@@ -591,8 +667,12 @@ discard block |
||
591 | 667 | $cache_path = _XE_PATH_.'files/cache/editor/cache/'; |
592 | 668 | FileHandler::makeDir($cache_path); |
593 | 669 | $cache_file = $cache_path.'component_list.' . $lang .'.'; |
594 | - if($filter_enabled) $cache_file .= 'filter.'; |
|
595 | - if($site_srl) $cache_file .= $site_srl.'.'; |
|
670 | + if($filter_enabled) { |
|
671 | + $cache_file .= 'filter.'; |
|
672 | + } |
|
673 | + if($site_srl) { |
|
674 | + $cache_file .= $site_srl.'.'; |
|
675 | + } |
|
596 | 676 | $cache_file .= 'php'; |
597 | 677 | return $cache_file; |
598 | 678 | } |
@@ -601,8 +681,12 @@ discard block |
||
601 | 681 | { |
602 | 682 | $cache_key = array(); |
603 | 683 | $cache_key[] = Context::getLangType(); |
604 | - if ($filter_enabled) $cache_key[] = 'filter'; |
|
605 | - if ($site_srl) $cache_key[] = $site_srl; |
|
684 | + if ($filter_enabled) { |
|
685 | + $cache_key[] = 'filter'; |
|
686 | + } |
|
687 | + if ($site_srl) { |
|
688 | + $cache_key[] = $site_srl; |
|
689 | + } |
|
606 | 690 | |
607 | 691 | return 'editor.component_list:' . implode('.', $cache_key); |
608 | 692 | } |
@@ -627,14 +711,15 @@ discard block |
||
627 | 711 | |
628 | 712 | } |
629 | 713 | |
630 | - if(!$component_list) return array(); |
|
714 | + if(!$component_list) { |
|
715 | + return array(); |
|
716 | + } |
|
631 | 717 | |
632 | 718 | $logged_info = Context::get('logged_info'); |
633 | 719 | if($logged_info && is_array($logged_info->group_list)) |
634 | 720 | { |
635 | 721 | $group_list = array_keys($logged_info->group_list); |
636 | - } |
|
637 | - else |
|
722 | + } else |
|
638 | 723 | { |
639 | 724 | $group_list = array(); |
640 | 725 | } |
@@ -643,39 +728,50 @@ discard block |
||
643 | 728 | { |
644 | 729 | foreach($component_list as $key => $val) |
645 | 730 | { |
646 | - if(!trim($key)) continue; |
|
731 | + if(!trim($key)) { |
|
732 | + continue; |
|
733 | + } |
|
647 | 734 | if(!is_dir(_XE_PATH_.'modules/editor/components/'.$key)) |
648 | 735 | { |
649 | 736 | FileHandler::removeFile($cache_file); |
650 | 737 | return $this->getComponentList($filter_enabled, $site_srl); |
651 | 738 | } |
652 | - if(!$filter_enabled) continue; |
|
739 | + if(!$filter_enabled) { |
|
740 | + continue; |
|
741 | + } |
|
653 | 742 | if($val->enabled == "N") |
654 | 743 | { |
655 | 744 | unset($component_list->{$key}); |
656 | 745 | continue; |
657 | 746 | } |
658 | - if($logged_info->is_admin == "Y" || $logged_info->is_site_admin == "Y") continue; |
|
747 | + if($logged_info->is_admin == "Y" || $logged_info->is_site_admin == "Y") { |
|
748 | + continue; |
|
749 | + } |
|
659 | 750 | if($val->target_group) |
660 | 751 | { |
661 | 752 | if(!$logged_info) |
662 | 753 | { |
663 | 754 | $val->enabled = "N"; |
664 | - } |
|
665 | - else |
|
755 | + } else |
|
666 | 756 | { |
667 | 757 | $is_granted = false; |
668 | 758 | foreach($group_list as $group_srl) |
669 | 759 | { |
670 | - if(in_array($group_srl, $val->target_group)) $is_granted = true; |
|
760 | + if(in_array($group_srl, $val->target_group)) { |
|
761 | + $is_granted = true; |
|
762 | + } |
|
763 | + } |
|
764 | + if(!$is_granted) { |
|
765 | + $val->enabled = "N"; |
|
671 | 766 | } |
672 | - if(!$is_granted) $val->enabled = "N"; |
|
673 | 767 | } |
674 | 768 | } |
675 | 769 | if($val->enabled != "N" && $val->mid_list) |
676 | 770 | { |
677 | 771 | $mid = Context::get('mid'); |
678 | - if(!in_array($mid, $val->mid_list)) $val->enabled = "N"; |
|
772 | + if(!in_array($mid, $val->mid_list)) { |
|
773 | + $val->enabled = "N"; |
|
774 | + } |
|
679 | 775 | } |
680 | 776 | if($val->enabled == "N") |
681 | 777 | { |
@@ -699,14 +795,15 @@ discard block |
||
699 | 795 | { |
700 | 796 | $args->site_srl = $site_srl; |
701 | 797 | $output = executeQuery('editor.getSiteComponent', $args); |
702 | - } |
|
703 | - else |
|
798 | + } else |
|
704 | 799 | { |
705 | 800 | $output = executeQuery('editor.getComponent', $args); |
706 | 801 | } |
707 | 802 | $component = $output->data; |
708 | 803 | |
709 | - if(!$output->data) return false; |
|
804 | + if(!$output->data) { |
|
805 | + return false; |
|
806 | + } |
|
710 | 807 | |
711 | 808 | $component_name = $component->component_name; |
712 | 809 | |
@@ -785,8 +882,7 @@ discard block |
||
785 | 882 | $component_info->homepage = $xml_doc->component->link->body; |
786 | 883 | $component_info->license = $xml_doc->component->license->body; |
787 | 884 | $component_info->license_link = $xml_doc->component->license->attrs->link; |
788 | - } |
|
789 | - else |
|
885 | + } else |
|
790 | 886 | { |
791 | 887 | sscanf($xml_doc->component->author->attrs->date, '%d. %d. %d', $date_obj->y, $date_obj->m, $date_obj->d); |
792 | 888 | $date = sprintf('%04d%02d%02d', $date_obj->y, $date_obj->m, $date_obj->d); |
@@ -803,8 +899,11 @@ discard block |
||
803 | 899 | |
804 | 900 | // Author information |
805 | 901 | $author_list = array(); |
806 | - if(!is_array($xml_doc->component->author)) $author_list[] = $xml_doc->component->author; |
|
807 | - else $author_list = $xml_doc->component->author; |
|
902 | + if(!is_array($xml_doc->component->author)) { |
|
903 | + $author_list[] = $xml_doc->component->author; |
|
904 | + } else { |
|
905 | + $author_list = $xml_doc->component->author; |
|
906 | + } |
|
808 | 907 | |
809 | 908 | for($i = 0; $i < count($author_list); $i++) |
810 | 909 | { |