function twitterBadge($userEmail, $userPassword, $count = 4)
{
    $json = new Services_JSON();
    // Create the twitter Cacher object to pull feed
    // Password is needed in case feed is protected
    // HTTP Basic Auth hasn't been deprecated...yet...so...lazy wins for now
    $tc = new TwitterCacher($userEmail, $userPassword);
    $tc->setUserAgent("Mozilla/5.0 (compatible; TwitterCacher/1.0; +http://www.kolich.com)");
    //echo '<!-- ' . $tc->getUserTimeline(4) . ' -->';
    //Create a timeline object of the feed (pull from live if old)
    $timeline = $json->decode($tc->getUserTimeline($count));
    if (!$timeline) {
        return '<p>Error locating tweets.</p>';
    }
    // Create unorderer list of tweets (see gagawa module)
    $ul = new Ol();
    foreach ($timeline as $tweet) {
        $text = $tweet->text;
        //Format date as 5 min ago, 2 hours ago, etc.
        $date = distance_of_time_in_words(strtotime($tweet->created_at)) . ' ago';
        // Tweet source, i.e. twhril, tweetie, tweetdeck, etc.
        // $source = $tweet->source;
        // Generate direct link to tweet
        $tweetid = $tweet->id;
        $screenname = $tweet->user->screen_name;
        $tweetlink = 'http://twitter.com/' . $screenname . '/status/' . $tweetid;
        // Turn links into links
        $text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\\+.~#?&//=]+)', '<a href="\\1" target="_blank">\\1</a>', $text);
        // Turn twitter @username into links to the users Twitter page
        $text = preg_replace('/(^|\\s)@(\\w+)/', '\\1<a href="http://www.twitter.com/\\2">@\\2</a>', $text);
        // Turn #hashtags into searches
        $text = preg_replace('/(^|\\s)#(\\w+)/', '\\1<a href="http://search.twitter.com/search?q=%23\\2">#\\2</a>', $text);
        // Personal Formatting, see Gagawa for documentaiton.
        // <li>Tweet Text <span>(<a href="linktotweet">some time ago</a>)<span></li>
        $li = new Li();
        $ul->appendChild($li);
        $li->appendChild(new Text($text . ' ('));
        $span = new Span();
        $link = new A();
        $link->setHref($tweetlink);
        $link->appendChild(new Text($date));
        $span->appendChild($link);
        $li->appendChild($span);
        $li->appendChild(new Text(')'));
    }
    //end foreach( $timeline as $tweet )
    // Returns the stack of li's enclosed by ul
    return $ul->write();
}
Ejemplo n.º 2
0
function wrapTweets($timeline)
{
    if (!$timeline) {
        return '<p>Unable to connect to twitter.</p>';
    }
    // Create unorderer list of tweets (see gagawa module)
    $ul = new Ol();
    foreach ($timeline as $tweet) {
        $text = $tweet->text;
        //Format date as 5 min ago, 2 hours ago, etc.
        $date = distance_of_time_in_words(strtotime($tweet->created_at)) . ' ago';
        // Tweet source, i.e. twhril, tweetie, tweetdeck, etc.
        // $source = $tweet->source;
        // Generate direct link to tweet
        $tweetid = $tweet->id;
        $screenname = $tweet->user->screen_name;
        $tweetlink = 'http://twitter.com/' . $screenname . '/status/' . $tweetid;
        // Turn links into links
        $text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\\+.~#?&//=]+)', '<a href="\\1" target="_blank">\\1</a>', $text);
        // Turn twitter @username into links to the users Twitter page
        $text = preg_replace('/(^|\\s)@(\\w+)/', '\\1<a href="http://www.twitter.com/\\2" target="_blank">@\\2</a>', $text);
        // Turn #hashtags into searches
        $text = preg_replace('/(^|\\s)#(\\w+)/', '\\1<a href="http://search.twitter.com/search?q=%23\\2" target="_blank">#\\2</a>', $text);
        // Personal Formatting, see Gagawa for documentaiton.
        // <li>Tweet Text <span>(<a href="linktotweet">some time ago</a>)<span></li>
        $li = new Li();
        $ul->appendChild($li);
        $span = new Span();
        $link = new A();
        $link->setHref($tweetlink);
        $link->appendChild(new Text($date));
        $span->appendChild($link);
        //$li->appendChild($span);
        $li->appendChild(new Text($text));
    }
    //end foreach( $timeline as $tweet )
    // Returns the stack of li's enclosed by ul
    return $ul->write();
}
Ejemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function parse($node)
 {
     return parent::parse($node);
 }
Ejemplo n.º 4
0
 /**
  * 
  * @param mixed $items
  * @param mixed $options
  */
 public function __construct($items = null, $options = null)
 {
     parent::__construct($items, $options);
     $this->setTag('ul');
 }