영문판 달력 소스에 대한 질문입니다. > 그누4 질문답변

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기
기존 게시물은 열람만 가능합니다.

영문판 달력 소스에 대한 질문입니다. 정보

영문판 달력 소스에 대한 질문입니다.

본문

외국에서는 요일표시를 월화수목금토일... 이런 식으로 일요일이 멘 뒤에 나오더군요.
지금 외국용 사이트를 만드는 중인데 이 부분때문에 또 질문 드립니다.
아래 소스는 어떤 분(?-_-;;)이 그누보드에 올려놓은 달력형 최근글입니다.
현재 일월화수목금토... 이런 식인데 이걸 월화수목금토일.. 이런 식으로 바꾸려면 어딜 손봐야 할까요?
이미지는 스샷입니다.


<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가

$cellh  = 20;
$cellw  = 20;
?>
<style type="text/css">
td.title    {text-align: center; padding-top: 1pt; padding-bottom: 1pt; height: 25px; font-weight:bold;}
td.invalid  {
    text-align: center; padding-top: 2pt; height:<?=$cellh?>; width:<?=$cellh?>;
    background-image: url(<?=$latest_skin_path?>..);
}

td.valid    {
    text-align: center; padding-top: 2pt; height:<?=$cellh?>; width:<?=$cellh?>;
    background-image: url(<?=$latest_skin_path?>..);
}

td.today    {
    text-align: center; padding-top: 2pt; height:<?=$cellh?>; width:<?=$cellh?>;
    background-image: url(<?=$latest_skin_path?>..);
}

p.title     {font-size: 1em; font-weight:bold}
p.sunday    {
    text-align: center;
    font-size: 9pt;
    color: #FF6666;
    font-family: "굴림", "돋움";
}
p.saturday  {
    text-align: center;
    font-size: 9pt;
    color: #0099FF;
    font-family: "굴림", "돋움";
}
p.weekday   {
    text-align: center;
    font-size: 9pt;
    font-family: "굴림", "돋움";
}

