Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Short array syntax #18

Merged
merged 3 commits into from Feb 24, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
76 changes: 38 additions & 38 deletions ps_sharebuttons.php
Expand Up @@ -32,7 +32,7 @@

class Ps_Sharebuttons extends Module implements WidgetInterface
{
protected static $networks = array('Facebook', 'Twitter', 'Pinterest');
protected static $networks = ['Facebook', 'Twitter', 'Pinterest'];

private $templateFile;

Expand All @@ -43,14 +43,14 @@ public function __construct()
$this->version = '2.0.1';
$this->need_instance = 0;

$this->ps_versions_compliancy = array('min' => '1.7.1.0', 'max' => _PS_VERSION_);
$this->ps_versions_compliancy = ['min' => '1.7.1.0', 'max' => _PS_VERSION_];
$this->_directory = dirname(__FILE__);

$this->bootstrap = true;
parent::__construct();

$this->displayName = $this->trans('Social media share buttons', array(), 'Modules.Sharebuttons.Admin');
$this->description = $this->trans('Displays social media sharing buttons (Twitter, Facebook and Pinterest) on every product page.', array(), 'Modules.Sharebuttons.Admin');
$this->displayName = $this->trans('Social media share buttons', [], 'Modules.Sharebuttons.Admin');
$this->description = $this->trans('Displays social media sharing buttons (Twitter, Facebook and Pinterest) on every product page.', [], 'Modules.Sharebuttons.Admin');

$this->templateFile = 'module:ps_sharebuttons/views/templates/hook/ps_sharebuttons.tpl';
}
Expand All @@ -67,7 +67,7 @@ public function install()

public function getConfigFieldsValues()
{
$values = array();
$values = [];

foreach (self::$networks as $network) {
$values['PS_SC_'.Tools::strtoupper($network)] = (int) Tools::getValue('PS_SC_'.Tools::strtoupper($network), Configuration::get('PS_SC_'.Tools::strtoupper($network)));
Expand All @@ -86,7 +86,7 @@ public function getContent()

$this->_clearCache($this->templateFile);

$output .= $this->displayConfirmation($this->trans('Settings updated.', array(), 'Admin.Notifications.Success'));
$output .= $this->displayConfirmation($this->trans('Settings updated.', [], 'Admin.Notifications.Success'));

Tools::redirectAdmin($this->context->link->getAdminLink('AdminModules', true).'&conf=6&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name);
}
Expand All @@ -95,43 +95,43 @@ public function getContent()
$helper->submit_action = 'submitSocialSharing';
$helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name;
$helper->token = Tools::getAdminTokenLite('AdminModules');
$helper->tpl_vars = array('fields_value' => $this->getConfigFieldsValues());
$helper->tpl_vars = ['fields_value' => $this->getConfigFieldsValues()];

$fields = array();
$fields = [];
foreach (self::$networks as $network) {
$fields[] = array(
$fields[] = [
'type' => 'switch',
'label' => $network,
'name' => 'PS_SC_'.Tools::strtoupper($network),
'values' => array(
array(
'values' => [
[
'id' => Tools::strtolower($network).'_active_on',
'value' => 1,
'label' => $this->trans('Enabled', array(), 'Admin.Global'),
),
array(
'label' => $this->trans('Enabled', [], 'Admin.Global'),
],
[
'id' => Tools::strtolower($network).'_active_off',
'value' => 0,
'label' => $this->trans('Disabled', array(), 'Admin.Global'),
),
'label' => $this->trans('Disabled', [], 'Admin.Global'),
],
),
);
matks marked this conversation as resolved.
Show resolved Hide resolved
}

return $output.$helper->generateForm(array(
array(
'form' => array(
'legend' => array(
return $output.$helper->generateForm([
[
'form' => [
'legend' => [
'title' => $this->displayName,
'icon' => 'icon-share',
),
],
'input' => $fields,
'submit' => array(
'title' => $this->trans('Save', array(), 'Admin.Actions'),
),
),
),
));
'submit' => [
'title' => $this->trans('Save', [], 'Admin.Actions'),
],
],
],
]);
}

public function renderWidget($hookName, array $params)
Expand Down Expand Up @@ -174,31 +174,31 @@ public function getWidgetVariables($hookName, array $params)
$sharing_img = addcslashes($this->context->link->getImageLink($product->link_rewrite, $image_cover_id), "'");

if (Configuration::get('PS_SC_FACEBOOK')) {
$social_share_links['facebook'] = array(
'label' => $this->trans('Share', array(), 'Modules.Sharebuttons.Shop'),
$social_share_links['facebook'] = [
'label' => $this->trans('Share', [], 'Modules.Sharebuttons.Shop'),
'class' => 'facebook',
'url' => 'http://www.facebook.com/sharer.php?u='.$sharing_url,
);
];
}

if (Configuration::get('PS_SC_TWITTER')) {
$social_share_links['twitter'] = array(
'label' => $this->trans('Tweet', array(), 'Modules.Sharebuttons.Shop'),
$social_share_links['twitter'] = [
'label' => $this->trans('Tweet', [], 'Modules.Sharebuttons.Shop'),
'class' => 'twitter',
'url' => 'https://twitter.com/intent/tweet?text='.$sharing_name.' '.$sharing_url,
);
];
}

if (Configuration::get('PS_SC_PINTEREST')) {
$social_share_links['pinterest'] = array(
'label' => $this->trans('Pinterest', array(), 'Modules.Sharebuttons.Shop'),
$social_share_links['pinterest'] = [
'label' => $this->trans('Pinterest', [], 'Modules.Sharebuttons.Shop'),
'class' => 'pinterest',
'url' => 'http://www.pinterest.com/pin/create/button/?media='.$sharing_img.'&url='.$sharing_url,
);
];
}

return array(
return [
'social_share_links' => $social_share_links,
);
];
}
}