function test_linkifyText() { $test_str = 'First add an anchor for http://cashmusic.org and mailto for info@cashmusic.org, second a twitter link for @cashmusic'; $linkified = CASHSystem::linkifyText($test_str); $this->assertPattern('/href=\\"http:\\/\\/cashmusic.org\\"\\>http:\\/\\/cashmusic.org/', $linkified); // test www link $this->assertPattern('/href=\\"mailto:info@cashmusic.org\\"\\>info@cashmusic.org/', $linkified); // test mailto $linkified = CASHSystem::linkifyText($test_str, true); $this->assertPattern('/href=\\"http:\\/\\/www.twitter.com\\/cashmusic\\" target=\\"_blank\\">@cashmusic/', $linkified); // test twitter }
public function prepMarkup($tweet) { $tmp_profile_img = $tweet->user->profile_image_url; if ($tmp_profile_img == 'http://static.twitter.com/images/default_profile_normal.png') { $tmp_profile_img = 'http://a2.twimg.com/sticky/default_profile_images/default_profile_' . rand(0, 6) . '_normal.png'; } $innermarkup = "<div class=\"cashmusic_social cashmusic_twitter cashmusic_twitter_" . $tweet->user->screen_name . "\"><img src=\"{$tmp_profile_img}\" class=\"cashmusic_twitter_avatar\" alt=\"avatar\" />" . "<div class=\"cashmusic_twitter_namespc\"><a href=\"http://twitter.com/" . $tweet->user->screen_name . "\">@" . $tweet->user->screen_name . "</a><br />" . $tweet->user->name . "</div><div class=\"cashmusic_clearall\">.</div>" . "<div class=\"tweet\">" . CASHSystem::linkifyText($tweet->text, true) . '<div class="cashmusic_social_date"><a href="http://twitter.com/#!/' . $tweet->user->screen_name . '/status/' . $tweet->id_str . '" target="_blank">' . CASHSystem::formatTimeAgo($tweet->created_at) . ' / twitter</a> </div></div>' . "</div>"; return $innermarkup; /* The CSS to go along with the twitter markup: From our stuff up on http://marketairglovamusic.com/ .cashmusic_social {margin:10px 0 20px 0;padding:15px;background-color:#fff;border-top-left-radius:5px 5px;border-top-right-radius:5px 5px;border-bottom-right-radius:5px 5px;border-bottom-left-radius:5px 5px;} .cashmusic_social a {color:#cdcdcd;} .cashmusic_twitter {font:14.5px/1.75em georgia,'times new roman',times,serif;} .cashmusic_twitter_avatar {float:left;margin:1px 8px 8px 0;} .cashmusic_twitter_namespc {color:#cdcdcd;font:11px/1.5em helvetica,"helvetica neue",arial,sans-serif;} .cashmusic_twitter_namespc a {color:#007e3d;font:bold 15px/1.85em helvetica,"helvetica neue",arial,sans-serif;} .cashmusic_twitter a {color:#007e3d;} .cashmusic_tumblr h2, .cashmusic_tumblr h2 a, #topmenu * a, h2 {color:#111;font:28px/1em 'IM Fell English',georgia,'times new roman',times,serif;} .cashmusic_social_date {margin-top:10px;color:#cdcdcd;font:11px/1.75em helvetica,"helvetica neue",arial,sans-serif;} .cashmusic_clearall {clear:both;height:1px;overflow:hidden;visibility:hidden;} */ }
protected function getCachedAPIResponse($endpoint, $params) { $data_name = http_build_query($params, '', '-'); $data = $this->getCacheData($this->settings_type, $data_name); if (!$data && $this->twitter) { $data = $this->twitter->get($endpoint, $params); if (!$data) { $data = $this->getCacheData($this->settings_type, $data_name, true); } else { foreach ($data as $tweet) { // add formatted time to tweet $tweet->formatted_created_at = CASHSystem::formatTimeAgo($tweet->created_at); if ($tweet->user->profile_image_url_https === true) { $tweet->user->profile_image_url_https_bigger = 'https://a0.twimg.com/sticky/default_profile_images/default_profile_1_bigger.png'; } else { $tweet->user->profile_image_url_https_bigger = str_replace('_normal', '_bigger', $tweet->user->profile_image_url_https); } // handle url links $twitterstatus = true; if (isset($tweet->entities)) { if (isset($tweet->entities->urls)) { if (count($tweet->entities->urls)) { $twitterstatus = $tweet->entities->urls; } } } $tweet->text = CASHSystem::linkifyText($tweet->text, $twitterstatus); // add media collections // handle twitter photos if (isset($tweet->extended_entities)) { if (is_object($tweet->extended_entities)) { if (is_array($tweet->extended_entities->media)) { $tweet->photos = array(); foreach ($tweet->extended_entities->media as $m) { $tweet->photos[] = $m; } } } } // handle youtube videos if (isset($tweet->entities)) { if (is_object($tweet->entities)) { if (is_array($tweet->entities->urls)) { $tweet->iframes = array(); foreach ($tweet->entities->urls as $u) { if (strpos($u->expanded_url, 'youtube.com') > 0) { $parsed_url = parse_url($u->expanded_url); $query_array = array(); parse_str($parsed_url['query'], $query_array); if (isset($query_array['v'])) { $tweet->iframes[] = array('iframe_url' => '//www.youtube.com/embed/' . $query_array['v']); // <iframe src="//www.youtube.com/embed/dOy7vPwEtCw" frameborder="0" allowfullscreen></iframe> } } } } } } } $this->setCacheData($this->settings_type, $data_name, $data); } } return $data; }