Conflicts:
	templates/admin/default/currencies.html
This commit is contained in:
franck
2013-09-05 23:30:50 +02:00
15 changed files with 167 additions and 116 deletions

View File

@@ -106,17 +106,50 @@ class AsseticHelper
$factory->setDebug($debug); $factory->setDebug($debug);
$factory->addWorker(new CacheBustingWorker()); $factory->addWorker(new CacheBustingWorker('-'));
// Prepare the assets writer // We do not pass the filter list here, juste to get the asset file name
$writer = new AssetWriter($output_path); $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;
} }
} }

View File

@@ -71,10 +71,12 @@ class Cart extends BaseLoop
*/ */
public function exec(&$pagination) public function exec(&$pagination)
{ {
$cartItems = $cart->getCartItems();
$result = new LoopResult($cartItems);
$cart = $this->getCart($this->request); $cart = $this->getCart($this->request);
$cartItems = $cart->getCartItems();
$result = new LoopResult($cartItems);
if ($cart === null) { if ($cart === null) {
return $result; return $result;

View File

@@ -123,6 +123,7 @@ class Form extends AbstractSmartyPlugin
$template->assign("name", $formFieldView->vars["full_name"]); $template->assign("name", $formFieldView->vars["full_name"]);
$template->assign("value", $formFieldView->vars["value"]); $template->assign("value", $formFieldView->vars["value"]);
$template->assign("label", $formFieldView->vars["label"]); $template->assign("label", $formFieldView->vars["label"]);
$template->assign("label_attr", $formFieldView->vars["label_attr"]);
$errors = $formFieldView->vars["errors"]; $errors = $formFieldView->vars["errors"];

View File

@@ -67,6 +67,10 @@ class CartAdd extends BaseForm
new Constraints\Callback(array("methods" => array( new Constraints\Callback(array("methods" => array(
array($this, "checkProduct") array($this, "checkProduct")
))) )))
),
"label" => "product",
"label_attr" => array(
"for" => "cart_product"
) )
)) ))
->add("product_sale_elements_id", "text", array( ->add("product_sale_elements_id", "text", array(

View File

@@ -40,11 +40,47 @@ class CurrencyCreationForm extends BaseForm
} }
$this->formBuilder $this->formBuilder
->add("name" , "text" , array("constraints" => array(new NotBlank()))) ->add("name" , "text" , array(
->add("locale" , "text" , array("constraints" => array(new NotBlank()))) "constraints" => array(
->add("symbol" , "text" , array("constraints" => array(new NotBlank()))) new NotBlank()
->add("rate" , "text" , array("constraints" => array(new NotBlank()))) ),
->add("code" , "text" , array("constraints" => $code_constraints)) "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"
))
)
; ;
} }

View File

