Conflicts:
	templates/admin/default/categories.html
	templates/admin/default/includes/add-category-dialog.html
	templates/admin/default/includes/delete-category-dialog.html
This commit is contained in:
franck
2013-09-06 16:18:54 +02:00
27 changed files with 851 additions and 628 deletions

View File

@@ -135,10 +135,19 @@
<default key="_controller">Thelia\Controller\Admin\CurrencyController::deleteAction</default> <default key="_controller">Thelia\Controller\Admin\CurrencyController::deleteAction</default>
</route> </route>
<route id="admin.configuration.currencies.update-position" path="/admin/configuration/currencies/update-position"> <route id="admin.configuration.attribute" path="/admin/configuration/product_attributes">
<default key="_controller">Thelia\Controller\Admin\AttributeController::defaultAction</default>
</route>
<!-- attribute and feature routes management -->
<route id="admin.configuration.currencies.update-position" path="/admin/configuration/product_attributes">
<default key="_controller">Thelia\Controller\Admin\CurrencyController::updatePositionAction</default> <default key="_controller">Thelia\Controller\Admin\CurrencyController::updatePositionAction</default>
</route> </route>
<!-- end attribute and feature routes management -->
<!-- The default route, to display a template --> <!-- The default route, to display a template -->
<route id="admin.processTemplate" path="/admin/{template}"> <route id="admin.processTemplate" path="/admin/{template}">

View File

@@ -0,0 +1,57 @@
<?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;
use Thelia\Core\Event\MessageDeleteEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Tools\URL;
use Thelia\Core\Event\MessageUpdateEvent;
use Thelia\Core\Event\MessageCreateEvent;
use Thelia\Log\Tlog;
use Thelia\Form\Exception\FormValidationException;
use Thelia\Core\Security\Exception\AuthorizationException;
use Thelia\Model\MessageQuery;
use Thelia\Form\MessageModificationForm;
use Thelia\Form\MessageCreationForm;
/**
* Manages messages sent by mail
*
* @author Franck Allimant <franck@cqfdev.fr>
*/
class AttributeController extends BaseAdminController
{
/**
* The default action is displaying the messages list.
*
* @return Symfony\Component\HttpFoundation\Response the response
*/
public function defaultAction() {
if (null !== $response = $this->checkAuth("admin.configuration.attributes.view")) return $response;
return $this->render('product_attributes');
}
}

View File

