From: Michael J. Rubinsky Date: Sat, 17 Jul 2010 13:58:30 +0000 (-0400) Subject: Use Horde_View for rendering tweets. Tweak style. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=a2a7c0c1bb7e9a6d8d1698e39a0bda74ece8f10b;p=horde.git Use Horde_View for rendering tweets. Tweak style. --- diff --git a/horde/services/twitter.php b/horde/services/twitter.php index 3235d3b1a..004b8761d 100644 --- a/horde/services/twitter.php +++ b/horde/services/twitter.php @@ -67,9 +67,12 @@ case 'getPage': $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-_]+)/", "\\0", $body); + $view->body = preg_replace("/[@]+([A-Za-z0-9-_]+)/", "\\0", $body); /* If this is a retweet, use the original author's profile info */ if (!empty($tweet->retweeted_status)) { @@ -79,30 +82,15 @@ case 'getPage': } /* 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 .= '
'; - $html .= '
' . $profileLink - . '' . $authorName . '' - . '
' . $profileLink . $authorName . '
'; - $html .= '
'; - $html .= $body; - $html .= '
' . sprintf(_("Posted %s via %s"), Horde_Date_Utils::relativeDateTime(strtotime($createdAt), $GLOBALS['prefs']->getValue('date_format')), $appText) . '
'; - - /* Specify the retweeted status */ - if (!empty($tweet->retweeted_status)) { - $html .= '
' . sprintf(_("Retweeted by %s"), Horde::externalUrl('http://twitter.com/' . htmlspecialchars($tweet->user->screen_name), true)) . htmlspecialchars($tweet->user->screen_name) . '
'; - } - - $html .= '
' . Horde::link('#', '', '', '', 'Horde.twitter.buildReply(\'' . $tweet->id . '\', \'' . $tweet->user->screen_name . '\', \'' . $tweet->user->name . '\')') . _("Reply") . ''; - $html .= ' | ' . Horde::link('#', '', '', '', 'Horde.twitter.retweet(\'' . $tweet->id . '\')') . _("Retweet") . ''; - $html .= '
 
'; + $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( diff --git a/horde/templates/block/twitter_tweet.html.php b/horde/templates/block/twitter_tweet.html.php new file mode 100644 index 000000000..5e70b6ecd --- /dev/null +++ b/horde/templates/block/twitter_tweet.html.php @@ -0,0 +1,38 @@ +body + * ->profileLink + * ->profileImg + * ->authorName + * ->authorFullname + * ->createdAt + * ->clientName + * ->tweet + * + */ +?> +
+
+ profileLink ?><?php echo $this->authorName?> +
profileLink . $this->authorName ?>
+
+
+ body ?> +
+ createdAt), $GLOBALS['prefs']->getValue('date_format')), $this->clientText)?> +
+ retweeted_status)):?> +
+ escape($this->tweet->user->screen_name), true)) . $this->escape($this->tweet->user->screen_name) ?> +
+ +
+ tweet->id . '\', \'' . $this->tweet->user->screen_name . '\', \'' . $this->tweet->user->name . '\')') . _("Reply") ?> +  |  tweet->id . '\')') . _("Retweet") ?> +
+
 
+
+