protected function keywordify($text) { // No fancy apostrophes and dashes in keywords $text = strtolower(stupefyRaw($text, true)); // Remove any apostrophes which aren't part of words $keywords = substr(preg_replace("((?<=\\W)'|'(?=\\W))", "", " " . $text . " "), 1, -1); // Remove symbols and multiple whitespace $keywords = preg_replace("/[\\^\$&\\(\\)<>`\"\\|,@_\\?%~\\+\\[\\]{}:=\\/#\\\\;!\\.\\s]+/", " ", $keywords); return $keywords; }
function tweetHTML($tweet, $tabs = 4) { global $twitterApi; $tweetextra = array(); $tweetplace = array(); if (!empty($tweet['extra'])) { @($tweetextra = unserialize($tweet['extra'])); } if (!empty($tweet['place'])) { $tweetplace = unserialize(str_replace("O:16:\"SimpleXMLElement\"", "O:8:\"stdClass\"", $tweet['place'])); } $rt = array_key_exists("rt", $tweetextra) && !empty($tweetextra['rt']); $t = str_repeat("\t", $tabs); if ($rt) { $retweet = $tweetextra['rt']; } // Entities $htmlcontent = s(stupefyRaw($rt ? $twitterApi->entityDecode($retweet['text']) : $tweet['text']), ENT_NOQUOTES); $entities = $rt ? $tweetextra['rt']['extra']['entities'] : $tweetextra['entities']; if (areEntitiesEmpty($entities)) { $htmlcontent = linkifyTweet($htmlcontent); } else { $htmlcontent = linkifyTweet(entitifyTweet($htmlcontent, $entities), true); } $d = $t . "<div id=\"tweet-" . s($tweet['tweetid']) . "\" class=\"tweet" . ($tweet['type'] == 1 ? " reply" : "") . ($tweet['type'] == 2 ? " retweet" : "") . "\">\n" . ($tweet['favorite'] ? $t . "\t<div class=\"fav\" title=\"A personal favorite\"><span>(A personal favorite)</span></div>\n" : "") . $t . "\t<p class=\"text\">" . ($rt ? "<a class=\"rt\" href=\"http://twitter.com/" . $retweet['screenname'] . "\"><strong>" . $retweet['screenname'] . "</strong></a> " : "") . nl2br(p(highlightQuery($htmlcontent, $tweet), 3)) . "</p>\n" . $t . "\t<p class=\"meta\">\n" . $t . "\t\t<a href=\"http://twitter.com/" . s($rt ? $retweet['screenname'] : $tweet['screenname']) . "/statuses/" . s($rt ? $retweet['tweetid'] : $tweet['tweetid']) . "\" class=\"permalink\">" . date("g:i A, M jS, Y", $rt ? $retweet['time'] : $tweet['time']) . "</a>\n" . $t . "\t\t<span class=\"via\">via " . ($rt ? $retweet['source'] : $tweet['source']) . "</span>\n" . ($rt ? $t . "\t\t<span class=\"rted\">(retweeted on " . date("g:i A, M jS, Y", $tweet['time']) . " <span class=\"via\">via " . $tweet['source'] . "</span>)</span>\n" : "") . (!$rt && $tweetextra && @(!empty($tweetextra['in_reply_to_status_id'])) ? $t . "\t\t<a class=\"replyto\" href=\"http://twitter.com/" . s($tweetextra['in_reply_to_screen_name']) . "/statuses/" . s($tweetextra['in_reply_to_status_id']) . "\">in reply to " . s($tweetextra['in_reply_to_screen_name']) . "</a>\n" : "") . ($tweetplace && @$tweetplace->full_name ? "\t\t<span class=\"place\">from <a href=\"http://maps.google.com/?q=" . urlencode($tweetplace->full_name) . "\">" . s($tweetplace->full_name) . "</a></span>" : "") . $t . "\t</p>\n" . $t . "</div>\n"; $dd = hook("displayTweet", array($d, $tweet)); if (!empty($dd)) { $d = $dd[0]; } return $d; }