-
Notifications
You must be signed in to change notification settings - Fork 3
/
mdn_webp.php
71 lines (63 loc) · 2.23 KB
/
mdn_webp.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
require 'vendor/autoload.php';
if (!defined('_PS_VERSION_')) {
exit;
}
require_once _PS_MODULE_DIR_ . '/mdn_webp/utils/SmartyExtension.php';
require_once _PS_MODULE_DIR_ . '/mdn_webp/utils/ConvertToWebp.php';
require_once _PS_MODULE_DIR_ . '/mdn_webp/utils/InstallFixs.php';
class Mdn_webp extends Module {
public function __construct()
{
$this->displayName = "MDN - WebP Support";
$this->name = 'mdn_webp';
$this->author = 'Maison du Net - Loris';
$this->tab = 'front_office_features';
$this->version = '1.0.1';
$this->bootstrap = true;
$this->need_instance = 0;
$this->ps_versions_compliancy = array('min' => '1.7.7.0', 'max' => _PS_VERSION_);
$this->tabs = [
[
'name' => [
'en' => 'WebP'
],
'class_name' => 'WebP',
'parent_class_name' => 'IMPROVE',
'route_name' => 'webp_home'
],
];
parent::__construct();
}
public function install()
{
return parent::install()
&& $this->registerHook("actionDispatcher")
&& $this->registerHook("actionWatermark")
&& $this->registerHook("actionAfterCreateCategoryFormHandler")
&& $this->registerHook("actionAfterUpdateCategoryFormHandler")
&& InstallFixs::installHtaccess()
&& InstallFixs::addWebPSupportImg();
}
public function hookActionWatermark($params) {
$image = new Image($params['id_image']);
$url = ConvertToWebp::doForProductImage($image->getImgPath());
}
public function hookActionAfterUpdateCategoryFormHandler($params) {
$category_id = $params['id'];
ConvertToWebp::doForCategory($category_id);
}
public function hookActionAfterCreateCategoryFormHandler($params) {
$category_id = $params['id'];
ConvertToWebp::doForCategory($category_id);
}
public function uninstall()
{
return parent::uninstall()
&& InstallFixs::uninstallHtaccess();
}
public function hookActionDispatcher()
{
$this->context->smarty->registerPlugin('modifier', 'webp', array('SmartyExtension', 'webp'));
}
}