diff --git a/core/lib/Thelia/Core/Template/Assets/AsseticHelper.php b/core/lib/Thelia/Core/Template/Assets/AsseticHelper.php index c5995e3de..fbb93440a 100755 --- a/core/lib/Thelia/Core/Template/Assets/AsseticHelper.php +++ b/core/lib/Thelia/Core/Template/Assets/AsseticHelper.php @@ -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; } } diff --git a/core/lib/Thelia/Core/Template/Loop/Cart.php b/core/lib/Thelia/Core/Template/Loop/Cart.php index f9e5c00aa..8e4d78683 100755 --- a/core/lib/Thelia/Core/Template/Loop/Cart.php +++ b/core/lib/Thelia/Core/Template/Loop/Cart.php @@ -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; diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php index 554d3f9de..0b22111cd 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php @@ -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"]; diff --git a/core/lib/Thelia/Form/CartAdd.php b/core/lib/Thelia/Form/CartAdd.php index fb6347cd9..25bde3cdc 100755 --- a/core/lib/Thelia/Form/CartAdd.php +++ b/core/lib/Thelia/Form/CartAdd.php @@ -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( diff --git a/core/lib/Thelia/Form/CurrencyCreationForm.php b/core/lib/Thelia/Form/CurrencyCreationForm.php index a4d858ed6..3328cd342 100644 --- a/core/lib/Thelia/Form/CurrencyCreationForm.php +++ b/core/lib/Thelia/Form/CurrencyCreationForm.php @@ -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" + )) + ) ; } diff --git a/core/lib/Thelia/Model/Currency.php b/core/lib/Thelia/Model/Currency.php index 20c36782d..ef8d73735 100755 --- a/core/lib/Thelia/Model/Currency.php +++ b/core/lib/Thelia/Model/Currency.php @@ -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; } diff --git a/core/lib/Thelia/Model/Tools/PositionManagementTrait.php b/core/lib/Thelia/Model/Tools/PositionManagementTrait.php index 3261f42ec..9e0b1f35c 100644 --- a/core/lib/Thelia/Model/Tools/PositionManagementTrait.php +++ b/core/lib/Thelia/Model/Tools/PositionManagementTrait.php @@ -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(); diff --git a/core/lib/Thelia/Tests/Action/ImageTest.php b/core/lib/Thelia/Tests/Action/ImageTest.php index 526f7cb86..808a246f6 100755 --- a/core/lib/Thelia/Tests/Action/ImageTest.php +++ b/core/lib/Thelia/Tests/Action/ImageTest.php @@ -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; } diff --git a/core/lib/Thelia/Tools/URL.php b/core/lib/Thelia/Tools/URL.php index ae8dcbb26..777e4543c 100755 --- a/core/lib/Thelia/Tools/URL.php +++ b/core/lib/Thelia/Tools/URL.php @@ -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()) { diff --git a/templates/admin/default/admin-layout.tpl b/templates/admin/default/admin-layout.tpl index 8bef5c011..3752c355b 100644 --- a/templates/admin/default/admin-layout.tpl +++ b/templates/admin/default/admin-layout.tpl @@ -210,9 +210,7 @@ {block name="before-javascript-include"}{/block} - {javascripts file='assets/js/jquery.min.js'} - - {/javascripts} + {block name="after-javascript-include"}{/block} diff --git a/templates/admin/default/assets/less/main.less b/templates/admin/default/assets/less/main.less index 7ad14e013..862810f6d 100644 --- a/templates/admin/default/assets/less/main.less +++ b/templates/admin/default/assets/less/main.less @@ -3,4 +3,6 @@ /* Thelia Admin */ @import "thelia/thelia.less"; -// @import "thelia/responsive.less"; \ No newline at end of file +// @import "thelia/responsive.less"; + +//mmm \ No newline at end of file diff --git a/templates/admin/default/categories.html b/templates/admin/default/categories.html index fdf2ab093..e3f3e9fde 100755 --- a/templates/admin/default/categories.html +++ b/templates/admin/default/categories.html @@ -4,12 +4,6 @@ {block name="check-permissions"}admin.catalog.view{/block} -{block name="after-admin-css"} - {stylesheets file='assets/bootstrap-editable/css/bootstrap-editable.css' filters='cssembed'} - - {/stylesheets} -{/block} - {block name="main-content"}