Example #1
0
function getCalendar($blogid, $period)
{
    global $database;
    $calendar = array('days' => array());
    if ($period === true || !checkPeriod($period)) {
        $period = Timestamp::getYearMonth();
    }
    $calendar['period'] = $period;
    $calendar['year'] = substr($period, 0, 4);
    $calendar['month'] = substr($period, 4, 2);
    $visibility = doesHaveOwnership() ? '' : 'AND e.visibility > 0' . getPrivateCategoryExclusionQuery($blogid);
    switch (POD::dbms()) {
        case 'Cubrid':
            $result = POD::queryAllWithDBCache("SELECT DISTINCT TO_CHAR(to_timestamp('09:00:00 AM 01/01/1970')+e.published, 'DD')\n\t\t\t\tFROM {$database['prefix']}Entries e\n\t\t\t\tWHERE e.blogid = {$blogid} AND e.draft = 0 {$visibility} AND e.category >= 0 AND\n\t\t\t\t\tTO_CHAR(to_timestamp('09:00:00 AM 01/01/1970')+e.published, 'YYYY') = '{$calendar['year']}' AND\n\t\t\t\t\tTO_CHAR(to_timestamp('09:00:00 AM 01/01/1970')+e.published, 'MM') = '{$calendar['month']}'", 'entry');
            break;
        case 'MySQL':
        case 'MySQLi':
        case 'PostgreSQL':
        default:
            $result = POD::queryAllWithDBCache("SELECT DISTINCT DAYOFMONTH(FROM_UNIXTIME(e.published)) \n\t\t\t\tFROM {$database['prefix']}Entries e\n\t\t\t\tWHERE e.blogid = {$blogid} AND e.draft = 0 {$visibility} AND e.category >= 0 AND YEAR(FROM_UNIXTIME(e.published)) = {$calendar['year']} AND MONTH(FROM_UNIXTIME(e.published)) = {$calendar['month']}", 'entry');
            break;
    }
    if ($result) {
        foreach ($result as $dayArray) {
            list($day) = $dayArray;
            array_push($calendar['days'], $day);
        }
    }
    $calendar['days'] = array_flip($calendar['days']);
    return $calendar;
}
Example #2
0
function getCalendar($blogid, $period)
{
    global $database;
    $skinSetting = Setting::getSkinSettings($blogid);
    $pool = DBModel::getInstance();
    $pool->init("Entries");
    $pool->setAlias("Entries", "e");
    $pool->setQualifier("e.blogid", "eq", $blogid);
    $pool->setQualifier("e.draft", "eq", 0);
    $pool->setQualifier("e.category", ">=", 0);
    if (!doesHaveOwnership()) {
        $pool->setQualifier("e.visibility", ">", 0);
        $pool = getPrivateCategoryExclusionQualifier($pool, $blogid);
    }
    $calendar = array('days' => array());
    if ($period === true || !checkPeriod($period)) {
        $period = Timestamp::getYearMonth();
    }
    $calendar['period'] = $period;
    $calendar['year'] = substr($period, 0, 4);
    $calendar['month'] = substr($period, 4, 2);
    switch (POD::dbms()) {
        case 'Cubrid':
            $pool->setQualifier("TO_CHAR(to_timestamp('09:00:00 AM 01/01/1970')+e.published, 'YYYY')", "eq", $calendar['year'], true);
            $pool->setQualifier("TO_CHAR(to_timestamp('09:00:00 AM 01/01/1970')+e.published, 'MM')", "eq", $calendar['month'], true);
            $result = $pool->getAll("TO_CHAR(to_timestamp('09:00:00 AM 01/01/1970')+e.published, 'DD')", array('filter' => 'distinct', 'usedbcache' => true, 'cacheprefix' => 'entry'));
            break;
        case 'SQLite3':
            $pool->setQualifier("strftime('%Y',e.published,'unixepoch')", "eq", $calendar['year'], true);
            $pool->setQualifier("strftime('%m',e.published,'unixepoch')", "eq", $calendar['month'], true);
            $result = $pool->getAll("strftime('%d',e.published,'unixepoch')", array('filter' => 'distinct', 'usedbcache' => true, 'cacheprefix' => 'entry'));
            break;
        case 'MySQL':
        case 'MySQLi':
        case 'PostgreSQL':
        default:
            $pool->setQualifier("YEAR(FROM_UNIXTIME(e.published))", "eq", $calendar['year'], true);
            $pool->setQualifier("MONTH(FROM_UNIXTIME(e.published))", "eq", $calendar['month'], true);
            $result = $pool->getAll("DAYOFMONTH(FROM_UNIXTIME(e.published))", array('filter' => 'distinct', 'usedbcache' => true, 'cacheprefix' => 'entry'));
            break;
    }
    if ($result) {
        foreach ($result as $dayArray) {
            list($day) = $dayArray;
            array_push($calendar['days'], $day);
        }
    }
    $calendar['days'] = array_flip($calendar['days']);
    return $calendar;
}
 function flushEntry($entryId = null)
 {
     global $database;
     if (empty($entryId)) {
         $entryId = '';
     } else {
         $entryId = intval($entryId);
     }
     $Entries = POD::queryColumn("SELECT name\n\t\t\tFROM {$database['prefix']}PageCacheLog\n\t\t\tWHERE blogid = " . getBlogId() . "\n\t\t\tAND (name like 'entry-" . $entryId . "-%' OR name like '%RSS-" . $entryId . "' OR name like '%ATOM-" . $entryId . "')");
     if (!empty($Entries)) {
         CacheControl::purgeItems($Entries);
     }
     if (!empty($entryId)) {
         $entry = POD::queryRow("SELECT userid, category, published FROM {$database['prefix']}Entries\n\t\t\t\tWHERE blogid = " . getBlogId() . " AND id = {$entryId}");
         if (!empty($entry)) {
             $entry['period'] = Timestamp::getYearMonth($entry['published']);
             CacheControl::flushAuthor($entry['userid']);
             CacheControl::flushCategory($entry['category']);
             CacheControl::flushArchive($entry['period']);
             CacheControl::flushDBCache('entry');
         }
     } else {
         CacheControl::flushAuthor();
         CacheControl::flushCategory();
         CacheControl::flushDBCache('entry');
     }
     return true;
 }
