Exemplo n.º 1
0
 public static function getArchiveWotD($year, $month)
 {
     $query = "SELECT displayDate, lexicon, replace(displayDate, '-', '/') linkDate, DAYOFWEEK(displayDate) dayOfWeek, DAYOFMONTH(displayDate) dayOfMonth \n        FROM WordOfTheDay W\n        JOIN WordOfTheDayRel R ON W.id=R.wotdId\n        JOIN Definition D ON R.refId=D.id AND D.status=0 AND R.refType='Definition'\n        WHERE MONTH(displayDate)={$month} AND YEAR(displayDate)={$year}\n        ORDER BY displayDate";
     //TODO
     $dbRes = db_execute($query);
     $results = array();
     foreach ($dbRes as $row) {
         $wotda = new WotDArchive();
         $wotda->set($row);
         $results[] = $wotda;
     }
     return $results;
 }
Exemplo n.º 2
0
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;
}