1
0
mirror of https://github.com/e107inc/e107.git synced 2025-04-16 02:26:25 +02:00

Added Facebook Like Menu and corrected some FB.init issues.

This commit is contained in:
Cameron 2015-06-02 13:17:52 -07:00
parent 4eb9f7884f
commit efe6f27c46
4 changed files with 74 additions and 27 deletions

View File

@ -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();

View File

@ -45,32 +45,12 @@ class social_comment
function facebook($data)
{
if(empty($this->facebookActive))
if(!deftrue('SOCIAL_FACEBOOK_INIT'))
{
return "<div class='alert alert-important alert-danger'>Unable to render comments. Missing Facebook appID.</div>";
}
$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)
{

View File

@ -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);
}
}

View File

@ -0,0 +1,34 @@
<?php
/**
* e107 website system
*
* Copyright (C) 2008-2015 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*/
//@see https://developers.facebook.com/docs/plugins/like-button
if(deftrue('SOCIAL_FACEBOOK_INIT') )
{
e107::js('footer-inline', SOCIAL_FACEBOOK_INIT); // defined in e_header.php
$pref = e107::pref('social');
$action = vartrue($pref['facebook_like_menu_action'], 'like'); // or 'recommend';
$layout = vartrue($pref['facebook_like_menu_layout'], 'standard'); // standard, button_count, button or box_count.
$width = vartrue($pref['facebook_like_menu_width'], 150);
$theme = vartrue($pref['facebook_like_menu_theme'], 'light');
$text = "<div style='overflow:hidden'>"; // prevent theme breakages.
$text .= '<div class="fb-like" data-href="'.SITEURL.'" data-width="'.$width.'px" data-layout="'.$layout.'" data-colorscheme="'.$theme.'" data-action="'.$action.'" data-show-faces="true" data-share="true"></div>';
$text .= "</div>";
e107::getRender()->tablerender('Facebook '.$theme,$text,'facebook-like-menu');
}elseif(ADMIN)
{
$text = "<div class='alert alert-danger'>Unable to display feed. Facebook App ID has not been defined in preferences.</div>";
e107::getRender()->tablerender('Facebook',$text,'twitter-menu');
}