Module Maintenance + création du module Recette
This commit is contained in:
31
local/modules/Maintenance/Config/config.xml
Normal file
31
local/modules/Maintenance/Config/config.xml
Normal file
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<config xmlns="http://thelia.net/schema/dic/config"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/thelia-1.0.xsd">
|
||||
|
||||
<forms>
|
||||
<form name="admin_maintenance_settings" class="Maintenance\Form\MaintenanceSettingsForm" />
|
||||
</forms>
|
||||
|
||||
<services>
|
||||
<service id="maintenance.listener" class="Maintenance\EventListener\MaintenanceListener">
|
||||
<argument>%kernel.debug%</argument>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
</services>
|
||||
|
||||
<hooks>
|
||||
<hook id="maintenance.warning" class="Maintenance\Hook\HookManager">
|
||||
<tag name="hook.event_listener" event="main.body-top" type="front" method="onMainBodyTop" />
|
||||
</hook>
|
||||
|
||||
<hook id="maintenance.configuration.hook" class="Maintenance\Hook\HookManager">
|
||||
<tag name="hook.event_listener" event="module.configuration" type="back" method="onModuleConfigure" />
|
||||
</hook>
|
||||
|
||||
<hook id="maintenance.menutools.hook" class="Maintenance\Hook\HookManager">
|
||||
<tag name="hook.event_listener" event="main.top-menu-tools" type="back" method="onMainTopMenuTools" />
|
||||
</hook>
|
||||
</hooks>
|
||||
</config>
|
||||
24
local/modules/Maintenance/Config/module.xml
Normal file
24
local/modules/Maintenance/Config/module.xml
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module xmlns="http://thelia.net/schema/dic/module"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://thelia.net/schema/dic/module http://thelia.net/schema/dic/module/module-2_1.xsd">
|
||||
<fullnamespace>Maintenance\Maintenance</fullnamespace>
|
||||
<descriptive locale="en_US">
|
||||
<title>Maintenance mode</title>
|
||||
</descriptive>
|
||||
<descriptive locale="fr_FR">
|
||||
<title>Mode Maintenance</title>
|
||||
</descriptive>
|
||||
<languages>
|
||||
<language>en_US</language>
|
||||
<language>fr_FR</language>
|
||||
</languages>
|
||||
<version>0.8</version>
|
||||
<author>
|
||||
<name>Nicolas Léon, Franck Allimant</name>
|
||||
<email>nicolas@omnitic.com, thelia@cqfdev.fr</email>
|
||||
</author>
|
||||
<type>classic</type>
|
||||
<thelia>2.3.0</thelia>
|
||||
<stability>prod</stability>
|
||||
</module>
|
||||
23
local/modules/Maintenance/Config/routing.xml
Normal file
23
local/modules/Maintenance/Config/routing.xml
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="maintenance.front" path="/maintenance">
|
||||
<default key="_controller">Maintenance\Controller\MaintenanceController::displayMaintenance</default>
|
||||
</route>
|
||||
|
||||
<route id="maintenance.back-preview" path="/maintenance-preview">
|
||||
<default key="_controller">Maintenance\Controller\MaintenanceController::displayMaintenance</default>
|
||||
</route>
|
||||
|
||||
<route id="maintenance.home" path="/admin/module/maintenance">
|
||||
<default key="_controller">Maintenance\Controller\MaintenanceAdminController::indexAction</default>
|
||||
</route>
|
||||
|
||||
<route id="maintenance.update" path="/admin/module/maintenance/configure" methods="post">
|
||||
<default key="_controller">Maintenance\Controller\MaintenanceAdminController::configureAction</default>
|
||||
</route>
|
||||
|
||||
</routes>
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* Maintenance mode plugin for Thelia 2 */
|
||||
/* */
|
||||
/* Copyright (c) Omnitic */
|
||||
/* email : nicolas@omnitic.com */
|
||||
/* web : http://www.omnitic.com */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Maintenance\Controller;
|
||||
|
||||
use Maintenance\Form\MaintenanceSettingsForm;
|
||||
use Thelia\Controller\Admin\BaseAdminController;
|
||||
use Thelia\Core\Security\AccessManager;
|
||||
use Thelia\Core\Security\Resource\AdminResources;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
/**
|
||||
* Class MaintenanceAdminController
|
||||
* @package Maintenance\Controller
|
||||
* @author Nicolas Léon <nicolas@omnitic.com>
|
||||
* @author Benjamin Perche <bperche@openstudio.fr>
|
||||
*/
|
||||
class MaintenanceAdminController extends BaseAdminController
|
||||
{
|
||||
|
||||
public function configureAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth([AdminResources::MODULE], ['Maintenance'], AccessManager::UPDATE)) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
$m_form = new MaintenanceSettingsForm($this->getRequest());
|
||||
|
||||
$error_message = null;
|
||||
|
||||
try {
|
||||
$form = $this->validateForm($m_form, "post");
|
||||
|
||||
$data = $form->getData();
|
||||
|
||||
ConfigQuery::write('com.omnitic.maintenance_mode', (bool) $data['maintenance_mode']);
|
||||
ConfigQuery::write('com.omnitic.maintenance_template_name', $data['maintenance_template_name']);
|
||||
ConfigQuery::write('com.omnitic.maintenance_message', $data['maintenance_message']);
|
||||
ConfigQuery::write('com.omnitic.maintenance_allowed_ips', preg_replace("/\s/", '', $data['maintenance_allowed_ips']));
|
||||
|
||||
} catch (FormValidationException $e) {
|
||||
$error_message = $this->createStandardFormValidationErrorMessage($e);
|
||||
} catch (\Exception $e) {
|
||||
$error_message = $e->getMessage();
|
||||
}
|
||||
|
||||
if ($error_message !== null) {
|
||||
$m_form->setErrorMessage($error_message);
|
||||
|
||||
$this->getParserContext()
|
||||
->addForm($m_form)
|
||||
->setGeneralError($error_message)
|
||||
;
|
||||
}
|
||||
|
||||
return $this->generateRedirect(URL::getInstance()->absoluteUrl('/admin/module/Maintenance'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Maintenance\Controller;
|
||||
use Thelia\Controller\Front\BaseFrontController;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
|
||||
/**
|
||||
* Class MaintenanceController
|
||||
* @package Maintenance\Controller
|
||||
* @author Benjamin Perche <bperche@openstudio.fr>
|
||||
*/
|
||||
class MaintenanceController extends BaseFrontController
|
||||
{
|
||||
public function displayMaintenance()
|
||||
{
|
||||
$tplName = ConfigQuery::read("com.omnitic.maintenance_template_name");
|
||||
|
||||
if (empty($tplName)) {
|
||||
$tplName = "maintenance";
|
||||
}
|
||||
|
||||
return $this->render("maintenance/$tplName");
|
||||
}
|
||||
}
|
||||
109
local/modules/Maintenance/EventListener/MaintenanceListener.php
Normal file
109
local/modules/Maintenance/EventListener/MaintenanceListener.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Maintenance module. */
|
||||
/* */
|
||||
/* Copyright (c) Omnitic */
|
||||
/* email : bonjour@omnitic.com */
|
||||
/* web : http://www.omnitic.com */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Maintenance\EventListener;
|
||||
|
||||
use BackOfficePath\BackOfficePath;
|
||||
use Maintenance\Controller\MaintenanceController;
|
||||
use Maintenance\Maintenance;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
||||
|
||||
use Thelia\Core\HttpKernel\Exception\RedirectException;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
/**
|
||||
* Class MaintenanceListener
|
||||
* @package Maintenance\EventListener
|
||||
* @author Benjamin Perche <bperche@openstudio.fr>
|
||||
* @author Nicolas Léon <nicolas@omnitic.com>
|
||||
*/
|
||||
class MaintenanceListener implements EventSubscriberInterface
|
||||
{
|
||||
protected $debugMode;
|
||||
|
||||
/**
|
||||
* MaintenanceListener constructor.
|
||||
*
|
||||
* @param $debugMode
|
||||
*/
|
||||
public function __construct($debugMode)
|
||||
{
|
||||
$this->debugMode = $debugMode;
|
||||
}
|
||||
|
||||
/*
|
||||
* Displays the maintenance page according to Admin settings
|
||||
*
|
||||
* @params FilterResponseEvent $event
|
||||
*
|
||||
*/
|
||||
public function setMaintenanceView(GetResponseEvent $event)
|
||||
{
|
||||
$maintenance_mode = ConfigQuery::read('com.omnitic.maintenance_mode');
|
||||
|
||||
if ($maintenance_mode) {
|
||||
/**
|
||||
* @var \Thelia\Core\HttpFoundation\Request
|
||||
*/
|
||||
$request = $event->getRequest();
|
||||
|
||||
// Check that the current request ip address is in the white list
|
||||
$allowed_ips = explode(',', ConfigQuery::read('com.omnitic.maintenance_allowed_ips'));
|
||||
$allowed_ips[] = '127.0.0.1';
|
||||
$current_ip = $request->server->get('REMOTE_ADDR');
|
||||
$path = $request->getPathInfo();
|
||||
|
||||
if ($path !== '/maintenance') {
|
||||
// Check that we're not in debug mode
|
||||
if (! $this->debugMode) {
|
||||
// Check that we're not an allowed ip address
|
||||
if (!in_array($current_ip, $allowed_ips)) {
|
||||
// Check that we're not an admin user
|
||||
if ($request->getSession()->getAdminUser() === null) {
|
||||
// Check that we're not accessing admin pages
|
||||
if (!preg_match("#^/admin#i", $path)) {
|
||||
throw new RedirectException(URL::getInstance()->absoluteUrl("/maintenance"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of event names this subscriber wants to listen to.
|
||||
*/
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
KernelEvents::REQUEST => ["setMaintenanceView", 128]
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
110
local/modules/Maintenance/Form/MaintenanceSettingsForm.php
Normal file
110
local/modules/Maintenance/Form/MaintenanceSettingsForm.php
Normal file
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* Maintenance mode plugin for Thelia 2 */
|
||||
/* */
|
||||
/* Copyright (c) Omnitic */
|
||||
/* email : nicolas@omnitic.com */
|
||||
/* web : http://www.omnitic.com */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Maintenance\Form;
|
||||
|
||||
use Maintenance\Maintenance;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Form\BaseForm;
|
||||
|
||||
/**
|
||||
* Class MaintenanceSettingsForm
|
||||
* @package Maintenance\Form
|
||||
* @author Nicolas Léon <nicolas@omnitic.com>
|
||||
* @author Benjamin Perche <bperche@openstudio.fr>
|
||||
*/
|
||||
class MaintenanceSettingsForm extends BaseForm
|
||||
{
|
||||
protected function buildForm()
|
||||
{
|
||||
$translator = Translator::getInstance();
|
||||
|
||||
$this->formBuilder
|
||||
->add('maintenance_mode', 'checkbox', array(
|
||||
'label' => $translator->trans(
|
||||
"Put the store in maintenance mode",
|
||||
[],
|
||||
Maintenance::MESSAGE_DOMAIN
|
||||
),
|
||||
'label_attr' => [
|
||||
'for' => 'maintenance_mode',
|
||||
'help' => $this->translator->trans(
|
||||
'Lorsque cette case est cochée, votre boutique n\'est plus accessible à vos clients.',
|
||||
[],
|
||||
Maintenance::MESSAGE_DOMAIN
|
||||
)
|
||||
],
|
||||
'required' => false,
|
||||
))
|
||||
->add('maintenance_template_name', 'text', array(
|
||||
'label' => $translator->trans(
|
||||
"Template name",
|
||||
[],
|
||||
Maintenance::MESSAGE_DOMAIN
|
||||
),
|
||||
'label_attr' => array(
|
||||
'for' => 'maintenance_template_name',
|
||||
'help' => $this->translator->trans(
|
||||
'This is the name of the HTML template displayed to your customers. The module provides the following templates : "maintenance", "light" and "simple", but feel free to make your own template, and put its name here.',
|
||||
[],
|
||||
Maintenance::MESSAGE_DOMAIN
|
||||
)
|
||||
),
|
||||
'required' => true,
|
||||
'constraints' => array(
|
||||
new NotBlank(),
|
||||
)
|
||||
))
|
||||
->add('maintenance_message', 'textarea', array(
|
||||
'label' => $translator->trans(
|
||||
"Reminder message",
|
||||
[],
|
||||
Maintenance::MESSAGE_DOMAIN
|
||||
),
|
||||
'label_attr' => array(
|
||||
'for' => 'maintenance_message',
|
||||
'help' => $this->translator->trans(
|
||||
'This message will be displayed to your customers.',
|
||||
[],
|
||||
Maintenance::MESSAGE_DOMAIN
|
||||
)
|
||||
),
|
||||
"required" => true,
|
||||
"constraints" => array(
|
||||
new NotBlank(),
|
||||
)
|
||||
))
|
||||
->add('maintenance_allowed_ips', 'text', array(
|
||||
'label' => $translator->trans(
|
||||
"Authorized IP address(es)",
|
||||
[],
|
||||
Maintenance::MESSAGE_DOMAIN
|
||||
),
|
||||
'label_attr' => array(
|
||||
'for' => 'allowed_ips',
|
||||
'help' => $this->translator->trans(
|
||||
'Enter here a comma separated list of the IP addresses that will be allowed to access the shop when maintenance mode is enabled. Your IP address is currently %ip.',
|
||||
[ "%ip" => $this->getRequest()->getClientIp()],
|
||||
Maintenance::MESSAGE_DOMAIN
|
||||
)
|
||||
),
|
||||
"required" => false,
|
||||
// "constraints" => array(
|
||||
// new NotBlank(),
|
||||
// )
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'admin_maintenance_settings';
|
||||
}
|
||||
}
|
||||
53
local/modules/Maintenance/Hook/HookManager.php
Normal file
53
local/modules/Maintenance/Hook/HookManager.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Maintenance\Hook;
|
||||
|
||||
use Maintenance\Maintenance;
|
||||
use Thelia\Core\Event\Hook\HookRenderBlockEvent;
|
||||
use Thelia\Core\Event\Hook\HookRenderEvent;
|
||||
use Thelia\Core\Hook\BaseHook;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
/**
|
||||
* Class HookManager
|
||||
*
|
||||
* @package Tinymce\Hook
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class HookManager extends BaseHook
|
||||
{
|
||||
public function onMainBodyTop(HookRenderEvent $event)
|
||||
{
|
||||
if (ConfigQuery::read('com.omnitic.maintenance_mode')) {
|
||||
$event->add($this->render("maintenance/maintenance_warning.html"));
|
||||
}
|
||||
}
|
||||
|
||||
public function onMainTopMenuTools(HookRenderBlockEvent $event)
|
||||
{
|
||||
$event->add(
|
||||
[
|
||||
'id' => 'tools_menu_tags',
|
||||
'class' => '',
|
||||
'url' => URL::getInstance()->absoluteUrl('/admin/module/Maintenance'),
|
||||
'title' => $this->translator->trans("Mode maintenance", [], Maintenance::MESSAGE_DOMAIN)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function onModuleConfigure(HookRenderEvent $event)
|
||||
{
|
||||
$event->add($this->render("maintenance/module_configuration.html"));
|
||||
}
|
||||
}
|
||||
11
local/modules/Maintenance/I18n/backOffice/default/en_US.php
Normal file
11
local/modules/Maintenance/I18n/backOffice/default/en_US.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'Le mode maintenance permet de fermer temporairement votre boutique, en affichant un message de votre choix à vos visiteurs.' => 'When the maintenance mode is active, your store is cloded, displaying a message of your choice to your visitors.',
|
||||
'Maintenance mode' => 'Maintenance mode',
|
||||
'Preview' => 'Preview',
|
||||
'Save changes' => 'Save changes',
|
||||
'Save your changes to get proper preview !' => 'Be sure to saveyour changes to get the selected preview !',
|
||||
'Sur cette page vous pouvez activer ou désactiver le mode maintenance, configurer les accès autorisés et régler les paramètres d\'affichage.' => 'On this page you can activate or deactivate the maintenance mode, configure the allowed accesses and adjust the display parameters.',
|
||||
'Vous conservez toujours un accès à la boutique si vous etes connecté en tant qu\'administrateur, ou accédez à la boutique en mode développement. Dans ce cas, un rappel du mode maintenance est affiché sur la boutique. Vous pouvez le modifier dans le template frontOffice/default/maintenance/maintenance_warning.html.' => 'You keep an access to the store if you are logged as an administrator, or access the store in development mode. In this case, a reminder of maintenance mode is displayed on the shop. You can change it in the frontOffice/default/maintenance/maintenance_warning.html template.',
|
||||
);
|
||||
11
local/modules/Maintenance/I18n/backOffice/default/fr_FR.php
Normal file
11
local/modules/Maintenance/I18n/backOffice/default/fr_FR.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'Le mode maintenance permet de fermer temporairement votre boutique, en affichant un message de votre choix à vos visiteurs.' => 'Le mode maintenance permet de fermer temporairement votre boutique, en affichant un message de votre choix à vos visiteurs.',
|
||||
'Maintenance mode' => 'Mode maintenance',
|
||||
'Preview' => 'Prévisualiser',
|
||||
'Save changes' => 'Enregistrer',
|
||||
'Save your changes to get proper preview !' => 'Enregistrez les changements pour afficher la vue choisie !',
|
||||
'Sur cette page vous pouvez activer ou désactiver le mode maintenance, configurer les accès autorisés et régler les paramètres d\'affichage.' => 'Sur cette page vous pouvez activer ou désactiver le mode maintenance, configurer les accès autorisés et régler les paramètres d\'affichage.',
|
||||
'Vous conservez toujours un accès à la boutique si vous etes connecté en tant qu\'administrateur, ou accédez à la boutique en mode développement. Dans ce cas, un rappel du mode maintenance est affiché sur la boutique. Vous pouvez le modifier dans le template frontOffice/default/maintenance/maintenance_warning.html.' => 'Vous conservez toujours un accès à la boutique si vous etes connecté en tant qu\'administrateur, ou accédez à la boutique en mode développement. Dans ce cas, un rappel du mode maintenance est affiché sur la boutique. Vous pouvez le modifier dans le template frontOffice/default/maintenance/maintenance_warning.html.',
|
||||
);
|
||||
13
local/modules/Maintenance/I18n/en_US.php
Normal file
13
local/modules/Maintenance/I18n/en_US.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'Authorized IP address(es)' => 'Allowed IP address(es)',
|
||||
'Enter here a comma separated list of the IP addresses that will be allowed to access the shop when maintenance mode is enabled. Your IP address is currently %ip.' => 'Enter here a comma separated list of the IP addresses that will be allowed to access the shop when maintenance mode is enabled. Your IP address is currently %ip.',
|
||||
'Lorsque cette case est cochée, votre boutique n\'est plus accessible à vos clients.' => 'When this box is checked, your store is closed',
|
||||
'Mode maintenance' => 'Maintenance mode',
|
||||
'Put the store in maintenance mode' => 'Put the store in maintenance mode',
|
||||
'Reminder message' => 'Reminder message',
|
||||
'Template name' => 'Template name',
|
||||
'This is the name of the HTML template displayed to your customers. The module provides the following templates : "maintenance", "light" and "simple", but feel free to make your own template, and put its name here.' => 'This is the name of the HTML template displayed to your customers. The module provides the following templates : "maintenance", "light" and "simple", but feel free to make your own template, and put its name here.',
|
||||
'This message will be displayed to your customers.' => 'This message will be displayed to your customers.',
|
||||
);
|
||||
13
local/modules/Maintenance/I18n/fr_FR.php
Normal file
13
local/modules/Maintenance/I18n/fr_FR.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'Authorized IP address(es)' => 'Addresses IP autorisées',
|
||||
'Enter here a comma separated list of the IP addresses that will be allowed to access the shop when maintenance mode is enabled. Your IP address is currently %ip.' => 'Indiquez ici la liste des adresses IP (séparées par des virgules) qui seront autorisées à voir la boutique lorsque le mode maintenance est actif. Votre adresse IP est %ip',
|
||||
'Lorsque cette case est cochée, votre boutique n\'est plus accessible à vos clients.' => 'Lorsque cette case est cochée, votre boutique n\'est plus accessible à vos clients.',
|
||||
'Mode maintenance' => 'Mode maintenance',
|
||||
'Put the store in maintenance mode' => 'Afficher la page de maintenance',
|
||||
'Reminder message' => 'Message d\'attente',
|
||||
'Template name' => 'Nom du template',
|
||||
'This is the name of the HTML template displayed to your customers. The module provides the following templates : "maintenance", "light" and "simple", but feel free to make your own template, and put its name here.' => 'Il s\'agit du nom du template HTML qui sera affiché aux visiteurs de la boutique. Le modulke vous propose les templates "simple", "light" et "maintenance", mais vous pouvez tout à fait créer le votre dans Maintenance/templates/frontOffice/default/maintenance et placer son nom ici.',
|
||||
'This message will be displayed to your customers.' => 'Ce message sera présenté aux visiteurs de la boutique',
|
||||
);
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'Maintenance mode is active' => 'Le mode maintenance est activé !',
|
||||
);
|
||||
65
local/modules/Maintenance/Maintenance.php
Normal file
65
local/modules/Maintenance/Maintenance.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* Maintenance mode plugin for Thelia 2 */
|
||||
/* */
|
||||
/* Copyright (c) Omnitic */
|
||||
/* email : nicolas@omnitic.com */
|
||||
/* web : http://www.omnitic.com */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Maintenance;
|
||||
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Module\BaseModule;
|
||||
|
||||
class Maintenance extends BaseModule
|
||||
{
|
||||
const MESSAGE_DOMAIN = "maintenance";
|
||||
|
||||
private $settings = [
|
||||
'com.omnitic.maintenance_mode' => 0,
|
||||
'com.omnitic.maintenance_template_name' => 'maintenance',
|
||||
'com.omnitic.maintenance_message' => 'Nous mettons à jour notre boutique. Revenez nous voir dans quelques minutes.',
|
||||
'com.omnitic.maintenance_allowed_ips' => '',
|
||||
];
|
||||
|
||||
/*
|
||||
* Install the default module settings
|
||||
*
|
||||
*/
|
||||
public function postActivation(ConnectionInterface $con = null)
|
||||
{
|
||||
foreach ($this->settings as $setting_name => $value) {
|
||||
$setting = ConfigQuery::read($setting_name);
|
||||
|
||||
if (empty($setting)) {
|
||||
ConfigQuery::write($setting_name, $value, null, 1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete module data on module destroy
|
||||
*
|
||||
*
|
||||
*/
|
||||
public function destroy(ConnectionInterface $con = null, $deleteModuleData = false)
|
||||
{
|
||||
foreach ($this->settings as $setting_name => $value) {
|
||||
$setting = ConfigQuery::create()->findOneByName($setting_name);
|
||||
if ($setting !== null) {
|
||||
$setting->delete();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getCode()
|
||||
{
|
||||
return 'Maintenance';
|
||||
}
|
||||
|
||||
}
|
||||
89
local/modules/Maintenance/Readme.md
Normal file
89
local/modules/Maintenance/Readme.md
Normal file
@@ -0,0 +1,89 @@
|
||||
# Maintenance mode module for Thelia 2 (en_US)
|
||||
|
||||
This module allow the store owner to put the store in maintenance mode while performing changes to the store.
|
||||
|
||||
## How to install
|
||||
|
||||
Download the .zip file of this module or create a git submodule into your project like this :
|
||||
|
||||
```
|
||||
cd /path-to-thelia
|
||||
git submodule add https://github.com/nicolasleon/Maintenance.git local/modules/Mainteance
|
||||
```
|
||||
|
||||
To install the module, copy the folder Maintenance into your ```modules/``` directory (install_dir/local/modules).
|
||||
|
||||
Next, go to your Thelia admin panel and activate the module.
|
||||
|
||||
|
||||
## Configuration
|
||||
|
||||
You can manage the store maintenance mode settings by clicking the "Configure" button on the modules list.
|
||||
|
||||
Under the Configure tab you can set the following options:
|
||||
|
||||
**Put the store in maintenance mode**: Check the box to put the store in maintenance mode.
|
||||
|
||||
**Maintenance page name**: the name of the template to be displayed when the maintenance mode is active (See the provided templates in /templates/fontOffice/module_maintenance folder of the module).
|
||||
|
||||
**Reminder message**: a message to display in the store front when the maintenance mode is active.
|
||||
|
||||
**Allowed ips**: Ip addresses that are allowed to see the store in maintenance mode is active (e.g.: "212.127.1.5, 192.135.0.1")
|
||||
|
||||
|
||||
## How to use
|
||||
|
||||
Click on "Configure" button and check "Put the store in maintenance mode".
|
||||
Define the message displayed to the shop visitors in Reminder message field.
|
||||
|
||||
The maintenance templates are stored in Maintenance/templates/frontOffice/default/maintenance folder. There are 3 samples maintenance templates provided (maintenance, simple and light) with the modules. Feel free to customize them to best match your store design.
|
||||
|
||||
Save you settings. The store is now in maintenance mode.
|
||||
|
||||
Any store admin can still accesss the store in maintenance mode (They will see the reminder message at the top of the page). The sotre remains visible if accessed in developement mode (you know, index_dev.php)
|
||||
|
||||
|
||||
# Module Mode Maintenance pour Thelia 2 (fr_FR)
|
||||
|
||||
Ce module permet au ecommerçant de mettre la boutique en mode maintenance pendant la mise à jour de cette dernière.
|
||||
|
||||
## Installation
|
||||
|
||||
Téléchargez le fichier zip du module ou créez un submodule Git dans votre projet comme ceci :
|
||||
|
||||
```
|
||||
cd /dossier-thelia
|
||||
git submodule add https://github.com/nicolasleon/Maintenance.git local/modules/Mainteance
|
||||
```
|
||||
|
||||
Pour installer le module, copiez le dossier Maintenance dans le répertoire /local/modules situé à la racine de votre dossier Thelia (mon-dossier-thelia/local/modules).
|
||||
|
||||
Activez le module dans l'interface d'administration Thelia.
|
||||
|
||||
|
||||
## Configuration
|
||||
|
||||
Vous pouvez régler les paramètres du mode maintenance de la boutique en cliquant sur le bouton "Configuration" du module.
|
||||
|
||||
Les paramètres disponibles sont les suivants :
|
||||
|
||||
**Afficher la page de maintenance**: cochez cette case pour passer la boutique en mode maintenance.
|
||||
|
||||
**Nom du template**: le nom du template que les visiteurs verront quand la boutique est en mode maintenance (le template fourni maintenance.html pourra êtreSee the provided maintenance.html in templates/fontOffice/default folder of the module).
|
||||
|
||||
**Message d'attente**: Un message à afficher sur la page de maintenance quand la boutique est en maintenance.
|
||||
|
||||
**Adresses ip autorisées**: Liste des adresses ip pouvant accéder à la boutique quand celle-ci est en maintenance ("212.127.1.5, 192.135.0.1").
|
||||
|
||||
## Utilisation
|
||||
|
||||
Réglez les paramètres du module, cochez la case "Afficher le mode maintenance".
|
||||
Click on "Configure" button and check "Put the store in maintenance mode".
|
||||
Define the message displayed to the shop visitors in Reminder message field.
|
||||
|
||||
Les templates du mode maintenance sont définis dans Maintenance/templates/frontOffice/default/maintenance. N'hésitez pas à personnaliser les 3 (maintenance, simple et light) exemples fournis pour mieux correspondre au design de votre boutique, ou a créer le vôtre.
|
||||
|
||||
Enregistrez vos paramètres. La boutique est en mode maintenance. Pour quittez le mode maintenance décochez la case et enregistrez votre configuration.
|
||||
|
||||
Dans le mode maintenance, les utilisateurs connectés au back office Thelia accèdent normalement à la boutique (un message est affiché en haut des pages rappelle que le mode maintenance est activé).
|
||||
Vous pouvez toujours accéder à la boutique en mode développement (vous savez, index_dev.php).
|
||||
11
local/modules/Maintenance/composer.json
Normal file
11
local/modules/Maintenance/composer.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "vlopes/maintenance-module",
|
||||
"license": "LGPL-3.0+",
|
||||
"type": "thelia-module",
|
||||
"require": {
|
||||
"thelia/installer": "~1.1"
|
||||
},
|
||||
"extra": {
|
||||
"installer-name": "Maintenance"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12 general-block-decorator">
|
||||
<div class="row">
|
||||
<div class="col-md-12 title title-without-tabs">
|
||||
{intl d="maintenance.fo.default" l="Maintenance mode"}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-container">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="alert alert-info">
|
||||
<p>{intl d="maintenance.fo.default" l="Le mode maintenance permet de fermer temporairement votre boutique, en affichant un message de votre choix à vos visiteurs."}</p>
|
||||
<p>{intl d="maintenance.fo.default" l="Sur cette page vous pouvez activer ou désactiver le mode maintenance, configurer les accès autorisés et régler les paramètres d'affichage."}</p>
|
||||
<p>{intl d="maintenance.fo.default" l="Vous conservez toujours un accès à la boutique si vous etes connecté en tant qu'administrateur, ou accédez à la boutique en mode développement. Dans ce cas, un rappel du mode maintenance est affiché sur la boutique. Vous pouvez le modifier dans le template frontOffice/default/maintenance/maintenance_warning.html."}</p>
|
||||
</div>
|
||||
|
||||
{form name="admin_maintenance_settings"}
|
||||
<form action="{url path="/admin/module/maintenance/configure"}" method="post">
|
||||
{if $form_error}
|
||||
<div class="alert alert-danger">{$form_error_message}</div>
|
||||
{/if}
|
||||
|
||||
{form_hidden_fields}
|
||||
|
||||
{render_form_field field="maintenance_mode" value={config key="com.omnitic.maintenance_mode"}}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
{custom_render_form_field field="maintenance_template_name"}
|
||||
<div class="input-group">
|
||||
<input type="text" {form_field_attributes field="maintenance_template_name" value={config key="com.omnitic.maintenance_template_name"}}>
|
||||
<span class="input-group-btn">
|
||||
<a href="{url path="/maintenance-preview"}" class="btn btn-info" target="maintenance_preview" title="{intl d="maintenance.fo.default" l="Save your changes to get proper preview !"}">{intl d="maintenance.fo.default" l="Preview"}</a>
|
||||
</span>
|
||||
</div>
|
||||
{/custom_render_form_field}
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
{render_form_field field="maintenance_allowed_ips" value={config key="com.omnitic.maintenance_allowed_ips"}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{render_form_field field="maintenance_message" value={config key="com.omnitic.maintenance_message"} extra_class="wysiwyg"}
|
||||
|
||||
<div class="form-group">
|
||||
<button type="submit" name="save_mode" value="stay" class="form-submit-button btn btn-success" title="{intl l='Save changes'}">{intl l='Save changes'} <span class="glyphicon glyphicon-ok"></span></button>
|
||||
</div>
|
||||
</form>
|
||||
{/form}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,41 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html;charset=utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="description" content="">
|
||||
<meta name="author" content="{config key="store_name"}">
|
||||
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0">
|
||||
<title>{config key="store_name"}</title>
|
||||
<style type="text/css">
|
||||
.paper {
|
||||
font-family: "Open Sans", sans serif;
|
||||
background-color: #1D7CBE;
|
||||
}
|
||||
.message {
|
||||
margin:10% auto;
|
||||
padding:30px;
|
||||
width:50%;
|
||||
}
|
||||
.message {
|
||||
color: #fff;
|
||||
font-size:24px;
|
||||
}
|
||||
.message .store-name {
|
||||
font-size:18px;
|
||||
}
|
||||
.fa {
|
||||
font-size:80px;
|
||||
}
|
||||
</style>
|
||||
<link href='//fonts.googleapis.com/css?family=Ubuntu:600' rel='stylesheet' type='text/css'>
|
||||
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
|
||||
</head>
|
||||
<body class="paper">
|
||||
<div class="message">
|
||||
<p><i class="fa fa-clock-o"></i></p>
|
||||
<div class="message-text">{config key="com.omnitic.maintenance_message"}</div>
|
||||
<p class="store-name">{config key="store_name"}</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,3 @@
|
||||
<div style="position: fixed; top: 0; left: 0; color: #fff; background-color: #ff8000; font-size: 12px; padding: 2px 10px; opacity: 0.5; z-index: 99999">
|
||||
{intl l="Maintenance mode is active" d="maintenance.fo.default"}
|
||||
</div>
|
||||
@@ -0,0 +1,39 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html;charset=utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="description" content="">
|
||||
<meta name="author" content="{config key="store_name"}">
|
||||
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0">
|
||||
<title>{config key="store_name"}</title>
|
||||
<style type="text/css">
|
||||
.paper {
|
||||
font-family: "Open Sans", sans serif;
|
||||
background-color: #466176;
|
||||
}
|
||||
.message {
|
||||
margin:10% auto;
|
||||
padding:30px;
|
||||
width:50%;
|
||||
}
|
||||
.message {
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
font-size:18px;
|
||||
}
|
||||
.message .message-text {
|
||||
font-size:24px;
|
||||
}
|
||||
</style>
|
||||
<link href='//fonts.googleapis.com/css?family=Open+Sans:600' rel='stylesheet' type='text/css'>
|
||||
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
|
||||
</head>
|
||||
<body class="paper">
|
||||
<div class="message">
|
||||
<p class="store-name">{config key="store_name"}</p>
|
||||
<div class="message-text">{config key="com.omnitic.maintenance_message"}</div>
|
||||
<p><i class="fa fa-cog fa-spin"></i></p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user