Example #4
0
<?php

/// Copyright (c) 2004-2012, Needlworks  / Tatter Network Foundation
/// All rights reserved. Licensed under the GPL.
/// See the GNU General Public License for more details. (/documents/LICENSE, /documents/COPYRIGHT)
require ROOT . '/library/preprocessor.php';
if (!empty($suri['id'])) {
    $period = $suri['id'];
} else {
    $period = Timestamp::getYearMonth();
}
fireEvent('OBStart');
require ROOT . '/interface/common/blog/begin.php';
if ($skinSetting['showListOnArchive'] != 0) {
    $listWithPaging = getEntryListWithPagingByPeriod($blogid, $period, $suri['page'], $blog['entriesOnList']);
    $list = array('title' => getPeriodLabel($period), 'items' => $listWithPaging[0], 'count' => $listWithPaging[1]['total']);
    $paging = $listWithPaging[1];
    if ($skinSetting['showListOnArchive'] == 1) {
        $skinSetting['showListWithTotalEntries'] = true;
    }
    $listFeedURL = 'archive/' . $period;
    require ROOT . '/interface/common/blog/list.php';
}
$entries = array();
if ($skinSetting['showListOnArchive'] != 2) {
    list($entries, $paging) = getEntriesWithPagingByPeriod($blogid, $period, $suri['page'], $skinSetting['showListOnArchive'] == 3 ? $blog['entriesOnPage'] : $blog['entriesOnList']);
    require ROOT . '/interface/common/blog/entries.php';
}
require ROOT . '/interface/common/blog/end.php';
fireEvent('OBEnd');
		function getCalendarView($period = null) {
			global $service, $database, $db;

			if ((empty($period) === true) || !TimePeriod::checkPeriod($period))
				$period = Timestamp::getYearMonth();
	        $calendar = array('days' => array());
			$calendar['period'] = $period;
			$calendar['year'] = substr($period, 0, 4);
			$calendar['month'] = substr($period, 4, 2);
			if ($db->query("SELECT DISTINCT DAYOFMONTH(FROM_UNIXTIME(written)) FROM {$database['prefix']}FeedItems WHERE YEAR(FROM_UNIXTIME(written)) = {$calendar['year']} AND MONTH(FROM_UNIXTIME(written)) = {$calendar['month']}")) {
				while (list($day) = $db->fetchArray())
						array_push($calendar['days'], $day);
			}
			$calendar['days'] = array_flip($calendar['days']);

			$current = $calendar['year'] . $calendar['month'];
			$previous = TimePeriod::addPeriod($current, - 1);
			$next = TimePeriod::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 = Timestamp::format('%Y.%m', TimePeriod::getTimeFromPeriod($current));

			define('CRLF', "\r\n");
			ob_start();
		?>
		<table class="calendar" cellpadding="0" cellspacing="1" style="width: 100%; table-layout: fixed">
			<caption class="cal_month">
				<?php echo $currentMonthStr;?>
			</caption>
			<thead>
				<tr>
					<th class="cal_week2"><?php echo _t('일요일');?></th>
					<th class="cal_week1"><?php echo _t('월요일');?></th>
					<th class="cal_week1"><?php echo _t('화요일');?></th>
					<th class="cal_week1"><?php echo _t('수요일');?></th>
					<th class="cal_week1"><?php echo _t('목요일');?></th>
					<th class="cal_week1"><?php echo _t('금요일');?></th>
					<th class="cal_week1"><?php echo _t('토요일');?></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="'.$service['path'].'/?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">&nbsp;</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">&nbsp;</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;
		}