diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index faf3b4241..1ecd8a649 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -63,6 +63,12 @@
+ + + + + + diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index af7c950af..18cb81abe 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -156,7 +156,20 @@ Thelia\Controller\Admin\ProductController::getAvailableRelatedContentAction xml|json + + + + Thelia\Controller\Admin\FolderController::indexAction + + + Thelia\Controller\Admin\FolderController::createAction + + + + Thelia\Controller\Admin\FolderController::updateAction + \d+ + diff --git a/core/lib/Thelia/Controller/Admin/FolderController.php b/core/lib/Thelia/Controller/Admin/FolderController.php new file mode 100644 index 000000000..dd2feb823 --- /dev/null +++ b/core/lib/Thelia/Controller/Admin/FolderController.php @@ -0,0 +1,46 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Controller\Admin; + +/** + * Class FolderController + * @package Thelia\Controller\Admin + * @author Manuel Raynaud + */ +class FolderController extends BaseAdminController +{ + public function indexAction() + { + if (null !== $response = $this->checkAuth("admin.folder.view")) return $response; + return $this->render("folders", array("display_folder" => 20)); + } + + public function updateAction($folder_id) + { + + return $this->render("folder-edit", array( + "folder_id" => $folder_id + )); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Form/ContentCreationForm.php b/core/lib/Thelia/Form/ContentCreationForm.php new file mode 100644 index 000000000..8d8c2d1ca --- /dev/null +++ b/core/lib/Thelia/Form/ContentCreationForm.php @@ -0,0 +1,63 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints\NotBlank; +use Thelia\Core\Translation\Translator; + +class ContentCreationForm extends BaseForm +{ + protected function buildForm($change_mode = false) + { + $this->formBuilder + ->add("title", "text", array( + "constraints" => array( + new NotBlank() + ), + "label" => "Content title *", + "label_attr" => array( + "for" => "title" + ) + )) + ->add("default_folder", "integer", array( + "constraints" => array( + new NotBlank() + ) + )) + ->add("locale", "text", array( + "constraints" => array( + new NotBlank() + ) + )) + ->add("visible", "integer", array( + "label" => Translator::getInstance()->trans("This content is online."), + "label_attr" => array("for" => "visible_create") + )) + ; + } + + public function getName() + { + return "thelia_content_creation"; + } +} diff --git a/core/lib/Thelia/Form/FolderCreationForm.php b/core/lib/Thelia/Form/FolderCreationForm.php new file mode 100644 index 000000000..ac7b10376 --- /dev/null +++ b/core/lib/Thelia/Form/FolderCreationForm.php @@ -0,0 +1,66 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints\NotBlank; +use Thelia\Core\Translation\Translator; + +class FolderCreationForm extends BaseForm +{ + protected function buildForm() + { + $this->formBuilder + ->add("title", "text", array( + "constraints" => array( + new NotBlank() + ), + "label" => Translator::getInstance()->trans("Folder title *"), + "label_attr" => array( + "for" => "title" + ) + )) + ->add("parent", "text", array( + "label" => Translator::getInstance()->trans("Parent folder *"), + "constraints" => array( + new NotBlank() + ), + "label_attr" => array("for" => "parent_create") + )) + ->add("locale", "text", array( + "constraints" => array( + new NotBlank() + ), + "label_attr" => array("for" => "locale_create") + )) + ->add("visible", "integer", array( + "label" => Translator::getInstance()->trans("This folder is online."), + "label_attr" => array("for" => "visible_create") + )) + ; + } + + public function getName() + { + return "thelia_folder_creation"; + } +} diff --git a/core/lib/Thelia/Form/FolderModificationForm.php b/core/lib/Thelia/Form/FolderModificationForm.php new file mode 100644 index 000000000..e075ea827 --- /dev/null +++ b/core/lib/Thelia/Form/FolderModificationForm.php @@ -0,0 +1,55 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints\GreaterThan; +use Thelia\Core\Translation\Translator; +use Symfony\Component\Validator\Constraints\NotBlank; + +class FolderModificationForm extends FolderCreationForm +{ + use StandardDescriptionFieldsTrait; + + protected function buildForm() + { + parent::buildForm(true); + + $this->formBuilder + ->add("id", "hidden", array("constraints" => array(new GreaterThan(array('value' => 0))))) + + ->add("url", "text", array( + "label" => Translator::getInstance()->trans("Rewriten URL *"), + "constraints" => array(new NotBlank()), + "label_attr" => array("for" => "rewriten_url") + )) + ; + + // Add standard description fields, excluding title and locale, which a re defined in parent class + $this->addStandardDescFields(array('title', 'locale')); + } + + public function getName() + { + return "thelia_folder_modification"; + } +} diff --git a/templates/admin/default/admin-layout.tpl b/templates/admin/default/admin-layout.tpl index 4cad798fb..8221fa90a 100644 --- a/templates/admin/default/admin-layout.tpl +++ b/templates/admin/default/admin-layout.tpl @@ -138,9 +138,9 @@ {/loop} - {loop name="menu-auth-content" type="auth" roles="ADMIN" permissions="admin.content.view"} -
  • - {intl l="Content"} + {loop name="menu-auth-content" type="auth" roles="ADMIN" permissions="admin.folders.view"} +
  • + {intl l="Folders"}
  • {/loop} diff --git a/templates/admin/default/folder-edit.html b/templates/admin/default/folder-edit.html new file mode 100644 index 000000000..6986a1e69 --- /dev/null +++ b/templates/admin/default/folder-edit.html @@ -0,0 +1,344 @@ +{extends file="admin-layout.tpl"} + +{block name="check-permissions"}admin.folder.view{/block} + +{block name="page-title"}{intl l='Edit folder'}{/block} + +{block name="main-content"} +
    +
    + + {* include file="includes/folder-breadcrumb.html" editing_category="true" *} + +
    + {loop name="folder_edit" type="folder" visible="*" id="{$folder_id}" backend_context="1" lang="$edit_language_id"} +
    +
    +
    + {intl l='Edit folder %title' title=$TITLE} +
    + +
    + + {if $HAS_PREVIOUS != 0} + + {else} + + {/if} + + + + {if $HAS_NEXT != 0} + + {else} + + {/if} +
    +
    + +
    +
    + + + +
    + +
    + +
    + + {form name="thelia.admin.folder.modification"} + + + {include file="includes/inner-form-toolbar.html" close_url="{url path='/admin/folders' folder_id=$folder_id}"} + + {* Be sure to get the folder ID, even if the form could not be validated *} + + + + + {form_hidden_fields form=$form} + + {form_field form=$form field='success_url'} + + {/form_field} + + {form_field form=$form field='locale'} + + {/form_field} + + {if $form_error}
    {$form_error_message}
    {/if} + + {include file="includes/standard-description-form-fields.html"} + + {form_field form=$form field='url'} +
    + + + +
    + {/form_field} + +
    +
    + {form_field form=$form field='parent'} +
    + + + + +
    + {/form_field} +
    + +
    + {form_field form=$form field='visible'} +
    + +
    + +
    +
    + {/form_field} +
    +
    + +
    +
    +
    +   +
    +

    {intl l='Colder created on %date_create. Last modification: %date_change' date_create="{format_date date=$CREATE_DATE}" date_change="{format_date date=$UPDATE_DATE}"}

    +
    +
    +
    +
    + + + {/form} +
    +
    + +
    +
    +
    + +
    + + + + + + + + + {module_include location='folder_contents_table_header'} + + + + + + + {loop name="assigned_contents" type="associated_content" folder="$folder_id" backend_context="1" lang="$edit_language_id"} + + + + + + {module_include location='folder_contents_table_row'} + + + + {/loop} + + {elseloop rel="assigned_contents"} + + + + {/elseloop} + +
    {intl l='ID'}{intl l='Attribute title'}{intl l="Actions"}
    {$ID} + {$TITLE} + +
    + {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.configuration.folder.content.delete"} + + + + {/loop} +
    +
    +
    + {intl l="This folder contains no contents"} +
    +
    +
    +
    + +
    +
    + +
    +
    + +
    +
    +
    +
    +
    +
    + {/loop} +
    +
    +
    + + +{* Delete related content confirmation dialog *} + +{capture "delete_content_dialog"} + + + + + +{/capture} + +{include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "delete_content_dialog" + dialog_title = {intl l="Remove related content"} + dialog_message = {intl l="Do you really want to remove this related content ?"} + + form_action = {url path='/admin/folders/related-content/delete'} + form_content = {$smarty.capture.delete_content_dialog nofilter} +} +{/block} + +{block name="javascript-initialization"} + +{/block} \ No newline at end of file diff --git a/templates/admin/default/folders.html b/templates/admin/default/folders.html new file mode 100644 index 000000000..e836770ab --- /dev/null +++ b/templates/admin/default/folders.html @@ -0,0 +1,626 @@ +{extends file="admin-layout.tpl"} + +{block name="page-title"}{intl l='Folders'}{/block} + +{block name="check-permissions"}admin.folders.view{/block} + +{block name="main-content"} +
    + +
    + + {* include file="includes/folder-breadcrumb.html" *} + + {module_include location='folders_top'} + +
    +
    +
    + + + + + {ifloop rel="folder_list"} + + + + + + + + + {module_include location='folder_list_header'} + + + + + + + + + + + {loop name="folder_list" type="folder" visible="*" parent=$folder_id order=$folder_order backend_context="1" lang=$lang_id} + + + + + + + + {module_include location='folder_list_row'} + + + + + + + + {/loop} + + {/ifloop} + + {elseloop rel="folder_list"} + + + + + + {/elseloop} +
    + {* display parent folder name, and get current folder ID *} + {loop name="folder_title" type="folder" visible="*" id=$folder_id} + {intl l="Folders in %fold" fold=$TITLE} + {$fold_id = $ID} + {/loop} + {elseloop rel="folder_title"} + {intl l="Top level folders"} + {/elseloop} + + {module_include location='folder_list_caption'} + + {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.folders.create"} + + + + {/loop} +
    + {admin_sortable_header + current_order=$folder_order + order='id' + reverse_order='id_reverse' + path={url path='/admin/folders' id_folder=$folder_id} + request_parameter_name='folder_order' + label="{intl l='ID'}" + } +   + {admin_sortable_header + current_order=$folder_order + order='alpha' + reverse_order='alpha_reverse' + path={url path='/admin/folders' id_folder=$folder_id} + request_parameter_name='folder_order' + label="{intl l='Folder title'}" + } + + {admin_sortable_header + current_order=$folder_order + order='visible' + reverse_order='visible_reverse' + path={url path='/admin/folders' id_folder=$folder_id} + request_parameter_name='folder_order' + label="{intl l='Online'}" + } + + {admin_sortable_header + current_order=$folder_order + order='manual' + reverse_order='manual_reverse' + path={url path='/admin/folders' id_folder=$folder_id} + request_parameter_name='folder_order' + label="{intl l='Position'}" + } + {intl l='Actions'}
    {$ID} + {loop type="image" name="folder_image" source="folder" source_id="$ID" limit="1" width="50" height="50" resize_mode="crop" backend_context="1"} + {$TITLE} + {/loop} + + + {$TITLE} + + + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.folders.edit"} +
    + +
    + {/loop} + + {elseloop rel="can_change"} +
    + +
    + {/elseloop} +
    + {admin_position_block + permission="admin.folders.edit" + path={url path='admin/folders/update-position' folder_id=$ID} + url_parameter="folder_id" + in_place_edit_class="folderPositionChange" + position=$POSITION + id=$ID + } + +
    + + + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.folders.edit"} + + {/loop} + + {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.folders.delete"} + + {/loop} +
    +
    +
    + {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.folders.create"} + {intl l="This folder has no sub-folders. To create a new one, click the + button above."} + {/loop} + + {elseloop rel="can_create"} + {intl l="This folder has no sub-folders."} + {/elseloop} +
    +
    +
    +
    +
    + +{* -- CONTENT MANAGEMENT ---------------------------------------------------- *} + +
    +
    +
    + + + + + {ifloop rel="content_list"} + + + + + + + + + + + + + + {loop name="content_list" type="content" visible="*" folder_default=$folder_id order=$content_order} + + + + + + {module_include location='content_list_row'} + + + + + + + + {/loop} + + {/ifloop} + + {elseloop rel="content_list"} + + + + + + {/elseloop} +
    + {* display parent folder name *} + {loop name="folder_title" type="folder" visible="*" id=$folder_id} + {intl l="Contents in %fold" fold=$TITLE} + {/loop} + + {elseloop rel="folder_title"} + {intl l="Top level Contents"} + {/elseloop} + + {module_include location='content_list_caption'} + + + + +
    + {admin_sortable_header + current_order=$content_order + order='id' + reverse_order='id_reverse' + path={url path='/admin/folders' id_folder=$folder_id target='contents'} + label="{intl l='ID'}" + } + +   + {admin_sortable_header + current_order=$content_order + order='alpha' + reverse_order='alpha_reverse' + path={url path='/admin/folders' id_folder=$folder_id target='contents'} + label="{intl l='Content title'}" + } + + {module_include location='content_list_header'} + + + {admin_sortable_header + current_order=$content_order + order='visible' + reverse_order='visible_reverse' + path={url path='/admin/folders' id_folder=$folder_id target='contents'} + label="{intl l='Online'}" + } + + {admin_sortable_header + current_order=$content_order + order='manual' + reverse_order='manual_reverse' + path={url path='/admin/folders' id_folder=$folder_id target='contents'} + label="{intl l='Position'}" + } +  
    {$ID} + {loop type="image" name="folder_image" source="content" source_id="$ID" limit="1" width="50" height="50" resize_mode="crop" backend_context="1"} + + {$TITLE} + + {/loop} + + {$TITLE} + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.contents.edit"} +
    + +
    + {/loop} + + {elseloop rel="can_change"} +
    + +
    + {/elseloop} +
    + {admin_position_block + permission="admin.content.edit" + path={url path='/admin/contents/update-position' content_id=$ID} + url_parameter="content_id" + in_place_edit_class="contentPositionChange" + position=$POSITION + id=$ID + } + +
    + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.content.edit"} + + {/loop} + + {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.content.delete"} + + {/loop} +
    +
    {intl l="This folder doesn't contains any contents. To add a new content, click the + button above."}
    + + +
    +
    +
    + + {module_include location='folders_bottom'} + +
    + +
    + + +{* -- Adding a new folder ------------------------------------------------- *} + +{form name="thelia.admin.folder.creation"} + + {* Capture the dialog body, to pass it to the generic dialog *} + {capture "folder_creation_dialog"} + + {form_hidden_fields form=$form} + + {form_field form=$form field='success_url'} + {* on success, redirect to the edition page, _ID_ is replaced with the created object ID, see controller *} + + {/form_field} + + {form_field form=$form field='parent'} + + {/form_field} + + {form_field form=$form field='title'} +
    + + {loop type="lang" name="default-lang" default_only="1"} +
    + + $TITLE +
    + +
    {intl l='Enter here the folder name in the default language (%title)' title="$TITLE"}
    + + {* Switch edition to the current locale *} + + + {form_field form=$form field='locale'} + + {/form_field} + {/loop} +
    + {/form_field} + + {form_field form=$form field='visible'} +
    +
    + +
    +
    + {/form_field} + + {module_include location='folder_create_form'} + + {/capture} + + {include + file = "includes/generic-create-dialog.html" + + dialog_id = "folder_creation_dialog" + dialog_title = {intl l="Create a new folder"} + dialog_body = {$smarty.capture.folder_creation_dialog nofilter} + + dialog_ok_label = {intl l="Create this folder"} + + form_action = {url path='/admin/folders/create'} + form_enctype = {form_enctype form=$form} + form_error_message = $form_error_message + } +{/form} + +{* -- Adding a new content -------------------------------------------------- *} + +{form name="thelia.admin.content.creation"} + + {* Capture the dialog body, to pass it to the generic dialog *} + {capture "content_creation_dialog"} + + {form_hidden_fields form=$form} + + {* Be sure to get the folder_id, even if the form could not be validated *} + + + {form_field form=$form field='success_url'} + {* on success, redirect to the edition page, _ID_ is replaced with the created object ID, see controller *} + + {/form_field} + + {form_field form=$form field='default_folder'} + + {/form_field} + + {form_field form=$form field='title'} +
    + + {loop type="lang" name="default-lang" default_only="1"} +
    + + $TITLE +
    + +
    {intl l='Enter here the content name in the default language (%title)' title="$TITLE"}
    + + {* Switch edition to the current locale *} + + + {form_field form=$form field='locale'} + + {/form_field} + {/loop} +
    + {/form_field} + + {form_field form=$form field='visible'} +
    +
    + +
    +
    + {/form_field} + + {module_include location='content_create_form'} + + {/capture} + + {include + file = "includes/generic-create-dialog.html" + + dialog_id = "content_creation_dialog" + dialog_title = {intl l="Create a new content"} + dialog_body = {$smarty.capture.content_creation_dialog nofilter} + + dialog_ok_label = {intl l="Create this content"} + + form_action = {url path='/admin/contents/create'} + form_enctype = {form_enctype form=$form} + form_error_message = $form_error_message + } +{/form} + +{* -- Delete folder confirmation dialog ----------------------------------- *} + +{capture "folder_delete_dialog"} + + + {module_include location='folder_delete_form'} + +{/capture} + +{include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "folder_delete_dialog" + dialog_title = {intl l="Delete folder"} + dialog_message = {intl l="Do you really want to delete this folder and all its content ?"} + + form_action = {url path='/admin/folders/delete'} + form_content = {$smarty.capture.folder_delete_dialog nofilter} +} + +{* -- Delete content confirmation dialog ------------------------------------ *} + +{capture "content_delete_dialog"} + + + + {module_include location='content_delete_form'} + +{/capture} + +{include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "content_delete_dialog" + dialog_title = {intl l="Delete content"} + dialog_message = {intl l="Do you really want to delete this content ?"} + + form_action = {url path='/admin/contents/delete'} + form_content = {$smarty.capture.content_delete_dialog nofilter} +} +{/block} + +{block name="javascript-initialization"} + + {javascripts file='assets/js/bootstrap-switch/bootstrap-switch.js'} + + {/javascripts} + + {javascripts file='assets/js/bootstrap-editable/bootstrap-editable.js'} + + {/javascripts} + + +{/block} \ No newline at end of file diff --git a/templates/admin/default/includes/folder-breadcrumb.html b/templates/admin/default/includes/folder-breadcrumb.html new file mode 100644 index 000000000..4319ba5ff --- /dev/null +++ b/templates/admin/default/includes/folder-breadcrumb.html @@ -0,0 +1,26 @@ +{* Breadcrumb for folders browsing and editing *} + + \ No newline at end of file