diff --git a/local/modules/Recettes/Config/config.xml b/local/modules/Recettes/Config/config.xml index adaf1e24..4227f83d 100644 --- a/local/modules/Recettes/Config/config.xml +++ b/local/modules/Recettes/Config/config.xml @@ -4,47 +4,14 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/thelia-1.0.xsd"> - - - - - +
- - - - - - - - - - - diff --git a/local/modules/Recettes/Config/module.xml b/local/modules/Recettes/Config/module.xml index 1acc4471..58c50b28 100644 --- a/local/modules/Recettes/Config/module.xml +++ b/local/modules/Recettes/Config/module.xml @@ -4,18 +4,11 @@ xsi:schemaLocation="http://thelia.net/schema/dic/module http://thelia.net/schema/dic/module/module-2_2.xsd"> Recettes\Recettes - Automatically generated module - please update module.xml file - + Esay way to display a recipe using Thelia's content feature - Module généré automatiquement - éditez le fichier module.xml + Permet de mettre ne page facilement une recette de cuisine via les contenus Thelia - - en_US fr_FR @@ -23,19 +16,11 @@ - - + Laurent LE CORRE + laurent@thecoredev.fr classic - 2.4.3 other 0 diff --git a/local/modules/Recettes/Config/routing.xml b/local/modules/Recettes/Config/routing.xml index 075d4c35..8472776c 100644 --- a/local/modules/Recettes/Config/routing.xml +++ b/local/modules/Recettes/Config/routing.xml @@ -4,28 +4,8 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd"> - - diff --git a/local/modules/Recettes/Controller/MainController.php b/local/modules/Recettes/Controller/MainController.php new file mode 100755 index 00000000..ad865411 --- /dev/null +++ b/local/modules/Recettes/Controller/MainController.php @@ -0,0 +1,60 @@ +validateForm($form); + $data = $formValidate->getData(); + + $content_id = $data['content_id']; + $title = $data['title']; + $difficulty = $data['difficulty']; + $numberPeople = $data['people']; + $preparationTime = $data['preparation_time']; + $cookingTime = $data['cooking_time']; + $steps = $data['steps']; + + if (null !== $title && null !== $preparationTime) { + $content = ContentI18nQuery::create()->filterByLocale('fr_FR')->findOneById($content_id); + + $encodedData = json_encode($data); + $content->setDescription($encodedData); + $content->save($con); + $con->commit(); + } + } catch (\Exception $e) { + $error = $e->getMessage(); + } + + return new RedirectResponse(URL::getInstance()->absoluteUrl("/admin/content/update/" . $content_id)); + } + +} diff --git a/local/modules/Recettes/Form/RecetteCreateForm.php b/local/modules/Recettes/Form/RecetteCreateForm.php new file mode 100644 index 00000000..2704cf6d --- /dev/null +++ b/local/modules/Recettes/Form/RecetteCreateForm.php @@ -0,0 +1,131 @@ +formBuilder + ->add( + "content_id", + "integer", + [ + "label" => $this->trans("Content Id"), + "constraints" => [ + new NotBlank() + ] + ] + ) + ->add( + "title", + "text", + [ + "label" => $this->trans("Title"), + "label_attr" => [ + "for" => "attr-title" + ], + "constraints" => [ + new NotBlank() + ] + ] + ) + ->add( + "difficulty", + "integer", + [ + "label" => $this->trans("Difficulty"), + "label_attr" => [ + "for" => "attr-difficulty" + ], + "constraints" => [ + new NotBlank() + ] + ] + ) + ->add( + "people", + "integer", + [ + "label" => $this->trans("Number of people"), + "label_attr" => [ + "for" => "attr-difficulty" + ], + "constraints" => [ + new NotBlank() + ] + ] + ) + ->add( + "preparation_time", + "text", + [ + "label" => $this->trans("Preparation time"), + "label_attr" => [ + "for" => "attr-preparation-time", + "help" => "ex : 1h15 ou 45 minutes" + ], + "constraints" => [ + new NotBlank() + ] + ] + ) + ->add( + "cooking_time", + "text", + [ + "label" => $this->trans("Cooking time"), + "label_attr" => [ + "for" => "attr-cooking-time", + "help" => "ex : 1h15 ou 45 minutes" + ], + "required" => false + ] + ) + ->add( + "steps", + "text", + [ + "label" => $this->trans("Steps"), + "label_attr" => [ + "for" => "attr-recipe" + ], + "constraints" => [ + new NotBlank() + ] + ] + ); + } + + + protected function trans($id, $parameters = []) + { + if (null === $this->translator) { + $this->translator = Translator::getInstance(); + } + + return $this->translator->trans($id, $parameters, Recettes::MESSAGE_DOMAIN); + } +} diff --git a/local/modules/Recettes/Hook/HookManager.php b/local/modules/Recettes/Hook/HookManager.php new file mode 100644 index 00000000..ac3ed7c5 --- /dev/null +++ b/local/modules/Recettes/Hook/HookManager.php @@ -0,0 +1,28 @@ +add( + [ + "id" => 'admin-comment', + "title" => 'Recette', + "content" => ($this->render('recette.html')) + ] + ); + + } + +} \ No newline at end of file diff --git a/local/modules/Recettes/I18n/fr_FR.php b/local/modules/Recettes/I18n/fr_FR.php index 37086245..d95dc47e 100644 --- a/local/modules/Recettes/I18n/fr_FR.php +++ b/local/modules/Recettes/I18n/fr_FR.php @@ -1,4 +1,11 @@ 'La traduction française de la chaine', + 'Steps' => 'Préparation', + 'Title' => 'Titre de la recette', + 'Preparation time' => 'Temps de préparation', + 'Cooking time' => 'Temps de cuisson', + 'Difficulty' => 'Difficulté', + 'Number of people' => 'Nombre de personnes', + 'Product' => 'Produit', + 'Quantity' => 'Quantité', ); diff --git a/local/modules/Recettes/Recettes.php b/local/modules/Recettes/Recettes.php index 9cac1ca3..ace105e7 100644 --- a/local/modules/Recettes/Recettes.php +++ b/local/modules/Recettes/Recettes.php @@ -1,14 +1,4 @@ +
+ {form name="recette_create_form"} + + + {form_hidden_fields form=$form} + + {form_field form=$form field="content_id"} + + {/form_field} + +
+ + {form_field form=$form field="title"} +
+ + +   +
+ {form_error form=$form field="title"}{$message}{/form_error} + {/form_field} + + + {form_field form=$form field="difficulty"} +
+ + + +
+ {form_error form=$form field="difficulty"}{$message}{/form_error} + {/form_field} + + + {form_field form=$form field="people"} +
+ +   +
+ {form_error form=$form field="people"}{$message}{/form_error} + {/form_field} + + + {form_field form=$form field="preparation_time"} +
+ +   + {$label_attr.help} +
+ {form_error form=$form field="preparation_time"}{$message}{/form_error} + {/form_field} + + + {form_field form=$form field="cooking_time"} +
+ +   + {$label_attr.help} +
+ {form_error form=$form field="cooking_time"}{$message}{/form_error} + {/form_field} + + {form_field form=$form field="steps"} +
+ + {if $required}*{/if} + +
+ {form_error form=$form field="steps"}{$message}{/form_error} + {/form_field} +
+ +
+ + + + + + +
{intl l="Product" d="recettes"}{intl l="Quantity" d="recettes"}
+
+ + +
+ +
+ + {/form} +
+ \ No newline at end of file diff --git a/local/modules/Recettes/templates/backOffice/recette.html b/local/modules/Recettes/templates/backOffice/recette.html deleted file mode 100644 index 69853608..00000000 --- a/local/modules/Recettes/templates/backOffice/recette.html +++ /dev/null @@ -1,10 +0,0 @@ -
-
- {render_form_field field='titre'} - {render_form_field field='difficulte'} - {render_form_field field='temps_preparation'} - {render_form_field field='temps_cuisson'} - {render_form_field field='ingredients'} - {render_form_field field="description" extra_class="wysiwyg"} -
-
\ No newline at end of file diff --git a/templates/backOffice/custom/content-edit.html b/templates/backOffice/custom/content-edit.html index a197ae47..fd82dfab 100644 --- a/templates/backOffice/custom/content-edit.html +++ b/templates/backOffice/custom/content-edit.html @@ -9,15 +9,6 @@ {block name="page-title"}{intl l='Edit content'}{/block} -{assign var="recette" value=false} -{loop name="my_folder_path" type="folder-path" visible="*" folder=$folder_id} - {if $TITLE|strstr:"recettes"} - {assign var="recette" value=true} - {/if} -{/loop} - - - {block name="main-content"}
@@ -92,9 +83,6 @@
  • {intl l="Documents"}
  • {$smarty.capture.content_tab_tab nofilter}
  • {intl l="Modules"}
  • - {if $recette} -
  • {intl l="Recette"}
  • - {/if}
    @@ -224,12 +212,6 @@ {* ugly fix : {hook name="content.tab-content" id="{$content_id}" view="content"} *} {include file="includes/module-tab-content.html" hook="content.tab-content" location="content-edit" id="{$content_id}" view="content"}
    - - {if $recette} -
    - {hook name="hook-recette" content_id=$content_id} -
    - {/if}