Merge branch 'master' of github.com:thelia/thelia

This commit is contained in:
Etienne Roudeix
2014-01-10 16:29:27 +01:00
60 changed files with 1056 additions and 1098 deletions

View File

@@ -87,10 +87,10 @@ class CouponCreateOrUpdateEvent extends ActionEvent
/**
* Constructor
*
* @param string $code Coupon Code
* @param string $serviceId Coupon Service id
* @param string $title Coupon title
* @param array $effects Coupon effects ready to be serialized
* @param string $code Coupon Code
* @param string $serviceId Coupon Service id
* @param string $title Coupon title
* @param array $effects Coupon effects ready to be serialized
* 'amount' key is mandatory and reflects
* the amount deduced from the cart
* @param string $shortDescription Coupon short description

View File

@@ -253,6 +253,26 @@ class Session extends BaseSession
return $this->get("thelia.order");
}
/**
* @param Order $order
* @return $this
*/
public function setProcessedOrder(Order $order)
{
$this->set('thelia.order.processed', $order);
return $this;
}
/**
* Return an order already processed, usefull for payment modules
* @return Order
*/
public function getProcessedOrder()
{
return $this->get('thelia.order.processed');
}
/**
* Set consumed coupons by the Customer
*

View File

@@ -23,7 +23,8 @@
namespace Thelia\Core\Template\Assets;
interface AssetManagerInterface {
interface AssetManagerInterface
{
/**
* Prepare an asset directory by checking that no changes occured in
* the source directory. If any change is detected, the whole asset directory
@@ -45,23 +46,23 @@ interface AssetManagerInterface {
/**
* Generates assets from $asset_path in $output_path, using $filters.
*
* @param $assetSource
* @param $assetDirectoryBase
* @param string $webAssetsDirectoryBase the full path to the asset file (or file collection, e.g. *.less)
* @param $assetSource
* @param $assetDirectoryBase
* @param string $webAssetsDirectoryBase the full path to the asset file (or file collection, e.g. *.less)
*
* @param string $webAssetsTemplate the full disk path to the base assets output directory in the web space
* @param $webAssetsKey
* @param string $outputUrl the URL to the base assets output directory in the web space
* @param string $webAssetsTemplate the full disk path to the base assets output directory in the web space
* @param $webAssetsKey
* @param string $outputUrl the URL to the base assets output directory in the web space
*
* @param string $assetType the asset type: css, js, ... The generated files will have this extension. Pass an empty string to use the asset source extension.
* @param array $filters a list of filters, as defined below (see switch($filter_name) ...)
* @param string $assetType the asset type: css, js, ... The generated files will have this extension. Pass an empty string to use the asset source extension.
* @param array $filters a list of filters, as defined below (see switch($filter_name) ...)
*
* @param boolean $debug true / false
* @param boolean $debug true / false
*
* @internal param string $web_assets_directory_base the full disk path to the base assets output directory in the web space
* @internal param string $output_url the URL to the base assets output directory in the web space
*
* @return string The URL to the generated asset file.
* @return string The URL to the generated asset file.
*/
public function processAsset($assetSource, $assetDirectoryBase, $webAssetsDirectoryBase, $webAssetsTemplate, $webAssetsKey, $outputUrl, $assetType, $filters, $debug);
}
}

View File

