This commit is contained in:
franck
2013-07-12 14:22:58 +02:00
421 changed files with 799 additions and 111 deletions

0
core/lib/Thelia/Admin/Controller/SessionController.php Normal file → Executable file
View File

View File

@@ -0,0 +1,58 @@
<?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 Thelia\Command;
use Propel\Runtime\Propel;
use Symfony\Component\Console\Application;
abstract class BaseModuleGenerate extends ContainerAwareCommand {
protected $module;
protected $moduleDirectory;
protected $reservedKeyWords = array(
"thelia"
);
protected $neededDirectories = array(
"Config",
"Model",
"Loop"
);
protected function verifyExistingModule()
{
if (file_exists($this->moduleDirectory)) {
throw new \RuntimeException(sprintf("%s module already exists", $this->module));
}
}
protected function formatModuleName($name)
{
if (in_array(strtolower($name), $this->reservedKeyWords)) {
throw new \RuntimeException(sprintf("%s module name is a reserved keyword", $name));
}
return ucfirst($name);
}
}

View File

@@ -0,0 +1,104 @@
<?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 Thelia\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Filesystem;
class ModuleGenerateCommand extends BaseModuleGenerate {
protected function configure()
{
$this
->setName("module:generate")
->setDescription("generate all needed files for creating a new Module")
->addArgument(
"name" ,
InputArgument::REQUIRED,
"name wanted for your Module"
)
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->module = $this->formatModuleName($input->getArgument("name"));
$this->moduleDirectory = THELIA_MODULE_DIR . DIRECTORY_SEPARATOR . $this->module;
$this->verifyExistingModule();
$this->createDirectories();
$this->createFiles();
if(method_exists($this, "renderBlock")) {
//impossible to change output class in CommandTester...
$output->renderBlock(array(
'',
sprintf("module %s create with success", $this->module),
"You can now configure your module and complete plugin.xml file",
''
), "bg=green;fg=black");
}
}
private function createDirectories()
{
$fs = new Filesystem();
$fs->mkdir($this->moduleDirectory);
foreach ($this->neededDirectories as $directory) {
$fs->mkdir($this->moduleDirectory . DIRECTORY_SEPARATOR . $directory);
}
}
private function createFiles()
{
$fs = new Filesystem();
$skeletonDir = str_replace("/", DIRECTORY_SEPARATOR, THELIA_ROOT . "/core/lib/Thelia/Command/Skeleton/Module/");
$fs->copy($skeletonDir . "config.xml", $this->moduleDirectory . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "config.xml");
$fs->copy($skeletonDir . "plugin.xml", $this->moduleDirectory . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "plugin.xml");
$classContent = file_get_contents($skeletonDir . "Class.php");
$classContent = str_replace("%%CLASSNAME%%", $this->module, $classContent);
$classContent = str_replace("%%NAMESPACE%%", $this->module, $classContent);
file_put_contents($this->moduleDirectory . DIRECTORY_SEPARATOR . $this->module.".php", $classContent);
$schemaContent = file_get_contents($skeletonDir . "schema.xml");
$schemaContent = str_replace("%%CONFIG_DIR%%", THELIA_CONF_DIR, $schemaContent);
$schemaContent = str_replace("%%NAMESPACE%%", $this->module, $schemaContent);
file_put_contents($this->moduleDirectory . DIRECTORY_SEPARATOR . "Config". DIRECTORY_SEPARATOR . "schema.xml", $schemaContent);
}
}

View File

