Merge branch 'master' into rewrite

Conflicts:
	core/lib/Thelia/Controller/BaseController.php
	install/insert.sql
This commit is contained in:
Etienne Roudeix
2013-09-04 10:06:22 +02:00
27 changed files with 472 additions and 112 deletions

View File

@@ -34,6 +34,8 @@ use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\CurrencyChangeEvent;
use Thelia\Core\Event\CurrencyCreateEvent;
use Thelia\Core\Event\CurrencyDeleteEvent;
use Thelia\Model\Map\CurrencyTableMap;
use Thelia\Model\ConfigQuery;
class Currency extends BaseAction implements EventSubscriberInterface
{
@@ -53,11 +55,12 @@ class Currency extends BaseAction implements EventSubscriberInterface
->setName($event->getCurrencyName())
->setSymbol($event->getSymbol())
->setRate($event->getRate())
->setCode($event->getCode())
->setCode(strtoupper($event->getCode()))
->save()
;
$event->setCurrency($currency);
}
@@ -79,7 +82,7 @@ class Currency extends BaseAction implements EventSubscriberInterface
->setName($event->getCurrencyName())
->setSymbol($event->getSymbol())
->setRate($event->getRate())
->setCode($event->getCode())
->setCode(strtoupper($event->getCode()))
->save();
@@ -87,6 +90,32 @@ class Currency extends BaseAction implements EventSubscriberInterface
}
}
/**
* Set the default currency
*
* @param CurrencyChangeEvent $event
*/
public function setDefault(CurrencyChangeEvent $event)
{
$search = CurrencyQuery::create();
if (null !== $currency = CurrencyQuery::create()->findOneById($event->getCurrencyId())) {
if ($currency->getByDefault() != $event->getIsDefault()) {
// Reset default status
CurrencyQuery::create()->filterByByDefault(true)->update(array('ByDefault' => false));
$currency
->setByDefault($event->getIsDefault())
->save()
;
}
$event->setCurrency($currency);
}
}
/**
* Delete a currencyuration entry
*
@@ -106,6 +135,29 @@ class Currency extends BaseAction implements EventSubscriberInterface
}
}
public function updateRates() {
$rates_url = ConfigQuery::read('currency_rate_update_url', 'http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml');
$rate_data = file_get_contents($rates_url);
if ($rate_data && $sxe = new \SimpleXMLElement($rate_data)) {
foreach ($sxe->Cube[0]->Cube[0]->Cube as $last)
{
$code = strtoupper($last["currency"]);
$rate = floatval($last['rate']);
if (null !== $currency = CurrencyQuery::create()->findOneByCode($code)) {
$currency->setRate($rate)->save();
}
}
}
else {
throw new \RuntimeException(sprintf("Failed to get currency rates data from URL %s", $url));
}
}
/**
* {@inheritDoc}
*/
@@ -115,6 +167,9 @@ class Currency extends BaseAction implements EventSubscriberInterface
TheliaEvents::CURRENCY_CREATE => array("create", 128),
TheliaEvents::CURRENCY_MODIFY => array("modify", 128),
TheliaEvents::CURRENCY_DELETE => array("delete", 128),
TheliaEvents::CURRENCY_SET_DEFAULT => array("setDefault", 128),
TheliaEvents::CURRENCY_UPDATE_RATES => array("updateRates", 128),
);
}
}

View File

@@ -101,6 +101,14 @@
<default key="_controller">Thelia\Controller\Admin\CurrencyController::saveChangeAction</default>
</route>
<route id="admin.configuration.currencies.set-default" path="/admin/configuration/currencies/set-default">
<default key="_controller">Thelia\Controller\Admin\CurrencyController::setDefaultAction</default>
</route>
<route id="admin.configuration.currencies.update-rates" path="/admin/configuration/currencies/update-rates">
<default key="_controller">Thelia\Controller\Admin\CurrencyController::updateRatesAction</default>
</route>
<route id="admin.configuration.currencies.delete" path="/admin/configuration/currencies/delete">
<default key="_controller">Thelia\Controller\Admin\CurrencyController::deleteAction</default>
</route>

View File

