protected function displayContent() { $conversations = $this->getActiveConversations(); if (count($conversations) > 0) { // get last visited date based on cookie value if ($this->app->hasModule('SiteCookieModule')) { $cookie = $this->app->getModule('SiteCookieModule'); try { if (isset($cookie->last_visit_date)) { $last_visit_date = new SwatDate($cookie->last_visit_date); } else { $last_visit_date = new SwatDate(); } } catch (SiteCookieException $e) { $last_visit_date = new SwatDate(); } } else { $last_visit_date = new SwatDate(); } echo '<ul>'; $locale = SwatI18NLocale::get(); $class_name = SwatDBClassMap::get('BlorgPost'); foreach ($conversations as $conversation) { $post = new $class_name($conversation); $last_comment_date = new SwatDate($conversation->last_comment_date); $last_comment_date->setTZById('UTC'); $li_tag = new SwatHtmlTag('li'); // is last comment is later than last visit date, mark as new if (SwatDate::compare($last_comment_date, $last_visit_date) > 0) { $li_tag->class = 'new'; } $li_tag->open(); $anchor_tag = new SwatHtmlTag('a'); $anchor_tag->href = $this->getPostRelativeUri($post); $anchor_tag->setContent($post->getTitle()); $span_tag = new SwatHtmlTag('span'); $span_tag->setContent(sprintf(Blorg::ngettext('(%s comment)', '(%s comments)', $post->getVisibleCommentCount()), $locale->formatNumber($post->getVisibleCommentCount()))); $anchor_tag->display(); echo ' '; $span_tag->display(); $li_tag->close(); } echo '</ul>'; } }
protected function setPhotoDateByMetaData($meta_data) { $now = new SwatDate(); $date_fields = array('createdate', 'datetimeoriginal'); foreach ($date_fields as $field) { if (isset($meta_data[$field])) { $photo_date = $this->parseMetaDataDate($meta_data[$field]->value); if ($photo_date !== null && $photo_date->before($now)) { $this->photo_date = $photo_date; break; } } } if ($this->photo_date !== null) { if ($this->camera_time_zone !== null) { $this->photo_date->setTZById($this->camera_time_zone); } $this->photo_date->toUTC(); } }
protected function setPhotoValues() { $values = $this->getUIValues(); // turns the date back into UTC $photo_date = new SwatDate($values['photo_date']); $photo_date->setTZById($this->photo->photo_time_zone); $photo_date->toUTC(); $this->photo->title = $values['title']; $this->photo->description = $values['description']; $this->photo->photo_date = $photo_date; $this->photo->private = $values['private']; $this->photo->for_sale = $values['for_sale']; $this->photo->photo_time_zone = $values['photo_time_zone']; $this->photo->setStatus($values['status']); if ($this->ui->getWidget('comment_status_field')->visible) { $this->photo->comment_status = $values['comment_status']; } if ($this->photo->photo_time_zone === null) { $this->photo->photo_time_zone = $this->app->default_time_zone->getName(); } }