@@ -0,0 +1,130 @@
<?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 Thelia\Command;
use Propel\Generator\Command\ModelBuildCommand;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Output\StreamOutput;
use Symfony\Component\Filesystem\Filesystem;
class ModuleGenerateModelCommand extends BaseModuleGenerate {
protected function configure()
{
$this
->setName("module:generate:model")
->setDescription("generate model for a specific module")
->addArgument(
"name",
InputArgument::REQUIRED,
"module name"
)
->addOption(
"generate-sql",
null,
InputOption::VALUE_NONE,
"with this option generate sql file at the same time"
)
;
}
public function execute(InputInterface $input, OutputInterface $output)
{
$this->module = $this->formatModuleName($input->getArgument("name"));
$this->moduleDirectory = THELIA_MODULE_DIR . DS . $this->module;
$fs = new Filesystem();
if ($fs->exists($this->moduleDirectory) === false) {
throw new \RuntimeException(sprintf("%s module does not exists", $this->module));
}
if ($fs->exists($this->moduleDirectory . DS . "Config" . DS . "schema.xml") === false) {
throw new \RuntimeException("schema.xml not found in Config directory. Needed file for generating model");
}
$this->generateModel($output);
$output->renderBlock(array(
'',
'Model generated successfuly',
''
), 'bg=green;fg=black');
if ($input->getOption("generate-sql")) {
$output->writeln(' ');
$this->generateSql($output);
}
}
protected function generateSql(OutputInterface $output)
{
$command = $this->getApplication()->find("module:generate:sql");
$command->run(
new ArrayInput(array(
"command" => $command->getName(),
"name" => $this->module
)),
$output
);
}
protected function generateModel(OutputInterface $output)
{
$fs = new Filesystem();
$moduleBuildPropel = new ModelBuildCommand();
$moduleBuildPropel->setApplication($this->getApplication());
$moduleBuildPropel->run(
new ArrayInput(array(
"command" => $moduleBuildPropel->getName(),
"--output-dir" => THELIA_MODULE_DIR,
"--input-dir" => $this->moduleDirectory . DS ."Config"
)),
$output
);
$verifyDirectories = array(
THELIA_MODULE_DIR . DS . "Thelia",
$this->moduleDirectory . DS . "Model" . DS . "Thelia"
);
foreach ($verifyDirectories as $directory) {
if ($fs->exists($directory)) {
$fs->remove($directory);
}
}
}
}

View File

@@ -0,0 +1,85 @@
<?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 Thelia\Command;
use Propel\Generator\Command\SqlBuildCommand;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Output\StreamOutput;
use Symfony\Component\Filesystem\Filesystem;
class ModuleGenerateSqlCommand extends BaseModuleGenerate {
public function configure()
{
$this
->setName("module:generate:sql")
->setDescription("Generate the sql from schema.xml file")
->addArgument(
"name",
InputArgument::REQUIRED,
"Module name"
)
;
}
public function execute(InputInterface $input, OutputInterface $output)
{
$this->module = $this->formatModuleName($input->getArgument("name"));
$this->moduleDirectory = THELIA_MODULE_DIR . DS . $this->module;
$fs = new Filesystem();
if ($fs->exists($this->moduleDirectory) === false) {
throw new \RuntimeException(sprintf("%s module does not exists", $this->module));
}
if ($fs->exists($this->moduleDirectory . DS . "Config" . DS . "schema.xml") === false) {
throw new \RuntimeException("schema.xml not found in Config directory. Needed file for generating model");
}
$sqlBuild = new SqlBuildCommand();
$sqlBuild->setApplication($this->getApplication());
$sqlBuild->run(
new ArrayInput(array(
"command" => $sqlBuild->getName(),
"--output-dir" => $this->moduleDirectory . DS ."Config",
"--input-dir" => $this->moduleDirectory . DS ."Config"
)),
$output
);
$output->renderBlock(array(
'',
'Sql generated successfuly',
'File available in your module config directory',
''
), 'bg=green;fg=black');
}
}

View File

@@ -0,0 +1,56 @@
<?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 Thelia\Command\Output;
use Symfony\Component\Console\Output\ConsoleOutput;
class TheliaConsoleOutput extends ConsoleOutput{
public function renderBlock(array $messages, $style = "info")
{
$strlen = function ($string) {
if (!function_exists('mb_strlen')) {
return strlen($string);
}
if (false === $encoding = mb_detect_encoding($string)) {
return strlen($string);
}
return mb_strlen($string, $encoding);
};
$length = 0;
foreach ($messages as $message) {
$length = ($strlen($message) > $length) ? $strlen($message) : $length;
}
$ouput = array();
foreach ($messages as $message) {
$output[] = "<" . $style . ">" . " " . $message . str_repeat(' ', $length - $strlen($message)) . " </" . $style . ">";
}
$this->writeln($output);
}
}

