Example #1
0
/**
 * Change the time format YYYYMMDDHHIISS to the user defined format
 *
 * @param string|int $str YYYYMMDDHHIISS format time values
 * @param string $format Time format of php date() function
 * @param bool $conversion Means whether to convert automatically according to the language
 * @return string
 */
function zdate($str, $format = 'Y-m-d H:i:s', $conversion = TRUE)
{
    // return null if no target time is specified
    if (!$str) {
        return;
    }
    // convert the date format according to the language
    if ($conversion == TRUE) {
        switch (Context::getLangType()) {
            case 'en':
            case 'es':
                if ($format == 'Y-m-d') {
                    $format = 'M d, Y';
                } elseif ($format == 'Y-m-d H:i:s') {
                    $format = 'M d, Y H:i:s';
                } elseif ($format == 'Y-m-d H:i') {
                    $format = 'M d, Y H:i';
                }
                break;
            case 'vi':
                if ($format == 'Y-m-d') {
                    $format = 'd-m-Y';
                } elseif ($format == 'Y-m-d H:i:s') {
                    $format = 'H:i:s d-m-Y';
                } elseif ($format == 'Y-m-d H:i') {
                    $format = 'H:i d-m-Y';
                }
                break;
        }
    }
    // If year value is less than 1970, handle it separately.
    if ((int) substr($str, 0, 4) < 1970) {
        $hour = (int) substr($str, 8, 2);
        $min = (int) substr($str, 10, 2);
        $sec = (int) substr($str, 12, 2);
        $year = (int) substr($str, 0, 4);
        $month = (int) substr($str, 4, 2);
        $day = (int) substr($str, 6, 2);
        // leading zero?
        $lz = create_function('$n', 'return ($n>9?"":"0").$n;');
        $trans = array('Y' => $year, 'y' => $lz($year % 100), 'm' => $lz($month), 'n' => $month, 'd' => $lz($day), 'j' => $day, 'G' => $hour, 'H' => $lz($hour), 'g' => $hour % 12, 'h' => $lz($hour % 12), 'i' => $lz($min), 's' => $lz($sec), 'M' => getMonthName($month), 'F' => getMonthName($month, FALSE));
        $string = strtr($format, $trans);
    } else {
        // if year value is greater than 1970, get unixtime by using ztime() for date() function's argument.
        $string = date($format, ztime($str));
    }
    // change day and am/pm for each language
    $unit_week = Context::getLang('unit_week');
    $unit_meridiem = Context::getLang('unit_meridiem');
    $string = str_replace(array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'), $unit_week, $string);
    $string = str_replace(array('am', 'pm', 'AM', 'PM'), $unit_meridiem, $string);
    return $string;
}
Example #2
0
 /**
  * Execute finding ID/Passoword
  * When clicking the link in the verification email, a method is called to change the old password and to authenticate it
  *
  * @return void|Object (void : success, Object : fail)
  */
 function procMemberAuthAccount()
 {
     $oMemberModel = getModel('member');
     // Test user_id and authkey
     $member_srl = Context::get('member_srl');
     $auth_key = Context::get('auth_key');
     if (!$member_srl || !$auth_key) {
         return $this->stop('msg_invalid_request');
     }
     // Test logs for finding password by user_id and authkey
     $args = new stdClass();
     $args->member_srl = $member_srl;
     $args->auth_key = $auth_key;
     $output = executeQuery('member.getAuthMail', $args);
     if (!$output->toBool() || $output->data->auth_key != $auth_key) {
         if (strlen($output->data->auth_key) !== strlen($auth_key)) {
             executeQuery('member.deleteAuthMail', $args);
         }
         return $this->stop('msg_invalid_auth_key');
     }
     if (ztime($output->data->regdate) < time() - 86400) {
         executeQuery('member.deleteAuthMail', $args);
         return $this->stop('msg_invalid_auth_key');
     }
     $args->password = $output->data->new_password;
     // If credentials are correct, change the password to a new one
     if ($output->data->is_register == 'Y') {
         $args->denied = 'N';
     } else {
         $args->password = $oMemberModel->hashPassword($args->password);
     }
     // Back up the value of $Output->data->is_register
     $is_register = $output->data->is_register;
     $output = executeQuery('member.updateMemberPassword', $args);
     if (!$output->toBool()) {
         return $this->stop($output->getMessage());
     }
     // Remove all values having the member_srl from authentication table
     executeQuery('member.deleteAuthMail', $args);
     $this->_clearMemberCache($args->member_srl);
     // Notify the result
     Context::set('is_register', $is_register);
     $this->setTemplatePath($this->module_path . 'tpl');
     $this->setTemplateFile('msg_success_authed');
 }
Example #3
0
/**
 * If the recent post within a day, output format of YmdHis is "min/hours ago from now". If not within a day, it return format string.
 *
 * @param string $date Time value in format of YYYYMMDDHHIISS
 * @param string $format If gap is within a day, returns this format.
 * @return string
 */
function getTimeGap($date, $format = 'Y.m.d')
{
    $gap = $_SERVER['REQUEST_TIME'] + zgap() - ztime($date);
    $lang_time_gap = Context::getLang('time_gap');
    if ($gap < 60) {
        $buff = sprintf($lang_time_gap['min'], (int) ($gap / 60) + 1);
    } elseif ($gap < 60 * 60) {
        $buff = sprintf($lang_time_gap['mins'], (int) ($gap / 60) + 1);
    } elseif ($gap < 60 * 60 * 2) {
        $buff = sprintf($lang_time_gap['hour'], (int) ($gap / 60 / 60) + 1);
    } elseif ($gap < 60 * 60 * 24) {
        $buff = sprintf($lang_time_gap['hours'], (int) ($gap / 60 / 60) + 1);
    } else {
        $buff = zdate($date, $format);
    }
    return $buff;
}
Example #4
0
 function getUpdateGM()
 {
     return gmdate('r', ztime($this->get('last_update')));
 }
 function getDate($date)
 {
     $time = strtotime($date);
     if ($time == -1) {
         $time = ztime(str_replace(array('-', 'T', ':'), '', $date));
     }
     return date('YmdHis', $time);
 }
Example #6
0
/**
 * If the recent post within a day, output format of YmdHis is "min/hours ago from now". If not within a day, it return format string.
 *
 * @param string $date Time value in format of YYYYMMDDHHIISS
 * @param string $format If gap is within a day, returns this format.
 * @return string
 */
function getTimeGap($date, $format = 'Y.m.d')
{
    $timestamp = ztime($date);
    $gap = RX_TIME - $timestamp;
    if ($gap < 60 * 60 * 24) {
        return Rhymix\Framework\DateTime::getRelativeTimestamp($gap >= 60 ? $timestamp : RX_TIME - 60);
    } else {
        return zdate($date, $format);
    }
}
 /**
  * 휴면 안내메일을 발송하는 메소드.
  */
 public function sendEmail($member_srl, $config = null, $resend = true, $use_transaction = true)
 {
     // 회원 오브젝트를 통째로 받은 경우 member_srl을 추출한다.
     if (is_object($member_srl) && isset($member_srl->member_srl)) {
         $member = $member_srl;
         $member_srl = $member_srl->member_srl;
     } else {
         $args = new stdClass();
         $args->member_srl = $member_srl;
         $member_query = executeQuery('member.getMemberInfoByMemberSrl', $args);
         if (!$member_query->toBool() || !$member_query->data) {
             return -41;
         }
         $member = is_object($member_query->data) ? $member_query->data : reset($member_query->data);
         if (!$member) {
             return -42;
         }
         $member_srl = $member->member_srl;
     }
     // 모듈 설정이 로딩되지 않은 경우 지금 로딩한다.
     if (!$config) {
         $config = $this->getConfig();
     }
     // 이미 발송한 경우, $resend = true가 아니라면 재발송하지 않는다.
     $args = new stdClass();
     $args->member_srl = $member_srl;
     $output = executeQuery('member_expire.getNotifiedDates', $args);
     if (!$output->toBool()) {
         return -43;
     }
     if (count($output->data) && !$resend) {
         return 2;
     }
     // 정리 예정일을 계산한다.
     $start_date = strtotime($config->auto_start) + zgap();
     $base_date = $member->last_login ? $member->last_login : $member->regdate;
     $base_date = $base_date ? ztime($base_date) : 0;
     $expire_date = $base_date + 86400 * $config->expire_threshold;
     if ($expire_date < $start_date) {
         $expire_date = $start_date;
     }
     $member->expire_date = date('YmdHis', $expire_date);
     // 매크로를 변환한다.
     $site_title = Context::getSiteTitle();
     $macros = array('{SITE_NAME}' => htmlspecialchars($site_title, ENT_QUOTES, 'UTF-8', false), '{USER_ID}' => htmlspecialchars($member->user_id, ENT_QUOTES, 'UTF-8', false), '{USER_NAME}' => htmlspecialchars($member->user_name, ENT_QUOTES, 'UTF-8', false), '{NICK_NAME}' => htmlspecialchars($member->nick_name, ENT_QUOTES, 'UTF-8', false), '{EMAIL}' => htmlspecialchars($member->email_address, ENT_QUOTES, 'UTF-8', false), '{LOGIN_DATE}' => $base_date ? date('Y년 n월 j일', $base_date) : '(로그인 기록 없음)', '{EXPIRE_DATE}' => date('Y년 n월 j일', $expire_date), '{TIME_LIMIT}' => $this->translateThreshold($config->expire_threshold), '{CLEAN_METHOD}' => $config->expire_method === 'delete' ? '삭제' : '별도의 저장공간으로 이동');
     // 메일을 작성하여 발송한다.
     $subject = htmlspecialchars_decode(str_replace(array_keys($macros), array_values($macros), $config->email_subject));
     $content = str_replace(array_keys($macros), array_values($macros), $config->email_content);
     $recipient_name = $member->user_name ? $member->user_name : ($member->nick_name ? $member->nick_name : 'member');
     static $sender_name = null;
     static $sender_email = null;
     if ($sender_name === null) {
         $member_config = getModel('module')->getModuleConfig('member');
         $sender_name = $member_config->webmaster_name ? $member_config->webmaster_name : ($site_title ? $site_title : 'webmaster');
         $sender_email = $member_config->webmaster_email;
     }
     $oMail = new Mail();
     $oMail->setTitle($subject);
     $oMail->setContent($content);
     $oMail->setSender($sender_name, $sender_email);
     $oMail->setReceiptor($recipient_name, $member->email_address);
     $oMail->send();
     // 트랜잭션을 시작한다.
     if ($use_transaction) {
         $this->oDB->begin();
     }
     // 발송한 메일을 기록한다.
     $output = executeQuery('member_expire.deleteNotifiedDate', $member);
     if (!$output->toBool()) {
         if ($use_transaction) {
             $this->oDB->rollback();
         }
         return -44;
     }
     $output = executeQuery('member_expire.insertNotifiedDate', $member);
     if (!$output->toBool()) {
         if ($use_transaction) {
             $this->oDB->rollback();
         }
         return -45;
     }
     // 트랜잭션을 커밋한다.
     if ($use_transaction) {
         $this->oDB->commit();
     }
     return 1;
 }
Example #8
0
 function getDateStr($format, $str)
 {
     if (strtotime($str) === -1 || strtotime($str) === false) {
         $type = substr($GLOBALS['_time_zone'], 0, 1);
         $hour = substr($GLOBALS['_time_zone'], 1, 2);
         $min = substr($GLOBALS['_time_zone'], 3, 2);
         $g = $hour * 60 * 60 + $min * 60;
         $t = ztime(str_replace(array('-', 'T', ':', '.', ' '), '', trim($str))) + $g;
         return date($format, $t);
     } else {
         return date($format, strtotime(trim($str)));
     }
 }
 function getChangesets($module_srl, $enddate = null, $limit = 10, $targets, $list_count = 0)
 {
     if (!$enddate) {
         $enddate = date("Ymd");
     }
     $args->enddate = date("Ymd", ztime($enddate) + 24 * 60 * 60);
     $args->startdate = date("Ymd", ztime($enddate) - 24 * 60 * 60 * $limit);
     $args->module_srl = $module_srl;
     if ($list_count) {
         $args->list_count = $list_count;
     }
     if (in_array('commit', $targets)) {
         $output = executeQueryArray("issuetracker.getChangesets", $args);
         if (!$output->toBool()) {
             return array();
         }
         if (!$output->data) {
             $output->data = array();
         }
         // message에 htmlspecialchars() 적용
         foreach ($output->data as $key => $changeset) {
             $changeset->message = $this->_linkXE(htmlspecialchars($changeset->message));
         }
     }
     if (in_array('issue_changed', $targets)) {
         $solvedHistory = array();
         $output2 = executeQueryArray("issuetracker.getHistories", $args);
         if (count($output2->data)) {
             foreach ($output2->data as $history) {
                 $hist = unserialize($history->history);
                 $h = array();
                 if (!is_array($hist)) {
                     continue;
                 }
                 $res = "";
                 $bFirst = true;
                 foreach ($hist as $key => $val) {
                     if ($bFirst) {
                         $bFirst = false;
                     } else {
                         $res .= "<br />";
                     }
                     if ($val[0]) {
                         $str = Context::getLang('history_format');
                     } else {
                         $str = Context::getLang('history_format_not_source');
                     }
                     $str = str_replace('[source]', $val[0], $str);
                     $str = str_replace('[target]', $val[1], $str);
                     $str = str_replace('[key]', Context::getLang($key), $str);
                     $res .= $str;
                 }
                 $obj = null;
                 $obj->date = $history->regdate;
                 $obj->type = "changed";
                 $obj->message = $res;
                 $obj->target_srl = $history->target_srl;
                 $obj->author = $history->nick_name;
                 $output->data[] = $obj;
             }
         }
     }
     if (in_array('issue_created', $targets)) {
         $output2 = executeQueryArray("issuetracker.getDocumentListForChangeset", $args);
         if (count($output2->data)) {
             foreach ($output2->data as $history) {
                 $obj = null;
                 $obj->date = $history->regdate;
                 $obj->type = "created";
                 $obj->author = $history->nick_name;
                 $obj->target_srl = $history->document_srl;
                 $output->data[] = $obj;
             }
         }
     }
     usort($output->data, _compare);
     return $output->data;
 }
 /**
  * @brief 위젯의 실행 부분
  * ./widgets/위젯/conf/info.xml에 선언한 extra_vars를 args로 받는다
  * 결과를 만든후 print가 아니라 return 해주어야 한다
  **/
 function proc($args)
 {
     // 인자 값 정리
     $graph_width = (int) $args->graph_width ? $args->graph_width : 150;
     $graph_height = (int) $args->graph_height ? $args->graph_height : 100;
     $day_range = (int) $args->day_range ? $args->day_range : 7;
     if ($day_range < 7) {
         $day_range = 7;
     }
     $bg_color = hexrgb($args->bg_color ? $args->bg_color : '#FFFFFF');
     $check_bg_color = hexrgb($args->check_bg_color ? $args->check_bg_color : '#F9F9F9');
     $grid_color = hexrgb($args->grid_color ? $args->grid_color : '#dbdbdb');
     $unique_line_color = hexrgb($args->unique_line_color ? $args->unique_line_color : '#BBBBBB');
     $unique_text_color = hexrgb($args->unique_text_color ? $args->unique_text_color : '#666666');
     $point_color = hexrgb($args->point_color ? $args->point_color : '#ed3027');
     // 시작일 부터 오늘까지 일단 배열 만들어 놓기
     $start_time = ztime(date("YmdHis")) - $day_range * 60 * 60 * 24;
     $end_time = time();
     $day_check_falg = 0;
     for ($i = $start_time; $i < $end_time; $i += 60 * 60 * 24) {
         $data[date("Ymd", $i + 60 * 60 * 24)] = 0;
         $day_check_falg++;
         if ($day_check_falg > $day_range) {
             break;
         }
     }
     unset($obj);
     // 현재부터 지난 $day_range동안의 카운터 로그를 가져옴
     $obj->e_regdate = date("Ymd");
     $obj->s_regdate = date("Ymd", ztime(date("YmdHis")) - $day_range * 60 * 60 * 24 + 1);
     $site_module_info = Context::get('site_module_info');
     if ($site_module_info->site_srl) {
         $obj->site_srl = $site_module_info->site_srl;
         $output = executeQuery('widgets.image_counter.getCounterSiteStatus', $obj);
     } else {
         $output = executeQuery('widgets.image_counter.getCounterStatus', $obj);
     }
     $site_srl = (int) $site_module_info->site_srl;
     // 결과가 있다면 loop를 돌면서 최고/최저값을 구하고 그래프를 그릴 준비
     $max_unique_visitor = 0;
     $min_unique_visitor = 99999999999;
     if (count($output->data)) {
         foreach ($output->data as $key => $val) {
             if ($max_unique_visitor < $val->unique_visitor) {
                 $max_unique_visitor = $val->unique_visitor;
             }
             if ($min_unique_visitor > $val->unique_visitor) {
                 $min_unique_visitor = $val->unique_visitor;
             }
             $data[$val->regdate] = $val;
         }
     }
     // 이미지를 그림 (이미지 위치는 ./files/cache/widget_cache/couter_graph.gif로 고정)
     if (!is_dir(_XE_PATH_ . 'files/cache/widget_cache/')) {
         FileHandler::makeDir(_XE_PATH_ . 'files/cache/widget_cache/');
     }
     $image_src = "files/cache/widget_cache/couter_graph." . $site_srl . ".gif";
     // 이미지 생성
     $image = imagecreate($graph_width, $graph_height);
     // 각 종류의 색상을 지정
     $gridLine = imagecolorallocate($image, $grid_color['red'], $grid_color['green'], $grid_color['blue']);
     $fillBack = imagecolorallocate($image, $bg_color['red'], $bg_color['green'], $bg_color['blue']);
     $checkFillBack = imagecolorallocate($image, $check_bg_color['red'], $check_bg_color['green'], $check_bg_color['blue']);
     $visitorLine = imagecolorallocate($image, $unique_line_color['red'], $unique_line_color['green'], $unique_line_color['blue']);
     $visitorText = imagecolorallocate($image, $unique_text_color['red'], $unique_text_color['green'], $unique_text_color['blue']);
     $pointColor = imagecolorallocate($image, $point_color['red'], $point_color['green'], $point_color['blue']);
     // 배경선 채우기
     imagefilledrectangle($image, 0, 0, $graph_width - 1, $graph_height - 1, $fillBack);
     // 가로선 그리기
     $y_gap = ($graph_height - 32) / 3;
     for ($i = 0; $i < 4; $i++) {
         imageline($image, 5, 5 + $i * $y_gap, $graph_width - 5, 5 + $i * $y_gap, $gridLine);
     }
     // 세로선 그리기
     $x_gap = ($graph_width - 30) / ($day_range - 1);
     for ($i = 0; $i < $day_range; $i++) {
         imageline($image, 15 + $i * $x_gap, 5, 15 + $i * $x_gap, $graph_height - 27, $gridLine);
     }
     // 체크 무늬 배경 칠하기
     for ($j = 0; $j < $day_range - 1; $j++) {
         for ($i = 0; $i < 3; $i++) {
             if (($j + $i) % 2 == 1) {
                 continue;
             }
             imagefilledrectangle($image, 15 + $j * $x_gap + 1, 5 + $i * $y_gap + 1, 15 + $j * $x_gap + $x_gap - 1, 5 + $i * $y_gap + $y_gap - 1, $checkFillBack);
         }
     }
     // 그래프 그리기
     $prev_x = 0;
     $prev_y = $graph_height - 45;
     $step = 0;
     // 선 그림
     foreach ($data as $date => $val) {
         // 그래프를 그리기 위한 좌표 구함
         $unique_visitor = $val->unique_visitor;
         if ($max_unique_visitor == 0) {
             $per = 0;
         } else {
             $per = $val->unique_visitor / $max_unique_visitor;
         }
         // x,y 좌표 구함
         $cur_x = (int) ($step * $x_gap);
         $cur_y = (int) ($graph_height - 45 - ($graph_height - 45) * $per);
         imageline($image, $prev_x + 15, $prev_y + 15, $cur_x + 15, $cur_y + 15, $visitorLine);
         $prev_x = $cur_x;
         $prev_y = $cur_y;
         $step++;
     }
     // 포인트 + 숫자 표시
     $prev_x = 0;
     $prev_y = $graph_height - 45;
     $step = 0;
     foreach ($data as $date => $val) {
         // 그래프를 그리기 위한 좌표 구함
         $unique_visitor = $val->unique_visitor;
         if ($max_unique_visitor == 0) {
             $per = 0;
         } else {
             $per = $val->unique_visitor / $max_unique_visitor;
         }
         // x,y 좌표 구함
         $cur_x = (int) ($step * $x_gap);
         $cur_y = (int) ($graph_height - 45 - ($graph_height - 45) * $per);
         imagefilledrectangle($image, $cur_x + 15 - 1, $cur_y + 15 - 1, $cur_x + 15 + 1, $cur_y + 15 + 1, $pointColor);
         for ($j = 0; $j < strlen($unique_visitor); $j++) {
             imageString($image, 1, $cur_x + 6 + $j * 4, $cur_y + 5 + ($step % 2 - 1) * 13 + 13, substr($unique_visitor, $j, 1), $visitorText);
         }
         $prev_x = $cur_x;
         $prev_y = $cur_y;
         imageString($image, 1, $cur_x + 15 - 1, $graph_height - 25, substr($date, 6, 2), $gridLine);
         $step++;
     }
     imageString($image, 1, $graph_width - 100, $graph_height - 15, date("Y-m-d H:i:s"), $gridLine);
     // 이미지 저장
     @imagegif($image, $image_src, 100);
     @chmod($image_src, 0644);
     // graph의 img 태그 값을 return
     return sprintf('<img src="%s%s" border="0" alt="counter" />', Context::getRequestUri(), $image_src);
 }
 function SendNotifyRequest($target, &$module_info, &$oDocument, &$oParent, $parentHomepage, &$oChild, $childHomepage)
 {
     $oReq = new HTTP_Request();
     $oReq->setURL($target);
     $oReq->setMethod("POST");
     $oReq->addHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
     $oReq->addPostData('mode', 'fb');
     $oReq->addPostData('url', getUrl('mid', $module_info->mid, 'act', '', 'module', ''));
     $oReq->addPostData('s_home_title', $module_info->browser_title);
     $oReq->addPostData('s_post_title', $oDocument->getTitleText());
     $oReq->addPostData('s_name', $oDocument->getNickName());
     $oReq->addPostData('s_url', $oDocument->getPermanentUrl());
     $oReq->addPostData('s_no', $oDocument->document_srl);
     $oReq->addPostData('r1_name', $oParent->getNickName());
     if ($oChild->get('parent_srl')) {
         $oReq->addPostData('r1_no', $oParent->comment_srl);
         $oReq->addPostData('r1_url', sprintf("%s#comment_%s", $oDocument->getPermanentUrl(), $oParent->comment_srl));
         $oReq->addPostData('r2_rno', $oParent->comment_srl);
     } else {
         $oReq->addPostData('r1_no', '-1');
         $oReq->addPostData('r1_url', $oParent->getPermanentUrl());
         $oReq->addPostData('r2_rno', '-1');
     }
     $oReq->addPostData('r1_pno', $oDocument->document_srl);
     $oReq->addPostData('r1_rno', '0');
     $oReq->addPostData('r1_homepage', $parentHomepage);
     $oReq->addPostData('r1_regdate', ztime($oParent->get('regdate')));
     $oReq->addPostData('r2_name', $oChild->getNickName());
     $oReq->addPostData('r2_no', $oChild->comment_srl);
     $oReq->addPostData('r2_pno', $oDocument->document_srl);
     $oReq->addPostData('r2_homepage', $childHomepage);
     $oReq->addPostData('r2_regdate', ztime($oChild->get('regdate')));
     $oReq->addPostData('r2_url', sprintf("%s#comment_%s", $oDocument->getPermanentUrl(), $oChild->comment_srl));
     if ($oChild->get('parent_srl')) {
         $oReq->addPostData('r1_body', strip_tags($oParent->get('content')));
     } else {
         $oReq->addPostData('r1_body', $oParent->getContentText(250));
     }
     $oReq->addPostData('r2_body', strip_tags($oChild->get('content')));
     $oReq->sendRequest(false);
     $code = $oReq->getResponseCode();
     return $code;
 }
Example #12
0
 /**
  * @brief 위젯의 실행 부분
  *
  * ./widgets/위젯/conf/info.xml 에 선언한 extra_vars를 args로 받는다
  * 결과를 만든후 print가 아니라 return 해주어야 한다
  **/
 function proc($args)
 {
     $oModuleModel =& getModel('module');
     // 대상 모듈 (mid_list는 기존 위젯의 호환을 위해서 처리하는 루틴을 유지. module_srl로 위젯에서 변경)
     if ($args->mid_list) {
         $tmp_mid = explode(",", $args->mid_list);
         $args->mid = $tmp_mid[0];
     }
     if ($args->mid) {
         $args->srl = $oModuleModel->getModuleSrlByMid($args->mid);
     }
     $obj->module_srl = $args->srl;
     // 선택된 모듈이 없으면 실행 취소
     if (!$obj->module_srl) {
         return Context::getLang('msg_not_founded');
     }
     // 모듈의 정보를 구함
     $module_info = $oModuleModel->getModuleInfoByModuleSrl($obj->module_srl);
     if (Context::get('search_target') == 'regdate') {
         $regdate = Context::get('search_keyword');
         if ($regdate) {
             $obj->regdate = zdate($regdate, 'Ym');
         }
     }
     if (!$obj->regdate) {
         $obj->regdate = zdate(date('YmdHis'), 'Ym');
     }
     // document 모듈의 model 객체를 받아서 getDailyArchivedList() method를 실행
     $oDocumentModel =& getModel('document');
     $output = $oDocumentModel->getDailyArchivedList($obj);
     // 위젯 자체적으로 설정한 변수들을 체크
     $title = $args->title;
     // 템플릿 파일에서 사용할 변수들을 세팅
     $widget_info->cur_date = $obj->regdate;
     $widget_info->today_str = sprintf('%4d%s %2d%s', zdate($obj->regdate, 'Y'), Context::getLang('unit_year'), zdate($obj->regdate, 'm'), Context::getLang('unit_month'));
     $widget_info->last_day = date('t', ztime($obj->regdate));
     $widget_info->start_week = date('w', ztime($obj->regdate));
     $widget_info->prev_month = date('Ym', mktime(1, 0, 0, zdate($obj->regdate, 'm'), 1, zdate($obj->regdate, 'Y')) - 60 * 60 * 24);
     $widget_info->prev_year = date('Y', mktime(1, 0, 0, 1, 1, zdate($obj->regdate, 'Y')) - 60 * 60 * 24);
     $widget_info->next_month = date('Ym', mktime(1, 0, 0, zdate($obj->regdate, 'm'), $widget_info->last_day, zdate($obj->regdate, 'Y')) + 60 * 60 * 24);
     $widget_info->next_year = date('Y', mktime(1, 0, 0, 12, $widget_info->last_day, zdate($obj->regdate, 'Y')) + 60 * 60 * 24);
     $widget_info->title = $title;
     if (count($output->data)) {
         foreach ($output->data as $key => $val) {
             $widget_info->calendar[$val->month] = $val->count;
         }
     }
     if ($module_info->site_srl) {
         $site_module_info = Context::get('site_module_info');
         if ($site_module_info->site_srl == $module_info->site_srl) {
             $widget_info->domain = $site_module_info->domain;
         } else {
             $site_info = $oModuleModel->getSiteInfo($module_info->site_srl);
             $widget_info->domain = $site_info->domain;
         }
     } else {
         $widget_info->domain = Context::getDefaultUrl();
     }
     $widget_info->module_info = $module_info;
     $widget_info->mid = $module_info->mid;
     Context::set('widget_info', $widget_info);
     // 템플릿의 스킨 경로를 지정 (skin, colorset에 따른 값을 설정)
     $tpl_path = sprintf('%sskins/%s', $this->widget_path, $args->skin);
     Context::set('colorset', $args->colorset);
     // 템플릿 파일을 지정
     $tpl_file = 'calendar';
     // 템플릿 컴파일
     $oTemplate =& TemplateHandler::getInstance();
     return $oTemplate->compile($tpl_path, $tpl_file);
 }
Example #13
0
/**
 * @brief YYYYMMDDHHIISS 형식의 시간값을 원하는 시간 포맷으로 변형
 * @param string|int str YYYYMMDDHHIISS 형식의 시간 값
 * @param string format php date()함수의 시간 포맷
 * @param bool conversion 언어에 따라 날짜 포맷의 자동변환 여부
 * @return string
 **/
function zdate($str, $format = 'Y-m-d H:i:s', $conversion = true)
{
    // 대상 시간이 없으면 null return
    if (!$str) {
        return;
    }
    // 언어권에 따라서 지정된 날짜 포맷을 변경
    if ($conversion == true) {
        switch (Context::getLangType()) {
            case 'en':
            case 'es':
                if ($format == 'Y-m-d') {
                    $format = 'M d, Y';
                } elseif ($format == 'Y-m-d H:i:s') {
                    $format = 'M d, Y H:i:s';
                } elseif ($format == 'Y-m-d H:i') {
                    $format = 'M d, Y H:i';
                }
                break;
        }
    }
    // 년도가 1970년 이전이면 별도 처리
    if ((int) substr($str, 0, 4) < 1970) {
        $hour = (int) substr($str, 8, 2);
        $min = (int) substr($str, 10, 2);
        $sec = (int) substr($str, 12, 2);
        $year = (int) substr($str, 0, 4);
        $month = (int) substr($str, 4, 2);
        $day = (int) substr($str, 6, 2);
        $string = str_replace(array('Y', 'm', 'd', 'H', 'h', 'i', 's', 'a', 'M', 'F'), array($year, $month, $day, $hour, $hour / 12, $min, $sec, $hour <= 12 ? 'am' : 'pm', getMonthName($month), getMonthName($month, false)), $format);
    } else {
        // 1970년 이후라면 ztime()함수로 unixtime을 구하고 date함수로 처리
        $string = date($format, ztime($str));
    }
    // 요일, am/pm을 각 언어에 맞게 변경
    $unit_week = Context::getLang('unit_week');
    $unit_meridiem = Context::getLang('unit_meridiem');
    $string = str_replace(array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'), $unit_week, $string);
    $string = str_replace(array('am', 'pm', 'AM', 'PM'), $unit_meridiem, $string);
    return $string;
}