first commit

This commit is contained in:
2024-11-05 12:22:50 +01:00
commit e5682a3912
19641 changed files with 2948548 additions and 0 deletions

View File

@@ -0,0 +1,245 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
namespace OnBoarding;
use Hook;
use Module;
use PrestaShopBundle\Service\Routing\Router;
class Configuration
{
/**
* Module Dependency
*/
const FAKE_ID = 123456789;
const HOOK_CONFIGURATION = 'welcome_configuration';
const STEP_DASHBOARD = 'dashboard';
const STEP_PRODUCT = 'product';
const STEP_THEME = 'theme';
const STEP_PAYMENT = 'payment';
const STEP_SHIPPING = 'shipping';
private $translator;
public function __construct($translator)
{
$this->translator = $translator;
}
public function getConfiguration(Router $router)
{
$contextLink = \Context::getContext()->link;
$productFormUrlPattern = $this->generateSfBaseUrl(
$router,
'admin_product_form',
['id' => static::FAKE_ID]
);
$data = [
'templates' => [
'lost',
'popup',
'tooltip',
],
'steps' => [
'groups' => [
[
'name' => static::STEP_DASHBOARD,
'steps' => [
[
'type' => 'popup',
'text' => [
'type' => 'template',
'src' => 'welcome',
],
'options' => [
'savepoint',
'hideFooter',
],
'page' => $contextLink->getAdminLink('AdminDashboard'),
],
],
],
[
'name' => static::STEP_PRODUCT,
'title' => $this->translator->trans('Let\'s create your first product', [], 'Modules.Welcome.Admin'),
'subtitle' => [
'1' => $this->translator->trans('What do you want to tell about it? Think about what your customers want to know.', [], 'Modules.Welcome.Admin'),
'2' => $this->translator->trans('Add clear and attractive information. Don\'t worry, you can edit it later :)', [], 'Modules.Welcome.Admin'),
],
'steps' => [
[
'type' => 'tooltip',
'text' => $this->translator->trans('Give your product a catchy name.', [], 'Modules.Welcome.Admin'),
'options' => [
'savepoint',
],
'page' => [
$router->generate('admin_product_new'),
$productFormUrlPattern,
],
'selector' => '#form_step1_name_1',
'position' => 'right',
],
[
'type' => 'tooltip',
'text' => $this->translator->trans('Fill out the essential details in this tab. The other tabs are for more advanced information.', [], 'Modules.Welcome.Admin'),
'page' => $productFormUrlPattern,
'selector' => '#tab_step1',
'position' => 'right',
],
[
'type' => 'tooltip',
'text' => $this->translator->trans('Add one or more pictures so your product looks tempting!', [], 'Modules.Welcome.Admin'),
'page' => $productFormUrlPattern,
'selector' => '#product-images-dropzone',
'position' => 'right',
],
[
'type' => 'tooltip',
'text' => $this->translator->trans('How much do you want to sell it for?', [], 'Modules.Welcome.Admin'),
'page' => $productFormUrlPattern,
'selector' => '.right-column > .row > .col-md-12 > .form-group:nth-child(4) > .row > .col-md-6:first-child > .input-group',
'position' => 'left',
'action' => [
'selector' => '#product_form_save_go_to_catalog_btn',
'action' => 'click',
],
],
[
'type' => 'tooltip',
'text' => $this->translator->trans('Yay! You just created your first product. Looks good, right?', [], 'Modules.Welcome.Admin'),
'page' => $this->generateSfBaseUrl($router, 'admin_product_catalog'),
'selector' => '#product_catalog_list table tr:first-child td:nth-child(3)',
'position' => 'left',
],
],
],
[
'name' => static::STEP_THEME,
'title' => $this->translator->trans('Give your shop its own identity', [], 'Modules.Welcome.Admin'),
'subtitle' => [
'1' => $this->translator->trans('How do you want your shop to look? What makes it so special?', [], 'Modules.Welcome.Admin'),
'2' => $this->translator->trans('Customize your theme or choose the best design from our theme catalog.', [], 'Modules.Welcome.Admin'),
],
'steps' => [
[
'type' => 'tooltip',
'text' => $this->translator->trans('A good way to start is to add your own logo here!', [], 'Modules.Welcome.Admin'),
'options' => [
'savepoint',
],
'page' => $contextLink->getAdminLink('AdminThemes'),
'selector' => '#form_shop_logos_header_logo, #form_header_logo',
'position' => 'right',
],
[
'type' => 'tooltip',
'text' => $this->translator->trans('If you want something really special, have a look at the theme catalog!', [], 'Modules.Welcome.Admin'),
'page' => $contextLink->getAdminLink('AdminThemesCatalog'),
'selector' => '.addons-theme-one:first-child',
'position' => 'right',
],
],
],
[
'name' => static::STEP_PAYMENT,
'title' => $this->translator->trans('Get your shop ready for payments', [], 'Modules.Welcome.Admin'),
'subtitle' => [
'1' => $this->translator->trans('How do you want your customers to pay you?', [], 'Modules.Welcome.Admin'),
],
'steps' => [
[
'type' => 'tooltip',
'text' => $this->translator->trans('These payment methods are already available to your customers.', [], 'Modules.Welcome.Admin'),
'options' => [
'savepoint',
],
'page' => $contextLink->getAdminLink('AdminPayment'),
'selector' => '.modules_list_container_tab:first tr:first-child .text-muted, .card:eq(0) .text-muted:eq(0)',
'position' => 'right',
],
],
],
[
'name' => static::STEP_SHIPPING,
'title' => $this->translator->trans('Choose your shipping solutions', [], 'Modules.Welcome.Admin'),
'subtitle' => [
'1' => $this->translator->trans('How do you want to deliver your products?', [], 'Modules.Welcome.Admin'),
],
'steps' => [
[
'type' => 'tooltip',
'text' => $this->translator->trans('Here are the shipping methods available on your shop today.', [], 'Modules.Welcome.Admin'),
'options' => [
'savepoint',
],
'page' => $contextLink->getAdminLink('AdminCarriers'),
'selector' => '#table-carrier tr:eq(2) td:eq(3)',
'position' => 'right',
],
[
'type' => 'popup',
'text' => [
'type' => 'template',
'src' => 'end',
],
'options' => [
'savepoint',
'hideFooter',
],
'page' => $contextLink->getAdminLink('AdminDashboard'),
],
],
],
],
],
];
Hook::exec(static::HOOK_CONFIGURATION, ['data' => &$data]);
return $data;
}
/**
* generate url pattern to recognize the route as the current step url
* here we replace the route specific parameters with wildcard to allow regexp matching
*
* @param \PrestaShopBundle\Service\Routing\Router $router
* @param string $controller
* @param array $fakeParameters
*
* @return mixed|string
*/
protected function generateSfBaseUrl(Router $router, string $controller, $fakeParameters = [])
{
$url = $router->getGenerator()->generate($controller, $fakeParameters);
$url = substr($url, strlen(basename(__PS_BASE_URI__)) + 1);
$url = str_replace('/' . basename(_PS_ADMIN_DIR_) . '/', '', $url);
$url = str_replace(array_values($fakeParameters), '.+', $url);
return $url;
}
}

