Skip to content
TUWLAB.com
모든 게시물에 대하여 '링크'
방식의 퍼가기만 허용합니다.
한양대학교 전자통신컴퓨터공학부
바라미
  • 551
  • 2573215
DNS Powered by DNSEver.com
XE

Social XE 댓글 위젯에 SNS 전송 옵션 추가하기

Posted 2013. 01. 24 Updated 2017. 06. 02 Views 23632 Replies 6

Social XE를 도입하면서 XE 홈페이지와 SNS 사이트가 아주 가까워졌다는 것을 새삼 느끼곤 합니다.

여기에 글을 등록하면 동시에 SNS로 포스팅되어 올라가고, 동시에 지인들도 제가 지금 이 시각 무슨짓(?)을 하고 있는지 알 수 있으므로 일종의 근황 전달의 기능을 할 수 있다는 점이죠.

예전처럼 개인 블로그에 글 쓰고 그걸 또 다시 SNS로 퍼 나르거나, (혹은 그 반대) 하는 등의 시간 낭비를 하지 않아도 된다는 점에서 경제적입니다.

홈페이지 주인인 제가 이 곳에 글을 쓸때는 기본으로 XE 아이디를 갖고 있습니다. 따라서 글을 쓸 때 XE에 로그인을 한 뒤 부계정으로 SNS로 연결을 하게 되므로 SNS 전송 옵션은 언제든지 끌 수 있습니다.

- 하지만, XE 회원가입을 하지 않은 외부 방문객의 경우 이렇지 못합니다. SNS 계정을 갖고 있지만 XE에 회원가입은 되어 있지 않은 상황이죠. 이 때 댓글을 남기는 등의 활동을 할 때는 XE가 아닌 SNS계정이 주 계정으로 로그인을 하게 됩니다.

Social XE에서 SNS에 로그인을 한 채로 글이나 댓글을 남기면 동시에 해당 SNS 사이트로도 같은 내용의 글이 전송됩니다. 하지만, 단순 감사글이나 별로 의미가 없는 댓글, 혹은 개인적인 판단에 의해서 SNS로 글 전송을 막을 필요가 있는 경우가 있습니다.

Social XE에 본래 이러한 목적으로 '소셜 통합'에서 '글 전송 차단' 기능을 제공하지만, 이는 XE에 회원가입이 된 상태에서만 설정할 수 있습니다. 그리고 무엇보다도 개개의 글마다 빠른 옵션 적용이 불가능합니다.

예전부터 이러한 문제점을 알고 있었지만, 딱히 필요성을 느끼지 못해서 그냥 방치하다가 오늘 손을 대어 보았습니다. 오늘 작업한 내용은 우선 Social XE 댓글위젯에 SNS 전송 옵션 체크박스를 삽입하는 것입니다.


option_sns_post.png
▲ SNS 전송 옵션 기능을 추가한 Social XE 댓글 위젯


처음에는 그냥 댓글위젯 모듈에서 간단히 해결할 수 있을 줄 알았는데, 스크립트를 분석해 본 결과 socialxe 모듈까지 수정해야 했습니다. Social XE의 댓글 위젯은 단지 댓글 정보만 주고받는 통로 역할만을 수행하며, 실제 모든 처리는 socialxe 모듈에서 이루어집니다. (게시판의 댓글창을 그냥 때로 떼어서 달아 놓은 것이라고 생각하면 됩니다.)

이거 수정하려고 총 20여개에 이르는 파일들을 뒤졌고, 그중 7개 파일을 수정해야 했습니다. 삽질로 인해 많은 시간이 날아갔지만, 덕분에 XE의 동작에 관해서 많이 공부한 것 같습니다.. =.=;;



Language 파일 수정

사용할 텍스트를 등록하기 위해 /widgets/socialxe_comment/lang/ 디렉토리의 ko.lang.php 파일과 en.lang.php 파일을 다음과 같이 수정합니다.

<?php

