lightbox로 불러온 레이어팝업에서 프린트기능을 추가할 수 없을까요? 정보
lightbox로 불러온 레이어팝업에서 프린트기능을 추가할 수 없을까요?첨부파일
본문
라이트박스를 이용한 갤러리 스킨을 사용중입니다.
기존의 lightbox소스가 사용되었구요~~
갤러리 내용보기에서 첨부된 이미지들이 쭈루룩 보이고
그 첨부이미지를 클릭하면 라이트박스가 적용되어서 팝업으로 뜨는데요~
이미지가 레이어로 팝업된 상태에서 인쇄버튼을 클릭하면
해당이미지를 프린트할 수 있을까요??
라이트박스로 된 이미지에 이미지제목이랑 넥스트프리뷰버튼
클로즈버튼이 각각 있는데
여기에다가 인쇄버튼을 추가하고
그 버튼을 클릭하면 해당이미지가 프린트되는 기능이 필요합니다.
view.skin.php에서 수정을 해야하는건 아닌것 같고
lightbox.js를 수정해야 할것 같은데
당최 어디를 어떻게 수정해야 할지..ㅠㅠ
근 일주일째 질문답변 활용팁 구석구석 찾아봐도
비슷한 내용조차 없어서 답답한 마음에 질문을 남깁니다.ㅠㅠ
라이트박스 소스는 첨부했구요
혹시 몰라서 뷰파일소스도 함께 남깁니다.
고수님들의 답변 꼭 부탁드릴께요~~~~
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
include_once("$board_skin_path/skin.lib.php");
if ($board[bo_1_subj] != "원본 이미지 크기" && $board[bo_2_subj] != "썸네일 이미지 크기") {
sql_query("update $g4[board_table] set bo_1_subj='원본 이미지 크기', bo_2_subj='썸네일 이미지 크기', bo_2='100x100' where bo_table='$bo_table'", false);
$board = sql_fetch("select $g4[board_table] where bo_table='$bo_table'", false);
}
if (!$board[bo_2]) die("여분필드1 [썸네일 이미지 크기] 를 설정해주세요. (예) 100x100");
list($img2_width, $img2_height) = explode("x", $board[bo_2]);
if (!($img2_width && $img2_height)) $img2_width = $img2_height = 90;
?>
<?
$view = get_view($write, $board, $board_skin_path);
if (strstr($sfl, "subject"))
$view[subject] = search_font($stx, $view[subject]);
$html = 0;
if (strstr($view[wr_option], "html1"))
$html = 1;
else if (strstr($view[wr_option], "html2"))
$html = 2;
$view[content] = conv_content($view[wr_content], $html);
if (strstr($sfl, "content"))
$view[content] = search_font($stx, $view[content]);
$view[content] = preg_replace("/(\<img )([^\>]*)(\>)/i", "\\1 name='target_resize_image[]' onclick='' \\2 \\3", $view[content]);
//$view[rich_content] = preg_replace("/{img\:([0-9]+)[:]?([^}]*)}/ie", "view_image(\$view, '\\1', '\\2')", $view[content]);
$view[rich_content] = preg_replace("/{이미지\:([0-9]+)[:]?([^}]*)}/ie", "view_image(\$view, '\\1', '\\2')", $view[content]);
?>
<script language=javascript>
//
// Configuration
//
var fileLoadingImage = "<?=$board_skin_path?>/images/loading.gif";
var fileBottomNavCloseImage = "<?=$board_skin_path?>/images/closelabel.gif";
var overlayOpacity = 0.3; // controls transparency of shadow overlay
var animate = true; // toggles resizing animations
var resizeSpeed = 10; // controls the speed of the image resizing animations (1=slowest and 10=fastest)
var borderSize = 30; //if you adjust the padding in the CSS, you will need to update this variable
</script>
<link rel = stylesheet href="../style4.css" type="text/css">
<script type="text/javascript" src="<?=$g4[path]?>/js/prototype.js"></script>
<script type="text/javascript" src="<?=$board_skin_path?>/lightbox.js"></script>
<script type="text/javascript" src="<?=$board_skin_path?>/scriptaculous.js?load=effects"></script>
<style type=text/css>
#lightbox{
position: absolute;
left: 0;
width: 100%;
z-index: 100;
text-align: center;
line-height: 0;
}
#lightbox a img{ border: none; }
#outerImageContainer{
position: relative;
background-color: #fff;
width: 250px;
height: 250px;
margin: 0 auto;
}
#imageContainer{
padding: 5px;
}
#loading{
position: absolute;
top: 50%;
left: 0%;
height: 25%;
width: 100%;
text-align: center;
line-height: 0;
}
#hoverNav{
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
z-index: 10;
}
#imageContainer>#hoverNav{ left: 0;}
#hoverNav a{ outline: none;}
#prevLink, #nextLink{
width: 49%;
height: 100%;
background: transparent url(<?=$board_skin_path?>/images/blank.gif) no-repeat; /* Trick IE into showing hover */
display: block;
}
#prevLink { left: 0; float: left;}
#nextLink { right: 0; float: right;}
#prevLink:hover, #prevLink:visited:hover { background: url(<?=$board_skin_path?>/images/prevlabel.gif) left 15% no-repeat; }
#nextLink:hover, #nextLink:visited:hover { background: url(<?=$board_skin_path?>/images/nextlabel.gif) right 15% no-repeat; }
#imageDataContainer{
font: 10px Verdana, Helvetica, sans-serif; color: #000; background-color: #fff; margin: 0 auto; line-height: 1.4em; overflow: auto; width: 100%
}
#imageData{ padding:0 10px; color: #666; }
#imageData #imageDetails{ width: 70%; float: left; text-align: left; }
#imageData #caption{ font: 14px Verdana, Helvetica, sans-serif; font-weight: bold; color: #000000; }
#imageData #bottomNavClose{ width: 66px; float: right; padding-bottom: 0.7em; }
#imageData #numberDisplay{ color: #ffffff; display: block; clear: left; padding-bottom: 1.0em; }
#overlay{
position: absolute;
top: 0;
left: 0;
z-index: 90;
width: 100%;
height: 500px;
background-color: #000;
}
</style>
<!-- 게시글 보기 시작 -->
<!-- 제목, 글쓴이, 날짜, 조회, 추천, 비추천 -->
<?
$n = 6; // 한줄당 출력 이미지수
$wid = (int)(1/$n*100);
echo "<table width='500' cellpadding=3 cellspacing=0 border=0>";
echo "<tr>";
for ($i=1; $i<=count($view[file]); $i++) {
if (($view[file][$i][view]) && $i>0 && ($i%$n == 0)) {
echo "</tr><tr>";
}
if ($view[file][$i][view]) {
$file = "{$view[file][$i][path]}/{$view[file][$i][file]}";
$thumb = "{$g4[path]}/data/file/{$bo_table}/thumb/{$wr_id}_{$i}_{$img2_width}x{$img2_height}";
if (!file_exists($thumb)) createThumb($img2_width, $img2_height, $file, $thumb, true);
echo "<td width='${wid}%' align='center'>";
echo "<a href=\"$file\" rel=\"lightbox[plants]\" title=\"{$view[file][$i][bf_content]}\"><img src=\"$thumb\" width=\"{$img2_width}\" height=\"{$img2_height}\" style=\"border:1px solid #D1D2D2;\" style=\"filter:progid:DXImageTransform.Microsoft.Shadow(color=#6C828E,Direction=135,Strength=3)\"></a>";
echo "<br><b><font class=content'>".$view[file][$i][bf_content] ."</font></b>";// 이미지 설명글
}
}
// 부족한 <td> 갯수 맞추는 작업
if ((count($view[file])-1) % $n != 0) {
$td_cnt = $n - ((count($view[file])-1)%$n);
for ($t=0; $t<$td_cnt; $t++) {
echo "<td width='${wid}%'> </td>";
}
}
echo "</tr></table>";
echo "<p>";
?>
<!-- 링크 버튼 -->
<?
ob_start();
?>
<table width='600' cellpadding=0 cellspacing=0>
<tr height=35>
<td width=75%>
<? if ($write_href) { echo "<a href=\"$write_href\"><img src='$board_skin_path/img/btn_write.gif' border='0' align='absmiddle'></a> "; } ?>
<? if ($update_href) { echo "<a href=\"$update_href\"><img src='$board_skin_path/img/btn_modify.gif' border='0' align='absmiddle'></a> "; } ?>
<? if ($delete_href) { echo "<a href=\"$delete_href\"><img src='$board_skin_path/img/btn_del.gif' border='0' align='absmiddle'></a> "; } ?>
<? if ($copy_href) { echo "<a href=\"$copy_href\"><img src='$board_skin_path/img/btn_copy.gif' border='0' align='absmiddle'></a> "; } ?>
<? if ($move_href) { echo "<a href=\"$move_href\"><img src='$board_skin_path/img/btn_move.gif' border='0' align='absmiddle'></a> "; } ?>
</td>
<td width=25% align=right></td>
</tr>
</table>
<script language="JavaScript">
function file_download(link, file) {
<? if ($board[bo_download_point] < 0) { ?>if (confirm("'"+file+"' 파일을 다운로드 하시면 포인트가 차감(<?=number_format($board[bo_download_point])?>점)됩니다.\n\n포인트는 게시물당 한번만 차감되며 다음에 다시 다운로드 하셔도 중복하여 차감하지 않습니다.\n\n그래도 다운로드 하시겠습니까?"))<?}?>
document.location.href=link;
}
</script>
<script language="JavaScript" src="<?="$g4[path]/js/board.js"?>"></script>
<script language="JavaScript">
window.onload=function() {
resizeBoardImage(<?=(int)$board[bo_image_width]?>);
drawFont();
}
</script>
<!-- 게시글 보기 끝 -->
댓글 전체
간단히 말해 이미지를 출력하는 거잖아요
먼저 인쇄할 수 있는 환경을 만들고
(MeadCo's ScriptX 의 smsx.cab 파일은 어디서 나눠주는데 잊어먹었네요. 검색해보시면 나올겁니다.)
bbs/board.php 파일을 복사합니다. print_image.php 파일로 이름을 바꾸고요
(print.php 는 다른용도로 쓰이니 중복 주의)
맨 아래 부분에
include_once("$board_skin_path/view.skin.php"); 을
include_once("$board_skin_path/print.skin.php"); 로 바꿔줍니다.
skin 폴더에 view.skin.php 파일을 복사해 print.skin.php 파일로 이름을 바꿔줍니다.
print.skin.php 에서 전달된 이미지만 출력되게 편집하고
MeadCo's ScriptX 의 인쇄관련 스크립트와 <body> 설정을 넣어줍니다.
<script language="javascript">
// 프린트 하기
function printPage(header,footer,portrait,leftMargin,topMargin,rightMargin,bottomMargin,act) {
if (!factory.object) {
alert("본 페이지에서 제공하는 MeadCo's ScriptX 를 설치하여 주십시오.");
return
}
else {
factory.printing.header = header; // Header에 들어갈 문장
factory.printing.footer = footer; // Footer에 들어갈 문장
factory.printing.portrait = portrait; // true 면 가로인쇄, false 면 세로 인쇄
factory.printing.leftMargin = leftMargin; // 왼쪽 여백 사이즈
factory.printing.topMargin = topMargin; // 위 여백 사이즈
factory.printing.rightMargin = rightMargin; // 오른쪽 여백 사이즈
factory.printing.bottomMargin = bottomMargin; // 아래 여백 사이즈
if ( act == "preview" ) {
factory.printing.Preview(); //preview
}
else {
factory.printing.Print(true, window); // 첫번째 인자 : 대화상자표시여부 , 두번째인자 : 출력될 프레임
}
self.opener = self;
self.close();
}
}
</script>
<body bgcolor="#FFFFFF" topmargin="0" leftmargin="0" onLoad="printPage('<?=addslashes($g4[title]);?>','<?=date("Y-m-d H:i:s", time());?>',true,'6.0','14.0','6.0','7.0','<?=$print;?>');">
<object id="factory" style="display:none" viewastext classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" codebase="<?=$g4[path]?>/smsx.cab#Version=6,5,439,12">
</object>
<img src="$view[file][$imageno][href]">
이런식으로요...
최종적으로 이미지인쇄 클릭시 인쇄되는 설정만 해 주시면 되겠네요...
view.skin.php에다
<form name="myform">
<input type="hidden" name="bo_table" value="<?=$bo_table?>" />
<input type="hidden" name="ca_name">
<input type="hidden" name="wr_id" value="<?=$wr_id?>" />
<input type="hidden" name="print" value="preview" />
<input type="hidden" name="imageno" value="" />
</form>
<script language="javascript">
// 프린트 하기
function print(url, getval){
window.open("","newWindow","width=800, height=600, menubar=no, status=yes, scrollbars=yes");
document.myform.action = url;
document.myform.imageno.value = getval;
document.myform.target = "newWindow";
document.myform.submit();
document.myform.target = "_self";
}
</script>
<a href="javascript:print('print_image.php?imageno=<?=$i?>', <?=$i?>);"><?=$view[file][$i][view]?><a>
자바로 링크하는 이유는 넘겨야 할 값들이 몇개 되서 입니다.
get방식도 무방합니다.