View File

@@ -0,0 +1,251 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
namespace OnBoarding;
use Configuration as LegacyConfiguration;
use Module;
use PrestaShopBundle\Service\Routing\Router;
use PrestaShopBundle\Translation\TranslatorComponent as Translator;
use Smarty_Data;
/**
* OnBoarding main class.
*/
class OnBoarding
{
/**
* @var array
*/
private $configuration;
/**
* @var Module
*/
private $module;
/**
* @var Translator
*/
private $translator;
/**
* @var Smarty_Data
*/
private $smarty;
/**
* OnBoarding constructor.
*
* @param Translator $translator Twig environment needed to manage the templates
* @param Smarty_Data $smarty
* @param Module $module
* @param Router $router
*/
public function __construct($translator, $smarty, $module, Router $router)
{
$this->translator = $translator;
$this->smarty = $smarty;
$this->module = $module;
$this->loadConfiguration($router);
}
/**
* Show the OnBoarding module content.
*/
public function showModuleContent()
{
$templates = [];
foreach ($this->configuration['templates'] as $template) {
$templates[] = [
'name' => $template,
'content' => str_replace(["\n", "\r", "\t"], '', $this->getTemplateContent("templates/$template")),
];
}
echo $this->getTemplateContent('content', [
'currentStep' => $this->getCurrentStep(),
'totalSteps' => $this->getTotalSteps(),
'percent_real' => ($this->getCurrentStep() / $this->getTotalSteps()) * 100,
'percent_rounded' => round(($this->getCurrentStep() / $this->getTotalSteps()) * 100),
'isShutDown' => $this->isShutDown(),
'steps' => $this->configuration['steps'],
'jsonSteps' => json_encode($this->configuration['steps']),
'templates' => $templates,
]);
}
/**
* Show the OnBoarding content for the nav bar.
*/
public function showModuleContentForNavBar()
{
echo $this->getTemplateContent('navbar', [
'currentStep' => $this->getCurrentStep(),
'totalSteps' => $this->getTotalSteps(),
'percent_real' => ($this->getCurrentStep() / $this->getTotalSteps()) * 100,
'percent_rounded' => round(($this->getCurrentStep() / $this->getTotalSteps()) * 100),
]);
}
/**
* Set the current step.
*
* @param int $step Current step ID
*
* @return bool Success of the configuration update
*/
public function setCurrentStep($step)
{
return LegacyConfiguration::updateValue('ONBOARDINGV2_CURRENT_STEP', $step);
}
/**
* Set the shut down status.
*
* @param bool $status Onboarding shut downed or not
*
* @return bool Success of the configuration update
*/
public function setShutDown($status)
{
return LegacyConfiguration::updateValue('ONBOARDINGV2_SHUT_DOWN', $status);
}
/**
* Return true if the OnBoarding is finished.
*
* @return bool True if the OnBoarding is finished
*/
public function isFinished()
{
return $this->getCurrentStep() >= $this->getTotalSteps();
}
/**
* Load all the steps with the localized texts.
*
* @param Router $router
*/
private function loadConfiguration(Router $router)
{
$configuration = new Configuration($this->translator);
$configuration = $configuration->getConfiguration($router);
foreach ($configuration['steps']['groups'] as &$currentGroup) {
if (isset($currentGroup['title'])) {
$currentGroup['title'] = $this->getTextFromSettings($currentGroup['title']);
}
if (isset($currentGroup['subtitle'])) {
foreach ($currentGroup['subtitle'] as &$subtitle) {
$subtitle = $this->getTextFromSettings($subtitle);
}
}
foreach ($currentGroup['steps'] as &$currentStep) {
$currentStep['text'] = $this->getTextFromSettings($currentStep['text']);
}
}
$this->configuration = $configuration;
}
/**
* Return a text from step text configuration.
*
* @param array $text Step text configuration
*
* @return array|mixed|string|null
*/
private function getTextFromSettings($text)
{
if (is_array($text)) {
switch ($text['type']) {
case 'template':
return $this->getTemplateContent('contents/' . $text['src']);
}
}
return $text;
}
/**
* Echoes a template.
*
* @param string $templateName Template name
*/
public function showTemplate($templateName)
{
echo $this->getTemplateContent($templateName);
}
/**
* Return a template.
*
* @param string $templateName Template name
* @param array $additionnalParameters Additionnal parameters to inject on the Twig template
*
* @return string
*/
private function getTemplateContent($templateName, $additionnalParameters = [])
{
$this->smarty->assign($additionnalParameters);
return $this->module->fetch(__DIR__ . '/../views/' . $templateName . '.tpl');
}
/**
* Return the current step.
*
* @return int Current step
*/
private function getCurrentStep()
{
return (int) LegacyConfiguration::get('ONBOARDINGV2_CURRENT_STEP');
}
/**
* Return the steps count.
*
* @return int Steps count
*/
private function getTotalSteps()
{
$total = 0;
if (null != $this->configuration) {
foreach ($this->configuration['steps']['groups'] as &$group) {
$total += count($group['steps']);
}
}
return $total;
}
/**
* Return the shut down status.
*
* @return int
*/
private function isShutDown()
{
return (int) LegacyConfiguration::get('ONBOARDINGV2_SHUT_DOWN');
}
}

View File

@@ -0,0 +1,34 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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 https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
*/
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;

1587
modules/welcome/composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>welcome</name>
<displayName><![CDATA[Welcome]]></displayName>
<version><![CDATA[6.0.7]]></version>
<description><![CDATA[Help the user to create his first product.]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[]]></tab>
<is_configurable>0</is_configurable>
<need_instance>1</need_instance>
<limited_countries></limited_countries>
</module>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>welcome</name>
<displayName><![CDATA[Witaj]]></displayName>
<version><![CDATA[6.0.7]]></version>
<description><![CDATA[Sell your first product quicker than you would have expected with our nice onboarding process.]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[]]></tab>
<is_configurable>0</is_configurable>
<need_instance>1</need_instance>
<limited_countries></limited_countries>
</module>

View File

@@ -0,0 +1,38 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
require_once _PS_MODULE_DIR_ . '/welcome/welcome.php';
class AdminWelcomeController extends ModuleAdminController
{
public function postProcess()
{
if (!isset($_POST['action'])) {
throw new Exception('The action to call is not defined.');
}
if (!isset($_POST['value'])) {
throw new Exception('The value to set is not defined.');
}
$onBoarding = new Welcome();
$onBoarding->apiCall($_POST['action'], $_POST['value']);
exit('0');
}
}

View File

