From efe6f27c46b93186ae77dac7b481b842496b412e Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 2 Jun 2015 13:17:52 -0700 Subject: [PATCH] Added Facebook Like Menu and corrected some FB.init issues. --- e107_plugins/social/admin_config.php | 15 ++++++++---- e107_plugins/social/e_comment.php | 24 ++------------------ e107_plugins/social/e_header.php | 28 +++++++++++++++++++++++ e107_plugins/social/fb_like_menu.php | 34 ++++++++++++++++++++++++++++ 4 files changed, 74 insertions(+), 27 deletions(-) create mode 100644 e107_plugins/social/fb_like_menu.php diff --git a/e107_plugins/social/admin_config.php b/e107_plugins/social/admin_config.php index 2f450a212..958b6694c 100644 --- a/e107_plugins/social/admin_config.php +++ b/e107_plugins/social/admin_config.php @@ -71,22 +71,27 @@ class social_ui extends e_admin_ui protected $fieldpref = array(); - protected $preftabs = array("Sharing", 'Facebook Comments', 'Twitter Menu' ); + protected $preftabs = array("Sharing", 'Facebook Comments', 'Facebook Menu', 'Twitter Menu', ); protected $prefs = array( 'facebook_comments_limit' => array('title'=> 'Limit', 'type'=>'number', 'tab'=>1, 'data' => 'int','help'=>'Number of tweets to display.'), - 'facebook_comments_theme' => array('title'=> 'Theme', 'type'=>'dropdown', 'tab'=>1, 'writeParms'=>array('optArray'=>array('light'=>'Light','dark'=>'Dark')), 'data' => 'int','help'=>'Number of tweets to display.'), + 'facebook_comments_theme' => array('title'=> 'Theme', 'type'=>'dropdown', 'tab'=>1, 'writeParms'=>array('optArray'=>array('light'=>'Light','dark'=>'Dark')), 'data' => 'str','help'=>''), 'facebook_comments_loadingtext' => array('title'=> 'Text while loading', 'type'=>'text', 'tab'=>1, 'data' => 'str', 'writeParms'=>array('placeholder'=>'Loading...'), 'help'=>''), - 'twitter_menu_height' => array('title'=> 'Height', 'type'=>'number', 'tab'=>2, 'data' => 'int','help'=>'Height in px'), - 'twitter_menu_limit' => array('title'=> 'Limit', 'type'=>'number', 'tab'=>2, 'data' => 'int','help'=>'Number of tweets to display.'), + 'facebook_like_menu_theme' => array('title'=> 'Theme', 'type'=>'dropdown', 'tab'=>2, 'writeParms'=>array('optArray'=>array('light'=>'Light','dark'=>'Dark')), 'data' => 'str'), + 'facebook_like_menu_action' => array('title'=> 'Action', 'type'=>'dropdown', 'tab'=>2, 'writeParms'=>array('optArray'=>array('like'=>'Like','recommend'=>'Recommend')), 'data' => 'str'), + 'facebook_like_menu_width' => array('title'=> 'Width', 'type'=>'number', 'tab'=>2, 'data' => 'int','help'=>'Width in px'), + + 'twitter_menu_theme' => array('title'=> 'Theme', 'type'=>'dropdown', 'tab'=>3, 'writeParms'=>array('optArray'=>array('light'=>'Light','dark'=>'Dark')), 'data' => 'str'), + 'twitter_menu_height' => array('title'=> 'Height', 'type'=>'number', 'tab'=>3, 'data' => 'int','help'=>'Height in px'), + 'twitter_menu_limit' => array('title'=> 'Limit', 'type'=>'number', 'tab'=>3, 'data' => 'int','help'=>'Number of tweets to display.'), + 'sharing_mode' => array('title'=> 'Display Mode', 'type'=>'dropdown', 'tab'=>0, 'writeParms'=>array('optArray'=>array('normal'=>'Normal','dropdown'=>'Dropdown','off'=>'Disabled')), 'data' => 'str','help'=>''), 'sharing_hashtags' => array('title'=> 'Hashtags', 'type'=>'tags', 'tab'=>0, 'data' => 'str','help'=>'Excluding the # symbol.'), 'sharing_providers' => array('title'=> 'Providers', 'type'=>'checkboxes', 'tab'=>0, 'writeParms'=>array(), 'data' => 'str','help'=>''), - ); protected $social_logins = array(); diff --git a/e107_plugins/social/e_comment.php b/e107_plugins/social/e_comment.php index bd14141be..7c9787448 100644 --- a/e107_plugins/social/e_comment.php +++ b/e107_plugins/social/e_comment.php @@ -45,32 +45,12 @@ class social_comment function facebook($data) { - if(empty($this->facebookActive)) + if(!deftrue('SOCIAL_FACEBOOK_INIT')) { return "
Unable to render comments. Missing Facebook appID.
"; } - $head = " - - window.fbAsyncInit = function() { - FB.init({ - appId : '".$this->facebookActive."', - xfbml : true, - version : 'v2.3' - }); - }; - - (function(d, s, id){ - var js, fjs = d.getElementsByTagName(s)[0]; - if (d.getElementById(id)) {return;} - js = d.createElement(s); js.id = id; - js.src = '//connect.facebook.net/en_US/sdk.js'; - fjs.parentNode.insertBefore(js, fjs); - }(document, 'script', 'facebook-jssdk')); - - "; - - e107::js('footer-inline', $head); + e107::js('footer-inline', SOCIAL_FACEBOOK_INIT); if(E107_DEBUG_LEVEL > 0) { diff --git a/e107_plugins/social/e_header.php b/e107_plugins/social/e_header.php index 3d371b26a..43c0a1084 100644 --- a/e107_plugins/social/e_header.php +++ b/e107_plugins/social/e_header.php @@ -14,7 +14,35 @@ if(USER_AREA) if(!empty($appID)) { e107::meta('fb:app_id', $appID); + + $init = " + + window.fbAsyncInit = function() { + FB.init({ + appId : '".$appID."', + xfbml : true, + version : 'v2.3' + }); + }; + + (function(d, s, id){ + var js, fjs = d.getElementsByTagName(s)[0]; + if (d.getElementById(id)) {return;} + js = d.createElement(s); js.id = id; + js.src = '//connect.facebook.net/en_US/sdk.js'; + fjs.parentNode.insertBefore(js, fjs); + }(document, 'script', 'facebook-jssdk')); + + "; + + define('SOCIAL_FACEBOOK_INIT', $init); + } + else + { + define('SOCIAL_FACEBOOK_INIT', false); + } + } diff --git a/e107_plugins/social/fb_like_menu.php b/e107_plugins/social/fb_like_menu.php new file mode 100644 index 000000000..12e33e009 --- /dev/null +++ b/e107_plugins/social/fb_like_menu.php @@ -0,0 +1,34 @@ +"; // prevent theme breakages. + $text .= '
'; + $text .= ""; + + e107::getRender()->tablerender('Facebook '.$theme,$text,'facebook-like-menu'); + +}elseif(ADMIN) +{ + $text = "
Unable to display feed. Facebook App ID has not been defined in preferences.
"; + e107::getRender()->tablerender('Facebook',$text,'twitter-menu'); +} \ No newline at end of file