a:link.writeday, a:visited.writeday  {font-family: "굴림", "돋움"; text-align: center; font-size: 9pt; color: #fd7100;}
</style>
<?
$today = getdate();
$b_mon = $today['mon'];
$b_day = $today['mday'];
$b_year = $today['year'];
if ($year < 1) {
   $month = $b_mon;
   $mday = $b_day;
   $year = $b_year;
}

$lastday=array(0,31,28,31,30,31,30,31,31,30,31,30,31);
if ($year%4 == 0) $lastday[2] = 29;
$dayoftheweek = date("w", mktime (0,0,0,$month,1,$year));

?>

<table width=190 border="0" cellspacing="0" cellpadding="0" align=center>
  <tr>
    <td width="16" height="16"><img src="<?=$latest_skin_path?>/image/table_1.gif" width="16" height="16"></td>
    <td height="16" background="<?=$latest_skin_path?>/image/table_haed.gif"></td>
    <td width="16" height="16"><img src="<?=$latest_skin_path?>/image/table_2.gif" width="16" height="16"></td>
  </tr>
  <tr>
    <td background="<?=$latest_skin_path?>/image/table_left.gif"></td>
    <td bgcolor="#FFFFFF">

    <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td valign="top">
          
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td rowspan="2">
                <a href="<?=$g4[bbs_path]?>/board.php?bo_table=<?=$bo_table?>" onfocus="this.blur()">
                <img src="<?=$latest_skin_path?>/image/cal/m_<?=$month?>.gif" width="35" height="42" border="0"></a></td>
                <td><img src="<?=$latest_skin_path?>/image/cal/y_<?=$year?>.gif"></td>
              </tr>
              <tr>
                <td colspan=2><img src="<?=$latest_skin_path?>/image/cal/m2_<?=$month?>.gif"></td>
              </tr>
<tr><td colspan=3 height=10>
            </table>
            
            <TABLE width=<?=$cellw*7?> cellSpacing=0 cellPadding=0 border=0 align=center>
<TR bgcolor=#dddddd>
    <td class=sunday><p class=sunday>S</p></td>
    <td class=weekday><p class=weekday>M</p></td>
    <td class=weekday><p class=weekday>T</p></td>
    <td class=weekday><p class=weekday>W</p></td>
    <td class=weekday><p class=weekday>T</p></td>
    <td class=weekday><p class=weekday>F</p></td>
    <td class=saturday><p class=saturday>S</p></td>
</TR>

<TR>
<?
$cday = 1;
$sel_mon = sprintf("%02d",$month);
$query = "SELECT * FROM $write_table WHERE left(wr_link1,6) <= '$year$sel_mon'  and left(wr_link2,6) >= '$year$sel_mon'  ORDER BY wr_id ASC";
$result = sql_query($query);

// 내용을 보여주는 부분
while ($row = mysql_fetch_array($result)) {  // 제목글 뽑아서 링크 문자열 만들기..
 if( substr($row[wr_link1],0,6) <  $year.$sel_mon ) {
     $start_day =1;
     $start_day= (int)$start_day;
 } else {
     $start_day = substr($row[wr_link1],6,2);
     $start_day= (int)$start_day;
 }

 if( substr($row[wr_link2],0,6) >  $year.$sel_mon ) {
     $end_day = $lastday[$month];
     $end_day= (int)$end_day;
 } else {
     $end_day = substr($row[wr_link2],6,2);
     $end_day= (int)$end_day;
 }

  for ($i = $start_day ; $i <= $end_day;  $i++) {
    // $html_day[$i].= 은  문자를 덧붙이는 작업이다. 바로 . (쩜) 의 위력이다.
    $html_day[$i] = "1"; //"<p><a href='javascript:;' onclick=\"popup_schedule('./pop_schedule.php?bo_table=$bo_table&year=$year&month=$month&day=$i');\" class=writeday>"; //.</a>"."\n";
    // $html_day[$i].= "<p><a href='javascript:;' onclick=\"popup_schedule('./popup_schedule.php?bo_table=$bo_table&wr_id=$row[wr_id]');\" class=writeday>"; //.</a>"."\n";
    //$html_day[$i].= "<br><a href='?doc=bbs/gnuboard.php&bo_table=$bo_table&wr_id=$row[wr_id]'>".substr($row[wr_subject],0,18)."</a>"."\n";
    // substr로 끊으면 경우에 따라 지져분해 지므로..
   }
 }

// 달력의 틀을 보여주는 부분
// 여기부터 분석하면 됨

$temp = 7- (($lastday[$month]+$dayoftheweek)%7);
// $dayoftheweek; // 6 이다.
// $temp = 6 이다. 무슨 의미인가?

if ($temp == 7) $temp = 0;
     $lastcount = $lastday[$month]+$dayoftheweek + $temp;

// $lastcount = 42
// $lastcount 는 달력을 이루고 있는 전체 셀의 갯수이다.  2003년 11월은 날짜 30개와 빈칸 12개 다.
//
for ($iz = 1; $iz <= $lastcount; $iz++) { // 42번을 칠하게 된다.
    $bgcolor = "#ffffff";  // 쭉 흰색으로 칠하고
    $offset = $iz%7;
    if ($offset == 1) echo ("  <tr>\n"); // 주당 7개씩 한쎌씩을 쌓는다.
    if ($dayoftheweek < $iz  &&  $iz <= $lastday[$month]+$dayoftheweek)    {

      if ($b_year==$year && $b_mon==$month && $b_day==$cday) {
        $cstyle = 'today';
      } else {
        $cstyle = 'valid';
      }

      switch ($offset) {            // 요일에 따라 날짜의 색깔 결정
        case 1: $dstyle = 'sunday';
                break;
        case 0: $dstyle = 'saturday';
                break;
        default: $dstyle = 'weekday';
      }    
     // 전체 루프안에서 숫자가 들어가는 셀들만 해당됨
     // 즉 11월 달에서 1일부터 30 일까지만 해당
       $daytext = "$cday";   // $cday 는 숫자 예> 11월달은 1~ 30일 까지
       //$daytext 은 셀에 써질 날짜 숫자 넣을 공간
//       if ($iz%7 == 1) $daytext = "<font color=red>$daytext</font>"; // 일요일
//       if ($iz%7 == 0) $daytext = "<font color=blue>$daytext</font>"; // 토요일
    
       // 여기까지 숫자와 들어갈 내용에 대한 변수들의 세팅이 끝나고
       // 이제 여기 부터 직접 셀이 그려지면서 그 안에 내용이 들어 간다.

       echo ("     <td class=$cstyle>\n");
       if ($html_day[$cday]) {
         $f_date = $year.sprintf("%02d",$month).sprintf("%02d",$cday);        

        echo "<p>
<!--<a href=\"javascript:void(window.open('$g4[path]/pop_schedule.php?bo_table=$bo_table&year=$year&month=$month&day=$cday', '_blank', 'left=50, top=50, width=300, height=400, scrollbars=1'));\">-->
        <a href='$g4[bbs_path]/board.php?bo_table=$bo_table'>
        <b style=background-color:tomato;color:#ffffff;>$daytext</b></a></p>\n";
       }

       else { // 글쓰기 권한이 없으면 글쓰기 링크는 넣지 않고 그냥 숫자만 출력하기
         echo "<p class=$dstyle>$daytext</p>\n";
       }
//       echo $html_day[$cday];
       echo ("     </td>\n");  // 한칸을 마무리
      $cday++; // 날짜를 카운팅
    }
    // 11월에서 1일부터 30일에 해당되지 않으면 그냥 회색을 칠한다.
    else { echo ("     <td class=invalid> </td>\n"); }
   if (($iz%7) == 0) echo ("  </tr>\n");

} // 반복구문이 끝남
?>
                </table>
            </td>
      </table>
    </td>
    <td background="<?=$latest_skin_path?>/image/table_right.gif"></td>
  </tr>
  <tr>
    <td width="16" height="16"><img src="<?=$latest_skin_path?>/image/table_3.gif" width="16" height="16"></td>
    <td height="16" background="<?=$latest_skin_path?>/image/table_tail.gif"></td>
    <td width="16" height="16"><img src="<?=$latest_skin_path?>/image/table_4.gif" width="16" height="16"></td>
  </tr>
</table>
  • 복사

댓글 전체

재미있을꺼 같아서 테스트해 봤습니다.
그런데 이 최신글 달력 자체에 문제가 많더군요..;
lib/latest.lib.php 에서 불러내므로 그냥 쓰면 100% 오류가 나던데 뭐 그문제는 스킨문제니 알아서 하실테고 :)


