Merge branch 'master' of https://github.com/thelia/thelia
Conflicts: templates/admin/default/currencies.html
This commit is contained in:
@@ -106,17 +106,50 @@ class AsseticHelper
|
||||
|
||||
$factory->setDebug($debug);
|
||||
|
||||
$factory->addWorker(new CacheBustingWorker());
|
||||
$factory->addWorker(new CacheBustingWorker('-'));
|
||||
|
||||
// Prepare the assets writer
|
||||
$writer = new AssetWriter($output_path);
|
||||
// We do not pass the filter list here, juste to get the asset file name
|
||||
$asset = $factory->createAsset($asset_name);
|
||||
|
||||
$asset = $factory->createAsset($asset_name, $filter_list);
|
||||
$asset_target_path = $asset->getTargetPath();
|
||||
$target_file = sprintf("%s/%s", $output_path, $asset_target_path);
|
||||
|
||||
$cache = new AssetCache($asset, new FilesystemCache($output_path));
|
||||
// As it seems that assetic cannot handle a real file cache, let's do the job ourselves.
|
||||
// It works only if the CacheBustingWorker is used, as a new file name is generated for each version.
|
||||
//
|
||||
// the previous version of the file is deleted, by getting the first part of the ouput file name
|
||||
// (the one before '-'), and delete aby file beginning with the same string. Example:
|
||||
// old name: 3bc974a-dfacc1f.css
|
||||
// new name: 3bc974a-ad3ef47.css
|
||||
//
|
||||
// before generating 3bc974a-ad3ef47.css, delete 3bc974a-* files.
|
||||
//
|
||||
if (! file_exists($target_file)) {
|
||||
|
||||
$writer->writeAsset($cache);
|
||||
// Delete previous version of the file
|
||||
list($commonPart, $dummy) = explode('-', $asset_target_path);
|
||||
|
||||
return rtrim($output_url, '/').'/'.$asset->getTargetPath();
|
||||
foreach (glob("$output_path/$commonPart-*") as $filename) {
|
||||
@unlink($filename);
|
||||
}
|
||||
|
||||
// Apply filters now
|
||||
foreach ($filter_list as $filter) {
|
||||
if ('?' != $filter[0]) {
|
||||
$asset->ensureFilter($fm->get($filter));
|
||||
}
|
||||
elseif (!$debug) {
|
||||
$asset->ensureFilter($fm->get(substr($filter, 1)));
|
||||
}
|
||||
}
|
||||
|
||||
//$cache = new AssetCache($asset, new FilesystemCache($output_path));
|
||||
|
||||
$writer = new AssetWriter($output_path);
|
||||
|
||||
$writer->writeAsset($asset);
|
||||
}
|
||||
|
||||
return rtrim($output_url, '/').'/'.$asset_target_path;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,10 +71,12 @@ class Cart extends BaseLoop
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
$cartItems = $cart->getCartItems();
|
||||
|
||||
$result = new LoopResult($cartItems);
|
||||
|
||||
|
||||
$cart = $this->getCart($this->request);
|
||||
$cartItems = $cart->getCartItems();
|
||||
$result = new LoopResult($cartItems);
|
||||
|
||||
if ($cart === null) {
|
||||
return $result;
|
||||
|
||||
@@ -123,6 +123,7 @@ class Form extends AbstractSmartyPlugin
|
||||
$template->assign("name", $formFieldView->vars["full_name"]);
|
||||
$template->assign("value", $formFieldView->vars["value"]);
|
||||
$template->assign("label", $formFieldView->vars["label"]);
|
||||
$template->assign("label_attr", $formFieldView->vars["label_attr"]);
|
||||
|
||||
$errors = $formFieldView->vars["errors"];
|
||||
|
||||
|
||||
@@ -67,6 +67,10 @@ class CartAdd extends BaseForm
|
||||
new Constraints\Callback(array("methods" => array(
|
||||
array($this, "checkProduct")
|
||||
)))
|
||||
),
|
||||
"label" => "product",
|
||||
"label_attr" => array(
|
||||
"for" => "cart_product"
|
||||
)
|
||||
))
|
||||
->add("product_sale_elements_id", "text", array(
|
||||
|
||||
@@ -40,11 +40,47 @@ class CurrencyCreationForm extends BaseForm
|
||||
}
|
||||
|
||||
$this->formBuilder
|
||||
->add("name" , "text" , array("constraints" => array(new NotBlank())))
|
||||
->add("locale" , "text" , array("constraints" => array(new NotBlank())))
|
||||
->add("symbol" , "text" , array("constraints" => array(new NotBlank())))
|
||||
->add("rate" , "text" , array("constraints" => array(new NotBlank())))
|
||||
->add("code" , "text" , array("constraints" => $code_constraints))
|
||||
->add("name" , "text" , array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => "Name *",
|
||||
"label_attr" => array(
|
||||
"for" => "name"
|
||||
))
|
||||
)
|
||||
->add("locale" , "text" , array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
))
|
||||
)
|
||||
->add("symbol" , "text" , array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => "Symbol *",
|
||||
"label_attr" => array(
|
||||
"for" => "symbol"
|
||||
))
|
||||
)
|
||||
->add("rate" , "text" , array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => "Rate from € *",
|
||||
"label_attr" => array(
|
||||
"for" => "rate"
|
||||
))
|
||||
)
|
||||
->add("code" , "text" , array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => "ISO 4217 code *",
|
||||
"label_attr" => array(
|
||||
"for" => "iso_4217_code"
|
||||
))
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,9 @@ class Currency extends BaseCurrency {
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_CREATECURRENCY, new CurrencyEvent($this));
|
||||
|
||||
// Set the current position for the new object
|
||||
$this->setPosition($this->getNextPosition());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,15 +49,15 @@ trait PositionManagementTrait {
|
||||
/**
|
||||
* Get the position of the next inserted object
|
||||
*/
|
||||
public function getNextPosition($parent) {
|
||||
public function getNextPosition($parent = null) {
|
||||
|
||||
$last = $this->createQuery()
|
||||
$query = $this->createQuery()
|
||||
->orderByPosition(Criteria::DESC)
|
||||
->limit(1);
|
||||
|
||||
if ($parent !== null) $last->filterByParent($parent);
|
||||
|
||||
$last->findOne()
|
||||
$last = $query->findOne()
|
||||
;
|
||||
|
||||
return $last != null ? $last->getPosition() + 1 : 1;
|
||||
@@ -107,11 +107,7 @@ trait PositionManagementTrait {
|
||||
// If we found the proper object, exchange their positions
|
||||
if ($result) {
|
||||
|
||||
// Find DATABASE_NAME constant
|
||||
$mapClassName = self::TABLE_MAP;
|
||||
$database_name = $mapClassName::DATABASE_NAME;
|
||||
|
||||
$cnx = Propel::getWriteConnection($database_name);
|
||||
$cnx = Propel::getWriteConnection($this->getDatabaseName());
|
||||
|
||||
$cnx->beginTransaction();
|
||||
|
||||
@@ -130,6 +126,16 @@ trait PositionManagementTrait {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Simply return the database name, from the constant in the MAP class.
|
||||
*/
|
||||
protected function getDatabaseName() {
|
||||
// Find DATABASE_NAME constant
|
||||
$mapClassName = self::TABLE_MAP;
|
||||
|
||||
return $mapClassName::DATABASE_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes object position
|
||||
*
|
||||
@@ -161,7 +167,7 @@ trait PositionManagementTrait {
|
||||
|
||||
$results = $search->find();
|
||||
|
||||
$cnx = Propel::getWriteConnection(CategoryTableMap::DATABASE_NAME);
|
||||
$cnx = Propel::getWriteConnection($this->getDatabaseName());
|
||||
|
||||
$cnx->beginTransaction();
|
||||
|
||||
|
||||
@@ -59,6 +59,17 @@ class ImageTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$container->set("request", $request);
|
||||
|
||||
$router = $this->getMock("Symfony\Component\Routing\Router");
|
||||
$container->set("router.admin", $router);
|
||||
|
||||
$context = $this->getMock("Symfony\Component\Routing\RequestContext");
|
||||
$context->setHost('localhost');
|
||||
$context->setPort(80);
|
||||
$context->setScheme('http');
|
||||
$context->getBaseUrl('/tagada/tsointsoin/');
|
||||
|
||||
$router->setContext($context);
|
||||
|
||||
return $container;
|
||||
}
|
||||
|
||||
|
||||
@@ -79,37 +79,7 @@ class URL
|
||||
*/
|
||||
public function getBaseUrl()
|
||||
{
|
||||
/*
|
||||
$request = $this->container->get('request');
|
||||
$lang = $request->getSession()->getLang();
|
||||
|
||||
// Check if we have a specific URL for each lang.
|
||||
$one_domain_foreach_lang = ConfigQuery::read("one_domain_foreach_lang", false);
|
||||
|
||||
if ($one_domain_foreach_lang == true) {
|
||||
// If it's the case, get the current lang URL
|
||||
$base_url = $lang->getUrl();
|
||||
|
||||
$err_msg_part = 'base_url';
|
||||
}
|
||||
else {
|
||||
// Get the base URL
|
||||
$base_url = ConfigQuery::read('base_url', $request->getSchemeAndHttpHost());
|
||||
|
||||
$err_msg_part = sprintf('base_url for lang %s', $lang->getCode());
|
||||
}
|
||||
|
||||
// Be sure that base-url starts with http, give up if it's not the case.
|
||||
if (substr($base_url, 0, 4) != 'http') {
|
||||
throw new \InvalidArgumentException(
|
||||
sprintf("The %s configuration parameter shoud contains the URL of your shop, starting with http or https.", $err_msg_part));
|
||||
}
|
||||
|
||||
// Normalize the base_url
|
||||
return rtrim($base_url, '/').'/';
|
||||
*/
|
||||
|
||||
$requestContext = $this->container->get('router.admin')->getGenerator()->getContext();
|
||||
$requestContext = $this->container->get('router.admin')->getContext();
|
||||
|
||||
if ($host = $requestContext->getHost()) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user