@@ -0,0 +1,34 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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 https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
*/
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;

View File

@@ -0,0 +1,34 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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 https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
*/
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;

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

@@ -0,0 +1,34 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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 https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
*/
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;

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 875 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@@ -0,0 +1,34 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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 https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
*/
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;

View File

@@ -0,0 +1,22 @@
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
import '../scss/module.scss';
// eslint-disable-next-line import/no-webpack-loader-syntax
require('expose-loader?exposes[]=OnBoarding!./src/OnBoarding.js');

View File

@@ -0,0 +1,600 @@
/* eslint-disable no-underscore-dangle,no-useless-escape */
/**
* OnBoarding main class.
*/
class OnBoarding {
/**
* Constructor.
*
* @param {int} currentStep Current step ID
* @param {object} steps All steps configuration
* @param {boolean} isShutDown Did the OnBoarding is shut down ?
* @param {string} apiLocation OnBoarding API location
* @param {string} baseAdminDir Base PrestaShop admin directory
*/
constructor(currentStep, steps, isShutDown, apiLocation, baseAdminDir) {
this.currentStep = currentStep;
this.steps = steps;
this.isShutDown = isShutDown;
this.apiLocation = apiLocation;
this.baseAdminDir = baseAdminDir;
this.templates = [];
}
/**
* Add a template used by the steps.
*
* @param {string} name Name of the template
* @param {string} content Content of the template
*/
addTemplate(name, content) {
this.templates[name] = content;
}
/**
* Display the needed elements for the current step.
*/
showCurrentStep() {
$('.onboarding-navbar').toggleClass('displayed', !!this.isShutDown);
$('.onboarding-advancement').toggle(this.isShutDown === false);
$('.onboarding-popup').remove();
$('.onboarding-tooltip').remove();
const onBoardingHeight = $('.onboarding-navbar.displayed').innerHeight();
// Fix the menu scroll
if ($('#nav-sidebar').length) {
$('#nav-sidebar').css('padding-bottom', `${onBoardingHeight + 50}px`);
} else {
$('nav.nav-bar ul.main-menu').css(
'margin-bottom',
`${onBoardingHeight}px`,
);
}
if (!this.isShutDown) {
const step = this.getStep(this.currentStep);
if (OnBoarding.isCurrentPage(step.page)) {
this.prependTemplate(step.type, step.text);
if (step.type === 'tooltip') {
this.placeToolTip(step);
}
$('.onboarding-advancement').toggle(
$.inArray('hideFooter', step.options) === -1,
);
this.updateAdvancement();
} else {
$('.onboarding-advancement').toggle(false);
this.setShutDown(true);
// this.prependTemplate('lost');
}
}
}
/**
* Prepend a template to a body and add the content to its '.content' element.
*
* @param {string} templateName Template name
* @param {string} content Content to add
*/
prependTemplate(templateName, content = '') {
const newContent = $(this.templates[templateName]);
if (content !== '') {
newContent.find('.content').html(content);
}
$('body').prepend(newContent);
}
/**
* Move to the next step.
*/
gotoNextStep() {
this.gotoStep(this.currentStep + 1);
}
/**
* Go to a step defined by its index.
*
* @param {int} stepIndex Step index
*/
gotoStep(stepIndex) {
this.save({action: 'setCurrentStep', value: stepIndex}, (error) => {
if (!error) {
const currentStep = this.getStep(this.currentStep);
const nextStep = this.getStep(stepIndex);
if (!nextStep) {
$('.onboarding-popup').remove();
$('.onboarding-navbar').remove();
$('.onboarding-tooltip').remove();
return;
}
if (currentStep.action) {
$(currentStep.action.selector)[currentStep.action.action]();
} else {
this.currentStep += 1;
if (!OnBoarding.isCurrentPage(nextStep.page)) {
window.location.href = this.getRedirectUrl(nextStep);
} else {
this.showCurrentStep();
}
}
}
});
}
getTokenAsString(redirectUrl) {
let separator;
if (redirectUrl.indexOf('?') !== -1) {
separator = '&';
} else {
separator = '?';
}
const queryString = window.location.search.substr(1);
const tokens = OnBoarding.getSecurityTokens(queryString);
let tokenAsString = separator;
if (tokens._token !== undefined) {
tokenAsString = `${tokenAsString}&_token=${tokens._token}`;
}
return tokenAsString;
}
getRedirectUrl(nextStep) {
let redirectUrl;
if (Array.isArray(nextStep.page)) {
[redirectUrl] = nextStep.page;
} else {
redirectUrl = nextStep.page;
}
return redirectUrl + this.getTokenAsString(redirectUrl);
}
static parseQueryString(queryString) {
const queryStringParts = queryString.split('&');
const queryParams = {};
let parts;
let i;
let key;
let value;
for (i = 0; i < queryStringParts.length; i += 1) {
parts = queryStringParts[i].split('=');
[key, value] = parts;
queryParams[key] = value;
}
return queryParams;
}
/**
* Get security tokens from URL and navigation menu
*
* @param queryString
* @returns {{}}
*/
static getSecurityTokens(queryString) {
const queryParams = OnBoarding.parseQueryString(queryString);
const tokens = {};
if (typeof queryParams._token !== 'undefined') {
tokens._token = queryParams._token;
}
return tokens;
}
/**
* Stop the OnBoarding
*/
stop() {
this.save(
{action: 'setCurrentStep', value: this.getTotalSteps()},
(error) => {
if (!error) {
$('.onboarding-advancement').remove();
$('.onboarding-navbar').remove();
$('.onboarding-popup').remove();
$('.onboarding-tooltip').remove();
}
},
);
}
/**
* Goto the last save point step.
*/
gotoLastSavePoint() {
let lastSavePointStep = 0;
let stepCount = 0;
this.steps.groups.forEach((group) => {
group.steps.forEach((step) => {
if (
stepCount <= this.currentStep
&& $.inArray('savepoint', step.options) !== -1
) {
lastSavePointStep = stepCount;
}
stepCount += 1;
});
});
this.gotoStep(lastSavePointStep);
}
/**
* Return a group configuration for a step ID.
*
* @param {int} stepID Step ID
*
* @return {object} Group configuration
*/
getGroupForStep(stepID) {
return this.getElementForStep(stepID, 'group');
}
/**
* Return the current group ID.
*
* @return {int} Current group
*/
getCurrentGroupID() {
let currentGroupID = 0;
let currentStepID = 0;
let returnValue = 0;
this.steps.groups.forEach((group) => {
group.steps.forEach(() => {
if (currentStepID === this.currentStep) {
returnValue = currentGroupID;
}
currentStepID += 1;
});
currentGroupID += 1;
});
return returnValue;
}
/**
* Get current step ID on the group.
*
* @return {int} Step ID
*/
getCurrentStepIDOnGroup() {
let currentStepID = 0;
let stepID = 0;
let stepIDOnGroup = 0;
this.steps.groups.forEach((group) => {
stepIDOnGroup = 0;
group.steps.forEach(() => {
if (currentStepID === this.currentStep) {
stepID = stepIDOnGroup;
}
stepIDOnGroup += 1;
currentStepID += 1;
});
});
return stepID;
}
/**
* Get the step configuration for a step ID.
*
* @param {int} stepID Step ID
*
* @return {object} Step configuration
*/
getStep(stepID) {
return this.getElementForStep(stepID, 'step');
}
/**
* Return the element configuration fot a step or a group.
*
* @param {int} stepID Step ID for the element to get
* @param {string} elementType Element type (step or group)
*
* @returns {(object|null)} Element configuration if it exists
*/
getElementForStep(stepID, elementType) {
let currentStepID = 0;
let element = null;
this.steps.groups.forEach((group) => {
group.steps.forEach((step) => {
if (currentStepID === stepID) {
if (elementType === 'step') {
element = step;
} else if (elementType === 'group') {
element = group;
}
}
currentStepID += 1;
});
});
return element;
}
/**
* Call the save ajax api of the module.
*
* @param {object} settings Settings to save via POST
* @param {function} callback Callback function called after the execution
*/
save(settings, callback) {
$.ajax({
method: 'POST',
url: this.apiLocation,
data: settings,
})
.done((result) => {
callback(result !== '0');
})
.fail(() => {
callback(true);
});
}
/**
* Update the advancement footer.
*/
updateAdvancement() {
const advancementFooter = $('.onboarding-advancement');
const advancementNav = $('.onboarding-navbar');
let totalSteps = 0;
this.steps.groups.forEach((group, index) => {
const positionOnChunk = Math.min(
this.currentStep + 1 - totalSteps,
group.steps.length,
);
advancementFooter
.find(`.group-${index} .advancement`)
.css('width', `${(positionOnChunk / group.steps.length) * 100}%`);
totalSteps += group.steps.length;
if (positionOnChunk === group.steps.length) {
const id = advancementFooter.find(`.group-${index} .id`);
if (!id.hasClass('-done')) {
id.addClass('-done');
}
}
});
advancementFooter
.find('.group-title')
.html(
`${this.getCurrentGroupID() + 1}/${this.getTotalGroups()} - ${
this.getGroupForStep(this.currentStep).title
}`,
);
if (this.getGroupForStep(this.currentStep).subtitle) {
if (this.getGroupForStep(this.currentStep).subtitle[1]) {
advancementFooter
.find('.step-title-1')
.html(
`<i class="material-icons">check</i> ${
this.getGroupForStep(this.currentStep).subtitle[1]
}`,
);
}
if (this.getGroupForStep(this.currentStep).subtitle[2]) {
advancementFooter
.find('.step-title-2')
.html(
`<i class="material-icons">check</i> ${
this.getGroupForStep(this.currentStep).subtitle[2]
}`,
);
}
}
const totalAdvancement = this.currentStep / this.getTotalSteps();
advancementNav
.find('.text')
.find('.text-right')
.html(`${Math.floor(totalAdvancement * 100)}%`);
advancementNav.find('.progress-bar').width(`${totalAdvancement * 100}%`);
}
/**
* Return the total steps count.
*
* @return {int} Total steps.
*/
getTotalSteps() {
let total = 0;
this.steps.groups.forEach((group) => {
total += group.steps.length;
});
return total;
}
/**
* Return the total groups count.
*
* @return {int} Total groups.
*/
getTotalGroups() {
return this.steps.groups.length;
}
/**
* Shut down or reactivate the onBoarding.
*
* @param {boolean} value True to shut down, false to activate.
*/
setShutDown(value) {
this.isShutDown = value ? 1 : 0;
if (this.isShutDown === 1) {
$('.onboarding-advancement').toggle(false);
$('.onboarding-navbar').toggleClass('displayed', true);
$('.onboarding-popup').remove();
$('.onboarding-tooltip').remove();
}
this.save({action: 'setShutDown', value: this.isShutDown}, (error) => {
if (!error) {
if (this.isShutDown === 0) {
if (OnBoarding.isCurrentPage(this.getStep(this.currentStep).page)) {
this.showCurrentStep();
} else {
this.gotoLastSavePoint();
}
}
}
});
}
/**
* Return true if the url correspond to the current page.
*
* @param {(string|Array)} url Url to test
*
* @return {boolean} True if the url correspond to the current page
*/
static isCurrentPage(url) {
const currentPage = window.location.href;
let urls;
if (!$.isArray(url)) {
urls = [String(url)];
} else {
urls = url;
}
let isCurrentUrl = false;
urls.forEach((currentUrl) => {
// replace special chars for correct regexp testing
const currentUrlFixed = currentUrl.replace(/[\?\$]/g, '\\$&');
const urlRegexp = new RegExp(currentUrlFixed, 'i');
if (urlRegexp.test(currentPage)) {
isCurrentUrl = true;
}
});
return isCurrentUrl;
}
/**
* Show a tooltip for a step.
*
* @param {object} step Step configuration
*/
placeToolTip(step) {
this.tooltipElement = $(step.selector);
this.tooltip = $('.onboarding-tooltip');
this.tooltip.hide();
if (!this.tooltipElement.is(':visible')) {
setTimeout(() => {
this.placeToolTip(step);
}, 100);
if (this.tooltipPlacementInterval !== undefined) {
clearInterval(this.tooltipPlacementInterval);
}
return;
}
this.tooltipPlacementInterval = setInterval(() => {
this.updateToolTipPosition(step);
}, 100);
this.tooltip.show();
this.tooltip.addClass(`-${step.position}`);
this.tooltip.data('position', step.position);
const currentStepIDOnGroup = this.getCurrentStepIDOnGroup();
const groupStepsCount = this.getGroupForStep(this.currentStep).steps.length;
this.tooltip
.find('.count')
.html(`${currentStepIDOnGroup + 1}/${groupStepsCount}`);
const bullsContainer = this.tooltip.find('.bulls');
for (let idStep = 0; idStep < groupStepsCount; idStep += 1) {
const newElement = $('<div></div>').addClass('bull');
if (idStep < currentStepIDOnGroup) {
newElement.addClass('-done');
}
if (idStep === currentStepIDOnGroup) {
newElement.addClass('-current');
}
bullsContainer.append(newElement);
}
setTimeout(() => {
if (this.tooltipElement.offset().top > window.screen.height / 2 - 200) {
window.scrollTo(
0,
this.tooltipElement.offset().top - (window.screen.height / 2 - 200),
);
}
}, 200);
this.updateToolTipPosition();
}
/**
* Update the position of the tooltip.
*/
updateToolTipPosition() {
/* eslint-disable */
const middleX =
this.tooltipElement.offset().top -
this.tooltipElement.outerHeight() / 2 -
this.tooltip.outerHeight() / 2;
const middleY =
this.tooltipElement.offset().top +
this.tooltipElement.outerHeight() / 2 -
this.tooltip.outerHeight() / 2;
const topY =
this.tooltipElement.offset().top +
this.tooltipElement.outerHeight() / 2 -
this.tooltip.outerHeight() / 2;
/* eslint-enable */
const leftX = this.tooltipElement.offset().left - this.tooltip.outerWidth();
const rightX = this.tooltipElement.offset().left + this.tooltipElement.outerWidth();
switch (this.tooltip.data('position')) {
case 'right':
this.tooltip.css({left: rightX, top: middleY});
break;
case 'left':
this.tooltip.css({left: leftX, top: middleY});
break;
case 'top':
this.tooltip.css({left: middleX, top: topY});
break;
default:
}
}
}
module.exports = OnBoarding;

View File

@@ -0,0 +1,34 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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 https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
*/
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;

BIN
modules/welcome/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

8170
modules/welcome/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 875 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,96 @@
@import "settings";
.onboarding-advancement {
font-family: Open Sans,sans-serif; // Forced because of old theme
font-weight: normal; // Forced because of old theme
position: fixed;
background: $background-color;
height: 6.875rem;
bottom: 0;
right: 0;
left: 13.125rem;
z-index: $minimum-z-index - 1;
.btn-primary {
background: $primary-color;
background: $primary-color !important; // Forced because of old theme
}
.col-md-8 { // Forced because of old theme
padding-left: 0.9375rem;
}
.group-title {
font-weight: bold; // Forced because of old theme
font-family: Open Sans,sans-serif; // Forced because of old theme
color: $dark-color;
font-size: 1rem;
margin-top: 0.625rem;
}
.step-title {
font-size: 0.875rem; // Forced because of old theme
line-height: 1.25rem; // Forced because of old theme
.material-icons {
color: $primary-color;
font-size: 1.125rem;
vertical-align: bottom;
margin-bottom: 1px;
}
}
.onboarding-button-next {
position: absolute;
right: 0.625rem;
top: 1.25rem;
}
.onboarding-button-shut-down {
position: absolute;
right: 0.625rem;
bottom: 1.875rem;
color: $dark-color;
font-size: 0.6875rem;
cursor: pointer;
}
> .advancement-groups {
width: 100%;
> .group {
float: left;
height: 0.625rem;
background: $dark-color;
position: relative;
}
> .group > .advancement {
height: 0.625rem;
background: $primary-color;
transition: all 0.8s;
}
> .group > .id {
position: absolute;
box-sizing: border-box;
background-color: $dark-color;
border: 1px solid $background-color;
border-radius: 1.25rem;
text-align: center;
vertical-align: middle;
line-height: 1.25rem;
height: 1.25rem;
width: 1.25rem;
color: white;
font-size: 0.75rem;
right: -1px;
top: -5px;
z-index: 1;
}
> .group > .id.-done {
background-color: $primary-color;
}
}
}

View File

@@ -0,0 +1,83 @@
.page-sidebar-closed {
.onboarding-navbar.displayed {
display: none;
}
}
.onboarding-navbar {
display: none;
}
.onboarding-navbar.displayed {
display: block;
font-weight: normal;
box-sizing: border-box;
width: $size-navbar-width;
padding: 0.625rem;
padding-bottom: 2.1875rem; // Forced because of old theme
background: $navbar-footer-color;
position: fixed;
bottom: 0;
font-size: 0.6875rem;
text-align: center;
> .text {
text-align: left;
color: $navbar-text-color;
padding-bottom: 0.625rem;
}
.onboarding-button-resume {
// Forced because of old theme
background: #1e2024;
color: #95a7ad;
}
.btn {
background: $navbar-progress-secondary-color;
color: $navbar-text-color;
text-transform: uppercase; // Forced because of old theme
margin: 0 auto;
font-size: 0.625rem;
padding: 0.375rem 0.9375rem;
&:hover {
// Forced because of old theme
color: #95a7ad !important; // Forced because of old theme
}
}
.btn.-small {
margin-top: 2px;
font-size: 0.5rem;
padding: 0.25rem;
text-transform: none;
background: $navbar-footer-color;
font-size: 0.625rem !important; // Forced because of old theme
text-transform: none; // Forced because of old theme
color: #95a7ad !important; // Forced because of old theme
&:hover {
// Forced because of old theme
color: #95a7ad !important; // Forced because of old theme
text-decoration: underline; // Forced because of old theme
}
}
> .btn.-small:hover {
text-decoration: underline;
}
> .progress {
border-radius: $navbar-progress-size;
height: $navbar-progress-size;
background: $navbar-progress-secondary-color;
margin-bottom: 1rem;
}
> .progress > .bar {
border-radius: $navbar-progress-size;
background: $navbar-progress-primary-color;
height: $navbar-progress-size;
}
}

View File

@@ -0,0 +1,185 @@
.onboarding-popup {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba($dark-color, 0.5);
z-index: $minimum-z-index;
> .content {
position: absolute;
width: $popup-width;
left: 50%;
margin-left: -$popup-width / 2;
top: 2.5rem;
padding: 0;
background: white;
box-shadow: 2px 2px 3px 0 rgba(0, 0, 0, 0.1);
}
}
.onboarding-welcome {
.welcome {
background: url('../images/preston-clouds.png') top no-repeat;
background-size: 35rem 10.25rem;
padding-top: 10.25rem;
height: 3.25rem;
color: black;
font-size: 1.5rem;
text-align: center;
margin-bottom: 0;
}
> .content {
padding-bottom: 5.625rem;
min-height: 12.5rem;
font-size: 0.875rem;
background: url('../images/balloons.png') bottom no-repeat;
background-size: 15rem 5.0625rem;
margin-top: 2.5rem;
display: flex;
flex-direction: column;
p {
display: flex;
text-align: center;
align-self: center;
width: 25rem;
}
}
.started {
display: flex;
font-weight: 600;
font-size: 1.0625rem;
justify-content: center;
}
> .content {
margin-bottom: 1.25rem;
}
> .material-icons {
color: $background-tertiary-color;
position: absolute;
top: 0.625rem;
right: 0.9375rem;
cursor: pointer;
font-size: 1.875rem;
}
.buttons {
display: flex;
justify-content: center;
margin-bottom: 1.5625rem;
}
.btn-primary.blue-balloon {
background-color: $blue-balloon;
}
.btn-tertiary-outline {
background: none;
color: $blue-balloon;
border: 2px solid $blue-balloon;
text-transform: uppercase;
box-sizing: border-box;
padding: 9px 16px;
margin-right: 20px;
}
}
.onboarding-popup {
h2 {
font-size: 1.5rem;
}
#onboarding-welcome {
&.modal-header {
padding: 1.5rem;
.close {
color: #000;
font-size: 2.5rem;
margin-top: -14px;
margin-right: -5px;
opacity: 0.4;
}
}
.btn {
background-color: $blue-balloon;
font-size: 0.9375rem;
font-weight: normal;
letter-spacing: normal;
}
.link-container {
.close {
color: #000;
font-size: 40px;
margin-top: -15px;
}
.starter-guide,
.video-tutorial,
.forum,
.training {
width: 9.375rem;
height: 8.125rem;
}
.starter-guide {
background: url('../images/starter-guide.png') no-repeat;
}
.video-tutorial {
background: url('../images/video-tutorial.png') no-repeat;
}
.forum {
background: url('../images/forum.png') no-repeat;
}
.training {
background: url('../images/training.png') no-repeat;
}
.final-link {
border-width: 0;
color: #363a41;
display: block;
font-weight: 600;
justify-content: center;
padding: 0;
position: relative;
margin-left: auto;
margin-right: auto;
text-align: center;
width: 9.375rem;
&:hover {
box-shadow: 2px 2px 4px 0 rgba(0, 0, 0, 0.25);
}
.link {
bottom: 0;
line-height: 16px;
position: absolute;
padding: 10px;
display: block;
text-align: center;
width: 100%;
}
}
}
}
}

View File

@@ -0,0 +1,24 @@
$navbar-footer-color: #292c32;
$navbar-progress-secondary-color: #1e2024;
$navbar-progress-primary-color: #fbb000;
$navbar-text-color: #95a7ad;
$popup-width: 35rem;
$navbar-progress-size: 8px;
$minimum-z-index: 1500;
$background-color: #dff5f9;
$primary-color: #25b9d7;
$dark-color: #363a41;
$dark-light-color: #6c868e;
$background-secondary-color: #bbcdd2;
$background-tertiary-color: #6c868e;
$blue-balloon: #2eacce;
$tooltip-border: 1px solid;
$tooltip-radius: 5px;
$size-navbar-width: 210px;

View File

@@ -0,0 +1,149 @@
.onboarding-tooltip {
@mixin addTriangle($size, $color) {
left: 100%;
top: 50%;
border: $size solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
border-left-color: $color;
margin-top: -$size;
}
@mixin addTriangleDown($size, $color) {
@include addTriangle($size, $color);
left: 50%;
top: 100%;
margin-top: 0;
transform: rotate(90deg);
}
@mixin addPreston($url, $width, $height, $offset) {
content: " ";
position: absolute;
top: 0.625rem;
width: $width;
height: $height;
background: url($url) no-repeat;
background-size: $width $height;
left: $offset;
z-index: 1;
}
font-family: Open Sans,sans-serif; // Forced because of old theme
font-size: 0.875rem; // Forced because of old theme
position: absolute;
box-sizing: border-box;
opacity: 1;
padding: 0.625rem 0.625rem 3.25rem 2.375rem;
width: 18.125rem;
min-height: 9.375rem;
z-index: $minimum-z-index + 2;
background: $background-color;
border-radius: $tooltip-radius;
border: $tooltip-border $primary-color;
&.-left {
margin-left: -0.75rem;
> .content {
&:before {
@include addPreston('../images/preston-right.png', 5.5rem, 9.5625rem, -3.8125rem);
}
}
&:after {
@include addTriangle(0.75rem, $background-color);
}
&:before {
@include addTriangle(0.75rem, $primary-color);
}
}
&.-right {
margin-left: 4.3125rerm;
> .content {
&:before {
@include addPreston('../images/preston-left.png', 6.5rem, 9.5625rem, -4.375rem);
}
}
}
&.-top {
margin-top: -2.6875rem;
margin-left: 2.8125rem;
> .content {
&:before {
@include addPreston('../images/preston-right.png', 6.5rem, 9.5625rem, -4.375rem);
}
}
&:after {
@include addTriangleDown(0.75rem, $dark-color);
}
&:before {
@include addTriangleDown(0.8125rem, $primary-color);
}
}
> .btn-primary {
text-transform: uppercase;
position: absolute;
bottom: 0.3125rem;
right: 0.3125rem;
padding: /* 0.1875rem */ 0 0.5rem;
background: $primary-color; // Forced because of old theme
color: white; // Forced because of old theme
font-size: 0.75rem; // Forced because of old theme
border-radius: 0.1875rem; // Forced because of old theme
border: none; // Forced because of old theme
vertical-align: middle; // Forced because of old theme
height: 1.5625rem; // Forced because of old theme
line-height: 1.5625rem; // Forced because of old theme
}
}
.onboarding-tooltipsteps {
position: absolute;
height: 2.5rem;
line-height: 2.5rem;
vertical-align: middle;
bottom: 0;
left: 0;
right: 0;
background: $dark-color;
padding-left: 3.125rem;
> .total {
color: $primary-color;
font-size: 0.625rem;
}
> .bulls {
text-align: center;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
> .bulls > .bull {
height: 0.375rem;
width: 0.375rem;
border-radius: 0.375rem;
background: $background-secondary-color;
display: inline-block;
margin: 0 1px 1px 1px;
}
> .bulls > .bull.-current {
background: $primary-color;
}
> .bulls > .bull.-done {
background: $dark-light-color;
}
}

View File

@@ -0,0 +1,34 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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 https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
*/
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;

View File

@@ -0,0 +1,65 @@
@import "~bourbon/core/bourbon";
@import "settings";
@import 'advancement';
@import 'navbar';
@import 'tooltip';
@import 'popup';
#onboarding-welcome {
.final-link {
display: block;
border: 1px solid #BBCDD2;
border-radius: 3px;
padding: 1.25rem;
margin: 0.4375rem 0;
text-decoration: none;
> i {
color: #BBCDD2;
font-size: 4rem;
margin-bottom: 1.5rem;
}
}
}
.btn {
&.with-spinner {
position: relative;
}
&.with-spinner.animated {
border-color: white;
background: white;
outline-color: white;
&:hover {
border-color: white;
background: white;
}
&:after {
position: absolute;
width: 1.875rem;
height: 1.875rem;
left: 50%;
top: 50%;
margin: {
top: -0.9375rem;
left: -0.9375rem;
}
display: block;
border: 3px solid $primary-color;
border-top-color: transparent;
border-radius: 3.125rem;
background: transparent;
content: '';
-webkit-animation:spin 4s linear infinite;
-moz-animation:spin 4s linear infinite;
animation:spin 4s linear infinite;
}
}
}
@-moz-keyframes spin { 100% { -moz-transform: rotate(360deg); } }
@-webkit-keyframes spin { 100% { -webkit-transform: rotate(360deg); } }
@keyframes spin { 100% { -webkit-transform: rotate(360deg); transform:rotate(360deg); } }

View File

View File

