@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | function _loadFromDB($load_extra_vars = true) |
| 76 | 76 | { |
| 77 | - if(!$this->document_srl) return; |
|
| 77 | + if (!$this->document_srl) return; |
|
| 78 | 78 | |
| 79 | 79 | $document_item = false; |
| 80 | 80 | $cache_put = false; |
@@ -83,11 +83,11 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | // cache controll |
| 85 | 85 | $oCacheHandler = CacheHandler::getInstance('object'); |
| 86 | - if($oCacheHandler->isSupport()) |
|
| 86 | + if ($oCacheHandler->isSupport()) |
|
| 87 | 87 | { |
| 88 | - $cache_key = 'document_item:' . getNumberingPath($this->document_srl) . $this->document_srl; |
|
| 88 | + $cache_key = 'document_item:'.getNumberingPath($this->document_srl).$this->document_srl; |
|
| 89 | 89 | $document_item = $oCacheHandler->get($cache_key); |
| 90 | - if($document_item !== false) |
|
| 90 | + if ($document_item !== false) |
|
| 91 | 91 | { |
| 92 | 92 | $columnList = array('readed_count', 'voted_count', 'blamed_count', 'comment_count', 'trackback_count'); |
| 93 | 93 | } |
@@ -97,12 +97,12 @@ discard block |
||
| 97 | 97 | $args->document_srl = $this->document_srl; |
| 98 | 98 | $output = executeQuery('document.getDocument', $args, $columnList); |
| 99 | 99 | |
| 100 | - if($document_item === false) |
|
| 100 | + if ($document_item === false) |
|
| 101 | 101 | { |
| 102 | 102 | $document_item = $output->data; |
| 103 | 103 | |
| 104 | 104 | //insert in cache |
| 105 | - if($document_item && $oCacheHandler->isSupport()) |
|
| 105 | + if ($document_item && $oCacheHandler->isSupport()) |
|
| 106 | 106 | { |
| 107 | 107 | $oCacheHandler->put($cache_key, $document_item); |
| 108 | 108 | } |
@@ -119,9 +119,9 @@ discard block |
||
| 119 | 119 | $this->setAttribute($document_item, $load_extra_vars); |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - function setAttribute($attribute, $load_extra_vars=true) |
|
| 122 | + function setAttribute($attribute, $load_extra_vars = true) |
|
| 123 | 123 | { |
| 124 | - if(!$attribute->document_srl) |
|
| 124 | + if (!$attribute->document_srl) |
|
| 125 | 125 | { |
| 126 | 126 | $this->document_srl = null; |
| 127 | 127 | return; |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | $this->adds($attribute); |
| 132 | 132 | |
| 133 | 133 | // Tags |
| 134 | - if($this->get('tags')) |
|
| 134 | + if ($this->get('tags')) |
|
| 135 | 135 | { |
| 136 | 136 | $tag_list = explode(',', $this->get('tags')); |
| 137 | 137 | $tag_list = array_map('trim', $tag_list); |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | $oDocumentModel = getModel('document'); |
| 142 | - if($load_extra_vars) |
|
| 142 | + if ($load_extra_vars) |
|
| 143 | 143 | { |
| 144 | 144 | $GLOBALS['XE_DOCUMENT_LIST'][$attribute->document_srl] = $this; |
| 145 | 145 | $oDocumentModel->setToAllDocumentExtraVars(); |
@@ -154,18 +154,18 @@ discard block |
||
| 154 | 154 | |
| 155 | 155 | function isGranted() |
| 156 | 156 | { |
| 157 | - if($_SESSION['own_document'][$this->document_srl]) return true; |
|
| 157 | + if ($_SESSION['own_document'][$this->document_srl]) return true; |
|
| 158 | 158 | |
| 159 | - if(!Context::get('is_logged')) return false; |
|
| 159 | + if (!Context::get('is_logged')) return false; |
|
| 160 | 160 | |
| 161 | 161 | $logged_info = Context::get('logged_info'); |
| 162 | - if($logged_info->is_admin == 'Y') return true; |
|
| 162 | + if ($logged_info->is_admin == 'Y') return true; |
|
| 163 | 163 | |
| 164 | 164 | $oModuleModel = getModel('module'); |
| 165 | 165 | $grant = $oModuleModel->getGrant($oModuleModel->getModuleInfoByModuleSrl($this->get('module_srl')), $logged_info); |
| 166 | - if($grant->manager) return true; |
|
| 166 | + if ($grant->manager) return true; |
|
| 167 | 167 | |
| 168 | - if($this->get('member_srl') && ($this->get('member_srl') == $logged_info->member_srl || $this->get('member_srl')*-1 == $logged_info->member_srl)) return true; |
|
| 168 | + if ($this->get('member_srl') && ($this->get('member_srl') == $logged_info->member_srl || $this->get('member_srl') * -1 == $logged_info->member_srl)) return true; |
|
| 169 | 169 | |
| 170 | 170 | return false; |
| 171 | 171 | } |
@@ -177,13 +177,13 @@ discard block |
||
| 177 | 177 | |
| 178 | 178 | function isAccessible() |
| 179 | 179 | { |
| 180 | - return $_SESSION['accessible'][$this->document_srl]==true?true:false; |
|
| 180 | + return $_SESSION['accessible'][$this->document_srl] == true ? true : false; |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | function allowComment() |
| 184 | 184 | { |
| 185 | 185 | // init write, document is not exists. so allow comment status is true |
| 186 | - if(!$this->isExists()) return true; |
|
| 186 | + if (!$this->isExists()) return true; |
|
| 187 | 187 | |
| 188 | 188 | return $this->get('comment_status') == 'ALLOW' ? true : false; |
| 189 | 189 | } |
@@ -191,11 +191,11 @@ discard block |
||
| 191 | 191 | function allowTrackback() |
| 192 | 192 | { |
| 193 | 193 | static $allow_trackback_status = null; |
| 194 | - if(is_null($allow_trackback_status)) |
|
| 194 | + if (is_null($allow_trackback_status)) |
|
| 195 | 195 | { |
| 196 | 196 | |
| 197 | 197 | // Check the tarckback module exist |
| 198 | - if(!getClass('trackback')) |
|
| 198 | + if (!getClass('trackback')) |
|
| 199 | 199 | { |
| 200 | 200 | $allow_trackback_status = false; |
| 201 | 201 | } |
@@ -205,20 +205,20 @@ discard block |
||
| 205 | 205 | $oModuleModel = getModel('module'); |
| 206 | 206 | $trackback_config = $oModuleModel->getModuleConfig('trackback'); |
| 207 | 207 | |
| 208 | - if(!$trackback_config) |
|
| 208 | + if (!$trackback_config) |
|
| 209 | 209 | { |
| 210 | 210 | $trackback_config = new stdClass(); |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - if(!isset($trackback_config->enable_trackback)) $trackback_config->enable_trackback = 'Y'; |
|
| 214 | - if($trackback_config->enable_trackback != 'Y') $allow_trackback_status = false; |
|
| 213 | + if (!isset($trackback_config->enable_trackback)) $trackback_config->enable_trackback = 'Y'; |
|
| 214 | + if ($trackback_config->enable_trackback != 'Y') $allow_trackback_status = false; |
|
| 215 | 215 | else |
| 216 | 216 | { |
| 217 | 217 | $module_srl = $this->get('module_srl'); |
| 218 | 218 | // Check settings of each module |
| 219 | 219 | $module_config = $oModuleModel->getModulePartConfig('trackback', $module_srl); |
| 220 | - if($module_config->enable_trackback == 'N') $allow_trackback_status = false; |
|
| 221 | - else if($this->get('allow_trackback')=='Y' || !$this->isExists()) $allow_trackback_status = true; |
|
| 220 | + if ($module_config->enable_trackback == 'N') $allow_trackback_status = false; |
|
| 221 | + else if ($this->get('allow_trackback') == 'Y' || !$this->isExists()) $allow_trackback_status = true; |
|
| 222 | 222 | } |
| 223 | 223 | } |
| 224 | 224 | } |
@@ -227,14 +227,14 @@ discard block |
||
| 227 | 227 | |
| 228 | 228 | function isLocked() |
| 229 | 229 | { |
| 230 | - if(!$this->isExists()) return false; |
|
| 230 | + if (!$this->isExists()) return false; |
|
| 231 | 231 | |
| 232 | 232 | return $this->get('comment_status') == 'ALLOW' ? false : true; |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | function isEditable() |
| 236 | 236 | { |
| 237 | - if($this->isGranted() || !$this->get('member_srl')) return true; |
|
| 237 | + if ($this->isGranted() || !$this->get('member_srl')) return true; |
|
| 238 | 238 | return false; |
| 239 | 239 | } |
| 240 | 240 | |
@@ -251,13 +251,13 @@ discard block |
||
| 251 | 251 | |
| 252 | 252 | function useNotify() |
| 253 | 253 | { |
| 254 | - return $this->get('notify_message')=='Y' ? true : false; |
|
| 254 | + return $this->get('notify_message') == 'Y' ? true : false; |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | function doCart() |
| 258 | 258 | { |
| 259 | - if(!$this->document_srl) return false; |
|
| 260 | - if($this->isCarted()) $this->removeCart(); |
|
| 259 | + if (!$this->document_srl) return false; |
|
| 260 | + if ($this->isCarted()) $this->removeCart(); |
|
| 261 | 261 | else $this->addCart(); |
| 262 | 262 | } |
| 263 | 263 | |
@@ -284,18 +284,18 @@ discard block |
||
| 284 | 284 | */ |
| 285 | 285 | function notify($type, $content) |
| 286 | 286 | { |
| 287 | - if(!$this->document_srl) return; |
|
| 287 | + if (!$this->document_srl) return; |
|
| 288 | 288 | // return if it is not useNotify |
| 289 | - if(!$this->useNotify()) return; |
|
| 289 | + if (!$this->useNotify()) return; |
|
| 290 | 290 | // Pass if an author is not a logged-in user |
| 291 | - if(!$this->get('member_srl')) return; |
|
| 291 | + if (!$this->get('member_srl')) return; |
|
| 292 | 292 | // Return if the currently logged-in user is an author |
| 293 | 293 | $logged_info = Context::get('logged_info'); |
| 294 | - if($logged_info->member_srl == $this->get('member_srl')) return; |
|
| 294 | + if ($logged_info->member_srl == $this->get('member_srl')) return; |
|
| 295 | 295 | // List variables |
| 296 | - if($type) $title = "[".$type."] "; |
|
| 296 | + if ($type) $title = "[".$type."] "; |
|
| 297 | 297 | $title .= cut_str(strip_tags($content), 10, '...'); |
| 298 | - $content = sprintf('%s<br /><br />from : <a href="%s" target="_blank">%s</a>',$content, getFullUrl('','document_srl',$this->document_srl), getFullUrl('','document_srl',$this->document_srl)); |
|
| 298 | + $content = sprintf('%s<br /><br />from : <a href="%s" target="_blank">%s</a>', $content, getFullUrl('', 'document_srl', $this->document_srl), getFullUrl('', 'document_srl', $this->document_srl)); |
|
| 299 | 299 | $receiver_srl = $this->get('member_srl'); |
| 300 | 300 | $sender_member_srl = $logged_info->member_srl; |
| 301 | 301 | // Send a message |
@@ -310,26 +310,26 @@ discard block |
||
| 310 | 310 | |
| 311 | 311 | function getIpAddress() |
| 312 | 312 | { |
| 313 | - if($this->isGranted()) |
|
| 313 | + if ($this->isGranted()) |
|
| 314 | 314 | { |
| 315 | 315 | return $this->get('ipaddress'); |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - return '*' . strstr($this->get('ipaddress'), '.'); |
|
| 318 | + return '*'.strstr($this->get('ipaddress'), '.'); |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | function isExistsHomepage() |
| 322 | 322 | { |
| 323 | - if(trim($this->get('homepage'))) return true; |
|
| 323 | + if (trim($this->get('homepage'))) return true; |
|
| 324 | 324 | return false; |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | function getHomepageUrl() |
| 328 | 328 | { |
| 329 | 329 | $url = trim($this->get('homepage')); |
| 330 | - if(!$url) return; |
|
| 330 | + if (!$url) return; |
|
| 331 | 331 | |
| 332 | - if(strncasecmp('http://', $url, 7) !== 0 && strncasecmp('https://', $url, 8) !== 0) $url = 'http://' . $url; |
|
| 332 | + if (strncasecmp('http://', $url, 7) !== 0 && strncasecmp('https://', $url, 8) !== 0) $url = 'http://'.$url; |
|
| 333 | 333 | |
| 334 | 334 | return $url; |
| 335 | 335 | } |
@@ -359,52 +359,52 @@ discard block |
||
| 359 | 359 | return htmlspecialchars($this->get('last_updater'), ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - function getTitleText($cut_size = 0, $tail='...') |
|
| 362 | + function getTitleText($cut_size = 0, $tail = '...') |
|
| 363 | 363 | { |
| 364 | - if(!$this->document_srl) return; |
|
| 364 | + if (!$this->document_srl) return; |
|
| 365 | 365 | |
| 366 | - if($cut_size) $title = cut_str($this->get('title'), $cut_size, $tail); |
|
| 366 | + if ($cut_size) $title = cut_str($this->get('title'), $cut_size, $tail); |
|
| 367 | 367 | else $title = $this->get('title'); |
| 368 | 368 | |
| 369 | 369 | return $title; |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | - function getTitle($cut_size = 0, $tail='...') |
|
| 372 | + function getTitle($cut_size = 0, $tail = '...') |
|
| 373 | 373 | { |
| 374 | - if(!$this->document_srl) return; |
|
| 374 | + if (!$this->document_srl) return; |
|
| 375 | 375 | |
| 376 | 376 | $title = $this->getTitleText($cut_size, $tail); |
| 377 | 377 | |
| 378 | 378 | $attrs = array(); |
| 379 | 379 | $this->add('title_color', trim($this->get('title_color'))); |
| 380 | - if($this->get('title_bold')=='Y') $attrs[] = "font-weight:bold;"; |
|
| 381 | - if($this->get('title_color') && $this->get('title_color') != 'N') $attrs[] = "color:#".$this->get('title_color'); |
|
| 380 | + if ($this->get('title_bold') == 'Y') $attrs[] = "font-weight:bold;"; |
|
| 381 | + if ($this->get('title_color') && $this->get('title_color') != 'N') $attrs[] = "color:#".$this->get('title_color'); |
|
| 382 | 382 | |
| 383 | - if(count($attrs)) return sprintf("<span style=\"%s\">%s</span>", implode(';',$attrs), htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
|
| 383 | + if (count($attrs)) return sprintf("<span style=\"%s\">%s</span>", implode(';', $attrs), htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
|
| 384 | 384 | else return htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | function getContentText($strlen = 0) |
| 388 | 388 | { |
| 389 | - if(!$this->document_srl) return; |
|
| 389 | + if (!$this->document_srl) return; |
|
| 390 | 390 | |
| 391 | - if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret'); |
|
| 391 | + if ($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret'); |
|
| 392 | 392 | |
| 393 | 393 | $result = $this->_checkAccessibleFromStatus(); |
| 394 | - if($result) $_SESSION['accessible'][$this->document_srl] = true; |
|
| 394 | + if ($result) $_SESSION['accessible'][$this->document_srl] = true; |
|
| 395 | 395 | |
| 396 | 396 | $content = $this->get('content'); |
| 397 | 397 | $content = preg_replace_callback('/<(object|param|embed)[^>]*/is', array($this, '_checkAllowScriptAccess'), $content); |
| 398 | 398 | $content = preg_replace_callback('/<object[^>]*>/is', array($this, '_addAllowScriptAccess'), $content); |
| 399 | 399 | |
| 400 | - if($strlen) return cut_str(strip_tags($content),$strlen,'...'); |
|
| 400 | + if ($strlen) return cut_str(strip_tags($content), $strlen, '...'); |
|
| 401 | 401 | |
| 402 | 402 | return htmlspecialchars($content); |
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | function _addAllowScriptAccess($m) |
| 406 | 406 | { |
| 407 | - if($this->allowscriptaccessList[$this->allowscriptaccessKey] == 1) |
|
| 407 | + if ($this->allowscriptaccessList[$this->allowscriptaccessKey] == 1) |
|
| 408 | 408 | { |
| 409 | 409 | $m[0] = $m[0].'<param name="allowscriptaccess" value="never"></param>'; |
| 410 | 410 | } |
@@ -414,26 +414,26 @@ discard block |
||
| 414 | 414 | |
| 415 | 415 | function _checkAllowScriptAccess($m) |
| 416 | 416 | { |
| 417 | - if($m[1] == 'object') |
|
| 417 | + if ($m[1] == 'object') |
|
| 418 | 418 | { |
| 419 | 419 | $this->allowscriptaccessList[] = 1; |
| 420 | 420 | } |
| 421 | 421 | |
| 422 | - if($m[1] == 'param') |
|
| 422 | + if ($m[1] == 'param') |
|
| 423 | 423 | { |
| 424 | - if(stripos($m[0], 'allowscriptaccess')) |
|
| 424 | + if (stripos($m[0], 'allowscriptaccess')) |
|
| 425 | 425 | { |
| 426 | 426 | $m[0] = '<param name="allowscriptaccess" value="never"'; |
| 427 | - if(substr($m[0], -1) == '/') |
|
| 427 | + if (substr($m[0], -1) == '/') |
|
| 428 | 428 | { |
| 429 | 429 | $m[0] .= '/'; |
| 430 | 430 | } |
| 431 | - $this->allowscriptaccessList[count($this->allowscriptaccessList)-1]--; |
|
| 431 | + $this->allowscriptaccessList[count($this->allowscriptaccessList) - 1]--; |
|
| 432 | 432 | } |
| 433 | 433 | } |
| 434 | - else if($m[1] == 'embed') |
|
| 434 | + else if ($m[1] == 'embed') |
|
| 435 | 435 | { |
| 436 | - if(stripos($m[0], 'allowscriptaccess')) |
|
| 436 | + if (stripos($m[0], 'allowscriptaccess')) |
|
| 437 | 437 | { |
| 438 | 438 | $m[0] = preg_replace('/always|samedomain/i', 'never', $m[0]); |
| 439 | 439 | } |
@@ -447,24 +447,24 @@ discard block |
||
| 447 | 447 | |
| 448 | 448 | function getContent($add_popup_menu = true, $add_content_info = true, $resource_realpath = false, $add_xe_content_class = true, $stripEmbedTagException = false) |
| 449 | 449 | { |
| 450 | - if(!$this->document_srl) return; |
|
| 450 | + if (!$this->document_srl) return; |
|
| 451 | 451 | |
| 452 | - if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret'); |
|
| 452 | + if ($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret'); |
|
| 453 | 453 | |
| 454 | 454 | $result = $this->_checkAccessibleFromStatus(); |
| 455 | - if($result) $_SESSION['accessible'][$this->document_srl] = true; |
|
| 455 | + if ($result) $_SESSION['accessible'][$this->document_srl] = true; |
|
| 456 | 456 | |
| 457 | 457 | $content = $this->get('content'); |
| 458 | - if(!$stripEmbedTagException) stripEmbedTagForAdmin($content, $this->get('member_srl')); |
|
| 458 | + if (!$stripEmbedTagException) stripEmbedTagForAdmin($content, $this->get('member_srl')); |
|
| 459 | 459 | |
| 460 | 460 | // Define a link if using a rewrite module |
| 461 | 461 | $oContext = &Context::getInstance(); |
| 462 | - if($oContext->allow_rewrite) |
|
| 462 | + if ($oContext->allow_rewrite) |
|
| 463 | 463 | { |
| 464 | - $content = preg_replace('/<a([ \t]+)href=("|\')\.\/\?/i',"<a href=\\2". Context::getRequestUri() ."?", $content); |
|
| 464 | + $content = preg_replace('/<a([ \t]+)href=("|\')\.\/\?/i', "<a href=\\2".Context::getRequestUri()."?", $content); |
|
| 465 | 465 | } |
| 466 | 466 | // To display a pop-up menu |
| 467 | - if($add_popup_menu) |
|
| 467 | + if ($add_popup_menu) |
|
| 468 | 468 | { |
| 469 | 469 | $content = sprintf( |
| 470 | 470 | '%s<div class="document_popup_menu"><a href="#popup_menu_area" class="document_%d" onclick="return false">%s</a></div>', |
@@ -473,10 +473,10 @@ discard block |
||
| 473 | 473 | ); |
| 474 | 474 | } |
| 475 | 475 | // If additional content information is set |
| 476 | - if($add_content_info) |
|
| 476 | + if ($add_content_info) |
|
| 477 | 477 | { |
| 478 | 478 | $memberSrl = $this->get('member_srl'); |
| 479 | - if($memberSrl < 0) |
|
| 479 | + if ($memberSrl < 0) |
|
| 480 | 480 | { |
| 481 | 481 | $memberSrl = 0; |
| 482 | 482 | } |
@@ -492,12 +492,12 @@ discard block |
||
| 492 | 492 | } |
| 493 | 493 | else |
| 494 | 494 | { |
| 495 | - if($add_xe_content_class) $content = sprintf('<div class="xe_content">%s</div>', $content); |
|
| 495 | + if ($add_xe_content_class) $content = sprintf('<div class="xe_content">%s</div>', $content); |
|
| 496 | 496 | } |
| 497 | 497 | // Change the image path to a valid absolute path if resource_realpath is true |
| 498 | - if($resource_realpath) |
|
| 498 | + if ($resource_realpath) |
|
| 499 | 499 | { |
| 500 | - $content = preg_replace_callback('/<img([^>]+)>/i',array($this,'replaceResourceRealPath'), $content); |
|
| 500 | + $content = preg_replace_callback('/<img([^>]+)>/i', array($this, 'replaceResourceRealPath'), $content); |
|
| 501 | 501 | } |
| 502 | 502 | |
| 503 | 503 | return $content; |
@@ -546,7 +546,7 @@ discard block |
||
| 546 | 546 | $content = trim(cut_str($content, $str_size, $tail)); |
| 547 | 547 | |
| 548 | 548 | // Replace back < , <, " |
| 549 | - $content = str_replace(array('<', '>', '"'),array('<', '>', '"'), $content); |
|
| 549 | + $content = str_replace(array('<', '>', '"'), array('<', '>', '"'), $content); |
|
| 550 | 550 | |
| 551 | 551 | return $content; |
| 552 | 552 | } |
@@ -559,13 +559,13 @@ discard block |
||
| 559 | 559 | function getRegdateTime() |
| 560 | 560 | { |
| 561 | 561 | $regdate = $this->get('regdate'); |
| 562 | - $year = substr($regdate,0,4); |
|
| 563 | - $month = substr($regdate,4,2); |
|
| 564 | - $day = substr($regdate,6,2); |
|
| 565 | - $hour = substr($regdate,8,2); |
|
| 566 | - $min = substr($regdate,10,2); |
|
| 567 | - $sec = substr($regdate,12,2); |
|
| 568 | - return mktime($hour,$min,$sec,$month,$day,$year); |
|
| 562 | + $year = substr($regdate, 0, 4); |
|
| 563 | + $month = substr($regdate, 4, 2); |
|
| 564 | + $day = substr($regdate, 6, 2); |
|
| 565 | + $hour = substr($regdate, 8, 2); |
|
| 566 | + $min = substr($regdate, 10, 2); |
|
| 567 | + $sec = substr($regdate, 12, 2); |
|
| 568 | + return mktime($hour, $min, $sec, $month, $day, $year); |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | function getRegdateGM() |
@@ -575,7 +575,7 @@ discard block |
||
| 575 | 575 | |
| 576 | 576 | function getRegdateDT() |
| 577 | 577 | { |
| 578 | - return $this->getRegdate('Y-m-d').'T'.$this->getRegdate('H:i:s').substr($GLOBALS['_time_zone'],0,3).':'.substr($GLOBALS['_time_zone'],3,2); |
|
| 578 | + return $this->getRegdate('Y-m-d').'T'.$this->getRegdate('H:i:s').substr($GLOBALS['_time_zone'], 0, 3).':'.substr($GLOBALS['_time_zone'], 3, 2); |
|
| 579 | 579 | } |
| 580 | 580 | |
| 581 | 581 | function getUpdate($format = 'Y.m.d H:i:s') |
@@ -585,13 +585,13 @@ discard block |
||
| 585 | 585 | |
| 586 | 586 | function getUpdateTime() |
| 587 | 587 | { |
| 588 | - $year = substr($this->get('last_update'),0,4); |
|
| 589 | - $month = substr($this->get('last_update'),4,2); |
|
| 590 | - $day = substr($this->get('last_update'),6,2); |
|
| 591 | - $hour = substr($this->get('last_update'),8,2); |
|
| 592 | - $min = substr($this->get('last_update'),10,2); |
|
| 593 | - $sec = substr($this->get('last_update'),12,2); |
|
| 594 | - return mktime($hour,$min,$sec,$month,$day,$year); |
|
| 588 | + $year = substr($this->get('last_update'), 0, 4); |
|
| 589 | + $month = substr($this->get('last_update'), 4, 2); |
|
| 590 | + $day = substr($this->get('last_update'), 6, 2); |
|
| 591 | + $hour = substr($this->get('last_update'), 8, 2); |
|
| 592 | + $min = substr($this->get('last_update'), 10, 2); |
|
| 593 | + $sec = substr($this->get('last_update'), 12, 2); |
|
| 594 | + return mktime($hour, $min, $sec, $month, $day, $year); |
|
| 595 | 595 | } |
| 596 | 596 | |
| 597 | 597 | function getUpdateGM() |
@@ -601,21 +601,21 @@ discard block |
||
| 601 | 601 | |
| 602 | 602 | function getUpdateDT() |
| 603 | 603 | { |
| 604 | - return $this->getUpdate('Y-m-d').'T'.$this->getUpdate('H:i:s').substr($GLOBALS['_time_zone'],0,3).':'.substr($GLOBALS['_time_zone'],3,2); |
|
| 604 | + return $this->getUpdate('Y-m-d').'T'.$this->getUpdate('H:i:s').substr($GLOBALS['_time_zone'], 0, 3).':'.substr($GLOBALS['_time_zone'], 3, 2); |
|
| 605 | 605 | } |
| 606 | 606 | |
| 607 | 607 | function getPermanentUrl() |
| 608 | 608 | { |
| 609 | - return getFullUrl('','document_srl',$this->get('document_srl')); |
|
| 609 | + return getFullUrl('', 'document_srl', $this->get('document_srl')); |
|
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | function getTrackbackUrl() |
| 613 | 613 | { |
| 614 | - if(!$this->document_srl) return; |
|
| 614 | + if (!$this->document_srl) return; |
|
| 615 | 615 | |
| 616 | 616 | // Generate a key to prevent spams |
| 617 | 617 | $oTrackbackModel = getModel('trackback'); |
| 618 | - if($oTrackbackModel) return $oTrackbackModel->getTrackbackUrl($this->document_srl, $this->getDocumentMid()); |
|
| 618 | + if ($oTrackbackModel) return $oTrackbackModel->getTrackbackUrl($this->document_srl, $this->getDocumentMid()); |
|
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | /** |
@@ -625,24 +625,24 @@ discard block |
||
| 625 | 625 | function updateReadedCount() |
| 626 | 626 | { |
| 627 | 627 | $oDocumentController = getController('document'); |
| 628 | - if($oDocumentController->updateReadedCount($this)) |
|
| 628 | + if ($oDocumentController->updateReadedCount($this)) |
|
| 629 | 629 | { |
| 630 | 630 | $readed_count = $this->get('readed_count'); |
| 631 | - $this->add('readed_count', $readed_count+1); |
|
| 631 | + $this->add('readed_count', $readed_count + 1); |
|
| 632 | 632 | } |
| 633 | 633 | } |
| 634 | 634 | |
| 635 | 635 | function isExtraVarsExists() |
| 636 | 636 | { |
| 637 | - if(!$this->get('module_srl')) return false; |
|
| 637 | + if (!$this->get('module_srl')) return false; |
|
| 638 | 638 | $oDocumentModel = getModel('document'); |
| 639 | 639 | $extra_keys = $oDocumentModel->getExtraKeys($this->get('module_srl')); |
| 640 | - return count($extra_keys)?true:false; |
|
| 640 | + return count($extra_keys) ? true : false; |
|
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | function getExtraVars() |
| 644 | 644 | { |
| 645 | - if(!$this->get('module_srl') || !$this->document_srl) return null; |
|
| 645 | + if (!$this->get('module_srl') || !$this->document_srl) return null; |
|
| 646 | 646 | |
| 647 | 647 | $oDocumentModel = getModel('document'); |
| 648 | 648 | return $oDocumentModel->getExtraVars($this->get('module_srl'), $this->document_srl); |
@@ -651,7 +651,7 @@ discard block |
||
| 651 | 651 | function getExtraValue($idx) |
| 652 | 652 | { |
| 653 | 653 | $extra_vars = $this->getExtraVars(); |
| 654 | - if(is_array($extra_vars) && array_key_exists($idx,$extra_vars)) |
|
| 654 | + if (is_array($extra_vars) && array_key_exists($idx, $extra_vars)) |
|
| 655 | 655 | { |
| 656 | 656 | return $extra_vars[$idx]->getValue(); |
| 657 | 657 | } |
@@ -664,7 +664,7 @@ discard block |
||
| 664 | 664 | function getExtraValueHTML($idx) |
| 665 | 665 | { |
| 666 | 666 | $extra_vars = $this->getExtraVars(); |
| 667 | - if(is_array($extra_vars) && array_key_exists($idx,$extra_vars)) |
|
| 667 | + if (is_array($extra_vars) && array_key_exists($idx, $extra_vars)) |
|
| 668 | 668 | { |
| 669 | 669 | return $extra_vars[$idx]->getValueHTML(); |
| 670 | 670 | } |
@@ -678,16 +678,16 @@ discard block |
||
| 678 | 678 | { |
| 679 | 679 | $extra_vars = $this->getExtraVars(); |
| 680 | 680 | |
| 681 | - if($extra_vars) |
|
| 681 | + if ($extra_vars) |
|
| 682 | 682 | { |
| 683 | 683 | // Handle extra variable(eid) |
| 684 | - foreach($extra_vars as $idx => $key) |
|
| 684 | + foreach ($extra_vars as $idx => $key) |
|
| 685 | 685 | { |
| 686 | 686 | $extra_eid[$key->eid] = $key; |
| 687 | 687 | } |
| 688 | 688 | } |
| 689 | 689 | |
| 690 | - if(is_array($extra_eid) && array_key_exists($eid,$extra_eid)) |
|
| 690 | + if (is_array($extra_eid) && array_key_exists($eid, $extra_eid)) |
|
| 691 | 691 | { |
| 692 | 692 | return $extra_eid[$eid]->getValue(); |
| 693 | 693 | } |
@@ -701,12 +701,12 @@ discard block |
||
| 701 | 701 | { |
| 702 | 702 | $extra_vars = $this->getExtraVars(); |
| 703 | 703 | // Handle extra variable(eid) |
| 704 | - foreach($extra_vars as $idx => $key) |
|
| 704 | + foreach ($extra_vars as $idx => $key) |
|
| 705 | 705 | { |
| 706 | 706 | $extra_eid[$key->eid] = $key; |
| 707 | 707 | } |
| 708 | 708 | |
| 709 | - if(is_array($extra_eid) && array_key_exists($eid,$extra_eid)) |
|
| 709 | + if (is_array($extra_eid) && array_key_exists($eid, $extra_eid)) |
|
| 710 | 710 | { |
| 711 | 711 | return $extra_eid[$eid]->getValueHTML(); |
| 712 | 712 | } |
@@ -730,13 +730,13 @@ discard block |
||
| 730 | 730 | |
| 731 | 731 | function getComments() |
| 732 | 732 | { |
| 733 | - if(!$this->getCommentCount()) return; |
|
| 734 | - if(!$this->isGranted() && $this->isSecret()) return; |
|
| 733 | + if (!$this->getCommentCount()) return; |
|
| 734 | + if (!$this->isGranted() && $this->isSecret()) return; |
|
| 735 | 735 | // cpage is a number of comment pages |
| 736 | 736 | $cpageStr = sprintf('%d_cpage', $this->document_srl); |
| 737 | 737 | $cpage = Context::get($cpageStr); |
| 738 | 738 | |
| 739 | - if(!$cpage) |
|
| 739 | + if (!$cpage) |
|
| 740 | 740 | { |
| 741 | 741 | $cpage = Context::get('cpage'); |
| 742 | 742 | } |
@@ -744,19 +744,19 @@ discard block |
||
| 744 | 744 | // Get a list of comments |
| 745 | 745 | $oCommentModel = getModel('comment'); |
| 746 | 746 | $output = $oCommentModel->getCommentList($this->document_srl, $cpage, $is_admin); |
| 747 | - if(!$output->toBool() || !count($output->data)) return; |
|
| 747 | + if (!$output->toBool() || !count($output->data)) return; |
|
| 748 | 748 | // Create commentItem object from a comment list |
| 749 | 749 | // If admin priviledge is granted on parent posts, you can read its child posts. |
| 750 | 750 | $accessible = array(); |
| 751 | 751 | $comment_list = array(); |
| 752 | - foreach($output->data as $key => $val) |
|
| 752 | + foreach ($output->data as $key => $val) |
|
| 753 | 753 | { |
| 754 | 754 | $oCommentItem = new commentItem(); |
| 755 | 755 | $oCommentItem->setAttribute($val); |
| 756 | 756 | // If permission is granted to the post, you can access it temporarily |
| 757 | - if($oCommentItem->isGranted()) $accessible[$val->comment_srl] = true; |
|
| 757 | + if ($oCommentItem->isGranted()) $accessible[$val->comment_srl] = true; |
|
| 758 | 758 | // If the comment is set to private and it belongs child post, it is allowable to read the comment for who has a admin privilege on its parent post |
| 759 | - if($val->parent_srl>0 && $val->is_secret == 'Y' && !$oCommentItem->isAccessible() && $accessible[$val->parent_srl]===true) |
|
| 759 | + if ($val->parent_srl > 0 && $val->is_secret == 'Y' && !$oCommentItem->isAccessible() && $accessible[$val->parent_srl] === true) |
|
| 760 | 760 | { |
| 761 | 761 | $oCommentItem->setAccessible(); |
| 762 | 762 | } |
@@ -765,7 +765,7 @@ discard block |
||
| 765 | 765 | // Variable setting to be displayed on the skin |
| 766 | 766 | Context::set($cpageStr, $output->page_navigation->cur_page); |
| 767 | 767 | Context::set('cpage', $output->page_navigation->cur_page); |
| 768 | - if($output->total_page>1) $this->comment_page_navigation = $output->page_navigation; |
|
| 768 | + if ($output->total_page > 1) $this->comment_page_navigation = $output->page_navigation; |
|
| 769 | 769 | |
| 770 | 770 | return $comment_list; |
| 771 | 771 | } |
@@ -777,9 +777,9 @@ discard block |
||
| 777 | 777 | |
| 778 | 778 | function getTrackbacks() |
| 779 | 779 | { |
| 780 | - if(!$this->document_srl) return; |
|
| 780 | + if (!$this->document_srl) return; |
|
| 781 | 781 | |
| 782 | - if(!$this->allowTrackback() || !$this->get('trackback_count')) return; |
|
| 782 | + if (!$this->allowTrackback() || !$this->get('trackback_count')) return; |
|
| 783 | 783 | |
| 784 | 784 | $oTrackbackModel = getModel('trackback'); |
| 785 | 785 | return $oTrackbackModel->getTrackbackList($this->document_srl, $is_admin); |
@@ -787,47 +787,47 @@ discard block |
||
| 787 | 787 | |
| 788 | 788 | function thumbnailExists($width = 80, $height = 0, $type = '') |
| 789 | 789 | { |
| 790 | - if(!$this->document_srl) return false; |
|
| 791 | - if(!$this->getThumbnail($width, $height, $type)) return false; |
|
| 790 | + if (!$this->document_srl) return false; |
|
| 791 | + if (!$this->getThumbnail($width, $height, $type)) return false; |
|
| 792 | 792 | return true; |
| 793 | 793 | } |
| 794 | 794 | |
| 795 | 795 | function getThumbnail($width = 80, $height = 0, $thumbnail_type = '') |
| 796 | 796 | { |
| 797 | 797 | // Return false if the document doesn't exist |
| 798 | - if(!$this->document_srl) return; |
|
| 798 | + if (!$this->document_srl) return; |
|
| 799 | 799 | |
| 800 | - if($this->isSecret() && !$this->isGranted()) |
|
| 800 | + if ($this->isSecret() && !$this->isGranted()) |
|
| 801 | 801 | { |
| 802 | 802 | return; |
| 803 | 803 | } |
| 804 | 804 | |
| 805 | 805 | // If not specify its height, create a square |
| 806 | - if(!$height) $height = $width; |
|
| 806 | + if (!$height) $height = $width; |
|
| 807 | 807 | |
| 808 | 808 | // Return false if neither attachement nor image files in the document |
| 809 | 809 | $content = $this->get('content'); |
| 810 | - if(!$this->get('uploaded_count')) |
|
| 810 | + if (!$this->get('uploaded_count')) |
|
| 811 | 811 | { |
| 812 | - if(!$content) |
|
| 812 | + if (!$content) |
|
| 813 | 813 | { |
| 814 | 814 | $args = new stdClass(); |
| 815 | 815 | $args->document_srl = $this->document_srl; |
| 816 | 816 | $output = executeQuery('document.getDocument', $args, array('content')); |
| 817 | - if($output->toBool() && $output->data) |
|
| 817 | + if ($output->toBool() && $output->data) |
|
| 818 | 818 | { |
| 819 | 819 | $content = $output->data->content; |
| 820 | 820 | $this->add('content', $content); |
| 821 | 821 | } |
| 822 | 822 | } |
| 823 | 823 | |
| 824 | - if(!preg_match("!<img!is", $content)) return; |
|
| 824 | + if (!preg_match("!<img!is", $content)) return; |
|
| 825 | 825 | } |
| 826 | 826 | // Get thumbnai_type information from document module's configuration |
| 827 | - if(!in_array($thumbnail_type, array('crop','ratio'))) |
|
| 827 | + if (!in_array($thumbnail_type, array('crop', 'ratio'))) |
|
| 828 | 828 | { |
| 829 | 829 | $config = $GLOBALS['__document_config__']; |
| 830 | - if(!$config) |
|
| 830 | + if (!$config) |
|
| 831 | 831 | { |
| 832 | 832 | $oDocumentModel = getModel('document'); |
| 833 | 833 | $config = $oDocumentModel->getDocumentConfig(); |
@@ -837,15 +837,15 @@ discard block |
||
| 837 | 837 | } |
| 838 | 838 | |
| 839 | 839 | // Define thumbnail information |
| 840 | - $thumbnail_path = sprintf('files/thumbnails/%s',getNumberingPath($this->document_srl, 3)); |
|
| 840 | + $thumbnail_path = sprintf('files/thumbnails/%s', getNumberingPath($this->document_srl, 3)); |
|
| 841 | 841 | $thumbnail_file = sprintf('%s%dx%d.%s.jpg', $thumbnail_path, $width, $height, $thumbnail_type); |
| 842 | 842 | $thumbnail_lockfile = sprintf('%s%dx%d.%s.lock', $thumbnail_path, $width, $height, $thumbnail_type); |
| 843 | 843 | $thumbnail_url = Context::getRequestUri().$thumbnail_file; |
| 844 | 844 | |
| 845 | 845 | // Return false if thumbnail file exists and its size is 0. Otherwise, return its path |
| 846 | - if(file_exists($thumbnail_file) || file_exists($thumbnail_lockfile)) |
|
| 846 | + if (file_exists($thumbnail_file) || file_exists($thumbnail_lockfile)) |
|
| 847 | 847 | { |
| 848 | - if(filesize($thumbnail_file) < 1) |
|
| 848 | + if (filesize($thumbnail_file) < 1) |
|
| 849 | 849 | { |
| 850 | 850 | return FALSE; |
| 851 | 851 | } |
@@ -863,64 +863,64 @@ discard block |
||
| 863 | 863 | $is_tmp_file = false; |
| 864 | 864 | |
| 865 | 865 | // Find an iamge file among attached files if exists |
| 866 | - if($this->hasUploadedFiles()) |
|
| 866 | + if ($this->hasUploadedFiles()) |
|
| 867 | 867 | { |
| 868 | 868 | $file_list = $this->getUploadedFiles(); |
| 869 | 869 | |
| 870 | 870 | $first_image = null; |
| 871 | - foreach($file_list as $file) |
|
| 871 | + foreach ($file_list as $file) |
|
| 872 | 872 | { |
| 873 | - if($file->direct_download !== 'Y') continue; |
|
| 873 | + if ($file->direct_download !== 'Y') continue; |
|
| 874 | 874 | |
| 875 | - if($file->cover_image === 'Y' && file_exists($file->uploaded_filename)) |
|
| 875 | + if ($file->cover_image === 'Y' && file_exists($file->uploaded_filename)) |
|
| 876 | 876 | { |
| 877 | 877 | $source_file = $file->uploaded_filename; |
| 878 | 878 | break; |
| 879 | 879 | } |
| 880 | 880 | |
| 881 | - if($first_image) continue; |
|
| 881 | + if ($first_image) continue; |
|
| 882 | 882 | |
| 883 | - if(preg_match("/\.(jpe?g|png|gif|bmp)$/i", $file->source_filename)) |
|
| 883 | + if (preg_match("/\.(jpe?g|png|gif|bmp)$/i", $file->source_filename)) |
|
| 884 | 884 | { |
| 885 | - if(file_exists($file->uploaded_filename)) |
|
| 885 | + if (file_exists($file->uploaded_filename)) |
|
| 886 | 886 | { |
| 887 | 887 | $first_image = $file->uploaded_filename; |
| 888 | 888 | } |
| 889 | 889 | } |
| 890 | 890 | } |
| 891 | 891 | |
| 892 | - if(!$source_file && $first_image) |
|
| 892 | + if (!$source_file && $first_image) |
|
| 893 | 893 | { |
| 894 | 894 | $source_file = $first_image; |
| 895 | 895 | } |
| 896 | 896 | } |
| 897 | 897 | // If not exists, file an image file from the content |
| 898 | 898 | $is_tmp_file = false; |
| 899 | - if(!$source_file) |
|
| 899 | + if (!$source_file) |
|
| 900 | 900 | { |
| 901 | 901 | $random = new Password(); |
| 902 | 902 | |
| 903 | 903 | preg_match_all("!<img[^>]*src=(?:\"|\')([^\"\']*?)(?:\"|\')!is", $content, $matches, PREG_SET_ORDER); |
| 904 | 904 | |
| 905 | - foreach($matches as $target_image) |
|
| 905 | + foreach ($matches as $target_image) |
|
| 906 | 906 | { |
| 907 | 907 | $target_src = trim($target_image[1]); |
| 908 | - if(preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) continue; |
|
| 908 | + if (preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) continue; |
|
| 909 | 909 | |
| 910 | - if(!preg_match('/^(http|https):\/\//i',$target_src)) |
|
| 910 | + if (!preg_match('/^(http|https):\/\//i', $target_src)) |
|
| 911 | 911 | { |
| 912 | 912 | $target_src = Context::getRequestUri().$target_src; |
| 913 | 913 | } |
| 914 | 914 | |
| 915 | 915 | $target_src = htmlspecialchars_decode($target_src); |
| 916 | 916 | |
| 917 | - $tmp_file = _XE_PATH_ . 'files/cache/tmp/' . $random->createSecureSalt(32, 'hex'); |
|
| 917 | + $tmp_file = _XE_PATH_.'files/cache/tmp/'.$random->createSecureSalt(32, 'hex'); |
|
| 918 | 918 | FileHandler::getRemoteFile($target_src, $tmp_file); |
| 919 | - if(!file_exists($tmp_file)) continue; |
|
| 919 | + if (!file_exists($tmp_file)) continue; |
|
| 920 | 920 | |
| 921 | 921 | $imageinfo = getimagesize($tmp_file); |
| 922 | 922 | list($_w, $_h) = $imageinfo; |
| 923 | - if($imageinfo === false || ($_w < ($width * 0.3) && $_h < ($height * 0.3))) { |
|
| 923 | + if ($imageinfo === false || ($_w < ($width * 0.3) && $_h < ($height * 0.3))) { |
|
| 924 | 924 | FileHandler::removeFile($tmp_file); |
| 925 | 925 | continue; |
| 926 | 926 | } |
@@ -931,13 +931,13 @@ discard block |
||
| 931 | 931 | } |
| 932 | 932 | } |
| 933 | 933 | |
| 934 | - if($source_file) |
|
| 934 | + if ($source_file) |
|
| 935 | 935 | { |
| 936 | 936 | $output = FileHandler::createImageFile($source_file, $thumbnail_file, $width, $height, 'jpg', $thumbnail_type); |
| 937 | 937 | } |
| 938 | 938 | |
| 939 | 939 | // Remove source file if it was temporary |
| 940 | - if($is_tmp_file) |
|
| 940 | + if ($is_tmp_file) |
|
| 941 | 941 | { |
| 942 | 942 | FileHandler::removeFile($source_file); |
| 943 | 943 | } |
@@ -946,14 +946,14 @@ discard block |
||
| 946 | 946 | FileHandler::removeFile($thumbnail_lockfile); |
| 947 | 947 | |
| 948 | 948 | // Return the thumbnail path if it was successfully generated |
| 949 | - if($output) |
|
| 949 | + if ($output) |
|
| 950 | 950 | { |
| 951 | 951 | return $thumbnail_url; |
| 952 | 952 | } |
| 953 | 953 | // Create an empty file if thumbnail generation failed |
| 954 | 954 | else |
| 955 | 955 | { |
| 956 | - FileHandler::writeFile($thumbnail_file, '','w'); |
|
| 956 | + FileHandler::writeFile($thumbnail_file, '', 'w'); |
|
| 957 | 957 | } |
| 958 | 958 | |
| 959 | 959 | return; |
@@ -967,21 +967,21 @@ discard block |
||
| 967 | 967 | */ |
| 968 | 968 | function getExtraImages($time_interval = 43200) |
| 969 | 969 | { |
| 970 | - if(!$this->document_srl) return; |
|
| 970 | + if (!$this->document_srl) return; |
|
| 971 | 971 | // variables for icon list |
| 972 | 972 | $buffs = array(); |
| 973 | 973 | |
| 974 | 974 | $check_files = false; |
| 975 | 975 | |
| 976 | 976 | // Check if secret post is |
| 977 | - if($this->isSecret()) $buffs[] = "secret"; |
|
| 977 | + if ($this->isSecret()) $buffs[] = "secret"; |
|
| 978 | 978 | |
| 979 | 979 | // Set the latest time |
| 980 | - $time_check = date("YmdHis", $_SERVER['REQUEST_TIME']-$time_interval); |
|
| 980 | + $time_check = date("YmdHis", $_SERVER['REQUEST_TIME'] - $time_interval); |
|
| 981 | 981 | |
| 982 | 982 | // Check new post |
| 983 | - if($this->get('regdate')>$time_check) $buffs[] = "new"; |
|
| 984 | - else if($this->get('last_update')>$time_check) $buffs[] = "update"; |
|
| 983 | + if ($this->get('regdate') > $time_check) $buffs[] = "new"; |
|
| 984 | + else if ($this->get('last_update') > $time_check) $buffs[] = "update"; |
|
| 985 | 985 | |
| 986 | 986 | /* |
| 987 | 987 | $content = $this->get('content'); |
@@ -1004,14 +1004,14 @@ discard block |
||
| 1004 | 1004 | */ |
| 1005 | 1005 | |
| 1006 | 1006 | // Check the attachment |
| 1007 | - if($this->hasUploadedFiles()) $buffs[] = "file"; |
|
| 1007 | + if ($this->hasUploadedFiles()) $buffs[] = "file"; |
|
| 1008 | 1008 | |
| 1009 | 1009 | return $buffs; |
| 1010 | 1010 | } |
| 1011 | 1011 | |
| 1012 | 1012 | function getStatus() |
| 1013 | 1013 | { |
| 1014 | - if(!$this->get('status')) return $this->getDefaultStatus(); |
|
| 1014 | + if (!$this->get('status')) return $this->getDefaultStatus(); |
|
| 1015 | 1015 | return $this->get('status'); |
| 1016 | 1016 | } |
| 1017 | 1017 | |
@@ -1022,15 +1022,15 @@ discard block |
||
| 1022 | 1022 | */ |
| 1023 | 1023 | function printExtraImages($time_check = 43200) |
| 1024 | 1024 | { |
| 1025 | - if(!$this->document_srl) return; |
|
| 1025 | + if (!$this->document_srl) return; |
|
| 1026 | 1026 | // Get the icon directory |
| 1027 | - $path = sprintf('%s%s',getUrl(), 'modules/document/tpl/icons/'); |
|
| 1027 | + $path = sprintf('%s%s', getUrl(), 'modules/document/tpl/icons/'); |
|
| 1028 | 1028 | |
| 1029 | 1029 | $buffs = $this->getExtraImages($time_check); |
| 1030 | - if(!count($buffs)) return; |
|
| 1030 | + if (!count($buffs)) return; |
|
| 1031 | 1031 | |
| 1032 | 1032 | $buff = array(); |
| 1033 | - foreach($buffs as $key => $val) |
|
| 1033 | + foreach ($buffs as $key => $val) |
|
| 1034 | 1034 | { |
| 1035 | 1035 | $buff[] = sprintf('<img src="%s%s.gif" alt="%s" title="%s" style="margin-right:2px;" />', $path, $val, $val, $val); |
| 1036 | 1036 | } |
@@ -1039,20 +1039,20 @@ discard block |
||
| 1039 | 1039 | |
| 1040 | 1040 | function hasUploadedFiles() |
| 1041 | 1041 | { |
| 1042 | - if(!$this->document_srl) return; |
|
| 1042 | + if (!$this->document_srl) return; |
|
| 1043 | 1043 | |
| 1044 | - if($this->isSecret() && !$this->isGranted()) return false; |
|
| 1045 | - return $this->get('uploaded_count')? true : false; |
|
| 1044 | + if ($this->isSecret() && !$this->isGranted()) return false; |
|
| 1045 | + return $this->get('uploaded_count') ? true : false; |
|
| 1046 | 1046 | } |
| 1047 | 1047 | |
| 1048 | 1048 | function getUploadedFiles($sortIndex = 'file_srl') |
| 1049 | 1049 | { |
| 1050 | - if(!$this->document_srl) return; |
|
| 1050 | + if (!$this->document_srl) return; |
|
| 1051 | 1051 | |
| 1052 | - if($this->isSecret() && !$this->isGranted()) return; |
|
| 1053 | - if(!$this->get('uploaded_count')) return; |
|
| 1052 | + if ($this->isSecret() && !$this->isGranted()) return; |
|
| 1053 | + if (!$this->get('uploaded_count')) return; |
|
| 1054 | 1054 | |
| 1055 | - if(!$this->uploadedFiles[$sortIndex]) |
|
| 1055 | + if (!$this->uploadedFiles[$sortIndex]) |
|
| 1056 | 1056 | { |
| 1057 | 1057 | $oFileModel = getModel('file'); |
| 1058 | 1058 | $this->uploadedFiles[$sortIndex] = $oFileModel->getFiles($this->document_srl, array(), $sortIndex, true); |
@@ -1068,7 +1068,7 @@ discard block |
||
| 1068 | 1068 | function getEditor() |
| 1069 | 1069 | { |
| 1070 | 1070 | $module_srl = $this->get('module_srl'); |
| 1071 | - if(!$module_srl) $module_srl = Context::get('module_srl'); |
|
| 1071 | + if (!$module_srl) $module_srl = Context::get('module_srl'); |
|
| 1072 | 1072 | |
| 1073 | 1073 | $oEditorModel = getModel('editor'); |
| 1074 | 1074 | return $oEditorModel->getModuleEditor('document', $module_srl, $this->document_srl, 'document_srl', 'content'); |
@@ -1083,7 +1083,7 @@ discard block |
||
| 1083 | 1083 | { |
| 1084 | 1084 | // Return false if not authorized, if a secret document, if the document is set not to allow any comment |
| 1085 | 1085 | if (!$this->allowComment()) return false; |
| 1086 | - if(!$this->isGranted() && $this->isSecret()) return false; |
|
| 1086 | + if (!$this->isGranted() && $this->isSecret()) return false; |
|
| 1087 | 1087 | |
| 1088 | 1088 | return true; |
| 1089 | 1089 | } |
@@ -1094,7 +1094,7 @@ discard block |
||
| 1094 | 1094 | */ |
| 1095 | 1095 | function getCommentEditor() |
| 1096 | 1096 | { |
| 1097 | - if(!$this->isEnableComment()) return; |
|
| 1097 | + if (!$this->isEnableComment()) return; |
|
| 1098 | 1098 | |
| 1099 | 1099 | $oEditorModel = getModel('editor'); |
| 1100 | 1100 | return $oEditorModel->getModuleEditor('comment', $this->get('module_srl'), $comment_srl, 'comment_srl', 'content'); |
@@ -1106,10 +1106,10 @@ discard block |
||
| 1106 | 1106 | */ |
| 1107 | 1107 | function getProfileImage() |
| 1108 | 1108 | { |
| 1109 | - if(!$this->isExists() || !$this->get('member_srl')) return; |
|
| 1109 | + if (!$this->isExists() || !$this->get('member_srl')) return; |
|
| 1110 | 1110 | $oMemberModel = getModel('member'); |
| 1111 | 1111 | $profile_info = $oMemberModel->getProfileImage($this->get('member_srl')); |
| 1112 | - if(!$profile_info) return; |
|
| 1112 | + if (!$profile_info) return; |
|
| 1113 | 1113 | |
| 1114 | 1114 | return $profile_info->src; |
| 1115 | 1115 | } |
@@ -1121,21 +1121,21 @@ discard block |
||
| 1121 | 1121 | function getSignature() |
| 1122 | 1122 | { |
| 1123 | 1123 | // Pass if a document doesn't exist |
| 1124 | - if(!$this->isExists() || !$this->get('member_srl')) return; |
|
| 1124 | + if (!$this->isExists() || !$this->get('member_srl')) return; |
|
| 1125 | 1125 | // Get signature information |
| 1126 | 1126 | $oMemberModel = getModel('member'); |
| 1127 | 1127 | $signature = $oMemberModel->getSignature($this->get('member_srl')); |
| 1128 | 1128 | // Check if a maximum height of signiture is set in the member module |
| 1129 | - if(!isset($GLOBALS['__member_signature_max_height'])) |
|
| 1129 | + if (!isset($GLOBALS['__member_signature_max_height'])) |
|
| 1130 | 1130 | { |
| 1131 | 1131 | $oModuleModel = getModel('module'); |
| 1132 | 1132 | $member_config = $oModuleModel->getModuleConfig('member'); |
| 1133 | 1133 | $GLOBALS['__member_signature_max_height'] = $member_config->signature_max_height; |
| 1134 | 1134 | } |
| 1135 | - if($signature) |
|
| 1135 | + if ($signature) |
|
| 1136 | 1136 | { |
| 1137 | 1137 | $max_signature_height = $GLOBALS['__member_signature_max_height']; |
| 1138 | - if($max_signature_height) $signature = sprintf('<div style="max-height:%dpx;overflow:auto;overflow-x:hidden;height:expression(this.scrollHeight > %d ? \'%dpx\': \'auto\')">%s</div>', $max_signature_height, $max_signature_height, $max_signature_height, $signature); |
|
| 1138 | + if ($max_signature_height) $signature = sprintf('<div style="max-height:%dpx;overflow:auto;overflow-x:hidden;height:expression(this.scrollHeight > %d ? \'%dpx\': \'auto\')">%s</div>', $max_signature_height, $max_signature_height, $max_signature_height, $signature); |
|
| 1139 | 1139 | } |
| 1140 | 1140 | |
| 1141 | 1141 | return $signature; |
@@ -1148,7 +1148,7 @@ discard block |
||
| 1148 | 1148 | */ |
| 1149 | 1149 | function replaceResourceRealPath($matches) |
| 1150 | 1150 | { |
| 1151 | - return preg_replace('/src=(["\']?)files/i','src=$1'.Context::getRequestUri().'files', $matches[0]); |
|
| 1151 | + return preg_replace('/src=(["\']?)files/i', 'src=$1'.Context::getRequestUri().'files', $matches[0]); |
|
| 1152 | 1152 | } |
| 1153 | 1153 | |
| 1154 | 1154 | /** |
@@ -1159,19 +1159,19 @@ discard block |
||
| 1159 | 1159 | function _checkAccessibleFromStatus() |
| 1160 | 1160 | { |
| 1161 | 1161 | $logged_info = Context::get('logged_info'); |
| 1162 | - if($logged_info->is_admin == 'Y') return true; |
|
| 1162 | + if ($logged_info->is_admin == 'Y') return true; |
|
| 1163 | 1163 | |
| 1164 | 1164 | $status = $this->get('status'); |
| 1165 | - if(empty($status)) return false; |
|
| 1165 | + if (empty($status)) return false; |
|
| 1166 | 1166 | |
| 1167 | 1167 | $oDocumentModel = getModel('document'); |
| 1168 | 1168 | $configStatusList = $oDocumentModel->getStatusList(); |
| 1169 | 1169 | |
| 1170 | - if($status == $configStatusList['public'] || $status == $configStatusList['publish']) |
|
| 1170 | + if ($status == $configStatusList['public'] || $status == $configStatusList['publish']) |
|
| 1171 | 1171 | return true; |
| 1172 | - else if($status == $configStatusList['private'] || $status == $configStatusList['secret']) |
|
| 1172 | + else if ($status == $configStatusList['private'] || $status == $configStatusList['secret']) |
|
| 1173 | 1173 | { |
| 1174 | - if($this->get('member_srl') == $logged_info->member_srl) |
|
| 1174 | + if ($this->get('member_srl') == $logged_info->member_srl) |
|
| 1175 | 1175 | return true; |
| 1176 | 1176 | } |
| 1177 | 1177 | return false; |
@@ -74,7 +74,9 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | function _loadFromDB($load_extra_vars = true) |
| 76 | 76 | { |
| 77 | - if(!$this->document_srl) return; |
|
| 77 | + if(!$this->document_srl) { |
|
| 78 | + return; |
|
| 79 | + } |
|
| 78 | 80 | |
| 79 | 81 | $document_item = false; |
| 80 | 82 | $cache_put = false; |
@@ -106,8 +108,7 @@ discard block |
||
| 106 | 108 | { |
| 107 | 109 | $oCacheHandler->put($cache_key, $document_item); |
| 108 | 110 | } |
| 109 | - } |
|
| 110 | - else |
|
| 111 | + } else |
|
| 111 | 112 | { |
| 112 | 113 | $document_item->readed_count = $output->data->readed_count; |
| 113 | 114 | $document_item->voted_count = $output->data->voted_count; |
@@ -154,18 +155,28 @@ discard block |
||
| 154 | 155 | |
| 155 | 156 | function isGranted() |
| 156 | 157 | { |
| 157 | - if($_SESSION['own_document'][$this->document_srl]) return true; |
|
| 158 | + if($_SESSION['own_document'][$this->document_srl]) { |
|
| 159 | + return true; |
|
| 160 | + } |
|
| 158 | 161 | |
| 159 | - if(!Context::get('is_logged')) return false; |
|
| 162 | + if(!Context::get('is_logged')) { |
|
| 163 | + return false; |
|
| 164 | + } |
|
| 160 | 165 | |
| 161 | 166 | $logged_info = Context::get('logged_info'); |
| 162 | - if($logged_info->is_admin == 'Y') return true; |
|
| 167 | + if($logged_info->is_admin == 'Y') { |
|
| 168 | + return true; |
|
| 169 | + } |
|
| 163 | 170 | |
| 164 | 171 | $oModuleModel = getModel('module'); |
| 165 | 172 | $grant = $oModuleModel->getGrant($oModuleModel->getModuleInfoByModuleSrl($this->get('module_srl')), $logged_info); |
| 166 | - if($grant->manager) return true; |
|
| 173 | + if($grant->manager) { |
|
| 174 | + return true; |
|
| 175 | + } |
|
| 167 | 176 | |
| 168 | - if($this->get('member_srl') && ($this->get('member_srl') == $logged_info->member_srl || $this->get('member_srl')*-1 == $logged_info->member_srl)) return true; |
|
| 177 | + if($this->get('member_srl') && ($this->get('member_srl') == $logged_info->member_srl || $this->get('member_srl')*-1 == $logged_info->member_srl)) { |
|
| 178 | + return true; |
|
| 179 | + } |
|
| 169 | 180 | |
| 170 | 181 | return false; |
| 171 | 182 | } |
@@ -183,7 +194,9 @@ discard block |
||
| 183 | 194 | function allowComment() |
| 184 | 195 | { |
| 185 | 196 | // init write, document is not exists. so allow comment status is true |
| 186 | - if(!$this->isExists()) return true; |
|
| 197 | + if(!$this->isExists()) { |
|
| 198 | + return true; |
|
| 199 | + } |
|
| 187 | 200 | |
| 188 | 201 | return $this->get('comment_status') == 'ALLOW' ? true : false; |
| 189 | 202 | } |
@@ -198,8 +211,7 @@ discard block |
||
| 198 | 211 | if(!getClass('trackback')) |
| 199 | 212 | { |
| 200 | 213 | $allow_trackback_status = false; |
| 201 | - } |
|
| 202 | - else |
|
| 214 | + } else |
|
| 203 | 215 | { |
| 204 | 216 | // If the trackback module is configured to be disabled, do not allow. Otherwise, check the setting of each module. |
| 205 | 217 | $oModuleModel = getModel('module'); |
@@ -210,15 +222,21 @@ discard block |
||
| 210 | 222 | $trackback_config = new stdClass(); |
| 211 | 223 | } |
| 212 | 224 | |
| 213 | - if(!isset($trackback_config->enable_trackback)) $trackback_config->enable_trackback = 'Y'; |
|
| 214 | - if($trackback_config->enable_trackback != 'Y') $allow_trackback_status = false; |
|
| 215 | - else |
|
| 225 | + if(!isset($trackback_config->enable_trackback)) { |
|
| 226 | + $trackback_config->enable_trackback = 'Y'; |
|
| 227 | + } |
|
| 228 | + if($trackback_config->enable_trackback != 'Y') { |
|
| 229 | + $allow_trackback_status = false; |
|
| 230 | + } else |
|
| 216 | 231 | { |
| 217 | 232 | $module_srl = $this->get('module_srl'); |
| 218 | 233 | // Check settings of each module |
| 219 | 234 | $module_config = $oModuleModel->getModulePartConfig('trackback', $module_srl); |
| 220 | - if($module_config->enable_trackback == 'N') $allow_trackback_status = false; |
|
| 221 | - else if($this->get('allow_trackback')=='Y' || !$this->isExists()) $allow_trackback_status = true; |
|
| 235 | + if($module_config->enable_trackback == 'N') { |
|
| 236 | + $allow_trackback_status = false; |
|
| 237 | + } else if($this->get('allow_trackback')=='Y' || !$this->isExists()) { |
|
| 238 | + $allow_trackback_status = true; |
|
| 239 | + } |
|
| 222 | 240 | } |
| 223 | 241 | } |
| 224 | 242 | } |
@@ -227,14 +245,18 @@ discard block |
||
| 227 | 245 | |
| 228 | 246 | function isLocked() |
| 229 | 247 | { |
| 230 | - if(!$this->isExists()) return false; |
|
| 248 | + if(!$this->isExists()) { |
|
| 249 | + return false; |
|
| 250 | + } |
|
| 231 | 251 | |
| 232 | 252 | return $this->get('comment_status') == 'ALLOW' ? false : true; |
| 233 | 253 | } |
| 234 | 254 | |
| 235 | 255 | function isEditable() |
| 236 | 256 | { |
| 237 | - if($this->isGranted() || !$this->get('member_srl')) return true; |
|
| 257 | + if($this->isGranted() || !$this->get('member_srl')) { |
|
| 258 | + return true; |
|
| 259 | + } |
|
| 238 | 260 | return false; |
| 239 | 261 | } |
| 240 | 262 | |
@@ -256,9 +278,14 @@ discard block |
||
| 256 | 278 | |
| 257 | 279 | function doCart() |
| 258 | 280 | { |
| 259 | - if(!$this->document_srl) return false; |
|
| 260 | - if($this->isCarted()) $this->removeCart(); |
|
| 261 | - else $this->addCart(); |
|
| 281 | + if(!$this->document_srl) { |
|
| 282 | + return false; |
|
| 283 | + } |
|
| 284 | + if($this->isCarted()) { |
|
| 285 | + $this->removeCart(); |
|
| 286 | + } else { |
|
| 287 | + $this->addCart(); |
|
| 288 | + } |
|
| 262 | 289 | } |
| 263 | 290 | |
| 264 | 291 | function addCart() |
@@ -284,16 +311,26 @@ discard block |
||
| 284 | 311 | */ |
| 285 | 312 | function notify($type, $content) |
| 286 | 313 | { |
| 287 | - if(!$this->document_srl) return; |
|
| 314 | + if(!$this->document_srl) { |
|
| 315 | + return; |
|
| 316 | + } |
|
| 288 | 317 | // return if it is not useNotify |
| 289 | - if(!$this->useNotify()) return; |
|
| 318 | + if(!$this->useNotify()) { |
|
| 319 | + return; |
|
| 320 | + } |
|
| 290 | 321 | // Pass if an author is not a logged-in user |
| 291 | - if(!$this->get('member_srl')) return; |
|
| 322 | + if(!$this->get('member_srl')) { |
|
| 323 | + return; |
|
| 324 | + } |
|
| 292 | 325 | // Return if the currently logged-in user is an author |
| 293 | 326 | $logged_info = Context::get('logged_info'); |
| 294 | - if($logged_info->member_srl == $this->get('member_srl')) return; |
|
| 327 | + if($logged_info->member_srl == $this->get('member_srl')) { |
|
| 328 | + return; |
|
| 329 | + } |
|
| 295 | 330 | // List variables |
| 296 | - if($type) $title = "[".$type."] "; |
|
| 331 | + if($type) { |
|
| 332 | + $title = "[".$type."] "; |
|
| 333 | + } |
|
| 297 | 334 | $title .= cut_str(strip_tags($content), 10, '...'); |
| 298 | 335 | $content = sprintf('%s<br /><br />from : <a href="%s" target="_blank">%s</a>',$content, getFullUrl('','document_srl',$this->document_srl), getFullUrl('','document_srl',$this->document_srl)); |
| 299 | 336 | $receiver_srl = $this->get('member_srl'); |
@@ -320,16 +357,22 @@ discard block |
||
| 320 | 357 | |
| 321 | 358 | function isExistsHomepage() |
| 322 | 359 | { |
| 323 | - if(trim($this->get('homepage'))) return true; |
|
| 360 | + if(trim($this->get('homepage'))) { |
|
| 361 | + return true; |
|
| 362 | + } |
|
| 324 | 363 | return false; |
| 325 | 364 | } |
| 326 | 365 | |
| 327 | 366 | function getHomepageUrl() |
| 328 | 367 | { |
| 329 | 368 | $url = trim($this->get('homepage')); |
| 330 | - if(!$url) return; |
|
| 369 | + if(!$url) { |
|
| 370 | + return; |
|
| 371 | + } |
|
| 331 | 372 | |
| 332 | - if(strncasecmp('http://', $url, 7) !== 0 && strncasecmp('https://', $url, 8) !== 0) $url = 'http://' . $url; |
|
| 373 | + if(strncasecmp('http://', $url, 7) !== 0 && strncasecmp('https://', $url, 8) !== 0) { |
|
| 374 | + $url = 'http://' . $url; |
|
| 375 | + } |
|
| 333 | 376 | |
| 334 | 377 | return $url; |
| 335 | 378 | } |
@@ -361,43 +404,65 @@ discard block |
||
| 361 | 404 | |
| 362 | 405 | function getTitleText($cut_size = 0, $tail='...') |
| 363 | 406 | { |
| 364 | - if(!$this->document_srl) return; |
|
| 407 | + if(!$this->document_srl) { |
|
| 408 | + return; |
|
| 409 | + } |
|
| 365 | 410 | |
| 366 | - if($cut_size) $title = cut_str($this->get('title'), $cut_size, $tail); |
|
| 367 | - else $title = $this->get('title'); |
|
| 411 | + if($cut_size) { |
|
| 412 | + $title = cut_str($this->get('title'), $cut_size, $tail); |
|
| 413 | + } else { |
|
| 414 | + $title = $this->get('title'); |
|
| 415 | + } |
|
| 368 | 416 | |
| 369 | 417 | return $title; |
| 370 | 418 | } |
| 371 | 419 | |
| 372 | 420 | function getTitle($cut_size = 0, $tail='...') |
| 373 | 421 | { |
| 374 | - if(!$this->document_srl) return; |
|
| 422 | + if(!$this->document_srl) { |
|
| 423 | + return; |
|
| 424 | + } |
|
| 375 | 425 | |
| 376 | 426 | $title = $this->getTitleText($cut_size, $tail); |
| 377 | 427 | |
| 378 | 428 | $attrs = array(); |
| 379 | 429 | $this->add('title_color', trim($this->get('title_color'))); |
| 380 | - if($this->get('title_bold')=='Y') $attrs[] = "font-weight:bold;"; |
|
| 381 | - if($this->get('title_color') && $this->get('title_color') != 'N') $attrs[] = "color:#".$this->get('title_color'); |
|
| 430 | + if($this->get('title_bold')=='Y') { |
|
| 431 | + $attrs[] = "font-weight:bold;"; |
|
| 432 | + } |
|
| 433 | + if($this->get('title_color') && $this->get('title_color') != 'N') { |
|
| 434 | + $attrs[] = "color:#".$this->get('title_color'); |
|
| 435 | + } |
|
| 382 | 436 | |
| 383 | - if(count($attrs)) return sprintf("<span style=\"%s\">%s</span>", implode(';',$attrs), htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
|
| 384 | - else return htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
|
| 437 | + if(count($attrs)) { |
|
| 438 | + return sprintf("<span style=\"%s\">%s</span>", implode(';',$attrs), htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
|
| 439 | + } else { |
|
| 440 | + return htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
|
| 441 | + } |
|
| 385 | 442 | } |
| 386 | 443 | |
| 387 | 444 | function getContentText($strlen = 0) |
| 388 | 445 | { |
| 389 | - if(!$this->document_srl) return; |
|
| 446 | + if(!$this->document_srl) { |
|
| 447 | + return; |
|
| 448 | + } |
|
| 390 | 449 | |
| 391 | - if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret'); |
|
| 450 | + if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) { |
|
| 451 | + return Context::getLang('msg_is_secret'); |
|
| 452 | + } |
|
| 392 | 453 | |
| 393 | 454 | $result = $this->_checkAccessibleFromStatus(); |
| 394 | - if($result) $_SESSION['accessible'][$this->document_srl] = true; |
|
| 455 | + if($result) { |
|
| 456 | + $_SESSION['accessible'][$this->document_srl] = true; |
|
| 457 | + } |
|
| 395 | 458 | |
| 396 | 459 | $content = $this->get('content'); |
| 397 | 460 | $content = preg_replace_callback('/<(object|param|embed)[^>]*/is', array($this, '_checkAllowScriptAccess'), $content); |
| 398 | 461 | $content = preg_replace_callback('/<object[^>]*>/is', array($this, '_addAllowScriptAccess'), $content); |
| 399 | 462 | |
| 400 | - if($strlen) return cut_str(strip_tags($content),$strlen,'...'); |
|
| 463 | + if($strlen) { |
|
| 464 | + return cut_str(strip_tags($content),$strlen,'...'); |
|
| 465 | + } |
|
| 401 | 466 | |
| 402 | 467 | return htmlspecialchars($content); |
| 403 | 468 | } |
@@ -430,14 +495,12 @@ discard block |
||
| 430 | 495 | } |
| 431 | 496 | $this->allowscriptaccessList[count($this->allowscriptaccessList)-1]--; |
| 432 | 497 | } |
| 433 | - } |
|
| 434 | - else if($m[1] == 'embed') |
|
| 498 | + } else if($m[1] == 'embed') |
|
| 435 | 499 | { |
| 436 | 500 | if(stripos($m[0], 'allowscriptaccess')) |
| 437 | 501 | { |
| 438 | 502 | $m[0] = preg_replace('/always|samedomain/i', 'never', $m[0]); |
| 439 | - } |
|
| 440 | - else |
|
| 503 | + } else |
|
| 441 | 504 | { |
| 442 | 505 | $m[0] = preg_replace('/\<embed/i', '<embed allowscriptaccess="never"', $m[0]); |
| 443 | 506 | } |
@@ -447,15 +510,23 @@ discard block |
||
| 447 | 510 | |
| 448 | 511 | function getContent($add_popup_menu = true, $add_content_info = true, $resource_realpath = false, $add_xe_content_class = true, $stripEmbedTagException = false) |
| 449 | 512 | { |
| 450 | - if(!$this->document_srl) return; |
|
| 513 | + if(!$this->document_srl) { |
|
| 514 | + return; |
|
| 515 | + } |
|
| 451 | 516 | |
| 452 | - if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret'); |
|
| 517 | + if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) { |
|
| 518 | + return Context::getLang('msg_is_secret'); |
|
| 519 | + } |
|
| 453 | 520 | |
| 454 | 521 | $result = $this->_checkAccessibleFromStatus(); |
| 455 | - if($result) $_SESSION['accessible'][$this->document_srl] = true; |
|
| 522 | + if($result) { |
|
| 523 | + $_SESSION['accessible'][$this->document_srl] = true; |
|
| 524 | + } |
|
| 456 | 525 | |
| 457 | 526 | $content = $this->get('content'); |
| 458 | - if(!$stripEmbedTagException) stripEmbedTagForAdmin($content, $this->get('member_srl')); |
|
| 527 | + if(!$stripEmbedTagException) { |
|
| 528 | + stripEmbedTagForAdmin($content, $this->get('member_srl')); |
|
| 529 | + } |
|
| 459 | 530 | |
| 460 | 531 | // Define a link if using a rewrite module |
| 461 | 532 | $oContext = &Context::getInstance(); |
@@ -489,10 +560,11 @@ discard block |
||
| 489 | 560 | $this->document_srl, $memberSrl |
| 490 | 561 | ); |
| 491 | 562 | // Add xe_content class although accessing content is not required |
| 492 | - } |
|
| 493 | - else |
|
| 563 | + } else |
|
| 494 | 564 | { |
| 495 | - if($add_xe_content_class) $content = sprintf('<div class="xe_content">%s</div>', $content); |
|
| 565 | + if($add_xe_content_class) { |
|
| 566 | + $content = sprintf('<div class="xe_content">%s</div>', $content); |
|
| 567 | + } |
|
| 496 | 568 | } |
| 497 | 569 | // Change the image path to a valid absolute path if resource_realpath is true |
| 498 | 570 | if($resource_realpath) |
@@ -611,11 +683,15 @@ discard block |
||
| 611 | 683 | |
| 612 | 684 | function getTrackbackUrl() |
| 613 | 685 | { |
| 614 | - if(!$this->document_srl) return; |
|
| 686 | + if(!$this->document_srl) { |
|
| 687 | + return; |
|
| 688 | + } |
|
| 615 | 689 | |
| 616 | 690 | // Generate a key to prevent spams |
| 617 | 691 | $oTrackbackModel = getModel('trackback'); |
| 618 | - if($oTrackbackModel) return $oTrackbackModel->getTrackbackUrl($this->document_srl, $this->getDocumentMid()); |
|
| 692 | + if($oTrackbackModel) { |
|
| 693 | + return $oTrackbackModel->getTrackbackUrl($this->document_srl, $this->getDocumentMid()); |
|
| 694 | + } |
|
| 619 | 695 | } |
| 620 | 696 | |
| 621 | 697 | /** |
@@ -634,7 +710,9 @@ discard block |
||
| 634 | 710 | |
| 635 | 711 | function isExtraVarsExists() |
| 636 | 712 | { |
| 637 | - if(!$this->get('module_srl')) return false; |
|
| 713 | + if(!$this->get('module_srl')) { |
|
| 714 | + return false; |
|
| 715 | + } |
|
| 638 | 716 | $oDocumentModel = getModel('document'); |
| 639 | 717 | $extra_keys = $oDocumentModel->getExtraKeys($this->get('module_srl')); |
| 640 | 718 | return count($extra_keys)?true:false; |
@@ -642,7 +720,9 @@ discard block |
||
| 642 | 720 | |
| 643 | 721 | function getExtraVars() |
| 644 | 722 | { |
| 645 | - if(!$this->get('module_srl') || !$this->document_srl) return null; |
|
| 723 | + if(!$this->get('module_srl') || !$this->document_srl) { |
|
| 724 | + return null; |
|
| 725 | + } |
|
| 646 | 726 | |
| 647 | 727 | $oDocumentModel = getModel('document'); |
| 648 | 728 | return $oDocumentModel->getExtraVars($this->get('module_srl'), $this->document_srl); |
@@ -654,8 +734,7 @@ discard block |
||
| 654 | 734 | if(is_array($extra_vars) && array_key_exists($idx,$extra_vars)) |
| 655 | 735 | { |
| 656 | 736 | return $extra_vars[$idx]->getValue(); |
| 657 | - } |
|
| 658 | - else |
|
| 737 | + } else |
|
| 659 | 738 | { |
| 660 | 739 | return ''; |
| 661 | 740 | } |
@@ -667,8 +746,7 @@ discard block |
||
| 667 | 746 | if(is_array($extra_vars) && array_key_exists($idx,$extra_vars)) |
| 668 | 747 | { |
| 669 | 748 | return $extra_vars[$idx]->getValueHTML(); |
| 670 | - } |
|
| 671 | - else |
|
| 749 | + } else |
|
| 672 | 750 | { |
| 673 | 751 | return ''; |
| 674 | 752 | } |
@@ -690,8 +768,7 @@ discard block |
||
| 690 | 768 | if(is_array($extra_eid) && array_key_exists($eid,$extra_eid)) |
| 691 | 769 | { |
| 692 | 770 | return $extra_eid[$eid]->getValue(); |
| 693 | - } |
|
| 694 | - else |
|
| 771 | + } else |
|
| 695 | 772 | { |
| 696 | 773 | return ''; |
| 697 | 774 | } |
@@ -709,8 +786,7 @@ discard block |
||
| 709 | 786 | if(is_array($extra_eid) && array_key_exists($eid,$extra_eid)) |
| 710 | 787 | { |
| 711 | 788 | return $extra_eid[$eid]->getValueHTML(); |
| 712 | - } |
|
| 713 | - else |
|
| 789 | + } else |
|
| 714 | 790 | { |
| 715 | 791 | return ''; |
| 716 | 792 | } |
@@ -730,8 +806,12 @@ discard block |
||
| 730 | 806 | |
| 731 | 807 | function getComments() |
| 732 | 808 | { |
| 733 | - if(!$this->getCommentCount()) return; |
|
| 734 | - if(!$this->isGranted() && $this->isSecret()) return; |
|
| 809 | + if(!$this->getCommentCount()) { |
|
| 810 | + return; |
|
| 811 | + } |
|
| 812 | + if(!$this->isGranted() && $this->isSecret()) { |
|
| 813 | + return; |
|
| 814 | + } |
|
| 735 | 815 | // cpage is a number of comment pages |
| 736 | 816 | $cpageStr = sprintf('%d_cpage', $this->document_srl); |
| 737 | 817 | $cpage = Context::get($cpageStr); |
@@ -744,7 +824,9 @@ discard block |
||
| 744 | 824 | // Get a list of comments |
| 745 | 825 | $oCommentModel = getModel('comment'); |
| 746 | 826 | $output = $oCommentModel->getCommentList($this->document_srl, $cpage, $is_admin); |
| 747 | - if(!$output->toBool() || !count($output->data)) return; |
|
| 827 | + if(!$output->toBool() || !count($output->data)) { |
|
| 828 | + return; |
|
| 829 | + } |
|
| 748 | 830 | // Create commentItem object from a comment list |
| 749 | 831 | // If admin priviledge is granted on parent posts, you can read its child posts. |
| 750 | 832 | $accessible = array(); |
@@ -754,7 +836,9 @@ discard block |
||
| 754 | 836 | $oCommentItem = new commentItem(); |
| 755 | 837 | $oCommentItem->setAttribute($val); |
| 756 | 838 | // If permission is granted to the post, you can access it temporarily |
| 757 | - if($oCommentItem->isGranted()) $accessible[$val->comment_srl] = true; |
|
| 839 | + if($oCommentItem->isGranted()) { |
|
| 840 | + $accessible[$val->comment_srl] = true; |
|
| 841 | + } |
|
| 758 | 842 | // If the comment is set to private and it belongs child post, it is allowable to read the comment for who has a admin privilege on its parent post |
| 759 | 843 | if($val->parent_srl>0 && $val->is_secret == 'Y' && !$oCommentItem->isAccessible() && $accessible[$val->parent_srl]===true) |
| 760 | 844 | { |
@@ -765,7 +849,9 @@ discard block |
||
| 765 | 849 | // Variable setting to be displayed on the skin |
| 766 | 850 | Context::set($cpageStr, $output->page_navigation->cur_page); |
| 767 | 851 | Context::set('cpage', $output->page_navigation->cur_page); |
| 768 | - if($output->total_page>1) $this->comment_page_navigation = $output->page_navigation; |
|
| 852 | + if($output->total_page>1) { |
|
| 853 | + $this->comment_page_navigation = $output->page_navigation; |
|
| 854 | + } |
|
| 769 | 855 | |
| 770 | 856 | return $comment_list; |
| 771 | 857 | } |
@@ -777,9 +863,13 @@ discard block |
||
| 777 | 863 | |
| 778 | 864 | function getTrackbacks() |
| 779 | 865 | { |
| 780 | - if(!$this->document_srl) return; |
|
| 866 | + if(!$this->document_srl) { |
|
| 867 | + return; |
|
| 868 | + } |
|
| 781 | 869 | |
| 782 | - if(!$this->allowTrackback() || !$this->get('trackback_count')) return; |
|
| 870 | + if(!$this->allowTrackback() || !$this->get('trackback_count')) { |
|
| 871 | + return; |
|
| 872 | + } |
|
| 783 | 873 | |
| 784 | 874 | $oTrackbackModel = getModel('trackback'); |
| 785 | 875 | return $oTrackbackModel->getTrackbackList($this->document_srl, $is_admin); |
@@ -787,15 +877,21 @@ discard block |
||
| 787 | 877 | |
| 788 | 878 | function thumbnailExists($width = 80, $height = 0, $type = '') |
| 789 | 879 | { |
| 790 | - if(!$this->document_srl) return false; |
|
| 791 | - if(!$this->getThumbnail($width, $height, $type)) return false; |
|
| 880 | + if(!$this->document_srl) { |
|
| 881 | + return false; |
|
| 882 | + } |
|
| 883 | + if(!$this->getThumbnail($width, $height, $type)) { |
|
| 884 | + return false; |
|
| 885 | + } |
|
| 792 | 886 | return true; |
| 793 | 887 | } |
| 794 | 888 | |
| 795 | 889 | function getThumbnail($width = 80, $height = 0, $thumbnail_type = '') |
| 796 | 890 | { |
| 797 | 891 | // Return false if the document doesn't exist |
| 798 | - if(!$this->document_srl) return; |
|
| 892 | + if(!$this->document_srl) { |
|
| 893 | + return; |
|
| 894 | + } |
|
| 799 | 895 | |
| 800 | 896 | if($this->isSecret() && !$this->isGranted()) |
| 801 | 897 | { |
@@ -803,7 +899,9 @@ discard block |
||
| 803 | 899 | } |
| 804 | 900 | |
| 805 | 901 | // If not specify its height, create a square |
| 806 | - if(!$height) $height = $width; |
|
| 902 | + if(!$height) { |
|
| 903 | + $height = $width; |
|
| 904 | + } |
|
| 807 | 905 | |
| 808 | 906 | // Return false if neither attachement nor image files in the document |
| 809 | 907 | $content = $this->get('content'); |
@@ -821,7 +919,9 @@ discard block |
||
| 821 | 919 | } |
| 822 | 920 | } |
| 823 | 921 | |
| 824 | - if(!preg_match("!<img!is", $content)) return; |
|
| 922 | + if(!preg_match("!<img!is", $content)) { |
|
| 923 | + return; |
|
| 924 | + } |
|
| 825 | 925 | } |
| 826 | 926 | // Get thumbnai_type information from document module's configuration |
| 827 | 927 | if(!in_array($thumbnail_type, array('crop','ratio'))) |
@@ -848,8 +948,7 @@ discard block |
||
| 848 | 948 | if(filesize($thumbnail_file) < 1) |
| 849 | 949 | { |
| 850 | 950 | return FALSE; |
| 851 | - } |
|
| 852 | - else |
|
| 951 | + } else |
|
| 853 | 952 | { |
| 854 | 953 | return $thumbnail_url; |
| 855 | 954 | } |
@@ -870,7 +969,9 @@ discard block |
||
| 870 | 969 | $first_image = null; |
| 871 | 970 | foreach($file_list as $file) |
| 872 | 971 | { |
| 873 | - if($file->direct_download !== 'Y') continue; |
|
| 972 | + if($file->direct_download !== 'Y') { |
|
| 973 | + continue; |
|
| 974 | + } |
|
| 874 | 975 | |
| 875 | 976 | if($file->cover_image === 'Y' && file_exists($file->uploaded_filename)) |
| 876 | 977 | { |
@@ -878,7 +979,9 @@ discard block |
||
| 878 | 979 | break; |
| 879 | 980 | } |
| 880 | 981 | |
| 881 | - if($first_image) continue; |
|
| 982 | + if($first_image) { |
|
| 983 | + continue; |
|
| 984 | + } |
|
| 882 | 985 | |
| 883 | 986 | if(preg_match("/\.(jpe?g|png|gif|bmp)$/i", $file->source_filename)) |
| 884 | 987 | { |
@@ -905,7 +1008,9 @@ discard block |
||
| 905 | 1008 | foreach($matches as $target_image) |
| 906 | 1009 | { |
| 907 | 1010 | $target_src = trim($target_image[1]); |
| 908 | - if(preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) continue; |
|
| 1011 | + if(preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) { |
|
| 1012 | + continue; |
|
| 1013 | + } |
|
| 909 | 1014 | |
| 910 | 1015 | if(!preg_match('/^(http|https):\/\//i',$target_src)) |
| 911 | 1016 | { |
@@ -916,7 +1021,9 @@ discard block |
||
| 916 | 1021 | |
| 917 | 1022 | $tmp_file = _XE_PATH_ . 'files/cache/tmp/' . $random->createSecureSalt(32, 'hex'); |
| 918 | 1023 | FileHandler::getRemoteFile($target_src, $tmp_file); |
| 919 | - if(!file_exists($tmp_file)) continue; |
|
| 1024 | + if(!file_exists($tmp_file)) { |
|
| 1025 | + continue; |
|
| 1026 | + } |
|
| 920 | 1027 | |
| 921 | 1028 | $imageinfo = getimagesize($tmp_file); |
| 922 | 1029 | list($_w, $_h) = $imageinfo; |
@@ -967,21 +1074,28 @@ discard block |
||
| 967 | 1074 | */ |
| 968 | 1075 | function getExtraImages($time_interval = 43200) |
| 969 | 1076 | { |
| 970 | - if(!$this->document_srl) return; |
|
| 1077 | + if(!$this->document_srl) { |
|
| 1078 | + return; |
|
| 1079 | + } |
|
| 971 | 1080 | // variables for icon list |
| 972 | 1081 | $buffs = array(); |
| 973 | 1082 | |
| 974 | 1083 | $check_files = false; |
| 975 | 1084 | |
| 976 | 1085 | // Check if secret post is |
| 977 | - if($this->isSecret()) $buffs[] = "secret"; |
|
| 1086 | + if($this->isSecret()) { |
|
| 1087 | + $buffs[] = "secret"; |
|
| 1088 | + } |
|
| 978 | 1089 | |
| 979 | 1090 | // Set the latest time |
| 980 | 1091 | $time_check = date("YmdHis", $_SERVER['REQUEST_TIME']-$time_interval); |
| 981 | 1092 | |
| 982 | 1093 | // Check new post |
| 983 | - if($this->get('regdate')>$time_check) $buffs[] = "new"; |
|
| 984 | - else if($this->get('last_update')>$time_check) $buffs[] = "update"; |
|
| 1094 | + if($this->get('regdate')>$time_check) { |
|
| 1095 | + $buffs[] = "new"; |
|
| 1096 | + } else if($this->get('last_update')>$time_check) { |
|
| 1097 | + $buffs[] = "update"; |
|
| 1098 | + } |
|
| 985 | 1099 | |
| 986 | 1100 | /* |
| 987 | 1101 | $content = $this->get('content'); |
@@ -1004,14 +1118,18 @@ discard block |
||
| 1004 | 1118 | */ |
| 1005 | 1119 | |
| 1006 | 1120 | // Check the attachment |
| 1007 | - if($this->hasUploadedFiles()) $buffs[] = "file"; |
|
| 1121 | + if($this->hasUploadedFiles()) { |
|
| 1122 | + $buffs[] = "file"; |
|
| 1123 | + } |
|
| 1008 | 1124 | |
| 1009 | 1125 | return $buffs; |
| 1010 | 1126 | } |
| 1011 | 1127 | |
| 1012 | 1128 | function getStatus() |
| 1013 | 1129 | { |
| 1014 | - if(!$this->get('status')) return $this->getDefaultStatus(); |
|
| 1130 | + if(!$this->get('status')) { |
|
| 1131 | + return $this->getDefaultStatus(); |
|
| 1132 | + } |
|
| 1015 | 1133 | return $this->get('status'); |
| 1016 | 1134 | } |
| 1017 | 1135 | |
@@ -1022,12 +1140,16 @@ discard block |
||
| 1022 | 1140 | */ |
| 1023 | 1141 | function printExtraImages($time_check = 43200) |
| 1024 | 1142 | { |
| 1025 | - if(!$this->document_srl) return; |
|
| 1143 | + if(!$this->document_srl) { |
|
| 1144 | + return; |
|
| 1145 | + } |
|
| 1026 | 1146 | // Get the icon directory |
| 1027 | 1147 | $path = sprintf('%s%s',getUrl(), 'modules/document/tpl/icons/'); |
| 1028 | 1148 | |
| 1029 | 1149 | $buffs = $this->getExtraImages($time_check); |
| 1030 | - if(!count($buffs)) return; |
|
| 1150 | + if(!count($buffs)) { |
|
| 1151 | + return; |
|
| 1152 | + } |
|
| 1031 | 1153 | |
| 1032 | 1154 | $buff = array(); |
| 1033 | 1155 | foreach($buffs as $key => $val) |
@@ -1039,18 +1161,28 @@ discard block |
||
| 1039 | 1161 | |
| 1040 | 1162 | function hasUploadedFiles() |
| 1041 | 1163 | { |
| 1042 | - if(!$this->document_srl) return; |
|
| 1164 | + if(!$this->document_srl) { |
|
| 1165 | + return; |
|
| 1166 | + } |
|
| 1043 | 1167 | |
| 1044 | - if($this->isSecret() && !$this->isGranted()) return false; |
|
| 1168 | + if($this->isSecret() && !$this->isGranted()) { |
|
| 1169 | + return false; |
|
| 1170 | + } |
|
| 1045 | 1171 | return $this->get('uploaded_count')? true : false; |
| 1046 | 1172 | } |
| 1047 | 1173 | |
| 1048 | 1174 | function getUploadedFiles($sortIndex = 'file_srl') |
| 1049 | 1175 | { |
| 1050 | - if(!$this->document_srl) return; |
|
| 1176 | + if(!$this->document_srl) { |
|
| 1177 | + return; |
|
| 1178 | + } |
|
| 1051 | 1179 | |
| 1052 | - if($this->isSecret() && !$this->isGranted()) return; |
|
| 1053 | - if(!$this->get('uploaded_count')) return; |
|
| 1180 | + if($this->isSecret() && !$this->isGranted()) { |
|
| 1181 | + return; |
|
| 1182 | + } |
|
| 1183 | + if(!$this->get('uploaded_count')) { |
|
| 1184 | + return; |
|
| 1185 | + } |
|
| 1054 | 1186 | |
| 1055 | 1187 | if(!$this->uploadedFiles[$sortIndex]) |
| 1056 | 1188 | { |
@@ -1068,7 +1200,9 @@ discard block |
||
| 1068 | 1200 | function getEditor() |
| 1069 | 1201 | { |
| 1070 | 1202 | $module_srl = $this->get('module_srl'); |
| 1071 | - if(!$module_srl) $module_srl = Context::get('module_srl'); |
|
| 1203 | + if(!$module_srl) { |
|
| 1204 | + $module_srl = Context::get('module_srl'); |
|
| 1205 | + } |
|
| 1072 | 1206 | |
| 1073 | 1207 | $oEditorModel = getModel('editor'); |
| 1074 | 1208 | return $oEditorModel->getModuleEditor('document', $module_srl, $this->document_srl, 'document_srl', 'content'); |
@@ -1082,8 +1216,12 @@ discard block |
||
| 1082 | 1216 | function isEnableComment() |
| 1083 | 1217 | { |
| 1084 | 1218 | // Return false if not authorized, if a secret document, if the document is set not to allow any comment |
| 1085 | - if (!$this->allowComment()) return false; |
|
| 1086 | - if(!$this->isGranted() && $this->isSecret()) return false; |
|
| 1219 | + if (!$this->allowComment()) { |
|
| 1220 | + return false; |
|
| 1221 | + } |
|
| 1222 | + if(!$this->isGranted() && $this->isSecret()) { |
|
| 1223 | + return false; |
|
| 1224 | + } |
|
| 1087 | 1225 | |
| 1088 | 1226 | return true; |
| 1089 | 1227 | } |
@@ -1094,7 +1232,9 @@ discard block |
||
| 1094 | 1232 | */ |
| 1095 | 1233 | function getCommentEditor() |
| 1096 | 1234 | { |
| 1097 | - if(!$this->isEnableComment()) return; |
|
| 1235 | + if(!$this->isEnableComment()) { |
|
| 1236 | + return; |
|
| 1237 | + } |
|
| 1098 | 1238 | |
| 1099 | 1239 | $oEditorModel = getModel('editor'); |
| 1100 | 1240 | return $oEditorModel->getModuleEditor('comment', $this->get('module_srl'), $comment_srl, 'comment_srl', 'content'); |
@@ -1106,10 +1246,14 @@ discard block |
||
| 1106 | 1246 | */ |
| 1107 | 1247 | function getProfileImage() |
| 1108 | 1248 | { |
| 1109 | - if(!$this->isExists() || !$this->get('member_srl')) return; |
|
| 1249 | + if(!$this->isExists() || !$this->get('member_srl')) { |
|
| 1250 | + return; |
|
| 1251 | + } |
|
| 1110 | 1252 | $oMemberModel = getModel('member'); |
| 1111 | 1253 | $profile_info = $oMemberModel->getProfileImage($this->get('member_srl')); |
| 1112 | - if(!$profile_info) return; |
|
| 1254 | + if(!$profile_info) { |
|
| 1255 | + return; |
|
| 1256 | + } |
|
| 1113 | 1257 | |
| 1114 | 1258 | return $profile_info->src; |
| 1115 | 1259 | } |
@@ -1121,7 +1265,9 @@ discard block |
||
| 1121 | 1265 | function getSignature() |
| 1122 | 1266 | { |
| 1123 | 1267 | // Pass if a document doesn't exist |
| 1124 | - if(!$this->isExists() || !$this->get('member_srl')) return; |
|
| 1268 | + if(!$this->isExists() || !$this->get('member_srl')) { |
|
| 1269 | + return; |
|
| 1270 | + } |
|
| 1125 | 1271 | // Get signature information |
| 1126 | 1272 | $oMemberModel = getModel('member'); |
| 1127 | 1273 | $signature = $oMemberModel->getSignature($this->get('member_srl')); |
@@ -1135,7 +1281,9 @@ discard block |
||
| 1135 | 1281 | if($signature) |
| 1136 | 1282 | { |
| 1137 | 1283 | $max_signature_height = $GLOBALS['__member_signature_max_height']; |
| 1138 | - if($max_signature_height) $signature = sprintf('<div style="max-height:%dpx;overflow:auto;overflow-x:hidden;height:expression(this.scrollHeight > %d ? \'%dpx\': \'auto\')">%s</div>', $max_signature_height, $max_signature_height, $max_signature_height, $signature); |
|
| 1284 | + if($max_signature_height) { |
|
| 1285 | + $signature = sprintf('<div style="max-height:%dpx;overflow:auto;overflow-x:hidden;height:expression(this.scrollHeight > %d ? \'%dpx\': \'auto\')">%s</div>', $max_signature_height, $max_signature_height, $max_signature_height, $signature); |
|
| 1286 | + } |
|
| 1139 | 1287 | } |
| 1140 | 1288 | |
| 1141 | 1289 | return $signature; |
@@ -1159,20 +1307,25 @@ discard block |
||
| 1159 | 1307 | function _checkAccessibleFromStatus() |
| 1160 | 1308 | { |
| 1161 | 1309 | $logged_info = Context::get('logged_info'); |
| 1162 | - if($logged_info->is_admin == 'Y') return true; |
|
| 1310 | + if($logged_info->is_admin == 'Y') { |
|
| 1311 | + return true; |
|
| 1312 | + } |
|
| 1163 | 1313 | |
| 1164 | 1314 | $status = $this->get('status'); |
| 1165 | - if(empty($status)) return false; |
|
| 1315 | + if(empty($status)) { |
|
| 1316 | + return false; |
|
| 1317 | + } |
|
| 1166 | 1318 | |
| 1167 | 1319 | $oDocumentModel = getModel('document'); |
| 1168 | 1320 | $configStatusList = $oDocumentModel->getStatusList(); |
| 1169 | 1321 | |
| 1170 | - if($status == $configStatusList['public'] || $status == $configStatusList['publish']) |
|
| 1171 | - return true; |
|
| 1172 | - else if($status == $configStatusList['private'] || $status == $configStatusList['secret']) |
|
| 1322 | + if($status == $configStatusList['public'] || $status == $configStatusList['publish']) { |
|
| 1323 | + return true; |
|
| 1324 | + } else if($status == $configStatusList['private'] || $status == $configStatusList['secret']) |
|
| 1173 | 1325 | { |
| 1174 | - if($this->get('member_srl') == $logged_info->member_srl) |
|
| 1175 | - return true; |
|
| 1326 | + if($this->get('member_srl') == $logged_info->member_srl) { |
|
| 1327 | + return true; |
|
| 1328 | + } |
|
| 1176 | 1329 | } |
| 1177 | 1330 | return false; |
| 1178 | 1331 | } |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | function _loadFromDB() |
| 51 | 51 | { |
| 52 | - if(!$this->comment_srl) |
|
| 52 | + if (!$this->comment_srl) |
|
| 53 | 53 | { |
| 54 | 54 | return; |
| 55 | 55 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | function setAttribute($attribute) |
| 69 | 69 | { |
| 70 | - if(!$attribute->comment_srl) |
|
| 70 | + if (!$attribute->comment_srl) |
|
| 71 | 71 | { |
| 72 | 72 | $this->comment_srl = NULL; |
| 73 | 73 | return; |
@@ -77,9 +77,9 @@ discard block |
||
| 77 | 77 | $this->adds($attribute); |
| 78 | 78 | |
| 79 | 79 | // define vars on the object for backward compatibility of skins |
| 80 | - if(count($attribute)) |
|
| 80 | + if (count($attribute)) |
|
| 81 | 81 | { |
| 82 | - foreach($attribute as $key => $val) |
|
| 82 | + foreach ($attribute as $key => $val) |
|
| 83 | 83 | { |
| 84 | 84 | $this->{$key} = $val; |
| 85 | 85 | } |
@@ -93,29 +93,29 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | function isGranted() |
| 95 | 95 | { |
| 96 | - if($_SESSION['own_comment'][$this->comment_srl]) |
|
| 96 | + if ($_SESSION['own_comment'][$this->comment_srl]) |
|
| 97 | 97 | { |
| 98 | 98 | return TRUE; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - if(!Context::get('is_logged')) |
|
| 101 | + if (!Context::get('is_logged')) |
|
| 102 | 102 | { |
| 103 | 103 | return FALSE; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | $logged_info = Context::get('logged_info'); |
| 107 | - if($logged_info->is_admin == 'Y') |
|
| 107 | + if ($logged_info->is_admin == 'Y') |
|
| 108 | 108 | { |
| 109 | 109 | return TRUE; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | $grant = Context::get('grant'); |
| 113 | - if($grant->manager) |
|
| 113 | + if ($grant->manager) |
|
| 114 | 114 | { |
| 115 | 115 | return TRUE; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - if($this->get('member_srl') && ($this->get('member_srl') == $logged_info->member_srl || $this->get('member_srl') * -1 == $logged_info->member_srl)) |
|
| 118 | + if ($this->get('member_srl') && ($this->get('member_srl') == $logged_info->member_srl || $this->get('member_srl') * -1 == $logged_info->member_srl)) |
|
| 119 | 119 | { |
| 120 | 120 | return TRUE; |
| 121 | 121 | } |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | |
| 137 | 137 | function isEditable() |
| 138 | 138 | { |
| 139 | - if($this->isGranted() || !$this->get('member_srl')) |
|
| 139 | + if ($this->isGranted() || !$this->get('member_srl')) |
|
| 140 | 140 | { |
| 141 | 141 | return TRUE; |
| 142 | 142 | } |
@@ -150,12 +150,12 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | function isAccessible() |
| 152 | 152 | { |
| 153 | - if($_SESSION['accessibled_comment'][$this->comment_srl]) |
|
| 153 | + if ($_SESSION['accessibled_comment'][$this->comment_srl]) |
|
| 154 | 154 | { |
| 155 | 155 | return TRUE; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - if($this->isGranted() || !$this->isSecret()) |
|
| 158 | + if ($this->isGranted() || !$this->isSecret()) |
|
| 159 | 159 | { |
| 160 | 160 | $this->setAccessible(); |
| 161 | 161 | return TRUE; |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | |
| 164 | 164 | $oDocumentModel = getModel('document'); |
| 165 | 165 | $oDocument = $oDocumentModel->getDocument($this->get('document_srl')); |
| 166 | - if($oDocument->isGranted()) |
|
| 166 | + if ($oDocument->isGranted()) |
|
| 167 | 167 | { |
| 168 | 168 | $this->setAccessible(); |
| 169 | 169 | return TRUE; |
@@ -184,20 +184,20 @@ discard block |
||
| 184 | 184 | function notify($type, $content) |
| 185 | 185 | { |
| 186 | 186 | // return if not useNotify |
| 187 | - if(!$this->useNotify()) |
|
| 187 | + if (!$this->useNotify()) |
|
| 188 | 188 | { |
| 189 | 189 | return; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | // pass if the author is not logged-in user |
| 193 | - if(!$this->get('member_srl')) |
|
| 193 | + if (!$this->get('member_srl')) |
|
| 194 | 194 | { |
| 195 | 195 | return; |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | // return if the currently logged-in user is an author of the comment. |
| 199 | 199 | $logged_info = Context::get('logged_info'); |
| 200 | - if($logged_info->member_srl == $this->get('member_srl')) |
|
| 200 | + if ($logged_info->member_srl == $this->get('member_srl')) |
|
| 201 | 201 | { |
| 202 | 202 | return; |
| 203 | 203 | } |
@@ -207,9 +207,9 @@ discard block |
||
| 207 | 207 | $oDocument = $oDocumentModel->getDocument($this->get('document_srl')); |
| 208 | 208 | |
| 209 | 209 | // Variables |
| 210 | - if($type) |
|
| 210 | + if ($type) |
|
| 211 | 211 | { |
| 212 | - $title = "[" . $type . "] "; |
|
| 212 | + $title = "[".$type."] "; |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | $title .= cut_str(strip_tags($content), 30, '...'); |
@@ -224,17 +224,17 @@ discard block |
||
| 224 | 224 | |
| 225 | 225 | function getIpAddress() |
| 226 | 226 | { |
| 227 | - if($this->isGranted()) |
|
| 227 | + if ($this->isGranted()) |
|
| 228 | 228 | { |
| 229 | 229 | return $this->get('ipaddress'); |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | - return '*' . strstr($this->get('ipaddress'), '.'); |
|
| 232 | + return '*'.strstr($this->get('ipaddress'), '.'); |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | function isExistsHomepage() |
| 236 | 236 | { |
| 237 | - if(trim($this->get('homepage'))) |
|
| 237 | + if (trim($this->get('homepage'))) |
|
| 238 | 238 | { |
| 239 | 239 | return TRUE; |
| 240 | 240 | } |
@@ -245,14 +245,14 @@ discard block |
||
| 245 | 245 | function getHomepageUrl() |
| 246 | 246 | { |
| 247 | 247 | $url = trim($this->get('homepage')); |
| 248 | - if(!$url) |
|
| 248 | + if (!$url) |
|
| 249 | 249 | { |
| 250 | 250 | return; |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - if(strncasecmp('http://', $url, 7) !== 0) |
|
| 253 | + if (strncasecmp('http://', $url, 7) !== 0) |
|
| 254 | 254 | { |
| 255 | - $url = "http://" . $url; |
|
| 255 | + $url = "http://".$url; |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | return htmlspecialchars($url, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
@@ -284,14 +284,14 @@ discard block |
||
| 284 | 284 | */ |
| 285 | 285 | function getContentText($strlen = 0) |
| 286 | 286 | { |
| 287 | - if($this->isSecret() && !$this->isAccessible()) |
|
| 287 | + if ($this->isSecret() && !$this->isAccessible()) |
|
| 288 | 288 | { |
| 289 | 289 | return Context::getLang('msg_is_secret'); |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | $content = $this->get('content'); |
| 293 | 293 | |
| 294 | - if($strlen) |
|
| 294 | + if ($strlen) |
|
| 295 | 295 | { |
| 296 | 296 | return cut_str(strip_tags($content), $strlen, '...'); |
| 297 | 297 | } |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | */ |
| 306 | 306 | function getContent($add_popup_menu = TRUE, $add_content_info = TRUE, $add_xe_content_class = TRUE) |
| 307 | 307 | { |
| 308 | - if($this->isSecret() && !$this->isAccessible()) |
|
| 308 | + if ($this->isSecret() && !$this->isAccessible()) |
|
| 309 | 309 | { |
| 310 | 310 | return Context::getLang('msg_is_secret'); |
| 311 | 311 | } |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | stripEmbedTagForAdmin($content, $this->get('member_srl')); |
| 315 | 315 | |
| 316 | 316 | // when displaying the comment on the pop-up menu |
| 317 | - if($add_popup_menu && Context::get('is_logged')) |
|
| 317 | + if ($add_popup_menu && Context::get('is_logged')) |
|
| 318 | 318 | { |
| 319 | 319 | $content = sprintf( |
| 320 | 320 | '%s<div class="comment_popup_menu"><a href="#popup_menu_area" class="comment_%d" onclick="return false">%s</a></div>', $content, $this->comment_srl, Context::getLang('cmd_comment_do') |
@@ -322,10 +322,10 @@ discard block |
||
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | // if additional information which can access contents is set |
| 325 | - if($add_content_info) |
|
| 325 | + if ($add_content_info) |
|
| 326 | 326 | { |
| 327 | 327 | $memberSrl = $this->get('member_srl'); |
| 328 | - if($memberSrl < 0) |
|
| 328 | + if ($memberSrl < 0) |
|
| 329 | 329 | { |
| 330 | 330 | $memberSrl = 0; |
| 331 | 331 | } |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | } |
| 337 | 337 | else |
| 338 | 338 | { |
| 339 | - if($add_xe_content_class) |
|
| 339 | + if ($add_xe_content_class) |
|
| 340 | 340 | { |
| 341 | 341 | $content = sprintf('<div class="xe_content">%s</div>', $content); |
| 342 | 342 | } |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | |
| 397 | 397 | function getRegdateGM() |
| 398 | 398 | { |
| 399 | - return $this->getRegdate('D, d M Y H:i:s') . ' ' . $GLOBALS['_time_zone']; |
|
| 399 | + return $this->getRegdate('D, d M Y H:i:s').' '.$GLOBALS['_time_zone']; |
|
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | function getUpdate($format = 'Y.m.d H:i:s') |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | |
| 407 | 407 | function getPermanentUrl() |
| 408 | 408 | { |
| 409 | - return getFullUrl('', 'document_srl', $this->get('document_srl')) . '#comment_' . $this->get('comment_srl'); |
|
| 409 | + return getFullUrl('', 'document_srl', $this->get('document_srl')).'#comment_'.$this->get('comment_srl'); |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | function getUpdateTime() |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | |
| 428 | 428 | function hasUploadedFiles() |
| 429 | 429 | { |
| 430 | - if(($this->isSecret() && !$this->isAccessible()) && !$this->isGranted()) |
|
| 430 | + if (($this->isSecret() && !$this->isAccessible()) && !$this->isGranted()) |
|
| 431 | 431 | { |
| 432 | 432 | return FALSE; |
| 433 | 433 | } |
@@ -436,12 +436,12 @@ discard block |
||
| 436 | 436 | |
| 437 | 437 | function getUploadedFiles() |
| 438 | 438 | { |
| 439 | - if(($this->isSecret() && !$this->isAccessible()) && !$this->isGranted()) |
|
| 439 | + if (($this->isSecret() && !$this->isAccessible()) && !$this->isGranted()) |
|
| 440 | 440 | { |
| 441 | 441 | return; |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | - if(!$this->get('uploaded_count')) |
|
| 444 | + if (!$this->get('uploaded_count')) |
|
| 445 | 445 | { |
| 446 | 446 | return; |
| 447 | 447 | } |
@@ -458,7 +458,7 @@ discard block |
||
| 458 | 458 | function getEditor() |
| 459 | 459 | { |
| 460 | 460 | $module_srl = $this->get('module_srl'); |
| 461 | - if(!$module_srl) |
|
| 461 | + if (!$module_srl) |
|
| 462 | 462 | { |
| 463 | 463 | $module_srl = Context::get('module_srl'); |
| 464 | 464 | } |
@@ -472,13 +472,13 @@ discard block |
||
| 472 | 472 | */ |
| 473 | 473 | function getProfileImage() |
| 474 | 474 | { |
| 475 | - if(!$this->isExists() || !$this->get('member_srl')) |
|
| 475 | + if (!$this->isExists() || !$this->get('member_srl')) |
|
| 476 | 476 | { |
| 477 | 477 | return; |
| 478 | 478 | } |
| 479 | 479 | $oMemberModel = getModel('member'); |
| 480 | 480 | $profile_info = $oMemberModel->getProfileImage($this->get('member_srl')); |
| 481 | - if(!$profile_info) |
|
| 481 | + if (!$profile_info) |
|
| 482 | 482 | { |
| 483 | 483 | return; |
| 484 | 484 | } |
@@ -493,7 +493,7 @@ discard block |
||
| 493 | 493 | function getSignature() |
| 494 | 494 | { |
| 495 | 495 | // pass if the posting not exists. |
| 496 | - if(!$this->isExists() || !$this->get('member_srl')) |
|
| 496 | + if (!$this->isExists() || !$this->get('member_srl')) |
|
| 497 | 497 | { |
| 498 | 498 | return; |
| 499 | 499 | } |
@@ -503,7 +503,7 @@ discard block |
||
| 503 | 503 | $signature = $oMemberModel->getSignature($this->get('member_srl')); |
| 504 | 504 | |
| 505 | 505 | // check if max height of the signiture is specified on the member module |
| 506 | - if(!isset($GLOBALS['__member_signature_max_height'])) |
|
| 506 | + if (!isset($GLOBALS['__member_signature_max_height'])) |
|
| 507 | 507 | { |
| 508 | 508 | $oModuleModel = getModel('module'); |
| 509 | 509 | $member_config = $oModuleModel->getModuleConfig('member'); |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | |
| 513 | 513 | $max_signature_height = $GLOBALS['__member_signature_max_height']; |
| 514 | 514 | |
| 515 | - if($max_signature_height) |
|
| 515 | + if ($max_signature_height) |
|
| 516 | 516 | { |
| 517 | 517 | $signature = sprintf('<div style="max-height:%dpx;overflow:auto;overflow-x:hidden;height:expression(this.scrollHeight > %d ? \'%dpx\': \'auto\')">%s</div>', $max_signature_height, $max_signature_height, $max_signature_height, $signature); |
| 518 | 518 | } |
@@ -522,12 +522,12 @@ discard block |
||
| 522 | 522 | |
| 523 | 523 | function thumbnailExists($width = 80, $height = 0, $type = '') |
| 524 | 524 | { |
| 525 | - if(!$this->comment_srl) |
|
| 525 | + if (!$this->comment_srl) |
|
| 526 | 526 | { |
| 527 | 527 | return FALSE; |
| 528 | 528 | } |
| 529 | 529 | |
| 530 | - if(!$this->getThumbnail($width, $height, $type)) |
|
| 530 | + if (!$this->getThumbnail($width, $height, $type)) |
|
| 531 | 531 | { |
| 532 | 532 | return FALSE; |
| 533 | 533 | } |
@@ -538,42 +538,42 @@ discard block |
||
| 538 | 538 | function getThumbnail($width = 80, $height = 0, $thumbnail_type = '') |
| 539 | 539 | { |
| 540 | 540 | // return false if no doc exists |
| 541 | - if(!$this->comment_srl) |
|
| 541 | + if (!$this->comment_srl) |
|
| 542 | 542 | { |
| 543 | 543 | return; |
| 544 | 544 | } |
| 545 | 545 | |
| 546 | - if($this->isSecret() && !$this->isGranted()) |
|
| 546 | + if ($this->isSecret() && !$this->isGranted()) |
|
| 547 | 547 | { |
| 548 | 548 | return; |
| 549 | 549 | } |
| 550 | 550 | |
| 551 | 551 | // If signiture height setting is omitted, create a square |
| 552 | - if(!$height) |
|
| 552 | + if (!$height) |
|
| 553 | 553 | { |
| 554 | 554 | $height = $width; |
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | $content = $this->get('content'); |
| 558 | - if(!$this->hasUploadedFiles()) |
|
| 558 | + if (!$this->hasUploadedFiles()) |
|
| 559 | 559 | { |
| 560 | - if(!$content) |
|
| 560 | + if (!$content) |
|
| 561 | 561 | { |
| 562 | 562 | $args = new stdClass(); |
| 563 | 563 | $args->comment_srl = $this->comment_srl; |
| 564 | 564 | $output = executeQuery('document.getComment', $args, array('content')); |
| 565 | - if($output->toBool() && $output->data) |
|
| 565 | + if ($output->toBool() && $output->data) |
|
| 566 | 566 | { |
| 567 | 567 | $content = $output->data->content; |
| 568 | 568 | $this->add('content', $content); |
| 569 | 569 | } |
| 570 | 570 | } |
| 571 | 571 | |
| 572 | - if(!preg_match("!<img!is", $content)) return; |
|
| 572 | + if (!preg_match("!<img!is", $content)) return; |
|
| 573 | 573 | } |
| 574 | 574 | |
| 575 | 575 | // get thumbail generation info on the doc module configuration. |
| 576 | - if(!in_array($thumbnail_type, array('crop', 'ratio'))) |
|
| 576 | + if (!in_array($thumbnail_type, array('crop', 'ratio'))) |
|
| 577 | 577 | { |
| 578 | 578 | $thumbnail_type = 'crop'; |
| 579 | 579 | } |
@@ -582,12 +582,12 @@ discard block |
||
| 582 | 582 | $thumbnail_path = sprintf('files/thumbnails/%s', getNumberingPath($this->comment_srl, 3)); |
| 583 | 583 | $thumbnail_file = sprintf('%s%dx%d.%s.jpg', $thumbnail_path, $width, $height, $thumbnail_type); |
| 584 | 584 | $thumbnail_lockfile = sprintf('%s%dx%d.%s.lock', $thumbnail_path, $width, $height, $thumbnail_type); |
| 585 | - $thumbnail_url = Context::getRequestUri() . $thumbnail_file; |
|
| 585 | + $thumbnail_url = Context::getRequestUri().$thumbnail_file; |
|
| 586 | 586 | |
| 587 | 587 | // return false if a size of existing thumbnail file is 0. otherwise return the file path |
| 588 | - if(file_exists($thumbnail_file) || file_exists($thumbnail_lockfile)) |
|
| 588 | + if (file_exists($thumbnail_file) || file_exists($thumbnail_lockfile)) |
|
| 589 | 589 | { |
| 590 | - if(filesize($thumbnail_file) < 1) |
|
| 590 | + if (filesize($thumbnail_file) < 1) |
|
| 591 | 591 | { |
| 592 | 592 | return FALSE; |
| 593 | 593 | } |
@@ -605,33 +605,33 @@ discard block |
||
| 605 | 605 | $is_tmp_file = FALSE; |
| 606 | 606 | |
| 607 | 607 | // find an image file among attached files |
| 608 | - if($this->hasUploadedFiles()) |
|
| 608 | + if ($this->hasUploadedFiles()) |
|
| 609 | 609 | { |
| 610 | 610 | $file_list = $this->getUploadedFiles(); |
| 611 | 611 | |
| 612 | 612 | $first_image = null; |
| 613 | - foreach($file_list as $file) |
|
| 613 | + foreach ($file_list as $file) |
|
| 614 | 614 | { |
| 615 | - if($file->direct_download !== 'Y') continue; |
|
| 615 | + if ($file->direct_download !== 'Y') continue; |
|
| 616 | 616 | |
| 617 | - if($file->cover_image === 'Y' && file_exists($file->uploaded_filename)) |
|
| 617 | + if ($file->cover_image === 'Y' && file_exists($file->uploaded_filename)) |
|
| 618 | 618 | { |
| 619 | 619 | $source_file = $file->uploaded_filename; |
| 620 | 620 | break; |
| 621 | 621 | } |
| 622 | 622 | |
| 623 | - if($first_image) continue; |
|
| 623 | + if ($first_image) continue; |
|
| 624 | 624 | |
| 625 | - if(preg_match("/\.(jpe?g|png|gif|bmp)$/i", $file->source_filename)) |
|
| 625 | + if (preg_match("/\.(jpe?g|png|gif|bmp)$/i", $file->source_filename)) |
|
| 626 | 626 | { |
| 627 | - if(file_exists($file->uploaded_filename)) |
|
| 627 | + if (file_exists($file->uploaded_filename)) |
|
| 628 | 628 | { |
| 629 | 629 | $first_image = $file->uploaded_filename; |
| 630 | 630 | } |
| 631 | 631 | } |
| 632 | 632 | } |
| 633 | 633 | |
| 634 | - if(!$source_file && $first_image) |
|
| 634 | + if (!$source_file && $first_image) |
|
| 635 | 635 | { |
| 636 | 636 | $source_file = $first_image; |
| 637 | 637 | } |
@@ -639,31 +639,31 @@ discard block |
||
| 639 | 639 | |
| 640 | 640 | // get an image file from the doc content if no file attached. |
| 641 | 641 | $is_tmp_file = false; |
| 642 | - if(!$source_file) |
|
| 642 | + if (!$source_file) |
|
| 643 | 643 | { |
| 644 | 644 | $random = new Password(); |
| 645 | 645 | |
| 646 | 646 | preg_match_all("!<img[^>]*src=(?:\"|\')([^\"\']*?)(?:\"|\')!is", $content, $matches, PREG_SET_ORDER); |
| 647 | 647 | |
| 648 | - foreach($matches as $target_image) |
|
| 648 | + foreach ($matches as $target_image) |
|
| 649 | 649 | { |
| 650 | 650 | $target_src = trim($target_image[1]); |
| 651 | - if(preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) continue; |
|
| 651 | + if (preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) continue; |
|
| 652 | 652 | |
| 653 | - if(!preg_match('/^(http|https):\/\//i',$target_src)) |
|
| 653 | + if (!preg_match('/^(http|https):\/\//i', $target_src)) |
|
| 654 | 654 | { |
| 655 | 655 | $target_src = Context::getRequestUri().$target_src; |
| 656 | 656 | } |
| 657 | 657 | |
| 658 | 658 | $target_src = htmlspecialchars_decode($target_src); |
| 659 | 659 | |
| 660 | - $tmp_file = _XE_PATH_ . 'files/cache/tmp/' . $random->createSecureSalt(32, 'hex'); |
|
| 660 | + $tmp_file = _XE_PATH_.'files/cache/tmp/'.$random->createSecureSalt(32, 'hex'); |
|
| 661 | 661 | FileHandler::getRemoteFile($target_src, $tmp_file); |
| 662 | - if(!file_exists($tmp_file)) continue; |
|
| 662 | + if (!file_exists($tmp_file)) continue; |
|
| 663 | 663 | |
| 664 | 664 | $imageinfo = getimagesize($tmp_file); |
| 665 | 665 | list($_w, $_h) = $imageinfo; |
| 666 | - if($imageinfo === false || ($_w < ($width * 0.3) && $_h < ($height * 0.3))) { |
|
| 666 | + if ($imageinfo === false || ($_w < ($width * 0.3) && $_h < ($height * 0.3))) { |
|
| 667 | 667 | FileHandler::removeFile($tmp_file); |
| 668 | 668 | continue; |
| 669 | 669 | } |
@@ -677,7 +677,7 @@ discard block |
||
| 677 | 677 | $output = FileHandler::createImageFile($source_file, $thumbnail_file, $width, $height, 'jpg', $thumbnail_type); |
| 678 | 678 | |
| 679 | 679 | // Remove source file if it was temporary |
| 680 | - if($is_tmp_file) |
|
| 680 | + if ($is_tmp_file) |
|
| 681 | 681 | { |
| 682 | 682 | FileHandler::removeFile($source_file); |
| 683 | 683 | } |
@@ -686,14 +686,14 @@ discard block |
||
| 686 | 686 | FileHandler::removeFile($thumbnail_lockfile); |
| 687 | 687 | |
| 688 | 688 | // Return the thumbnail path if it was successfully generated |
| 689 | - if($output) |
|
| 689 | + if ($output) |
|
| 690 | 690 | { |
| 691 | 691 | return $thumbnail_url; |
| 692 | 692 | } |
| 693 | 693 | // Create an empty file if thumbnail generation failed |
| 694 | 694 | else |
| 695 | 695 | { |
| 696 | - FileHandler::writeFile($thumbnail_file, '','w'); |
|
| 696 | + FileHandler::writeFile($thumbnail_file, '', 'w'); |
|
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | return; |