diff --git a/ps_sharebuttons.php b/ps_sharebuttons.php index 975f1c2..a8fc9ae 100644 --- a/ps_sharebuttons.php +++ b/ps_sharebuttons.php @@ -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; @@ -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'; } @@ -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))); @@ -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); } @@ -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'), + ], + ], + ]; } - 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) @@ -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, - ); + ]; } }