@@ -0,0 +1,74 @@
{**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<div class="onboarding-advancement" style="display: none">
<div class="advancement-groups">
{foreach from=$steps.groups item=group key=index}
<div class="group group-{$index}" style="width: {math equation="(x / y) * 100" x=$group.steps|@count y=$totalSteps}%;">
<div class="advancement" style="width: {$percent_real}%;"></div>
<div class="id">{$index+1}</div>
</div>
{/foreach}
</div>
<div class="col-md-8">
<h4 class="group-title"></h4>
<div class="step-title step-title-1"></div>
<div class="step-title step-title-2"></div>
</div>
<button class="btn btn-primary onboarding-button-next">{l s='Continue' d='Modules.Welcome.Admin'}</button>
<a class="onboarding-button-shut-down">{l s='Skip this tutorial' d='Modules.Welcome.Admin'}</a>
</div>
<script type="text/javascript">
var onBoarding;
$(function(){
onBoarding = new OnBoarding({$currentStep}, {$jsonSteps nofilter}, {$isShutDown}, "{$link->getAdminLink('AdminWelcome')}", baseAdminDir);
{foreach from=$templates item=template}
onBoarding.addTemplate('{$template['name']}', '{$template['content']}');
{/foreach}
onBoarding.showCurrentStep();
var body = $("body");
body.delegate(".onboarding-button-next", "click", function(){
if ($(this).is('.with-spinner')) {
if (!$(this).is('.animated')) {
$(this).addClass('animated');
onBoarding.gotoNextStep();
}
} else {
onBoarding.gotoNextStep();
}
}).delegate(".onboarding-button-shut-down", "click", function(){
onBoarding.setShutDown(true);
}).delegate(".onboarding-button-resume", "click", function(){
onBoarding.setShutDown(false);
}).delegate(".onboarding-button-goto-current", "click", function(){
onBoarding.gotoLastSavePoint();
}).delegate(".onboarding-button-stop", "click", function(){
onBoarding.stop();
});
});
</script>

View File

@@ -0,0 +1,68 @@
{**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<div id="onboarding-welcome" class="modal-body">
<div class="col-12">
<button class="onboarding-button-next pull-right close" type="button">&times;</button>
<h2 class="text-center text-md-center">{l s='Over to you!' d='Modules.Welcome.Admin'}</h2>
</div>
<div class="col-12">
<p class="text-center text-md-center">
{l s='You\'ve seen the essential, but there\'s a lot more to explore.' d='Modules.Welcome.Admin'}<br />
{l s='Some ressources can help you go further:' d='Modules.Welcome.Admin'}
</p>
<div class="container-fluid">
<div class="row">
<div class="col-md-6 justify-content-center text-center text-md-center link-container">
<a class="final-link" href="http://doc.prestashop.com/display/PS17/Getting+Started" target="_blank">
<div class="starter-guide"></div>
<span class="link">{l s='Starter Guide' d='Modules.Welcome.Admin'}</span>
</a>
</div>
<div class="col-md-6 text-center text-md-center link-container">
<a class="final-link" href="https://www.prestashop.com/forums/" target="_blank">
<div class="forum"></div>
<span class="link">{l s='Forum' d='Modules.Welcome.Admin'}</span>
</a>
</div>
</div>
<div class="row">
<div class="col-md-6 text-center text-md-center link-container">
<a class="final-link" href="https://www.prestashop.com/en/training-prestashop" target="_blank">
<div class="training"></div>
<span class="link">{l s='Training' d='Modules.Welcome.Admin'}</span>
</a>
</div>
<div class="col-md-6 text-center text-md-center link-container">
<a class="final-link" href="https://www.youtube.com/user/prestashop" target="_blank">
<div class="video-tutorial"></div>
<span class="link">{l s='Video tutorial' d='Modules.Welcome.Admin'}</span>
</a>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<div class="col-12">
<div class="text-center text-md-center">
<button class="btn btn-primary onboarding-button-next">{l s='I\'m ready' d='Modules.Welcome.Admin'}</button>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,34 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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 https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
*/
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;

View File

@@ -0,0 +1,35 @@
{**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<div class="onboarding-welcome">
<i class="material-icons onboarding-button-shut-down">close</i>
<p class="welcome">{l s='Welcome to your shop!' d='Modules.Welcome.Admin'}</p>
<div class="content">
<p>{l s='Hi! My name is Preston and I\'m here to show you around.' d='Modules.Welcome.Admin'}</p>
<p>{l s='You will discover a few essential steps before you can launch your shop:' d='Modules.Welcome.Admin'}
{l s='Create your first product, customize your shop, configure shipping and payments...' d='Modules.Welcome.Admin'}</p>
</div>
<div class="started">
<p>{l s='Let\'s get started!' d='Modules.Welcome.Admin'}</p>
</div>
<div class="buttons">
<button class="btn btn-tertiary-outline btn-lg onboarding-button-shut-down">{l s='Later' d='Modules.Welcome.Admin'}</button>
<button class="blue-balloon btn btn-primary btn-lg with-spinner onboarding-button-next">{l s='Start' d='Modules.Welcome.Admin'}</button>
</div>
</div>

View File

@@ -0,0 +1,34 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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 https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
*/
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;

View File

@@ -0,0 +1,36 @@
{**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<div class="onboarding-navbar bootstrap">
<div class="row text">
<div class="col-md-8">
{l s='Launch your shop!' d='Modules.Welcome.Admin'}
</div>
<div class="col-md-4 text-right text-md-right">{$percent_rounded}%</div>
</div>
<div class="progress">
<div class="bar" role="progressbar" style="width:{$percent_real}%;"></div>
</div>
<div>
<button class="btn btn-main btn-sm onboarding-button-resume">{l s='Resume' d='Modules.Welcome.Admin'}</button>
</div>
<div>
<a class="btn -small btn-main btn-sm onboarding-button-stop">{l s='Stop the OnBoarding' d='Modules.Welcome.Admin'}</a>
</div>
</div>

View File

@@ -0,0 +1,34 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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 https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
*/
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;

View File

@@ -0,0 +1,32 @@
{**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<div class="onboarding onboarding-popup bootstrap">
<div class="content">
<p>{l s='Hey! Are you lost?' d='Modules.Welcome.Admin'}</p>
<p>{l s='To continue, click here:' d='Modules.Welcome.Admin'}</p>
<div class="text-center">
<button class="btn btn-primary onboarding-button-goto-current">{l s='Continue' d='Modules.Welcome.Admin'}</button>
</div>
<p>{l s='If you want to stop the tutorial for good, click here:' d='Modules.Welcome.Admin'}</p>
<div class="text-center">
<button class="btn btn-alert onboarding-button-stop">{l s='Quit the Welcome tutorial' d='Modules.Welcome.Admin'}</button>
</div>
</div>
</div>

View File

@@ -0,0 +1,22 @@
{**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<div class="onboarding-popup bootstrap">
<div class="content"></div>
</div>

View File

@@ -0,0 +1,28 @@
{**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<div class="onboarding-tooltip">
<div class="content"></div>
<div class="onboarding-tooltipsteps">
<div class="total">{l s='Step' d='Modules.Welcome.Admin'} <span class="count">1/5</span></div>
<div class="bulls">
</div>
</div>
<button class="btn btn-primary btn-xs onboarding-button-next">{l s='Next' d='Modules.Welcome.Admin'}</button>
</div>

View File

@@ -0,0 +1,66 @@
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
entry: [
'./js/module.js',
],
output: {
path: './public',
filename: 'module.js',
},
module: {
loaders: [{
test: path.join(__dirname, 'js'),
loader: 'babel',
query: {
presets: ['es2015'],
},
}, {
test: /\.scss$/,
loader: ExtractTextPlugin.extract('style', 'css!sass'),
}, {
test: /\.css$/,
loader: ExtractTextPlugin.extract('style', 'css?sourceMap!postcss!sass?sourceMap'),
}, {
test: /.(png|woff(2)?|eot|ttf|svg)(\?[a-z0-9=]+)?$/,
loader: 'file-loader?name=[hash].[ext]',
}],
},
plugins: [
new ExtractTextPlugin('module.css'),
new webpack.optimize.UglifyJsPlugin({
sourceMap: false,
compress: {
sequences: true,
conditionals: true,
booleans: true,
if_return: true,
join_vars: true,
drop_console: true,
},
output: {
comments: false,
},
}),
],
};

231
modules/welcome/welcome.php Normal file
View File

@@ -0,0 +1,231 @@
<?php
/**
* 2007-2020 PrestaShop and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (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:
* https://opensource.org/licenses/AFL-3.0
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
if (!defined('_PS_VERSION_')) {
exit;
}
$autoloadPath = __DIR__ . '/vendor/autoload.php';
if (file_exists($autoloadPath)) {
require_once $autoloadPath;
}
use OnBoarding\OnBoarding;
use PrestaShop\PrestaShop\Adapter\SymfonyContainer;
/**
* OnBoarding module entry class.
*/
class Welcome extends Module
{
const CLASS_NAME = 'AdminWelcome';
/**
* @var string Name of the module running on PS 1.6.x. Used for data migration.
*/
const PS_16_EQUIVALENT_MODULE = 'onboarding';
/**
* @var OnBoarding
*/
private $onBoarding;
/**
* @var bool
*/
private $displayHeader = true;
/**
* Module's constructor.
*/
public function __construct()
{
$this->name = 'welcome';
$this->version = '6.0.7';
$this->author = 'PrestaShop';
parent::__construct();
$this->displayName = $this->trans('Welcome', [], 'Modules.Welcome.Admin');
$this->description = $this->trans('Sell your first product quicker than you would have expected with our nice onboarding process.', [], 'Modules.Welcome.Admin');
$this->ps_versions_compliancy = [
'min' => '1.7.6.0',
'max' => _PS_VERSION_,
];
// If the symfony container is not available or if we are not in the admin directory
// this constructor will fail.
// This can happen during the upgrade process
if (null == SymfonyContainer::getInstance() || !defined('_PS_ADMIN_DIR_')) {
return;
}
if (Module::isInstalled($this->name)) {
$smartyDisplayHeader = $this->smarty->getTemplateVars('display_header');
$this->displayHeader = (null !== $smartyDisplayHeader && is_bool($smartyDisplayHeader)) ?
$smartyDisplayHeader :
true;
$this->onBoarding = new OnBoarding(
$this->getTranslator(),
$this->smarty,
$this,
SymfonyContainer::getInstance()->get('router')
);
if (Tools::getIsset('resetonboarding')) {
$this->onBoarding->setShutDown(false);
$this->onBoarding->setCurrentStep(0);
}
}
}
/**
* Module installation.
*
* @return bool Success of the installation
*/
public function install()
{
$this->uninstallPrestaShop16Module();
return parent::install()
&& $this->installTab()
&& $this->registerHook('displayAdminNavBarBeforeEnd')
&& $this->registerHook('displayAdminAfterHeader')
&& $this->registerHook('displayBackOfficeHeader');
}
public function installTab()
{
$tab = new Tab();
$tab->active = true;
$tab->class_name = static::CLASS_NAME;
$tab->name = [];
foreach (Language::getLanguages(true) as $lang) {
$tab->name[$lang['id_lang']] = 'Welcome';
}
$tab->module = $this->name;
return $tab->add();
}
public function uninstallTab()
{
$id_tab = (int) Tab::getIdFromClassName(static::CLASS_NAME);
if ($id_tab) {
$tab = new Tab($id_tab);
return $tab->delete();
} else {
return false;
}
}
/**
* Uninstall the module.
*
* @return bool Success of the uninstallation
*/
public function uninstall()
{
$this->onBoarding->setCurrentStep(0);
$this->onBoarding->setShutDown(false);
$this->uninstallTab();
return parent::uninstall();
}
/**
* Migrate data from 1.6 equivalent module (if applicable), then uninstall
*/
public function uninstallPrestaShop16Module()
{
if (!Module::isInstalled(self::PS_16_EQUIVALENT_MODULE)) {
return false;
}
$oldModule = Module::getInstanceByName(self::PS_16_EQUIVALENT_MODULE);
if ($oldModule) {
// This closure calls the parent class to prevent data to be erased
// It allows the new module to be configured without migration
$parentUninstallClosure = function () {
return parent::uninstall();
};
$parentUninstallClosure = $parentUninstallClosure->bindTo($oldModule, get_class($oldModule));
$parentUninstallClosure();
}
return true;
}
/**
* Hook called when the backoffice header is displayed.
*/
public function hookDisplayBackOfficeHeader()
{
if (!$this->onBoarding->isFinished()) {
$this->context->controller->addCSS($this->_path . 'public/module.css', 'all');
$this->context->controller->addJS($this->_path . 'public/module.js');
}
}
/**
* Hook called after the header of the backoffice.
*/
public function hookDisplayAdminAfterHeader()
{
if (!$this->onBoarding->isFinished()) {
$this->onBoarding->showModuleContent();
}
}
/**
* Hook called before the end of the nav bar.
*/
public function hookDisplayAdminNavBarBeforeEnd()
{
if (!$this->onBoarding->isFinished()) {
$this->onBoarding->showModuleContentForNavBar();
}
}
/**
* Execute an API like action for the OnBoarding.
*
* @param string $action Action to perform
* @param mixed $value Value to assign to the action
*
* @throws Exception
*/
public function apiCall($action, $value)
{
switch ($action) {
case 'setCurrentStep':
if (!$this->onBoarding->setCurrentStep($value)) {
throw new Exception('The current step cannot be saved.');
}
break;
case 'setShutDown':
if (!$this->onBoarding->setShutDown($value)) {
throw new Exception('The shut down status cannot be saved.');
}
break;
}
}
}