<?php include_once 'feed/json_common.php'; /* * Echo out the data */ $obj = get_json_data('soundcloud'); if (count($obj) <= 0 || !$obj[0]->user_id) { exit; } echo '<table class="table table-striped"><th><h2 class="text-center">LMMS SoundCloud</h2></th>'; foreach ($obj as $item) { create_row('soundcloud', $item->title, "javascript:embedSound('#div-" . $item->id . "','" . $item->id . "')", trim_feed($item->description, $item->permalink_url), $item->user->username, $item->user->permalink_url, $item->created_at, $item->artwork_url ? $item->artwork_url : $item->user->avatar_url, 'div-' . $item->id); } echo '</table>';
<?php include_once 'utils.php'; include_once 'feed/json_common.php'; require_once '../vendor/autoload.php'; /* * Echo out the data */ $obj = get_json_data('facebook'); if (count($obj) <= 0 || !$obj->entries) { exit; } echo '<table class="table table-striped"><th><h2 class="text-center">LMMS Facebook</h2></th>'; foreach ($obj->entries as $item) { create_row('facebook', $item->title, $item->alternate, cleanse_urls($item->content, $item->alternate), $item->author->name, 'http://facebook.com/' . get_json_id('facebook'), $item->published); } echo '</table>'; /* * Fixes facebook JSON feed nuances such as: * - Relative linking (i.e. href="/makefreemusic") * - URL redirecting (i.e. ...l.php?u=http://my_real_link) * - Render cross-posted thumbnails (i.e. <a src="https://fbcdn-profile-a.akamaihd.net...>) */ function cleanse_urls($str, $article_url) { $html = SimpleHtmlDom\str_get_html($str); foreach ($html->find('a') as $element) { // Fix cross posts, especially those from LMMSChallenge facebook if (!$element->find('img') && is_feed_image($element)) { $element->innertext = '<img class="img-thumbnail fb-thumb" src="' . $element->href . '"/>'; $element->href = $article_url;
function soundcloud_iframe($message, $width, $height) { $parts = explode('<sc>', $message); $html = ''; foreach ($parts as $part) { if (strpos($part, '</sc>') !== false) { $url_parts = explode('</sc>', $part); if (sizeof($url_parts) > 0) { $object = get_json_data('soundcloud', '../resolve', "?url=https://soundcloud.com/{$url_parts['0']}", '.'); if (is_object($object) && property_exists($object, 'id')) { $html .= '<iframe width="' . $width . '" height="' . $height . '" scrolling="no" frameborder="no" ' . 'src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/' . $object->id . '&auto_play=false&hide_related=true&show_comments=false&' . 'show_user=true&show_reposts=false&visual=false"></iframe>'; $html .= $url_parts[1]; } else { $html .= 'https://soundcloud.com/' . $url_parts[0] . ' <i class="fa fa-exclamation-circle" title="Link is no longer valid"></i>'; $html .= $url_parts[1]; } } else { continue; } } else { $html .= $part; } } return $html; }
<?php include_once 'feed/json_common.php'; /* * Echo out the data */ $obj = get_json_data('google', 'activities', '?maxResults=25'); echo '<table class="table table-striped"><th><h2 class="text-center">LMMS Google+</h2></th>'; // Sort on publish date usort($obj->items, function ($a, $b) { return strtotime($a->published) > strtotime($b->published) ? -1 : 1; }); foreach ($obj as $items) { if (!is_array($items) || count($items) < 1) { continue; } $duplicates = array(); foreach ($items as $item) { // Google+ seems to have an abundance of duplicates in their feed (likely historical edits) // This is a quick hack to check for duplicates based on title name if (array_key_exists($item->title, $duplicates)) { continue; } $duplicates[$item->title] = true; create_row('google+', $item->title, $item->url, trim_feed($item->object->content, $item->url), $item->actor->displayName, $item->actor->url, $item->published); } } echo '</table>';
<?php include_once 'feed/json_common.php'; /* * Maximum number of displayed items */ $max = 20; /* * Creates an array of relational JSON objects from cached or online GitHub data */ $obj = get_json_data('github', 'issues', '?state=open'); /* * Loop through items and echo */ $count = 0; /* * Echo our data to the page */ echo '<table class="table table-striped"><th><h2 class="text-center">LMMS GitHub</h2></th>'; foreach ($obj as $item) { $title = 'GitHub #' . $item->number . ' • ' . $item->title; create_row('github', $title, $item->html_url, trim_feed($item->body, $item->html_url), $item->user->login, $item->user->html_url, $item->created_at); if ($count++ == $max) { break; } } echo '</table>';
<?php include_once 'feed/json_common.php'; /* * Echo out the data */ $videos_url = 'https://www.youtube.com/user/LMMSOfficial/videos'; $obj = get_json_data('youtube', 'activities', '&part=snippet&maxResults=25'); echo '<table class="table table-striped"><th><h2 class="text-center">LMMS YouTube</h2></th>'; foreach ($obj as $items) { if (!is_array($items) || count($items) < 1) { continue; } $duplicates = array(); foreach ($items as $item) { $item = $item->snippet; // YouTube seems to have some duplicates in their feed (likely historical edits) // This is a quick hack to check for duplicates based on title name if (array_key_exists($item->title, $duplicates)) { continue; } $duplicates[$item->title] = true; $id = parse_youtube_id($item->thumbnails->default->url); $url = $id ? 'http://www.youtube.com/watch?v=' . $id : ''; create_row('youtube', $item->title, "javascript:embedVideo('#div-" . $id . "','" . $id . "')", trim_feed($item->description, $url), $item->channelTitle, $videos_url, $item->publishedAt, $item->thumbnails->default->url, 'div-' . $id); } } echo '</table>'; // The feed doesn't give us a clean URL to the video // So we parse it from the thumbnail image URL function parse_youtube_id($thumbnail)