First version template
This commit is contained in:
18
psmodule/composer.json
Normal file
18
psmodule/composer.json
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "websmid/psmodule",
|
||||
"description": "",
|
||||
"type": "prestashop-module",
|
||||
"license": "mit",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Websmid\\PsModule": "src/"
|
||||
}
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "George van Engers",
|
||||
"email": "george@dewebsmid.nl"
|
||||
}
|
||||
],
|
||||
"minimum-stability": "dev"
|
||||
}
|
||||
6
psmodule/config/services.yml
Normal file
6
psmodule/config/services.yml
Normal file
@ -0,0 +1,6 @@
|
||||
imports:
|
||||
- { resource: services/*.yml }
|
||||
|
||||
services:
|
||||
_defaults:
|
||||
public: true
|
||||
3
psmodule/config/services/event_listener.yml
Normal file
3
psmodule/config/services/event_listener.yml
Normal file
@ -0,0 +1,3 @@
|
||||
services:
|
||||
_defaults:
|
||||
public: true
|
||||
BIN
psmodule/logo.gif
Normal file
BIN
psmodule/logo.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1004 B |
BIN
psmodule/logo.png
Normal file
BIN
psmodule/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.5 KiB |
34
psmodule/override/index.php
Normal file
34
psmodule/override/index.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2024 PrestaShop
|
||||
*
|
||||
* 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@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2024 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property 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;
|
||||
64
psmodule/psmodule.php
Normal file
64
psmodule/psmodule.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2025 PrestaShop
|
||||
*
|
||||
* 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@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2025 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
use Websmid\Muller\WsMullerModule\Module\Helper\Config;
|
||||
use Websmid\Muller\WsMullerModule\Module\Helper\ConfigForm;
|
||||
use Websmid\Muller\WsMullerModule\Module\Helper\Install;
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
class psmodule extends Module
|
||||
{
|
||||
// use hooks
|
||||
use Config;
|
||||
use Install;
|
||||
use ConfigForm;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->name = 'psmodule';
|
||||
$this->tab = 'administration';
|
||||
$this->version = '0.0.1';
|
||||
$this->author = 'George van Engers | De Websmid';
|
||||
$this->need_instance = 0;
|
||||
$this->ps_versions_compliancy = [
|
||||
'min' => '8.2.0',
|
||||
'max' => _PS_VERSION_,
|
||||
];
|
||||
$this->bootstrap = true;
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->displayName = $this->trans('Ps Module', [], 'Modules.PsModule.Module');
|
||||
$this->description = $this->trans('Ps Module', [], 'Modules.PsModule.Module');
|
||||
|
||||
$this->confirmUninstall = $this->trans('Are you sure you want to uninstall?', [], 'Modules.PsModule.Module');
|
||||
}
|
||||
}
|
||||
14
psmodule/src/Module/Helper/Config.php
Normal file
14
psmodule/src/Module/Helper/Config.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Websmid\Muller\WsMullerModule\Module\Helper;
|
||||
|
||||
trait Config
|
||||
{
|
||||
public static $hooks = [
|
||||
|
||||
];
|
||||
|
||||
public static $config = [
|
||||
'TEST' => 'test',
|
||||
];
|
||||
}
|
||||
120
psmodule/src/Module/Helper/ConfigForm.php
Normal file
120
psmodule/src/Module/Helper/ConfigForm.php
Normal file
@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace Websmid\Muller\WsMullerModule\Module\Helper;
|
||||
|
||||
use Configuration;
|
||||
use HelperForm;
|
||||
use Tools;
|
||||
|
||||
trait ConfigForm
|
||||
{
|
||||
protected $config_form = false;
|
||||
public array $translatables = [];
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @author George van Engers <george@dewebsmid.nl>
|
||||
* @since 05-04-2025
|
||||
*/
|
||||
public function getContent(): string
|
||||
{
|
||||
if ((Tools::isSubmit($this->name . 'submitBtn'))) {
|
||||
$this->postProcess();
|
||||
}
|
||||
$this->context->smarty->assign('module_dir', $this->_path);
|
||||
|
||||
$output = $this->context->smarty->fetch($this->local_path.'views/templates/admin/index.tpl');;
|
||||
|
||||
return $output.$this->renderForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @author George van Engers <george@dewebsmid.nl>
|
||||
* @since 05-04-2025
|
||||
*/
|
||||
protected function renderForm(): string
|
||||
{
|
||||
$helper = new HelperForm();
|
||||
|
||||
$helper->show_toolbar = false;
|
||||
$helper->table = $this->table;
|
||||
$helper->module = $this;
|
||||
$helper->name_controller = $this->name;
|
||||
$helper->default_form_language = $this->context->language->id;
|
||||
$helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG', 0);
|
||||
|
||||
$helper->identifier = $this->identifier;
|
||||
$helper->submit_action = $this->name.'submitBtn';
|
||||
$helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false)
|
||||
.'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name;
|
||||
$helper->token = Tools::getValue('token');
|
||||
|
||||
$helper->tpl_vars = array(
|
||||
'fields_value' => $this->getConfigFormValues(), /* Add values for your inputs */
|
||||
'languages' => $this->context->controller->getLanguages(),
|
||||
'id_language' => $this->context->language->id,
|
||||
);
|
||||
|
||||
return $helper->generateForm($this->getConfigForm());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @author George van Engers <george@dewebsmid.nl>
|
||||
* @since 05-04-2025
|
||||
*/
|
||||
protected function getConfigFormValues(): array
|
||||
{
|
||||
$data = [];
|
||||
foreach(self::$config as $key => $value) {
|
||||
$data[$key] = Configuration::get($key);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @author George van Engers <george@dewebsmid.nl>
|
||||
* @since 05-04-2025
|
||||
*/
|
||||
protected function postProcess(): void
|
||||
{
|
||||
$form_values = $this->getConfigFormValues();
|
||||
|
||||
foreach (array_keys($form_values) as $key) {
|
||||
if (Tools::isSubmit($key)) {
|
||||
Configuration::updateValue($key, Tools::getValue($key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
* @author George van Engers <george@dewebsmid.nl>
|
||||
* @since 05-04-2025
|
||||
*/
|
||||
protected function getConfigForm(): array
|
||||
{
|
||||
return array(
|
||||
'api' => array(
|
||||
'form' => array(
|
||||
'legend' => array(
|
||||
'title' => $this->trans('Settings', [], 'Modules.PsModule.Module'),
|
||||
'icon' => 'icon-cogs',
|
||||
),
|
||||
'input' => array(
|
||||
/////
|
||||
/////
|
||||
/////
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->trans('Save', [], 'Modules.PsModule.Module'),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
55
psmodule/src/Module/Helper/Install.php
Normal file
55
psmodule/src/Module/Helper/Install.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace Websmid\Muller\WsMullerModule\Module\Helper;
|
||||
|
||||
use Configuration;
|
||||
|
||||
trait Install
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
* @author George van Engers <george@dewebsmid.nl>
|
||||
* @since 05-04-2025
|
||||
*/
|
||||
public function install()
|
||||
{
|
||||
if (!parent::install()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach(self::$hooks as $hook) {
|
||||
if (!$this->registerHook($hook)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
foreach(self::$config as $key => $value) {
|
||||
if (!Configuration::updateValue($key, $value)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
* @author George van Engers <george@dewebsmid.nl>
|
||||
* @since 05-04-2025
|
||||
*/
|
||||
public function uninstall()
|
||||
{
|
||||
if (!parent::uninstall()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// hooks are auto-unregistered by PrestaShop
|
||||
|
||||
foreach(self::$config as $key => $value) {
|
||||
if (!Configuration::deleteByName($key)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
34
psmodule/src/index.php
Normal file
34
psmodule/src/index.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2024 PrestaShop
|
||||
*
|
||||
* 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@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2024 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property 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;
|
||||
34
psmodule/translations/index.php
Normal file
34
psmodule/translations/index.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2024 PrestaShop
|
||||
*
|
||||
* 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@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2024 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property 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;
|
||||
34
psmodule/upgrade/index.php
Normal file
34
psmodule/upgrade/index.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2024 PrestaShop
|
||||
*
|
||||
* 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@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2024 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property 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;
|
||||
34
psmodule/views/index.php
Normal file
34
psmodule/views/index.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2024 PrestaShop
|
||||
*
|
||||
* 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@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2024 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property 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;
|
||||
0
psmodule/views/templates/admin/index.tpl
Normal file
0
psmodule/views/templates/admin/index.tpl
Normal file
Reference in New Issue
Block a user