protected function displayContent()
 {
     $comments = $this->getComments();
     if (count($comments) == 0) {
         echo Pinhole::_('No comments have been made.');
     } else {
         $locale = SwatI18NLocale::get();
         echo '<ul>';
         foreach ($comments as $comment) {
             echo '<li>';
             $date = new SwatDate($comment->createdate);
             $date->convertTZById($this->app->config->date->time_zone);
             $date_diff = $date->getHumanReadableDateDiff();
             $author = $comment->photographer === null ? $comment->fullname : $comment->photographer->fullname;
             $a_tag = new SwatHtmlTag('a');
             $a_tag->href = sprintf('photo/%s#comment%s', $comment->getInternalValue('photo'), $comment->id);
             $a_tag->setContent(sprintf('%s ago by %s', $date_diff, $author));
             $a_tag->display();
             $div_tag = new SwatHtmlTag('div');
             $div_tag->setContent(SwatString::ellipsizeRight(SwatString::condense($comment->bodytext), 100));
             $div_tag->display();
             echo '</li>';
         }
         echo '</ul>';
     }
 }
 protected function displayContent()
 {
     echo '<div id="' . $this->calendar_id . '" ' . 'class="pinhole-calendar-gadget-container">';
     $date = new SwatDate();
     $date->convertTZById($this->app->config->date->time_zone);
     $date->setDay(1);
     $date->setTime(0, 0, 0);
     echo '<div class="pinhole-calendar-gadget-head">';
     echo '<a class="pinhole-calendar-gadget-prev" ' . 'title="' . Pinhole::_('Previous Month') . '" ' . 'id="' . $this->calendar_id . '_prev" href="#">«</a>';
     echo '<div id="' . $this->calendar_id . '_month" class="pinhole-calendar-month">';
     echo self::displayCalendarMonth($this->app, $date);
     echo '</div>';
     echo '<a class="pinhole-calendar-gadget-next" ' . 'title="' . Pinhole::_('Next Month') . '" ' . 'id="' . $this->calendar_id . '_next" href="#">»</a>';
     echo '</div>';
     echo '<div id="' . $this->calendar_id . '_body" class="pinhole-calendar-body">';
     echo self::displayCalendarBody($this->app, $date);
     echo '</div>';
     echo '</div>';
     Swat::displayInlineJavaScript($this->getInlineJavaScript($date));
 }
 protected function displayByDateAdded(PinholeTagList $tag_list)
 {
     $now = new SwatDate();
     $now->convertTZById($this->app->config->date->time_zone);
     $store = new SwatTableStore();
     foreach ($tag_list as $tag) {
         $ds = new SwatDetailsStore();
         $ds->tag = $tag;
         $tag_date = $tag->getDataObject()->first_modified;
         $tag_date->convertTZById($this->app->config->date->time_zone);
         $days_past = $now->diff($tag_date)->days;
         if ($days_past <= 1) {
             $ds->date_part = Pinhole::_('Today');
         } elseif ($days_past <= $now->getDayOfWeek() + 1) {
             $ds->date_part = Pinhole::_('This Week');
         } elseif ($days_past <= $now->getDay()) {
             $ds->date_part = Pinhole::_('This Month');
         } elseif ($days_past <= $now->getDayOfYear()) {
             $ds->date_part = Pinhole::_('This Year');
         } else {
             $ds->date_part = sprintf(Pinhole::_('%s'), $tag_date->getYear());
         }
         $store->add($ds);
     }
     $ul_tag = new SwatHtmlTag('ul');
     $li_tag = new SwatHtmlTag('li');
     $ul_tag->open();
     $part = null;
     foreach ($store as $ds) {
         if ($part !== $ds->date_part) {
             if ($part !== null) {
                 $li_tag->close();
             }
             $li_tag->open();
             $h2_tag = new SwatHtmlTag('h2');
             $h2_tag->class = 'pinhole-tag-entity';
             $h2_tag->setContent($ds->date_part);
             $h2_tag->display();
         } elseif ($part !== null) {
             echo ', ';
         }
         $this->displayTag($ds->tag);
         $part = $ds->date_part;
     }
     $li_tag->close();
     $ul_tag->close();
 }
    protected function buildPhotoDate(SwatDetailsView $view)
    {
        $photo_date = $view->getField('photo_date');
        if ($this->photo->photo_date === null) {
            $photo_date->visible = false;
        } else {
            $date = new SwatDate($this->photo->photo_date);
            $date->convertTZById($this->photo->photo_time_zone);
            $date_links = $photo_date->getRenderer('date_links');
            $date_links->content_type = 'text/xml';
            $date_links->text = sprintf(Pinhole::_('
				(view photos taken on the same: ' . '<a href="tag?date.date=%1$s-%2$s-%3$s">day</a>, ' . '<a href="tag?date.week=%1$s-%2$s-%3$s">week</a>, ' . '<a href="tag?date.month=%2$s/date.year=%1$s">month</a>, ' . '<a href="tag?date.year=%1$s">year</a>)'), $date->formatLikeIntl('yyyy'), $date->formatLikeIntl('MM'), $date->formatLikeIntl('dd'));
        }
    }
 protected function getPhotoTableStore()
 {
     if (count($this->tag_list) == 0) {
         $tag_path = '';
     } else {
         $tag_path = '?' . $this->tag_list->__toString();
     }
     $photos = $this->tag_list->getPhotos('thumbnail');
     // throw exception or else tags that have only private photos would be
     // exposed.
     if (count($this->tag_list->getByType('PinholeTag')) > 0 && count($photos) == 0) {
         throw new SiteNotFoundException(sprintf('There are no photos in the current tag intersection: %s.', (string) $this->tag_list));
     }
     $store = new SwatTableStore();
     foreach ($photos as $photo) {
         $ds = new SwatDetailsStore();
         $ds->root_path = $this->app->config->pinhole->path;
         $ds->path = $photo->id . $tag_path;
         $ds->photo = $photo;
         $ds->display_title = $this->app->config->pinhole->browser_index_titles;
         $now = new SwatDate();
         $now->convertTZById($this->app->config->date->time_zone);
         $now->setTime(0, 0, 0);
         if (count($this->tag_list) == 0) {
             $publish_date = $photo->publish_date;
             $publish_date->convertTZbyID($this->app->config->date->time_zone);
             $days_past = $now->diff($publish_date)->days;
             if ($days_past <= 1) {
                 $period = Pinhole::_('Today');
             } elseif ($days_past <= 2) {
                 $period = Pinhole::_('Yesterday');
             } elseif ($days_past <= 7) {
                 $period = sprintf(Pinhole::_('%d Days Ago'), floor($days_past));
             } else {
                 $period = $publish_date->formatLikeIntl(SwatDate::DF_DATE_LONG);
             }
             $ds->publish_period = sprintf(Pinhole::_('Added %s'), $period);
         } else {
             $ds->publish_period = null;
         }
         $store->add($ds);
     }
     return $store;
 }