@@ -150,6 +150,27 @@ class BaseAdminController extends BaseController
return $this->container->get('http_kernel')->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
}
/**
* Return the route path defined for the givent route ID
*
* @param string $routeId a route ID, as defines in Config/Resources/routing/admin.xml
*
* @see \Thelia\Controller\BaseController::getRouteFromRouter()
*/
protected function getRoute($routeId) {
return $this->getRouteFromRouter('router.admin', $routeId);
}
/**
* Redirect to à route ID related URL
*
* @param unknown $routeId the route ID, as found in Config/Resources/routing/admin.xml
* @param unknown $urlParameters the URL parametrs, as a var/value pair array
*/
public function redirectToRoute($routeId, $urlParameters = array()) {
$this->redirect(URL::absoluteUrl($this->getRoute($routeId), $urlParameters));
}
/**
* Get the current edition lang ID, checking if a change was requested in the current request
*/

View File

@@ -239,10 +239,11 @@ class ConfigController extends BaseAdminController
// If we have to stay on the same page, do not redirect to the succesUrl,
// just redirect to the edit page again.
if ($this->getRequest()->get('save_mode') == 'stay') {
$this->redirect(URL::absoluteUrl(
"admin/configuration/variables/change",
$this->redirectToRoute(
"admin.configuration.variables.change",
array('variable_id' => $variable_id)
));
);
}
// Redirect to the success URL
@@ -295,7 +296,7 @@ class ConfigController extends BaseAdminController
$this->dispatch(TheliaEvents::CONFIG_SETVALUE, $event);
}
$this->redirect(URL::absoluteUrl('/admin/configuration/variables'));
$this->redirectToRoute('admin.configuration.variables.default');
}
/**
@@ -313,6 +314,6 @@ class ConfigController extends BaseAdminController
$this->dispatch(TheliaEvents::CONFIG_DELETE, $event);
$this->redirect(URL::absoluteUrl('/admin/configuration/variables'));
$this->redirectToRoute('admin.configuration.variables.default');
}
}

View File

@@ -83,7 +83,7 @@ class CurrencyController extends BaseAdminController
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.currencies.create")) return $response;
$currency = false;
$error_msg = false;
// Create the Creation Form
$creationForm = new CurrencyCreationForm($this->getRequest());
@@ -120,24 +120,24 @@ class CurrencyController extends BaseAdminController
}
catch (FormValidationException $ex) {
// Form cannot be validated
$currency = sprintf("Please check your input: %s", $ex->getCurrency());
$error_msg = sprintf("Please check your input: %s", $ex->getMessage());
}
catch (\Exception $ex) {
// Any other error
$currency = sprintf("Sorry, an error occured: %s", $ex->getCurrency());
$error_msg = sprintf("Sorry, an error occured: %s", $ex->getMessage());
}
if ($currency !== false) {
if ($error_msg !== false) {
// An error has been detected: log it
Tlog::getInstance()->error(sprintf("Error during currency creation process : %s. Exception was %s", $currency, $ex->getCurrency()));
Tlog::getInstance()->error(sprintf("Error during currency creation process : %s. Exception was %s", $error_msg, $ex->getMessage()));
// Mark the form as errored
$creationForm->setErrorCurrency($currency);
$creationForm->setErrorMessage($error_msg);
// Pass it to the parser, along with the error currency
$this->getParserContext()
->addForm($creationForm)
->setGeneralError($currency)
->setGeneralError($error_msg)
;
}
@@ -169,7 +169,7 @@ class CurrencyController extends BaseAdminController
'locale' => $currency->getLocale(),
'code' => $currency->getCode(),
'symbol' => $currency->getSymbol(),
'rate' => $currency->getSubject()
'rate' => $currency->getRate()
);
// Setup the object form
@@ -193,7 +193,7 @@ class CurrencyController extends BaseAdminController
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.currencies.change")) return $response;
$currency = false;
$error_msg = false;
// Create the form from the request
$changeForm = new CurrencyModificationForm($this->getRequest());
@@ -230,10 +230,10 @@ class CurrencyController extends BaseAdminController
// If we have to stay on the same page, do not redirect to the succesUrl,
// just redirect to the edit page again.
if ($this->getRequest()->get('save_mode') == 'stay') {
$this->redirect(URL::absoluteUrl(
"admin/configuration/currencies/change",
$this->redirectToRoute(
"admin.configuration.currencies.change",
array('currency_id' => $currency_id)
));
);
}
// Redirect to the success URL
@@ -241,24 +241,24 @@ class CurrencyController extends BaseAdminController
}
catch (FormValidationException $ex) {
// Invalid data entered
$currency = sprintf("Please check your input: %s", $ex->getCurrency());
$error_msg = sprintf("Please check your input: %s", $ex->getMessage());
}
catch (\Exception $ex) {
// Any other error
$currency = sprintf("Sorry, an error occured: %s", $ex->getCurrency());
$error_msg = sprintf("Sorry, an error occured: %s", $ex->getMessage());
}
if ($currency !== false) {
if ($error_msg !== false) {
// Log error currency
Tlog::getInstance()->error(sprintf("Error during currency modification process : %s. Exception was %s", $currency, $ex->getCurrency()));
Tlog::getInstance()->error(sprintf("Error during currency modification process : %s. Exception was %s", $error_msg, $ex->getMessage()));
// Mark the form as errored
$changeForm->setErrorCurrency($currency);
$changeForm->setErrorMessage($error_msg);
// Pas the form and the error to the parser
$this->getParserContext()
->addForm($changeForm)
->setGeneralError($currency)
->setGeneralError($error_msg)
;
}
@@ -266,6 +266,47 @@ class CurrencyController extends BaseAdminController
return $this->render('currency-edit', array('currency_id' => $currency_id));
}
/**
* Sets the default currency
*/
public function setDefaultAction() {
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.currencies.change")) return $response;
$changeEvent = new CurrencyChangeEvent($this->getRequest()->get('currency_id', 0));
// Create and dispatch the change event
$changeEvent->setIsDefault(true);
try {
$this->dispatch(TheliaEvents::CURRENCY_SET_DEFAULT, $changeEvent);
}
catch (\Exception $ex) {
// Any error
return $this->errorPage(sprintf("Sorry, an error occured: %s", $ex->getMessage()));
}
$this->redirectToRoute('admin.configuration.currencies.default');
}
/**
* Update currencies rates
*/
public function updateRatesAction() {
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.currencies.change")) return $response;
try {
$this->dispatch(TheliaEvents::CURRENCY_UPDATE_RATES);
}
catch (\Exception $ex) {
// Any error
return $this->errorPage(sprintf("Sorry, an error occured: %s", $ex->getMessage()));
}
$this->redirectToRoute('admin.configuration.currencies.default');
}
/**
* Delete a currency object
*
@@ -281,6 +322,6 @@ class CurrencyController extends BaseAdminController
$this->dispatch(TheliaEvents::CURRENCY_DELETE, $event);
$this->redirect(URL::adminViewUrl('currencies'));
$this->redirectToRoute('admin.configuration.currencies.default');
}
}

View File

@@ -214,10 +214,10 @@ class MessageController extends BaseAdminController
// If we have to stay on the same page, do not redirect to the succesUrl,
// just redirect to the edit page again.
if ($this->getRequest()->get('save_mode') == 'stay') {
$this->redirect(URL::absoluteUrl(
"admin/configuration/messages/change",
$this->redirectToRoute(
"admin.configuration.messages.change",
array('message_id' => $message_id)
));
);
}
// Redirect to the success URL

View File

@@ -46,7 +46,7 @@ class SessionController extends BaseAdminController
$this->getSecurityContext()->clearAdminUser();
// Go back to login page.
return Redirect::exec(URL::absoluteUrl('/admin/login')); // FIXME - should be a parameter
$this->redirectToRoute('admin.login');
}
public function checkLoginAction()

View File

@@ -31,14 +31,13 @@ use Thelia\Tools\Redirect;
use Thelia\Core\Template\ParserContext;
use Thelia\Core\Event\ActionEvent;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Thelia\Core\Factory\ActionEventFactory;
use Thelia\Form\BaseForm;
use Thelia\Form\Exception\FormValidationException;
use Symfony\Component\EventDispatcher\Event;
use Thelia\Core\Event\DefaultActionEvent;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
*
* The defaut administration controller. Basically, display the login form if
@@ -203,6 +202,25 @@ class BaseController extends ContainerAware
if (null !== $url) $this->redirect($url);
}
/**
* Get a route path from the route id.
*
* @param $routerName
* @param $routeId
*
* @return mixed
* @throws InvalidArgumentException
*/
protected function getRouteFromRouter($routerName, $routeId) {
$route = $this->container->get($routerName)->getRouteCollection()->get($routeId);
if ($route == null) {
throw new InvalidArgumentException(sprintf("Route ID '%s' does not exists.", $routeId));
}
return $route->getPath();
}
/**
* Return a 404 error
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException

View File

@@ -26,4 +26,24 @@ use Thelia\Controller\BaseController;
class BaseFrontController extends BaseController
{
/**
* Return the route path defined for the givent route ID
*
* @param string $routeId a route ID, as defines in Config/Resources/routing/front.xml
*
* @see \Thelia\Controller\BaseController::getRouteFromRouter()
*/
protected function getRoute($routeId) {
return $this->getRouteFromRouter('router.front', $routeId);
}
/**
* Redirect to à route ID related URL
*
* @param unknown $routeId the route ID, as found in Config/Resources/routing/admin.xml
* @param unknown $urlParameters the URL parametrs, as a var/value pair array
*/
public function redirectToRoute($routeId, $urlParameters = array()) {
$this->redirect(URL::absoluteUrl($this->getRoute($routeId), $urlParameters));
}
}