@@ -20,6 +20,9 @@ class Currency extends BaseCurrency {
{ {
$this->dispatchEvent(TheliaEvents::BEFORE_CREATECURRENCY, new CurrencyEvent($this)); $this->dispatchEvent(TheliaEvents::BEFORE_CREATECURRENCY, new CurrencyEvent($this));
// Set the current position for the new object
$this->setPosition($this->getNextPosition());
return true; return true;
} }

View File

@@ -49,15 +49,15 @@ trait PositionManagementTrait {
/** /**
* Get the position of the next inserted object * 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) ->orderByPosition(Criteria::DESC)
->limit(1); ->limit(1);
if ($parent !== null) $last->filterByParent($parent); if ($parent !== null) $last->filterByParent($parent);
$last->findOne() $last = $query->findOne()
; ;
return $last != null ? $last->getPosition() + 1 : 1; return $last != null ? $last->getPosition() + 1 : 1;
@@ -107,11 +107,7 @@ trait PositionManagementTrait {
// If we found the proper object, exchange their positions // If we found the proper object, exchange their positions
if ($result) { if ($result) {
// Find DATABASE_NAME constant $cnx = Propel::getWriteConnection($this->getDatabaseName());
$mapClassName = self::TABLE_MAP;
$database_name = $mapClassName::DATABASE_NAME;
$cnx = Propel::getWriteConnection($database_name);
$cnx->beginTransaction(); $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 * Changes object position
* *
@@ -161,7 +167,7 @@ trait PositionManagementTrait {
$results = $search->find(); $results = $search->find();
$cnx = Propel::getWriteConnection(CategoryTableMap::DATABASE_NAME); $cnx = Propel::getWriteConnection($this->getDatabaseName());
$cnx->beginTransaction(); $cnx->beginTransaction();

View File

@@ -59,6 +59,17 @@ class ImageTest extends \PHPUnit_Framework_TestCase
$container->set("request", $request); $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; return $container;
} }

View File

@@ -79,37 +79,7 @@ class URL
*/ */
public function getBaseUrl() public function getBaseUrl()
{ {
/* $requestContext = $this->container->get('router.admin')->getContext();
$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();
if ($host = $requestContext->getHost()) { if ($host = $requestContext->getHost()) {

View File

@@ -210,9 +210,7 @@
{block name="before-javascript-include"}{/block} {block name="before-javascript-include"}{/block}
{javascripts file='assets/js/jquery.min.js'} <script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
<script src="{$asset_url}"></script>
{/javascripts}
{block name="after-javascript-include"}{/block} {block name="after-javascript-include"}{/block}

View File

@@ -3,4 +3,6 @@
/* Thelia Admin */ /* Thelia Admin */
@import "thelia/thelia.less"; @import "thelia/thelia.less";
// @import "thelia/responsive.less"; // @import "thelia/responsive.less";
//mmm

View File

@@ -4,12 +4,6 @@
{block name="check-permissions"}admin.catalog.view{/block} {block name="check-permissions"}admin.catalog.view{/block}
{block name="after-admin-css"}
{stylesheets file='assets/bootstrap-editable/css/bootstrap-editable.css' filters='cssembed'}
<link rel="stylesheet" href="{$asset_url}">
{/stylesheets}
{/block}
{block name="main-content"} {block name="main-content"}
<div class="catalog"> <div class="catalog">
<div id="wrapper" class="container"> <div id="wrapper" class="container">
@@ -278,13 +272,11 @@
{include file="includes/delete-category-dialog.html"} {include file="includes/delete-category-dialog.html"}
{/block} {/block}
{block name="after-javascript-include"} {block name="javascript-initialization"}
{javascripts file='assets/bootstrap-editable/js/bootstrap-editable.js'} {javascripts file='assets/js/bootstrap-editable/bootstrap-editable.js'}
<script src="{$asset_url}"></script> <script src="{$asset_url}"></script>
{/javascripts} {/javascripts}
{/block}
{block name="javascript-initialization"}
<script> <script>
$(function() { $(function() {

View File

@@ -217,18 +217,21 @@
<input type="hidden" name="{$name}" value="{url path='/admin/configuration/currencies/update' currency_id='_ID_'}" /> <input type="hidden" name="{$name}" value="{url path='/admin/configuration/currencies/update' currency_id='_ID_'}" />
{/form_field} {/form_field}
{* We do not allow users to create secured currencies from here *}
<div class="modal-body"> <div class="modal-body">
{if $form_error}<div class="alert alert-block alert-error" id="add_currency_dialog_error">{$form_error_message}</div>{/if} {if $form_error}<div class="alert alert-block alert-error" id="add_currency_dialog_error">{$form_error_message}</div>{/if}
{form_field form=$form field='name'} {form_field form=$form field='name'}
<div class="form-group {if $error}has-error{/if}"> <div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<label>{intl l='Name *'}</label>
{loop type="lang" name="default-lang" default_only="1"} {loop type="lang" name="default-lang" default_only="1"}
<div class="input-group">
<input type="text" id="{$label_attr.for}" required="required" name="{$name}" class="form-control" value="{$value}" title="{intl l='Currency name'}" placeholder="{intl l='Name'}">
<span class="input-group-addon"><img src="{image file="assets/img/flags/{$CODE}.gif"}" alt="{intl l=$TITLE}" /></span>
</div>
<div class="help-block">{intl l="Enter here the currency name in the default language ($TITLE)"}</div>
{* Switch edition to the current locale *} {* Switch edition to the current locale *}
<input type="hidden" name="edit_language_id" value="{$ID}" /> <input type="hidden" name="edit_language_id" value="{$ID}" />
@@ -236,39 +239,29 @@
{form_field form=$form field='locale'} {form_field form=$form field='locale'}
<input type="hidden" name="{$name}" value="{$LOCALE}" /> <input type="hidden" name="{$name}" value="{$LOCALE}" />
{/form_field} {/form_field}
{form_field form=$form field='name'}
<div class="input-group">
<input type="text" required="required" name="{$name}" class="form-control" value="{$value}" title="{intl l='Currency name'}" placeholder="{intl l='Name'}">
<span class="input-group-addon"><img src="{image file="assets/img/flags/{$CODE}.gif"}" alt="{intl l=$TITLE}" /></span>
</div>
{/form_field}
<div class="help-block">{intl l="Enter here the currency name in the default language ($TITLE)"}</div>
{/loop} {/loop}
</div> </div>
{/form_field} {/form_field}
{form_field form=$form field='code'} {form_field form=$form field='code'}
<div class="form-group {if $error}has-error{/if}"> <div class="form-group {if $error}has-error{/if}">
<label class="control-label">{intl l='ISO 4217 code *'}</label> <label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" required="required" name="{$name}" class="form-control" value="{$value}" title="{intl l='ISO 4217 code'}" placeholder="{intl l='Code'}"> <input type="text" id="{$label_attr.for}" required="required" name="{$name}" class="form-control" value="{$value}" title="{intl l='ISO 4217 code'}" placeholder="{intl l='Code'}">
<span class="help-block"><a href="http://fr.wikipedia.org/wiki/ISO_4217" target="_blank">{intl l='More information about ISO 4217'}</a></span> <span class="help-block"><a href="http://fr.wikipedia.org/wiki/ISO_4217" target="_blank">{intl l='More information about ISO 4217'}</a></span>
</div> </div>
{/form_field} {/form_field}
{form_field form=$form field='symbol'} {form_field form=$form field='symbol'}
<div class="form-group {if $error}has-error{/if}"> <div class="form-group {if $error}has-error{/if}">
<label class="control-label">{intl l='Symbol *'}</label> <label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" required="required" name="{$name}" class="form-control" value="{$value}" title="{intl l='Currency symbol'}" placeholder="{intl l='Symbol'}"> <input type="text" id="{$label_attr.for}" required="required" name="{$name}" class="form-control" value="{$value}" title="{intl l='Currency symbol'}" placeholder="{intl l='Symbol'}">
</div> </div>
{/form_field} {/form_field}
{form_field form=$form field='rate'} {form_field form=$form field='rate'}
<div class="form-group {if $error}has-error{/if}"> <div class="form-group {if $error}has-error{/if}">
<label class="control-label">{intl l='Rate *'}</label> <label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" required="required" name="{$name}" class="form-control" value="{$value}" title="{intl l='Currency rate'}" placeholder="{intl l='Rate'}"> <input type="text" id="{$label_attr.for}" required="required" name="{$name}" class="form-control" value="{$value}" title="{intl l='Currency rate'}" placeholder="{intl l='Rate'}">
<span class="help-block">{intl l="The rate from Euro (Price in Euro * rate = Price in this currency)"}</span> <span class="help-block">{intl l="The rate from Euro (Price in Euro * rate = Price in this currency)"}</span>
</div> </div>
{/form_field} {/form_field}

View File

@@ -28,10 +28,10 @@
<div class="form-container"> <div class="form-container">
<div class="col-md-12"> <div class="col-md-12">
{form name="thelia.admin.currency.modification"} {form name="thelia.admin.currency.modification"}
<form method="POST" action="{url path='/admin/configuration/currencies/save'}" {form_enctype form=$form} class="clearfix"> <form method="POST" action="{url path='/admin/configuration/currencies/save'}" {form_enctype form=$form} class="clearfix">
{* Be sure to get the currency ID, even if the form could not be validated *} {* Be sure to get the currency ID, even if the form could not be validated *}
<input type="hidden" name="currency_id" value="{$currency_id}" /> <input type="hidden" name="currency_id" value="{$currency_id}" />
@@ -47,26 +47,27 @@
<input type="hidden" name="{$name}" value="{$edit_language_locale}" /> <input type="hidden" name="{$name}" value="{$edit_language_locale}" />
{/form_field} {/form_field}
{if $form_error}<div class="alert alert-block alert-error">{$form_error_message}</div>{/if} {if $form_error}<div class="alert alert-danger">{$form_error_message}</div>{/if}
<div class="col-md-6"> <div class="col-md-6">
{form_field form=$form field='name'} {form_field form=$form field='name'}
<div class="form-group {if $error}has-error{/if}"> <div class="form-group {if $error}has-error{/if}">
<label>{intl l='Name *'}</label> <label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" required="required" name="{$name}" value="{$value|htmlspecialchars}" title="{intl l='Currency name'}" placeholder="{intl l='Currency name'}" class="form-control"> <input type="text" id="{$label_attr.for}" required="required" name="{$name}" value="{$value|htmlspecialchars}" title="{intl l='Currency name'}" placeholder="{intl l='Currency name'}" class="form-control">
<span class="help-block">&nbsp;</span>
</div> </div>
{/form_field} {/form_field}
{form_field form=$form field='code'} {form_field form=$form field='code'}
<div class="form-group {if $error}has-error{/if}"> <div class="form-group {if $error}has-error{/if}">
<label> <label for="{$label_attr.for}" class="control-label">
{intl l='ISO 4217 Code *'} {intl l="{$label}"} :
<span class="label-help-block">
<a title="{intl l='More information about ISO 4217'}" href="http://fr.wikipedia.org/wiki/ISO_4217" target="_blank">List of ISO 4217 code</a>
</span>
</label> </label>
<input type="text" required="required" name="{$name}" value="{$value|htmlspecialchars}" title="{intl l='Currency ISO 4217 Code'}" placeholder="{intl l='Code'}" class="form-control"> <input type="text" id="{$label_attr.for}" required="required" name="{$name}" value="{$value|htmlspecialchars}" title="{intl l='Currency ISO 4217 Code'}" placeholder="{intl l='Code'}" class="form-control">
<span class="help-block">
<a title="{intl l='More information about ISO 4217'}" href="http://fr.wikipedia.org/wiki/ISO_4217" target="_blank">List of ISO 4217 code</a>
</span>
</div> </div>
{/form_field} {/form_field}
@@ -76,27 +77,26 @@
{form_field form=$form field='symbol'} {form_field form=$form field='symbol'}
<div class="form-group {if $error}has-error{/if}"> <div class="form-group {if $error}has-error{/if}">
<label> <label for="{$label_attr.for}" class="control-label">
{intl l='Symbol *'} {intl l="{$label}"} :
<span class="label-help-block">The symbol, sur as $, £, &euro;...</span>
</label> </label>
<input type="text" required="required" name="{$name}" value="{$value|htmlspecialchars}" title="{intl l='Currency symbol'}" placeholder="{intl l='Symbol'}" class="form-control"> <input type="text" id="{$label_attr.for}" required="required" name="{$name}" value="{$value|htmlspecialchars}" title="{intl l='Currency symbol'}" placeholder="{intl l='Symbol'}" class="form-control">
<span class="help-block">{intl l='The symbol, such as $, £, &euro;...'}</span>
</div> </div>
{/form_field} {/form_field}
{form_field form=$form field='rate'} {form_field form=$form field='rate'}
<div class="form-group {if $error}has-error{/if}"> <div class="form-group {if $error}has-error{/if}">
<label> <label for="{$label_attr.for}" class="control-label">
{intl l='Rate from &euro; *'} {intl l="{$label}"} :
<span class="label-help-block">The rate from Euro</span> </label>
</label> <input type="text" id="{$label_attr.for}" required="required" name="{$name}" value="{$value|htmlspecialchars}" title="{intl l='Rate from Euro'}" placeholder="{intl l='Rate'}" class="form-control">
<input type="text" required="required" name="{$name}" value="{$value|htmlspecialchars}" title="{intl l='Rate from Euro'}" placeholder="{intl l='Rate'}" class="form-control"> <span class="help-block">The rate from Euro: Price in Euro x rate = Price in this currency</span>
<span class="help-block">Price in Euro x rate = Price in this currency</span>
</div> </div>
{/form_field} {/form_field}
</div> </div>
</form> </form>
{/form} {/form}

View File

@@ -24,7 +24,7 @@
{form_error form=$form field="product"} {form_error form=$form field="product"}
{$message} {$message}
{/form_error} {/form_error}
<label>{intl l="product"}: </label><input type="text" name="{$name}" value="{$value}" {$attr} ><br /> <label for="{$label_attr.for}">{intl l="{$label}"}: </label><input id="{$label_attr.for}" type="text" name="{$name}" value="{$value}" {$attr} ><br />
{/form_field} {/form_field}
{form_field form=$form field='product_sale_elements_id'} {form_field form=$form field='product_sale_elements_id'}