웹마스터 팁
page_full_width" class="col-xs-12" |cond="$__Context->page_full_width">
외부이미지 저장 애드온을 본문을 읽으면 작동하도록 하자!! 1.7.3적용
2013.03.16 00:20
카르마님의 외부이미지 저장 애드온을 가지고 사용중인데요.
기존 본문에 있는 이미지를 적용하기 위해서는 일부러 수정을 눌렀다가 저장을 해야 적용이 되는 불편한 점이 있었습니다.
오늘 푸시아님의 도움으로 편하게 본문을 읽어도 바로 외부이미지 저장기법이 적동되도록 수정하는데 성공했습니다.
원 애드온 소스는 카르마님의 사이트에 있구요.
저는 변경된 소스만 공유하도록 하겠습니다. ^^
<?php
if(!defined("__ZBXE__")) exit();
/**
* @outimage.addon.php
* @author 카르마(http://www.wildgreen.co.kr)
*
**/
$oDocumentModel = &getModel('document');
$act_arr = array('dispBoardContent','dispBodexContent','dispTextyle','dispBodexContentView','dispBoardContentView');
$document_act = array('dispBoardContent','procBoardInsertDocument','procBodexInsertDocument');
$comment_act = array('procBoardInsertComment','procBodexInsertComment');
$ri_avoid_domain = explode(',', $addon_info->ri_avoid_domain);
array_push($ri_avoid_domain,$_SERVER['HTTP_HOST']);
require_once('./addons/auto_outimage/auto_outimage.func.php');
if($addon_info->ri_permanent_get =='Y') {
if($called_position == 'after_module_proc' && in_array($this->act,$document_act) ) {
$var = $this->variables;
$document_srl = Context::get('document_srl');;
if(!$document_srl) return;
$module_info = $oModuleModel->getModuleInfoByDocumentSrl($document_srl);
$args->document_srl = $document_srl;
$output = executeQuery('document.getDocument', $args);
$content = $output->data->content;
//$oDocument = $oDocumentModel->getDocument($document_srl);
//$content = $oDocument->getContent(false,false,false,false);
$upload_target_srl = $document_srl;
$oFileController = &getController('file');
$contImg = extractImage($content);
if(count($contImg)) {
$replace = $content;
foreach($contImg as $src) {
$ri_localfile = geRitLocalFile($src,$ri_avoid_domain,'N');
if(strcmp($src,$ri_localfile)==true)
{
$url = parse_url($ri_localfile);
$path_parts = pathinfo($url['path']);
$file_info['name']=$path_parts['basename'];
$file_info['tmp_name']=$ri_localfile;
$file_obj = $oFileController->insertFile($file_info,$module_info->module_srl,$upload_target_srl,0,true);
if(@$file_obj->variables['uploaded_filename']!=null) $replace = str_replace($src,$file_obj->variables['uploaded_filename'],$replace);
@unlink($ri_localfile);
}
}
$obj->module_srl = $module_info->module_srl;
$obj->content = $replace;
$obj->document_srl = $document_srl;
executeQuery('addons.auto_outimage.updateDocument', $obj);
}
} elseif($addon_info->ri_comment_get != 'N' && $called_position == 'after_module_proc' && in_array($this->act,$comment_act)) {
$var = $this->variables;
$document_srl = $var[document_srl];
$module_info = $oModuleModel->getModuleInfoByDocumentSrl($document_srl);
$comment_srl = $var[comment_srl];
if(!$comment_srl) return;
$oCommentModel = &getModel('comment');
$comment = $oCommentModel->getComment($comment_srl);
$content = $comment->getContent(false,false,false,false);
$upload_target_srl = $comment_srl;
$oFileController = &getController('file');
$contImg = extractImage($content);
if(count($contImg)) {
foreach($contImg as $src) {
$ri_localfile = geRitLocalFile($src,$ri_avoid_domain,'N');
if(strcmp($src,$ri_localfile)==true)
{
$url = parse_url($ri_localfile);
$path_parts = pathinfo($url['path']);
$file_info['name']=$path_parts['basename'];
$file_info['tmp_name']=$ri_localfile;
$file_obj = $oFileController->insertFile($file_info,$module_info->module_srl,$upload_target_srl,0,true);
if(@$file_obj->variables['uploaded_filename']!=null) $replace = str_replace($src,$file_obj->variables['uploaded_filename'],$replace);
@unlink($ri_localfile);
}
}
$obj->module_srl = $module_info->module_srl;
$obj->content = $content;
$obj->comment_srl = $comment_srl;
$output = executeQuery('addons.auto_outimage.updateComment', $obj);
}
}
} else {
$document_srl = Context::get('document_srl');
if(!$document_srl) return;
$current_module_info = Context::get('current_module_info');
$oView = &getView($current_module_info->module);
$act = $oView->act;
if($_COOKIE['mobile'] || in_array($act,$act_arr) && $called_position == 'before_display_content') {
$oDocument = $oDocumentModel->getDocument($document_srl);
$content = $oDocument->getContent(false,false,false,false);
$_comment_list = $oDocument->getComments();
$contImg = extractImage($content);
if(count($contImg)) {
$replace = $content;
foreach($contImg as $src) {
$ri_localfile = geRitLocalFile($src,$ri_avoid_domain,$addon_info->ri_permanent_get);
$replace = str_replace($src,$ri_localfile,$replace);
}
$output = str_replace($content,$replace,$output);
}
if($addon_info->ri_comment_get == 'Y' && $oDocument->getCommentCount()) {
$pattern_comments_area = '/<div class="comment_[0-9]+_[0-9]+ xe_content">(.*?)<!--AfterComment\([0-9]+,[0-9]+\)-->/is';
preg_match_all($pattern_comments_area, $output,$match);
if(!count($match[0])) return;
foreach ($match[0] as $comment) {
$list = extractImage($comment);
if(count($list)) {
$repcom = $comment;
foreach($list as $rfile) {
$ri_localfile = geRitLocalFile($rfile,$ri_avoid_domain,$addon_info->ri_permanent_get);
$repcom = str_replace($rfile,$ri_localfile,$repcom);
}
$output = str_replace($comment,$repcom,$output);
}
}
}
}
}
?>
if(!defined("__ZBXE__")) exit();
/**
* @outimage.addon.php
* @author 카르마(http://www.wildgreen.co.kr)
*
**/
$oDocumentModel = &getModel('document');
$act_arr = array('dispBoardContent','dispBodexContent','dispTextyle','dispBodexContentView','dispBoardContentView');
$document_act = array('dispBoardContent','procBoardInsertDocument','procBodexInsertDocument');
$comment_act = array('procBoardInsertComment','procBodexInsertComment');
$ri_avoid_domain = explode(',', $addon_info->ri_avoid_domain);
array_push($ri_avoid_domain,$_SERVER['HTTP_HOST']);
require_once('./addons/auto_outimage/auto_outimage.func.php');
if($addon_info->ri_permanent_get =='Y') {
if($called_position == 'after_module_proc' && in_array($this->act,$document_act) ) {
$var = $this->variables;
$document_srl = Context::get('document_srl');;
if(!$document_srl) return;
$module_info = $oModuleModel->getModuleInfoByDocumentSrl($document_srl);
$args->document_srl = $document_srl;
$output = executeQuery('document.getDocument', $args);
$content = $output->data->content;
//$oDocument = $oDocumentModel->getDocument($document_srl);
//$content = $oDocument->getContent(false,false,false,false);
$upload_target_srl = $document_srl;
$oFileController = &getController('file');
$contImg = extractImage($content);
if(count($contImg)) {
$replace = $content;
foreach($contImg as $src) {
$ri_localfile = geRitLocalFile($src,$ri_avoid_domain,'N');
if(strcmp($src,$ri_localfile)==true)
{
$url = parse_url($ri_localfile);
$path_parts = pathinfo($url['path']);
$file_info['name']=$path_parts['basename'];
$file_info['tmp_name']=$ri_localfile;
$file_obj = $oFileController->insertFile($file_info,$module_info->module_srl,$upload_target_srl,0,true);
if(@$file_obj->variables['uploaded_filename']!=null) $replace = str_replace($src,$file_obj->variables['uploaded_filename'],$replace);
@unlink($ri_localfile);
}
}
$obj->module_srl = $module_info->module_srl;
$obj->content = $replace;
$obj->document_srl = $document_srl;
executeQuery('addons.auto_outimage.updateDocument', $obj);
}
} elseif($addon_info->ri_comment_get != 'N' && $called_position == 'after_module_proc' && in_array($this->act,$comment_act)) {
$var = $this->variables;
$document_srl = $var[document_srl];
$module_info = $oModuleModel->getModuleInfoByDocumentSrl($document_srl);
$comment_srl = $var[comment_srl];
if(!$comment_srl) return;
$oCommentModel = &getModel('comment');
$comment = $oCommentModel->getComment($comment_srl);
$content = $comment->getContent(false,false,false,false);
$upload_target_srl = $comment_srl;
$oFileController = &getController('file');
$contImg = extractImage($content);
if(count($contImg)) {
foreach($contImg as $src) {
$ri_localfile = geRitLocalFile($src,$ri_avoid_domain,'N');
if(strcmp($src,$ri_localfile)==true)
{
$url = parse_url($ri_localfile);
$path_parts = pathinfo($url['path']);
$file_info['name']=$path_parts['basename'];
$file_info['tmp_name']=$ri_localfile;
$file_obj = $oFileController->insertFile($file_info,$module_info->module_srl,$upload_target_srl,0,true);
if(@$file_obj->variables['uploaded_filename']!=null) $replace = str_replace($src,$file_obj->variables['uploaded_filename'],$replace);
@unlink($ri_localfile);
}
}
$obj->module_srl = $module_info->module_srl;
$obj->content = $content;
$obj->comment_srl = $comment_srl;
$output = executeQuery('addons.auto_outimage.updateComment', $obj);
}
}
} else {
$document_srl = Context::get('document_srl');
if(!$document_srl) return;
$current_module_info = Context::get('current_module_info');
$oView = &getView($current_module_info->module);
$act = $oView->act;
if($_COOKIE['mobile'] || in_array($act,$act_arr) && $called_position == 'before_display_content') {
$oDocument = $oDocumentModel->getDocument($document_srl);
$content = $oDocument->getContent(false,false,false,false);
$_comment_list = $oDocument->getComments();
$contImg = extractImage($content);
if(count($contImg)) {
$replace = $content;
foreach($contImg as $src) {
$ri_localfile = geRitLocalFile($src,$ri_avoid_domain,$addon_info->ri_permanent_get);
$replace = str_replace($src,$ri_localfile,$replace);
}
$output = str_replace($content,$replace,$output);
}
if($addon_info->ri_comment_get == 'Y' && $oDocument->getCommentCount()) {
$pattern_comments_area = '/<div class="comment_[0-9]+_[0-9]+ xe_content">(.*?)<!--AfterComment\([0-9]+,[0-9]+\)-->/is';
preg_match_all($pattern_comments_area, $output,$match);
if(!count($match[0])) return;
foreach ($match[0] as $comment) {
$list = extractImage($comment);
if(count($list)) {
$repcom = $comment;
foreach($list as $rfile) {
$ri_localfile = geRitLocalFile($rfile,$ri_avoid_domain,$addon_info->ri_permanent_get);
$repcom = str_replace($rfile,$ri_localfile,$repcom);
}
$output = str_replace($comment,$repcom,$output);
}
}
}
}
}
?>
댓글 18
제목 | 글쓴이 | 날짜 |
---|---|---|
XE를 처음 접하거나 이제막 사이트개발을 하려는 초보자를 위한 XE 접근방법 [1] | DuRi | 2009.11.12 |
1.3.0 버전에서 모듈설치 방법과 시작 모듈 설정하기
[21]
![]() | 스타호스트 | 2009.11.11 |
추천인/비추천인 표시하기
[7]
![]() | 고진감래 | 2009.11.05 |
게시판 리스트에서 확장변수를 카테고리처럼 보여주기
[11]
![]() | 고진감래 | 2009.11.05 |
XE로 API 처리 완전 정복하기(2)
[2]
![]() | 라르게덴 | 2009.11.03 |
XE로 API 처리 완전 정복하기(1)
[6]
![]() | 라르게덴 | 2009.11.02 |
프로필이미지, 이미지마크, 이미지이름 수정, 추가시 포인트 삭감 [1] | lattente | 2009.11.02 |
카운터위젯 - 오늘 가입한 회원수 전체 회원수 출력 [5] | 공수래 | 2009.11.01 |
1.2.6 업데이트 후 애드온 등 css가 적용 안되는 분들~ | SeokiE | 2009.10.29 |
board.api.php 사용법
[1]
![]() | Hide_D | 2009.10.29 |
게시판 글작성 선택적 메일보내기 - 확장변수 이용
[2]
![]() | noirzo | 2009.10.28 |
제로보드 XE가 갑자기 느려져서 확인해봤더니 [1] | jy1664 | 2009.10.27 |
하나의 게시물을 각각 다르게 보이도록 만드는 방법 [5] | 얼터1.0 | 2009.10.24 |
Blog API ''not logged'' 오류 해결법
[2]
![]() | June Oh | 2009.10.23 |
오늘 게시된 글은 날짜 대신 today 그림으로 대치 (왕초보용 초간단팁)
![]() | jsuimage | 2009.10.21 |
댓글 삭제/수정/답글 시 팝업창으로 띄우기
[22]
![]() | 고진감래 | 2009.10.21 |
댓글 새창으로 보기 (경로수정)
[1]
![]() | 고진감래 | 2009.10.20 |
1.2.6 버전에서 메뉴추가 안되시는 분들 읽어보세요... [6] | Crazyhouse.cn | 2009.10.19 |
모든 원하는 확장변수를 선택해서 최근게시물 위젯에 나타내기 간단팁 [12] | jsuimage | 2009.10.17 |
간단한 위키링크 흉내내기 [5] | 고진감래 | 2009.10.17 |