View File

@@ -27,6 +27,7 @@ use Thelia\Model\Currency;
class CurrencyChangeEvent extends CurrencyCreateEvent
{
protected $currency_id;
protected $is_default;
public function __construct($currency_id)
{
@@ -44,4 +45,16 @@ class CurrencyChangeEvent extends CurrencyCreateEvent
return $this;
}
public function getIsDefault()
{
return $this->is_default;
}
public function setIsDefault($is_default)
{
$this->is_default = $is_default;
return $this;
}
}

View File

@@ -65,6 +65,8 @@ class CurrencyCreateEvent extends CurrencyEvent
public function setSymbol($symbol)
{
$this->symbol = $symbol;
return $this;
}
public function getCode()

View File

@@ -214,6 +214,8 @@ final class TheliaEvents
const CURRENCY_CREATE = "action.createCurrency";
const CURRENCY_MODIFY = "action.changeCurrency";
const CURRENCY_DELETE = "action.deleteCurrency";
const CURRENCY_SET_DEFAULT = "action.setDefaultCurrency";
const CURRENCY_UPDATE_RATES = "action.updateCurrencyRates";
const BEFORE_CREATECURRENCY = "action.before_createCurrency";
const AFTER_CREATECURRENCY = "action.after_createCurrency";

View File