@@ -51,7 +51,7 @@ class AsseticAssetManager implements AssetManagerInterface
/**
* Create a stamp form the modification time of the content of the given directory and all of its subdirectories
*
* @param string $directory ther directory name
* @param string $directory ther directory name
* @return string the stamp of this directory
*/
protected function getStamp($directory)
@@ -76,7 +76,8 @@ class AsseticAssetManager implements AssetManagerInterface
*
* @return bool
*/
protected function isSourceFile(\SplFileInfo $fileInfo) {
protected function isSourceFile(\SplFileInfo $fileInfo)
{
return in_array($fileInfo->getExtension(), $this->source_file_extensions);
}
@@ -84,9 +85,9 @@ class AsseticAssetManager implements AssetManagerInterface
* Recursively copy assets from the source directory to the destination
* directory in the web space, omitting source files.
*
* @param Filesystem $fs
* @param string $from_directory the source
* @param string $to_directory the destination
* @param Filesystem $fs
* @param string $from_directory the source
* @param string $to_directory the destination
* @throws \RuntimeException if a problem occurs.
*/
protected function copyAssets(Filesystem $fs, $from_directory, $to_directory)
@@ -205,8 +206,7 @@ class AsseticAssetManager implements AssetManagerInterface
throw new \RuntimeException(
"Failed to create asset stamp file $stamp_file_path. Please check that your web server has the proper access rights to do that.");
}
/* }
else {
/* } else {
@fclose($fp);
}
*/
@@ -216,13 +216,13 @@ class AsseticAssetManager implements AssetManagerInterface
/**
* Decode the filters names, and initialize the Assetic FilterManager
*
* @param FilterManager $filterManager the Assetic filter manager
* @param string $filters a comma separated list of filter names
* @param FilterManager $filterManager the Assetic filter manager
* @param string $filters a comma separated list of filter names
* @throws \InvalidArgumentException if a wrong filter is passed
* @return an array of filter names
* @return an array of filter names
*/
protected function decodeAsseticFilters(FilterManager $filterManager, $filters) {
protected function decodeAsseticFilters(FilterManager $filterManager, $filters)
{
if (!empty($filters)) {
$filter_list = explode(',', $filters);
@@ -261,8 +261,7 @@ class AsseticAssetManager implements AssetManagerInterface
break;
}
}
}
else {
} else {
$filter_list = array();
}
@@ -272,20 +271,20 @@ class AsseticAssetManager implements AssetManagerInterface
/**
* Generates assets from $asset_path in $output_path, using $filters.
*
* @param $assetSource
* @param $assetDirectoryBase
* @param string $webAssetsDirectoryBase the full path to the asset file (or file collection, e.g. *.less)
* @param $assetSource
* @param $assetDirectoryBase
* @param string $webAssetsDirectoryBase the full path to the asset file (or file collection, e.g. *.less)
*
* @param string $webAssetsTemplate the full disk path to the base assets output directory in the web space
* @param $webAssetsKey
* @param string $outputUrl the URL to the base assets output directory in the web space
* @param string $webAssetsTemplate the full disk path to the base assets output directory in the web space
* @param $webAssetsKey
* @param string $outputUrl the URL to the base assets output directory in the web space
*
* @param string $assetType the asset type: css, js, ... The generated files will have this extension. Pass an empty string to use the asset source extension.
* @param array $filters a list of filters, as defined below (see switch($filter_name) ...)
* @param string $assetType the asset type: css, js, ... The generated files will have this extension. Pass an empty string to use the asset source extension.
* @param array $filters a list of filters, as defined below (see switch($filter_name) ...)
*
* @param boolean $debug true / false
* @param boolean $debug true / false
*
* @return string The URL to the generated asset file.
* @return string The URL to the generated asset file.
*/
public function processAsset($assetSource, $assetDirectoryBase, $webAssetsDirectoryBase, $webAssetsTemplate, $webAssetsKey, $outputUrl, $assetType, $filters, $debug)
{

View File

@@ -15,7 +15,6 @@ use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Model\CountryQuery;
use Thelia\TaxEngine\TaxEngine;
use Thelia\Type;

View File

@@ -25,8 +25,6 @@ namespace Thelia\Core\Template\Loop;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Condition\ConditionFactory;
use Thelia\Condition\Implementation\ConditionInterface;
use Thelia\Core\HttpFoundation\Request;
use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow;
@@ -35,7 +33,6 @@ use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Model\OrderCouponQuery;
use Thelia\Model\OrderQuery;
use Thelia\Type;
/**
*

View File

@@ -36,7 +36,6 @@ use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Exception\TaxEngineException;
use Thelia\Model\CategoryQuery;
use Thelia\Model\CountryQuery;
use Thelia\Model\CurrencyQuery;
use Thelia\Model\Map\ProductPriceTableMap;
use Thelia\Model\Map\ProductSaleElementsTableMap;

View File

@@ -34,7 +34,6 @@ use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Exception\TaxEngineException;
use Thelia\Model\Base\ProductSaleElementsQuery;
use Thelia\Model\CountryQuery;
use Thelia\Model\CurrencyQuery;
use Thelia\Model\Map\ProductSaleElementsTableMap;
use Thelia\TaxEngine\TaxEngine;

View File

@@ -23,19 +23,12 @@
namespace Thelia\Core\Template\Loop;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Core\Security\AccessManager;
use Thelia\Core\Template\Element\BaseI18nLoop;
use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Model\ModuleQuery;
use Thelia\Module\BaseModule;
use Thelia\Type;
use Thelia\Core\Template\TemplateHelper;
use Thelia\Core\Template\TemplateDefinition;
@@ -72,7 +65,8 @@ class Template extends BaseLoop implements ArraySearchLoopInterface
);
}
public function buildArray() {
public function buildArray()
{
$type = $this->getArg('template-type')->getValue();
if ($type == 'front-office')

View File

@@ -43,20 +43,19 @@ interface ParserInterface
*
* @param unknown $templateType the template type (
*
* @param string $templateName the template name
* @param string $templateDirectory path to the template dirtectory
* @param unknown $key ???
* @param string $unshift ??? Etienne ?
* @param string $templateName the template name
* @param string $templateDirectory path to the template dirtectory
* @param unknown $key ???
* @param string $unshift ??? Etienne ?
*/
public function addTemplateDirectory($templateType, $templateName, $templateDirectory, $key, $unshift = false);
/**
* Return the registeted template directories for a givent template type
*
* @param unknown $templateType
* @param unknown $templateType
* @throws InvalidArgumentException if the tempmateType is not defined
* @return array: an array of defined templates directories for the given template type
* @return array: an array of defined templates directories for the given template type
*/
public function getTemplateDirectories($templateType);
}
}