@@ -132,7 +132,7 @@ class BaseAdminController extends BaseController
* Create the standard message displayed to the user when the form cannot be validated. * Create the standard message displayed to the user when the form cannot be validated.
*/ */
protected function createStandardFormValidationErrorMessage(FormValidationException $exception) { protected function createStandardFormValidationErrorMessage(FormValidationException $exception) {
return Translator::getInstance()->trans( return $this->getTranslator()->trans(
"Please check your input: %error", "Please check your input: %error",
array( array(
'%error' => $exception->getMessage() '%error' => $exception->getMessage()
@@ -154,7 +154,7 @@ class BaseAdminController extends BaseController
// Log the error message // Log the error message
Tlog::getInstance()->error( Tlog::getInstance()->error(
Translator::getInstance()->trans( $this->getTranslator()->trans(
"Error during %action process : %error. Exception was %exc", "Error during %action process : %error. Exception was %exc",
array( array(
'%action' => $action, '%action' => $action,

View File

@@ -34,6 +34,7 @@ use Thelia\Core\Event\CategoryToggleVisibilityEvent;
use Thelia\Core\Event\CategoryChangePositionEvent; use Thelia\Core\Event\CategoryChangePositionEvent;
use Thelia\Form\CategoryDeletionForm; use Thelia\Form\CategoryDeletionForm;
use Thelia\Model\Lang; use Thelia\Model\Lang;
use Thelia\Core\Translation\Translator;
class CategoryController extends BaseAdminController class CategoryController extends BaseAdminController
{ {
@@ -244,31 +245,53 @@ class CategoryController extends BaseAdminController
} }
catch (FormValidationException $ex) { catch (FormValidationException $ex) {
// Invalid data entered // Invalid data entered
$error_msg = sprintf("Please check your input: %s", $ex->getMessage()); $error_msg = $this->getTranslator()->trans(
"Please check your input: %message", array("%message" => $ex->getMessage()));
} }
catch (\Exception $ex) { catch (\Exception $ex) {
// Any other error // Any other error
$error_msg = $ex; $error_msg = $ex;
} }
if ($error_msg !== false) { $this->setupFormErrorContext(
// Log error currency $form,
Tlog::getInstance()->error(sprintf("Error during currency modification process : %s. Exception was %s", $error_msg, $ex->getMessage())); $error_msg,
"category"
// Mark the form as errored
$changeForm->setErrorMessage($error_msg);
// Pas the form and the error to the parser
$this->getParserContext()
->addForm($changeForm)
->setGeneralError($error_msg)
;
}
// At this point, the form has errors, and should be redisplayed. // At this point, the form has errors, and should be redisplayed.
return $this->render('currency-edit', array('currency_id' => $currency_id)); return $this->render('currency-edit', array('currency_id' => $currency_id));
} }
protected function setupFormErrorContext($object_type, $form, $error_message, $exception) {
if ($error_message !== false) {
// Lot the error message
Tlog::getInstance()->error(
$this->getTranslator()->trans(
"Error during %type modification process : %error. Exception was %exc",
array(
"%type" => "category",
"%error" => $error_message,
"%exc" => $exception->getMessage()
)
)
);
// Mark the form as errored
$form->setErrorMessage($error_message);
// Pas the form and the error to the parser
$this->getParserContext()
->addForm($form)
->setGeneralError($error_message)
;
}
}
/** /**
* Sets the default currency * Sets the default currency
*/ */
@@ -293,25 +316,7 @@ class CategoryController extends BaseAdminController
} }
/** /**
* Update categories rates * Update currency position
*/
public function updateRatesAction() {
// Check current user authorization
if (null !== $response = $this->checkAuth("admin.categories.update")) return $response;
try {
$this->dispatch(TheliaEvents::CATEGORY_UPDATE_RATES);
}
catch (\Exception $ex) {
// Any error
return $this->errorPage($ex);
}
$this->redirectToRoute('admin.categories.default');
}
/**
* Update currencyposition
*/ */
public function updatePositionAction() { public function updatePositionAction() {
// Check current user authorization // Check current user authorization

View File

@@ -229,7 +229,7 @@ class ConfigController extends BaseAdminController
if ($this->getRequest()->get('save_mode') == 'stay') { if ($this->getRequest()->get('save_mode') == 'stay') {
$this->redirectToRoute( $this->redirectToRoute(
"admin.configuration.variables.change", "admin.configuration.variables.update",
array('variable_id' => $variable_id) array('variable_id' => $variable_id)
); );
} }
@@ -246,7 +246,7 @@ class ConfigController extends BaseAdminController
$message = $ex->getMessage(); $message = $ex->getMessage();
} }
$this->setupFormErrorContext("variable edition", $message, $creationForm, $ex); $this->setupFormErrorContext("variable edition", $message, $changeForm, $ex);
// At this point, the form has errors, and should be redisplayed. // At this point, the form has errors, and should be redisplayed.
return $this->render('variable-edit', array('variable_id' => $variable_id)); return $this->render('variable-edit', array('variable_id' => $variable_id));

View File

@@ -121,26 +121,14 @@ class CurrencyController extends BaseAdminController
} }
catch (FormValidationException $ex) { catch (FormValidationException $ex) {
// Form cannot be validated // Form cannot be validated
$error_msg = sprintf("Please check your input: %s", $ex->getMessage()); $error_msg = $this->createStandardFormValidationErrorMessage($ex);
} }
catch (\Exception $ex) { catch (\Exception $ex) {
// Any other error // Any other error
$error_msg = $ex; $error_msg = $ex->getMessage();
} }
if ($error_msg !== false) { $this->setupFormErrorContext("currency creation", $error_msg, $creationForm, $ex);
// An error has been detected: log it
Tlog::getInstance()->error(sprintf("Error during currency creation process : %s. Exception was %s", $error_msg, $ex->getMessage()));
// Mark the form as errored
$creationForm->setErrorMessage($error_msg);
// Pass it to the parser, along with the error currency
$this->getParserContext()
->addForm($creationForm)
->setGeneralError($error_msg)
;
}
// At this point, the form has error, and should be redisplayed. // At this point, the form has error, and should be redisplayed.
return $this->renderList(); return $this->renderList();
@@ -241,27 +229,15 @@ class CurrencyController extends BaseAdminController
$this->redirect($changeForm->getSuccessUrl()); $this->redirect($changeForm->getSuccessUrl());
} }
catch (FormValidationException $ex) { catch (FormValidationException $ex) {
// Invalid data entered // Form cannot be validated
$error_msg = sprintf("Please check your input: %s", $ex->getMessage()); $error_msg = $this->createStandardFormValidationErrorMessage($ex);
} }
catch (\Exception $ex) { catch (\Exception $ex) {
// Any other error // Any other error
$error_msg = $ex; $error_msg = $ex->getMessage();
} }
if ($error_msg !== false) { $this->setupFormErrorContext("currency modification", $error_msg, $changeForm, $ex);
// Log error currency
Tlog::getInstance()->error(sprintf("Error during currency modification process : %s. Exception was %s", $error_msg, $ex->getMessage()));
// Mark the form as errored
$changeForm->setErrorMessage($error_msg);
// Pas the form and the error to the parser
$this->getParserContext()
->addForm($changeForm)
->setGeneralError($error_msg)
;
}
// At this point, the form has errors, and should be redisplayed. // At this point, the form has errors, and should be redisplayed.
return $this->render('currency-edit', array('currency_id' => $currency_id)); return $this->render('currency-edit', array('currency_id' => $currency_id));

View File

@@ -100,26 +100,14 @@ class MessageController extends BaseAdminController
} }
catch (FormValidationException $ex) { catch (FormValidationException $ex) {
// Form cannot be validated // Form cannot be validated
$message = sprintf("Please check your input: %s", $ex->getMessage()); $message = $this->createStandardFormValidationErrorMessage($ex);
} }
catch (\Exception $ex) { catch (\Exception $ex) {
// Any other error // Any other error
$message = sprintf("Sorry, an error occured: %s", $ex->getMessage()); $message = $ex->getMessage();
} }
if ($message !== false) { $this->setupFormErrorContext("message modification", $message, $creationForm, $ex);
// An error has been detected: log it
Tlog::getInstance()->error(sprintf("Error during message creation process : %s. Exception was %s", $message, $ex->getMessage()));
// Mark the form as errored
$creationForm->setErrorMessage($message);
// Pass it to the parser, along with the error message
$this->getParserContext()
->addForm($creationForm)
->setGeneralError($message)
;
}
// At this point, the form has error, and should be redisplayed. // At this point, the form has error, and should be redisplayed.
return $this->render('messages'); return $this->render('messages');
@@ -224,27 +212,15 @@ class MessageController extends BaseAdminController
$this->redirect($changeForm->getSuccessUrl()); $this->redirect($changeForm->getSuccessUrl());
} }
catch (FormValidationException $ex) { catch (FormValidationException $ex) {
// Invalid data entered // Form cannot be validated
$message = sprintf("Please check your input: %s", $ex->getMessage()); $message = $this->createStandardFormValidationErrorMessage($ex);
} }
catch (\Exception $ex) { catch (\Exception $ex) {
// Any other error // Any other error
$message = sprintf("Sorry, an error occured: %s", $ex->getMessage()); $message = $ex->getMessage();
} }
if ($message !== false) { $this->setupFormErrorContext("message modification", $message, $changeForm, $ex);
// Log error message
Tlog::getInstance()->error(sprintf("Error during message modification process : %s. Exception was %s", $message, $ex->getMessage()));
// Mark the form as errored
$changeForm->setErrorMessage($message);
// Pas the form and the error to the parser
$this->getParserContext()
->addForm($changeForm)
->setGeneralError($message)
;
}
// At this point, the form has errors, and should be redisplayed. // At this point, the form has errors, and should be redisplayed.
return $this->render('message-edit', array('message_id' => $message_id)); return $this->render('message-edit', array('message_id' => $message_id));

View File

@@ -73,30 +73,32 @@ class SessionController extends BaseAdminController
// Redirect to the success URL // Redirect to the success URL
return Redirect::exec($adminLoginForm->getSuccessUrl()); return Redirect::exec($adminLoginForm->getSuccessUrl());
} catch (ValidatorException $ex) {
}
catch (FormValidationException $ex) {
// Validation problem // Validation problem
$message = "Missing or invalid information. Please check your input."; $message = $this->createStandardFormValidationErrorMessage($ex);
} catch (AuthenticationException $ex) { }
catch (AuthenticationException $ex) {
// Log authentication failure // Log authentication failure
AdminLog::append(sprintf("Authentication failure for username '%s'", $authenticator->getUsername()), $request); AdminLog::append(sprintf("Authentication failure for username '%s'", $authenticator->getUsername()), $request);
$message = "Login failed. Please check your username and password."; $message = $this->getTranslator()->trans("Login failed. Please check your username and password.");
} catch (\Exception $ex) { }
catch (\Exception $ex) {
// Log authentication failure // Log authentication failure
AdminLog::append(sprintf("Undefined error: %s", $ex->getMessage()), $request); AdminLog::append(sprintf("Undefined error: %s", $ex->getMessage()), $request);
$message = "Unable to process your request. Please try again.".$ex->getMessage(); $message = $this->getTranslator()->trans(
"Unable to process your request. Please try again (%err).",
array("%err" => $ex->getMessage())
);
} }
// Store error information in the form $this->setupFormErrorContext("Login process", $message, $adminLoginForm, $ex);
$adminLoginForm->setError(true);
$adminLoginForm->setErrorMessage($message);
// Store the form name in session (see Form Smarty plugin to find usage of this parameter)
$this->getParserContext()->addForm($adminLoginForm);
// Display the login form again // Display the login form again
return $this->render("login"); return $this->render("login");

View File

@@ -215,7 +215,7 @@ class BaseController extends ContainerAware
$route = $this->container->get($routerName)->getRouteCollection()->get($routeId); $route = $this->container->get($routerName)->getRouteCollection()->get($routeId);
if ($route == null) { if ($route == null) {
throw new InvalidArgumentException(sprintf("Route ID '%s' does not exists.", $routeId)); throw new \InvalidArgumentException(sprintf("Route ID '%s' does not exists.", $routeId));
} }
return $route->getPath(); return $route->getPath();

View File

@@ -24,7 +24,7 @@
namespace Thelia\Core\Event; namespace Thelia\Core\Event;
use Thelia\Model\Category; use Thelia\Model\Category;
class CategoryToggleVisibilityEvent extends ActionEvent class CategoryToggleVisibilityEvent extends CategoryEvent
{ {
protected $category_id; protected $category_id;
protected $category; protected $category;

View File

@@ -43,12 +43,31 @@ abstract class BaseDescForm extends BaseForm
->add("title", "text", array( ->add("title", "text", array(
"constraints" => array( "constraints" => array(
new NotBlank() new NotBlank()
),
"label" => "Title",
"label_attr" => array(
"for" => "title"
) )
) )
) )
->add("chapo", "text", array()) ->add("chapo", "text", array(
->add("description", "text", array()) "label" => "Summary",
->add("postscriptum", "text", array()) "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"
)
))
; ;
} }
} }

View File

