Skip to content

Commit 0676440

Browse files
Merge pull request #1 from lopes-vincent/improvement
Improvement
2 parents afcf5c5 + bd154a3 commit 0676440

5 files changed

Lines changed: 38 additions & 9 deletions

File tree

‎Config/module.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<language>en_US</language>
2121
<language>fr_FR</language>
2222
</languages>
23-
<version>1.0</version>
23+
<version>1.0.1</version>
2424
<authors>
2525
<author>
2626
<name>Vincent Lopes-Vicente</name>

‎Controller/ConfigurationController.php‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ public function viewAction()
4040
$isInMaintenance = 1;
4141
}
4242

43+
$isIndexWritable = is_writable(THELIA_WEB_DIR."index.php");
44+
$isWebWritable = is_writable(THELIA_WEB_DIR);
45+
4346
return $this->render(
4447
'maintenance/configuration',
4548
[
@@ -48,7 +51,9 @@ public function viewAction()
4851
'backgroundColor' => html_entity_decode($backgroundColor[1]),
4952
'fontColor' => html_entity_decode($fontColor[1]),
5053
'linkColor' => html_entity_decode($linkColor[1]),
51-
'isInMaintenance' => $isInMaintenance
54+
'isInMaintenance' => $isInMaintenance,
55+
'isIndexWritable' => $isIndexWritable,
56+
'isWebWritable' => $isWebWritable,
5257
]
5358
);
5459
}
@@ -115,7 +120,7 @@ public function toggleMaintenanceAction()
115120
if (preg_match("/\/\/⚠((.|\n)*)⚠/", $contents)) {
116121
$newContent = preg_replace("/\/\/⚠((.|\n)*)⚠/", "", $contents);
117122
} else {
118-
$maintenanceTag = "**/\n\n//⚠--MAINTENANCE\nhttp_response_code(503);\ninclude('../local/modules/Maintenance/templates/maintenance.html');\ndie();\n//__⚠\n";
123+
$maintenanceTag = "**/\n\n//⚠--MAINTENANCE\nhttp_response_code(503);\ninclude('maintenance.html');\ndie();\n//__⚠\n";
119124
$newContent = preg_replace("/\*\*\/\n\n/i", $maintenanceTag, $contents);
120125
}
121126

‎Maintenance.php‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
namespace Maintenance;
1414

15+
use Propel\Runtime\Connection\ConnectionInterface;
1516
use Symfony\Component\Finder\Finder;
1617
use Symfony\Component\Finder\SplFileInfo;
1718
use Thelia\Module\BaseModule;
@@ -21,21 +22,34 @@ class Maintenance extends BaseModule
2122
/** @var string */
2223
const DOMAIN_NAME = 'maintenance';
2324

25+
const MAINTENANCE_FILE = THELIA_WEB_DIR.'maintenance.html';
26+
2427
/*
2528
* You may now override BaseModuleInterface methods, such as:
2629
* install, destroy, preActivation, postActivation, preDeactivation, postDeactivation
2730
*
2831
* Have fun !
2932
*/
3033

34+
public function postActivation(ConnectionInterface $con = null)
35+
{
36+
if (!file_exists(self::MAINTENANCE_FILE)) {
37+
copy(THELIA_MODULE_DIR . 'Maintenance' . DS . 'templates'. DS .'maintenance.html', self::MAINTENANCE_FILE);
38+
}
39+
}
40+
3141

3242
/**
3343
* @return SplFileInfo
3444
*/
3545
public static function getMaintenanceFile()
3646
{
47+
if (!file_exists(self::MAINTENANCE_FILE)) {
48+
copy(THELIA_MODULE_DIR . 'Maintenance' . DS . 'templates'. DS .'maintenance.html', self::MAINTENANCE_FILE);
49+
}
50+
3751
$finder = new Finder();
38-
$finder->files()->in(THELIA_MODULE_DIR . 'Maintenance' . DS . 'templates')->name("maintenance.html");
52+
$finder->files()->in(THELIA_WEB_DIR)->name("maintenance.html");
3953

4054
/** @var SplFileInfo $file */
4155
foreach ($finder as $file) {

‎templates/backOffice/default/maintenance/configuration.html‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@
3333

3434
<div class="row">
3535
<div class="col-lg-12">
36+
{if $isIndexWritable !== true}
37+
<div class="alert alert-danger">
38+
{intl l="The file web/index.php is not writable please change the permissions or the module will not work"}
39+
</div>
40+
{/if}
41+
{if $isWebWritable !== true}
42+
<div class="alert alert-danger">
43+
{intl l="The directory web is not writable please change the permissions or the module will not work"}
44+
</div>
45+
{/if}
3646
<h1 class="page-header">
3747
<div class="row">
3848
<div class="col-md-4">

‎templates/maintenance.html‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<title>Maintenance</title>
44
<style>
55
body {
6-
--background-color: /*background_color*/#251616/*background_color*/;
7-
--font-color: /*font_color*/#d5c394/*font_color*/;
6+
--background-color: /*background_color*/#2a3343/*background_color*/;
7+
--font-color: /*font_color*/#d1d1d1/*font_color*/;
88
background-color: var(--background-color);
99
}
1010
#maintenance_page {
@@ -16,18 +16,18 @@
1616
}
1717
#maintenance_page article { display: block; text-align: left; width: 650px; margin: 0 auto; }
1818
#maintenance_page h1 { font-size: 50px; }
19-
#maintenance_page a { color: /*link_color*/#ffffff/*link_color*/; text-decoration: none; }
19+
#maintenance_page a { color: /*link_color*/#ffff8d/*link_color*/; text-decoration: none; }
2020
#maintenance_page a:hover { color: var(--font-color); text-decoration: none; }
2121
</style>
2222

2323
<div id="maintenance_page">
2424
<article>
2525
<h1>
26-
<!--TITLE START-->We&rsquo;ll be back soon!<!--TITLE END-->
26+
<!--TITLE START-->We’ll be back soon!<!--TITLE END-->
2727
</h1>
2828
<div>
2929
<p>
30-
<!--MESSAGE START-->Sorry for the inconvenience but we&rsquo;re performing some maintenance at the moment. If you need to you can always <a href="mailto:#">contact us</a>, otherwise we&rsquo;ll be back online shortly!<!--MESSAGE END-->
30+
<!--MESSAGE START-->Sorry for the inconvenience but we’re performing some maintenance at the moment. If you need to you can always <a href="mailto:#">contact us</a>, otherwise we’ll be back online shortly!<!--MESSAGE END-->
3131
</p>
3232
</div>
3333
</article>

0 commit comments

Comments
 (0)