@@ -114,22 +114,24 @@ class Address extends BaseLoop
foreach ($addresses as $address) {
$loopResultRow = new LoopResultRow();
$loopResultRow->set("ID", $address->getId());
$loopResultRow->set("NAME", $address->getName());
$loopResultRow->set("CUSTOMER", $address->getCustomerId());
$loopResultRow->set("TITLE", $address->getTitleId());
$loopResultRow->set("COMPANY", $address->getCompany());
$loopResultRow->set("FIRSTNAME", $address->getFirstname());
$loopResultRow->set("LASTNAME", $address->getLastname());
$loopResultRow->set("ADDRESS1", $address->getAddress1());
$loopResultRow->set("ADDRESS2", $address->getAddress2());
$loopResultRow->set("ADDRESS3", $address->getAddress3());
$loopResultRow->set("ZIPCODE", $address->getZipcode());
$loopResultRow->set("CITY", $address->getCity());
$loopResultRow->set("COUNTRY", $address->getCountryId());
$loopResultRow->set("PHONE", $address->getPhone());
$loopResultRow->set("CELLPHONE", $address->getCellphone());
$loopResultRow->set("DEFAULT", $address->getIsDefault());
$loopResultRow
->set("ID", $address->getId())
->set("NAME", $address->getName())
->set("CUSTOMER", $address->getCustomerId())
->set("TITLE", $address->getTitleId())
->set("COMPANY", $address->getCompany())
->set("FIRSTNAME", $address->getFirstname())
->set("LASTNAME", $address->getLastname())
->set("ADDRESS1", $address->getAddress1())
->set("ADDRESS2", $address->getAddress2())
->set("ADDRESS3", $address->getAddress3())
->set("ZIPCODE", $address->getZipcode())
->set("CITY", $address->getCity())
->set("COUNTRY", $address->getCountryId())
->set("PHONE", $address->getPhone())
->set("CELLPHONE", $address->getCellphone())
->set("DEFAULT", $address->getIsDefault())
;
$loopResult->addRow($loopResultRow);
}

