module modification
This commit is contained in:
@@ -27,6 +27,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
|||||||
use Symfony\Component\Filesystem\Filesystem;
|
use Symfony\Component\Filesystem\Filesystem;
|
||||||
use Thelia\Core\Event\Cache\CacheEvent;
|
use Thelia\Core\Event\Cache\CacheEvent;
|
||||||
use Thelia\Core\Event\Module\ModuleDeleteEvent;
|
use Thelia\Core\Event\Module\ModuleDeleteEvent;
|
||||||
|
use Thelia\Core\Event\Module\ModuleEvent;
|
||||||
use Thelia\Core\Event\Module\ModuleToggleActivationEvent;
|
use Thelia\Core\Event\Module\ModuleToggleActivationEvent;
|
||||||
use Thelia\Core\Event\TheliaEvents;
|
use Thelia\Core\Event\TheliaEvents;
|
||||||
use Thelia\Model\Map\ModuleTableMap;
|
use Thelia\Model\Map\ModuleTableMap;
|
||||||
@@ -99,6 +100,28 @@ class Module extends BaseAction implements EventSubscriberInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ModuleEvent $event
|
||||||
|
*/
|
||||||
|
public function update(ModuleEvent $event)
|
||||||
|
{
|
||||||
|
if (null !== $module = ModuleQuery::create()->findPk($event->getId())) {
|
||||||
|
|
||||||
|
$module
|
||||||
|
->setDispatcher($this->getDispatcher())
|
||||||
|
->setLocale($event->getLocale())
|
||||||
|
->setTitle($event->getTitle())
|
||||||
|
->setChapo($event->getChapo())
|
||||||
|
->setDescription($event->getDescription())
|
||||||
|
->setPostscriptum($event->getPostscriptum())
|
||||||
|
;
|
||||||
|
|
||||||
|
$module->save();
|
||||||
|
|
||||||
|
$event->setModule($module);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected function cacheClear()
|
protected function cacheClear()
|
||||||
{
|
{
|
||||||
$cacheEvent = new CacheEvent($this->container->getParameter('kernel.cache_dir'));
|
$cacheEvent = new CacheEvent($this->container->getParameter('kernel.cache_dir'));
|
||||||
@@ -130,7 +153,8 @@ class Module extends BaseAction implements EventSubscriberInterface
|
|||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
TheliaEvents::MODULE_TOGGLE_ACTIVATION => array('toggleActivation', 128),
|
TheliaEvents::MODULE_TOGGLE_ACTIVATION => array('toggleActivation', 128),
|
||||||
TheliaEvents::MODULE_DELETE => array('delete', 128)
|
TheliaEvents::MODULE_DELETE => array('delete', 128),
|
||||||
|
TheliaEvents::MODULE_UPDATE => array('update', 128),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,6 +122,8 @@
|
|||||||
<form name="thelia.lang.url" class="Thelia\Form\Lang\LangUrlForm"/>
|
<form name="thelia.lang.url" class="Thelia\Form\Lang\LangUrlForm"/>
|
||||||
|
|
||||||
<form name="thelia.system-logs.configuration" class="Thelia\Form\SystemLogConfigurationForm"/>
|
<form name="thelia.system-logs.configuration" class="Thelia\Form\SystemLogConfigurationForm"/>
|
||||||
|
|
||||||
|
<form name="thelia.admin.module.modification" class="Thelia\Form\ModuleModificationForm"/>
|
||||||
</forms>
|
</forms>
|
||||||
|
|
||||||
</config>
|
</config>
|
||||||
|
|||||||
@@ -925,16 +925,25 @@
|
|||||||
|
|
||||||
<!-- Modules rule management -->
|
<!-- Modules rule management -->
|
||||||
|
|
||||||
<route id="admin.module" path="/admin/configuration/modules">
|
<route id="admin.module" path="/admin/modules">
|
||||||
<default key="_controller">Thelia\Controller\Admin\ModuleController::indexAction</default>
|
<default key="_controller">Thelia\Controller\Admin\ModuleController::indexAction</default>
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
<route id="admin.module.toggle-activation" path="/admin/configuration/modules/toggle-activation/{module_id}">
|
<route id="admin.module.update" path="/admin/module/update/{module_id}">
|
||||||
|
<default key="_controller">Thelia\Controller\Admin\ModuleController::updateAction</default>
|
||||||
|
<requirement key="module_id">\d+</requirement>
|
||||||
|
</route>
|
||||||
|
|
||||||
|
<route id="admin.module.save" path="/admin/module/save">
|
||||||
|
<default key="_controller">Thelia\Controller\Admin\ModuleController::processUpdateAction</default>
|
||||||
|
</route>
|
||||||
|
|
||||||
|
<route id="admin.module.toggle-activation" path="/admin/modules/toggle-activation/{module_id}">
|
||||||
<default key="_controller">Thelia\Controller\Admin\ModuleController::toggleActivationAction</default>
|
<default key="_controller">Thelia\Controller\Admin\ModuleController::toggleActivationAction</default>
|
||||||
<requirement key="module_id">\d+</requirement>
|
<requirement key="module_id">\d+</requirement>
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
<route id="admin.module.delete" path="/admin/configuration/modules/delete">
|
<route id="admin.module.delete" path="/admin/modules/delete">
|
||||||
<default key="_controller">Thelia\Controller\Admin\ModuleController::deleteAction</default>
|
<default key="_controller">Thelia\Controller\Admin\ModuleController::deleteAction</default>
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
|
|||||||
@@ -23,12 +23,15 @@
|
|||||||
|
|
||||||
namespace Thelia\Controller\Admin;
|
namespace Thelia\Controller\Admin;
|
||||||
|
|
||||||
|
use Thelia\Core\Event\Module\ModuleEvent;
|
||||||
use Thelia\Core\Security\Resource\AdminResources;
|
use Thelia\Core\Security\Resource\AdminResources;
|
||||||
|
|
||||||
use Thelia\Core\Event\Module\ModuleDeleteEvent;
|
use Thelia\Core\Event\Module\ModuleDeleteEvent;
|
||||||
use Thelia\Core\Event\Module\ModuleToggleActivationEvent;
|
use Thelia\Core\Event\Module\ModuleToggleActivationEvent;
|
||||||
use Thelia\Core\Event\TheliaEvents;
|
use Thelia\Core\Event\TheliaEvents;
|
||||||
use Thelia\Core\Security\AccessManager;
|
use Thelia\Core\Security\AccessManager;
|
||||||
|
use Thelia\Form\ModuleModificationForm;
|
||||||
|
use Thelia\Model\ModuleQuery;
|
||||||
use Thelia\Module\ModuleManagement;
|
use Thelia\Module\ModuleManagement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,25 +39,155 @@ use Thelia\Module\ModuleManagement;
|
|||||||
* @package Thelia\Controller\Admin
|
* @package Thelia\Controller\Admin
|
||||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||||
*/
|
*/
|
||||||
class ModuleController extends BaseAdminController
|
class ModuleController extends AbstractCrudController
|
||||||
{
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct(
|
||||||
|
'module',
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
|
||||||
|
AdminResources::MODULE,
|
||||||
|
|
||||||
|
null,
|
||||||
|
TheliaEvents::MODULE_UPDATE,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getCreationForm()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getUpdateForm()
|
||||||
|
{
|
||||||
|
return new ModuleModificationForm($this->getRequest());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getCreationEvent($formData)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getUpdateEvent($formData)
|
||||||
|
{
|
||||||
|
$event = new ModuleEvent();
|
||||||
|
|
||||||
|
$event->setLocale($formData['locale']);
|
||||||
|
$event->setId($formData['id']);
|
||||||
|
$event->setTitle($formData['title']);
|
||||||
|
$event->setChapo($formData['chapo']);
|
||||||
|
$event->setDescription($formData['description']);
|
||||||
|
$event->setPostscriptum($formData['postscriptum']);
|
||||||
|
|
||||||
|
return $event;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getDeleteEvent()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function eventContainsObject($event)
|
||||||
|
{
|
||||||
|
return $event->hasModule();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function hydrateObjectForm($object)
|
||||||
|
{
|
||||||
|
$object->setLocale($this->getCurrentEditionLocale());
|
||||||
|
$data = array(
|
||||||
|
'id' => $object->getId(),
|
||||||
|
'locale' => $object->getLocale(),
|
||||||
|
'title' => $object->getTitle(),
|
||||||
|
'chapo' => $object->getChapo(),
|
||||||
|
'description' => $object->getDescription(),
|
||||||
|
'postscriptum' => $object->getPostscriptum(),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Setup the object form
|
||||||
|
return new ModuleModificationForm($this->getRequest(), "form", $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getObjectFromEvent($event)
|
||||||
|
{
|
||||||
|
return $event->hasModule() ? $event->getModule() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getExistingObject()
|
||||||
|
{
|
||||||
|
return ModuleQuery::create()
|
||||||
|
->joinWithI18n($this->getCurrentEditionLocale())
|
||||||
|
->findOneById($this->getRequest()->get('module_id'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected function getObjectLabel($object)
|
||||||
|
{
|
||||||
|
return $object->getTitle();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getObjectId($object)
|
||||||
|
{
|
||||||
|
return $object->getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getViewArguments()
|
||||||
|
{
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getRouteArguments($module_id = null)
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'module_id' => $module_id === null ? $this->getRequest()->get('module_id') : $module_id,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function renderListTemplate($currentOrder)
|
||||||
|
{
|
||||||
|
// We always return to the feature edition form
|
||||||
|
return $this->render(
|
||||||
|
'modules',
|
||||||
|
array()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function renderEditionTemplate()
|
||||||
|
{
|
||||||
|
// We always return to the feature edition form
|
||||||
|
return $this->render('module-edit', array_merge($this->getViewArguments(), $this->getRouteArguments()));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function redirectToEditionTemplate($request = null, $country = null)
|
||||||
|
{
|
||||||
|
// We always return to the module edition form
|
||||||
|
$this->redirectToRoute(
|
||||||
|
"admin.module.update",
|
||||||
|
$this->getViewArguments(),
|
||||||
|
$this->getRouteArguments()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function redirectToListTemplate()
|
||||||
|
{
|
||||||
|
$this->redirectToRoute(
|
||||||
|
"admin.module"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function indexAction()
|
public function indexAction()
|
||||||
{
|
{
|
||||||
if (null !== $response = $this->checkAuth(AdminResources::MODULE, AccessManager::VIEW)) return $response;
|
if (null !== $response = $this->checkAuth(AdminResources::MODULE, AccessManager::VIEW)) return $response;
|
||||||
|
|
||||||
$modulemanagement = new ModuleManagement();
|
$moduleManagement = new ModuleManagement();
|
||||||
$modulemanagement->updateModules();
|
$moduleManagement->updateModules();
|
||||||
|
|
||||||
return $this->render("modules");
|
return $this->render("modules");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateAction($module_id)
|
|
||||||
{
|
|
||||||
return $this->render("module-edit", array(
|
|
||||||
"module_id" => $module_id
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function toggleActivationAction($module_id)
|
public function toggleActivationAction($module_id)
|
||||||
{
|
{
|
||||||
if (null !== $response = $this->checkAuth(AdminResources::MODULE, AccessManager::UPDATE)) return $response;
|
if (null !== $response = $this->checkAuth(AdminResources::MODULE, AccessManager::UPDATE)) return $response;
|
||||||
|
|||||||
@@ -37,6 +37,109 @@ class ModuleEvent extends ActionEvent
|
|||||||
*/
|
*/
|
||||||
protected $module;
|
protected $module;
|
||||||
|
|
||||||
|
protected $id;
|
||||||
|
protected $locale;
|
||||||
|
protected $title;
|
||||||
|
protected $chapo;
|
||||||
|
protected $description;
|
||||||
|
protected $postscriptum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $chapo
|
||||||
|
*/
|
||||||
|
public function setChapo($chapo)
|
||||||
|
{
|
||||||
|
$this->chapo = $chapo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getChapo()
|
||||||
|
{
|
||||||
|
return $this->chapo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $description
|
||||||
|
*/
|
||||||
|
public function setDescription($description)
|
||||||
|
{
|
||||||
|
$this->description = $description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getDescription()
|
||||||
|
{
|
||||||
|
return $this->description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $id
|
||||||
|
*/
|
||||||
|
public function setId($id)
|
||||||
|
{
|
||||||
|
$this->id = $id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getId()
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $locale
|
||||||
|
*/
|
||||||
|
public function setLocale($locale)
|
||||||
|
{
|
||||||
|
$this->locale = $locale;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getLocale()
|
||||||
|
{
|
||||||
|
return $this->locale;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $postscriptum
|
||||||
|
*/
|
||||||
|
public function setPostscriptum($postscriptum)
|
||||||
|
{
|
||||||
|
$this->postscriptum = $postscriptum;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getPostscriptum()
|
||||||
|
{
|
||||||
|
return $this->postscriptum;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $title
|
||||||
|
*/
|
||||||
|
public function setTitle($title)
|
||||||
|
{
|
||||||
|
$this->title = $title;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getTitle()
|
||||||
|
{
|
||||||
|
return $this->title;
|
||||||
|
}
|
||||||
|
|
||||||
public function __construct(Module $module = null)
|
public function __construct(Module $module = null)
|
||||||
{
|
{
|
||||||
$this->module = $module;
|
$this->module = $module;
|
||||||
|
|||||||
@@ -693,8 +693,9 @@ final class TheliaEvents
|
|||||||
const MODULE_TOGGLE_ACTIVATION = 'thelia.module.toggleActivation';
|
const MODULE_TOGGLE_ACTIVATION = 'thelia.module.toggleActivation';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sent when a module is deleted
|
* module
|
||||||
*/
|
*/
|
||||||
|
const MODULE_UPDATE = 'thelia.module.update';
|
||||||
const MODULE_DELETE = 'thelia.module.delete';
|
const MODULE_DELETE = 'thelia.module.delete';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ final class AdminResources
|
|||||||
|
|
||||||
const MESSAGE = "admin.configuration.message";
|
const MESSAGE = "admin.configuration.message";
|
||||||
|
|
||||||
const MODULE = "admin.configuration.module";
|
const MODULE = "admin.module";
|
||||||
|
|
||||||
const ORDER = "admin.order";
|
const ORDER = "admin.order";
|
||||||
|
|
||||||
|
|||||||
@@ -102,9 +102,9 @@ class FolderPath extends BaseI18nLoop implements ArraySearchLoopInterface
|
|||||||
if ($folder != null) {
|
if ($folder != null) {
|
||||||
|
|
||||||
$results[] = array(
|
$results[] = array(
|
||||||
"ID" => $result->getId(),
|
"ID" => $folder->getId(),
|
||||||
"TITLE" => $result->getVirtualColumn('i18n_TITLE'),
|
"TITLE" => $folder->getVirtualColumn('i18n_TITLE'),
|
||||||
"URL" => $result->getUrl($this->locale),
|
"URL" => $folder->getUrl($this->locale),
|
||||||
"LOCALE" => $this->locale,
|
"LOCALE" => $this->locale,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
/* Thelia */
|
/* Thelia */
|
||||||
/* */
|
/* */
|
||||||
/* Copyright (c) OpenStudio */
|
/* Copyright (c) OpenStudio */
|
||||||
/* email : info@thelia.net */
|
/* email : info@thelia.net */
|
||||||
/* web : http://www.thelia.net */
|
/* web : http://www.thelia.net */
|
||||||
/* */
|
/* */
|
||||||
/* This program is free software; you can redistribute it and/or modify */
|
/* This program is free software; you can redistribute it and/or modify */
|
||||||
@@ -21,32 +21,55 @@
|
|||||||
/* */
|
/* */
|
||||||
/*************************************************************************************/
|
/*************************************************************************************/
|
||||||
|
|
||||||
namespace FakeCB\Tests;
|
namespace Thelia\Form;
|
||||||
|
|
||||||
use FakeCB\FakeCB;
|
use Symfony\Component\Validator\Constraints;
|
||||||
use Thelia\Tests\Module\BaseModuleTestor;
|
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||||
|
use Thelia\Model\ModuleQuery;
|
||||||
|
|
||||||
/**
|
class ModuleModificationForm extends BaseForm
|
||||||
*
|
|
||||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class FakeCBTest extends BaseModuleTestor
|
|
||||||
{
|
{
|
||||||
public function getTestedClassName()
|
use StandardDescriptionFieldsTrait;
|
||||||
|
|
||||||
|
protected function buildForm()
|
||||||
{
|
{
|
||||||
return 'FakeCB\FakeCB';
|
$this->addStandardDescFields();
|
||||||
|
|
||||||
|
$this->formBuilder
|
||||||
|
->add("id", "hidden", array(
|
||||||
|
"required" => true,
|
||||||
|
"constraints" => array(
|
||||||
|
new Constraints\NotBlank(),
|
||||||
|
new Constraints\Callback(
|
||||||
|
array(
|
||||||
|
"methods" => array(
|
||||||
|
array($this, "verifyModuleId"),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
),
|
||||||
|
),
|
||||||
|
"attr" => array(
|
||||||
|
"id" => "module_update_id",
|
||||||
|
),
|
||||||
|
))
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTestedInstance()
|
/**
|
||||||
|
* @return string the name of you form. This name must be unique
|
||||||
|
*/
|
||||||
|
public function getName()
|
||||||
{
|
{
|
||||||
return new FakeCB();
|
return "thelia_admin_module_modification";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testInstall()
|
public function verifyModuleId($value, ExecutionContextInterface $context)
|
||||||
{
|
{
|
||||||
//$fakeCB = new FakeCB();
|
$module = ModuleQuery::create()
|
||||||
|
->findPk($value);
|
||||||
|
|
||||||
//$fakeCB->install();
|
if (null === $module) {
|
||||||
|
$context->addViolation("Module ID not found");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,8 +4,11 @@ namespace Thelia\Model;
|
|||||||
|
|
||||||
use Propel\Runtime\Connection\ConnectionInterface;
|
use Propel\Runtime\Connection\ConnectionInterface;
|
||||||
use Thelia\Model\Base\Module as BaseModule;
|
use Thelia\Model\Base\Module as BaseModule;
|
||||||
|
use Thelia\Model\Tools\ModelEventDispatcherTrait;
|
||||||
|
|
||||||
class Module extends BaseModule {
|
class Module extends BaseModule
|
||||||
|
{
|
||||||
|
use ModelEventDispatcherTrait;
|
||||||
|
|
||||||
public function postSave(ConnectionInterface $con = null)
|
public function postSave(ConnectionInterface $con = null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
|
|
||||||
<config xmlns="http://thelia.net/schema/dic/config"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/thelia-1.0.xsd">
|
|
||||||
|
|
||||||
<loops>
|
|
||||||
<!-- sample definition
|
|
||||||
<loop name="MySuperLoop" class="MyModule\Loop\MySuperLoop" />
|
|
||||||
-->
|
|
||||||
</loops>
|
|
||||||
|
|
||||||
<forms>
|
|
||||||
<!--
|
|
||||||
<form name="MyFormName" class="MyModule\Form\MySuperForm" />
|
|
||||||
-->
|
|
||||||
</forms>
|
|
||||||
|
|
||||||
<commands>
|
|
||||||
<!--
|
|
||||||
<command class="MyModule\Command\MySuperCommand" />
|
|
||||||
-->
|
|
||||||
</commands>
|
|
||||||
|
|
||||||
<templateDirectives>
|
|
||||||
<!-- Sample definition
|
|
||||||
<templateDirectives class="MyModule\Directive\MyTemplateDirective" name="my_filter"/>
|
|
||||||
-->
|
|
||||||
</templateDirectives>
|
|
||||||
|
|
||||||
<!--
|
|
||||||
<services>
|
|
||||||
|
|
||||||
</services>
|
|
||||||
-->
|
|
||||||
</config>
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module>
|
|
||||||
<fullnamespace>FakeCB\FakeCB</fullnamespace>
|
|
||||||
<descriptive locale="en_US">
|
|
||||||
<title>fake cb</title>
|
|
||||||
</descriptive>
|
|
||||||
<descriptive locale="fr_FR">
|
|
||||||
<title>simulation cb</title>
|
|
||||||
</descriptive>
|
|
||||||
<version>1.0</version>
|
|
||||||
<author>
|
|
||||||
<name>Manuel Raynaud</name>
|
|
||||||
<email>mraynaud@openstudio.fr</email>
|
|
||||||
</author>
|
|
||||||
<type>payment</type>
|
|
||||||
<thelia>2.0.0</thelia>
|
|
||||||
<stability>alpha</stability>
|
|
||||||
</module>
|
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*************************************************************************************/
|
|
||||||
/* */
|
|
||||||
/* Thelia */
|
|
||||||
/* */
|
|
||||||
/* Copyright (c) OpenStudio */
|
|
||||||
/* email : info@thelia.net */
|
|
||||||
/* web : http://www.thelia.net */
|
|
||||||
/* */
|
|
||||||
/* This program is free software; you can redistribute it and/or modify */
|
|
||||||
/* it under the terms of the GNU General Public License as published by */
|
|
||||||
/* the Free Software Foundation; either version 3 of the License */
|
|
||||||
/* */
|
|
||||||
/* This program is distributed in the hope that it will be useful, */
|
|
||||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
|
||||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
|
||||||
/* GNU General Public License for more details. */
|
|
||||||
/* */
|
|
||||||
/* You should have received a copy of the GNU General Public License */
|
|
||||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
||||||
/* */
|
|
||||||
/*************************************************************************************/
|
|
||||||
|
|
||||||
namespace FakeCB;
|
|
||||||
|
|
||||||
use Propel\Runtime\Connection\ConnectionInterface;
|
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Thelia\Model\Base\ModuleImageQuery;
|
|
||||||
use Thelia\Module\BaseModule;
|
|
||||||
use Thelia\Module\PaymentModuleInterface;
|
|
||||||
|
|
||||||
class FakeCB extends BaseModule implements PaymentModuleInterface
|
|
||||||
{
|
|
||||||
protected $request;
|
|
||||||
protected $dispatcher;
|
|
||||||
|
|
||||||
public function setRequest(Request $request)
|
|
||||||
{
|
|
||||||
$this->request = $request;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getRequest()
|
|
||||||
{
|
|
||||||
return $this->request;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setDispatcher(EventDispatcherInterface $dispatcher)
|
|
||||||
{
|
|
||||||
$this->dispatcher = $dispatcher;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDispatcher()
|
|
||||||
{
|
|
||||||
return $this->dispatcher;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function pay()
|
|
||||||
{
|
|
||||||
// TODO: Implement pay() method.
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function postActivation(ConnectionInterface $con = null)
|
|
||||||
{
|
|
||||||
/* insert the images from image folder if first module activation */
|
|
||||||
$module = $this->getModuleModel();
|
|
||||||
if(ModuleImageQuery::create()->filterByModule($module)->count() == 0) {
|
|
||||||
$this->deployImageFolder($module, sprintf('%s/images', __DIR__));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* set module title */
|
|
||||||
$this->setTitle(
|
|
||||||
$module,
|
|
||||||
array(
|
|
||||||
"en_US" => "Credit Card",
|
|
||||||
"fr_FR" => "Carte de crédit",
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function getCode()
|
|
||||||
{
|
|
||||||
return 'FakeCB';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.6 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 3.1 KiB |
@@ -116,13 +116,6 @@
|
|||||||
|
|
||||||
{module_include location='system_configuration_top'}
|
{module_include location='system_configuration_top'}
|
||||||
|
|
||||||
{loop type="auth" name="pcc1" role="ADMIN" resource="admin.configuration.module" access="VIEW"}
|
|
||||||
<tr>
|
|
||||||
<td><a href="{url path='/admin/configuration/modules'}">{intl l='Modules activation'}</a></td>
|
|
||||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/modules'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
|
||||||
</tr>
|
|
||||||
{/loop}
|
|
||||||
|
|
||||||
{loop type="auth" name="pcc2" role="ADMIN" resource="admin.configuration.variable" access="VIEW"}
|
{loop type="auth" name="pcc2" role="ADMIN" resource="admin.configuration.variable" access="VIEW"}
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="{url path='/admin/configuration/variables'}">{intl l='System variables'}</a></td>
|
<td><a href="{url path='/admin/configuration/variables'}">{intl l='System variables'}</a></td>
|
||||||
|
|||||||
@@ -27,9 +27,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<noscript>
|
<noscript>
|
||||||
{if $ACTIVE}
|
{if $ACTIVE}
|
||||||
<a title="{intl l="Deactivate %title module" title=$TITLE}" href="{url path="/admin/configuration/modules/toggle-activation/{$ID}"}">{intl l="deactivation"}</a>
|
<a title="{intl l="Deactivate %title module" title=$TITLE}" href="{url path="/admin/modules/toggle-activation/{$ID}"}">{intl l="deactivation"}</a>
|
||||||
{else}
|
{else}
|
||||||
<a title="{intl l="activate %title module" title=$TITLE}" href="{url path="/admin/configuration/modules/toggle-activation/{$ID}"}">{intl l="activation"}</a>
|
<a title="{intl l="activate %title module" title=$TITLE}" href="{url path="/admin/modules/toggle-activation/{$ID}"}">{intl l="activation"}</a>
|
||||||
{/if}
|
{/if}
|
||||||
</noscript>
|
</noscript>
|
||||||
</td>
|
</td>
|
||||||
@@ -48,7 +48,7 @@
|
|||||||
{/loop}
|
{/loop}
|
||||||
|
|
||||||
{loop type="auth" name="can_delete" role="ADMIN" resource="admin.modules" access="DELETE"}
|
{loop type="auth" name="can_delete" role="ADMIN" resource="admin.modules" access="DELETE"}
|
||||||
<a class="btn btn-default btn-xs module-delete-action" title="{intl l='Delete this module'}" href="#delete_module_dialog" data-id="{$ID}" data-toggle="modal"><span class="glyphicon glyphicon-trash"></span></a>
|
<a class="btn btn-default btn-xs module-delete-action" title="{intl l='Delete this module'}" href="#delete_module_dialog" data-id="{$ID}" data-toggle="modal"><span class="glyphicon glyphicon-trash"></span></a>
|
||||||
{/loop}
|
{/loop}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
82
templates/admin/default/module-edit.html
Normal file
82
templates/admin/default/module-edit.html
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
{extends file="admin-layout.tpl"}
|
||||||
|
|
||||||
|
{block name="page-title"}{intl l='Edit a module'}{/block}
|
||||||
|
|
||||||
|
{block name="check-resource"}admin.module{/block}
|
||||||
|
{block name="check-access"}update{/block}
|
||||||
|
|
||||||
|
{block name="main-content"}
|
||||||
|
|
||||||
|
<div class="edit-module">
|
||||||
|
|
||||||
|
<div id="wrapper" class="container">
|
||||||
|
|
||||||
|
<ul class="breadcrumb">
|
||||||
|
<li><a href="{url path='/admin/home'}">{intl l="Home"}</a></li>
|
||||||
|
<li><a href="{url path='/admin/modules'}">{intl l="Modules"}</a></li>
|
||||||
|
<li>{intl l='Editing module'}</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
{loop type="module" name="module" id=$module_id backend_context="1" lang=$edit_language_id}
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12 general-block-decorator clearfix">
|
||||||
|
|
||||||
|
<div class="form-container">
|
||||||
|
|
||||||
|
{form name="thelia.admin.module.modification"}
|
||||||
|
|
||||||
|
<form method="POST" action="{url path="/admin/module/save"}" {form_enctype form=$form} >
|
||||||
|
|
||||||
|
{include
|
||||||
|
file = "includes/inner-form-toolbar.html"
|
||||||
|
hide_submit_buttons = false
|
||||||
|
|
||||||
|
page_url = {url path="/admin/module/update/$module_id"}
|
||||||
|
close_url = {url path="/admin/modules"}
|
||||||
|
}
|
||||||
|
|
||||||
|
{* Be sure to get the product ID, even if the form could not be validated *}
|
||||||
|
<input type="hidden" name="module_id" value="{$ID}" />
|
||||||
|
|
||||||
|
{form_hidden_fields form=$form}
|
||||||
|
|
||||||
|
{form_field form=$form field='success_url'}
|
||||||
|
<input type="hidden" name="{$name}" value="{url path="/admin/modules"}" />
|
||||||
|
{/form_field}
|
||||||
|
|
||||||
|
{if $form_error}<div class="alert alert-danger">{$form_error_message}</div>{/if}
|
||||||
|
|
||||||
|
{include file="includes/standard-description-form-fields.html" form=$form}
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="control-group">
|
||||||
|
<label> </label>
|
||||||
|
<div class="controls">
|
||||||
|
<p>{intl l='Module created on %date_create. Last modification: %date_change' date_create={format_date date=$CREATE_DATE} date_change={format_date date=$UPDATE_DATE}}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
{/form}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/loop}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/block}
|
||||||
|
|
||||||
|
{block name="javascript-initialization"}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{/block}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
{block name="page-title"}{intl l='Modules'}{/block}
|
{block name="page-title"}{intl l='Modules'}{/block}
|
||||||
|
|
||||||
{block name="check-resource"}admin.configuration.module{/block}
|
{block name="check-resource"}admin.module{/block}
|
||||||
{block name="check-access"}view{/block}
|
{block name="check-access"}view{/block}
|
||||||
|
|
||||||
{block name="main-content"}
|
{block name="main-content"}
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
dialog_title = {intl l="Delete a module"}
|
dialog_title = {intl l="Delete a module"}
|
||||||
dialog_message = {intl l="Do you really want to delete this module ?"}
|
dialog_message = {intl l="Do you really want to delete this module ?"}
|
||||||
|
|
||||||
form_action = {url path='/admin/configuration/modules/delete'}
|
form_action = {url path='/admin/modules/delete'}
|
||||||
form_content = {$smarty.capture.delete_module_dialog nofilter}
|
form_content = {$smarty.capture.delete_module_dialog nofilter}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,8 +81,8 @@
|
|||||||
{/javascripts}
|
{/javascripts}
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function(){
|
$(document).ready(function() {
|
||||||
var url_management = "{url path="/admin/configuration/modules/toggle-activation/"}";
|
var url_management = "{url path="/admin/modules/toggle-activation/"}";
|
||||||
$(".module-activation").on("switch-change", function(e, data){
|
$(".module-activation").on("switch-change", function(e, data){
|
||||||
$('body').append('<div class="modal-backdrop fade in" id="loading-event"><div class="loading"></div></div>');
|
$('body').append('<div class="modal-backdrop fade in" id="loading-event"><div class="loading"></div></div>');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
|||||||
Reference in New Issue
Block a user