|
1
|
|
|
<?php |
|
2
|
|
|
/*************************************************************************************/ |
|
3
|
|
|
/* This file is part of the module FeatureType */ |
|
4
|
|
|
/* */ |
|
5
|
|
|
/* Copyright (c) OpenStudio */ |
|
6
|
|
|
/* email : [email protected] */ |
|
7
|
|
|
/* web : http://www.thelia.net */ |
|
8
|
|
|
/* */ |
|
9
|
|
|
/* For the full copyright and license information, please view the LICENSE.txt */ |
|
10
|
|
|
/* file that was distributed with this source code. */ |
|
11
|
|
|
/*************************************************************************************/ |
|
12
|
|
|
|
|
13
|
|
|
namespace FeatureType; |
|
14
|
|
|
|
|
15
|
|
|
use Propel\Runtime\Connection\ConnectionInterface; |
|
16
|
|
|
use Symfony\Component\Finder\Finder; |
|
17
|
|
|
use Thelia\Core\Template\TemplateDefinition; |
|
18
|
|
|
use Thelia\Module\BaseModule; |
|
19
|
|
|
use Thelia\Install\Database; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Class FeatureType |
|
23
|
|
|
* @package FeatureType |
|
24
|
|
|
* @author Gilles Bourgeat <[email protected]> |
|
25
|
|
|
*/ |
|
26
|
|
|
class FeatureType extends BaseModule |
|
27
|
|
|
{ |
|
28
|
|
|
const MODULE_DOMAIN = "featuretype"; |
|
29
|
|
|
|
|
30
|
|
|
const RESERVED_SLUG = 'id,feature_id,id_translater,locale,title,chapo,description,postscriptum,position'; |
|
31
|
|
|
|
|
32
|
|
|
const FEATURE_TYPE_AV_IMAGE_FOLDER = 'feature_type_av_images'; |
|
33
|
|
|
|
|
34
|
|
|
/** @var string */ |
|
35
|
|
|
const UPDATE_PATH = __DIR__ . DS . 'Config' . DS . 'update'; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @param ConnectionInterface $con |
|
39
|
|
|
*/ |
|
40
|
|
|
public function postActivation(ConnectionInterface $con = null) |
|
41
|
|
|
{ |
|
42
|
|
|
if (!self::getConfigValue('is_initialized', false)) { |
|
43
|
|
|
$database = new Database($con); |
|
44
|
|
|
$database->insertSql(null, [__DIR__ . "/Config/thelia.sql", __DIR__ . "/Config/insert.sql"]); |
|
45
|
|
|
self::setConfigValue('is_initialized', true); |
|
46
|
|
|
} |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @param $currentVersion |
|
51
|
|
|
* @param $newVersion |
|
52
|
|
|
* @param ConnectionInterface|null $con |
|
53
|
|
|
*/ |
|
54
|
|
|
public function update($currentVersion, $newVersion, ConnectionInterface $con = null) |
|
55
|
|
|
{ |
|
56
|
|
|
$finder = (new Finder())->files()->name('#.*?\.sql#')->sortByName()->in(self::UPDATE_PATH); |
|
57
|
|
|
|
|
58
|
|
|
if ($finder->count() === 0) { |
|
59
|
|
|
return; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
$database = new Database($con); |
|
63
|
|
|
|
|
64
|
|
|
/** @var \Symfony\Component\Finder\SplFileInfo $updateSQLFile */ |
|
65
|
|
|
foreach ($finder as $updateSQLFile) { |
|
66
|
|
|
if (version_compare($currentVersion, str_replace('.sql', '', $updateSQLFile->getFilename()), '<')) { |
|
67
|
|
|
$database->insertSql(null, [$updateSQLFile->getPathname()]); |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @return array |
|
74
|
|
|
*/ |
|
75
|
|
|
public function getHooks() |
|
76
|
|
|
{ |
|
77
|
|
|
return array( |
|
78
|
|
|
array( |
|
79
|
|
|
"type" => TemplateDefinition::BACK_OFFICE, |
|
80
|
|
|
"code" => "feature-type.form-top", |
|
81
|
|
|
"title" => array( |
|
82
|
|
|
"fr_FR" => "Module Feature Type, form haut", |
|
83
|
|
|
"en_US" => "Module Feature Type, form top", |
|
84
|
|
|
), |
|
85
|
|
|
"description" => array( |
|
86
|
|
|
"fr_FR" => "En haut du formulaire de création et de mise à jour", |
|
87
|
|
|
"en_US" => "Top of creation form and update", |
|
88
|
|
|
), |
|
89
|
|
|
"active" => true |
|
90
|
|
|
), |
|
91
|
|
|
array( |
|
92
|
|
|
"type" => TemplateDefinition::BACK_OFFICE, |
|
93
|
|
|
"code" => "feature-type.form-bottom", |
|
94
|
|
|
"title" => array( |
|
95
|
|
|
"fr_FR" => "Module Feature Type, form bas", |
|
96
|
|
|
"en_US" => "Module Feature Type, form bottom", |
|
97
|
|
|
), |
|
98
|
|
|
"description" => array( |
|
99
|
|
|
"fr_FR" => "En bas du formulaire de création et de mise à jour", |
|
100
|
|
|
"en_US" => "Top of creation form and update", |
|
101
|
|
|
), |
|
102
|
|
|
"active" => true |
|
103
|
|
|
), |
|
104
|
|
|
array( |
|
105
|
|
|
"type" => TemplateDefinition::BACK_OFFICE, |
|
106
|
|
|
"code" => "feature-type.configuration-top", |
|
107
|
|
|
"title" => array( |
|
108
|
|
|
"fr_FR" => "Module Feature Type, configuration haut", |
|
109
|
|
|
"en_US" => "Module Feature Type, configuration top", |
|
110
|
|
|
), |
|
111
|
|
|
"description" => array( |
|
112
|
|
|
"fr_FR" => "En haut du la page de configuration du module", |
|
113
|
|
|
"en_US" => "At the top of the module's configuration page", |
|
114
|
|
|
), |
|
115
|
|
|
"active" => true |
|
116
|
|
|
), |
|
117
|
|
|
array( |
|
118
|
|
|
"type" => TemplateDefinition::BACK_OFFICE, |
|
119
|
|
|
"code" => "feature-type.configuration-bottom", |
|
120
|
|
|
"title" => array( |
|
121
|
|
|
"fr_FR" => "Module Feature Type, configuration bas", |
|
122
|
|
|
"en_US" => "Module Feature Type, configuration bottom", |
|
123
|
|
|
), |
|
124
|
|
|
"description" => array( |
|
125
|
|
|
"fr_FR" => "En bas du la page de configuration du module", |
|
126
|
|
|
"en_US" => "At the bottom of the module's configuration page", |
|
127
|
|
|
), |
|
128
|
|
|
"active" => true |
|
129
|
|
|
), |
|
130
|
|
|
array( |
|
131
|
|
|
"type" => TemplateDefinition::BACK_OFFICE, |
|
132
|
|
|
"code" => "feature-type.list-action", |
|
133
|
|
|
"title" => array( |
|
134
|
|
|
"fr_FR" => "Module Feature Type, list action", |
|
135
|
|
|
"en_US" => "Module Feature Type, list action", |
|
136
|
|
|
), |
|
137
|
|
|
"description" => array( |
|
138
|
|
|
"fr_FR" => "Action de la liste des types de caractéristiques", |
|
139
|
|
|
"en_US" => "Action from the list of features types", |
|
140
|
|
|
), |
|
141
|
|
|
"active" => true |
|
142
|
|
|
), |
|
143
|
|
|
array( |
|
144
|
|
|
"type" => TemplateDefinition::BACK_OFFICE, |
|
145
|
|
|
"code" => "feature-type.configuration-js", |
|
146
|
|
|
"title" => array( |
|
147
|
|
|
"fr_FR" => "Module Feature Type, configuration js", |
|
148
|
|
|
"en_US" => "Module Feature Type, configuration js", |
|
149
|
|
|
), |
|
150
|
|
|
"description" => array( |
|
151
|
|
|
"fr_FR" => "JS la page de configuration du module", |
|
152
|
|
|
"en_US" => "JS of the module's configuration page", |
|
153
|
|
|
), |
|
154
|
|
|
"active" => true |
|
155
|
|
|
) |
|
156
|
|
|
); |
|
157
|
|
|
} |
|
158
|
|
|
} |
|
159
|
|
|
|