Files
wyczarujprezent.pl/modules/an_homeproducts/classes/anHomeProductFiles.php
Jacek Pyziak 64bcc1a6be Add new templates and update existing ones for An Home Products module
- Created new index.php files for various directories to establish structure.
- Added form.tpl and index.php for form helpers to enhance form handling.
- Introduced suggestions.tpl and top.tpl for improved admin interface.
- Implemented ajax-products.tpl and banners.tpl for front-end product display.
- Developed content.tpl and widget-blocks.tpl for dynamic content rendering.
- Enhanced widget-tabs.tpl and widget-wrapper.tpl for better tabbed navigation.
- Included necessary licensing information in all new files.
2025-05-16 14:21:29 +02:00

159 lines
3.7 KiB
PHP

<?php
/**
* 2024 Anvanto
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
*
* @author Anvanto <anvantoco@gmail.com>
* @copyright 2024 Anvanto
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
if (!defined('_PS_VERSION_')) {
exit;
}
class anHomeProductFiles
{
public function __construct()
{
$this->themeDir = Context::getContext()->shop->theme->getDirectory();
$this->themeName = Context::getContext()->shop->theme->getName();
$this->moduleDir = _PS_MODULE_DIR_ . 'an_homeslider/';
$this->fileJsonDir = $this->themeDir.'assets/antheme/an_homeproducts/';
$this->fileJsonBanners = $this->themeDir.'assets/antheme/an_homeproducts/banners.json';
$this->fileJsonblocks = $this->themeDir.'assets/antheme/an_homeproducts/blocks.json';
}
public function getJsonDirblocks()
{
return $this->getJsonDir() . 'blocks.json';
}
public function getJsonDirBanners()
{
return $this->getJsonDir() . 'banners.json';
}
public function getJsonDir()
{
$this->createFolders();
if (Tools::file_exists_no_cache($this->fileJsonDir)){
return $this->fileJsonDir;
}
return $this->moduleDir;
}
public function getJsonBannersPathFile()
{
if (Tools::file_exists_no_cache($this->fileJsonDir . 'banners.json')){
return Tools::file_get_contents($this->fileJsonDir . 'banners.json');
} else if (Tools::file_exists_no_cache($this->moduleDir . 'banners.json')){
return Tools::file_get_contents($this->moduleDir . 'banners.json');
}
return '';
}
public function getJsonBlocksPathFile()
{
if (Tools::file_exists_no_cache($this->fileJsonDir . 'blocks.json')){
return Tools::file_get_contents($this->fileJsonDir . 'blocks.json');
} else if (Tools::file_exists_no_cache($this->moduleDir . 'blocks.json')){
return Tools::file_get_contents($this->moduleDir . 'blocks.json');
}
return '';
}
public function createFolders()
{
$this->checkCreateFolder($this->fileJsonDir);
}
public function checkCreateFolder($path)
{
if (!Tools::file_exists_no_cache($path)){
mkdir($path, 0777, true);
Tools::copy($this->moduleDir . 'index.php', $path . 'index.php');
}
}
public function checkAndGetDir()
{
$this->createFoldersImg();
if (Tools::file_exists_no_cache($this->imgDir)){
return $this->imgDir;
} else if (Tools::file_exists_no_cache($this->imgDirOld)){
return $this->imgDirOld;
}
return '';
}
public function getUrlImg($imgName = '')
{
if ($imgName == ''){
return '';
}
if (Tools::file_exists_no_cache($this->imgDir.$imgName)){
return $this->imgUrl . $imgName;
} else if (Tools::file_exists_no_cache($this->imgDirOld.$imgName)){
return $this->imgUrlOld . $imgName;
}
return '';
}
public function getPathImg($imgName = '')
{
if ($imgName == ''){
return '';
}
if (Tools::file_exists_no_cache($this->imgDir.$imgName)){
return $this->imgDir . $imgName;
} else if (Tools::file_exists_no_cache($this->imgDirOld.$imgName)){
return $this->imgDirOld . $imgName;
}
return '';
}
public function deleteImg($imgName)
{
@unlink($this->imgDir . $imgName);
@unlink($this->imgDirOld . $imgName);
}
}