Exemplo n.º 1
0
 protected function showEvent(Notice $stored, HTMLOutputter $out, Profile $scoped = null)
 {
     $profile = $stored->getProfile();
     $event = Happening::fromNotice($stored);
     if (!$event instanceof Happening) {
         // TRANS: Content for a deleted RSVP list item (RSVP stands for "please respond").
         $out->element('p', null, _m('Deleted.'));
         return;
     }
     $out->elementStart('div', 'h-event');
     $out->elementStart('h3', 'p-summary p-name');
     try {
         $out->element('a', array('href' => $event->getUrl()), $event->title);
     } catch (InvalidUrlException $e) {
         $out->text($event->title);
     }
     $out->elementEnd('h3');
     $now = new DateTime();
     $startDate = new DateTime($event->start_time);
     $endDate = new DateTime($event->end_time);
     $userTz = new DateTimeZone(common_timezone());
     // Localize the time for the observer
     $now->setTimeZone($userTz);
     $startDate->setTimezone($userTz);
     $endDate->setTimezone($userTz);
     $thisYear = $now->format('Y');
     $startYear = $startDate->format('Y');
     $endYear = $endDate->format('Y');
     $dateFmt = 'D, F j, ';
     // e.g.: Mon, Aug 31
     if ($startYear != $thisYear || $endYear != $thisYear) {
         $dateFmt .= 'Y,';
         // append year if we need to think about years
     }
     $startDateStr = $startDate->format($dateFmt);
     $endDateStr = $endDate->format($dateFmt);
     $timeFmt = 'g:ia';
     $startTimeStr = $startDate->format($timeFmt);
     $endTimeStr = $endDate->format("{$timeFmt} (T)");
     $out->elementStart('div', 'event-times');
     // VEVENT/EVENT-TIMES IN
     // TRANS: Field label for event description.
     $out->element('strong', null, _m('Time:'));
     $out->element('time', array('class' => 'dt-start', 'datetime' => common_date_iso8601($event->start_time)), $startDateStr . ' ' . $startTimeStr);
     $out->text(' – ');
     $out->element('time', array('class' => 'dt-end', 'datetime' => common_date_iso8601($event->end_time)), $startDateStr != $endDateStr ? "{$endDateStr} {$endTimeStr}" : $endTimeStr);
     $out->elementEnd('div');
     // VEVENT/EVENT-TIMES OUT
     if (!empty($event->location)) {
         $out->elementStart('div', 'event-location');
         // TRANS: Field label for event description.
         $out->element('strong', null, _m('Location:'));
         $out->element('span', 'p-location', $event->location);
         $out->elementEnd('div');
     }
     if (!empty($event->description)) {
         $out->elementStart('div', 'event-description');
         // TRANS: Field label for event description.
         $out->element('strong', null, _m('Description:'));
         $out->element('div', 'p-description', $event->description);
         $out->elementEnd('div');
     }
     $rsvps = $event->getRSVPs();
     $out->elementStart('div', 'event-rsvps');
     // TRANS: Field label for event description.
     $out->element('strong', null, _m('Attending:'));
     $out->elementStart('ul', 'attending-list');
     foreach ($rsvps as $verb => $responses) {
         $out->elementStart('li', 'rsvp-list');
         switch ($verb) {
             case RSVP::POSITIVE:
                 $out->text(_('Yes:'));
                 break;
             case RSVP::NEGATIVE:
                 $out->text(_('No:'));
                 break;
             case RSVP::POSSIBLE:
                 $out->text(_('Maybe:'));
                 break;
         }
         $ids = array();
         foreach ($responses as $response) {
             $ids[] = $response->profile_id;
         }
         $ids = array_slice($ids, 0, ProfileMiniList::MAX_PROFILES + 1);
         $minilist = new ProfileMiniList(Profile::multiGet('id', $ids), $out);
         $minilist->show();
         $out->elementEnd('li');
     }
     $out->elementEnd('ul');
     $out->elementEnd('div');
     if ($scoped instanceof Profile) {
         $rsvp = $event->getRSVP($scoped);
         if (empty($rsvp)) {
             $form = new RSVPForm($event, $out);
         } else {
             $form = new CancelRSVPForm($rsvp, $out);
         }
         $form->show();
     }
     $out->elementEnd('div');
 }
 protected function showNoticeContent(Notice $stored, HTMLOutputter $out, Profile $scoped = null)
 {
     $out->text($stored->getContent());
 }
Exemplo n.º 3
0
 protected function showNoticeContent(Notice $stored, HTMLOutputter $out, Profile $scoped = null)
 {
     $nb = Bookmark::getByNotice($stored);
     if (empty($nb)) {
         common_log(LOG_ERR, "No bookmark for notice {$stored->id}");
         parent::showContent();
         return;
     } else {
         if (empty($nb->url)) {
             common_log(LOG_ERR, "No url for bookmark {$nb->id} for notice {$stored->id}");
             parent::showContent();
             return;
         }
     }
     $profile = $stored->getProfile();
     // Whether to nofollow
     $attrs = array('href' => $nb->url, 'class' => 'bookmark-title');
     $nf = common_config('nofollow', 'external');
     if ($nf == 'never' || ($nf == 'sometimes' and $out instanceof ShowstreamAction)) {
         $attrs['rel'] = 'external';
     } else {
         $attrs['rel'] = 'nofollow external';
     }
     $out->elementStart('h3');
     $out->element('a', $attrs, $nb->title);
     $out->elementEnd('h3');
     // Replies look like "for:" tags
     $replies = $stored->getReplies();
     $tags = $stored->getTags();
     if (!empty($nb->description)) {
         $out->element('p', array('class' => 'bookmark-description'), $nb->description);
     }
     if (!empty($replies) || !empty($tags)) {
         $out->elementStart('ul', array('class' => 'bookmark-tags'));
         foreach ($replies as $reply) {
             $other = Profile::getKV('id', $reply);
             if (!empty($other)) {
                 $out->elementStart('li');
                 $out->element('a', array('rel' => 'tag', 'href' => $other->profileurl, 'title' => $other->getBestName()), sprintf('for:%s', $other->nickname));
                 $out->elementEnd('li');
                 $out->text(' ');
             }
         }
         foreach ($tags as $tag) {
             $tag = trim($tag);
             if (!empty($tag)) {
                 $out->elementStart('li');
                 $out->element('a', array('rel' => 'tag', 'href' => Notice_tag::url($tag)), $tag);
                 $out->elementEnd('li');
                 $out->text(' ');
             }
         }
         $out->elementEnd('ul');
     }
 }
Exemplo n.º 4
0
 public function onEndShowAttachmentLink(HTMLOutputter $out, File $file)
 {
     $oembed = File_oembed::getKV('file_id', $file->id);
     if (empty($oembed->author_name) && empty($oembed->provider)) {
         return true;
     }
     $out->elementStart('div', array('id' => 'oembed_info', 'class' => 'e-content'));
     if (!empty($oembed->author_name)) {
         $out->elementStart('div', 'fn vcard author');
         if (empty($oembed->author_url)) {
             $out->text($oembed->author_name);
         } else {
             $out->element('a', array('href' => $oembed->author_url, 'class' => 'url'), $oembed->author_name);
         }
     }
     if (!empty($oembed->provider)) {
         $out->elementStart('div', 'fn vcard');
         if (empty($oembed->provider_url)) {
             $out->text($oembed->provider);
         } else {
             $out->element('a', array('href' => $oembed->provider_url, 'class' => 'url'), $oembed->provider);
         }
     }
     $out->elementEnd('div');
 }
Exemplo n.º 5
0
 protected function showNoticeContent(Notice $stored, HTMLOutputter $out, Profile $scoped = null)
 {
     $nb = Bookmark::fromStored($stored);
     // Whether to nofollow
     $attrs = array('href' => $nb->getUrl(), 'class' => 'bookmark-title');
     $nf = common_config('nofollow', 'external');
     if ($nf == 'never' || ($nf == 'sometimes' and $out instanceof ShowstreamAction)) {
         $attrs['rel'] = 'external';
     } else {
         $attrs['rel'] = 'nofollow external';
     }
     $out->elementStart('h3');
     $out->element('a', $attrs, $nb->getTitle());
     $out->elementEnd('h3');
     // Replies look like "for:" tags
     $replies = $stored->getReplies();
     $tags = $stored->getTags();
     if (!empty($nb->description)) {
         $out->element('p', array('class' => 'bookmark-description'), $nb->description);
     }
     if (!empty($replies) || !empty($tags)) {
         $out->elementStart('ul', array('class' => 'bookmark-tags'));
         foreach ($replies as $reply) {
             $other = Profile::getByPK($reply);
             $out->elementStart('li');
             $out->element('a', array('rel' => 'tag', 'href' => $other->getUrl(), 'title' => $other->getBestName()), sprintf('for:%s', $other->getNickname()));
             $out->elementEnd('li');
             $out->text(' ');
         }
         foreach ($tags as $tag) {
             $tag = trim($tag);
             if (!empty($tag)) {
                 $out->elementStart('li');
                 $out->element('a', array('rel' => 'tag', 'href' => Notice_tag::url($tag)), $tag);
                 $out->elementEnd('li');
                 $out->text(' ');
             }
         }
         $out->elementEnd('ul');
     }
 }