mirror of
https://github.com/e107inc/e107.git
synced 2025-08-03 21:27:25 +02:00
Added Facebook Like Menu and corrected some FB.init issues.
This commit is contained in:
@@ -71,22 +71,27 @@ class social_ui extends e_admin_ui
|
|||||||
protected $fieldpref = array();
|
protected $fieldpref = array();
|
||||||
|
|
||||||
|
|
||||||
protected $preftabs = array("Sharing", 'Facebook Comments', 'Twitter Menu' );
|
protected $preftabs = array("Sharing", 'Facebook Comments', 'Facebook Menu', 'Twitter Menu', );
|
||||||
|
|
||||||
protected $prefs = array(
|
protected $prefs = array(
|
||||||
|
|
||||||
|
|
||||||
'facebook_comments_limit' => array('title'=> 'Limit', 'type'=>'number', 'tab'=>1, 'data' => 'int','help'=>'Number of tweets to display.'),
|
'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'=>''),
|
'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'),
|
'facebook_like_menu_theme' => array('title'=> 'Theme', 'type'=>'dropdown', 'tab'=>2, 'writeParms'=>array('optArray'=>array('light'=>'Light','dark'=>'Dark')), 'data' => 'str'),
|
||||||
'twitter_menu_limit' => array('title'=> 'Limit', 'type'=>'number', 'tab'=>2, 'data' => 'int','help'=>'Number of tweets to display.'),
|
'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_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_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'=>''),
|
'sharing_providers' => array('title'=> 'Providers', 'type'=>'checkboxes', 'tab'=>0, 'writeParms'=>array(), 'data' => 'str','help'=>''),
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
protected $social_logins = array();
|
protected $social_logins = array();
|
||||||
|
@@ -45,32 +45,12 @@ class social_comment
|
|||||||
function facebook($data)
|
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>";
|
return "<div class='alert alert-important alert-danger'>Unable to render comments. Missing Facebook appID.</div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
$head = "
|
e107::js('footer-inline', SOCIAL_FACEBOOK_INIT);
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
if(E107_DEBUG_LEVEL > 0)
|
if(E107_DEBUG_LEVEL > 0)
|
||||||
{
|
{
|
||||||
|
@@ -14,7 +14,35 @@ if(USER_AREA)
|
|||||||
if(!empty($appID))
|
if(!empty($appID))
|
||||||
{
|
{
|
||||||
e107::meta('fb:app_id', $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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
34
e107_plugins/social/fb_like_menu.php
Normal file
34
e107_plugins/social/fb_like_menu.php
Normal 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');
|
||||||
|
}
|
Reference in New Issue
Block a user