*** 핵심 코드입니다. ***

latest.skin.php
=[ 58 line before ]============================
$dayoftheweek = date("w", mktime (0,0,0,$month,1,$year));
=[ 58 line after ] =============================
$dayoftheweek = date("w", mktime (0,0,0,$month,0,$year));
========================================

=[ 83 line before ]=============================
<td class=sunday><p class=sunday>일</p></td>
<td class=weekday><p class=weekday>월</p></td>
<td class=weekday><p class=weekday>화</p></td>
<td class=weekday><p class=weekday>수</p></td>
<td class=weekday><p class=weekday>목</p></td>
<td class=weekday><p class=weekday>금</p></td>
<td class=saturday><p class=saturday>토</p></td>
=[ 83 line after ] ==============================
<td class=weekday><p class=weekday>월</p></td>
<td class=weekday><p class=weekday>화</p></td>
<td class=weekday><p class=weekday>수</p></td>
<td class=weekday><p class=weekday>목</p></td>
<td class=weekday><p class=weekday>금</p></td>
<td class=saturday><p class=saturday>토</p></td>
<td class=sunday><p class=sunday>일</p></td>
=========================================

=[ 152 line before ]=============================
case 1: $dstyle = 'sunday';
break;
case 0: $dstyle = 'saturday';
break;
=[ 152 line after ] ==============================
case 0: $dstyle = 'sunday';
break;
case 6: $dstyle = 'saturday';
break;
==========================================
prosper님 감사합니다. 해보니까 되는군요^^


혹시 이 소스를 쓰실 분이 있을지도 몰라 원래의 팁을 찾아 남깁니다.

http://sir.co.kr/bbs/board.php?bo_table=g4_skin&wr_id=14725
링크가 원문인데 디자인 등을 많이 수정했습니다.

그리고 extend폴더에 따로 아래 소스를 schedule.lib.php란 이름으로 저장해야 합니다.


<?
if (!defined('_GNUBOARD_')) exit;
//======일정관리 메인추출=========
function latest_schedule($skin_dir='', $bo_table)
{
    global $config;
    global $g4;
    global $year, $month;

    // 스킨디렉토리값이 넘어왔다면
    if ($skin_dir) {
        $latest_skin_path = "./$g4[path]/skin/latest/$skin_dir";
    }

    $write_table = $g4[write_prefix] . $bo_table;
 
    ob_start();
    include "$latest_skin_path/latest.skin.php";
    $content = ob_get_contents();
    ob_end_clean();

    return $content;
}
?>


이렇게 한 다음 이 달력형 최근글을 출력하고 싶은 곳에 아래의 소스를 써줍니다.

<?=latest_schedule("schedule","delivery_schedule");?>

여기서 "schedule"은 본문에 올린 소스를 저장한 최근글 스킨명이고 "delivery_schedule"은 달력형 게시판명입니다. 이 달력형 게시판 스킨은 앞에 소개한 링크에서 아마도(?) 찾을 수 있을 겁니다.
© SIRSOFT
현재 페이지 제일 처음으로