WIP : Setting Folders management

This commit is contained in:
mespeche
2013-09-18 15:38:08 +02:00
parent 742b90b24c
commit 25becbe0cc
10 changed files with 1248 additions and 3 deletions

View File

@@ -63,6 +63,12 @@
<form name="thelia.admin.product.creation" class="Thelia\Form\ProductCreationForm"/>
<form name="thelia.admin.product.deletion" class="Thelia\Form\ProductModificationForm"/>
<form name="thelia.admin.folder.creation" class="Thelia\Form\FolderCreationForm"/>
<form name="thelia.admin.folder.modification" class="Thelia\Form\FolderModificationForm"/>
<form name="thelia.admin.content.creation" class="Thelia\Form\ContentCreationForm"/>
<form name="thelia.admin.content.modification" class="Thelia\Form\ContentModificationForm"/>
<form name="thelia.cart.add" class="Thelia\Form\CartAdd"/>
<form name="thelia.order.delivery" class="Thelia\Form\OrderDelivery"/>

View File

@@ -156,7 +156,20 @@
<default key="_controller">Thelia\Controller\Admin\ProductController::getAvailableRelatedContentAction</default>
<requirement key="_format">xml|json</requirement>
</route>
<!-- Folder routes management -->
<route id="admin.folders.default" path="/admin/folders">
<default key="_controller">Thelia\Controller\Admin\FolderController::indexAction</default>
</route>
<route id="admin.folders.create" path="/admin/folders/create">
<default key="_controller">Thelia\Controller\Admin\FolderController::createAction</default>
</route>
<route id="admin.folders.update" path="/admin/folders/update/{folder_id}" methods="get">
<default key="_controller">Thelia\Controller\Admin\FolderController::updateAction</default>
<requirement key="folder_id">\d+</requirement>
</route>
<!-- Route to the Coupon controller (process Coupon browsing) -->

View File