$lang->select_service = "서비스 선택";
$lang->msg_login = '로그인해주세요.';
$lang->more = '더보기';
$lang->write_comment = '댓글 달기';
$lang->cmd_master = '대표 계정 변경';
$lang->master = '대표 계정';
$lang->viewComment = '전체 댓글 보기';
//$lang->about_socialxe = '소셜 서비스에 로그인 하신 후 댓글을 작성할 수 있습니다. 작성하신 댓글은 소셜 서비스에 동시 전송됩니다.';

/*+* [20130124|TUW] 소셜 전송 선택 기능 추가 */
/*+*/ $lang->about_socialxe = '소셜 서비스에 로그인 하신 후 댓글을 작성할 수 있습니다.';
/*+*/ $lang->send_social = '작성한 댓글을 SNS에도 전송합니다.';
?>

<?php
// English language pack, translation by misol <misol@korea.ac.kr> for SocialXE Comment widget
$lang->select_service = "Select service";
$lang->msg_login = 'Please, sign in.';
$lang->more = 'more';
$lang->write_comment = 'Post comment';
$lang->cmd_master = 'Change master account';
$lang->master = 'Master account';
$lang->viewComment = 'View all comments';
//$lang->about_socialxe = 'You can write a comment after SNS sign in. Your written comments would be posted on the SNS at the same time, you post.';

/*+* [20130124|TUW] 소셜 전송 선택 기능 추가 */
/*+*/ $lang->about_socialxe = 'You can write a comment after SNS sign in.';
/*+*/ $lang->send_social = 'Post written comment on SNS, too.';
?>



위젯 템플릿 파일 수정

댓글 위젯에 체크박스와 안내 문구가 표시되도록 /widgets/socialxe_comment/skins/default/ 디렉토리의 comment.htmlcomment_input.html 파일을 다음과 같이 수정합니다.

<!--@end-->
</script>

<a name="socialxe_comment"></a>
<div class="socialxe_comment">
	<!--@if($allow_comment)-->
		<form action="./" method="post" onsubmit="return socialSend(this, insert_social_comment);">
		<input type="hidden" name="document_srl" value="{$document_srl}" />
		<input type="hidden" name="content_link" value="{$content_link}" />
		<input type="hidden" name="skin" value="{$skin}" />
		<input type="hidden" name="list_count" value="{$list_count}" />
		<input type="hidden" name="content_title" value="{$content_title}" />
<!--//[20130124|TUW] 소셜 전송 선택 기능 추가 -->
<!--//+ --><input type="hidden" name="send_social" value="Y" />

		<div class="socialxe_comment_input">
			<!--#include("comment_input.html")-->
		</div>

		</form>
	<!--@end-->

	<div class="socialxe_comment_list">
		<!--#include("comment_list.html")-->
	</div>
</div>

<!--// 댓글 삭제용 폼-->

<!--@end-->
						<img width="24" height="24" src="./images/{$provider}_off.png" title="{$lang->provider[$provider]} {$lang->cmd_login}" alt="{$lang->provider[$provider]} {$lang->cmd_login}" class="iePngFix"/>
						</a>
					<!--@end-->
				</li>
				<!--@end-->
<!--//[20130124|TUW] 소셜 전송 선택 기능 추가 -->
<!--//+ -->		<li>
<!--//+ -->			<input type="checkbox" id="chkbox_send_social" checked="checked"|cond="$nick_name" disabled="disabled"|cond="!$nick_name" /><label for="chkbox_send_social" disabled="disabled"|cond="!$nick_name">{$lang->send_social}</label>
<!--//+ -->		</li>
			</ul>
		</fieldset>

		<fieldset class="socialxe_input">
		<legend>{$lang->cmd_reply}</legend>
			<div class="socialxe_name">
				<!--@if($nick_name)-->
					<img width="15" height="15" src="./images/{$master_provider}_small.png" alt="{$lang->provider[$master_provider]}" class="iePngFix"/> {$nick_name}
					<!--@if($slave_provider)-->



댓글 위젯 스크립트 수정