View File

@@ -107,8 +107,6 @@ class CategoryTree extends BaseI18nLoop
$visible = $this->getVisible();
$exclude = $this->getExclude();
//echo "exclude=".print_r($exclude);
$loopResult = new LoopResult();
$this->buildCategoryTree($id, $visible, 0, $depth, $exclude, $loopResult);

View File

@@ -164,8 +164,12 @@ class Config extends BaseI18nLoop
->set("POSTSCRIPTUM" , $result->getVirtualColumn('i18n_POSTSCRIPTUM'))
->set("HIDDEN" , $result->getHidden())
->set("SECURED" , $result->getSecured())
->set("CREATE_DATE" , $result->getCreatedAt())
->set("UPDATE_DATE" , $result->getUpdatedAt())
->set("VERSION" , $result->getVersion())
->set("VERSION_DATE" , $result->getVersionCreatedAt())
->set("VERSION_AUTHOR" , $result->getVersionCreatedBy())
;
$loopResult->addRow($loopResultRow);

View File

@@ -177,7 +177,11 @@ class Currency extends BaseI18nLoop
->set("SYMBOL" , $currency->getSymbol())
->set("RATE" , $currency->getRate())
->set("POSITION" , $currency->getPosition())
->set("IS_DEFAULT" , $currency->getByDefault());
->set("IS_DEFAULT" , $currency->getByDefault())
->set("CREATE_DATE" , $currency->getCreatedAt())
->set("UPDATE_DATE" , $currency->getUpdatedAt())
;
$loopResult->addRow($loopResultRow);
}

View File

@@ -519,6 +519,12 @@ class Product extends BaseI18nLoop
->set("IS_PROMO", $product->getVirtualColumn('main_product_is_promo'))
->set("IS_NEW", $product->getVirtualColumn('main_product_is_new'))
->set("POSITION", $product->getPosition())
->set("CREATE_DATE", $category->getCreatedAt())
->set("UPDATE_DATE", $category->getUpdatedAt())
->set("VERSION", $category->getVersion())
->set("VERSION_DATE", $category->getVersionCreatedAt())
->set("VERSION_AUTHOR", $category->getVersionCreatedBy())
;
$loopResult->addRow($loopResultRow);

View File

