Revert "Revert "Merge branch 'cleanmaster' into modules""
This reverts commit b3ac365b45.
Conflicts:
Readme.md
core/lib/Thelia/Controller/Admin/AbstractCrudController.php
core/lib/Thelia/Core/Template/Assets/AssetManagerInterface.php
core/lib/Thelia/Core/Template/Assets/AsseticAssetManager.php
core/lib/Thelia/Core/Template/Smarty/SmartyParser.php
core/lib/Thelia/Core/Template/TemplateDefinition.php
core/lib/Thelia/Model/Base/Coupon.php
core/lib/Thelia/Model/Base/CouponQuery.php
core/lib/Thelia/Model/Base/CouponVersion.php
core/lib/Thelia/Model/Base/CouponVersionQuery.php
core/lib/Thelia/Model/Base/OrderCouponQuery.php
This commit is contained in:
@@ -26,7 +26,6 @@ use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
|
||||
/**
|
||||
* Class TranslatorPass
|
||||
* @package Thelia\Core\DependencyInjection\Compiler
|
||||
@@ -50,11 +49,11 @@ class TranslatorPass implements CompilerPassInterface
|
||||
|
||||
$translator = $container->getDefinition('thelia.translator');
|
||||
|
||||
foreach($container->findTaggedServiceIds('translation.loader') as $id => $attributes) {
|
||||
foreach ($container->findTaggedServiceIds('translation.loader') as $id => $attributes) {
|
||||
$translator->addMethodCall('addLoader', array($attributes[0]['alias'], new Reference($id)));
|
||||
if (isset($attributes[0]['legacy-alias'])) {
|
||||
$translator->addMethodCall('addLoader', array($attributes[0]['legacy-alias'], new Reference($id)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ namespace Thelia\Core\Event\Administrator;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\Admin;
|
||||
|
||||
|
||||
/**
|
||||
* Class AdministratorUpdatePasswordEvent
|
||||
* @package Thelia\Core\Event\Administrator
|
||||
@@ -82,4 +81,3 @@ class AdministratorUpdatePasswordEvent extends ActionEvent
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
namespace Thelia\Core\Event\Customer;
|
||||
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\Customer;
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
namespace Thelia\Core\Event\Customer;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\Customer;
|
||||
|
||||
class CustomerLoginEvent extends CustomerEvent
|
||||
|
||||
@@ -138,4 +138,4 @@ class MessageUpdateEvent extends MessageCreateEvent
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@ class ProductCombinationGenerationEvent extends ProductEvent
|
||||
public function setReference($reference)
|
||||
{
|
||||
$this->reference = $reference;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -76,6 +77,7 @@ class ProductCombinationGenerationEvent extends ProductEvent
|
||||
public function setPrice($price)
|
||||
{
|
||||
$this->price = $price;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -87,6 +89,7 @@ class ProductCombinationGenerationEvent extends ProductEvent
|
||||
public function setWeight($weight)
|
||||
{
|
||||
$this->weight = $weight;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -98,6 +101,7 @@ class ProductCombinationGenerationEvent extends ProductEvent
|
||||
public function setQuantity($quantity)
|
||||
{
|
||||
$this->quantity = $quantity;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -109,6 +113,7 @@ class ProductCombinationGenerationEvent extends ProductEvent
|
||||
public function setSalePrice($sale_price)
|
||||
{
|
||||
$this->sale_price = $sale_price;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -120,6 +125,7 @@ class ProductCombinationGenerationEvent extends ProductEvent
|
||||
public function setOnsale($onsale)
|
||||
{
|
||||
$this->onsale = $onsale;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -131,6 +137,7 @@ class ProductCombinationGenerationEvent extends ProductEvent
|
||||
public function setIsnew($isnew)
|
||||
{
|
||||
$this->isnew = $isnew;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -142,6 +149,7 @@ class ProductCombinationGenerationEvent extends ProductEvent
|
||||
public function setEanCode($ean_code)
|
||||
{
|
||||
$this->ean_code = $ean_code;
|
||||
|
||||
return $this;
|
||||
return $this;
|
||||
}
|
||||
@@ -154,6 +162,7 @@ class ProductCombinationGenerationEvent extends ProductEvent
|
||||
public function setCombinations($combinations)
|
||||
{
|
||||
$this->combinations = $combinations;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,4 +60,4 @@ class ProductSetTemplateEvent extends ProductEvent
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\ProductSaleElement;
|
||||
use Thelia\Model\Product;
|
||||
|
||||
class ProductSaleElementDeleteEvent extends ProductSaleElementEvent
|
||||
{
|
||||
|
||||
@@ -370,6 +370,7 @@ final class TheliaEvents
|
||||
*/
|
||||
const ORDER_SET_DELIVERY_ADDRESS = "action.order.setDeliveryAddress";
|
||||
const ORDER_SET_DELIVERY_MODULE = "action.order.setDeliveryModule";
|
||||
const ORDER_SET_POSTAGE = "action.order.setPostage";
|
||||
const ORDER_SET_INVOICE_ADDRESS = "action.order.setInvoiceAddress";
|
||||
const ORDER_SET_PAYMENT_MODULE = "action.order.setPaymentModule";
|
||||
const ORDER_PAY = "action.order.pay";
|
||||
|
||||
@@ -184,5 +184,4 @@ class UpdateSeoEvent extends ActionEvent
|
||||
return $this->object;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -30,12 +30,10 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Thelia\Core\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Router;
|
||||
use Thelia\Core\HttpKernel\Exception\NotFountHttpException;
|
||||
use Thelia\Core\Template\Exception\ResourceNotFoundException;
|
||||
use Thelia\Core\Template\ParserInterface;
|
||||
use Thelia\Core\Template\TemplateHelper;
|
||||
use Thelia\Exception\OrderException;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Tools\Redirect;
|
||||
use Thelia\Tools\URL;
|
||||
use Thelia\Core\Security\Exception\AuthenticationException;
|
||||
|
||||
@@ -39,8 +39,8 @@ class Response extends BaseResponse
|
||||
*
|
||||
* @see \Thelia\Core\HttpFoundation\Response::sendContent()
|
||||
*/
|
||||
public function sendContent() {
|
||||
|
||||
public function sendContent()
|
||||
{
|
||||
Tlog::getInstance()->write($this->content);
|
||||
|
||||
parent::sendContent();
|
||||
|
||||
@@ -65,7 +65,8 @@ class HttpCache extends BaseHttpCache implements HttpKernelInterface
|
||||
$request->getContent()
|
||||
);
|
||||
}
|
||||
|
||||
return parent::handle($request, $type, $catch);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ class SecurityContext
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!array_key_exists('module', $userPermissions)) {
|
||||
if (!array_key_exists('module', $userPermissions)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
@@ -17,51 +17,38 @@
|
||||
/* 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/>. */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
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
|
||||
* is copied in the web space.
|
||||
*
|
||||
* @param string $sourceAssetsDirectory the full path to the source asstes directory
|
||||
* @param string $webAssetsDirectoryBase the base directory of the web based asset directory
|
||||
* @param $webAssetsTemplate
|
||||
* @param string $webAssetsKey the assets key : module name or 0 for base template
|
||||
* Prepare an asset directory.
|
||||
*
|
||||
* @param string $source_assets_directory the full path to the source asstes directory
|
||||
* @param string $web_assets_directory_base the base directory of the web based asset directory
|
||||
* @throws \RuntimeException if something goes wrong.
|
||||
*
|
||||
* @internal param string $source_assets_directory the full path to the source asstes directory
|
||||
* @internal param string $web_assets_directory_base the base directory of the web based asset directory
|
||||
* @internal param string $key the assets key : module name or 0 for base template
|
||||
*/
|
||||
public function prepareAssets($sourceAssetsDirectory, $webAssetsDirectoryBase, $webAssetsTemplate, $webAssetsKey);
|
||||
public function prepareAssets($source_assets_directory, $web_assets_directory_base);
|
||||
|
||||
/**
|
||||
* 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 string $asset_path 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 $web_assets_directory_base the full disk path to the base assets output directory in the web space
|
||||
* @param string $output_url 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 $asset_type 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 the debug mode, true or 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.
|
||||
* @throws \InvalidArgumentException if an invalid filter name is found
|
||||
* @return string The URL to the generated asset file.
|
||||
*/
|
||||
public function processAsset($assetSource, $assetDirectoryBase, $webAssetsDirectoryBase, $webAssetsTemplate, $webAssetsKey, $outputUrl, $assetType, $filters, $debug);
|
||||
public function processAsset($asset_path, $web_assets_directory_base, $output_url, $asset_type, $filters, $debug);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
@@ -17,7 +17,7 @@
|
||||
/* 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/>. */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
@@ -31,6 +31,7 @@ use Assetic\AssetWriter;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Log\Tlog;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Symfony\Component\Filesystem\Exception\IOException;
|
||||
|
||||
/**
|
||||
* This class is a simple helper for generating assets using Assetic.
|
||||
@@ -51,7 +52,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)
|
||||
@@ -59,8 +60,8 @@ class AsseticAssetManager implements AssetManagerInterface
|
||||
$stamp = '';
|
||||
|
||||
$iterator = new \RecursiveIteratorIterator(
|
||||
new \RecursiveDirectoryIterator($directory, \RecursiveDirectoryIterator::SKIP_DOTS),
|
||||
\RecursiveIteratorIterator::LEAVES_ONLY);
|
||||
new \RecursiveDirectoryIterator($directory, \RecursiveDirectoryIterator::SKIP_DOTS),
|
||||
\RecursiveIteratorIterator::LEAVES_ONLY);
|
||||
|
||||
foreach ($iterator as $file) {
|
||||
$stamp .= $file->getMTime();
|
||||
@@ -72,21 +73,19 @@ class AsseticAssetManager implements AssetManagerInterface
|
||||
/**
|
||||
* Check if a file is a source asset file
|
||||
*
|
||||
* @param \SplFileInfo $fileInfo
|
||||
*
|
||||
* @return bool
|
||||
* @param \DirectoryIterator $fileInfo
|
||||
*/
|
||||
protected function isSourceFile(\SplFileInfo $fileInfo) {
|
||||
protected function isSourceFile(\SplFileInfo $fileInfo)
|
||||
{
|
||||
return in_array($fileInfo->getExtension(), $this->source_file_extensions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively copy assets from the source directory to the destination
|
||||
* directory in the web space, omitting source files.
|
||||
* directory in the web space, ommiting source files.
|
||||
*
|
||||
* @param Filesystem $fs
|
||||
* @param string $from_directory the source
|
||||
* @param string $to_directory the destination
|
||||
* @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)
|
||||
@@ -94,8 +93,8 @@ class AsseticAssetManager implements AssetManagerInterface
|
||||
Tlog::getInstance()->addDebug("Copying assets from $from_directory to $to_directory");
|
||||
|
||||
$iterator = new \RecursiveIteratorIterator(
|
||||
new \RecursiveDirectoryIterator($from_directory, \RecursiveDirectoryIterator::SKIP_DOTS),
|
||||
\RecursiveIteratorIterator::SELF_FIRST);
|
||||
new \RecursiveDirectoryIterator($from_directory, \RecursiveDirectoryIterator::SKIP_DOTS),
|
||||
\RecursiveIteratorIterator::SELF_FIRST);
|
||||
|
||||
foreach ($iterator as $item) {
|
||||
if ($item->isDir()) {
|
||||
@@ -123,21 +122,38 @@ class AsseticAssetManager implements AssetManagerInterface
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compite the assets path relative to the base template directory
|
||||
*
|
||||
* @param string $source_assets_directory the source directory
|
||||
* @param string $web_assets_directory_base base directory of the web assets
|
||||
* @return the full path of the destination directory
|
||||
*/
|
||||
protected function getRelativeDirectoryPath($source_assets_directory, $web_assets_directory_base)
|
||||
{
|
||||
$source_assets_directory = realpath($source_assets_directory);
|
||||
|
||||
// Remove base path from asset source path to get a path relative to the template base
|
||||
// and use it to create the destination path.
|
||||
return str_replace(
|
||||
realpath(THELIA_ROOT),
|
||||
'',
|
||||
$source_assets_directory
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute the destination directory path, from the source directory and the
|
||||
* base directory of the web assets
|
||||
*
|
||||
* @param string $webAssetsDirectoryBase base directory of the web assets
|
||||
* @param $webAssetsTemplate
|
||||
* @param string $webAssetsKey the assests key : module name or 0 for base template
|
||||
*
|
||||
* @internal param string $source_assets_directory the source directory
|
||||
* @return the full path of the destination directory
|
||||
* @param string $source_assets_directory the source directory
|
||||
* @param string $web_assets_directory_base base directory of the web assets
|
||||
* @return the full path of the destination directory
|
||||
*/
|
||||
protected function getDestinationDirectory($webAssetsDirectoryBase, $webAssetsTemplate, $webAssetsKey)
|
||||
protected function getDestinationDirectory($source_assets_directory, $web_assets_directory_base)
|
||||
{
|
||||
// Compute the absolute path of the output directory
|
||||
return $webAssetsDirectoryBase . DS . $webAssetsTemplate . DS . $webAssetsKey;
|
||||
return $web_assets_directory_base . $this->getRelativeDirectoryPath($source_assets_directory, $web_assets_directory_base);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -145,17 +161,14 @@ class AsseticAssetManager implements AssetManagerInterface
|
||||
* the source directory. If any change is detected, the whole asset directory
|
||||
* is copied in the web space.
|
||||
*
|
||||
* @param string $sourceAssetsDirectory the full path to the source asstes directory
|
||||
* @param string $webAssetsDirectoryBase the base directory of the web based asset directory
|
||||
* @param $webAssetsTemplate
|
||||
* @param string $webAssetsKey the assets key : module name or 0 for base template
|
||||
*
|
||||
* @param string $source_assets_directory the full path to the source asstes directory
|
||||
* @param string $web_assets_directory_base the base directory of the web based asset directory
|
||||
* @throws \RuntimeException if something goes wrong.
|
||||
*/
|
||||
public function prepareAssets($sourceAssetsDirectory, $webAssetsDirectoryBase, $webAssetsTemplate, $webAssetsKey)
|
||||
public function prepareAssets($source_assets_directory, $web_assets_directory_base)
|
||||
{
|
||||
// Compute the absolute path of the output directory
|
||||
$to_directory = $this->getDestinationDirectory($webAssetsDirectoryBase, $webAssetsTemplate, $webAssetsKey);
|
||||
$to_directory = $this->getDestinationDirectory($source_assets_directory, $web_assets_directory_base);
|
||||
|
||||
// Get a path to the stamp file
|
||||
$stamp_file_path = $to_directory . DS . '.source-stamp';
|
||||
@@ -164,65 +177,64 @@ class AsseticAssetManager implements AssetManagerInterface
|
||||
$prev_stamp = @file_get_contents($stamp_file_path);
|
||||
|
||||
// Get the current stamp of the source directory
|
||||
$curr_stamp = $this->getStamp($sourceAssetsDirectory);
|
||||
$curr_stamp = $this->getStamp($source_assets_directory);
|
||||
|
||||
if ($prev_stamp !== $curr_stamp) {
|
||||
|
||||
$fs = new Filesystem();
|
||||
|
||||
// FIXME: locking or not locking ?
|
||||
/*
|
||||
$lock_file = "$web_assets_directory_base/assets-".md5($source_assets_directory)."-generation-lock.txt";
|
||||
/*
|
||||
$lock_file = "$web_assets_directory_base/assets-".md5($source_assets_directory)."-generation-lock.txt";
|
||||
|
||||
if (! $fp = fopen($lock_file, "w")) {
|
||||
throw new IOException(sprintf('Failed to open lock file %s', $lock_file));
|
||||
}
|
||||
|
||||
if (flock($fp, LOCK_EX|LOCK_NB)) { // do an exclusive lock
|
||||
*/
|
||||
$tmp_dir = "$to_directory.tmp";
|
||||
|
||||
if (! $fp = fopen($lock_file, "w")) {
|
||||
throw new IOException(sprintf('Failed to open lock file %s', $lock_file));
|
||||
$fs->remove($tmp_dir);
|
||||
|
||||
// Copy the whole source dir in a temp directory
|
||||
$this->copyAssets($fs, $source_assets_directory, $tmp_dir);
|
||||
|
||||
// Remove existing directory
|
||||
if ($fs->exists($to_directory)) $fs->remove($to_directory);
|
||||
|
||||
// Put in place the new directory
|
||||
$fs->rename($tmp_dir, $to_directory);
|
||||
/*
|
||||
// Release the lock
|
||||
flock($fp, LOCK_UN);
|
||||
|
||||
// Remove the lock file
|
||||
@fclose($fp);
|
||||
|
||||
$fs->remove($lock_file);
|
||||
*/
|
||||
if (false === @file_put_contents($stamp_file_path, $curr_stamp)) {
|
||||
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.");
|
||||
}
|
||||
|
||||
if (flock($fp, LOCK_EX|LOCK_NB)) { // do an exclusive lock
|
||||
*/
|
||||
$tmp_dir = "$to_directory.tmp";
|
||||
|
||||
$fs->remove($tmp_dir);
|
||||
|
||||
// Copy the whole source dir in a temp directory
|
||||
$this->copyAssets($fs, $sourceAssetsDirectory, $tmp_dir);
|
||||
|
||||
// Remove existing directory
|
||||
if ($fs->exists($to_directory)) $fs->remove($to_directory);
|
||||
|
||||
// Put in place the new directory
|
||||
$fs->rename($tmp_dir, $to_directory);
|
||||
/*
|
||||
// Release the lock
|
||||
flock($fp, LOCK_UN);
|
||||
|
||||
// Remove the lock file
|
||||
@fclose($fp);
|
||||
|
||||
$fs->remove($lock_file);
|
||||
*/
|
||||
if (false === @file_put_contents($stamp_file_path, $curr_stamp)) {
|
||||
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 {
|
||||
@fclose($fp);
|
||||
}
|
||||
*/
|
||||
/* } else {
|
||||
@fclose($fp);
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 +273,7 @@ class AsseticAssetManager implements AssetManagerInterface
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$filter_list = array();
|
||||
}
|
||||
|
||||
@@ -272,73 +283,67 @@ 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 string $asset_path 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 $web_assets_directory_base the full disk path to the base assets output directory in the web space
|
||||
* @param string $output_url 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 $asset_type 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
|
||||
*
|
||||
* @return string The URL to the generated asset file.
|
||||
* @param boolean $debug true / false
|
||||
* @throws \InvalidArgumentException if an invalid filter name is found
|
||||
* @return string The URL to the generated asset file.
|
||||
*/
|
||||
public function processAsset($assetSource, $assetDirectoryBase, $webAssetsDirectoryBase, $webAssetsTemplate, $webAssetsKey, $outputUrl, $assetType, $filters, $debug)
|
||||
public function processAsset($asset_path, $web_assets_directory_base, $output_url, $asset_type, $filters, $debug)
|
||||
{
|
||||
$assetName = basename($assetSource);
|
||||
$inputDirectory = realpath(dirname($assetSource));
|
||||
|
||||
$assetFileDirectoryInAssetDirectory = trim(str_replace(array($assetDirectoryBase, $assetName), '', $assetSource), DS);
|
||||
$asset_name = basename($asset_path);
|
||||
$input_directory = realpath(dirname($asset_path));
|
||||
|
||||
$am = new AssetManager();
|
||||
$fm = new FilterManager();
|
||||
|
||||
// Get the filter list
|
||||
$filterList = $this->decodeAsseticFilters($fm, $filters);
|
||||
$filter_list = $this->decodeAsseticFilters($fm, $filters);
|
||||
|
||||
// Factory setup
|
||||
$factory = new AssetFactory($inputDirectory);
|
||||
$factory = new AssetFactory($input_directory);
|
||||
|
||||
$factory->setAssetManager($am);
|
||||
$factory->setFilterManager($fm);
|
||||
|
||||
$factory->setDefaultOutput('*' . (!empty($assetType) ? '.' : '') . $assetType);
|
||||
$factory->setDefaultOutput('*' . (!empty($asset_type) ? '.' : '') . $asset_type);
|
||||
|
||||
$factory->setDebug($debug);
|
||||
|
||||
$asset = $factory->createAsset($assetName, $filterList);
|
||||
$asset = $factory->createAsset($asset_name, $filter_list);
|
||||
|
||||
$outputDirectory = $this->getDestinationDirectory($webAssetsDirectoryBase, $webAssetsTemplate, $webAssetsKey);
|
||||
$input_directory = realpath(dirname($asset_path));
|
||||
|
||||
$output_directory = $this->getDestinationDirectory($input_directory, $web_assets_directory_base);
|
||||
|
||||
// Get the URL part from the relative path
|
||||
$outputRelativePath = $webAssetsTemplate . DS . $webAssetsKey;
|
||||
$output_relative_path = $this->getRelativeDirectoryPath($input_directory, $web_assets_directory_base);
|
||||
|
||||
$outputRelativeWebPath = rtrim(str_replace('\\', '/', $outputRelativePath), '/') . '/';
|
||||
$output_relative_web_path = rtrim(str_replace('\\', '/', $output_relative_path), '/') . '/';
|
||||
|
||||
$assetTargetFilename = $asset->getTargetPath();
|
||||
$asset_target_filename = $asset->getTargetPath();
|
||||
|
||||
/*
|
||||
* This is the final name of the generated asset
|
||||
* We preserve file structure intending to keep - for example - relative css links working
|
||||
*/
|
||||
$assetDestinationPath = $outputDirectory . DS . $assetFileDirectoryInAssetDirectory . DS . $assetTargetFilename;
|
||||
// This is the final name of the generated asset
|
||||
$asset_destination_path = $output_directory . DS . $asset_target_filename;
|
||||
|
||||
Tlog::getInstance()->addDebug("Asset destination full path: $assetDestinationPath");
|
||||
Tlog::getInstance()->addDebug("Asset destination full path: $asset_destination_path");
|
||||
|
||||
// We generate an asset only if it does not exists, or if the asset processing is forced in development mode
|
||||
if (! file_exists($assetDestinationPath) || ($this->debugMode && ConfigQuery::read('process_assets', true)) ) {
|
||||
if (! file_exists($asset_destination_path) || ($this->debugMode && ConfigQuery::read('process_assets', true)) ) {
|
||||
|
||||
$writer = new AssetWriter($outputDirectory . DS . $assetFileDirectoryInAssetDirectory);
|
||||
$writer = new AssetWriter($output_directory);
|
||||
|
||||
Tlog::getInstance()->addDebug("Writing asset to $outputDirectory . DS . $assetFileDirectoryInAssetDirectory");
|
||||
Tlog::getInstance()->addDebug("Writing asset to $output_directory");
|
||||
|
||||
$writer->writeAsset($asset);
|
||||
}
|
||||
|
||||
return rtrim($outputUrl, '/') . '/' . trim($outputRelativeWebPath, '/') . '/' . trim($assetFileDirectoryInAssetDirectory, '/') . '/' . ltrim($assetTargetFilename, '/');
|
||||
return rtrim($output_url, '/') . '/' . ltrim($output_relative_web_path, '/') . $asset_target_filename;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -277,7 +277,6 @@ abstract class BaseLoop
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function searchArray(array $search, &$pagination = null)
|
||||
{
|
||||
if (false === $this->countable) {
|
||||
@@ -286,7 +285,7 @@ abstract class BaseLoop
|
||||
if ($this->getArgValue('page') !== null) {
|
||||
|
||||
$nbPage = ceil(count($search)/$this->getArgValue('limit'));
|
||||
if($this->getArgValue('page') > $nbPage || $this->getArgValue('page') <= 0) {
|
||||
if ($this->getArgValue('page') > $nbPage || $this->getArgValue('page') <= 0) {
|
||||
return array();
|
||||
}
|
||||
|
||||
@@ -338,9 +337,9 @@ abstract class BaseLoop
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
if($this instanceof PropelSearchLoopInterface) {
|
||||
if ($this instanceof PropelSearchLoopInterface) {
|
||||
$searchModelCriteria = $this->buildModelCriteria();
|
||||
if(null === $searchModelCriteria) {
|
||||
if (null === $searchModelCriteria) {
|
||||
$results = array();
|
||||
} else {
|
||||
$results = $this->search(
|
||||
@@ -350,7 +349,7 @@ abstract class BaseLoop
|
||||
}
|
||||
} elseif ($this instanceof ArraySearchLoopInterface) {
|
||||
$searchArray = $this->buildArray();
|
||||
if(null === $searchArray) {
|
||||
if (null === $searchArray) {
|
||||
$results = array();
|
||||
} else {
|
||||
$results = $this->searchArray(
|
||||
@@ -362,13 +361,13 @@ abstract class BaseLoop
|
||||
|
||||
$loopResult = new LoopResult($results);
|
||||
|
||||
if(true === $this->countable) {
|
||||
if (true === $this->countable) {
|
||||
$loopResult->setCountable();
|
||||
}
|
||||
if(true === $this->timestampable) {
|
||||
if (true === $this->timestampable) {
|
||||
$loopResult->setTimestamped();
|
||||
}
|
||||
if(true === $this->versionable) {
|
||||
if (true === $this->versionable) {
|
||||
$loopResult->setVersioned();
|
||||
}
|
||||
|
||||
@@ -382,29 +381,29 @@ abstract class BaseLoop
|
||||
* - ArraySearchLoopInterface
|
||||
*/
|
||||
$searchInterface = false;
|
||||
if($this instanceof PropelSearchLoopInterface) {
|
||||
if(true === $searchInterface) {
|
||||
if ($this instanceof PropelSearchLoopInterface) {
|
||||
if (true === $searchInterface) {
|
||||
throw new LoopException('Loop cannot implements multiple Search Interfaces : `PropelSearchLoopInterface`, `ArraySearchLoopInterface`', LoopException::MULTIPLE_SEARCH_INTERFACE);
|
||||
}
|
||||
$searchInterface = true;
|
||||
}
|
||||
if($this instanceof ArraySearchLoopInterface) {
|
||||
if(true === $searchInterface) {
|
||||
if ($this instanceof ArraySearchLoopInterface) {
|
||||
if (true === $searchInterface) {
|
||||
throw new LoopException('Loop cannot implements multiple Search Interfaces : `PropelSearchLoopInterface`, `ArraySearchLoopInterface`', LoopException::MULTIPLE_SEARCH_INTERFACE);
|
||||
}
|
||||
$searchInterface = true;
|
||||
}
|
||||
|
||||
if(false === $searchInterface) {
|
||||
if (false === $searchInterface) {
|
||||
throw new LoopException('Loop must implements one of the following interfaces : `PropelSearchLoopInterface`, `ArraySearchLoopInterface`', LoopException::SEARCH_INTERFACE_NOT_FOUND);
|
||||
}
|
||||
|
||||
/* Only PropelSearch allows timestamp and version */
|
||||
if(!$this instanceof PropelSearchLoopInterface) {
|
||||
if(true === $this->timestampable) {
|
||||
if (!$this instanceof PropelSearchLoopInterface) {
|
||||
if (true === $this->timestampable) {
|
||||
throw new LoopException("Loop must implements 'PropelSearchLoopInterface' to be timestampable", LoopException::NOT_TIMESTAMPED);
|
||||
}
|
||||
if(true === $this->versionable) {
|
||||
if (true === $this->versionable) {
|
||||
throw new LoopException("Loop must implements 'PropelSearchLoopInterface' to be versionable", LoopException::NOT_VERSIONED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\AdminQuery;
|
||||
use Thelia\Type;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -48,7 +48,7 @@ class AssociatedContent extends Content
|
||||
{
|
||||
protected $contentId;
|
||||
protected $contentPosition;
|
||||
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
*/
|
||||
|
||||
@@ -88,7 +88,7 @@ class Auth extends BaseLoop implements ArraySearchLoopInterface
|
||||
$module = $this->getModule();
|
||||
$access = $this->getAccess();
|
||||
|
||||
if(null !== $module) {
|
||||
if (null !== $module) {
|
||||
$in = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
|
||||
@@ -58,7 +58,7 @@ class Cart extends BaseLoop implements ArraySearchLoopInterface
|
||||
{
|
||||
$cart = $this->getCart($this->request);
|
||||
|
||||
if(null === $cart) {
|
||||
if (null === $cart) {
|
||||
return array();
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ class Cart extends BaseLoop implements ArraySearchLoopInterface
|
||||
{
|
||||
$taxCountry = TaxEngine::getInstance($this->request->getSession())->getDeliveryCountry();
|
||||
|
||||
foreach($loopResult->getResultDataCollection() as $cartItem) {
|
||||
foreach ($loopResult->getResultDataCollection() as $cartItem) {
|
||||
$product = $cartItem->getProduct();
|
||||
$productSaleElement = $cartItem->getProductSaleElements();
|
||||
|
||||
|
||||
@@ -125,9 +125,9 @@ class CategoryPath extends BaseI18nLoop implements ArraySearchLoopInterface
|
||||
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach($loopResult->getResultDataCollection() as $result) {
|
||||
foreach ($loopResult->getResultDataCollection() as $result) {
|
||||
$loopResultRow = new LoopResultRow($result);
|
||||
foreach($result as $output => $outputValue) {
|
||||
foreach ($result as $output => $outputValue) {
|
||||
$loopResultRow->set($output, $outputValue);
|
||||
}
|
||||
$loopResult->addRow($loopResultRow);
|
||||
|
||||
@@ -99,9 +99,9 @@ class CategoryTree extends BaseI18nLoop implements ArraySearchLoopInterface
|
||||
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach($loopResult->getResultDataCollection() as $result) {
|
||||
foreach ($loopResult->getResultDataCollection() as $result) {
|
||||
$loopResultRow = new LoopResultRow($result);
|
||||
foreach($result as $output => $outputValue) {
|
||||
foreach ($result as $output => $outputValue) {
|
||||
$loopResultRow->set($output, $outputValue);
|
||||
}
|
||||
$loopResult->addRow($loopResultRow);
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\Util\PropelModelPager;
|
||||
use Thelia\Condition\ConditionFactory;
|
||||
use Thelia\Condition\Implementation\ConditionInterface;
|
||||
use Thelia\Core\HttpFoundation\Request;
|
||||
|
||||
@@ -158,6 +158,7 @@ class Currency extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
}
|
||||
|
||||
/* perform search */
|
||||
|
||||
return $search;
|
||||
|
||||
}
|
||||
|
||||
@@ -36,9 +36,6 @@ use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Model\CustomerQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
use Thelia\Model\OrderQuery;
|
||||
use Thelia\Model\Map\OrderAddressTableMap;
|
||||
use Thelia\Model\Map\OrderTableMap;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -208,7 +205,6 @@ class Customer extends BaseLoop implements SearchLoopInterface, PropelSearchLoop
|
||||
$search->orderByCreatedAt(Criteria::DESC);
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,8 +74,8 @@ class Delivery extends BaseSpecificModule
|
||||
|
||||
try {
|
||||
$postage = $moduleInstance->getPostage($country);
|
||||
} catch(OrderException $e) {
|
||||
switch($e->getCode()) {
|
||||
} catch (OrderException $e) {
|
||||
switch ($e->getCode()) {
|
||||
case OrderException::DELIVERY_MODULE_UNAVAILABLE:
|
||||
/* do not show this delivery module */
|
||||
continue(2);
|
||||
|
||||
@@ -126,7 +126,6 @@ class Folder extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
|
||||
if ($visible !== BooleanOrBothType::ANY) $search->filterByVisible($visible ? 1 : 0);
|
||||
|
||||
|
||||
$orders = $this->getOrder();
|
||||
|
||||
foreach ($orders as $order) {
|
||||
|
||||
@@ -135,9 +135,9 @@ class FolderPath extends BaseI18nLoop implements ArraySearchLoopInterface
|
||||
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach($loopResult->getResultDataCollection() as $result) {
|
||||
foreach ($loopResult->getResultDataCollection() as $result) {
|
||||
$loopResultRow = new LoopResultRow($result);
|
||||
foreach($result as $output => $outputValue) {
|
||||
foreach ($result as $output => $outputValue) {
|
||||
$loopResultRow->set($output, $outputValue);
|
||||
}
|
||||
$loopResult->addRow($loopResultRow);
|
||||
|
||||
@@ -100,9 +100,9 @@ class FolderTree extends BaseI18nLoop implements ArraySearchLoopInterface
|
||||
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
foreach($loopResult->getResultDataCollection() as $result) {
|
||||
foreach ($loopResult->getResultDataCollection() as $result) {
|
||||
$loopResultRow = new LoopResultRow($result);
|
||||
foreach($result as $output => $outputValue) {
|
||||
foreach ($result as $output => $outputValue) {
|
||||
$loopResultRow->set($output, $outputValue);
|
||||
}
|
||||
$loopResult->addRow($loopResultRow);
|
||||
|
||||
@@ -236,7 +236,6 @@ class Image extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
$search->filterById($exclude, Criteria::NOT_IN);
|
||||
|
||||
// echo "sql=".$search->toString();
|
||||
|
||||
return $search;
|
||||
|
||||
}
|
||||
|
||||
@@ -196,19 +196,19 @@ class Module extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
|
||||
/* first test if module defines it's own config route */
|
||||
$routerId = "router." . $module->getBaseDir();
|
||||
if($this->container->has($routerId)) {
|
||||
if ($this->container->has($routerId)) {
|
||||
try {
|
||||
if($this->container->get($routerId)->match('/admin/module/' . $module->getCode())) {
|
||||
if ($this->container->get($routerId)->match('/admin/module/' . $module->getCode())) {
|
||||
$hasConfigurationInterface = true;
|
||||
}
|
||||
} catch(ResourceNotFoundException $e) {
|
||||
} catch (ResourceNotFoundException $e) {
|
||||
/* $hasConfigurationInterface stays false */
|
||||
}
|
||||
}
|
||||
|
||||
/* if not ; test if it uses admin inclusion : module_configuration.html */
|
||||
if(false === $hasConfigurationInterface) {
|
||||
if(file_exists( sprintf("%s/AdminIncludes/%s.html", $module->getAbsoluteBaseDir(), "module_configuration"))) {
|
||||
if (false === $hasConfigurationInterface) {
|
||||
if (file_exists( sprintf("%s/AdminIncludes/%s.html", $module->getAbsoluteBaseDir(), "module_configuration"))) {
|
||||
$hasConfigurationInterface = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ use Thelia\Type;
|
||||
*/
|
||||
class Order extends BaseLoop implements SearchLoopInterface, PropelSearchLoopInterface
|
||||
{
|
||||
protected $countable = true;
|
||||
protected $countable = true;
|
||||
protected $timestampable = true;
|
||||
protected $versionable = false;
|
||||
|
||||
@@ -175,7 +175,6 @@ class Order extends BaseLoop implements SearchLoopInterface, PropelSearchLoopInt
|
||||
}
|
||||
|
||||
return $search;
|
||||
|
||||
}
|
||||
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
@@ -202,6 +201,7 @@ class Order extends BaseLoop implements SearchLoopInterface, PropelSearchLoopInt
|
||||
->set("STATUS", $order->getStatusId())
|
||||
->set("LANG", $order->getLangId())
|
||||
->set("POSTAGE", $order->getPostage())
|
||||
->set("DISCOUNT", $order->getDiscount())
|
||||
->set("TOTAL_TAX", $tax)
|
||||
->set("TOTAL_AMOUNT", $amount - $tax)
|
||||
->set("TOTAL_TAXED_AMOUNT", $amount)
|
||||
|
||||
116
core/lib/Thelia/Core/Template/Loop/OrderCoupon.php
Executable file
116
core/lib/Thelia/Core/Template/Loop/OrderCoupon.php
Executable file
@@ -0,0 +1,116 @@
|
||||
<?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\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;
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
* OrderCoupon loop
|
||||
*
|
||||
*
|
||||
* Class OrderCoupon
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class OrderCoupon extends BaseLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
/**
|
||||
* Define all args used in your loop
|
||||
*
|
||||
* @return ArgumentCollection
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntTypeArgument('order', null, true)
|
||||
);
|
||||
}
|
||||
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
$search = OrderCouponQuery::create();
|
||||
|
||||
$order = $this->getOrder();
|
||||
|
||||
$search->filterByOrderId($order, Criteria::EQUAL);
|
||||
|
||||
$search->orderById(Criteria::ASC);
|
||||
|
||||
return $search;
|
||||
|
||||
}
|
||||
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
$conditionFactory = $this->container->get('thelia.condition.factory');
|
||||
|
||||
/** @var OrderCoupon $orderCoupon */
|
||||
foreach ($loopResult->getResultDataCollection() as $orderCoupon) {
|
||||
$loopResultRow = new LoopResultRow($orderCoupon);
|
||||
$conditions = $conditionFactory->unserializeConditionCollection(
|
||||
$orderCoupon->getSerializedConditions()
|
||||
);
|
||||
|
||||
$now = time();
|
||||
$datediff = $orderCoupon->getExpirationDate()->getTimestamp() - $now;
|
||||
$daysLeftBeforeExpiration = floor($datediff/(60*60*24));
|
||||
|
||||
$cleanedConditions = array();
|
||||
|
||||
foreach ($conditions->getConditions() as $condition) {
|
||||
$cleanedConditions[] = $condition->getToolTip();
|
||||
}
|
||||
$loopResultRow->set("ID", $orderCoupon->getId())
|
||||
->set("CODE", $orderCoupon->getCode())
|
||||
->set("TITLE", $orderCoupon->getTitle())
|
||||
->set("SHORT_DESCRIPTION", $orderCoupon->getShortDescription())
|
||||
->set("DESCRIPTION", $orderCoupon->getDescription())
|
||||
->set("EXPIRATION_DATE", $orderCoupon->getExpirationDate( OrderQuery::create()->findPk($this->getOrder())->getLangId() ))
|
||||
->set("USAGE_LEFT", $orderCoupon->getMaxUsage())
|
||||
->set("IS_CUMULATIVE", $orderCoupon->getIsCumulative())
|
||||
->set("IS_REMOVING_POSTAGE", $orderCoupon->getIsRemovingPostage())
|
||||
->set("IS_AVAILABLE_ON_SPECIAL_OFFERS", $orderCoupon->getIsAvailableOnSpecialOffers())
|
||||
->set("AMOUNT", $orderCoupon->getAmount())
|
||||
->set("APPLICATION_CONDITIONS", $cleanedConditions)
|
||||
->set("DAY_LEFT_BEFORE_EXPIRATION", $daysLeftBeforeExpiration)
|
||||
;
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
@@ -72,7 +72,7 @@ class OrderProduct extends BaseLoop implements PropelSearchLoopInterface
|
||||
$search->orderById(Criteria::ASC);
|
||||
|
||||
return $search;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
|
||||
@@ -87,7 +87,7 @@ class OrderProductAttributeCombination extends BaseI18nLoop implements PropelSea
|
||||
}
|
||||
|
||||
return $search;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
|
||||
@@ -103,4 +103,4 @@ class ProductTemplate extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\ProfileQuery;
|
||||
use Thelia\Type;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -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,8 +65,14 @@ class Template extends BaseLoop implements ArraySearchLoopInterface
|
||||
);
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
public function buildArray() {
|
||||
$type = $this->getArg('template-type')->getValue();
|
||||
=======
|
||||
public function buildArray()
|
||||
{
|
||||
$type = $this->getArg(template_type);
|
||||
>>>>>>> cleanmaster
|
||||
|
||||
if ($type == 'front-office')
|
||||
$templateType = TemplateDefinition::FRONT_OFFICE;
|
||||
|
||||
@@ -23,8 +23,11 @@
|
||||
|
||||
namespace Thelia\Core\Template\Smarty\Assets;
|
||||
|
||||
<<<<<<< HEAD
|
||||
use Thelia\Core\Template\Assets\AsseticHelper;
|
||||
use Thelia\Core\Template\TemplateDefinition;
|
||||
=======
|
||||
>>>>>>> cleanmaster
|
||||
use Thelia\Tools\URL;
|
||||
use Thelia\Core\Template\Assets\AssetManagerInterface;
|
||||
|
||||
@@ -42,9 +45,9 @@ class SmartyAssetsManager
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
@@ -56,6 +59,7 @@ class SmartyAssetsManager
|
||||
|
||||
public function prepareAssets($assets_directory, \Smarty_Internal_Template $template)
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
self::$assetsDirectory = $assets_directory;
|
||||
|
||||
$smartyParser = $template->smarty;
|
||||
@@ -70,6 +74,9 @@ class SmartyAssetsManager
|
||||
foreach($templateDirectories[$templateDefinition->getName()] as $key => $directory) {
|
||||
|
||||
$tpl_path = $directory . DS . self::$assetsDirectory;
|
||||
=======
|
||||
$tpl_dir = dirname($template->source->filepath);
|
||||
>>>>>>> cleanmaster
|
||||
|
||||
$asset_dir_absolute_path = realpath($tpl_path);
|
||||
|
||||
|
||||
@@ -27,8 +27,6 @@ use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
|
||||
use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
|
||||
use Thelia\Tools\URL;
|
||||
use Thelia\Core\Security\SecurityContext;
|
||||
use Thelia\Model\Config;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Core\Template\TemplateHelper;
|
||||
|
||||
/**
|
||||
@@ -45,8 +43,8 @@ class AdminUtilities extends AbstractSmartyPlugin
|
||||
$this->securityContext = $securityContext;
|
||||
}
|
||||
|
||||
protected function fetch_snippet($smarty, $templateName, $variablesArray) {
|
||||
|
||||
protected function fetch_snippet($smarty, $templateName, $variablesArray)
|
||||
{
|
||||
$data = '';
|
||||
|
||||
$snippet_path = sprintf('%s/%s/%s.html',
|
||||
@@ -99,7 +97,6 @@ class AdminUtilities extends AbstractSmartyPlugin
|
||||
$module === null ? array() : array($module),
|
||||
array($access))
|
||||
) {
|
||||
|
||||
return $this->fetch_snippet($smarty, 'includes/admin-utilities-position-block', array(
|
||||
'admin_utilities_go_up_url' => URL::getInstance()->absoluteUrl($path, array('mode' => 'up', $url_parameter => $id)),
|
||||
'admin_utilities_in_place_edit_class' => $in_place_edit_class,
|
||||
|
||||
@@ -56,10 +56,11 @@ class Assets extends AbstractSmartyPlugin
|
||||
{
|
||||
try {
|
||||
return $this->assetManager->processSmartyPluginCall('js', $params, $content, $template, $repeat);
|
||||
} catch(\Exception $e) {
|
||||
} catch (\Exception $e) {
|
||||
$catchException = $this->getNormalizedParam($params, array('catchException'));
|
||||
if($catchException == "true") {
|
||||
if ($catchException == "true") {
|
||||
$repeat = false;
|
||||
|
||||
return null;
|
||||
} else {
|
||||
throw $e;
|
||||
|
||||
@@ -212,6 +212,8 @@ class DataAccessFunctions extends AbstractSmartyPlugin
|
||||
switch ($attribute) {
|
||||
case 'postage':
|
||||
return $order->getPostage();
|
||||
case 'discount':
|
||||
return $order->getDiscount();
|
||||
case 'delivery_address':
|
||||
return $order->chosenDeliveryAddress;
|
||||
case 'invoice_address':
|
||||
@@ -267,69 +269,69 @@ class DataAccessFunctions extends AbstractSmartyPlugin
|
||||
$includeShipping = true;
|
||||
}
|
||||
|
||||
if($params['startDate'] == 'today') {
|
||||
if ($params['startDate'] == 'today') {
|
||||
$startDate = new \DateTime();
|
||||
$startDate->setTime(0, 0, 0);
|
||||
} elseif($params['startDate'] == 'yesterday') {
|
||||
} elseif ($params['startDate'] == 'yesterday') {
|
||||
$startDate = new \DateTime();
|
||||
$startDate->setTime(0, 0, 0);
|
||||
$startDate->modify('-1 day');
|
||||
} elseif($params['startDate'] == 'this_month') {
|
||||
} elseif ($params['startDate'] == 'this_month') {
|
||||
$startDate = new \DateTime();
|
||||
$startDate->modify('first day of this month');
|
||||
$startDate->setTime(0, 0, 0);
|
||||
} elseif($params['startDate'] == 'last_month') {
|
||||
} elseif ($params['startDate'] == 'last_month') {
|
||||
$startDate = new \DateTime();
|
||||
$startDate->modify('first day of last month');
|
||||
$startDate->setTime(0, 0, 0);
|
||||
} elseif($params['startDate'] == 'this_year') {
|
||||
} elseif ($params['startDate'] == 'this_year') {
|
||||
$startDate = new \DateTime();
|
||||
$startDate->modify('first day of January this year');
|
||||
$startDate->setTime(0, 0, 0);
|
||||
} elseif($params['startDate'] == 'last_year') {
|
||||
} elseif ($params['startDate'] == 'last_year') {
|
||||
$startDate = new \DateTime();
|
||||
$startDate->modify('first day of December last year');
|
||||
$startDate->setTime(0, 0, 0);
|
||||
} else {
|
||||
try {
|
||||
$startDate = new \DateTime($params['startDate']);
|
||||
} catch(\Exception $e) {
|
||||
} catch (\Exception $e) {
|
||||
throw new \InvalidArgumentException(sprintf("invalid startDate attribute '%s' in stats access function", $params['startDate']));
|
||||
}
|
||||
}
|
||||
|
||||
if($params['endDate'] == 'today') {
|
||||
if ($params['endDate'] == 'today') {
|
||||
$endDate = new \DateTime();
|
||||
$endDate->setTime(0, 0, 0);
|
||||
} elseif($params['endDate'] == 'yesterday') {
|
||||
} elseif ($params['endDate'] == 'yesterday') {
|
||||
$endDate = new \DateTime();
|
||||
$endDate->setTime(0, 0, 0);
|
||||
$endDate->modify('-1 day');
|
||||
} elseif($params['endDate'] == 'this_month') {
|
||||
} elseif ($params['endDate'] == 'this_month') {
|
||||
$endDate = new \DateTime();
|
||||
$endDate->modify('last day of this month');
|
||||
$endDate->setTime(0, 0, 0);
|
||||
} elseif($params['endDate'] == 'last_month') {
|
||||
} elseif ($params['endDate'] == 'last_month') {
|
||||
$endDate = new \DateTime();
|
||||
$endDate->modify('last day of last month');
|
||||
$endDate->setTime(0, 0, 0);
|
||||
} elseif($params['endDate'] == 'this_year') {
|
||||
} elseif ($params['endDate'] == 'this_year') {
|
||||
$endDate = new \DateTime();
|
||||
$endDate->modify('last day of December this year');
|
||||
$endDate->setTime(0, 0, 0);
|
||||
} elseif($params['endDate'] == 'last_year') {
|
||||
} elseif ($params['endDate'] == 'last_year') {
|
||||
$endDate = new \DateTime();
|
||||
$endDate->modify('last day of January last year');
|
||||
$endDate->setTime(0, 0, 0);
|
||||
} else {
|
||||
try {
|
||||
$endDate = new \DateTime($params['endDate']);
|
||||
} catch(\Exception $e) {
|
||||
} catch (\Exception $e) {
|
||||
throw new \InvalidArgumentException(sprintf("invalid endDate attribute '%s' in stats access function", $params['endDate']));
|
||||
}
|
||||
}
|
||||
|
||||
switch( $params['key'] ) {
|
||||
switch ($params['key']) {
|
||||
case 'sales' :
|
||||
return OrderQuery::getSaleStats($startDate, $endDate, $includeShipping);
|
||||
case 'orders' :
|
||||
|
||||
@@ -28,7 +28,6 @@ use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
|
||||
use Thelia\Core\Template\Smarty\an;
|
||||
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
|
||||
|
||||
|
||||
/**
|
||||
* Class Esi
|
||||
* @package Thelia\Core\Template\Smarty\Plugins
|
||||
@@ -53,7 +52,7 @@ class Esi extends AbstractSmartyPlugin
|
||||
$ignore_errors = $this->getParam($params, 'ignore_errors');
|
||||
$comment = $this->getParam($params, 'comment');
|
||||
|
||||
if(null === $path) {
|
||||
if (null === $path) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -79,4 +78,4 @@ class Esi extends AbstractSmartyPlugin
|
||||
new SmartyPluginDescriptor('function', 'render_esi', $this, 'renderEsi')
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ class Module extends AbstractSmartyPlugin
|
||||
/**
|
||||
* Process theliaModule template inclusion function
|
||||
*
|
||||
* @param unknown $params
|
||||
* @param unknown $params
|
||||
* @param \Smarty_Internal_Template $template
|
||||
* @internal param \Thelia\Core\Template\Smarty\Plugins\unknown $smarty
|
||||
*
|
||||
@@ -60,7 +60,7 @@ class Module extends AbstractSmartyPlugin
|
||||
|
||||
if (false !== $location = $this->getParam($params, 'location', false)) {
|
||||
|
||||
if($this->debug === true && $this->request->get('SHOW_INCLUDE')) {
|
||||
if ($this->debug === true && $this->request->get('SHOW_INCLUDE')) {
|
||||
echo sprintf('<div style="background-color: #C82D26; border-color: #000000; border: solid;">%s</div>', $location);
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ class Module extends AbstractSmartyPlugin
|
||||
|
||||
foreach ($modules as $module) {
|
||||
|
||||
if(null !== $moduleLimit && $moduleLimit != $module->getCode()) {
|
||||
if (null !== $moduleLimit && $moduleLimit != $module->getCode()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,9 +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;
|
||||
|
||||
/**
|
||||
@@ -35,12 +32,7 @@ class SmartyParser extends Smarty implements ParserInterface
|
||||
protected $backOfficeTemplateDirectories = array();
|
||||
protected $frontOfficeTemplateDirectories = array();
|
||||
|
||||
protected $templateDirectories = array();
|
||||
|
||||
/**
|
||||
* @var TemplateDefinition
|
||||
*/
|
||||
protected $templateDefinition = "";
|
||||
protected $template = "";
|
||||
|
||||
protected $status = 200;
|
||||
|
||||
@@ -52,8 +44,8 @@ class SmartyParser extends Smarty implements ParserInterface
|
||||
* @param bool $debug
|
||||
*/
|
||||
public function __construct(
|
||||
Request $request, EventDispatcherInterface $dispatcher, ParserContext $parserContext,
|
||||
$env = "prod", $debug = false)
|
||||
Request $request, EventDispatcherInterface $dispatcher, ParserContext $parserContext,
|
||||
$env = "prod", $debug = false)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
@@ -72,7 +64,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 +71,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 +80,6 @@ class SmartyParser extends Smarty implements ParserInterface
|
||||
|
||||
//$this->enableSecurity();
|
||||
|
||||
|
||||
// The default HTTP status
|
||||
$this->status = 200;
|
||||
|
||||
@@ -97,46 +87,6 @@ class SmartyParser extends Smarty implements ParserInterface
|
||||
$this->registerFilter('variable', array(__CLASS__, "theliaEscape"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 ?
|
||||
*/
|
||||
public function addTemplateDirectory($templateType, $templateName, $templateDirectory, $key, $unshift = false) {
|
||||
|
||||
if(true === $unshift && isset($this->templateDirectories[$templateType][$templateName])) {
|
||||
|
||||
$this->templateDirectories[$templateType][$templateName] = array_merge(
|
||||
array(
|
||||
$key => $templateDirectory,
|
||||
),
|
||||
$this->templateDirectories[$templateType][$templateName]
|
||||
);
|
||||
} else {
|
||||
$this->templateDirectories[$templateType][$templateName][$key] = $templateDirectory;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the registeted template directories for a givent template type
|
||||
*
|
||||
* @param unknown $templateType
|
||||
* @throws InvalidArgumentException
|
||||
* @return multitype:
|
||||
*/
|
||||
public function getTemplateDirectories($templateType)
|
||||
{
|
||||
if (! isset($this->templateDirectories[$templateType])) {
|
||||
throw new InvalidArgumentException("Failed to get template type %", $templateType);
|
||||
}
|
||||
|
||||
return $this->templateDirectories[$templateType];
|
||||
}
|
||||
|
||||
public function removeBlankLines($tpl_source, \Smarty_Internal_Template $template)
|
||||
{
|
||||
return preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $tpl_source);
|
||||
@@ -151,52 +101,72 @@ class SmartyParser extends Smarty implements ParserInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function addBackOfficeTemplateDirectory($templateName, $templateDirectory, $key)
|
||||
{
|
||||
$this->backOfficeTemplateDirectories[$templateName][$key] = $templateDirectory;
|
||||
}
|
||||
|
||||
public function addFrontOfficeTemplateDirectory($templateName, $templateDirectory, $key)
|
||||
{
|
||||
$this->frontOfficeTemplateDirectories[$templateName][$key] = $templateDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TemplateDefinition $templateDefinition
|
||||
*/
|
||||
public function setTemplateDefinition(TemplateDefinition $templateDefinition)
|
||||
public function setTemplate(TemplateDefinition $templateDefinition)
|
||||
{
|
||||
$this->templateDefinition = $templateDefinition;
|
||||
$this->template = $templateDefinition->getPath();
|
||||
|
||||
/* init template directories */
|
||||
$this->setTemplateDir(array());
|
||||
|
||||
/* add main template directory */
|
||||
$this->addTemplateDir($templateDefinition->getAbsolutePath(), 0);
|
||||
|
||||
/* define config directory */
|
||||
$configDirectory = THELIA_TEMPLATE_DIR . $this->getTemplate() . '/configs';
|
||||
$configDirectory = $templateDefinition->getAbsoluteConfigPath();
|
||||
$this->setConfigDir($configDirectory);
|
||||
|
||||
/* add modules template directories */
|
||||
$this->addTemplateDirectory(
|
||||
$templateDefinition->getType(),
|
||||
$templateDefinition->getName(),
|
||||
THELIA_TEMPLATE_DIR . $this->getTemplate(),
|
||||
'0',
|
||||
true
|
||||
);
|
||||
switch ($templateDefinition->getType()) {
|
||||
case TemplateDefinition::FRONT_OFFICE:
|
||||
/* do not pass array directly to addTemplateDir since we cant control on keys */
|
||||
if (isset($this->frontOfficeTemplateDirectories[$templateDefinition->getName()])) {
|
||||
foreach ($this->frontOfficeTemplateDirectories[$templateDefinition->getName()] as $key => $directory) {
|
||||
$this->addTemplateDir($directory, $key);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* 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) {
|
||||
$this->addTemplateDir($directory, $key);
|
||||
}
|
||||
case TemplateDefinition::BACK_OFFICE:
|
||||
/* do not pass array directly to addTemplateDir since we cant control on keys */
|
||||
if (isset($this->backOfficeTemplateDirectories[$templateDefinition->getName()])) {
|
||||
foreach ($this->backOfficeTemplateDirectories[$templateDefinition->getName()] as $key => $directory) {
|
||||
$this->addTemplateDir($directory, $key);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case TemplateDefinition::PDF:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function getTemplateDefinition()
|
||||
{
|
||||
return $this->templateDefinition;
|
||||
}
|
||||
|
||||
public function getTemplate()
|
||||
{
|
||||
return $this->templateDefinition->getPath();
|
||||
return $this->template;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 +185,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 +201,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())
|
||||
@@ -287,15 +257,15 @@ class SmartyParser extends Smarty implements ParserInterface
|
||||
|
||||
foreach ($plugins as $plugin) {
|
||||
$this->registerPlugin(
|
||||
$plugin->getType(),
|
||||
$plugin->getName(),
|
||||
array(
|
||||
$plugin->getClass(),
|
||||
$plugin->getMethod()
|
||||
)
|
||||
$plugin->getType(),
|
||||
$plugin->getName(),
|
||||
array(
|
||||
$plugin->getClass(),
|
||||
$plugin->getMethod()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
@@ -17,7 +17,7 @@
|
||||
/* 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/>. */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
@@ -35,13 +35,6 @@ class TemplateDefinition
|
||||
const PDF_SUBDIR = 'pdf/';
|
||||
const EMAIL_SUBDIR = 'email/';
|
||||
|
||||
protected static $standardTemplatesSubdirs = array(
|
||||
self::FRONT_OFFICE => self::FRONT_OFFICE_SUBDIR,
|
||||
self::BACK_OFFICE => self::BACK_OFFICE_SUBDIR,
|
||||
self::PDF => self::PDF_SUBDIR,
|
||||
self::EMAIL => self::EMAIL_SUBDIR,
|
||||
);
|
||||
|
||||
/**
|
||||
* @var the template directory name (e.g. 'default')
|
||||
*/
|
||||
@@ -57,13 +50,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 +82,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 +101,8 @@ class TemplateDefinition
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
public function getAbsolutePath() {
|
||||
public function getAbsolutePath()
|
||||
{
|
||||
return THELIA_TEMPLATE_DIR . $this->getPath();
|
||||
}
|
||||
|
||||
@@ -115,13 +111,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 +131,7 @@ class TemplateDefinition
|
||||
public function setType($type)
|
||||
{
|
||||
$this->type = $type;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an iterator on the standard templates subdir names
|
||||
*/
|
||||
public static function getStandardTemplatesSubdirsIterator() {
|
||||
return new \ArrayIterator(self::$standardTemplatesSubdirs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,16 +40,17 @@ class TemplateHelper
|
||||
|
||||
private function __construct() {}
|
||||
|
||||
public static function getInstance() {
|
||||
public static function getInstance()
|
||||
{
|
||||
if (self::$instance == null) self::$instance = new TemplateHelper();
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TemplateDefinition
|
||||
*/
|
||||
public function getActiveMailTemplate() {
|
||||
public function getActiveMailTemplate()
|
||||
{
|
||||
return new TemplateDefinition(
|
||||
ConfigQuery::read('active-mail-template', 'default'),
|
||||
TemplateDefinition::EMAIL
|
||||
@@ -59,7 +60,8 @@ class TemplateHelper
|
||||
/**
|
||||
* @return TemplateDefinition
|
||||
*/
|
||||
public function getActivePdfTemplate() {
|
||||
public function getActivePdfTemplate()
|
||||
{
|
||||
return new TemplateDefinition(
|
||||
ConfigQuery::read('active-pdf-template', 'default'),
|
||||
TemplateDefinition::PDF
|
||||
@@ -69,7 +71,8 @@ class TemplateHelper
|
||||
/**
|
||||
* @return TemplateDefinition
|
||||
*/
|
||||
public function getActiveAdminTemplate() {
|
||||
public function getActiveAdminTemplate()
|
||||
{
|
||||
return new TemplateDefinition(
|
||||
ConfigQuery::read('active-admin-template', 'default'),
|
||||
TemplateDefinition::BACK_OFFICE
|
||||
@@ -79,13 +82,15 @@ class TemplateHelper
|
||||
/**
|
||||
* @return TemplateDefinition
|
||||
*/
|
||||
public function getActiveFrontTemplate() {
|
||||
public function getActiveFrontTemplate()
|
||||
{
|
||||
return new TemplateDefinition(
|
||||
ConfigQuery::read('active-front-template', 'default'),
|
||||
TemplateDefinition::FRONT_OFFICE
|
||||
);
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
/**
|
||||
* Returns an array which contains all standard template definitions
|
||||
*/
|
||||
@@ -109,6 +114,18 @@ class TemplateHelper
|
||||
$list = $exclude = array();
|
||||
|
||||
$tplIterator = TemplateDefinition::getStandardTemplatesSubdirsIterator();
|
||||
=======
|
||||
public function getList($templateType)
|
||||
{
|
||||
$list = $exclude = array();
|
||||
|
||||
if ($templateType == TemplateDefinition::BACK_OFFICE) {
|
||||
$baseDir = THELIA_TEMPLATE_DIR.TemplateDefinition::BACK_OFFICE_SUBDIR;
|
||||
} elseif ($templateType == TemplateDefinition::PDF) {
|
||||
$baseDir = THELIA_TEMPLATE_DIR.TemplateDefinition::PDF_SUBDIR;
|
||||
} else {
|
||||
$baseDir = THELIA_TEMPLATE_DIR.TemplateDefinition::FRONT_OFFICE_SUBDIR;
|
||||
>>>>>>> cleanmaster
|
||||
|
||||
foreach($tplIterator as $type => $subdir) {
|
||||
|
||||
@@ -134,7 +151,6 @@ class TemplateHelper
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function normalize_path($path)
|
||||
{
|
||||
$path = str_replace(
|
||||
@@ -155,28 +171,27 @@ class TemplateHelper
|
||||
* 'translation' => the text translation, or an empty string if none available.
|
||||
* 'dollar' => true if the translatable text contains a $
|
||||
*
|
||||
* @param string $directory the path to the directory to examine
|
||||
* @param string $walkMode type of file scanning: WALK_MODE_PHP or WALK_MODE_TEMPLATE
|
||||
* @param \Thelia\Core\Translation\Translator $translator the current translator
|
||||
* @param string $currentLocale the current locale
|
||||
* @param array $strings the list of strings
|
||||
* @throws \InvalidArgumentException if $walkMode contains an invalid value
|
||||
* @return number the total number of translatable texts
|
||||
* @param string $directory the path to the directory to examine
|
||||
* @param string $walkMode type of file scanning: WALK_MODE_PHP or WALK_MODE_TEMPLATE
|
||||
* @param \Thelia\Core\Translation\Translator $translator the current translator
|
||||
* @param string $currentLocale the current locale
|
||||
* @param array $strings the list of strings
|
||||
* @throws \InvalidArgumentException if $walkMode contains an invalid value
|
||||
* @return number the total number of translatable texts
|
||||
*/
|
||||
public function walkDir($directory, $walkMode, Translator $translator, $currentLocale, &$strings) {
|
||||
|
||||
public function walkDir($directory, $walkMode, Translator $translator, $currentLocale, &$strings)
|
||||
{
|
||||
$num_texts = 0;
|
||||
|
||||
if ($walkMode == self::WALK_MODE_PHP) {
|
||||
$prefix = '\-\>[\s]*trans[\s]*\(';
|
||||
|
||||
$allowed_exts = array('php');
|
||||
} else if ($walkMode == self::WALK_MODE_TEMPLATE) {
|
||||
} elseif ($walkMode == self::WALK_MODE_TEMPLATE) {
|
||||
$prefix = '\{intl[\s]l=';
|
||||
|
||||
$allowed_exts = array('html', 'tpl', 'xml');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw new \InvalidArgumentException(
|
||||
Translator::getInstance()->trans('Invalid value for walkMode parameter: %value', array('%value' => $walkMode))
|
||||
);
|
||||
@@ -210,18 +225,15 @@ class TemplateHelper
|
||||
|
||||
Tlog::getInstance()->debug("Strings found: ", $matches[2]);
|
||||
|
||||
foreach($matches[2] as $match) {
|
||||
foreach ($matches[2] as $match) {
|
||||
|
||||
$hash = md5($match);
|
||||
|
||||
if (isset($strings[$hash]))
|
||||
{
|
||||
if (! in_array($short_path, $strings[$hash]['files']))
|
||||
{
|
||||
if (isset($strings[$hash])) {
|
||||
if (! in_array($short_path, $strings[$hash]['files'])) {
|
||||
$strings[$hash]['files'][] = $short_path;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$num_texts++;
|
||||
|
||||
// remove \'
|
||||
@@ -273,9 +285,7 @@ class TemplateHelper
|
||||
fwrite($fp, ");\n");
|
||||
|
||||
@fclose($fp);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
throw new \RuntimeException(
|
||||
Translator::getInstance()->trans(
|
||||
'Failed to open translation file %file. Please be sure that this file is writable by your Web server',
|
||||
|
||||
@@ -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;
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -198,6 +197,11 @@ class Thelia extends Kernel
|
||||
$definition
|
||||
);
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
$code = ucfirst($module->getCode());
|
||||
|
||||
>>>>>>> cleanmaster
|
||||
$loader = new XmlFileLoader($container, new FileLocator($module->getAbsoluteConfigPath()));
|
||||
$loader->load("config.xml");
|
||||
|
||||
|
||||
@@ -215,7 +215,7 @@ class TheliaHttpKernel extends HttpKernel
|
||||
|
||||
protected function initSession(Request $request)
|
||||
{
|
||||
if(null === self::$session) {
|
||||
if (null === self::$session) {
|
||||
$storage = new Session\Storage\NativeSessionStorage();
|
||||
|
||||
if (Model\ConfigQuery::read("session_config.default")) {
|
||||
|
||||
@@ -40,7 +40,7 @@ class Translator extends BaseTranslator
|
||||
|
||||
public function getLocale()
|
||||
{
|
||||
if($this->container->isScopeActive('request') && $this->container->has('request')) {
|
||||
if ($this->container->isScopeActive('request') && $this->container->has('request')) {
|
||||
return $this->container->get('request')->getSession()->getLang()->getLocale();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user