Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Save images inside /img/homeslider directory
Module directory is not the right place to store slide image files. That is because tbupdater module always wipes out module directory during module update. This causes data loss. This new implementation uploads images into /img/homeslider/ directory instead. Closes #3 Related to thirtybees/thirtybees#922
- Loading branch information
1 parent
a800903
commit 73c1fa1
Showing
16 changed files
with
326 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[ | ||
{ | ||
"image": "sample-1.jpg", | ||
"title": "Shop Tea", | ||
"legend": "Shop Tea", | ||
"description": "<h3 style=\"float:left;clear:both;font-size:30px;\">Shop Tea</h3><p style=\"text-align:center;margin-top:20px;\"><button class=\"btn btn-default\" type=\"button\">Shop now !</button></p>" | ||
}, | ||
{ | ||
"image": "sample-2.jpg", | ||
"title": "Soaps", | ||
"legend": "Soaps", | ||
"description": "<h3 style=\"float:left;clear:both;font-size:30px;\">View All Soaps</h3><p style=\"text-align:center;margin-top:20px;\"><button class=\"btn btn-default\" type=\"button\">Shop now !</button></p>" | ||
}, | ||
{ | ||
"image": "sample-3.jpg", | ||
"title": "Gifts", | ||
"legend": "Gifts", | ||
"description": "<h3 style=\"float:left;clear:both;font-size:30px;\">Shop Gifts</h3><p style=\"text-align:center;margin-top:20px;\"><button class=\"btn btn-default\" type=\"button\">Shop now !</button></p>" | ||
} | ||
] |
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
/** | ||
* Copyright (C) 2017-2019 thirty bees | ||
* Copyright (C) 2007-2016 PrestaShop SA | ||
* | ||
* thirty bees is an extension to the PrestaShop software by PrestaShop SA. | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Academic Free License (AFL 3.0) | ||
* that is bundled with this package in the file LICENSE.md. | ||
* It is also available through the world-wide-web at this URL: | ||
* https://opensource.org/licenses/afl-3.0.php | ||
* If you did not receive a copy of the license and are unable to | ||
* obtain it through the world-wide-web, please send an email | ||
* to license@thirtybees.com so we can send you a copy immediately. | ||
* | ||
* @author thirty bees <modules@thirtybees.com> | ||
* @author PrestaShop SA <contact@prestashop.com> | ||
* @copyright 2017-2019 thirty bees | ||
* @copyright 2007-2016 PrestaShop SA | ||
* @license Academic Free License (AFL 3.0) | ||
* PrestaShop is an internationally registered trademark of PrestaShop SA. | ||
*/ | ||
|
||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); | ||
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); | ||
|
||
header('Cache-Control: no-store, no-cache, must-revalidate'); | ||
header('Cache-Control: post-check=0, pre-check=0', false); | ||
header('Pragma: no-cache'); | ||
|
||
header('Location: ../'); | ||
|
||
exit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
/** | ||
* 2007-2016 PrestaShop | ||
* | ||
* thirty bees is an extension to the PrestaShop e-commerce software developed by PrestaShop SA | ||
* Copyright (C) 2017-2018 thirty bees | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Academic Free License (AFL 3.0) | ||
* that is bundled with this package in the file LICENSE.txt. | ||
* It is also available through the world-wide-web at this URL: | ||
* http://opensource.org/licenses/afl-3.0.php | ||
* If you did not receive a copy of the license and are unable to | ||
* obtain it through the world-wide-web, please send an email | ||
* to license@thirtybees.com so we can send you a copy immediately. | ||
* | ||
* @author thirty bees <modules@thirtybees.com> | ||
* @author PrestaShop SA <contact@prestashop.com> | ||
* @copyright 2017-2018 thirty bees | ||
* @copyright 2007-2016 PrestaShop SA | ||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) | ||
* PrestaShop is an internationally registered trademark & property of PrestaShop SA | ||
*/ | ||
|
||
if (!defined('_TB_VERSION_')) { | ||
exit; | ||
} | ||
|
||
/** | ||
* Copy all image files referenced in the database to the /img/homeslider/ directory | ||
* | ||
* @return bool | ||
* | ||
* @throws PrestaShopDatabaseException | ||
* @throws PrestaShopException | ||
*/ | ||
function upgrade_module_2_1_0() | ||
{ | ||
$sourceDir = __DIR__ . '/../images/'; | ||
$targetDir = HomeSlider::getImageDir(); | ||
if (file_exists($sourceDir)) { | ||
|
||
// find images from the database | ||
$images = array_column(Db::getInstance()->executeS((new DbQuery()) | ||
->select('DISTINCT(image) as image') | ||
->from('homeslider_slides_lang') | ||
), 'image'); | ||
|
||
// copy them to destination | ||
foreach ($images as $image) { | ||
if (file_exists($sourceDir . $image)) { | ||
if (! file_exists($targetDir . $image)) { | ||
copy($sourceDir . $image, $targetDir . $image); | ||
} | ||
} | ||
} | ||
} | ||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters