update
This commit is contained in:
@@ -1,31 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2016 PrestaShop
|
||||
* 2007-2020 PrestaShop and Contributors
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* 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:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* 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 http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2015 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* @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;
|
||||
|
||||
@@ -34,10 +29,16 @@ class Configuration
|
||||
/**
|
||||
* Module Dependency
|
||||
*/
|
||||
const MODULE_MBO = 'ps_mbo';
|
||||
|
||||
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)
|
||||
@@ -55,7 +56,6 @@ class Configuration
|
||||
['id' => static::FAKE_ID]
|
||||
);
|
||||
|
||||
|
||||
$data = [
|
||||
'templates' => [
|
||||
'lost',
|
||||
@@ -65,6 +65,7 @@ class Configuration
|
||||
'steps' => [
|
||||
'groups' => [
|
||||
[
|
||||
'name' => static::STEP_DASHBOARD,
|
||||
'steps' => [
|
||||
[
|
||||
'type' => 'popup',
|
||||
@@ -81,6 +82,7 @@ class Configuration
|
||||
],
|
||||
],
|
||||
[
|
||||
'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'),
|
||||
@@ -135,6 +137,7 @@ class Configuration
|
||||
],
|
||||
],
|
||||
[
|
||||
'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'),
|
||||
@@ -148,7 +151,7 @@ class Configuration
|
||||
'savepoint',
|
||||
],
|
||||
'page' => $contextLink->getAdminLink('AdminThemes'),
|
||||
'selector' => '#js_theme_form_container .tab-content.panel .btn:first-child',
|
||||
'selector' => '#form_shop_logos_header_logo, #form_header_logo',
|
||||
'position' => 'right',
|
||||
],
|
||||
[
|
||||
@@ -160,114 +163,61 @@ class Configuration
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
'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'),
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$paymentSteps = [
|
||||
'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',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
if (Module::isInstalled(self::MODULE_MBO) && Module::isEnabled(self::MODULE_MBO)) {
|
||||
$paymentSteps['subtitle']['2'] = $this->translator->trans(
|
||||
'Adapt your offer to your market: add the most popular payment methods for your customers!',
|
||||
[],
|
||||
'Modules.Welcome.Admin'
|
||||
);
|
||||
$paymentSteps['steps'][] = [
|
||||
'type' => 'tooltip',
|
||||
'text' => $this->translator->trans('And you can choose to add other payment methods from here!', [], 'Modules.Welcome.Admin'),
|
||||
'page' => $contextLink->getAdminLink('AdminPayment'),
|
||||
'selector' => '.panel:eq(1) table tr:eq(0) td:eq(1), .card:eq(1) .module-item-list div:eq(0) div:eq(1)',
|
||||
'position' => 'top',
|
||||
];
|
||||
}
|
||||
$data['steps']['groups'][] = $paymentSteps;
|
||||
|
||||
$shippingSteps = [
|
||||
'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',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
if (Module::isInstalled(self::MODULE_MBO) && Module::isEnabled(self::MODULE_MBO)) {
|
||||
$shippingSteps['subtitle']['2'] = $this->translator->trans(
|
||||
'Select the shipping solutions the most likely to suit your customers! Create your own carrier or add a ready-made module.',
|
||||
[],
|
||||
'Modules.Welcome.Admin'
|
||||
);
|
||||
|
||||
$shippingSteps['steps'][] = [
|
||||
'type' => 'tooltip',
|
||||
'text' => $this->translator->trans('You can offer more delivery options by setting up additional carriers', [], 'Modules.Welcome.Admin'),
|
||||
'page' => $contextLink->getAdminLink('AdminCarriers'),
|
||||
'selector' => '.modules_list_container_tab tr:eq(0) .text-muted',
|
||||
'position' => 'right',
|
||||
];
|
||||
}
|
||||
$data['steps']['groups'][] = $shippingSteps;
|
||||
|
||||
|
||||
$moduleSteps = [
|
||||
'title' => $this->translator->trans('Improve your shop with modules', [], 'Modules.Welcome.Admin'),
|
||||
'subtitle' => [
|
||||
'1' => $this->translator->trans('Add new features and manage existing ones thanks to modules.', [], 'Modules.Welcome.Admin'),
|
||||
'2' => $this->translator->trans('Some modules are already pre-installed, others may be free or paid modules - browse our selection and find out what is available!', [], 'Modules.Welcome.Admin'),
|
||||
],
|
||||
'steps' => [
|
||||
[
|
||||
'type' => 'tooltip',
|
||||
'text' => $this->translator->trans('Discover our module selection in the first tab. Manage your modules on the second one and be aware of notifications in the third tab.', [], 'Modules.Welcome.Admin'),
|
||||
'options' => [
|
||||
'savepoint',
|
||||
],
|
||||
'page' => $router->generate('admin_module_catalog'),
|
||||
'selector' => '.page-head-tabs .tab:eq(0)',
|
||||
'position' => 'right',
|
||||
],
|
||||
[
|
||||
'type' => 'popup',
|
||||
'text' => [
|
||||
'type' => 'template',
|
||||
'src' => 'end',
|
||||
],
|
||||
'options' => [
|
||||
'savepoint',
|
||||
'hideFooter',
|
||||
],
|
||||
'page' => $this->generateSfBaseUrl($router, 'admin_module_catalog'),
|
||||
],
|
||||
],
|
||||
];
|
||||
$data['steps']['groups'][] = $moduleSteps;
|
||||
Hook::exec(static::HOOK_CONFIGURATION, ['data' => &$data]);
|
||||
|
||||
return $data;
|
||||
}
|
||||
@@ -277,12 +227,12 @@ class Configuration
|
||||
* here we replace the route specific parameters with wildcard to allow regexp matching
|
||||
*
|
||||
* @param \PrestaShopBundle\Service\Routing\Router $router
|
||||
* @param $controller
|
||||
* @param array $fakeParameters
|
||||
* @param string $controller
|
||||
* @param array $fakeParameters
|
||||
*
|
||||
* @return mixed|string
|
||||
*/
|
||||
protected function generateSfBaseUrl(Router $router, $controller, $fakeParameters = [])
|
||||
protected function generateSfBaseUrl(Router $router, string $controller, $fakeParameters = [])
|
||||
{
|
||||
$url = $router->getGenerator()->generate($controller, $fakeParameters);
|
||||
$url = substr($url, strlen(basename(__PS_BASE_URI__)) + 1);
|
||||
|
||||
@@ -1,52 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2016 PrestaShop
|
||||
* 2007-2020 PrestaShop and Contributors
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* 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:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* 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 http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2015 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* @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 */
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $configuration;
|
||||
|
||||
/** @var Translator */
|
||||
/**
|
||||
* @var Module
|
||||
*/
|
||||
private $module;
|
||||
|
||||
/**
|
||||
* @var Translator
|
||||
*/
|
||||
private $translator;
|
||||
|
||||
/**
|
||||
* @var Smarty_Data
|
||||
*/
|
||||
private $smarty;
|
||||
private $module;
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
@@ -62,38 +73,37 @@ class OnBoarding
|
||||
*/
|
||||
public function showModuleContent()
|
||||
{
|
||||
$templates = array();
|
||||
$templates = [];
|
||||
foreach ($this->configuration['templates'] as $template) {
|
||||
$templates[] = array(
|
||||
'name' => $template,
|
||||
'content' => str_replace(array("\n", "\r", "\t"), "", $this->getTemplateContent("templates/$template")),
|
||||
);
|
||||
$templates[] = [
|
||||
'name' => $template,
|
||||
'content' => str_replace(["\n", "\r", "\t"], '', $this->getTemplateContent("templates/$template")),
|
||||
];
|
||||
}
|
||||
|
||||
echo $this->getTemplateContent('content', array(
|
||||
echo $this->getTemplateContent('content', [
|
||||
'currentStep' => $this->getCurrentStep(),
|
||||
'totalSteps' => $this->getTotalSteps(),
|
||||
'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,
|
||||
));
|
||||
'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($link)
|
||||
public function showModuleContentForNavBar()
|
||||
{
|
||||
echo $this->getTemplateContent('navbar', array(
|
||||
echo $this->getTemplateContent('navbar', [
|
||||
'currentStep' => $this->getCurrentStep(),
|
||||
'totalSteps' => $this->getTotalSteps(),
|
||||
'totalSteps' => $this->getTotalSteps(),
|
||||
'percent_real' => ($this->getCurrentStep() / $this->getTotalSteps()) * 100,
|
||||
'percent_rounded' => round(($this->getCurrentStep() / $this->getTotalSteps())*100),
|
||||
'link' => $link->getAdminLink('AdminWelcome'),
|
||||
));
|
||||
'percent_rounded' => round(($this->getCurrentStep() / $this->getTotalSteps()) * 100),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,7 +143,7 @@ class OnBoarding
|
||||
/**
|
||||
* Load all the steps with the localized texts.
|
||||
*
|
||||
* @param string $configPath Path where the configuration can be loaded
|
||||
* @param Router $router
|
||||
*/
|
||||
private function loadConfiguration(Router $router)
|
||||
{
|
||||
@@ -162,14 +172,14 @@ class OnBoarding
|
||||
*
|
||||
* @param array $text Step text configuration
|
||||
*
|
||||
* @return string|null Text if it exists
|
||||
* @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 $this->getTemplateContent('contents/' . $text['src']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,15 +199,16 @@ class OnBoarding
|
||||
/**
|
||||
* Return a template.
|
||||
*
|
||||
* @param string $templateName Template name
|
||||
* @param array $additionnalParameters Additionnal parameters to inject on the Twig template
|
||||
* @param string $templateName Template name
|
||||
* @param array $additionnalParameters Additionnal parameters to inject on the Twig template
|
||||
*
|
||||
* @return string Parsed template
|
||||
* @return string
|
||||
*/
|
||||
private function getTemplateContent($templateName, $additionnalParameters = array())
|
||||
private function getTemplateContent($templateName, $additionnalParameters = [])
|
||||
{
|
||||
$this->smarty->assign($additionnalParameters);
|
||||
return $this->module->fetch(__DIR__.'/../views/'.$templateName.'.tpl');
|
||||
|
||||
return $this->module->fetch(__DIR__ . '/../views/' . $templateName . '.tpl');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,7 +218,7 @@ class OnBoarding
|
||||
*/
|
||||
private function getCurrentStep()
|
||||
{
|
||||
return (int)LegacyConfiguration::get('ONBOARDINGV2_CURRENT_STEP');
|
||||
return (int) LegacyConfiguration::get('ONBOARDINGV2_CURRENT_STEP');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -231,10 +242,10 @@ class OnBoarding
|
||||
/**
|
||||
* Return the shut down status.
|
||||
*
|
||||
* @return bool Shut down status
|
||||
* @return int
|
||||
*/
|
||||
private function isShutDown()
|
||||
{
|
||||
return (int)LegacyConfiguration::get('ONBOARDINGV2_SHUT_DOWN');
|
||||
return (int) LegacyConfiguration::get('ONBOARDINGV2_SHUT_DOWN');
|
||||
}
|
||||
}
|
||||
|
||||
34
modules/welcome/OnBoarding/index.php
Normal file
34
modules/welcome/OnBoarding/index.php
Normal 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;
|
||||
Reference in New Issue
Block a user