@@ -31,20 +31,20 @@ class CurrencyCreationForm extends BaseForm
{
protected function buildForm($change_mode = false)
{
$name_constraints = array(new Constraints\NotBlank());
$code_constraints = array(new Constraints\NotBlank());
if (!$change_mode) {
$name_constraints[] = new Constraints\Callback(array(
"methods" => array(array($this, "checkDuplicateName"))
$code_constraints[] = new Constraints\Callback(array(
"methods" => array(array($this, "checkDuplicateCode"))
));
}
$this->formBuilder
->add("name" , "text" , array("constraints" => array($name_constraints)))
->add("locale" , "text" , array())
->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" => array(new NotBlank())))
->add("code" , "text" , array("constraints" => $code_constraints))
;
}
@@ -53,12 +53,12 @@ class CurrencyCreationForm extends BaseForm
return "thelia_currency_creation";
}
public function checkDuplicateName($value, ExecutionContextInterface $context)
public function checkDuplicateCode($value, ExecutionContextInterface $context)
{
$currency = CurrencyQuery::create()->findOneByName($value);
$currency = CurrencyQuery::create()->findOneByCode($value);
if ($currency) {
$context->addViolation(sprintf("A currency with name \"%s\" already exists.", $value));
$context->addViolation(sprintf("A currency with code \"%s\" already exists.", $value));
}
}

View File

@@ -2,6 +2,7 @@
namespace Thelia\Model;
use Thelia\Core\Event\CategoryEvent;
use Thelia\Model\Base\Category as BaseCategory;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Tools\URL;

View File

@@ -6,14 +6,15 @@ INSERT INTO `lang`(`id`,`title`,`code`,`locale`,`url`,`by_default`,`created_at`,
INSERT INTO `config` (`name`, `value`, `secured`, `hidden`, `created_at`, `updated_at`) VALUES
('session_config.default', '1', 1, 1, NOW(), NOW()),
('verifyStock', '1', 1, 0, NOW(), NOW()),
('default_lang_without_translation', '1', 1, 0, NOW(), NOW()),
('rewriting_enable', '0', 1, 0, NOW(), NOW()),
('imagine_graphic_driver', 'gd', 1, 0, NOW(), NOW()),
('default_images_quality_percent', '75', 1, 0, NOW(), NOW()),
('original_image_delivery_mode', 'symlink', 1, 0, NOW(), NOW()),
('images_library_path', 'local/media/images', 1, 0, NOW(), NOW()),
('image_cache_dir_from_web_root', 'cache/images', 1, 0, NOW(), NOW());
('verifyStock', '1', 0, 0, NOW(), NOW()),
('default_lang_without_translation', '1', 0, 0, NOW(), NOW()),
('rewriting_enable', '0', 0, 0, NOW(), NOW()),
('imagine_graphic_driver', 'gd', 0, 0, NOW(), NOW()),
('default_images_quality_percent', '75', 0, 0, NOW(), NOW()),
('original_image_delivery_mode', 'symlink', 0, 0, NOW(), NOW()),
('images_library_path', 'local/media/images', 0, 0, NOW(), NOW()),
('image_cache_dir_from_web_root', 'cache/images', 0, 0, NOW(), NOW()),
('currency_rate_update_url', 'http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml', 0, 0, NOW(), NOW()),
('page_not_found_view', '404.html', 0, 0, NOW(), NOW());
INSERT INTO `module` (`code`, `type`, `activate`, `position`, `created_at`, `updated_at`) VALUES ('test', '1', '1', '1', NOW(), NOW());
@@ -39,12 +40,12 @@ VALUES
INSERT INTO `currency_i18n` (`id` ,`locale` ,`name`)
VALUES
(1, 'fr_FR', 'euro'),
(1, 'en_UK', 'euro'),
(2, 'fr_FR', 'dollar'),
(2, 'en_UK', 'dollar'),
(3, 'fr_FR', 'livre'),
(3, 'en_UK', 'pound');
(1, 'fr_FR', 'Euro'),
(1, 'en_UK', 'Euro'),
(2, 'fr_FR', 'Dollar Américain'),
(2, 'en_UK', 'United States Dollar'),
(3, 'fr_FR', 'Livre anglaise'),
(3, 'en_UK', 'UK Pound');
INSERT INTO `country` (`id`, `area_id`, `isocode`, `isoalpha2`, `isoalpha3`, `created_at`, `updated_at`) VALUES

View File

@@ -658,6 +658,7 @@ label {
font-weight: normal;
}
.form-horizontal input + .help-block,
.form-horizontal select + .help-block,
.form-horizontal textarea + .help-block,
@@ -665,9 +666,10 @@ label {
.form-horizontal .input-prepend + .help-block,
.form-horizontal .input-append + .help-block
.help-block, .form-horizontal .help-block {
margin-top: 0px;
margin-top: 5px;
}
// Fix for append-fields shorter than others
// see http://stackoverflow.com/questions/13306670/bootstrap-prepended-and-appended-input-how-to-max-input-field-width
.input-append.input-block-level,

View File

@@ -26,7 +26,7 @@
<div class="row-fluid">
<div class="span12">
<form action="{url path='/admin/configuration/currencies/change-values'}" method="post">
<form action="{url path='/admin/configuration/currencies/update-rates'}" method="post">
<div class="general-block-decorator">
<table class="table table-striped table-condensed table-left-aligned">
<caption>
@@ -35,6 +35,7 @@
<a class="btn btn-primary action-btn" title="{intl l='Add a new currency'}" href="#add_currency_dialog" data-toggle="modal">
<i class="icon-plus-sign icon-white"></i>
</a>
<button class="btn btn-info action-btn" title="{intl l='Update rates'}">{intl l='Update rates'} <i class="icon icon-white icon-globe"></i></button>
{/loop}
</caption>
@@ -117,7 +118,6 @@
{loop name="currencies" type="currency" backend_context="1" lang=$lang_id order=$order}
<tr>
<td>{$ID}</td>
<td>
@@ -133,7 +133,7 @@
<td class="text-center">{$SYMBOL}</td>
<td class="text-right">{$RATE|string_format:"%.4f"}</td>
<td class="text-right">{format_number number="$RATE" decimals="4"}</td>
<td class="text-center">
{admin_position_block
@@ -146,7 +146,9 @@
}
</td>
<td class="text-center"><input type="radio" name="default[{$ID}]" value="1" {if $IS_DEFAULT}checked="checked"{/if}/></td>
<td class="text-center">
<input class="change-default" type="radio" name="is_default" value="{$ID}" {if $IS_DEFAULT}checked="checked"{/if}/>
</td>
{module_include location='currencies_table_row'}
@@ -208,7 +210,7 @@
<div class="modal-body">
{if #form_error}<div class="alert alert-block alert-error" id="add_currency_dialog_error">#form_error_currency</div>{/if}
{if $form_error}<div class="alert alert-block alert-error" id="add_currency_dialog_error">{$form_error_message}</div>{/if}
<div class="control-group">
@@ -246,7 +248,7 @@
</label>
<div class="controls">
{form_field form=$form field='symbol'}
{form_field form=$form field='code'}
<span {if $error}class="error"{/if}>
<input type="text" required="required" name="{$name}" value="{$value}" title="{intl l='ISO 4217 code'}" placeholder="{intl l='Code'}">
</span>
@@ -278,11 +280,11 @@
</label>
<div class="controls">
{form_field form=$form field='symbol'}
{form_field form=$form field='rate'}
<span {if $error}class="error"{/if}>
<input type="text" required="required" name="{$name}" value="{$value}" title="{intl l='Currency rate'}" placeholder="{intl l='Rate'}">
</span>
<div class="help-block">{intl l="Currency rate, in Euro"}</div>
<div class="help-block">{intl l="The rate from Euro (Price in Euro * rate = Price in this currency)"}</div>
{/form_field}
</div>
</div>
@@ -380,6 +382,18 @@
}
});
{* Change default status *}
$('.change-default').click(function(ev) {
var url = "{url path='/admin/configuration/currencies/set-default' currency_id='__ID__'}";
// Perform ID subtitutions
url = url.replace('__ID__', $(this).val());
// Reload the page
location.href = url;
});
});
</script>
{/block}

