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

Some fixes for v4 #21

Merged
merged 2 commits into from Jul 17, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 11 additions & 0 deletions CONTRIBUTORS.md
@@ -0,0 +1,11 @@
GitHub contributors:
--------------------------------
- Alex Sampaio
- AlexEven
- Franck Lefebvre
- Julien Bourdeau
- Martin Fojtík
- Mathieu Ferment
- Mickaël Andrieu
- Maxime Biloé
- Pablo Polyte
11 changes: 5 additions & 6 deletions blockreassurance.php
Expand Up @@ -142,7 +142,6 @@ public function install()
$languages = Language::getLanguages(false);
include_once(dirname(__FILE__) . '/sql/install.php');

// register hook used by the module
if (parent::install() &&
$this->registerHook('displayAfterBodyOpeningTag') &&
$this->registerHook('displayNavFullWidth') &&
Expand Down Expand Up @@ -431,10 +430,10 @@ public function getWidgetVariables($hookName = null, array $configuration = [])

$elements = [];
foreach ($blocks as $key => $value) {
if (!empty($value['icone'])) {
$elements[$key]['image'] = $value['icone'];
} elseif (!empty($value['icone_perso'])) {
$elements[$key]['image'] = $value['icone_perso'];
if (!empty($value['icon'])) {
$elements[$key]['image'] = $value['icon'];
} elseif (!empty($value['custom_icon'])) {
$elements[$key]['image'] = $value['custom_icon'];
} else {
$elements[$key]['image'] = '';
}
Expand Down Expand Up @@ -483,7 +482,7 @@ private function renderTemplateInHook($template)

$this->context->smarty->assign(array(
'blocks' => ReassuranceActivity::getAllBlockByStatus($id_lang, $this->context->shop->id),
'iconeColor' => Configuration::get('PSR_ICON_COLOR'),
'iconColor' => Configuration::get('PSR_ICON_COLOR'),
'textColor' => Configuration::get('PSR_TEXT_COLOR'),
// constants
'LINK_TYPE_NONE' => ReassuranceActivity::TYPE_LINK_NONE,
Expand Down
8 changes: 4 additions & 4 deletions classes/ReassuranceActivity.php
Expand Up @@ -31,8 +31,8 @@ class ReassuranceActivity extends ObjectModel
const TYPE_LINK_URL = 2;

public $id;
public $icone;
public $icone_perso;
public $icon;
public $custom_icon;
public $title;
public $description;
public $status;
Expand All @@ -54,8 +54,8 @@ class ReassuranceActivity extends ObjectModel
'multilang' => true,
'multilang_shop' => true,
'fields' => array(
'icone' => array('type' => self::TYPE_STRING, 'shop' => true, 'validate' => 'isCleanHtml', 'size' => 255),
'icone_perso' => array('type' => self::TYPE_STRING, 'shop' => true, 'validate' => 'isCleanHtml', 'size' => 255),
'icon' => array('type' => self::TYPE_STRING, 'shop' => true, 'validate' => 'isCleanHtml', 'size' => 255),
'custom_icon' => array('type' => self::TYPE_STRING, 'shop' => true, 'validate' => 'isCleanHtml', 'size' => 255),
'title' => array('type' => self::TYPE_STRING, 'shop' => true, 'lang' => true, 'validate' => 'isCleanHtml', 'size' => 255),
'description' => array('type' => self::TYPE_HTML, 'shop' => true, 'lang' => true, 'validate' => 'isCleanHtml', 'size' => 2000),
'status' => array('type' => self::TYPE_BOOL, 'shop' => true, 'validate' => 'isBool', 'required' => true),
Expand Down
6 changes: 0 additions & 6 deletions composer.json
Expand Up @@ -16,12 +16,6 @@
"symfony/css-selector": "^3.4.0",
"guzzlehttp/cache-subscriber": "dev-master"
},
"repositories": [
{
"type": "vcs",
"url": "git@github.com:jolelievre/circuit-breaker.git"
}
],
"autoload": {
"psr-4": {
"PrestaShop\\Module\\BlockReassurance\\": "src/"
Expand Down
24 changes: 13 additions & 11 deletions controllers/admin/AdminBlockListingController.php
Expand Up @@ -27,7 +27,8 @@
class AdminBlockListingController extends ModuleAdminController
{
/**
* Update the status of a block
* Enable or disable a block
*
* @throws PrestaShopException
*/
public function ajaxProcessChangeBlockStatus()
Expand All @@ -48,7 +49,7 @@ public function ajaxProcessChangeBlockStatus()
}

/**
* Update position of a block
* Update how the blocks are displayed in the front-office
*
* @throws PrestaShopException
*/
Expand All @@ -57,7 +58,7 @@ public function ajaxProcessSavePositionByHook()
$hook = Tools::getValue('hook');
$value = Tools::getValue('value');

if (empty($hook) || empty($value)) {
if (empty($hook) || !in_array($value, array('0', '1'))) {
$this->ajaxDie(json_encode('error'));
}

Expand All @@ -67,7 +68,7 @@ public function ajaxProcessSavePositionByHook()
}

/**
* Update colors of a block
* Update color settings to be used in front-office display
*
* @throws PrestaShopException
*/
Expand All @@ -87,7 +88,7 @@ public function ajaxProcessSaveColor()
}

/**
* Update content of a block
* Modify the settings of one block from BO "configure" page
*
* @throws PrestaShopDatabaseException
* @throws PrestaShopException
Expand All @@ -105,9 +106,9 @@ public function ajaxProcessSaveBlockContent()
$blockPsr = new ReassuranceActivity($id_block);
$blockPsr->handleBlockValues($psr_languages, $type_link, $id_cms);

$blockPsr->icone = $picto;
$blockPsr->icon = $picto;
if (empty($picto)) {
$blockPsr->icone_perso = '';
$blockPsr->custom_icon = '';
}

$blockPsr->date_add = date("Y-m-d H:i:s");
Expand All @@ -122,8 +123,8 @@ public function ajaxProcessSaveBlockContent()
$validUpload = ImageManager::validateUpload($customImage);
if (is_bool($validUpload) && $validUpload === false) {
move_uploaded_file($fileTmpName, $this->module->folder_file_upload . $filename);
$blockPsr->icone_perso = $this->module->img_path_perso . '/' . $filename;
$blockPsr->icone = '';
$blockPsr->custom_icon = $this->module->img_path_perso . '/' . $filename;
$blockPsr->icon = '';
} else {
$errors[] = $validUpload;
$this->ajaxDie(json_encode($errors));
Expand All @@ -135,13 +136,14 @@ public function ajaxProcessSaveBlockContent()
}

/**
* Update the position of the reassurance blocks
* Reorder the blocks positions
*
* @return bool
*/
public function ajaxProcessUpdatePosition()
{
$blocks = Tools::getValue('blocks');

if (empty($blocks)) {
return false;
}
Expand All @@ -163,7 +165,7 @@ public function ajaxProcessUpdatePosition()
return false;
}
}

return true;
}
}
35 changes: 0 additions & 35 deletions docs/index.php

This file was deleted.

12 changes: 6 additions & 6 deletions sql/install.php
Expand Up @@ -32,8 +32,8 @@

$sql[] = ' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'psreassurance` (
`id_psreassurance` int(10) unsigned NOT NULL AUTO_INCREMENT,
`icone` varchar(255) NULL,
`icone_perso` varchar(255) NULL,
`icon` varchar(255) NULL,
`custom_icon` varchar(255) NULL,
`status` int(10) unsigned NOT NULL,
`position` int(10) unsigned NOT NULL,
`id_shop` int(10) unsigned NOT NULL,
Expand All @@ -54,11 +54,11 @@
PRIMARY KEY (`id_psreassurance`,`id_shop`,`id_lang`)
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=UTF8;';

$sqlInsertPSReassurance = "INSERT INTO "._DB_PREFIX_."psreassurance (id_psreassurance, icone, icone_perso, status, position, id_shop, type_link, id_cms, date_add) VALUES ";
$sqlInsertPSReassurance = "INSERT INTO "._DB_PREFIX_."psreassurance (id_psreassurance, icon, custom_icon, status, position, id_shop, type_link, id_cms, date_add) VALUES ";

$sql[] = $sqlInsertPSReassurance . "(1, '/PrestaShop/modules/blockreassurance/views/img/reassurance/pack2/security.svg', null, 1, 1, 1, null, null, now())";
$sql[] = $sqlInsertPSReassurance . "(2, '/PrestaShop/modules/blockreassurance/views/img/reassurance/pack2/carrier.svg', null, 1, 2, 1, null, null, now())";
$sql[] = $sqlInsertPSReassurance . "(3, '/PrestaShop/modules/blockreassurance/views/img/reassurance/pack2/parcel.svg', null, 1, 3, 1, null, null, now())";
$sql[] = $sqlInsertPSReassurance . "(1, '/modules/blockreassurance/views/img/reassurance/pack2/security.svg', null, 1, 1, 1, null, null, now())";
$sql[] = $sqlInsertPSReassurance . "(2, '/modules/blockreassurance/views/img/reassurance/pack2/carrier.svg', null, 1, 2, 1, null, null, now())";
$sql[] = $sqlInsertPSReassurance . "(3, '/modules/blockreassurance/views/img/reassurance/pack2/parcel.svg', null, 1, 3, 1, null, null, now())";

$sqlInsertPSReassuranceLang = "INSERT INTO "._DB_PREFIX_."psreassurance_lang (id_psreassurance, id_lang, id_shop, title, description, link) VALUES ";
foreach ($languages as $lang) {
Expand Down
13 changes: 6 additions & 7 deletions upgrade/upgrade-4.0.0.php
Expand Up @@ -29,12 +29,10 @@
}

/**
* This function updates your module from previous versions to the version 1.1,
* useful when you modify your database, or register a new hook ...
* Don't forget to create one file per version.
*
* @param $module
*
* @return bool|string
*
* @throws PrestaShopDatabaseException
* @throws PrestaShopException
*/
Expand Down Expand Up @@ -70,8 +68,8 @@ function upgrade_module_4_0_0($module)

$sql[] = ' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'psreassurance` (
`id_psreassurance` int(10) unsigned NOT NULL AUTO_INCREMENT,
`icone` varchar(255) NULL,
`icone_perso` varchar(255) NULL,
`icon` varchar(255) NULL,
`custom_icon` varchar(255) NULL,
`status` int(10) unsigned NOT NULL,
`position` int(10) unsigned NOT NULL,
`id_shop` int(10) unsigned NOT NULL,
Expand Down Expand Up @@ -105,7 +103,7 @@ function upgrade_module_4_0_0($module)
*/
if (!empty($reassurances)) {
foreach ($reassurances as $reassurance) {
$sql[] = "INSERT INTO "._DB_PREFIX_."psreassurance (id_psreassurance, icone, icone_perso, status, position, id_shop, type_link, id_cms, date_add)
$sql[] = "INSERT INTO "._DB_PREFIX_."psreassurance (id_psreassurance, icon, custom_icon, status, position, id_shop, type_link, id_cms, date_add)
VALUES (".$reassurance['id_reassurance'].", '".$module->old_path_img.$reassurance['file_name']."', null, 1, ".$reassurance['id_reassurance'].", ".$reassurance['id_shop'].", null, null, now())";
}
}
Expand Down Expand Up @@ -154,5 +152,6 @@ function upgrade_module_4_0_0($module)
Configuration::updateValue('PSR_TEXT_COLOR', '#000000');

unset($module);

return $result;
}
3 changes: 1 addition & 2 deletions views/js/front.js
Expand Up @@ -51,7 +51,7 @@ $(window).ready(function () {

// Check if the viewport is set, else we gonna set it if we can.
if (!$svg.attr('viewBox') && $svg.attr('height') && $svg.attr('width')) {
$svg.attr('viewBox', '0 0 ' + $svg.attr('height') + ' ' + $svg.attr('width'))
$svg.attr('viewBox', '0 0 ' + $svg.attr('height') + ' ' + $svg.attr('width'));
}

// Replace image with new SVG
Expand All @@ -60,7 +60,6 @@ $(window).ready(function () {
// set color of svg at load
$('.block-reassurance-item svg path').css('fill', psr_icon_color);

//$svg.attr('height', '35')
$('.block-reassurance-item svg')
.attr('height', '30')
.attr('width', '30');
Expand Down
4 changes: 2 additions & 2 deletions views/lib/pickr/css/index.php
@@ -1,6 +1,6 @@
<?php
/**
* 2007-2017 PrestaShop
* 2007-2019 PrestaShop
*
* NOTICE OF LICENSE
*
Expand All @@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2017 PrestaShop SA
* @copyright 2007-2019 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
Expand Down
4 changes: 2 additions & 2 deletions views/lib/pickr/index.php
@@ -1,6 +1,6 @@
<?php
/**
* 2007-2017 PrestaShop
* 2007-2019 PrestaShop
*
* NOTICE OF LICENSE
*
Expand All @@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2017 PrestaShop SA
* @copyright 2007-2019 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
Expand Down
4 changes: 2 additions & 2 deletions views/lib/pickr/js/index.php
@@ -1,6 +1,6 @@
<?php
/**
* 2007-2017 PrestaShop
* 2007-2019 PrestaShop
*
* NOTICE OF LICENSE
*
Expand All @@ -19,7 +19,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2017 PrestaShop SA
* @copyright 2007-2019 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
Expand Down
Expand Up @@ -34,7 +34,7 @@
<div class="col-xs-12 col-sm-12 col-md-7 col-lg-4 first-block">
<div class="psr_picto_showing input-group col-lg-4">
<img class="psr-picto picto_by_module svg"
src="{if $aBlock['icone']}{$aBlock['icone']}{elseif $aBlock['icone_perso']}{$aBlock['icone_perso']}{/if}"/>
src="{if $aBlock['icon']}{$aBlock['icon']}{elseif $aBlock['custom_icon']}{$aBlock['custom_icon']}{/if}"/>
<div>
<i class="material-icons landscape">landscape</i>
</div>
Expand Down
4 changes: 2 additions & 2 deletions views/templates/admin/tabs/content/listing.tpl
Expand Up @@ -47,9 +47,9 @@
<i class="material-icons">drag_indicator</i>
</div>
<div class="col-lg-1 col-xs-1 resize">
{if $aBlock['icone'] != 'undefined'}
{if $aBlock['icon'] != 'undefined'}
<img class="svg"
src="{if $aBlock['icone']}{$aBlock['icone']}{else if $aBlock['icone_perso']}{$aBlock['icone_perso']}{/if}"
src="{if $aBlock['icon']}{$aBlock['icon']}{else if $aBlock['custom_icon']}{$aBlock['custom_icon']}{/if}"
/>
{else}
{l s='none' mod='psreassurance'}
Expand Down
4 changes: 2 additions & 2 deletions views/templates/hook/blockreassurance.tpl
@@ -1,5 +1,5 @@
{*
* 2007-2015 PrestaShop
* 2007-2019 PrestaShop
*
* NOTICE OF LICENSE
*
Expand All @@ -18,7 +18,7 @@
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2015 PrestaShop SA
* @copyright 2007-2019 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
Expand Down
4 changes: 2 additions & 2 deletions views/templates/hook/displayBlock.tpl
Expand Up @@ -27,8 +27,8 @@
<div class="reass-item" style="{if $block['type_link'] !== $LINK_TYPE_NONE && !empty($block['link'])}cursor:pointer;{/if}"
{if ($block['type_link'] !== $LINK_TYPE_NONE) && !empty($block['link'])} onclick="window.open('{$block['link']}')"{/if}>
<div class="block-icon">
{if $block['icone'] != 'undefined'}
<img class="svg" src="{if $block['icone']}{$block['icone']}{elseif $block['icone_perso']}{$block['icone_perso']}{/if}" />
{if $block['icon'] != 'undefined'}
<img class="svg" src="{if $block['icon']}{$block['icon']}{elseif $block['custom_icon']}{$block['custom_icon']}{/if}" />
{/if}
</div>
<div class="block-title" style="color:{$textColor}">{$block['title']}</div>
Expand Down