View File

@@ -23,7 +23,6 @@
namespace Thelia\Core\Template\Smarty\Assets;
use Thelia\Core\Template\Assets\AsseticHelper;
use Thelia\Core\Template\TemplateDefinition;
use Thelia\Tools\URL;
use Thelia\Core\Template\Assets\AssetManagerInterface;
@@ -37,14 +36,14 @@ class SmartyAssetsManager
private $web_root;
private $path_relative_to_web_root;
static private $assetsDirectory = null;
private static $assetsDirectory = null;
/**
* Creates a new SmartyAssetsManager instance
*
* @param AssetManagerInterface $assetsManager an asset manager instance
* @param string $web_root the disk path to the web root (with final /)
* @param string $path_relative_to_web_root the path (relative to web root) where the assets will be generated
* @param AssetManagerInterface $assetsManager an asset manager instance
* @param string $web_root the disk path to the web root (with final /)
* @param string $path_relative_to_web_root the path (relative to web root) where the assets will be generated
*/
public function __construct(AssetManagerInterface $assetsManager, $web_root, $path_relative_to_web_root)
{
@@ -67,7 +66,7 @@ class SmartyAssetsManager
if (isset($templateDirectories[$templateDefinition->getName()])) {
/* create assets foreach registered directory : main @ modules */
foreach($templateDirectories[$templateDefinition->getName()] as $key => $directory) {
foreach ($templateDirectories[$templateDefinition->getName()] as $key => $directory) {
$tpl_path = $directory . DS . self::$assetsDirectory;
@@ -95,7 +94,7 @@ class SmartyAssetsManager
/* we trick here relative thinking for file attribute */
$file = ltrim($file, '/');
while(substr($file, 0, 3) == '../') {
while (substr($file, 0, 3) == '../') {
$file = substr($file, 3);
}

View File

@@ -14,8 +14,6 @@ use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
use Thelia\Core\Template\Exception\ResourceNotFoundException;
use Thelia\Core\Template\ParserContext;
use Thelia\Core\Template\TemplateDefinition;
use Thelia\Model\ConfigQuery;
use Thelia\Core\Template\TemplateHelper;
use Imagine\Exception\InvalidArgumentException;
use Thelia\Core\Translation\Translator;
@@ -72,7 +70,6 @@ class SmartyParser extends Smarty implements ParserInterface
$this->setCompileDir($compile_dir);
$this->setCacheDir($cache_dir);
$this->debugging = $debug;
// Prevent smarty ErrorException: Notice: Undefined index bla bla bla...
@@ -80,7 +77,7 @@ class SmartyParser extends Smarty implements ParserInterface
// Si on n'est pas en mode debug, activer le cache, avec une lifetime de 15mn, et en vérifiant que les templates sources n'ont pas été modifiés.
if($debug) {
if ($debug) {
$this->setCaching(Smarty::CACHING_OFF);
$this->setForceCompile(true);
} else {
@@ -89,7 +86,6 @@ class SmartyParser extends Smarty implements ParserInterface
//$this->enableSecurity();
// The default HTTP status
$this->status = 200;
@@ -100,15 +96,15 @@ class SmartyParser extends Smarty implements ParserInterface
/**
* Add a template directory to the current template list
*
* @param unknown $templateType the template type (a TemplateDefinition type constant)
* @param string $templateName the template name
* @param string $templateDirectory path to the template dirtectory
* @param unknown $key ???
* @param string $unshift ??? Etienne ?
* @param unknown $templateType the template type (a TemplateDefinition type constant)
* @param string $templateName the template name
* @param string $templateDirectory path to the template dirtectory
* @param unknown $key ???
* @param string $unshift ??? Etienne ?
*/
public function addTemplateDirectory($templateType, $templateName, $templateDirectory, $key, $unshift = false) {
if(true === $unshift && isset($this->templateDirectories[$templateType][$templateName])) {
public function addTemplateDirectory($templateType, $templateName, $templateDirectory, $key, $unshift = false)
{
if (true === $unshift && isset($this->templateDirectories[$templateType][$templateName])) {
$this->templateDirectories[$templateType][$templateName] = array_merge(
array(
@@ -124,7 +120,7 @@ class SmartyParser extends Smarty implements ParserInterface
/**
* Return the registeted template directories for a givent template type
*
* @param unknown $templateType
* @param unknown $templateType
* @throws InvalidArgumentException
* @return multitype:
*/
@@ -176,7 +172,7 @@ class SmartyParser extends Smarty implements ParserInterface
/* do not pass array directly to addTemplateDir since we cant control on keys */
if (isset($this->templateDirectories[$templateDefinition->getType()][$templateDefinition->getName()])) {
foreach($this->templateDirectories[$templateDefinition->getType()][$templateDefinition->getName()] as $key => $directory) {
foreach ($this->templateDirectories[$templateDefinition->getType()][$templateDefinition->getName()] as $key => $directory) {
$this->addTemplateDir($directory, $key);
}
}
@@ -194,9 +190,9 @@ class SmartyParser extends Smarty implements ParserInterface
/**
* Return a rendered template, either from file or ftom a string
*
* @param string $resourceType either 'string' (rendering from a string) or 'file' (rendering a file)
* @param string $resourceType either 'string' (rendering from a string) or 'file' (rendering a file)
* @param string $resourceContent the resource content (a text, or a template file name)
* @param array $parameters an associative array of names / value pairs
* @param array $parameters an associative array of names / value pairs
*
* @return string the rendered template text
*/
@@ -215,8 +211,8 @@ class SmartyParser extends Smarty implements ParserInterface
/**
* Return a rendered template file
*
* @param string $realTemplateName the template name (from the template directory)
* @param array $parameters an associative array of names / value pairs
* @param string $realTemplateName the template name (from the template directory)
* @param array $parameters an associative array of names / value pairs
* @return string the rendered template text
*/
public function render($realTemplateName, array $parameters = array())
@@ -231,8 +227,8 @@ class SmartyParser extends Smarty implements ParserInterface
/**
* Return a rendered template text
*
* @param string $templateText the template text
* @param array $parameters an associative array of names / value pairs
* @param string $templateText the template text
* @param array $parameters an associative array of names / value pairs
* @return string the rendered template text
*/
public function renderString($templateText, array $parameters = array())
@@ -298,4 +294,4 @@ class SmartyParser extends Smarty implements ParserInterface
}
}
}
}

View File

@@ -57,13 +57,12 @@ class TemplateDefinition
*/
protected $type;
public function __construct($name, $type)
{
$this->name = $name;
$this->type = $type;
switch($type) {
switch ($type) {
case TemplateDefinition::FRONT_OFFICE:
$this->path = self::FRONT_OFFICE_SUBDIR . $name;
break;
@@ -90,14 +89,17 @@ class TemplateDefinition
public function setName($name)
{
$this->name = $name;
return $this;
}
public function getI18nPath() {
public function getI18nPath()
{
return $this->getPath() . DS . 'I18n';
}
public function getAbsoluteI18nPath() {
public function getAbsoluteI18nPath()
{
return THELIA_TEMPLATE_DIR . $this->getI18nPath();
}
@@ -106,7 +108,8 @@ class TemplateDefinition
return $this->path;
}
public function getAbsolutePath() {
public function getAbsolutePath()
{
return THELIA_TEMPLATE_DIR . $this->getPath();
}
@@ -115,13 +118,15 @@ class TemplateDefinition
return $this->getPath() . DS . 'configs';
}
public function getAbsoluteConfigPath() {
public function getAbsoluteConfigPath()
{
return THELIA_TEMPLATE_DIR . $this->getConfigPath();
}
public function setPath($path)
{
$this->path = $path;
return $this;
}
@@ -133,13 +138,15 @@ class TemplateDefinition
public function setType($type)
{
$this->type = $type;
return $this;
}
/**
* Returns an iterator on the standard templates subdir names
*/
public static function getStandardTemplatesSubdirsIterator() {
public static function getStandardTemplatesSubdirsIterator()
{
return new \ArrayIterator(self::$standardTemplatesSubdirs);
}
}

View File

@@ -93,7 +93,8 @@ class TemplateHelper
/**
* Returns an array which contains all standard template definitions
*/
public function getStandardTemplateDefinitions() {
public function getStandardTemplateDefinitions()
{
return array(
$this->getActiveFrontTemplate(),
$this->getActiveAdminTemplate(),
@@ -105,16 +106,16 @@ class TemplateHelper
/**
* Return a list of existing templates for a given template type
*
* @param int $templateType the template type
* @return An array of \Thelia\Core\Template\TemplateDefinition
* @param int $templateType the template type
* @return An array of \Thelia\Core\Template\TemplateDefinition
*/
public function getList($templateType) {
public function getList($templateType)
{
$list = $exclude = array();
$tplIterator = TemplateDefinition::getStandardTemplatesSubdirsIterator();
foreach($tplIterator as $type => $subdir) {
foreach ($tplIterator as $type => $subdir) {
if ($templateType == $type) {

View File

@@ -49,7 +49,6 @@ use Thelia\Config\DefinePropel;
use Thelia\Core\Template\TemplateDefinition;
use Thelia\Core\TheliaContainerBuilder;
use Thelia\Core\DependencyInjection\Loader\XmlFileLoader;
use Thelia\Model\ConfigQuery;
use Symfony\Component\Config\FileLocator;
use Propel\Runtime\Propel;
@@ -110,12 +109,13 @@ class Thelia extends Kernel
* Add all module's standard templates to the parser environment
*
* @param TheliaParser $parser the parser
* @param Module $module the Module.
* @param Module $module the Module.
*/
protected function addStandardModuleTemplatesToParserEnvironment($parser, $module) {
protected function addStandardModuleTemplatesToParserEnvironment($parser, $module)
{
$stdTpls = TemplateDefinition::getStandardTemplatesSubdirsIterator();
foreach($stdTpls as $templateType => $templateSubdirName) {
foreach ($stdTpls as $templateType => $templateSubdirName) {
$this->addModuleTemplateToParserEnvironment($parser, $module, $templateType, $templateSubdirName);
}
}
@@ -123,13 +123,13 @@ class Thelia extends Kernel
/**
* Add a module template directory to the parser environment
*
* @param TheliaParser $parser the parser
* @param Module $module the Module.
* @param string $templateType the template type (one of the TemplateDefinition type constants)
* @param string $templateSubdirName the template subdirectory name (one of the TemplateDefinition::XXX_SUBDIR constants)
* @param TheliaParser $parser the parser
* @param Module $module the Module.
* @param string $templateType the template type (one of the TemplateDefinition type constants)
* @param string $templateSubdirName the template subdirectory name (one of the TemplateDefinition::XXX_SUBDIR constants)
*/
protected function addModuleTemplateToParserEnvironment($parser, $module, $templateType, $templateSubdirName) {
protected function addModuleTemplateToParserEnvironment($parser, $module, $templateType, $templateSubdirName)
{
// Get template path
$templateDirectory = $module->getAbsoluteTemplateDirectoryPath($templateSubdirName);
@@ -155,8 +155,7 @@ class Thelia extends Kernel
);
}
}
}
catch (\UnexpectedValueException $ex) {
} catch (\UnexpectedValueException $ex) {
// The directory does not exists, ignore it.
}
}
@@ -176,7 +175,7 @@ class Thelia extends Kernel
->depth(0)
->in(THELIA_ROOT . "/core/lib/Thelia/Config/Resources");
foreach($finder as $file) {
foreach ($finder as $file) {
$loader->load($file->getBaseName());
}
@@ -219,7 +218,7 @@ class Thelia extends Kernel
// Standard templates (front, back, pdf, mail)
$th = TemplateHelper::getInstance();
foreach($th->getStandardTemplateDefinitions() as $templateDefinition) {
foreach ($th->getStandardTemplateDefinitions() as $templateDefinition) {
if (is_dir($dir = $templateDefinition->getAbsoluteI18nPath())) {
$translationDirs[] = $dir;
}
@@ -370,4 +369,4 @@ class Thelia extends Kernel
//Nothing is load here but it's possible to load container configuration here.
//exemple in sf2 : $loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
}
}
}