View File

@@ -0,0 +1,147 @@
{extends file="admin-layout.tpl"}
{block name="page-title"}{intl l='Edit a currency'}{/block}
{block name="check-permissions"}admin.configuration.currencies.edit{/block}
{block name="main-content"}
<div class="currencies edit-currency">
<div id="wrapper" class="container">
{loop name="currency_edit" type="currency" id="$currency_id" backend_context="1" lang="$edit_language_id"}
<ul class="breadcrumb">
<li><a href="{url path='/admin/home'}">{intl l="Home"}</a> <span class="divider">/</span></li>
<li><a href="{url path='/admin/configuration'}">{intl l="Configuration"}</a> <span class="divider">/</span></li>
<li><a href="{url path='/admin/configuration/currencies'}">{intl l="Currencies"}</a> <span class="divider">/</span></li>
<li>{intl l='Editing currency "%name"' name="{$NAME}"}</li>
</ul>
<div class="row-fluid">
<div class="span12 general-block-decorator">
<div class="row-fluid">
<div class="span12 title title-without-tabs">
{intl l="Edit currency $NAME"}
</div>
<div class="form-container">
<div class="form-horizontal span12">
{form name="thelia.admin.currency.modification"}
<form method="POST" action="{url path='/admin/configuration/currencies/save-change'}" {form_enctype form=$form}>
<fieldset>
{* Be sure to get the currency ID, even if the form could not be validated *}
<input type="hidden" name="currency_id" value="{$currency_id}" />
{include file="includes/inner-form-toolbar.html"}
{form_hidden_fields form=$form}
{form_field form=$form field='success_url'}
<input type="hidden" name="{$name}" value="{url path='/admin/configuration/currencies'}" />
{/form_field}
{form_field form=$form field='locale'}
<input type="hidden" name="{$name}" value="{$edit_language_locale}" />
{/form_field}
{if $form_error}<div class="alert alert-block alert-error">{$form_error_message}</div>{/if}
<div class="row-fluid">
<div class="span6">
<div class="control-group">
<label class="control-label">
{intl l='Name *'}
</label>
<div class="controls">
{form_field form=$form field='name'}
<span {if $error}class="error"{/if}>
<input type="text" required="required" name="{$name}" value="{$value|htmlspecialchars}" title="{intl l='Currency name'}" placeholder="{intl l='Currency name'}" class="input-medium">
</span>
{/form_field}
</div>
</div>
<div class="control-group">
<label class="control-label">
{intl l='ISO 4217 Code *'}
<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>
<div class="controls">
{form_field form=$form field='code'}
<span {if $error}class="error"{/if}>
<input type="text" required="required" name="{$name}" value="{$value|htmlspecialchars}" title="{intl l='Currency ISO 4217 Code'}" placeholder="{intl l='Code'}" class="input-mini">
</span>
{/form_field}
</div>
</div>
</div>
<div class="span6">
<div class="control-group">
<label class="control-label">
{intl l='Symbol *'}
<span class="label-help-block">The symbol, sur as $, £, &euro;...</span>
</label>
<div class="controls">
{form_field form=$form field='symbol'}
<span {if $error}class="error"{/if}>
<input type="text" required="required" name="{$name}" value="{$value|htmlspecialchars}" title="{intl l='Currency symbol'}" placeholder="{intl l='Symbol'}" class="input-mini">
</span>
{/form_field}
</div>
</div>
<div class="control-group">
<label class="control-label">
{intl l='Rate from &euro; *'}
<span class="label-help-block">The rate from Euro</span>
</label>
<div class="controls">
{form_field form=$form field='rate'}
<span {if $error}class="error"{/if}>
<input type="text" required="required" name="{$name}" value="{$value|htmlspecialchars}" title="{intl l='Rate from Euro'}" placeholder="{intl l='Rate'}" class="input-mini">
</span>
{/form_field}
<span class="help-block">Price in Euro x rate = Price in this currency</span>
</div>
</div>
</div>
</div>
<div class="control-group">
<div class="controls">
<p>{intl l='Currency created on %date_create. Last modification: %date_change' date_create="{format_date date=$CREATE_DATE}" date_change="{format_date date=$UPDATE_DATE}"}</p>
</div>
</div>
</fieldset>
</form>
{/form}
</div>
</div>
</div>
</div>
</div>
{/loop}
{elseloop rel="currency_edit"}
<div class="row-fluid">
<div class="span12">
<div class="alert alert-error">
{intl l="Sorry, currency ID=$currency_id was not found."}
</div>
</div>
</div>
{/elseloop}
</div>
</div>
{/block}

