function createCalendar($year, $month)
{
    $days = listDaysOfMonth($year, $month);
    $today = date('Y-m-d');
    $words = WordOfTheDay::getArchiveWotD($year, $month);
    $inv = array();
    foreach ($words as $k => $v) {
        $inv[$v->displayDate] = $k;
    }
    $new_words = array();
    foreach ($days as $day) {
        if ($day <= $today && array_key_exists($day, $inv)) {
            $new_words[] = $words[$inv[$day]];
        } else {
            $new_words[] = WotDArchive::setOnlyDate($day);
        }
    }
    return $new_words;
}
示例#2
0
$today = date('Y-m-d', time());
$timestamp = $date ? strtotime($date) : time();
$mysqlDate = date("Y-m-d", $timestamp);
if ($mysqlDate < WOTD_BIG_BANG || $mysqlDate > $today) {
    util_redirect(util_getWwwRoot() . 'cuvantul-zilei');
}
$wotd = WordOfTheDay::get_by_displayDate($mysqlDate);
if (!$wotd) {
    // We shouldn't have missing words since the Big Bang.
    if ($mysqlDate != $today) {
        util_redirect(util_getWwwRoot() . 'cuvantul-zilei');
    }
    WordOfTheDay::updateTodaysWord();
    $wotd = WordOfTheDay::get_by_displayDate($mysqlDate);
}
$archive = WordOfTheDay::getArchiveWotD(date('Y', $timestamp), date('m', $timestamp));
$defId = WordOfTheDayRel::getRefId($wotd->id);
$def = Definition::get_by_id($defId);
$searchResults = SearchResult::mapDefinitionArray(array($def));
setlocale(LC_ALL, 'ro_RO');
$roDate = strftime("%e %B %Y", $timestamp);
$pageTitle = sprintf("Cuvântul zilei: %s (%s)", $def->lexicon, $roDate);
if ($mysqlDate > WOTD_BIG_BANG) {
    smarty_assign('prevday', date('Y/m/d', $timestamp - 86400));
}
if ($mysqlDate < $today) {
    smarty_assign('nextday', date('Y/m/d', $timestamp + 86400));
}
smarty_assign('imageUrl', $wotd->getImageUrl());
smarty_assign('timestamp', $timestamp);
smarty_assign('archive', $archive);