/**
  * Build an Atom entry similar to search.twitter.com's based on
  * a given notice
  *
  * @param Notice $notice the notice to use
  *
  * @return void
  */
 function showEntry($notice)
 {
     $server = common_config('site', 'server');
     $profile = $notice->getProfile();
     $nurl = common_local_url('shownotice', array('notice' => $notice->id));
     $this->elementStart('entry');
     $taguribase = TagURI::base();
     $this->element('id', null, "tag:{$taguribase}:{$notice->id}");
     $this->element('published', null, common_date_w3dtf($notice->created));
     $this->element('link', array('type' => 'text/html', 'rel' => 'alternate', 'href' => $nurl));
     $this->element('title', null, common_xml_safe_str(trim($notice->content)));
     $this->element('content', array('type' => 'html'), $notice->getRendered());
     $this->element('updated', null, common_date_w3dtf($notice->created));
     $this->element('link', array('type' => 'image/png', 'rel' => 'related', 'href' => $profile->avatarUrl()));
     // @todo: Here is where we'd put in a link to an atom feed for threads
     $source = null;
     $ns = $notice->getSource();
     if ($ns instanceof Notice_source) {
         if (!empty($ns->name) && !empty($ns->url)) {
             $source = '<a href="' . htmlspecialchars($ns->url) . '" rel="nofollow">' . htmlspecialchars($ns->name) . '</a>';
         } else {
             $source = $ns->code;
         }
     }
     $this->element("twitter:source", null, $source);
     $this->elementStart('author');
     $name = $profile->nickname;
     if ($profile->fullname) {
         // @todo Needs proper i18n?
         $name .= ' (' . $profile->fullname . ')';
     }
     $this->element('name', null, $name);
     $this->element('uri', null, common_profile_uri($profile));
     $this->elementEnd('author');
     $this->elementEnd('entry');
 }
 /**
  * Layout stuff
  */
 protected function showNoticeContent(Notice $stored, HTMLOutputter $out, Profile $scoped = null)
 {
     $out->raw($stored->getRendered());
 }
Beispiel #3
0
 /**
  * Mirror a notice by emitting a new notice with the same contents.
  * Kind of dirty, but if pulling an external data feed into an account
  * that may be what you want.
  *
  * @param Notice $notice
  * @return mixed Notice on successful repeat, true if already repeated, false on failure
  */
 protected function copyNotice($profile, $notice)
 {
     $options = array('is_local' => Notice::LOCAL_PUBLIC, 'url' => $notice->getUrl(), 'rendered' => $notice->getRendered());
     $saved = Notice::saveNew($profile->id, $notice->content, 'feed', $options);
     return $saved;
 }
Beispiel #4
0
 /**
  * extra information for XMPP messages, as defined by Twitter
  *
  * @param Profile $profile Profile of the sending user
  * @param Notice  $notice  Notice being sent
  *
  * @return string Extra information (Atom, HTML, addresses) in string format
  */
 protected function format_entry(Notice $notice)
 {
     $profile = $notice->getProfile();
     $entry = $notice->asAtomEntry(true, true);
     $xs = new XMLStringer();
     $xs->elementStart('html', array('xmlns' => 'http://jabber.org/protocol/xhtml-im'));
     $xs->elementStart('body', array('xmlns' => 'http://www.w3.org/1999/xhtml'));
     $xs->element('a', array('href' => $profile->profileurl), $profile->nickname);
     try {
         $parent = $notice->getParent();
         $orig_profile = $parent->getProfile();
         $orig_profurl = $orig_profile->getUrl();
         $xs->text(" => ");
         $xs->element('a', array('href' => $orig_profurl), $orig_profile->nickname);
         $xs->text(": ");
     } catch (InvalidUrlException $e) {
         $xs->text(sprintf(' => %s', $orig_profile->nickname));
     } catch (NoParentNoticeException $e) {
         $xs->text(": ");
     } catch (NoResultException $e) {
         // Parent notice was probably deleted.
         $xs->text(": ");
     }
     // FIXME: Why do we replace \t with ''? is it just to make it pretty? shouldn't whitespace be handled well...?
     $xs->raw(str_replace("\t", "", $notice->getRendered()));
     $xs->text(" ");
     $xs->element('a', array('href' => common_local_url('conversation', array('id' => $notice->conversation)) . '#notice-' . $notice->id), sprintf(_m('[%u]'), $notice->id));
     $xs->elementEnd('body');
     $xs->elementEnd('html');
     $html = $xs->getString();
     return $html . ' ' . $entry;
 }
 public function activityObjectFromNotice(Notice $stored)
 {
     // Repeat is a little bit special. As it's an activity, our
     // ActivityObject is instead turned into an Activity
     $object = new Activity();
     $object->actor = $stored->getProfile()->asActivityObject();
     $object->verb = ActivityVerb::SHARE;
     $object->content = $stored->getRendered();
     $this->extendActivity($stored, $object);
     return $object;
 }