댓글 작성 정보를 전달할 때 SNS 게시 여부 옵션을 함께 전달하도록 /widgets/socialxe_comment/skins/default/js/socialxe.js 파일을 다음과 같이 수정합니다.

});
}
function completeAutoLogin(ret_obj){
	replaceInput(ret_obj);
	socialxe_auto_login_key = 'Y';
}

// 등록 시작하면 등록 비활성
var sending = false;
function socialSend(obj, filter){
	if (sending) return false;

	sending = true;

/*+* [20130124|TUW] 소셜 전송 선택 기능 추가 */
/*+*/ if(obj.send_social) obj.send_social.value = document.getElementById('chkbox_send_social').checked?'Y':'N';
	return procFilter(obj, filter);
}

// 댓글 삭제
function deleteSocialComment(comment_srl){
	var fo_obj = jQuery("#socialxe_delete_comment_form")[0];
	if(!fo_obj) return;
	fo_obj.comment_srl.value = comment_srl;
	procFilter(fo_obj, delete_social_comment);
}

// 댓글 삭제 후
function completeDeleteSocialComment(ret_obj)



socialxe 모듈 스크립트 수정

SNS 전송 옵션을 최종 댓글 등록 메소드로 전달하고, 이를 읽어 처리하도록 하기 위해 /modules/socialxe/ 디렉토리의 socialxe.controller.php 파일과 communicator.php 파일을 다음과 같이 수정합니다.

// 텍스타일이면 지지자 처리
			if ($module_info->module == 'textyle'){
				$oCommentModel = &getModel('comment');
				$oComment = $oCommentModel->getComment($comment_srl);

				$obj->module_srl = $module_info->module_srl;
				$obj->nick_name = $oComment->get('nick_name');
				$obj->member_srl = $oComment->get('member_srl');
				$obj->homepage = $oComment->get('homepage');
				$obj->comment_count = 1;

				$oTextyleController = &getController('textyle');
				$oTextyleController->updateTextyleSupporter($obj);
			}

			// 태그 제거 htmlspecialchars 복원
			$args->content = $this->htmlEntityDecode(strip_tags($args->content));

