diff --git a/core/lib/Thelia/Controller/Admin/CategoryController.php b/core/lib/Thelia/Controller/Admin/CategoryController.php index 6acbbd707..5eca91cf9 100755 --- a/core/lib/Thelia/Controller/Admin/CategoryController.php +++ b/core/lib/Thelia/Controller/Admin/CategoryController.php @@ -37,6 +37,7 @@ use Thelia\Model\Lang; use Thelia\Core\Translation\Translator; use Thelia\Core\Event\CategoryUpdatePositionEvent; use Thelia\Model\CategoryQuery; +use Thelia\Form\CategoryModificationForm; class CategoryController extends BaseAdminController { @@ -46,13 +47,10 @@ class CategoryController extends BaseAdminController * @return Symfony\Component\HttpFoundation\Response the response */ protected function renderList() { - - $args = $this->setupArgs(); - - return $this->render('categories', $args); + return $this->render('categories', $this->getTemplateArgs()); } - protected function setupArgs() { + protected function getTemplateArgs() { // Get the category ID $category_id = $this->getRequest()->get('category_id', 0); @@ -164,8 +162,14 @@ class CategoryController extends BaseAdminController // Prepare the data that will hydrate the form $data = array( 'id' => $category->getId(), - 'name' => $category->getTitle(), 'locale' => $category->getLocale(), + 'title' => $category->getTitle(), + 'chapo' => $category->getChapo(), + 'description' => $category->getDescription(), + 'postscriptum' => $category->getPostscriptum(), + 'parent' => $category->getParent(), + 'visible' => $category->getVisible() ? true : false, + 'url' => $category->getUrl($this->getCurrentEditionLocale()) // tbc !!! ); @@ -177,7 +181,7 @@ class CategoryController extends BaseAdminController } // Render the edition template. - return $this->render('category-edit', array('category_id' => $this->getRequest()->get('category_id'))); + return $this->render('category-edit', $this->getTemplateArgs()); } /** diff --git a/core/lib/Thelia/Core/Template/Assets/AsseticHelper.php b/core/lib/Thelia/Core/Template/Assets/AsseticHelper.php index bf0b7450e..cd7f06ac8 100755 --- a/core/lib/Thelia/Core/Template/Assets/AsseticHelper.php +++ b/core/lib/Thelia/Core/Template/Assets/AsseticHelper.php @@ -126,7 +126,7 @@ class AsseticHelper // // before generating 3bc974a-ad3ef47.css, delete 3bc974a-* files. // - if (/*$dev_mode == true || */! file_exists($target_file)) { + if ($dev_mode == true || ! file_exists($target_file)) { // Delete previous version of the file list($commonPart, $dummy) = explode('-', $asset_target_path); diff --git a/core/lib/Thelia/Form/BaseDescForm.php b/core/lib/Thelia/Form/CategoryModificationForm.php similarity index 61% rename from core/lib/Thelia/Form/BaseDescForm.php rename to core/lib/Thelia/Form/CategoryModificationForm.php index 2b35f3e6e..a27389324 100644 --- a/core/lib/Thelia/Form/BaseDescForm.php +++ b/core/lib/Thelia/Form/CategoryModificationForm.php @@ -23,51 +23,33 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints\NotBlank; +use Thelia\Model\LangQuery; +use Propel\Runtime\ActiveQuery\Criteria; +use Symfony\Component\Validator\Constraints\GreaterThan; +use Thelia\Core\Translation\Translator; -/** - * A base form for all objects with standard contents. - * - * @author Franck Allimant - */ -abstract class BaseDescForm extends BaseForm +class CategoryModificationForm extends CategoryCreationForm { + use StandardDescriptionFieldsTrait; + protected function buildForm() { + parent::buildForm(true); + $this->formBuilder - ->add("locale", "hidden", array( - "constraints" => array( - new NotBlank() - ) - ) - ) - ->add("title", "text", array( - "constraints" => array( - new NotBlank() - ), - "label" => "Title", - "label_attr" => array( - "for" => "title" - ) - ) - ) - ->add("chapo", "text", array( - "label" => "Summary", - "label_attr" => array( - "for" => "summary" - ) - )) - ->add("description", "text", array( - "label" => "Detailed description", - "label_attr" => array( - "for" => "detailed_description" - ) - )) - ->add("postscriptum", "text", array( - "label" => "Conclusion", - "label_attr" => array( - "for" => "conclusion" - ) + ->add("id", "hidden", array("constraints" => array(new GreaterThan(array('value' => 0))))) + + ->add("visible", "checkbox", array( + "label" => Translator::getInstance()->trans("This category is online on the front office.") )) ; - } + + // Add standard description fields + $this->addStandardDescFields(array('title', 'locale')); + } + + public function getName() + { + return "thelia_category_modification"; + } } \ No newline at end of file diff --git a/core/lib/Thelia/Form/ConfigModificationForm.php b/core/lib/Thelia/Form/ConfigModificationForm.php index 295c0403d..ce508137f 100644 --- a/core/lib/Thelia/Form/ConfigModificationForm.php +++ b/core/lib/Thelia/Form/ConfigModificationForm.php @@ -27,12 +27,12 @@ use Thelia\Model\LangQuery; use Propel\Runtime\ActiveQuery\Criteria; use Symfony\Component\Validator\Constraints\GreaterThan; -class ConfigModificationForm extends BaseDescForm +class ConfigModificationForm extends BaseForm { + use StandardDescriptionFieldsTrait; + protected function buildForm() { - parent::buildForm(true); - $this->formBuilder ->add("id", "hidden", array( "constraints" => array( @@ -61,6 +61,9 @@ class ConfigModificationForm extends BaseDescForm "label" => "Prevent variable modification or deletion, except for super-admin" )) ; + + // Add standard description fields + $this->addStandardDescFields(); } public function getName() diff --git a/core/lib/Thelia/Form/StandardDescriptionFieldsTrait.php b/core/lib/Thelia/Form/StandardDescriptionFieldsTrait.php index 98bc53b08..7c0a51a31 100644 --- a/core/lib/Thelia/Form/StandardDescriptionFieldsTrait.php +++ b/core/lib/Thelia/Form/StandardDescriptionFieldsTrait.php @@ -24,35 +24,69 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints\NotBlank; +use Thelia\Core\Translation\Translator; + /** - * This form defines all standard description fields: - * - title - * - chapo - * - description - * - postscriptum + * A trait to add standard localized description fields to a form. * * @author Franck Allimant */ -Trait StandardDescriptionFieldsTrait +trait StandardDescriptionFieldsTrait { - protected function addStandardDescriptionFields() + /** + * Add standard description fields + locale tot the form + * + * @param array $exclude name of the fields that should not be added to the form + */ + protected function addStandardDescFields($exclude = array()) { - $this->formBuilder - ->add("locale", "hidden", array( + if (! in_array('locale', $exclude)) + $this->formBuilder + ->add("locale", "hidden", array( + "constraints" => array( + new NotBlank() + ) + ) + ); + + if (! in_array('title', $exclude)) + $this->formBuilder + ->add("title", "text", array( "constraints" => array( new NotBlank() + ), + "label" => Translator::getInstance()->trans("Title"), + "label_attr" => array( + "for" => "title" ) ) - ) - ->add("title", "text", array( - "constraints" => array( - new NotBlank() + ); + + if (! in_array('chapo', $exclude)) + $this->formBuilder + ->add("chapo", "text", array( + "label" => Translator::getInstance()->trans("Summary"), + "label_attr" => array( + "for" => "summary" ) - ) - ) - ->add("chapo", "text", array()) - ->add("description", "text", array()) - ->add("postscriptum", "text", array()) - ; + )); + + if (! in_array('description', $exclude)) + $this->formBuilder + ->add("description", "text", array( + "label" => Translator::getInstance()->trans("Detailed description"), + "label_attr" => array( + "for" => "detailed_description" + ) + )); + + if (! in_array('postscriptum', $exclude)) + $this->formBuilder + ->add("postscriptum", "text", array( + "label" => Translator::getInstance()->trans("Conclusion"), + "label_attr" => array( + "for" => "conclusion" + ) + )); } } \ No newline at end of file diff --git a/templates/admin/default/admin-layout.tpl b/templates/admin/default/admin-layout.tpl index f968bb6df..58cad9108 100644 --- a/templates/admin/default/admin-layout.tpl +++ b/templates/admin/default/admin-layout.tpl @@ -18,7 +18,7 @@ {* -- Bootstrap CSS section --------------------------------------------- *} {block name="before-bootstrap-css"}{/block} - + {stylesheets file='assets/less/*' filters='less,cssembed'} {/stylesheets} @@ -47,15 +47,15 @@
- +
{intl l='Version %ver' ver="{$THELIA_VERSION}"}
- {module_include location='inside_topbar'} - -
+ {module_include location='inside_topbar'} + +
- +
@@ -82,7 +82,7 @@ {module_include location='before_top_menu'}