View File

@@ -0,0 +1,36 @@
<?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 %%NAMESPACE%%;
use Thelia\Module\BaseModule;
class %%CLASSNAME%% extends BaseModule
{
/**
* YOU HAVE TO IMPLEMENT HERE ABSTRACT METHODD FROM BaseModule Class
* Like install and destroy
*/
}

View File

@@ -0,0 +1,36 @@
<?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>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<database defaultIdMethod="native" name="thelia" namespace="%%NAMESPACE%%\Model">
<!--
See propel documentation on http://propelorm.org for all information about schema file
-->
<external-schema filename="%%CONFIG_DIR%%schema.xml" referenceOnly="true" />
</database>

View File

@@ -34,6 +34,9 @@
<commands>
<command class="Thelia\Command\CacheClear"/>
<command class="Thelia\Command\Install"/>
<command class="Thelia\Command\ModuleGenerateCommand"/>
<command class="Thelia\Command\ModuleGenerateModelCommand"/>
<command class="Thelia\Command\ModuleGenerateSqlCommand"/>
</commands>
<services>

0
core/lib/Thelia/Core/Event/CustomRefEvent.php Normal file → Executable file
View File

0
core/lib/Thelia/Core/HttpFoundation/Request.php Normal file → Executable file
View File

View File

0
core/lib/Thelia/Core/Security/Role/Role.php Normal file → Executable file
View File

0
core/lib/Thelia/Core/Security/Role/RoleInterface.php Normal file → Executable file
View File

0
core/lib/Thelia/Core/Security/SecurityContext.php Normal file → Executable file
View File

0
core/lib/Thelia/Core/Security/User/UserInterface.php Normal file → Executable file
View File

View File

View File

View File

View File

0
core/lib/Thelia/Core/Template/Loop/Auth.php Normal file → Executable file
View File

0
core/lib/Thelia/Core/Template/Loop/Feed.php Normal file → Executable file
View File

0
core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php Normal file → Executable file
View File

View File

View File

0
core/lib/Thelia/Form/AdminLogin.php Normal file → Executable file
View File

0
core/lib/Thelia/Form/BaseForm.php Normal file → Executable file
View File

0
core/lib/Thelia/Form/CustomerCreation.php Normal file → Executable file
View File

0
core/lib/Thelia/Form/CustomerModification.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Accessory.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/AccessoryQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Address.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/AddressQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Admin.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/AdminGroup.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/AdminGroupQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/AdminLog.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/AdminLogQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/AdminQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Area.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/AreaQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Attribute.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/AttributeAv.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/AttributeAvI18n.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/AttributeAvI18nQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/AttributeAvQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/AttributeCategory.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/AttributeCategoryQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/AttributeCombination.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/AttributeCombinationQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/AttributeI18n.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/AttributeI18nQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/AttributeQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/Accessory.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/AccessoryQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/Address.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/AddressQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/Admin.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/AdminGroup.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/AdminGroupQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/AdminLog.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/AdminLogQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/AdminQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/Area.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/AreaQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/Attribute.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/AttributeAv.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/AttributeAvI18n.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/AttributeAvI18nQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/AttributeAvQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/AttributeCategory.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/AttributeCategoryQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/AttributeCombination.php Normal file → Executable file
View File

View File

0
core/lib/Thelia/Model/Base/AttributeI18n.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/AttributeI18nQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/AttributeQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/Category.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/CategoryI18n.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/CategoryI18nQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/CategoryQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/CategoryVersion.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/CategoryVersionQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/Combination.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/CombinationQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/Config.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/ConfigI18n.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/ConfigI18nQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/ConfigQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/Content.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/ContentAssoc.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/ContentAssocQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/ContentFolder.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/ContentFolderQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/ContentI18n.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/ContentI18nQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/ContentQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Base/ContentVersion.php Normal file → Executable file
View File

Some files were not shown because too many files have changed in this diff Show More