View File

@@ -123,7 +123,7 @@
<div class="control-group">
<lablel>&nbsp;</lablel>
<div class="controls">
<p>{intl l='Category created on %date_create. Last modification: %date_change' date_create=$CREATE_DATE->format($datetime_format) date_change=$UPDATE_DATE->format($datetime_format)}</p>
<p>{intl l='Category created on %date_create. Last modification: %date_change' date_create="{format_date date=$CREATE_DATE}" date_change="{format_date date=$UPDATE_DATE}"}}</p>
</div>
</div>
</div>

View File

@@ -144,7 +144,7 @@
<div class="control-group">
<div class="controls">
<p>{intl l='Message created on %date_create. Last modification: %date_change' df=$datetime_format date_create=$CREATE_DATE->format($datetime_format) date_change=$UPDATE_DATE->format($datetime_format)}</p>
<p>{intl l='Message created on %date_create. Last modification: %date_change' date_create="{format_date date=$CREATE_DATE}" date_change="{format_date date=$UPDATE_DATE}"}}</p>
</div>
</div>
</fieldset>

View File

@@ -108,7 +108,7 @@
<div class="control-group">
<div class="controls">
<p>{intl l='Variable created on %date_create. Last modification: %date_change' df=$datetime_format date_create=$CREATE_DATE->format($datetime_format) date_change=$UPDATE_DATE->format($datetime_format)}</p>
<p>{intl l='Variable created on %date_create. Last modification: %date_change' date_create="{format_date date=$CREATE_DATE}" date_change="{format_date date=$UPDATE_DATE}"}</p>
</div>
</div>