public function init()
 {
     parent::init();
     // set a cookie with the last visit date
     if ($this->app->hasModule('SiteCookieModule')) {
         $now = new SwatDate();
         $cookie = $this->app->getModule('SiteCookieModule');
         $cookie->setCookie('last_visit_date', $now->getISO8601());
     }
 }
 public static function displayCalendarBody(SiteWebApplication $app, SwatDate $date)
 {
     if (isset($app->memcache)) {
         $cache_key = sprintf('PinholeCalendarGadget.%s.%s.%s', 'displayCalendarBody', $date->getISO8601(), $app->session->isLoggedIn() ? 'private' : 'public');
         $body = $app->memcache->getNs('photos', $cache_key);
         if ($body !== false) {
             echo $body;
             return;
         }
     }
     ob_start();
     $day_count = self::getPhotoCountPerDay($app, $date);
     echo '<table>';
     $wd = new SwatDate();
     $wd->setDate(1995, 1, 1);
     echo '<tr class="days-of-week">';
     for ($i = 1; $i <= 7; $i++) {
         echo '<td>' . $wd->formatLikeIntl('EEE') . '</td>';
         $wd->setDay($i + 1);
     }
     echo '</tr>';
     $locale = SwatI18NLocale::get();
     $start = -1 * $date->getDayOfWeek() + 1;
     $current_date = clone $date;
     for ($i = 0; $i <= 41; $i++) {
         $day = $i + $start;
         if ($i == 0) {
             echo '<tr>';
         } elseif ($i % 7 == 0) {
             echo '</tr><tr>';
         }
         if ($day > 0 && $day <= $date->getDaysInMonth()) {
             $current_date->setDay($day);
             if (array_key_exists($day, $day_count)) {
                 printf('<td class="has-photos">' . '<a href="%stag?date.date=%s" ' . 'title="%s %s">%s</a></td>', $app->config->pinhole->path, $current_date->formatLikeIntl('yyyy-MM-dd'), $locale->formatNumber($day_count[$day]), Pinhole::ngettext('Photo', 'Photos', $day_count[$day]), $day);
             } else {
                 echo '<td>' . $day . '</td>';
             }
         } else {
             echo '<td>&nbsp;</td>';
         }
     }
     echo '</tr></table>';
     $body = ob_get_clean();
     if (isset($app->memcache)) {
         $app->memcache->setNs('photos', $cache_key, $body);
     }
     echo $body;
 }