create lang defaultBehavior form
This commit is contained in:
@@ -154,6 +154,7 @@
|
||||
|
||||
<form name="thelia.lang.update" class="Thelia\Form\Lang\LangUpdateForm"/>
|
||||
<form name="thelia.lang.create" class="Thelia\Form\Lang\LangCreateForm"/>
|
||||
<form name="thelia.lang.defaultBehavior" class="Thelia\Form\Lang\LangDefaultBehaviorForm"/>
|
||||
</forms>
|
||||
|
||||
|
||||
|
||||
@@ -949,6 +949,10 @@
|
||||
<default key="_controller">Thelia\Controller\Admin\LangController::deleteAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.languages.defaultBehavior" path="/admin/configuration/languages/defaultBehavior">
|
||||
<default key="_controller">Thelia\Controller\Admin\LangController::defaultBehaviorAction</default>
|
||||
</route>
|
||||
|
||||
|
||||
<!-- The default route, to display a template -->
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ use Thelia\Core\Security\Resource\AdminResources;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Form\Lang\LangCreateForm;
|
||||
use Thelia\Form\Lang\LangUpdateForm;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Model\LangQuery;
|
||||
|
||||
|
||||
@@ -49,7 +50,15 @@ class LangController extends BaseAdminController
|
||||
{
|
||||
if (null !== $response = $this->checkAuth(AdminResources::LANGUAGE, AccessManager::VIEW)) return $response;
|
||||
|
||||
return $this->render('languages');
|
||||
return $this->renderDefault();
|
||||
}
|
||||
|
||||
public function renderDefault(array $param = array())
|
||||
{
|
||||
return $this->render('languages', array_merge($param, array(
|
||||
'lang_without_translation' => ConfigQuery::getDefaultLangWhenNoTranslationAvailable(),
|
||||
'one_domain_per_lang' => ConfigQuery::read("one_domain_foreach_lang", false)
|
||||
)));
|
||||
}
|
||||
|
||||
public function updateAction($lang_id)
|
||||
@@ -104,7 +113,7 @@ class LangController extends BaseAdminController
|
||||
$error_msg = $e->getMessage();
|
||||
}
|
||||
|
||||
return $this->render('languages');
|
||||
return $this->renderDefault();
|
||||
}
|
||||
|
||||
protected function hydrateEvent($event,Form $form)
|
||||
@@ -187,7 +196,7 @@ class LangController extends BaseAdminController
|
||||
$this->getTranslator()->trans("%obj creation", array('%obj' => 'Lang')), $error_msg, $createForm, $ex);
|
||||
|
||||
// At this point, the form has error, and should be redisplayed.
|
||||
return $this->render('languages');
|
||||
return $this->renderDefault();
|
||||
|
||||
}
|
||||
|
||||
@@ -209,9 +218,14 @@ class LangController extends BaseAdminController
|
||||
$error_msg = $ex->getMessage();
|
||||
}
|
||||
|
||||
$this->render('languages', array(
|
||||
return $this->renderDefault(array(
|
||||
'error_delete_message' => $error_msg
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
public function defaultBehaviorAction()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
85
core/lib/Thelia/Form/Lang/LangDefaultBehaviorForm.php
Normal file
85
core/lib/Thelia/Form/Lang/LangDefaultBehaviorForm.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Form\Lang;
|
||||
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Component\Validator\Constraints\Range;
|
||||
use Thelia\Form\BaseForm;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
|
||||
/**
|
||||
* Class LangDefaultBehaviorForm
|
||||
* @package Thelia\Form\Lang
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class LangDefaultBehaviorForm extends BaseForm
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* in this function you add all the fields you need for your Form.
|
||||
* Form this you have to call add method on $this->formBuilder attribute :
|
||||
*
|
||||
* $this->formBuilder->add("name", "text")
|
||||
* ->add("email", "email", array(
|
||||
* "attr" => array(
|
||||
* "class" => "field"
|
||||
* ),
|
||||
* "label" => "email",
|
||||
* "constraints" => array(
|
||||
* new \Symfony\Component\Validator\Constraints\NotBlank()
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* ->add('age', 'integer');
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
->add('behavior', 'choice', array(
|
||||
'choices' => array(
|
||||
0 => Translator::getInstance()->trans("Strictly use the requested language"),
|
||||
1 => Translator::getInstance()->trans("Replace by the default language"),
|
||||
),
|
||||
'constraints' => array(
|
||||
new NotBlank()
|
||||
),
|
||||
'label' => Translator::getInstance()->trans("If a translation is missing or incomplete :"),
|
||||
'label_attr' => array(
|
||||
'for' => 'defaultBehavior-form'
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string the name of you form. This name must be unique
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'thelia_lang_defaultBehavior';
|
||||
}
|
||||
}
|
||||
@@ -91,24 +91,25 @@
|
||||
<div class="general-block-decorator">
|
||||
|
||||
<div class="title title-without-tabs">{intl l="Parameters"}</div>
|
||||
|
||||
<form action="" method="post">
|
||||
|
||||
{form name="thelia.lang.defaultBehavior"}
|
||||
<form action="{url path="/admin/configuration/languages/defaultBehavior"}" method="post">
|
||||
{form_field form=$form field="behavior"}
|
||||
<div class="form-group">
|
||||
<label for="" class="label-control">{intl l="If a translation is missing or incomplete :"}</label>
|
||||
<label for="{$label_attr.for}" class="label-control">{intl l="If a translation is missing or incomplete :"}</label>
|
||||
<div class="input-group">
|
||||
<select name="" id="" data-toggle="selectpicker">
|
||||
<option value="">Replace by the default language</option>
|
||||
<option value="">Strictly use the requested language</option>
|
||||
<select name="{$name}" id="{$label_attr.for}" data-toggle="selectpicker">
|
||||
{foreach $choices as $choice}
|
||||
<option value="{$choice->value}" {if $lang_without_translation == $choice->value}selected="selected"{/if}>{$choice->label}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
<div class="input-group-btn">
|
||||
<button type="submit" class="btn btn-default btn-primary"><span class="glyphicon glyphicon-check"></span></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/form_field}
|
||||
</form>
|
||||
|
||||
{/form}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
|
||||
Reference in New Issue
Block a user