function getEntriesWithPagingByPeriod($blogid, $period, $page, $count) { global $database, $folderURL, $suri; $cond = "AND published >= " . getTimeFromPeriod($period) . " AND published < " . getTimeFromPeriod(addPeriod($period)); $visibility = doesHaveOwnership() ? '' : 'AND e.visibility > 0 AND (c.visibility > 1 OR e.category = 0)'; $visibility .= doesHaveOwnership() && !Acl::check('group.editors') ? ' AND (e.userid = ' . getUserId() . ' OR e.visibility > 0)' : ''; $sql = "SELECT e.*, c.label AS categoryLabel \n\t\tFROM {$database['prefix']}Entries e \n\t\tLEFT JOIN {$database['prefix']}Categories c ON e.blogid = c.blogid AND e.category = c.id \n\t\tWHERE e.blogid = {$blogid} AND e.draft = 0 {$visibility} AND e.category >= 0 {$cond} \n\t\tORDER BY e.published DESC"; return Paging::fetch($sql, $page, $count, "{$folderURL}/{$suri['value']}"); }
function getEntriesWithPagingByPeriod($blogid, $period, $page, $count, $countItem = null) { $ctx = Model_Context::getInstance(); $pool = DBModel::getInstance(); $pool->init("Entries"); $pool->setAlias("Entries", "e"); $pool->setAlias("Categories", "c"); $pool->join("Categories", "left", array(array("e.blogid", "eq", "c.blogid"), array("e.category", "eq", "c.id"))); $pool->setQualifier("e.blogid", "eq", $blogid); $pool->setQualifier("e.category", ">=", 0); $pool->setQualifier("e.draft", "eq", 0); $pool->setQualifier("e.published", ">=", getTimeFromPeriod($period)); $pool->setQualifier("e.published", "<", getTimeFromPeriod(addPeriod($period))); if (!doesHaveOwnership()) { $pool->setQualifier("e.visibility", ">", 0); $pool->setQualifierSet(array("c.visibility", ">", 1), "OR", array("e.category", "eq", 0)); } if (doesHaveOwnership() && !Acl::check('group.editors')) { $pool->setQualifierSet(array("e.userid", "eq", getUserId()), "OR", array("e.visibility", ">", 0)); } $pool->setOrder("e.published", "DESC"); $pool->setProjection("e.*", "c.label AS categoryLabel"); return Paging::fetch($pool, $page, $count, $ctx->getProperty('uri.folder') . "/" . $ctx->getProperty('suri.value'), $countItem); }
function getCalendarView($calendar) { $context = Model_Context::getInstance(); $current = $calendar['year'] . $calendar['month']; $previous = addPeriod($current, -1); $next = addPeriod($current, 1); $firstWeekday = date('w', mktime(0, 0, 0, $calendar['month'], 1, $calendar['year'])); $lastDay = date('t', mktime(0, 0, 0, $calendar['month'], 1, $calendar['year'])); $today = $current == Timestamp::get('Ym') ? Timestamp::get('j') : null; $currentMonthStr = fireEvent('ViewCalendarHead', Timestamp::format('%Y/%m', getTimeFromPeriod($current))); ob_start(); ?> <table class="tt-calendar" cellpadding="0" cellspacing="1" style="width: 100%; table-layout: fixed"> <caption class="cal_month"> <a href="<?php echo $context->getProperty('uri.blog'); ?> /archive/<?php echo $previous; ?> " title="<?php echo _text('1개월 앞의 달력을 보여줍니다.'); ?> ">«</a> <a href="<?php echo $context->getProperty('uri.blog'); ?> /archive/<?php echo $current; ?> " title="<?php echo _text('현재 달의 달력을 보여줍니다.'); ?> "><?php echo $currentMonthStr; ?> </a> <a href="<?php echo $context->getProperty('uri.blog'); ?> /archive/<?php echo $next; ?> " title="<?php echo _text('1개월 뒤의 달력을 보여줍니다.'); ?> ">»</a> </caption> <thead> <tr> <th class="cal_week2"><?php echo fireEvent('ViewCalendarHeadWeekday', _text('일요일')); ?> </th> <th class="cal_week1"><?php echo fireEvent('ViewCalendarHeadWeekday', _text('월요일')); ?> </th> <th class="cal_week1"><?php echo fireEvent('ViewCalendarHeadWeekday', _text('화요일')); ?> </th> <th class="cal_week1"><?php echo fireEvent('ViewCalendarHeadWeekday', _text('수요일')); ?> </th> <th class="cal_week1"><?php echo fireEvent('ViewCalendarHeadWeekday', _text('목요일')); ?> </th> <th class="cal_week1"><?php echo fireEvent('ViewCalendarHeadWeekday', _text('금요일')); ?> </th> <th class="cal_week1"><?php echo fireEvent('ViewCalendarHeadWeekday', _text('토요일')); ?> </th> </tr> </thead> <tbody> <?php $day = 0; $totalDays = $firstWeekday + $lastDay; $lastWeek = ceil($totalDays / 7); for ($week = 0; $week < $lastWeek; $week++) { // 주중에 현재 날짜가 포함되어 있으면 주를 현재 주 class(tt-current-week)를 부여한다. if ($today + $firstWeekday > $week * 7 && $today + $firstWeekday <= ($week + 1) * 7) { echo ' <tr class="cal_week cal_current_week">' . CRLF; } else { echo ' <tr class="cal_week">' . CRLF; } for ($weekday = 0; $weekday < 7; $weekday++) { $day++; $dayString = isset($calendar['days'][$day]) ? '<a class="cal_click" href="' . $context->getProperty('uri.blog') . '/archive/' . $current . ($day > 9 ? $day : "0{$day}") . '">' . $day . '</a>' : $day; // 일요일, 평일, 토요일별로 class를 부여한다. switch ($weekday) { case 0: $className = " cal_day cal_day_sunday"; break; case 1: case 2: case 3: case 4: case 5: case 6: $className = " cal_day"; break; } // 오늘에 현재 class(tt-current-day)를 부여한다. $className .= $day == $today ? " cal_day4" : " cal_day3"; if ($week == 0) { if ($weekday < $firstWeekday) { $day--; // 달의 첫째날이 되기 전의 빈 칸. echo ' <td class="cal_day1"> </td>' . CRLF; } else { echo ' <td class="' . $className . '">' . $dayString . '</td>' . CRLF; } } else { if ($week == $lastWeek - 1) { if ($day <= $lastDay) { echo ' <td class="' . $className . '">' . $dayString . '</td>' . CRLF; } else { // 달의 마지막날을 넘어간 날짜 빈 칸. echo ' <td class="cal_day2"> </td>' . CRLF; } } else { echo ' <td class="' . $className . '">' . $dayString . '</td>' . CRLF; } } } echo ' </tr>' . CRLF; if ($day >= $lastDay) { break; } } ?> </tbody> </table> <?php $view = ob_get_contents(); ob_end_clean(); return $view; }
function getEntriesWithPagingByPeriod($blogid, $period, $page, $count, $countItem = null) { $ctx = Model_Context::getInstance(); $cond = "AND published >= " . getTimeFromPeriod($period) . " AND published < " . getTimeFromPeriod(addPeriod($period)); $visibility = doesHaveOwnership() ? '' : 'AND e.visibility > 0 AND (c.visibility > 1 OR e.category = 0)'; $visibility .= doesHaveOwnership() && !Acl::check('group.editors') ? ' AND (e.userid = ' . getUserId() . ' OR e.visibility > 0)' : ''; $sql = "SELECT e.*, c.label AS categoryLabel \n\t\tFROM " . $ctx->getProperty('database.prefix') . "Entries e \n\t\tLEFT JOIN " . $ctx->getProperty('database.prefix') . "Categories c ON e.blogid = c.blogid AND e.category = c.id \n\t\tWHERE e.blogid = {$blogid} AND e.draft = 0 {$visibility} AND e.category >= 0 {$cond} \n\t\tORDER BY e.published DESC"; return Paging::fetch($sql, $page, $count, $ctx->getProperty('uri.folder') . "/" . $ctx->getProperty('suri.value'), $countItem); }