Improved languages management, added many country flags. Fix #183
@@ -123,7 +123,6 @@ class LangController extends BaseAdminController
|
||||
$error_msg = $this->getTranslator()->trans("Failed to update language definition: %ex", array("%ex" => $ex->getMessage()));
|
||||
Tlog::getInstance()->addError("Failed to update language definition", $ex->getMessage());
|
||||
}
|
||||
echo "err=".$error_msg;
|
||||
|
||||
return $this->renderDefault(array('error_message' => $error_msg));
|
||||
}
|
||||
@@ -231,7 +230,7 @@ echo "err=".$error_msg;
|
||||
}
|
||||
|
||||
return $this->renderDefault(array(
|
||||
'error_delete_message' => $error_msg
|
||||
'error_message' => $error_msg
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ class LangCreateForm extends BaseForm
|
||||
'constraints' => array(
|
||||
new NotBlank()
|
||||
),
|
||||
'label' => Translator::getInstance()->trans('ISO 639 Code'),
|
||||
'label' => Translator::getInstance()->trans('ISO 639-1 Code'),
|
||||
'label_attr' => array(
|
||||
'for' => 'code_lang'
|
||||
)
|
||||
|
||||
@@ -92,6 +92,9 @@ class ConfigQuery extends BaseConfigQuery {
|
||||
return self::read('check-available-stock', 1) != 0;
|
||||
}
|
||||
|
||||
public static function getUnknownFlagPath() {
|
||||
return self::read('unknown-flag-path', '/assets/img/flags/unknown.png');
|
||||
}
|
||||
/* smtp config */
|
||||
public static function isSmtpEnable()
|
||||
{
|
||||
|
||||
@@ -5,8 +5,11 @@ namespace Thelia\Model;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Propel\Runtime\Propel;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Thelia\Core\Event\Lang\LangEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Template\TemplateHelper;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Model\Base\Lang as BaseLang;
|
||||
use Thelia\Model\LangQuery;
|
||||
use Thelia\Model\Map\LangTableMap;
|
||||
@@ -53,6 +56,33 @@ class Lang extends BaseLang {
|
||||
|
||||
}
|
||||
|
||||
protected function fixMissingFlag() {
|
||||
// Be sure that a lang have a flag, otherwise copy the
|
||||
// "unknown" flag
|
||||
$adminTemplate = TemplateHelper::getInstance()->getActiveAdminTemplate();
|
||||
$unknownFlag = ConfigQuery::getUnknownFlagPath();
|
||||
|
||||
$unknownFlagPath = $adminTemplate->getAbsolutePath().DS.$unknownFlag;
|
||||
|
||||
if (! file_exists($unknownFlagPath)) {
|
||||
throw new \RuntimeException(
|
||||
Translator::getInstance()->trans(
|
||||
"The image which replaces an undefined country flag (%file) was not found. Please check unknown-flag-path configuration variable, and check that the image exists.",
|
||||
array("%file" => $unknownFlag)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Check if the country flag exists
|
||||
$countryFlag = rtrim(dirname($unknownFlagPath), DS).DS.$this->getCode().'.png';
|
||||
|
||||
if (! file_exists($countryFlag)) {
|
||||
$fs = new Filesystem();
|
||||
|
||||
$fs->copy($unknownFlagPath, $countryFlag);
|
||||
}
|
||||
}
|
||||
|
||||
public function preInsert(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_CREATELANG, new LangEvent($this));
|
||||
@@ -63,6 +93,8 @@ class Lang extends BaseLang {
|
||||
public function postInsert(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_CREATELANG, new LangEvent($this));
|
||||
|
||||
$this->fixMissingFlag();
|
||||
}
|
||||
|
||||
public function preUpdate(ConnectionInterface $con = null)
|
||||
@@ -75,6 +107,8 @@ class Lang extends BaseLang {
|
||||
public function postUpdate(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_UPDATELANG, new LangEvent($this));
|
||||
|
||||
$this->fixMissingFlag();
|
||||
}
|
||||
|
||||
public function preDelete(ConnectionInterface $con = null)
|
||||
|
||||
@@ -32,6 +32,8 @@ INSERT INTO `config` (`name`, `value`, `secured`, `hidden`, `created_at`, `updat
|
||||
('url_site','', 0, 0, NOW(), NOW()),
|
||||
('pdf_invoice_file', 'invoice', 0, 0, NOW(), NOW()),
|
||||
('pdf_delivery_file', 'delivery', 0, 0, NOW(), NOW()),
|
||||
('unknown-flag-path','assets/img/flags/unknown.png', 0, 0, NOW(), NOW()),
|
||||
|
||||
('session_config.default', '1', 1, 1, NOW(), NOW()),
|
||||
('default_lang_without_translation', '1', 1, 1, NOW(), NOW()),
|
||||
('store_name','', 0, 1, NOW(), NOW()),
|
||||
@@ -43,6 +45,7 @@ INSERT INTO `config` (`name`, `value`, `secured`, `hidden`, `created_at`, `updat
|
||||
('thelia_release_version','0', 1, 1, NOW(), NOW()),
|
||||
('thelia_extra_version','beta3', 1, 1, NOW(), NOW());
|
||||
|
||||
|
||||
INSERT INTO `config_i18n` (`id`, `locale`, `title`, `description`, `chapo`, `postscriptum`) VALUES
|
||||
(1, 'en_US', 'Class name of the session handler', NULL, NULL, NULL),
|
||||
(2, 'en_US', 'Check available product stock (1) or ignore it (0) when displaying and changing ordered quantity', NULL, NULL, NULL),
|
||||
@@ -70,7 +73,8 @@ INSERT INTO `config_i18n` (`id`, `locale`, `title`, `description`, `chapo`, `pos
|
||||
(24, 'en_US', '"Remember me" cookie expiration time, in seconds, for customer users', NULL, NULL, NULL),
|
||||
(25, 'en_US', 'Base URL of the shop (e.g. http://www.yourshopdomain.com)', NULL, NULL, NULL),
|
||||
(26, 'en_US', 'Name of the invoice view in the current PDF template (without extension)', NULL, NULL, NULL),
|
||||
(27, 'en_US', 'Name of the delivery view in the current PDF template (without extension)', NULL, NULL, NULL);
|
||||
(27, 'en_US', 'Name of the delivery view in the current PDF template (without extension)', NULL, NULL, NULL),
|
||||
(28, 'en_US', 'The path (relative to the default back-office template) to the image used when no flag image can be found for a country', NULL, NULL, NULL);
|
||||
|
||||
INSERT INTO `module` (`id`, `code`, `type`, `activate`, `position`, `full_namespace`, `created_at`, `updated_at`) VALUES
|
||||
(1, 'TheliaDebugBar', 1, 1, 1, 'TheliaDebugBar\\TheliaDebugBar', NOW(), NOW()),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
# This is a fix for InnoDB in MySQL >= 4.1.x
|
||||
# It "suspends judgement" for fkey relationships until are tables are set.
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
@@ -12,6 +12,12 @@ INSERT INTO `module_i18n` (`id`, `locale`, `title`, `description`, `chapo`, `po
|
||||
UPDATE `config` SET `value`='2.0.0-beta4' WHERE `name`='thelia_version';
|
||||
UPDATE `config` SET `value`='beta4' WHERE `name`='thelia_extra_version';
|
||||
|
||||
-- Preferred locale for admin users
|
||||
ALTER TABLE `admin` ADD `locale` VARCHAR(45) NOT NULL;
|
||||
UPDATE `admin` SET `locale`='en_US';
|
||||
|
||||
-- Unknown flag image path
|
||||
INSERT INTO `config` (`name`, `value`, `secured`, `hidden`, `created_at`, `updated_at`) VALUES
|
||||
('unknown-flag-path','assets/img/flags/unknown.png', 1, 1, NOW(), NOW());
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
@@ -84,7 +84,7 @@
|
||||
<div class="btn-group">
|
||||
{loop type="lang" name="ui-lang" id="{lang attr='id'}"}
|
||||
<button class="btn btn-default">
|
||||
<img src="{image file="assets/img/flags/{$CODE}.gif"}" alt="$TITLE" /> {$CODE|ucfirst}</a>
|
||||
<img src="{image file="assets/img/flags/{$CODE}.png"}" alt="{$TITLE}" /> {$CODE|ucfirst}</a>
|
||||
</button>
|
||||
{/loop}
|
||||
|
||||
@@ -93,7 +93,7 @@
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
{loop type="lang" name="ui-lang"}
|
||||
<li><a href="{url path="{navigate to="current"}" lang={$CODE}}"><img src="{image file="assets/img/flags/{$CODE}.gif"}" alt="$TITLE" /> {$CODE|ucfirst}</a></li>
|
||||
<li><a href="{url path="{navigate to="current"}" lang={$CODE}}"><img src="{image file="assets/img/flags/{$CODE}.png"}" alt="{$TITLE}" /> {$CODE|ucfirst}</a></li>
|
||||
{/loop}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{intl l={$label}} : </label>
|
||||
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l={$label}}" placeholder="{intl l='Company'}">
|
||||
<span class="help-block">{intl l='<a href="http://en.wikipedia.org/wiki/ISO_639-1_language_matrix" target="_other">Check the list</a> of ISO 639-1 codes'}</span>
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
@@ -32,6 +33,7 @@
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{intl l={$label}} : </label>
|
||||
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l={$label}}" placeholder="{intl l='Company'}">
|
||||
<span class="help-block">{intl l='The syntax used is identical to the PHP <a href="http://www.php.net/date" target="_other">date()</a> function'}</span>
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
@@ -39,6 +41,7 @@
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{intl l={$label}} : </label>
|
||||
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l={$label}}" placeholder="{intl l='Company'}">
|
||||
<span class="help-block">{intl l='The syntax used is identical to the PHP <a href="http://www.php.net/date" target="_other">date()</a> function'}</span>
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
@@ -53,7 +56,7 @@
|
||||
dialog_title = {intl l="Edit a language"}
|
||||
dialog_body = {$smarty.capture.edit_lang_dialog nofilter}
|
||||
|
||||
dialog_ok_label = {intl l="Edit this language"}
|
||||
dialog_ok_label = {intl l="Save changes"}
|
||||
dialog_cancel_label = {intl l="Cancel"}
|
||||
|
||||
form_action = {url path="/admin/configuration/languages/save/{$lang_id}"}
|
||||
|
||||
BIN
templates/backOffice/default/assets/img/flags/ad.png
Normal file
|
After Width: | Height: | Size: 263 B |
BIN
templates/backOffice/default/assets/img/flags/ae.png
Normal file
|
After Width: | Height: | Size: 107 B |
BIN
templates/backOffice/default/assets/img/flags/af.png
Normal file
|
After Width: | Height: | Size: 259 B |
BIN
templates/backOffice/default/assets/img/flags/ag.png
Normal file
|
After Width: | Height: | Size: 302 B |
BIN
templates/backOffice/default/assets/img/flags/ai.png
Normal file
|
After Width: | Height: | Size: 332 B |
BIN
templates/backOffice/default/assets/img/flags/al.png
Normal file
|
After Width: | Height: | Size: 291 B |
BIN
templates/backOffice/default/assets/img/flags/am.png
Normal file
|
After Width: | Height: | Size: 105 B |
BIN
templates/backOffice/default/assets/img/flags/an.png
Normal file
|
After Width: | Height: | Size: 145 B |
BIN
templates/backOffice/default/assets/img/flags/ao.png
Normal file
|
After Width: | Height: | Size: 241 B |
BIN
templates/backOffice/default/assets/img/flags/aq.png
Normal file
|
After Width: | Height: | Size: 382 B |
BIN
templates/backOffice/default/assets/img/flags/ar.png
Normal file
|
After Width: | Height: | Size: 209 B |
BIN
templates/backOffice/default/assets/img/flags/as.png
Normal file
|
After Width: | Height: | Size: 448 B |
BIN
templates/backOffice/default/assets/img/flags/at.png
Normal file
|
After Width: | Height: | Size: 98 B |
BIN
templates/backOffice/default/assets/img/flags/au.png
Normal file
|
After Width: | Height: | Size: 228 B |
BIN
templates/backOffice/default/assets/img/flags/aw.png
Normal file
|
After Width: | Height: | Size: 182 B |
BIN
templates/backOffice/default/assets/img/flags/ax.png
Normal file
|
After Width: | Height: | Size: 121 B |
BIN
templates/backOffice/default/assets/img/flags/az.png
Normal file
|
After Width: | Height: | Size: 267 B |
BIN
templates/backOffice/default/assets/img/flags/ba.png
Normal file
|
After Width: | Height: | Size: 355 B |
BIN
templates/backOffice/default/assets/img/flags/bb.png
Normal file
|
After Width: | Height: | Size: 159 B |
BIN
templates/backOffice/default/assets/img/flags/bd.png
Normal file
|
After Width: | Height: | Size: 211 B |
BIN
templates/backOffice/default/assets/img/flags/be.png
Normal file
|
After Width: | Height: | Size: 102 B |
BIN
templates/backOffice/default/assets/img/flags/bf.png
Normal file
|
After Width: | Height: | Size: 166 B |
BIN
templates/backOffice/default/assets/img/flags/bg.png
Normal file
|
After Width: | Height: | Size: 103 B |
BIN
templates/backOffice/default/assets/img/flags/bh.png
Normal file
|
After Width: | Height: | Size: 129 B |
BIN
templates/backOffice/default/assets/img/flags/bi.png
Normal file
|
After Width: | Height: | Size: 454 B |
BIN
templates/backOffice/default/assets/img/flags/bj.png
Normal file
|
After Width: | Height: | Size: 106 B |
BIN
templates/backOffice/default/assets/img/flags/bl.png
Normal file
|
After Width: | Height: | Size: 539 B |
BIN
templates/backOffice/default/assets/img/flags/bm.png
Normal file
|
After Width: | Height: | Size: 321 B |
BIN
templates/backOffice/default/assets/img/flags/bn.png
Normal file
|
After Width: | Height: | Size: 518 B |
BIN
templates/backOffice/default/assets/img/flags/bo.png
Normal file
|
After Width: | Height: | Size: 236 B |
BIN
templates/backOffice/default/assets/img/flags/br.png
Normal file
|
After Width: | Height: | Size: 432 B |
BIN
templates/backOffice/default/assets/img/flags/bs.png
Normal file
|
After Width: | Height: | Size: 171 B |
BIN
templates/backOffice/default/assets/img/flags/bt.png
Normal file
|
After Width: | Height: | Size: 449 B |
BIN
templates/backOffice/default/assets/img/flags/bw.png
Normal file
|
After Width: | Height: | Size: 108 B |
BIN
templates/backOffice/default/assets/img/flags/by.png
Normal file
|
After Width: | Height: | Size: 151 B |
BIN
templates/backOffice/default/assets/img/flags/bz.png
Normal file
|
After Width: | Height: | Size: 337 B |
BIN
templates/backOffice/default/assets/img/flags/ca.png
Normal file
|
After Width: | Height: | Size: 177 B |
BIN
templates/backOffice/default/assets/img/flags/cc.png
Normal file
|
After Width: | Height: | Size: 259 B |
BIN
templates/backOffice/default/assets/img/flags/cd.png
Normal file
|
After Width: | Height: | Size: 432 B |
BIN
templates/backOffice/default/assets/img/flags/cf.png
Normal file
|
After Width: | Height: | Size: 162 B |
BIN
templates/backOffice/default/assets/img/flags/cg.png
Normal file
|
After Width: | Height: | Size: 152 B |
BIN
templates/backOffice/default/assets/img/flags/ch.png
Normal file
|
After Width: | Height: | Size: 100 B |
BIN
templates/backOffice/default/assets/img/flags/ci.png
Normal file
|
After Width: | Height: | Size: 100 B |
BIN
templates/backOffice/default/assets/img/flags/ck.png
Normal file
|
After Width: | Height: | Size: 331 B |
BIN
templates/backOffice/default/assets/img/flags/cl.png
Normal file
|
After Width: | Height: | Size: 150 B |
BIN
templates/backOffice/default/assets/img/flags/cm.png
Normal file
|
After Width: | Height: | Size: 163 B |
BIN
templates/backOffice/default/assets/img/flags/cn.png
Normal file
|
After Width: | Height: | Size: 310 B |
BIN
templates/backOffice/default/assets/img/flags/co.png
Normal file
|
After Width: | Height: | Size: 108 B |
BIN
templates/backOffice/default/assets/img/flags/cr.png
Normal file
|
After Width: | Height: | Size: 110 B |
BIN
templates/backOffice/default/assets/img/flags/cu.png
Normal file
|
After Width: | Height: | Size: 215 B |
BIN
templates/backOffice/default/assets/img/flags/cv.png
Normal file
|
After Width: | Height: | Size: 138 B |
BIN
templates/backOffice/default/assets/img/flags/cw.png
Normal file
|
After Width: | Height: | Size: 191 B |
BIN
templates/backOffice/default/assets/img/flags/cx.png
Normal file
|
After Width: | Height: | Size: 390 B |
BIN
templates/backOffice/default/assets/img/flags/cy.png
Normal file
|
After Width: | Height: | Size: 364 B |
BIN
templates/backOffice/default/assets/img/flags/cz.png
Normal file
|
After Width: | Height: | Size: 221 B |
BIN
templates/backOffice/default/assets/img/flags/de.png
Normal file
|
After Width: | Height: | Size: 102 B |
BIN
templates/backOffice/default/assets/img/flags/dj.png
Normal file
|
After Width: | Height: | Size: 228 B |
BIN
templates/backOffice/default/assets/img/flags/dk.png
Normal file
|
After Width: | Height: | Size: 106 B |
BIN
templates/backOffice/default/assets/img/flags/dm.png
Normal file
|
After Width: | Height: | Size: 333 B |
BIN
templates/backOffice/default/assets/img/flags/do.png
Normal file
|
After Width: | Height: | Size: 142 B |
BIN
templates/backOffice/default/assets/img/flags/dz.png
Normal file
|
After Width: | Height: | Size: 309 B |
BIN
templates/backOffice/default/assets/img/flags/ec.png
Normal file
|
After Width: | Height: | Size: 264 B |
BIN
templates/backOffice/default/assets/img/flags/ee.png
Normal file
|
After Width: | Height: | Size: 102 B |
BIN
templates/backOffice/default/assets/img/flags/eg.png
Normal file
|
After Width: | Height: | Size: 199 B |
BIN
templates/backOffice/default/assets/img/flags/eh.png
Normal file
|
After Width: | Height: | Size: 248 B |
|
Before Width: | Height: | Size: 3.0 KiB |
BIN
templates/backOffice/default/assets/img/flags/en.png
Normal file
|
After Width: | Height: | Size: 353 B |
BIN
templates/backOffice/default/assets/img/flags/er.png
Normal file
|
After Width: | Height: | Size: 421 B |
|
Before Width: | Height: | Size: 3.0 KiB |
BIN
templates/backOffice/default/assets/img/flags/es.png
Normal file
|
After Width: | Height: | Size: 221 B |
BIN
templates/backOffice/default/assets/img/flags/et.png
Normal file
|
After Width: | Height: | Size: 420 B |
BIN
templates/backOffice/default/assets/img/flags/eu.png
Normal file
|
After Width: | Height: | Size: 316 B |
BIN
templates/backOffice/default/assets/img/flags/fi.png
Normal file
|
After Width: | Height: | Size: 103 B |
BIN
templates/backOffice/default/assets/img/flags/fj.png
Normal file
|
After Width: | Height: | Size: 387 B |
BIN
templates/backOffice/default/assets/img/flags/fk.png
Normal file
|
After Width: | Height: | Size: 344 B |
BIN
templates/backOffice/default/assets/img/flags/fm.png
Normal file
|
After Width: | Height: | Size: 198 B |
BIN
templates/backOffice/default/assets/img/flags/fo.png
Normal file
|
After Width: | Height: | Size: 122 B |
|
Before Width: | Height: | Size: 3.0 KiB |
BIN
templates/backOffice/default/assets/img/flags/fr.png
Normal file
|
After Width: | Height: | Size: 100 B |
BIN
templates/backOffice/default/assets/img/flags/ga.png
Normal file
|
After Width: | Height: | Size: 108 B |
BIN
templates/backOffice/default/assets/img/flags/gb.png
Normal file
|
After Width: | Height: | Size: 626 B |
BIN
templates/backOffice/default/assets/img/flags/gd.png
Normal file
|
After Width: | Height: | Size: 313 B |
BIN
templates/backOffice/default/assets/img/flags/ge.png
Normal file
|
After Width: | Height: | Size: 122 B |
BIN
templates/backOffice/default/assets/img/flags/gg.png
Normal file
|
After Width: | Height: | Size: 124 B |
BIN
templates/backOffice/default/assets/img/flags/gh.png
Normal file
|
After Width: | Height: | Size: 162 B |
BIN
templates/backOffice/default/assets/img/flags/gi.png
Normal file
|
After Width: | Height: | Size: 245 B |
BIN
templates/backOffice/default/assets/img/flags/gl.png
Normal file
|
After Width: | Height: | Size: 196 B |
BIN
templates/backOffice/default/assets/img/flags/gm.png
Normal file
|
After Width: | Height: | Size: 115 B |
BIN
templates/backOffice/default/assets/img/flags/gn.png
Normal file
|
After Width: | Height: | Size: 103 B |
BIN
templates/backOffice/default/assets/img/flags/gq.png
Normal file
|
After Width: | Height: | Size: 308 B |
BIN
templates/backOffice/default/assets/img/flags/gr.png
Normal file
|
After Width: | Height: | Size: 141 B |