$html = '';
$newest = $stream[0]->id;
foreach ($stream as $tweet) {
- /* links */
+ $view = new Horde_View(array('templatePath' => HORDE_TEMPLATES . '/block'));
+ $view->addHelper('Tag');
+
+ /* links */
$body = Horde_Text_Filter::filter($tweet->text, 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::MICRO_LINKURL));
- $body = preg_replace("/[@]+([A-Za-z0-9-_]+)/", "<a href=\"http://twitter.com/\\1\" target=\"_blank\">\\0</a>", $body);
+ $view->body = preg_replace("/[@]+([A-Za-z0-9-_]+)/", "<a href=\"http://twitter.com/\\1\" target=\"_blank\">\\0</a>", $body);
/* If this is a retweet, use the original author's profile info */
if (!empty($tweet->retweeted_status)) {
}
/* These are all referencing the *original* tweet */
- $profileLink = Horde::externalUrl('http://twitter.com/' . htmlspecialchars($tweetObj->user->screen_name), true);
- $profileImg = $tweetObj->user->profile_image_url;
- $authorName = htmlspecialchars($tweetObj->user->screen_name, ENT_COMPAT, $GLOBALS['registry']->getCharset());
- $authorFullname = htmlspecialchars($tweetObj->user->name, ENT_COMPAT, $GLOBALS['registry']->getCharset());
- $createdAt = $tweetObj->created_at;
-
- $appText = Horde_Text_Filter::filter($tweet->source, 'xss', array());
- $html .= '<div class="fbstreamstory">';
- $html .= '<div style="float:left;text-align:center;width:70px;margin-right:5px;">' . $profileLink
- . '<img width="73" height="73" src="' . $profileImg . '" alt="' . $authorName . '" title="' . $authorFullname . '" />'
- . '</a><div style="overflow:hidden;">' . $profileLink . $authorName . '</a></div></div>';
- $html .= ' <div class="fbstreambody">';
- $html .= $body;
- $html .= '<div class="fbstreaminfo">' . sprintf(_("Posted %s via %s"), Horde_Date_Utils::relativeDateTime(strtotime($createdAt), $GLOBALS['prefs']->getValue('date_format')), $appText) . '</div>';
-
- /* Specify the retweeted status */
- if (!empty($tweet->retweeted_status)) {
- $html .= '<div class="fbstreaminfo">' . sprintf(_("Retweeted by %s"), Horde::externalUrl('http://twitter.com/' . htmlspecialchars($tweet->user->screen_name), true)) . htmlspecialchars($tweet->user->screen_name) . '</a></div>';
- }
-
- $html .= '<div class="fbstreaminfo">' . Horde::link('#', '', '', '', 'Horde.twitter.buildReply(\'' . $tweet->id . '\', \'' . $tweet->user->screen_name . '\', \'' . $tweet->user->name . '\')') . _("Reply") . '</a>';
- $html .= ' | ' . Horde::link('#', '', '', '', 'Horde.twitter.retweet(\'' . $tweet->id . '\')') . _("Retweet") . '</a>';
- $html .= '</div><div class="clear"> </div></div></div>';
+ $view->profileLink = Horde::externalUrl('http://twitter.com/' . htmlspecialchars($tweetObj->user->screen_name), true);
+ $view->profileImg = $tweetObj->user->profile_image_url;
+ $view->authorName = htmlspecialchars($tweetObj->user->screen_name, ENT_COMPAT, $GLOBALS['registry']->getCharset());
+ $view->authorFullname = htmlspecialchars($tweetObj->user->name, ENT_COMPAT, $GLOBALS['registry']->getCharset());
+ $view->createdAt = $tweetObj->created_at;
+ $view->clientText = Horde_Text_Filter::filter($tweet->source, 'xss', array());
+ $view->tweet = $tweet;
$oldest = $tweet->id;
+ $html .= $view->render('twitter_tweet');
}
$result = array(
--- /dev/null
+<?php
+/**
+ * Template for individual tweets:
+ *
+ * Uses:
+ * ->body
+ * ->profileLink
+ * ->profileImg
+ * ->authorName
+ * ->authorFullname
+ * ->createdAt
+ * ->clientName
+ * ->tweet
+ *
+ */
+?>
+<div class="fbstreamstory">
+ <div class="fbgreybox" style="float:left;text-align:center;height:73px;width:73px;margin-right:5px;">
+ <?php echo $this->profileLink ?><img width="48" height="48" src="<?php echo $this->profileImg?>" alt="<?php echo $this->authorName?>" title="<?php echo $this->authorFullname?>" /></a>
+ <div style="overflow:hidden;"><?php echo $this->profileLink . $this->authorName ?></a></div>
+ </div>
+ <div class="fbstreambody">
+ <?php echo $this->body ?>
+ <div class="fbstreaminfo">
+ <?php echo sprintf(_("Posted %s via %s"), Horde_Date_Utils::relativeDateTime(strtotime($this->createdAt), $GLOBALS['prefs']->getValue('date_format')), $this->clientText)?>
+ </div>
+ <?php if (!empty($tweet->retweeted_status)):?>
+ <div class="fbstreaminfo">
+ <?php echo sprintf(_("Retweeted by %s"), Horde::externalUrl('http://twitter.com/' . $this->escape($this->tweet->user->screen_name), true)) . $this->escape($this->tweet->user->screen_name) ?></a>
+ </div>
+ <?php endif; ?>
+ <div class="fbstreaminfo">
+ <?php echo Horde::link('#', '', '', '', 'Horde.twitter.buildReply(\'' . $this->tweet->id . '\', \'' . $this->tweet->user->screen_name . '\', \'' . $this->tweet->user->name . '\')') . _("Reply") ?></a>
+ | <?php echo Horde::link('#', '', '', '', 'Horde.twitter.retweet(\'' . $this->tweet->id . '\')') . _("Retweet") ?></a>
+ </div>
+ <div class="clear"> </div>
+ </div>
+</div>