Skip to content

Commit

Permalink
cover some additional options for a plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
kpodemski committed Nov 21, 2018
1 parent 3ee0515 commit e57b40b
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 49 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = function(grunt) {
compress: {
main: {
options: {
archive: moduleName + '-v' + version + '.zip'
archive: moduleName + '-latest.zip'
},
files: [
{src: ['controllers/**'], dest: moduleName + '/', filter: 'isFile'},
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

### How to use?

- [ ] Download module from: https://goo.gl/grFfBs
- [ ] Download module from: https://goo.gl/6iNRkG
- [ ] Get your Facebook Page ID by going to https://findmyfbid.com
- [ ] Install module from Modules tab
- [ ] Go to the Configuration page of module
Expand Down
Binary file renamed phfbchat-v1.0.1.zip → phfbchat-latest.zip
Binary file not shown.
58 changes: 38 additions & 20 deletions phfbchat.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __construct()
{
$this->name = 'phfbchat';
$this->tab = 'front_office_features';
$this->version = '1.0.1';
$this->version = '1.1.0';
$this->author = 'PrestaHome';
$this->need_instance = 0;
$this->bootstrap = true;
Expand Down Expand Up @@ -122,7 +122,7 @@ public function renderConfigurationForm()
'type' => 'html',
'html_content' => '
<div class="alert alert-info">
'.$this->l('To use Messanger Chat you need to add your full domain to allowed ones by going to: FB Page -> Settings -> Messanger -> White-listed domains').'
'.$this->l('To use Messenger Chat you need to add your full domain to allowed ones by going to: FB Page -> Settings -> Messanger -> White-listed domains').'
</div>'
,
'ignore' => true
Expand All @@ -131,44 +131,59 @@ public function renderConfigurationForm()
array(
'type' => 'text',
'lang' => false,
'label' => $this->l('App ID:'),
'name' => $this->options_prefix.'APP_ID',
'label' => $this->l('Page ID:'),
'name' => $this->options_prefix.'PAGE_ID',
'default' => '',
'desc' => $this->l('More informations: https://developers.facebook.com/docs/apps/register'),
'desc' => $this->l('You can use https://findmyfbid.com/ to find your FB Page ID'),
'validate' => 'isUnsignedInt',
),

array(
'type' => 'text',
'lang' => false,
'label' => $this->l('Page ID:'),
'name' => $this->options_prefix.'PAGE_ID',
'lang' => true,
'label' => $this->l('Logged in message:'),
'name' => $this->options_prefix.'LOGGED_IN',
'default' => '',
'desc' => $this->l('You can use https://findmyfbid.com/ to find your FB Page ID'),
'validate' => 'isUnsignedInt',
'desc' => $this->l('The message displayed on the chat box for logged in users, leave empty to display default text'),
'validate' => 'isAnything',
),

array(
'type' => 'text',
'lang' => true,
'label' => $this->l('Language code:'),
'name' => $this->options_prefix.'LOCALE',
'label' => $this->l('Logged out message:'),
'name' => $this->options_prefix.'LOGGED_OUT',
'default' => '',
'desc' => $this->l('For eg. pl_PL, en_EN, more informations: https://developers.facebook.com/docs/internationalization'),
'desc' => $this->l('The message displayed on the chat box for logged out users, leave empty to display default text'),
'validate' => 'isAnything',
),

array(
'type' => 'color',
'label' => $this->l('Theme color:'),
'name' => $this->options_prefix.'THEME_COLOR',
'default' => '#0084FF',
'desc' => $this->l('The color of the chat bubble theme'),
'validate' => 'isAnything',
),
array(
'type' => 'text',
'label' => $this->l('Dialog delay:'),
'name' => $this->options_prefix.'DIALOG_DELAY',
'default' => '0',
'desc' => $this->l('The amount of seconds the dialog stays open.'),
'validate' => 'isUnsignedInt',
),
array(
'name' => 'separator',
'type' => 'html',
'html_content' => '<h2>'.$this->l('Troubleshooting').'</h2>',
'html_content' => '<h2>'.$this->l('Troubleshooting').'</h2><div class="alert alert-info">'.$this->l('If you have any issues create new ticket on https://github.com/kpodemski/phfbchat/issues').'</div>',
'ignore' => true
),

array(
'type' => 'switch',
'label' => $this->l('Initialize Facebook API?'),
'name' => $this->options_prefix.'FB_API',
'desc' => $this->l('From 1.1.0 there is not really a chance that you\'d like to turn off this option.'),
'values' => array(
array(
'id' => 'active_on',
Expand Down Expand Up @@ -204,10 +219,13 @@ public function renderConfigurationForm()
public function hookDisplayFooter()
{
$this->context->smarty->assign(array(
'phfbchat_page_id' => Configuration::get($this->options_prefix.'PAGE_ID'),
'phfbchat_app_id' => Configuration::get($this->options_prefix.'APP_ID'),
'phfbchat_locale' => Configuration::get($this->options_prefix.'LOCALE', (int) $this->context->language->id),
'phfbchat_init' => Configuration::get($this->options_prefix.'FB_API', (int) $this->context->language->id),
'phfbchat_page_id' => Configuration::get($this->options_prefix.'PAGE_ID'),
'phfbchat_locale' => Configuration::get($this->options_prefix.'LOCALE', (int) $this->context->language->id),
'phfbchat_init' => Configuration::get($this->options_prefix.'FB_API'),
'phfbchat_logged_in' => Configuration::get($this->options_prefix.'LOGGED_IN', (int) $this->context->language->id),
'phfbchat_logged_out' => Configuration::get($this->options_prefix.'LOGGED_OUT', (int) $this->context->language->id),
'phfbchat_theme_color' => Configuration::get($this->options_prefix.'THEME_COLOR'),
'phfbchat_greeting_dialog_delay' => Configuration::get($this->options_prefix.'DIALOG_DELAY'),
));

if (version_compare(_PS_VERSION_, '1.7', '>=')) {
Expand Down
50 changes: 23 additions & 27 deletions views/templates/hook/footer.tpl
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
{if $phfbchat_init}
<script>
(function (d) {ldelim}
var js, id = 'facebook-jssdk';
if (d.getElementById(id)) {ldelim}
return;
{rdelim}
js = d.createElement('script');
js.id = id;
js.async = true;
js.src = "//connect.facebook.net/{$phfbchat_locale}/sdk/xfbml.customerchat.js";
d.getElementsByTagName('head')[0].appendChild(js);
{rdelim}(document));
<div id="fb-root"></div>
{/if}
<script>(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 = 'https://connect.facebook.net/{$phfbchat_locale}/sdk/xfbml.customerchat.js#xfbml=1&version=v2.12&autoLogAppEvents=1';
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

window.fbAsyncInit = function () {ldelim}
FB.init({ldelim}
appId: {$phfbchat_app_id},
autoLogAppEvents : true,
xfbml : true,
version : 'v3.1'
{rdelim});
{rdelim};
</script>
<div class="fb-customerchat"
page_id="{$phfbchat_page_id}"
{if $phfbchat_logged_in}
logged_in_greeting="{$phfbchat_logged_in}"
{/if}
{if $phfbchat_logged_out}
logged_out_greeting="{$phfbchat_logged_out}"
{/if}
{if $phfbchat_theme_color}
theme_color="{$phfbchat_theme_color}"
{/if}
{if $phfbchat_greeting_dialog_delay}
greeting_dialog_delay="{$phfbchat_greeting_dialog_delay}"
{/if}
<div
class="fb-customerchat"
page_id="{$phfbchat_page_id}"
ref="website"
minimized="true"
></div>
></div>

0 comments on commit e57b40b

Please sign in to comment.