/*+* [20130124|TUW] 소셜 전송 선택 기능 추가 */
/*+*/		$args->send_social = Context::get('send_social');

			// 소셜 서비스로 댓글 전송
			$output = $this->sendSocialComment($args, $comment_srl, $msg);
			if (!$output->toBool()){
				$oCommentController->deleteComment($comment_srl);
				return $output;
			}

			// 위젯에서 화면 갱신에 사용할 정보 세팅
			$this->add('skin', Context::get('skin'));
			$this->add('document_srl', Context::get('document_srl'));
			$this->add('comment_srl', Context::get('comment_srl'));
			$this->add('list_count', Context::get('list_count'));
			$this->add('content_link', Context::get('content_link'));
			$this->add('msg', $msg);
		}

		// 소셜 사이트로 전송
		function sendSocialComment($args, $comment_srl, &$msg, $manual_data = null){

// URL 생성
		$url = $this->getURL('send', $data);

/*+* [20130124|TUW] 소셜 전송 선택 기능 추가 */
/*+*/	if( $args->send_social != 'N' )
/*+*/	{
			// 요청
			$content = $this->httpRequest($url, 'POST');

			if (!$content){
				$result->setError(-1);
				$result->setMessage('msg_request_error');
				return $result;
			}

			// JSON 디코딩
			$json = new Services_JSON_SocialXE();
			$output = $json->decode($content);
			if (!$output){
				return new Object(-1, $content);
			}

			// 오류 체크
			if ($output->error){
				$result->setError(-1);
				$result->setMessage($output->message);
				return $result;
			}

			// 전송 결과를 체크
			$msg = array();
			$lang_provider = Context::getLang('provider');
			foreach($this->providerManager->getProviderList() as $provider){
				if ($output->result->{$provider}->error){
					$msg[] = sprintf(Context::getLang('msg_send_failed'), $lang_provider[$provider], $output->result->{$provider}->error);
				}
			}
			if (count($msg)){
				$msg = implode("\n", $msg);
				$result->add('msg', $msg);
			}

			if($config->use_short_url != 'N') {
				// bit.ly 결과를 저장한다.
				if ($bitly){
					$bitly_result = $bitly->getRawResults();
					$args->hash = $bitly_result['userHash'];
					$args->title = $comment->content_title;
					$args->short_url = $comment->short_link;
					$args->url = $this->_getCommentUrl($comment->content_link, $comment->parent->comment_srl);
					executeQuery('socialxe.insertBitly', $args);
				}
			}
/*+*/	}
	
		// 대표 계정의 댓글 번호를 세팅한다.

※ 266번째 줄의 대괄호 닫는 부분을 꼭!! 추가해 주세요. ^-^


참조 : 수정된 파일 목록

ko.lang.php  -> /widgets/socialxe_comment/lang/
en.lang.php  -> /widgets/socialxe_comment/lang/
comment.html  -> /widgets/socialxe_comment/skins/default/
comment_input.html  -> /widgets/socialxe_comment/skins/default/
socialxe.js -> /widgets/socialxe_comment/skins/default/js/
socialxe.controller.php  -> /modules/socialxe/
communicator.php -> /modules/socialxe/


서비스 선택
이용중인 SNS 버튼을 클릭하여 로그인 해주세요.
SNS 계정을 통해 로그인하면 회원가입 없이 댓글을 남길 수 있습니다.
댓글
?
Powered by SocialXE

  • ?
    홈페이지 문부기 2013.01.24 21:16:28
    좋은팁 감사합니다. ^.^
    /modules/socialxe/communicator.php 에서 아래부분 { 때문에 에러를 일으킵니다. ; 이 맞지 않나요.
    if( $args->send_social != 'N' )
    {
  • 홈페이지 TUW 2013.01.24 20:20:21
    현재 대댓글 관련 오류가 발견되어 수정중에 있습니다.
    조만간 보완된 수정 방법을 다시 정리하여 올리도록 하겠습니다. ㅡ.ㅜ

List of Articles
번호 분류 제목 글쓴이 최근 수정일 조회 수
97 XE XE 룰셋(Ruleset) 작성 방법 매뉴얼 file TUW 2017.06.02 12739
96 XE [XE] elFinderXE 모듈 24 file TUW 2019.10.14 13995
95 XE Social XE 트위터 프로필사진 표시 문제 해결하기 3 file TUW 2017.06.02 205146
94 Android 루팅 응용 : 스마트폰 부팅화면 커스터마이징 4 file TUW 2017.06.02 33787
93 Android 루팅 응용 : 스마트폰 카메라 셔터음 없애기 2 file TUW 2018.02.08 34299
92 Android 삼성 스마트폰 루팅하기 file TUW 2017.06.02 22886
» XE Social XE 댓글 위젯에 SNS 전송 옵션 추가하기 6 file TUW 2017.06.02 23632
90 Linux Ubuntu에서 PHP 최신버전 업데이트하기 TUW 2014.04.23 11025
89 Apache Apache2 서버에 SSL/HTTPS 설치하기 (StartSSL) - 2 file TUW 2017.06.02 20544
88 Apache Apache2 서버에 SSL/HTTPS 설치하기 (StartSSL) - 1 file TUW 2017.06.02 17807
87 Linux [Emacs] 주요 단축키 모음 file TUW 2017.06.02 11576
86 Linux [Vi/Vim] 단축키 모음 file TUW 2017.06.02 11549
85 Linux [vi] 기본환경설정 (줄번호 표시, 방향키활성 등) TUW 2014.04.23 11627
84 Linux [vsFTP] 계정별 서로 다른 루트 디렉토리 지정하기 (chroot) file TUW 2017.06.02 23786
83 Linux iptables 명령을 이용하여 특정 IP대역 접속 차단하기 TUW 2014.11.17 19030
82 Apache Apache 일별 로그파일 생성하기, 필터링 로깅하기 TUW 2014.04.23 19932
목록
Board Pagination Prev 1 ... 4 5 6 7 8 9 10 ... 13 Next
/ 13

Powered by Xpress Engine / Designed by Sketchbook

sketchbook5, 스케치북5

sketchbook5, 스케치북5