document_srl = $document_srl;
$this->_loadFromDB();
}
function setDocument($document_srl) {
$this->document_srl = $document_srl;
$this->_loadFromDB();
}
function _loadFromDB() {
if(!$this->document_srl) return;
$args->document_srl = $this->document_srl;
$output = executeQuery('document.getDocument', $args);
$this->setAttribute($output->data);
}
function setAttribute($attribute) {
if(!$attribute->document_srl) {
$this->document_srl = null;
return;
}
$this->document_srl = $attribute->document_srl;
$this->adds($attribute);
// 태그 정리
if($this->get('tags')) {
$tags = explode(',',$this->get('tags'));
$tag_count = count($tags);
for($i=0;$i<$tag_count;$i++) if(trim($tags[$i])) $tag_list[] = trim($tags[$i]);
$this->add('tag_list', $tag_list);
}
}
function isExists() {
return $this->document_srl ? true : false;
}
function isGranted() {
if($_SESSION['own_document'][$this->document_srl]) return true;
if(!Context::get('is_logged')) return false;
$logged_info = Context::get('logged_info');
if($logged_info->is_admin == 'Y') return true;
if($this->get('member_srl') && $this->get('member_srl') == $logged_info->member_srl) return true;
return false;
}
function setGrant() {
$_SESSION['own_document'][$this->document_srl] = true;
}
function isAccessible() {
return $_SESSION['accessible'][$this->document_srl]==true?true:false;
}
function allowComment() {
return $this->get('allow_comment') == 'Y' || !$this->isExists() ? true : false;
}
function allowTrackback() {
return $this->get('allow_trackback') == 'Y' || !$this->isExists() ? true : false;
}
function isLocked() {
return $this->get('lock_comment') == 'Y' ? true : false;
}
function isEditable() {
if($this->isGranted() || !$this->get('member_srl')) return true;
return false;
}
function isSecret() {
return $this->get('is_secret') == 'Y' ? true : false;
}
function isNotice() {
return $this->get('is_notice') == 'Y' ? true : false;
}
function useNotify() {
return $this->get('notify_message')=='Y' ? true : false;
}
function doCart() {
if($this->isCarted()) $this->removeCart();
else $this->addCart();
}
function addCart() {
$_SESSION['document_management'][$this->document_srl] = true;
}
function removeCart() {
unset($_SESSION['document_management'][$this->document_srl]);
}
function isCarted() {
return $_SESSION['document_management'][$this->document_srl];
}
function notify($type, $content) {
// useNotify가 아니면 return
if(!$this->useNotify()) return;
// 글쓴이가 로그인 유저가 아니면 패스~
if(!$this->get('member_srl')) return;
// 현재 로그인한 사용자와 글을 쓴 사용자를 비교하여 동일하면 return
$logged_info = Context::get('logged_info');
if($logged_info->member_srl == $this->get('member_srl')) return;
// 변수 정리
if($type) $title = "[".$type."] ";
$title .= cut_str(strip_tags($content), 10, '...');
$content = sprintf('%s
from : %s',$content, $this->getPermanentUrl(), $this->getPermanentUrl());
$receiver_srl = $this->get('member_srl');
$sender_member_srl = $logged_info->member_srl;
// 쪽지 발송
$oMemberController = &getController('member');
$oMemberController->sendMessage($sender_member_srl, $receiver_srl, $title, $content, false);
}
function isExistsHomepage() {
if(trim($this->get('homepage'))) return true;
return false;
}
function getHomepageUrl() {
$url = trim($this->get('homepage'));
if(!$url) return;
if(!eregi("^http:\/\/",$url)) $url = "http://".$url;
return $url;
}
function getMemberSrl() {
return $this->get('member_srl');
}
function getUserID() {
return htmlspecialchars($this->get('user_id'));
}
function getUserName() {
return htmlspecialchars($this->get('user_name'));
}
function getNickName() {
return htmlspecialchars($this->get('nick_name'));
}
function getTitleText($cut_size = 0, $tail='...') {
if($this->isSecret() && !$this->isGranted()) return Context::getLang('msg_is_secret');
if($cut_size) $title = cut_str($this->get('title'), $cut_size, $tail);
else $title = $this->get('title');
return $title;
}
function getTitle($cut_size = 0, $tail='...') {
$title = $this->getTitleText($cut_size, $tail);
$attrs = array();
if($this->get('title_bold')=='Y') $attrs[] = "font-weight:bold;";
if($this->get('title_color')) $attrs[] = "color:#".$this->get('title_color');
if(count($attrs)) return sprintf("%s", implode(';',$attrs), htmlspecialchars($title));
else return htmlspecialchars($title);
}
function getContentText($strlen = 0) {
if($this->isSecret() && !$this->isGranted()) return Context::getLang('msg_is_secret');
$_SESSION['accessible'][$this->document_srl] = true;
$content = $this->get('content');
if($strlen) return cut_str(strip_tags($content),$strlen,'...');
return htmlspecialchars($content);
}
function getContent($add_document_info = true) {
if($this->isSecret() && !$this->isGranted()) return Context::getLang('msg_is_secret');
$_SESSION['accessible'][$this->document_srl] = true;
$content = $this->get('content');
// OL/LI 태그를 위한 치환 처리
$content = preg_replace('!<(ol|ul|blockquote)>!is','<\\1 style="margin-left:40px;">',$content);
// url에 대해서 정규표현식으로 치환
$content = preg_replace('!([^>^"^\'^=])(http|https|ftp|mms):\/\/([^ ^<^"^\']*)!is','$1$2://$3',' '.$content);
// 추가 정보 출력을 하지 않는 경우
if(!$add_document_info) {
$content = sprintf(
'