Skip to content

Commit

Permalink
* Should now technically work without the CMS module
Browse files Browse the repository at this point in the history
* Facebook Posts will now display videos that were shared from other websites
  • Loading branch information
Mellisa Hankins committed Nov 29, 2015
1 parent f1cc666 commit 8475555
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion code/Profiles/SocialFeed_Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public function getTemplates() {
}

public function getStyleClasses() {
return singleton('utilities')->raw2htmlid('platform-' . str_replace('_', '-', strtolower($this->singular_name())));
return singleton('mwm')->raw2htmlid('platform-' . str_replace('_', '-', strtolower($this->singular_name())));
}

public function Link($parent = null) {
Expand Down
26 changes: 26 additions & 0 deletions code/Providers/Facebook.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class Facebook extends Oauth implements \Flushable

protected $defaultType = 'feed';

protected $allowLargeUnsafeImages = true;

protected $replaceInUrls = [
//'/v/' => '/',
// 'p600x600/' => '',
Expand Down Expand Up @@ -212,6 +214,19 @@ protected function handlePost(array $data, $settings = [], $type = 'feed', $user
}
}

if($post['Type'] == 'video' && $post['Source']) {
$url = parse_url($post['Source']);
parse_str($url['query'], $query);

if(isset($query['autoplay'])) {
unset($query['autoplay']);
}

$url = sprintf('%s://%s%s%s', $url['scheme'], $url['host'], $url['path'], (!empty($query) ? '?' . http_build_query($query) : ''));

$post['ObjectEmbed'] = '<iframe src="' . $url . '" class="panel-post-media--embed" width="640" height="480" frameborder="0" allowfullscreen></iframe>';
}

return $post;
}

Expand Down Expand Up @@ -266,6 +281,17 @@ protected function getPictureFromData($data) {
else
$link = $data;

if($this->allowLargeUnsafeImages && strpos($link, '/safe_image.php?') !== false) {
$parts = parse_url($link);

if(isset($parts['query'])) {
parse_str($parts['query'], $query);
if(isset($query['url'])) {
$link = $query['url'];
}
}
}

return $link ? str_replace(array_keys($this->replaceInUrls), array_values($this->replaceInUrls), $link) : '';
}

Expand Down
4 changes: 4 additions & 0 deletions code/SocialFeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
* @author Mellisa Hankins <[email protected]>
*/

if(!class_exists('Page')) {
return;
}

class SocialFeed extends Page {
private static $description = 'A page that displays a social feed from various social platforms';

Expand Down

0 comments on commit 8475555

Please sign in to comment.