@@ -0,0 +1,46 @@
<?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\Controller\Admin;
/**
* Class FolderController
* @package Thelia\Controller\Admin
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
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
));
}
}

View File

@@ -0,0 +1,63 @@
<?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;
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";
}
}

View File

@@ -0,0 +1,66 @@
<?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;
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";
}
}

View File

@@ -0,0 +1,55 @@
<?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;
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";
}
}

View File

@@ -138,9 +138,9 @@
</li>
{/loop}
{loop name="menu-auth-content" type="auth" roles="ADMIN" permissions="admin.content.view"}
<li class="{if $admin_current_location == 'content'}active{/if}" id="content_menu">
<a href="{url path='/admin/content'}">{intl l="Content"}</a>
{loop name="menu-auth-content" type="auth" roles="ADMIN" permissions="admin.folders.view"}
<li class="{if $admin_current_location == 'folder'}active{/if}" id="folders_menu">
<a href="{url path='/admin/folders'}">{intl l="Folders"}</a>
</li>
{/loop}

View File

@@ -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"}
<div class="folder edit-folder">
<div id="wrapper" class="container">
{* include file="includes/folder-breadcrumb.html" editing_category="true" *}
<div class="row">
{loop name="folder_edit" type="folder" visible="*" id="{$folder_id}" backend_context="1" lang="$edit_language_id"}
<div class="col-md-12 general-block-decorator">
<div class="row">
<div class="col-md-7 title">
{intl l='Edit folder %title' title=$TITLE}
</div>
<div class="col-md-5 actions">
{if $HAS_PREVIOUS != 0}
<a href="{url path='/admin/folders/update' folder_id=$PREVIOUS}" class="btn btn-default" title="{intl l='Edit previous folder'}"><span class="glyphicon glyphicon-arrow-left"></span></a>
{else}
<a href="#" disabled="disabled" class="btn btn-default"><span class="glyphicon glyphicon-arrow-left"></span></a>
{/if}
<a href="{$URL}" target="_blank" class="btn btn-default" title="{intl l='Preview folder page'}"><span class="glyphicon glyphicon-eye-open"></span></a>
{if $HAS_NEXT != 0}
<a href="{url path='/admin/folders/update' folder_id=$NEXT}" class="btn btn-default" title="{intl l='Edit next folder'}"><span class="glyphicon glyphicon-arrow-right"></span></a>
{else}
<a href="#" disabled="disabled" class="btn btn-default"><span class="glyphicon glyphicon-arrow-right"></span></a>
{/if}
</div>
</div>
<div class="row">
<div class="col-md-12">
<ul class="nav nav-tabs" id="tabbed-menu">
<li class="active"><a href="#general" data-toggle="tab">{intl l="General description"}</a></li>
<li><a href="#details" data-toggle="tab">{intl l="Details"}</a></li>
<li><a href="#images" data-toggle="tab">{intl l="Images"}</a></li>
<li><a href="#documents" data-toggle="tab">{intl l="Documents"}</a></li>
<li><a href="#modules" data-toggle="tab">{intl l="Modules"}</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane fade active in" id="general">
<div class="form-container">
{form name="thelia.admin.folder.modification"}
<form method="POST" action="{url path='/admin/folders/save'}" {form_enctype form=$form} class="clearfix">
{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 *}
<input type="hidden" name="folder_id" value="{$folder_id}" />
<input type="hidden" name="current_tab" value="general" />
{form_hidden_fields form=$form}
{form_field form=$form field='success_url'}
<input type="hidden" name="{$name}" value="{url path='/admin/folder' folder_id={$folder_id}}" />
{/form_field}
{form_field form=$form field='locale'}
<input type="hidden" name="{$name}" value="{$edit_language_locale}" />
{/form_field}
{if $form_error}<div class="alert alert-danger">{$form_error_message}</div>{/if}
{include file="includes/standard-description-form-fields.html"}
{form_field form=$form field='url'}
<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}" required="required" name="{$name}" value="{$value}" title="{intl l='Rewritten URL'}" placeholder="{intl l='Rewriten URL'}" class="form-control">
</div>
{/form_field}
<div class="row">
<div class="col-md-6">
{form_field form=$form field='parent'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">
{intl l="{$label}"} :
</label>
<select id="{$label_attr.for}" required="required" name="{$name}" class="form-control">
<option value="0">{intl l="Top level"}</option>
{$myparent=$PARENT}
{loop name="fold-parent" type="folder-tree" visible="*" folder="0"}
<option value="{$ID}" style="padding-left: {3 + $LEVEL * 20}px" {if $myparent == $ID}selected="selected"{/if} {if $folder_id == $ID}disabled="disabled"{/if}>{$TITLE}</option>
{/loop}
</select>
</div>
{/form_field}
</div>
<div class="col-md-6">
{form_field form=$form field='visible'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l='Visibility'}</label>
<div class="checkbox">
<label>
<input type="checkbox" id="{$label_attr.for}" name="{$name}" value="1" {if $value != 0}checked="checked"{/if}>
{$label}
</label>
</div>
</div>
{/form_field}
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="control-group">
<lablel>&nbsp;</lablel>
<div class="controls">
<p>{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}"}</p>
</div>
</div>
</div>
</div>
</form>
{/form}
</div>
</div>
<div class="tab-pane fade" id="details">
<div class="form-container">
<div class="form-group">
<form action="{url path='/admin/folders/related-content/add'}" id="related_content_form">
{include
file="includes/inner-form-toolbar.html"
hide_submit_buttons=true
close_url="{url path='/admin/folders' folder_id=$folder_id}"
}
<input type="hidden" name="folder_id" value="{$folder_id}" />
<input type="hidden" name="current_tab" value="details" />
{ifloop rel="folders"}
<div class="row">
<div class="col-md-6">
<div class="form-group">
<select name="folder_id" id="folder_id" class="form-control">
<option value="">Select a folder...</option>
{loop name="folders" type="folder" backend_context="1" lang="$edit_language_id"}
<option value="{$ID}">{$TITLE}</option>
{/loop}
</select>
</div>
<span class="help-block">{intl l='Select a folder to get its content'}</span>
</div>
<div class="col-md-6">
<div id="content_selector" class="hide">
<div class="input-group">
<select required="required" name="content_id" id="content_id" class="form-control">
<option value="">Select a folder content...</option>
</select>
<span class="input-group-btn" id="content_add_button">
<button class="btn btn-default btn-primary action-btn" type="submit"><span class="glyphicon glyphicon-plus-sign"></span></button>
</span>
</div>
<span class="help-block">{intl l='Select a content and click (+) to add it to this category'}</span>
</div>
</div>
</div>
{/ifloop}
{elseloop rel="folders"}
<div class="alert alert-info">{intl l="No folders found"}</div>
{/elseloop}
</form>
</div>
<table class="table table-striped table-condensed table-left-aligned">
<thead>
<tr>
<th>{intl l='ID'}</th>
<th>{intl l='Attribute title'}</th>
{module_include location='folder_contents_table_header'}
<th class="actions">{intl l="Actions"}</th>
</tr>
</thead>
<tbody>
{loop name="assigned_contents" type="associated_content" folder="$folder_id" backend_context="1" lang="$edit_language_id"}
<tr>
<td>{$ID}</td>
<td>
{$TITLE}
</td>
{module_include location='folder_contents_table_row'}
<td class="actions">
<div class="btn-group">
{loop type="auth" name="can_create" roles="ADMIN" permissions="admin.configuration.folder.content.delete"}
<a class="btn btn-default btn-xs delete-content" title="{intl l='Delete this content'}" href="#delete_content_dialog" data-id="{$ID}" data-toggle="modal">
<span class="glyphicon glyphicon-trash"></span>
</a>
{/loop}
</div>
</td>
</tr>
{/loop}
{elseloop rel="assigned_contents"}
<tr>
<td colspan="3">
<div class="alert alert-info">
{intl l="This folder contains no contents"}
</div>
</td>
</tr>
{/elseloop}
</tbody>
</table>
</div>
</div>
<div class="tab-pane fade" id="images">
</div>
<div class="tab-pane fade" id="documents">
</div>
<div class="tab-pane fade" id="modules">
</div>
</div>
</div>
</div>
</div>
{/loop}
</div>
</div>
</div>
{* Delete related content confirmation dialog *}
{capture "delete_content_dialog"}
<!-- <input type="hidden" name="category_id" value="{$category_id}" /> -->
<input type="hidden" name="content_id" id="content_delete_id" value="" />
<input type="hidden" name="folder_id" id="folder_delete_id" value="" />
<input type="hidden" name="current_tab" value="details" />
{/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"}
<script>
$(function() {
$('.use_default_rewriten_url').click(function(ev) {
alert("Not functionnal");
ev.preventDefault();
});
// Show proper tab, if defined
{if ! empty($current_tab)}
$('#tabbed-menu a[href="#{$current_tab}"]').tab('show')
{/if}
// Set proper content ID in delete content from
$('a.delete-content').click(function(ev) {
$('#content_delete_id').val($(this).data('id'));
$('#folder_delete_id').val($('#folder_id').val());
});
// Load content on folder selection
$('#folder_id').change(function(event) {
$.ajax({
url : '{url path="/admin/folder/$folder_id/available-related-content/"}' + $(this).val() + '.xml',
type : 'get',
dataType : 'json',
success : function(json) {
$('#content_id :not(:first-child)').remove();
var have_content = false;
$.each(json, function(idx, value) {
$('#content_id').append($('<option>').text(value.title).attr('value', value.id));
have_content = true; // Lame...
});
if (have_content)
$('#content_selector').removeClass('hide');
else
$('#content_selector').addClass('hide');
}
});
});
// Initialize folder (id={$folder_id}) select value
{if $folder_id != 0}
$('#folder_id').val("{$folder_id}").change();
{/if}
});
</script>
{/block}

View File

@@ -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"}
<div class="folders">
<div id="wrapper" class="container">
{* include file="includes/folder-breadcrumb.html" *}
{module_include location='folders_top'}
<div class="row">
<div class="col-md-12">
<div class="general-block-decorator">
<table class="table table-striped table-condensed" id="folder_list">
<caption>
{* 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"}
<a class="btn btn-default btn-primary action-btn" title="{intl l='Add a new folder'}" href="#folder_creation_dialog" data-toggle="modal">
<span class="glyphicon glyphicon-plus-sign"></span>
</a>
{/loop}
</caption>
{ifloop rel="folder_list"}
<thead>
<tr>
<th class="object-title">
{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'}"
}
</th>
<th class="object-image">&nbsp;</th>
<th class="object-title">
{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'}"
}
</th>
{module_include location='folder_list_header'}
<th>
{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'}"
}
</th>
<th>
{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'}"
}
</th>
<th class="actions">{intl l='Actions'}</th>
</tr>
</thead>
<tbody>
{loop name="folder_list" type="folder" visible="*" parent=$folder_id order=$folder_order backend_context="1" lang=$lang_id}
<tr>
<td>{$ID}</td>
<td>
{loop type="image" name="folder_image" source="folder" source_id="$ID" limit="1" width="50" height="50" resize_mode="crop" backend_context="1"}
<a href="{url path='admin/folder' folder_id=$ID}" title="{intl l='Browse this folder'}"><img class="img-thumbnail" src="{$IMAGE_URL}" alt="{$TITLE}" /></a>
{/loop}
</td>
<td class="object-title">
<a href="{url path='admin/folder' folder_id=$ID}" title="{intl l='Browse this folder'}">
{$TITLE}
</a>
</td>
{module_include location='folder_list_row'}
<td>
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.folders.edit"}
<div class="make-switch switch-small folderVisibleToggle" data-id="{$ID}" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
<input type="checkbox" class="folderVisibleToggle" {if $VISIBLE == 1}checked="checked"{/if}>
</div>
{/loop}
{elseloop rel="can_change"}
<div class="make-switch switch-small" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
<input type="checkbox" class="disabled" disabled="disabled" {if $VISIBLE == 1}checked="checked"{/if}>
</div>
{/elseloop}
</td>
<td>
{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
}
</td>
<td class="actions">
<div class="btn-group">
<a class="btn btn-default btn-xs" title="{intl l='Browse this folder'}" href="{url path='admin/folder' folder_id=$ID}"><i class="glyphicon glyphicon-folder-open"></i></a>
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.folders.edit"}
<a class="btn btn-default btn-xs" title="{intl l='Edit this folder'}" href="{url path='/admin/folders/update' folder_id=$ID}"><i class="glyphicon glyphicon-edit"></i></a>
{/loop}
{loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.folders.delete"}
<a class="btn btn-default btn-xs folder-delete" title="{intl l='Delete this folder and all its contents'}" href="#folder_delete_dialog" data-id="{$ID}" data-toggle="modal"><i class="glyphicon glyphicon-trash"></i></a>
{/loop}
</div>
</td>
</tr>
{/loop}
</tbody>
{/ifloop}
{elseloop rel="folder_list"}
<thead>
<tr>
<td class="message">
<div class="alert alert-info">
{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}
</div>
</td>
</tr>
</thead>
{/elseloop}
</table>
</div>
</div>
</div>
{* -- CONTENT MANAGEMENT ---------------------------------------------------- *}
<div class="row">
<div class="col-md-12">
<div class="general-block-decorator">
<table class="table table-striped table-condensed">
<caption>
{* 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'}
<a class="btn btn-default btn-primary action-btn" title="{intl l='Add a new content'}" href="#content_creation_dialog" data-toggle="modal">
<span class="glyphicon glyphicon-plus-sign"></span>
</a>
</caption>
{ifloop rel="content_list"}
<thead>
<tr>
<th class="object-title">
{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'}"
}
<th>&nbsp;</th>
<th class="object-title">
{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'}
<th>
{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'}"
}
</th>
<th>
{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'}"
}
</th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
{loop name="content_list" type="content" visible="*" folder_default=$folder_id order=$content_order}
<tr>
<td>{$ID}</td>
<td>
{loop type="image" name="folder_image" source="content" source_id="$ID" limit="1" width="50" height="50" resize_mode="crop" backend_context="1"}
<a href="{url path='admin/content/edit' id=$ID}" title="{intl l='Edit this content'}">
<img src="{$IMAGE_URL}" alt="{$TITLE}" />
</a>
{/loop}
<td class="object-title"><a href="{url path="/admin/content/update/$ID"}" title="{intl l='Edit this content'}">{$TITLE}</a></td>
{module_include location='content_list_row'}
<td>
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.contents.edit"}
<div class="make-switch switch-small contentVisibleToggle" data-id="{$ID}" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
<input type="checkbox" class="contentVisibleToggle" {if $VISIBLE == 1}checked="checked"{/if}>
</div>
{/loop}
{elseloop rel="can_change"}
<div class="make-switch switch-small" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
<input type="checkbox" class="disabled" disabled="disabled" {if $VISIBLE == 1}checked="checked"{/if}>
</div>
{/elseloop}
</td>
<td>
{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
}
</td>
<td>
<div class="btn-group">
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.content.edit"}
<a class="btn btn-default btn-xs" title="{intl l='Edit this content'}" href="{url path="admin/content/update/$ID"}"><i class="glyphicon glyphicon-edit"></i></a>
{/loop}
{loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.content.delete"}
<a class="btn btn-default btn-xs content-delete" title="{intl l='Delete this content'}" href="#content_delete_dialog" data-id="{$ID}" data-toggle="modal"><i class="glyphicon glyphicon-trash"></i></a>
{/loop}
</div>
</td>
</tr>
{/loop}
</tbody>
{/ifloop}
{elseloop rel="content_list"}
<thead>
<tr>
<td class="message"><div class="alert alert-info">{intl l="This folder doesn't contains any contents. To add a new content, <strong>click the + button</strong> above."}</div></td>
</tr>
</thead>
{/elseloop}
</table>
</div>
</div>
</div>
{module_include location='folders_bottom'}
</div>
</div>
{* -- 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 *}
<input type="hidden" name="{$name}" value="{url path='/admin/folders/update' folder_id='_ID_'}" />
{/form_field}
{form_field form=$form field='parent'}
<input type="hidden" name="{$name}" value="{$folder_id}" />
{/form_field}
{form_field form=$form field='title'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{$label} : </label>
{loop type="lang" name="default-lang" default_only="1"}
<div class="input-group">
<input type="text" id="{$label_attr.for}" required="required" name="{$name}" class="form-control" value="{$value}" title="{intl l='Folder title'}" placeholder="{intl l='Name'}">
<span class="input-group-addon"><img src="{image file="assets/img/flags/{$CODE}.gif"}" alt="$TITLE" /></span>
</div>
<div class="help-block">{intl l='Enter here the folder name in the default language (%title)' title="$TITLE"}</div>
{* Switch edition to the current locale *}
<input type="hidden" name="edit_language_id" value="{$ID}" />
{form_field form=$form field='locale'}
<input type="hidden" name="{$name}" value="{$LOCALE}" />
{/form_field}
{/loop}
</div>
{/form_field}
{form_field form=$form field='visible'}
<div class="form-group {if $error}has-error{/if}">
<div class="checkbox">
<label>
<input type="checkbox" id="{$label_attr.for}" name="{$name}" value="1" checked="checked">
{$label}
</label>
</div>
</div>
{/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 *}
<input type="hidden" name="folder_id" value="{$folder_id}" />
{form_field form=$form field='success_url'}
{* on success, redirect to the edition page, _ID_ is replaced with the created object ID, see controller *}
<input type="hidden" name="{$name}" value="{url path='/admin/contents/update' content_id='_ID_'}" />
{/form_field}
{form_field form=$form field='default_folder'}
<input type="hidden" name="{$name}" value="{$folder_id}" />
{/form_field}
{form_field form=$form field='title'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{$label} : </label>
{loop type="lang" name="default-lang" default_only="1"}
<div class="input-group">
<input type="text" id="{$label_attr.for}" required="required" name="{$name}" class="form-control" value="{$value}" title="{$label}" placeholder="{intl l='Title'}">
<span class="input-group-addon"><img src="{image file="assets/img/flags/{$CODE}.gif"}" alt="$TITLE" /></span>
</div>
<div class="help-block">{intl l='Enter here the content name in the default language (%title)' title="$TITLE"}</div>
{* Switch edition to the current locale *}
<input type="hidden" name="edit_language_id" value="{$ID}" />
{form_field form=$form field='locale'}
<input type="hidden" name="{$name}" value="{$LOCALE}" />
{/form_field}
{/loop}
</div>
{/form_field}
{form_field form=$form field='visible'}
<div class="form-group {if $error}has-error{/if}">
<div class="checkbox">
<label>
<input type="checkbox" id="{$label_attr.for}" name="{$name}" value="1" checked="checked">
{$label}
</label>
</div>
</div>
{/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"}
<input type="hidden" name="folder_id" id="folder_delete_id" value="" />
{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"}
<input type="hidden" name="content_id" id="content_delete_id" value="" />
<input type="hidden" name="folder_id" value="{$folder_id}" />
{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'}
<script src="{$asset_url}"></script>
{/javascripts}
{javascripts file='assets/js/bootstrap-editable/bootstrap-editable.js'}
<script src="{$asset_url}"></script>
{/javascripts}
<script>
$(function() {
// Set proper folder ID in delete from
$('a.folder-delete').click(function(ev) {
$('#folder_delete_id').val($(this).data('id'));
});
// Set proper content ID in delete from
$('a.content-delete').click(function(ev) {
$('#content_delete_id').val($(this).data('id'));
});
// JS stuff for creation form
{include
file = "includes/generic-js-dialog.html"
dialog_id = "folder_creation_dialog"
form_name = "thelia.admin.folder.creation"
}
{include
file = "includes/generic-js-dialog.html"
dialog_id = "content_creation_dialog"
form_name = "thelia.admin.content.creation"
}
{* Toggle object visibility *}
$(".folderVisibleToggle").on('switch-change', function(event, data) {
$.ajax({
url : "{url path='admin/folders/toggle-online'}",
data : {
folder_id : $(this).data('id'),
action : 'visibilityToggle'
}
});
});
$(".contentVisibleToggle").on('switch-change', function(event, data) {
$.ajax({
url : "{url path='admin/contents/toggle-online'}",
data : {
content_id : $(this).data('id'),
action : 'visibilityToggle'
}
});
});
{* Inline editing of object position using bootstrap-editable *}
$('.folderPositionChange').editable({
type : 'text',
title : '{intl l="Enter new folder position"}',
mode : 'popup',
inputclass : 'input-mini',
placement : 'left',
success : function(response, newValue) {
// The URL template
var url = "{url path='/admin/folders/update-position' folder_id='__ID__' position='__POS__'}";
// Perform subtitutions
url = url.replace('__ID__', $(this).data('id'))
.replace('__POS__', newValue);
// Reload the page
location.href = url;
}
});
$('.contentPositionChange').editable({
type : 'text',
title : '{intl l="Enter new content position"}',
mode : 'popup',
inputclass : 'input-mini',
placement : 'left',
success : function(response, newValue) {
// The URL template
var url = "{url path='/admin/contents/update-position' content_id='__ID__' position='__POS__'}";
// Perform subtitutions
url = url.replace('__ID__', $(this).data('id'))
.replace('__POS__', newValue);
// Reload the page
location.href = url;
}
});
{* Change default status *}
$('.change-default').change(function(ev) {
var url = "{url path='/admin/folders/set-default' folder_id='__ID__'}";
// Perform ID subtitutions
url = url.replace('__ID__', $(this).val());
// Reload the page
location.href = url;
});
});
</script>
{/block}

View File

@@ -0,0 +1,26 @@
{* Breadcrumb for folders browsing and editing *}
<ul class="breadcrumb">
<li><a href="{url path='admin/home'}">Home</a></li>
<li><a href="{url path='admin/folders'}">Folders</a>
{ifloop rel="folder_path"}</li>
{loop name="folder_path" type="folder-path" visible="*" folder=$folder_id}
{if $ID == $folder_id}
<li class="active">
{if $editing_folder == true}
{intl l='Editing %fold' fold="{$TITLE}"}
{else}
{$TITLE} <a href="{url path='/admin/folders/update' folder_id=$ID}" title="{intl l='Edit this folder'}">{intl l="(edit)"}</a>
{/if}
</li>
{else}
<li><a href="{url path='/admin/folders' folder_id=" $ID" action='browse'}">{$TITLE}</a></li>
{/if}
{/loop}
{/ifloop}
{elseloop rel="folder_path"}
</li>
{/elseloop}
</ul>