@@ -141,6 +141,8 @@ abstract class BaseForm
public function createView() public function createView()
{ {
$this->view = $this->form->createView(); $this->view = $this->form->createView();
return $this;
} }
public function getView() public function getView()
@@ -159,6 +161,8 @@ abstract class BaseForm
public function setError($has_error = true) public function setError($has_error = true)
{ {
$this->has_error = $has_error; $this->has_error = $has_error;
return $this;
} }
/** /**
@@ -180,6 +184,8 @@ abstract class BaseForm
{ {
$this->setError(true); $this->setError(true);
$this->error_message = $message; $this->error_message = $message;
return $this;
} }
/** /**

View File

@@ -32,6 +32,10 @@ class CategoryCreationForm extends BaseForm
->add("title", "text", array( ->add("title", "text", array(
"constraints" => array( "constraints" => array(
new NotBlank() new NotBlank()
),
"label" => "Category title *",
"label_attr" => array(
"for" => "title"
) )
)) ))
->add("parent", "integer", array( ->add("parent", "integer", array(

View File

@@ -40,11 +40,19 @@ class ConfigCreationForm extends BaseForm
$this->formBuilder $this->formBuilder
->add("name", "text", array( ->add("name", "text", array(
"constraints" => $name_constraints "constraints" => $name_constraints,
"label" => "Name *",
"label_attr" => array(
"for" => "name"
)
)) ))
->add("title", "text", array( ->add("title", "text", array(
"constraints" => array( "constraints" => array(
new Constraints\NotBlank() new Constraints\NotBlank()
),
"label" => "Purpose *",
"label_attr" => array(
"for" => "purpose"
) )
)) ))
->add("locale", "hidden", array( ->add("locale", "hidden", array(
@@ -52,9 +60,16 @@ class ConfigCreationForm extends BaseForm
new Constraints\NotBlank() new Constraints\NotBlank()
) )
)) ))
->add("value", "text", array()) ->add("value", "text", array(
"label" => "Value *",
"label_attr" => array(
"for" => "value"
)
))
->add("hidden", "hidden", array()) ->add("hidden", "hidden", array())
->add("secured", "hidden", array()) ->add("secured", "hidden", array(
"label" => "Prevent variable modification or deletion, except for super-admin"
))
; ;
} }

View File

@@ -44,11 +44,22 @@ class ConfigModificationForm extends BaseDescForm
->add("name", "text", array( ->add("name", "text", array(
"constraints" => array( "constraints" => array(
new NotBlank() new NotBlank()
),
"label" => "Name",
"label_attr" => array(
"for" => "name"
)
))
->add("value", "text", array(
"label" => "Value",
"label_attr" => array(
"for" => "value"
) )
)) ))
->add("value", "text", array())
->add("hidden", "hidden", array()) ->add("hidden", "hidden", array())
->add("secured", "hidden", array()) ->add("secured", "hidden", array(
"label" => "Prevent variable modification or deletion, except for super-admin"
))
; ;
} }

View File

@@ -40,11 +40,19 @@ class MessageCreationForm extends BaseForm
$this->formBuilder $this->formBuilder
->add("name", "text", array( ->add("name", "text", array(
"constraints" => $name_constraints "constraints" => $name_constraints,
"label" => "Name *",
"label_attr" => array(
"for" => "name"
)
)) ))
->add("title", "text", array( ->add("title", "text", array(
"constraints" => array( "constraints" => array(
new Constraints\NotBlank() new Constraints\NotBlank()
),
"label" => "Purpose *",
"label_attr" => array(
"for" => "purpose"
) )
)) ))
->add("locale", "hidden", array( ->add("locale", "hidden", array(

View File

@@ -33,13 +33,43 @@ class MessageModificationForm extends BaseForm
{ {
$this->formBuilder $this->formBuilder
->add("id" , "hidden", array("constraints" => array(new GreaterThan(array('value' => 0))))) ->add("id" , "hidden", array("constraints" => array(new GreaterThan(array('value' => 0)))))
->add("name" , "text" , array("constraints" => array(new NotBlank()))) ->add("name" , "text" , array(
->add("secured" , "text" , array()) "constraints" => array(new NotBlank()),
"label" => "Name *",
"label_attr" => array(
"for" => "name"
)
))
->add("secured" , "text" , array(
"label" => "Prevent mailing template modification or deletion, except for super-admin"
))
->add("locale" , "text" , array()) ->add("locale" , "text" , array())
->add("title" , "text" , array("constraints" => array(new NotBlank()))) ->add("title" , "text" , array(
->add("subject" , "text" , array("constraints" => array(new NotBlank()))) "constraints" => array(new NotBlank()),
->add("html_message" , "text" , array()) "label" => "Title *",
->add("text_message" , "text" , array()) "label_attr" => array(
"for" => "title"
)
))
->add("subject" , "text" , array(
"constraints" => array(new NotBlank()),
"label" => "Message subject *",
"label_attr" => array(
"for" => "subject"
)
))
->add("html_message" , "text" , array(
"label" => "HTML Message",
"label_attr" => array(
"for" => "html_message"
)
))
->add("text_message" , "text" , array(
"label" => "Text Message",
"label_attr" => array(
"for" => "text_message"
)
))
; ;
} }

View File

@@ -45,3 +45,9 @@
// Try to avoid customizing these :) // Try to avoid customizing these :)
@zindex-dropdown: 1005; @zindex-dropdown: 1005;
// Forms
// -------------------------
@input-border-focus: @link-color;

View File

@@ -269,6 +269,7 @@
{module_include location='product_list_row'} {module_include location='product_list_row'}
<td> <td>
<<<<<<< HEAD
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.products.edit"} {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.products.edit"}
<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>"> <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" data-id="{$ID}" class="productVisibleToggle" {if $VISIBLE == 1}checked="checked"{/if}> <input type="checkbox" data-id="{$ID}" class="productVisibleToggle" {if $VISIBLE == 1}checked="checked"{/if}>
@@ -280,6 +281,11 @@
<input type="checkbox" class="disabled" disabled="disabled" {if $VISIBLE == 1}checked="checked"{/if}> <input type="checkbox" class="disabled" disabled="disabled" {if $VISIBLE == 1}checked="checked"{/if}>
</div> </div>
{/elseloop} {/elseloop}
=======
<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" data-id="{$ID}" class="displayToggle" {if $VISIBLE == 1}checked="checked"{/if}>
</div>
>>>>>>> ebb350111a2c65929f8c61f621c9a8a6dd878984
</td> </td>
<td> <td>
@@ -312,7 +318,7 @@
{elseloop rel="product_list"} {elseloop rel="product_list"}
<thead> <thead>
<tr> <tr>
<td class="message"><div class="alert alert-info">{intl l="This category doesn't have any products. To add a new product, click the + button above."}</div></td> <td class="message"><div class="alert alert-info">{intl l="This category doesn't have any products. To add a new product, <strong>click the + button</strong> above."}</div></td>
</tr> </tr>
</thead> </thead>
{/elseloop} {/elseloop}
@@ -436,6 +442,7 @@
<script src="{$asset_url}"></script> <script src="{$asset_url}"></script>
{/javascripts} {/javascripts}
<<<<<<< HEAD
<script> <script>
$(function() { $(function() {
@@ -530,4 +537,70 @@ $(function() {
}) })
</script> </script>
=======
<script>
$(function() {
{* display the form creation dialog if it contains errors *}
{form name="thelia.admin.category.creation"}
{if #form_error}
$('#add_category_dialog').modal();
{/if}
{/form}
{* Always reset create dialog on close *}
$('#add_category_dialog').on('hidden',function() {
// Hide error message
$('#add_category_dialog_error').remove();
// Clear error status
$("#add_category_dialog .error").removeClass('error');
// Empty field values
$("#add_category_dialog input[type=text]").val('');
});
{* Set the proper category ID in the delete confirmation dialog *}
$(document).on("click", ".category-delete", function () {
$('#'+'delete-category-id').val($(this).data('id'));
});
// Toggle category visibility
$(".categoryVisibleToggle").change(function() {
$.ajax({
url : "{url path='admin/catalog/category'}",
data : {
category_id : $(this).data('id'),
action : 'visibilityToggle'
}
});
});
{* Inline editing of object position using bootstrap-editable *}
$('.categoryPositionChange').editable({
type : 'text',
title : '{intl l="Enter new category position"}',
mode : 'popup',
inputclass : 'input-mini',
placement : 'left',
success : function(response, newValue) {
// The URL template
var url = "{url path='admin/catalog/category' action='changePosition' category_id='__ID__' position='__POS__'}";
// Perform subtitutions
url = url.replace('__ID__', $(this).data('id'))
.replace('__POS__', newValue);
// Reload the page
location.href = url;
}
});
});
</script>
>>>>>>> ebb350111a2c65929f8c61f621c9a8a6dd878984
{/block} {/block}

View File

@@ -0,0 +1,70 @@
{* Adding a new Category *}
<div class="modal fade" id="add_category_dialog" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3>{intl l="Create a new category"}</h3>
</div>
{form name="thelia.admin.category.creation"}
<form method="POST" action="{url path='/admin/catalog/category'}" {form_enctype form=$form}>
{* the action processed by the controller *}
<input type="hidden" name="action" value="create" />
{form_hidden_fields form=$form}
{form_field form=$form field='parent'}
<input type="hidden" name="{$name}" value="{$current_category_id}" />
{/form_field}
{form_field form=$form field='success_url'}
{* on success, redirect to category change page. _ID_ is replaced with the ID of the created category (see Thelia\Action\Category.php) *}
<input type="hidden" name="{$name}" value="{url path='admin/catalog/category' id="_ID_" action='edit'}" />
{/form_field}
<div class="modal-body">
{if #form_error}<div class="alert alert-error" id="add_category_dialog_error">#form_error_message</div>{/if}
{form_field form=$form field='title'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$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}" value="{$value}" title="{intl l='Category title'}" placeholder="{intl l='Category title'}" class="form-control">
<span class="input-group-addon"><img src="{image file="../assets/img/flags/{$CODE}.gif"}" alt="{intl l=$TITLE}" /></span>
</div>
<div class="help-block">{intl l="Enter here the category title in the default language ($TITLE)"}</div>
{form_field form=$form field='locale'}
<input type="hidden" name="{$name}" value="{$LOCALE}" />
{/form_field}
{/loop}
</div>
{/form_field}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true"><span class="glyphicon glyphicon-remove"></span> {intl l="Cancel"}</button>
<button type="submit" class="btn btn-default btn-primary"><span class="glyphicon glyphicon-check"></span> {intl l="Create this category"}</button>
</div>
</form>
{/form}
</div>
</div>
</div>

View File

@@ -0,0 +1,48 @@
{* Adding a new Category *}
<div class="modal fade" id="delete_category_dialog" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3>{intl l="Delete a category"}</h3>
</div>
{form name="thelia.admin.category.deletion"}
<form method="POST" action="{url path='/admin/catalog/category'}" {form_enctype form=$form}>
{* the action processed by the controller *}
<input type="hidden" name="action" value="delete" />
{form_hidden_fields form=$form}
{form_field form=$form field='category_id'}
<input type="hidden" name="{$name}" id="delete-category-id" value="" />
{/form_field}
{form_field form=$form field='success_url'}
{* on success, redirect to catalog. _ID_ is replaced with the ID of the deleted category parent id (see Thelia\Action\Category.php) *}
<input type="hidden" name="{$name}" value="{url path='admin/catalog/category' id="_ID_" action='browse'}" />
{/form_field}
<div class="modal-body">
{if #form_error}<div class="alert alert-block alert-error" id="add_category_dialog_error">#form_error_message</div>{/if}
<p>{intl l="Delete this category and all its contents ?"}</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true"><span class="glyphicon glyphicon-remove"></span> {intl l="No"}</button>
<button type="submit" class="btn btn-default btn-primary"><span class="glyphicon glyphicon-check"></span> {intl l="Yes"}</button>
</div>
</form>
{/form}
</div>
</div>
</div>

View File

@@ -1,60 +1,41 @@
{* The standard description fields, used by many Thelia objects *} {* The standard description fields, used by many Thelia objects *}
{form_field form=$form field='title'} {form_field form=$form field='title'}
<div class="control-group"> <div class="form-group {if $error}has-error{/if}">
<label class="control-label"> <label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
{intl l='Title *'} <input type="text" id="{$label_attr.for}" name="{$name}" required="required" title="{intl l='Title'}" placeholder="{intl l='Title'}" class="form-control" value="{$value|htmlspecialchars}">
</label>
<div class="controls">
<span {if $error}class="error"{/if}>
<input type="text" name="{$name}" required="required" title="{intl l='Title'}" placeholder="{intl l='Title'}" class="input-block-level" value="{$value|htmlspecialchars}">
</span>
</div>
</div> </div>
{/form_field} {/form_field}
{form_field form=$form field='chapo'} {form_field form=$form field='chapo'}
<div class="control-group"> <div class="form-group {if $error}has-error{/if}">
<label class="control-label"> <label for="{$label_attr.for}" class="control-label">
{intl l='Summary'} {intl l="{$label}"} :
<span class="label-help-block">{intl l="A short description, used when a summary or an introduction is required"}</span> <span class="label-help-block">{intl l="A short description, used when a summary or an introduction is required"}</span>
</label> </label>
<div class="controls"> <textarea name="{$name}" id="{$label_attr.for}" rows="3" title="{intl l='Short description'}" placeholder="{intl l='Short description'}" class="form-control">{$value|htmlspecialchars}</textarea>
<span {if $error}class="error"{/if}>
<textarea name="{$name}" rows="3" title="{intl l='Short description'}" placeholder="{intl l='Short description'}" class="input-block-level">{$value|htmlspecialchars}</textarea>
</span>
</div>
</div> </div>
{/form_field} {/form_field}
{form_field form=$form field='description'} {form_field form=$form field='description'}
<div class="control-group"> <div class="form-group {if $error}has-error{/if}">
<label class="control-label"> <label for="{$label_attr.for}" class="control-label">
{intl l='Detailed description'} {intl l="{$label}"} :
<span class="label-help-block">{intl l="The détailed description."}</span> <span class="label-help-block">{intl l="The détailed description."}</span>
</label> </label>
<div class="controls"> <textarea name="{$name}" id="{$label_attr.for}" rows="10" class="form-control">{$value|htmlspecialchars}</textarea>
<span {if $error}class="error"{/if}>
<textarea name="{$name}" rows="10" class="input-block-level">{$value|htmlspecialchars}</textarea>
</span>
</div>
</div> </div>
{/form_field} {/form_field}
{form_field form=$form field='postscriptum'} {form_field form=$form field='postscriptum'}
<div class="control-group"> <div class="form-group {if $error}has-error{/if}">
<label class="control-label"> <label for="{$label_attr.for}" class="control-label">
{intl l='Conclusion'} {intl l="{$label}"} :
<span class="label-help-block">{intl l="A short post-description information"}</span> <span class="label-help-block">{intl l="A short post-description information"}</span>
</label> </label>
<div class="controls"> <textarea name="{$name}" id="{$label_attr.for}" rows="3" title="{intl l='Short conclusion'}" placeholder="{intl l='Short conclusion'}" class="form-control">{$value|htmlspecialchars}</textarea>
<span {if $error}class="error"{/if}>
<textarea name="{$name}" rows="3" title="{intl l='Short conclusion'}" placeholder="{intl l='Short conclusion'}" class="input-block-level">{$value|htmlspecialchars}</textarea>
</span>
</div>
</div> </div>
{/form_field} {/form_field}

View File

@@ -27,127 +27,85 @@
</div> </div>
<div class="form-container"> <div class="form-container">
<div class="form-horizontal col-md-12"> <div class="col-md-12">
{form name="thelia.admin.message.modification"} {form name="thelia.admin.message.modification"}
<form method="POST" action="{url path='/admin/configuration/messages/save'}" {form_enctype form=$form}> <form method="POST" action="{url path='/admin/configuration/messages/save'}" {form_enctype form=$form}>
<fieldset>
{* Be sure to get the message ID, even if the form could not be validated *}
<input type="hidden" name="message_id" value="{$message_id}" />
{include file="includes/inner-form-toolbar.html"} {* Be sure to get the message ID, even if the form could not be validated *}
<input type="hidden" name="message_id" value="{$message_id}" />
{form_hidden_fields form=$form} {include file="includes/inner-form-toolbar.html"}
{form_field form=$form field='success_url'} {form_hidden_fields form=$form}
<input type="hidden" name="{$name}" value="{url path='/admin/configuration/messages'}" />
{/form_field}
{form_field form=$form field='id'} {form_field form=$form field='success_url'}
<input type="hidden" name="{$name}" value="{$value|htmlspecialchars}" /> <input type="hidden" name="{$name}" value="{url path='/admin/configuration/messages'}" />
{/form_field} {/form_field}
{form_field form=$form field='locale'} {form_field form=$form field='id'}
<input type="hidden" name="{$name}" value="{{$edit_language_locale}}" /> <input type="hidden" name="{$name}" value="{$value|htmlspecialchars}" />
{/form_field} {/form_field}
{if #form_error}<div class="alert alert-block alert-error">#form_error_message</div>{/if} {form_field form=$form field='locale'}
<input type="hidden" name="{$name}" value="{{$edit_language_locale}}" />
{/form_field}
<div class="control-group"> {if #form_error}<div class="alert alert-danger">#form_error_message</div>{/if}
<label class="control-label"> {form_field form=$form field='name'}
{intl l='Name *'} <div class="form-group {if $error}has-error{/if}">
</label> <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|htmlspecialchars}" title="{intl l='Variable name'}" placeholder="{intl l='Variable name'}" class="form-control">
</div>
{/form_field}
<div class="controls"> {form_field form=$form field='secured'}
{form_field form=$form field='name'} <div class="checkbox {if $error}has-error{/if}">
<span {if $error}class="error"{/if}> <label>
<input type="text" required="required" name="{$name}" value="{$value|htmlspecialchars}" title="{intl l='Variable name'}" placeholder="{intl l='Variable name'}" class="input-block-level"> <input type="checkbox" name="{$name}" value="1" {if $value == 1}checked="checked"{/if}>
</span> {intl l="{$label}"}
{/form_field} </label>
</div> </div>
</div> {/form_field}
<div class="control-group"> {form_field form=$form field='title'}
<label class="control-label"> <div class="form-group {if $error}has-error{/if}">
{intl l='Secured'} <label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
</label> <input type="text" id="{$label_attr.for}" name="{$name}" required="required" title="{intl l='Title'}" placeholder="{intl l='Title'}" class="form-control" value="{$value|htmlspecialchars}">
</div>
{/form_field}
<div class="controls"> {form_field form=$form field='subject'}
{form_field form=$form field='secured'} <div class="form-group {if $error}has-error{/if}">
<span {if $error}class="error"{/if}> <label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<label class="checkbox"> <input type="text" id="{$label_attr.for}" name="{$name}" required="required" title="{intl l='Subject'}" placeholder="{intl l='Subject'}" class="form-control" value="{$value|htmlspecialchars}">
<input type="checkbox" name="{$name}" value="1" {if $value == 1}checked="checked"{/if}> </div>
{intl l="Prevent mailing template modification or deletion, except for super-admin"} {/form_field}
</label>
</span>
{/form_field}
</div>
</div>
{form_field form=$form field='title'} {form_field form=$form field='html_message'}
<div class="control-group"> <div class="form-group {if $error}has-error{/if}">
<label class="control-label"> <label for="{$label_attr.for}" class="control-label">
{intl l='Title *'} {intl l="{$label}"} :
</label> <span class="label-help-block">{intl l="The mailing template in HTML format."}</span>
</label>
<textarea name="{$name}" id="{$label_attr.for}" rows="10" class="form-control">{$value|htmlspecialchars}</textarea>
</div>
{/form_field}
<div class="controls"> {form_field form=$form field='text_message'}
<span {if $error}class="error"{/if}> <div class="form-group {if $error}has-error{/if}">
<input type="text" name="{$name}" required="required" title="{intl l='Title'}" placeholder="{intl l='Title'}" class="input-block-level" value="{$value|htmlspecialchars}"> <label for="{$label_attr.for}" class="control-label">
</span> {intl l="{$label}"} :
</div> <span class="label-help-block">{intl l="The mailing template in text-only format."}</span>
</div> </label>
{/form_field} <textarea name="{$name}" id="{$label_attr.for}" rows="10" class="form-control">{$value|htmlspecialchars}</textarea>
</div>
{/form_field}
{form_field form=$form field='subject'} <div class="form-group">
<div class="control-group"> <p>{intl l='Message created on %date_create. Last modification: %date_change' date_create="{format_date date=$CREATE_DATE}" date_change="{format_date date=$UPDATE_DATE}"}}</p>
<label class="control-label"> </div>
{intl l='Message subject *'}
</label>
<div class="controls">
<span {if $error}class="error"{/if}>
<input type="text" name="{$name}" required="required" title="{intl l='Subject'}" placeholder="{intl l='Subject'}" class="input-block-level" value="{$value|htmlspecialchars}">
</span>
</div>
</div>
{/form_field}
{form_field form=$form field='html_message'}
<div class="control-group">
<label class="control-label">
{intl l='HTML Message'}
<span class="label-help-block">{intl l="The mailing template in HTML format."}</span>
</label>
<div class="controls">
<span {if $error}class="error"{/if}>
<textarea name="{$name}" rows="10" class="input-block-level">{$value|htmlspecialchars}</textarea>
</span>
</div>
</div>
{/form_field}
{form_field form=$form field='text_message'}
<div class="control-group">
<label class="control-label">
{intl l='Text Message'}
<span class="label-help-block">{intl l="The mailing template in text-only format."}</span>
</label>
<div class="controls">
<span {if $error}class="error"{/if}>
<textarea name="{$name}" rows="10" class="input-block-level">{$value|htmlspecialchars}</textarea>
</span>
</div>
</div>
{/form_field}
<div class="control-group">
<div class="controls">
<p>{intl l='Message 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>
</fieldset>
</form> </form>
{/form} {/form}
</div> </div>

View File

@@ -31,62 +31,65 @@
{/loop} {/loop}
</caption> </caption>
<tr> <thead>
<th>{intl l="Purpose"}</th> <tr>
<th>{intl l="Name"}</th> <th>{intl l="Purpose"}</th>
<th>{intl l="Name"}</th>
{module_include location='messages_table_header'} {module_include location='messages_table_header'}
<th>&nbsp;</th> <th>&nbsp;</th>
</tr> </tr>
</thead>
{loop name="mailing-templates" type="message" secured="*" backend_context="1" lang="$lang_id"} <tbody>
<tr> {loop name="mailing-templates" type="message" secured="*" backend_context="1" lang="$lang_id"}
<tr>
<td>{$TITLE}</td> <td>{$TITLE}</td>
<td> <td>
{if ! $SECURED} {if ! $SECURED}
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.messages.change"} {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.messages.change"}
<a title="{intl l='Change this mailing template'}" href="{url path='/admin/configuration/messages/update' message_id="$ID"}">{$NAME}</a> <a title="{intl l='Change this mailing template'}" href="{url path='/admin/configuration/messages/update' message_id="$ID"}">{$NAME}</a>
{/loop} {/loop}
{elseloop rel="can_change"} {elseloop rel="can_change"}
{$NAME}
{/elseloop}
{else}
{$NAME} {$NAME}
{/elseloop} {/if}
{else} </td>
{$NAME}
{/if}
</td>
{module_include location='messages_table_row'} {module_include location='messages_table_row'}
<td class="actions"> <td class="actions">
{if ! $SECURED} {if ! $SECURED}
<div class="btn-group"> <div class="btn-group">
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.messages.change"} {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.messages.change"}
<a class="btn btn-default btn-xs message-change" title="{intl l='Change this mailing template'}" href="{url path='/admin/configuration/messages/update' message_id="$ID"}"><i class="glyphicon glyphicon-edit"></i></a> <a class="btn btn-default btn-xs message-change" title="{intl l='Change this mailing template'}" href="{url path='/admin/configuration/messages/update' message_id="$ID"}"><i class="glyphicon glyphicon-edit"></i></a>
{/loop} {/loop}
{loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.configuration.messages.delete"} {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.configuration.messages.delete"}
<a class="btn btn-default btn-xs message-delete" title="{intl l='Delete this mailing template'}" href="#delete_message_dialog" data-id="{$ID}" data-toggle="modal"><i class="glyphicon glyphicon-trash"></i></a> <a class="btn btn-default btn-xs message-delete" title="{intl l='Delete this mailing template'}" href="#delete_message_dialog" data-id="{$ID}" data-toggle="modal"><i class="glyphicon glyphicon-trash"></i></a>
{/loop} {/loop}
</div> </div>
{else} {else}
<i title="{intl l='This mailing template could not be changed.'}" class="glyphicon glyphicon-ban-circle"></i> <i title="{intl l='This mailing template could not be changed.'}" class="glyphicon glyphicon-ban-circle"></i>
{/if} {/if}
</td> </td>
</tr> </tr>
{/loop} {/loop}
{elseloop rel="mailing-templates"}
{elseloop rel="mailing-templates"} <tr>
<tr> <td colspan="3">
<td colspan="3"> <div class="alert alert-info">
<div class="alert alert-info"> {intl l="No mailing template has been created yet. Click the + button to create one."}
{intl l="No mailing template has been created yet. Click the + button to create one."} </div>
</div> </td>
</td> </tr>
</tr> {/elseloop}
{/elseloop} </tbody>
</table> </table>
</div> </div>
</form> </form>
@@ -101,110 +104,107 @@
{* Adding a new message *} {* Adding a new message *}
<div class="modal hide fade" id="add_message_dialog" tabindex="-1" role="dialog" aria-hidden="true"> <div class="modal fade" id="add_message_dialog" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-header"> <div class="modal-dialog">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> <div class="modal-content">
<h3>{intl l="Create a new mailing template"}</h3>
</div>
{form name="thelia.admin.message.creation"} <div class="modal-header">
<form method="POST" action="{url path='/admin/configuration/messages/create'}" {form_enctype form=$form}> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3>{intl l="Create a new mailing template"}</h3>
{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 message ID, see controller *}
<input type="hidden" name="{$name}" value="{url path='/admin/configuration/messages/update' message_id='_ID_'}" />
{/form_field}
{* We do not allow users to create secured messages from here *}
{form_field form=$form field='secured'}
<input type="hidden" name="{$name}" value="0" />
{/form_field}
<div class="modal-body">
{if #form_error}<div class="alert alert-block alert-error" id="add_message_dialog_error">#form_error_message</div>{/if}
<div class="control-group">
<label class="control-label">
{intl l='Name *'}
</label>
<div class="controls">
{form_field form=$form field='name'}
<span {if $error}class="error"{/if}>
<input type="text" required="required" name="{$name}" value="{$value}" title="{intl l='Mailing template name'}" placeholder="{intl l='Mailing template name'}" class="input-block-level">
</span>
{/form_field}
</div>
</div> </div>
<div class="control-group"> {form name="thelia.admin.message.creation"}
<label class="control-label"> <form method="POST" action="{url path='/admin/configuration/messages/create'}" {form_enctype form=$form}>
{intl l='Purpose *'}
</label>
<div class="controls"> {form_hidden_fields form=$form}
{loop type="lang" name="default-lang" default_only="1"}
{* Switch edition to the current locale *} {form_field form=$form field='success_url'}
<input type="hidden" name="edit_language_id" value="{$ID}" /> {* on success, redirect to the edition page, _ID_ is replaced with the created message ID, see controller *}
<input type="hidden" name="{$name}" value="{url path='/admin/configuration/messages/update' message_id='_ID_'}" />
{/form_field}
{form_field form=$form field='locale'} {* We do not allow users to create secured messages from here *}
<input type="hidden" name="{$name}" value="{$LOCALE}" />
{/form_field}
<div class="input-group input-block-level"> {form_field form=$form field='secured'}
{form_field form=$form field='title'} <input type="hidden" name="{$name}" value="0" />
<span {if $error}class="error"{/if}> {/form_field}
<input type="text" required="required" name="{$name}" value="{$value}" title="{intl l='Mailing template purpose'}" placeholder="{intl l='Mailing template purpose'}" class="input-block-level">
</span> <div class="modal-body">
{if #form_error}<div class="alert alert-danger" id="add_message_dialog_error">#form_error_message</div>{/if}
{form_field form=$form field='name'}
<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='Mailing template name'}" placeholder="{intl l='Mailing template name'}" class="form-control">
</div>
{/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">{intl l="{$label}"} : </label>
{loop type="lang" name="default-lang" default_only="1"}
{* Switch edition to the current locale *}
<input type="hidden" name="edit_language_id" value="{$ID}" />
<div class="input-group">
<input type="text" id="{$label_attr.for}" required="required" name="{$name}" value="{$value}" title="{intl l='Mailing template purpose'}" placeholder="{intl l='Mailing template purpose'}" class="form-control">
<span class="input-group-addon"><img src="{image file="assets/img/flags/{$CODE}.gif"}" alt="{intl l=$TITLE}" /></span>
</div>
<div class="help-block">{intl l="Enter here the mailing template purpose in the default language ($TITLE)"}</div>
{form_field form=$form field='locale'}
<input type="hidden" name="{$name}" value="{$LOCALE}" />
{/form_field} {/form_field}
<span class="input-group-addon"><img src="{image file="assets/img/flags/{$CODE}.gif"}" alt="{intl l=$TITLE}" /></span> {/loop}
</div>
</div>
{/form_field}
<div class="help-block">{intl l="Enter here the mailing template purpose in the default language ($TITLE)"}</div>
{/loop}
</div> </div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true"><span class="glyphicon glyphicon-remove"></span> {intl l="Cancel"}</button>
<button type="submit" class="btn btn-default btn-primary"><span class="glyphicon glyphicon-check"></span> {intl l="Create this mailing template"}</button>
</div>
</form>
{/form}
</div> </div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-default btn-primary">{intl l="Create this mailing template"}</button>
<button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true">{intl l="Cancel"}</button>
</div>
</form>
{/form}
</div> </div>
{* Delete confirmation dialog *} {* Delete confirmation dialog *}
<div class="modal hide fade" id="delete_message_dialog" tabindex="-1" role="dialog" aria-hidden="true"> <div class="modal fade" id="delete_message_dialog" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3>{intl l="Delete a mailing template"}</h3> <h3>{intl l="Delete a mailing template"}</h3>
</div>
<div class="modal-body">
<p>{intl l="Do you really want to delete this mailing template ?"}</p>
</div>
<form method="post" action="{url path='/admin/configuration/messages/delete'}">
<input type="hidden" name="message_id" id="message_delete_id" value="" />
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true"><span class="glyphicon glyphicon-remove"></span> {intl l="No"}</button>
<button type="submit" class="btn btn-default btn-primary"><span class="glyphicon glyphicon-check"></span> {intl l="Yes"}</button>
</div>
</form>
</div>
</div> </div>
<div class="modal-body">
<p>{intl l="Do you really want to delete this mailing template ?"}</p>
</div>
<form method="post" action="{url path='/admin/configuration/messages/delete'}">
<input type="hidden" name="message_id" id="message_delete_id" value="" />
<div class="modal-footer">
<button type="submit" class="btn btn-default btn-primary">{intl l="Yes"}</button>
<button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true">{intl l="No"}</button>
</div>
</form>
</div> </div>
{/block} {/block}

View File

@@ -27,7 +27,7 @@
</div> </div>
<div class="form-container"> <div class="form-container">
<div class="form-horizontal col-md-12"> <div class="col-md-12">
{form name="thelia.admin.config.modification"} {form name="thelia.admin.config.modification"}
<form method="POST" action="{url path='/admin/configuration/variables/save'}" {form_enctype form=$form}> <form method="POST" action="{url path='/admin/configuration/variables/save'}" {form_enctype form=$form}>
<fieldset> <fieldset>
@@ -56,53 +56,30 @@
<input type="hidden" name="{$name}" value="{$edit_language_locale}" /> <input type="hidden" name="{$name}" value="{$edit_language_locale}" />
{/form_field} {/form_field}
{if #form_error}<div class="alert alert-block alert-error">#form_error_message</div>{/if} {if #form_error}<div class="alert alert-danger">#form_error_message</div>{/if}
<div class="control-group"> {form_field form=$form field='name'}
<div class="form-group {if $error}has-error{/if}">
<label class="control-label"> <label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
{intl l='Name *'} <input type="text" id="{$label_attr.for}" required="required" name="{$name}" value="{$value|htmlspecialchars}" title="{intl l='Variable name'}" placeholder="{intl l='Variable name'}" class="form-control">
</label>
<div class="controls">
{form_field form=$form field='name'}
<span {if $error}class="error"{/if}>
<input type="text" required="required" name="{$name}" value="{$value|htmlspecialchars}" title="{intl l='Variable name'}" placeholder="{intl l='Variable name'}" class="input-block-level">
</span>
{/form_field}
</div>
</div> </div>
{/form_field}
<div class="control-group"> {form_field form=$form field='value'}
<label class="control-label"> <div class="form-group {if $error}has-error{/if}">
{intl l='Value'} <label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
</label> <input type="text" id="{$label_attr.for}" name="{$name}" value="{$value|htmlspecialchars}" title="{intl l='Variable value'}" placeholder="{intl l='Variable value'}" class="form-control">
<div class="controls">
{form_field form=$form field='value'}
<span {if $error}class="error"{/if}>
<input type="text" name="{$name}" value="{$value|htmlspecialchars}" title="{intl l='Variable value'}" placeholder="{intl l='Variable value'}" class="input-block-level">
</span>
{/form_field}
</div>
</div> </div>
{/form_field}
<div class="control-group"> {form_field form=$form field='secured'}
<label class="control-label"> <div class="checkbox {if $error}has-error{/if}">
{intl l='Secured'} <label>
</label> <input type="checkbox" name="{$name}" value="1" {if $value == 1}checked="checked"{/if}>
{intl l="{$label}"}
<div class="controls"> </label>
{form_field form=$form field='secured'}
<span {if $error}class="error"{/if}>
<label class="checkbox">
<input type="checkbox" name="{$name}" value="1" {if $value == 1}checked="checked"{/if}>
{intl l="Prevent variable modification or deletion, except for super-admin"}
</label>
</span>
{/form_field}
</div>
</div> </div>
{/form_field}
{include file="includes/standard-description-form-fields.html"} {include file="includes/standard-description-form-fields.html"}

View File

@@ -22,99 +22,105 @@
<form action="{url path='/admin/configuration/variables/update-values'}" method="post"> <form action="{url path='/admin/configuration/variables/update-values'}" method="post">
<div class="general-block-decorator"> <div class="general-block-decorator">
<table class="table table-striped table-condensed table-left-aligned"> <table class="table table-striped table-condensed table-left-aligned">
<caption> <caption class="clearfix">
{intl l='Thelia system variables'} {intl l='Thelia system variables'}
{loop type="auth" name="can_create" roles="ADMIN" permissions="admin.configuration.variables.create"} {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.configuration.variables.create"}
<a class="btn btn-default btn-primary action-btn" title="{intl l='Add a new variable'}" href="#add_variable_dialog" data-toggle="modal"> <div class="pull-right">
<span class="glyphicon glyphicon-plus-sign"></span> <a class="btn btn-default btn-primary action-btn" title="{intl l='Add a new variable'}" href="#add_variable_dialog" data-toggle="modal">
</a> <span class="glyphicon glyphicon-plus-sign"></span>
<button class="btn btn-default btn-primary action-btn" title="{intl l='Save chages'}">{intl l='Save changes'} <span class="glyphicon glyphicon-ok"></span></button> </a>
<button class="btn btn-default btn-primary" title="{intl l='Save chages'}"><span class="glyphicon glyphicon-ok"></span> {intl l='Save changes'}</button>
</div>
{/loop} {/loop}
</caption> </caption>
<tr>
<th>
{admin_sortable_header
current_order=$order
order='title'
reverse_order='title_reverse'
path={url path='/admin/configuration/variables'}
label={intl l='Purpose'}
}
</th>
<th> <thead>
{admin_sortable_header <tr>
current_order=$order <th>
order='name' {admin_sortable_header
reverse_order='name_reverse' current_order=$order
path={url path='/admin/configuration/variables'} order='title'
label={intl l='Name'} reverse_order='title_reverse'
} path={url path='/admin/configuration/variables'}
</th> label={intl l='Purpose'}
}
</th>
<th> <th>
{admin_sortable_header {admin_sortable_header
current_order=$order current_order=$order
order='value' order='name'
reverse_order='value_reverse' reverse_order='name_reverse'
path={url path='/admin/configuration/variables'} path={url path='/admin/configuration/variables'}
label={intl l='Value'} label={intl l='Name'}
} }
</th> </th>
{module_include location='variables_table_header'} <th>
{admin_sortable_header
current_order=$order
order='value'
reverse_order='value_reverse'
path={url path='/admin/configuration/variables'}
label={intl l='Value'}
}
</th>
<th>&nbsp;</th> {module_include location='variables_table_header'}
</tr>
{loop name="config" type="config" hidden="0" secured="*" backend_context="1" lang="$lang_id" order="$order"} <th>{intl l='Action'}</th>
<tr> </tr>
</thead>
<tbody>
{loop name="config" type="config" hidden="0" secured="*" backend_context="1" lang="$lang_id" order="$order"}
<tr>
<td>{$TITLE}</td> <td>{$TITLE}</td>
<td> <td>
{if ! $SECURED} {if ! $SECURED}
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.variables.change"} {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.variables.change"}
<a title="{intl l='Change this variable'}" href="{url path='/admin/configuration/variables/update' variable_id="$ID"}">{$NAME}</a> <a title="{intl l='Change this variable'}" href="{url path='/admin/configuration/variables/update' variable_id="$ID"}">{$NAME}</a>
{/loop} {/loop}
{elseloop rel="can_change"} {elseloop rel="can_change"}
{$NAME} {$NAME}
{/elseloop} {/elseloop}
{else} {else}
{$NAME} {$NAME}
{/if} {/if}
</td> </td>
<td> <td>
{if $SECURED} {if $SECURED}
{$VALUE} {$VALUE}
{else} {else}
<input id="cancelable_edit_{$ID}" class="js-edit" data-id="{$ID}" type="text" name="variable[{$ID}]" value="{$VALUE|htmlspecialchars}" /> <input id="cancelable_edit_{$ID}" class="js-edit form-control" data-id="{$ID}" type="text" name="variable[{$ID}]" value="{$VALUE|htmlspecialchars}" />
{/if} {/if}
</td> </td>
{module_include location='variables_table_row'} {module_include location='variables_table_row'}
<td class="actions"> <td class="actions">
{if ! $SECURED} {if ! $SECURED}
<div class="btn-group"> <div class="btn-group">
<a class="btn btn-default btn-xs cancel-edit" id="cancel_edit_btn_{$ID}" data-id="{$ID}" title="{intl l='Cancel changes and revert to original value'}" href="#"><i class="glyphicon glyphicon-remove"></i></a> <a class="btn btn-default btn-xs cancel-edit" id="cancel_edit_btn_{$ID}" data-id="{$ID}" title="{intl l='Cancel changes and revert to original value'}" href="#"><i class="glyphicon glyphicon-remove"></i></a>
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.variables.change"} {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.variables.change"}
<a class="btn btn-default btn-xs config-change" title="{intl l='Change this variable'}" href="{url path='/admin/configuration/variables/update' variable_id="$ID"}"><i class="glyphicon glyphicon-edit"></i></a> <a class="btn btn-default btn-xs config-change" title="{intl l='Change this variable'}" href="{url path='/admin/configuration/variables/update' variable_id="$ID"}"><i class="glyphicon glyphicon-edit"></i></a>
{/loop} {/loop}
{loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.configuration.variables.delete"} {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.configuration.variables.delete"}
<a class="btn btn-default btn-xs config-delete" title="{intl l='Delete this variable'}" href="#delete_variable_dialog" data-id="{$ID}" data-toggle="modal"><i class="glyphicon glyphicon-trash"></i></a> <a class="btn btn-default btn-xs config-delete" title="{intl l='Delete this variable'}" href="#delete_variable_dialog" data-id="{$ID}" data-toggle="modal"><i class="glyphicon glyphicon-trash"></i></a>
{/loop} {/loop}
</div> </div>
{else} {else}
<i title="{intl l='This variable could not be changed.'}" class="glyphicon glyphicon-ban-circle"></i> <i title="{intl l='This variable could not be changed.'}" class="glyphicon glyphicon-ban-circle"></i>
{/if} {/if}
</td> </td>
</tr> </tr>
{/loop} {/loop}
</tbody>
</table> </table>
</div> </div>
</form> </form>
@@ -129,129 +135,115 @@
{* Adding a new variable *} {* Adding a new variable *}
<div class="modal hide fade" id="add_variable_dialog" tabindex="-1" role="dialog" aria-hidden="true"> <div class="modal fade" id="add_variable_dialog" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3>{intl l="Create a new variable"}</h3> <h3>{intl l="Create a new variable"}</h3>
</div> </div>
{form name="thelia.admin.config.creation"} {form name="thelia.admin.config.creation"}
<form method="POST" action="{url path='/admin/configuration/variables/create'}" {form_enctype form=$form}> <form method="POST" action="{url path='/admin/configuration/variables/create'}" {form_enctype form=$form}>
{form_hidden_fields form=$form} {form_hidden_fields form=$form}
{form_field form=$form field='success_url'} {form_field form=$form field='success_url'}
{* on success, redirect to the edition page, _ID_ is replaced with the created variable ID, see controller *} {* on success, redirect to the edition page, _ID_ is replaced with the created variable ID, see controller *}
<input type="hidden" name="{$name}" value="{url path='/admin/configuration/variables/update' variable_id='_ID_'}" /> <input type="hidden" name="{$name}" value="{url path='/admin/configuration/variables/update' variable_id='_ID_'}" />
{/form_field} {/form_field}
{* We do not allow users to create hidden or secured variables from here *} {* We do not allow users to create hidden or secured variables from here *}
{form_field form=$form field='hidden'} {form_field form=$form field='hidden'}
<input type="hidden" name="{$name}" value="0" /> <input type="hidden" name="{$name}" value="0" />
{/form_field} {/form_field}
{form_field form=$form field='secured'} {form_field form=$form field='secured'}
<input type="hidden" name="{$name}" value="0" /> <input type="hidden" name="{$name}" value="0" />
{/form_field} {/form_field}
<div class="modal-body"> <div class="modal-body">
{if #form_error}<div class="alert alert-block alert-error" id="add_variable_dialog_error">#form_error_message</div>{/if} {if #form_error}<div class="alert alert-error" id="add_variable_dialog_error">#form_error_message</div>{/if}
<div class="control-group"> {form_field form=$form field='name'}
<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='Variable name'}" placeholder="{intl l='Variable name'}" class="form-control">
</div>
{/form_field}
<label class="control-label"> {form_field form=$form field='value'}
{intl l='Name *'} <div class="form-group {if $error}has-error{/if}">
</label> <label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" value="{$value}" title="{intl l='Variable value'}" placeholder="{intl l='Variable value'}" class="form-control">
</div>
{/form_field}
<div class="controls"> {form_field form=$form field='title'}
{form_field form=$form field='name'} <div class="form-group {if $error}has-error{/if}">
<span {if $error}class="error"{/if}> <label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" required="required" name="{$name}" value="{$value}" title="{intl l='Variable name'}" placeholder="{intl l='Variable name'}" class="input-block-level">
</span>
{/form_field}
</div>
</div>
<div class="control-group"> {loop type="lang" name="default-lang" default_only="1"}
<label class="control-label"> {* Switch edition to the current locale *}
{intl l='Value'} <input type="hidden" name="edit_language_id" value="{$ID}" />
</label>
<div class="controls"> <div class="input-group">
{form_field form=$form field='value'} <input type="text" id="{$label_attr.for}" required="required" name="{$name}" value="{$value}" title="{intl l='Variable purpose'}" placeholder="{intl l='Variable purpose'}" class="form-control">
<span {if $error}class="error"{/if}> <span class="input-group-addon"><img src="{image file="assets/img/flags/{$CODE}.gif"}" alt="{intl l=$TITLE}" /></span>
<input type="text" name="{$name}" value="{$value}" title="{intl l='Variable value'}" placeholder="{intl l='Variable value'}" class="input-block-level"> </div>
</span>
{/form_field}
</div>
</div>
<div class="control-group"> <div class="help-block">{intl l="Enter here the variable purpose in the default language ($TITLE)"}</div>
<label class="control-label">
{intl l='Purpose *'}
</label>
<div class="controls"> {form_field form=$form field='locale'}
{loop type="lang" name="default-lang" default_only="1"}
{* 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}" /> <input type="hidden" name="{$name}" value="{$LOCALE}" />
{/form_field} {/form_field}
{/loop}
</div>
{/form_field}
<div class="input-group input-block-level"> </div>
{form_field form=$form field='title'}
<span {if $error}class="error"{/if}>
<input type="text" required="required" name="{$name}" value="{$value}" title="{intl l='Variable purpose'}" placeholder="{intl l='Variable purpose'}" class="input-block-level">
</span>
{/form_field}
<span class="input-group-addon"><img src="{image file="assets/img/flags/{$CODE}.gif"}" alt="{intl l=$TITLE}" /></span>
</div>
<div class="help-block">{intl l="Enter here the variable purpose in the default language ($TITLE)"}</div> <div class="modal-footer">
{/loop} <button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true"><span class="glyphicon glyphicon-remove"></span> {intl l="Cancel"}</button>
</div> <button type="submit" class="btn btn-default btn-primary"><span class="glyphicon glyphicon-check"></span> {intl l="Create this variable"}</button>
</div> </div>
</div> </form>
{/form}
<div class="modal-footer"> </div>
<button type="submit" class="btn btn-default btn-primary">{intl l="Create this variable"}</button> </div>
<button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true">{intl l="Cancel"}</button>
</div>
</form>
{/form}
</div> </div>
{* Delete confirmation dialog *} {* Delete confirmation dialog *}
<div class="modal hide fade" id="delete_variable_dialog" tabindex="-1" role="dialog" aria-hidden="true"> <div class="modal fade" id="delete_variable_dialog" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3>{intl l="Delete a variable"}</h3> <h3>{intl l="Delete a variable"}</h3>
</div>
<div class="modal-body">
<p>{intl l="Do you really want to delete this variable ?"}</p>
</div>
<form method="post" action="{url path='/admin/configuration/variables/delete'}">
<input type="hidden" name="variable_id" id="variable_delete_id" value="" />
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true"><span class="glyphicon glyphicon-remove"></span> {intl l="No"}</button>
<button type="submit" class="btn btn-default btn-primary"><span class="glyphicon glyphicon-check"></span> {intl l="Yes"}</button>
</div>
</form>
</div> </div>
</div>
<div class="modal-body">
<p>{intl l="Do you really want to delete this variable ?"}</p>
</div>
<form method="post" action="{url path='/admin/configuration/variables/delete'}">
<input type="hidden" name="variable_id" id="variable_delete_id" value="" />
<div class="modal-footer">
<button type="submit" class="btn btn-default btn-primary">{intl l="Yes"}</button>
<button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true">{intl l="No"}</button>
</div>
</form>
</div> </div>
{/block} {/block}