Merge branch 'master' of github.com:thelia/thelia

This commit is contained in:
Etienne Roudeix
2013-09-06 16:14:38 +02:00
36 changed files with 1333 additions and 678 deletions

View File

@@ -24,6 +24,7 @@
namespace Thelia\Command; namespace Thelia\Command;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Filesystem\Exception\IOException; use Symfony\Component\Filesystem\Exception\IOException;
@@ -44,7 +45,14 @@ class CacheClear extends ContainerAwareCommand
{ {
$this $this
->setName("cache:clear") ->setName("cache:clear")
->setDescription("Invalidate all caches"); ->setDescription("Invalidate all caches")
->addOption(
"without-assets",
null,
InputOption::VALUE_NONE,
"remove cache assets"
)
;
} }
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
@@ -52,20 +60,28 @@ class CacheClear extends ContainerAwareCommand
$cacheDir = $this->getContainer()->getParameter("kernel.cache_dir"); $cacheDir = $this->getContainer()->getParameter("kernel.cache_dir");
if (!is_writable($cacheDir)) { $this->clearCache($cacheDir, $output);
throw new \RuntimeException(sprintf('Unable to write in the "%s" directory', $cacheDir)); if(!$input->getOption("without-assets")) {
} $this->clearCache(THELIA_WEB_DIR . "/assets", $output);
$output->writeln(sprintf("Clearing cache in <info>%s</info> directory", $cacheDir));
$fs = new Filesystem();
try {
$fs->remove($cacheDir);
$output->writeln("<info>cache cleared successfully</info>");
} catch (IOException $e) {
$output->writeln(sprintf("error during clearing cache : %s", $e->getMessage()));
} }
} }
protected function clearCache($dir, OutputInterface $output)
{
if (!is_writable($dir)) {
throw new \RuntimeException(sprintf('Unable to write in the "%s" directory', $dir));
}
$output->writeln(sprintf("Clearing cache in <info>%s</info> directory", $dir));
$fs = new Filesystem();
try {
$fs->remove($dir);
$output->writeln(sprintf("<info>%s cache dir cleared successfully</info>", $dir));
} catch (IOException $e) {
$output->writeln(sprintf("error during clearing cache : %s", $e->getMessage()));
}
}
} }

View File

@@ -129,6 +129,7 @@
<service id="smarty.plugin.assetic" class="Thelia\Core\Template\Smarty\Plugins\Assetic" > <service id="smarty.plugin.assetic" class="Thelia\Core\Template\Smarty\Plugins\Assetic" >
<tag name="thelia.parser.register_plugin"/> <tag name="thelia.parser.register_plugin"/>
<argument>%kernel.environment%</argument>
</service> </service>
<service id="smarty.plugin.theliasyntax" class="Thelia\Core\Template\Smarty\Plugins\TheliaSyntax" > <service id="smarty.plugin.theliasyntax" class="Thelia\Core\Template\Smarty\Plugins\TheliaSyntax" >

View File

@@ -113,10 +113,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

@@ -241,7 +241,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)
); );
} }

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

@@ -43,15 +43,16 @@ class AsseticHelper
* Generates assets from $asset_path in $output_path, using $filters. * Generates assets from $asset_path in $output_path, using $filters.
* *
* @param string $asset_path the full path to the asset file (or file collection) * @param string $asset_path the full path to the asset file (or file collection)
* @param unknown $output_path the full disk path to the output directory (shoud be visible to web server) * @param string $output_path the full disk path to the output directory (shoud be visible to web server)
* @param unknown $output_url the URL to the generated asset directory * @param string $output_url the URL to the generated asset directory
* @param unknown $asset_type the asset type: css, js, ... The generated files will have this extension. Pass an empty string to use the asset source extension. * @param string $asset_type the asset type: css, js, ... The generated files will have this extension. Pass an empty string to use the asset source extension.
* @param unknown $filters a list of filters, as defined below (see switch($filter_name) ...) * @param array $filters a list of filters, as defined below (see switch($filter_name) ...)
* @param unknown $debug true / false * @param boolean $debug true / false
* @param boolean $dev_mode true / false. If true, assets are not cached and always compiled.
* @throws \InvalidArgumentException if an invalid filter name is found * @throws \InvalidArgumentException if an invalid filter name is found
* @return string The URL to the generated asset file. * @return string The URL to the generated asset file.
*/ */
public function asseticize($asset_path, $output_path, $output_url, $asset_type, $filters, $debug) public function asseticize($asset_path, $output_path, $output_url, $asset_type, $filters, $debug, $dev_mode = false)
{ {
$asset_name = basename($asset_path); $asset_name = basename($asset_path);
$asset_dir = dirname($asset_path); $asset_dir = dirname($asset_path);
@@ -112,6 +113,7 @@ class AsseticHelper
$asset = $factory->createAsset($asset_name); $asset = $factory->createAsset($asset_name);
$asset_target_path = $asset->getTargetPath(); $asset_target_path = $asset->getTargetPath();
$target_file = sprintf("%s/%s", $output_path, $asset_target_path); $target_file = sprintf("%s/%s", $output_path, $asset_target_path);
// As it seems that assetic cannot handle a real file cache, let's do the job ourselves. // As it seems that assetic cannot handle a real file cache, let's do the job ourselves.
@@ -124,7 +126,7 @@ class AsseticHelper
// //
// before generating 3bc974a-ad3ef47.css, delete 3bc974a-* files. // before generating 3bc974a-ad3ef47.css, delete 3bc974a-* files.
// //
if (! file_exists($target_file)) { if ($dev_mode == true || ! file_exists($target_file)) {
// Delete previous version of the file // Delete previous version of the file
list($commonPart, $dummy) = explode('-', $asset_target_path); list($commonPart, $dummy) = explode('-', $asset_target_path);
@@ -143,8 +145,6 @@ class AsseticHelper
} }
} }
//$cache = new AssetCache($asset, new FilesystemCache($output_path));
$writer = new AssetWriter($output_path); $writer = new AssetWriter($output_path);
$writer->writeAsset($asset); $writer->writeAsset($asset);

View File

@@ -34,18 +34,22 @@ class SmartyAssetsManager
private $web_root; private $web_root;
private $path_relative_to_web_root; private $path_relative_to_web_root;
private $developmentMode;
/** /**
* Creates a new SmartyAssetsManager instance * Creates a new SmartyAssetsManager instance
* *
* @param string $web_root the disk path to the web root * @param string $web_root the disk path to the web root
* @param string $path_relative_to_web_root the path (relative to web root) where the assets will be generated * @param string $path_relative_to_web_root the path (relative to web root) where the assets will be generated
* @param boolean $developmentMode true / false. If true, assets are not cached, and always generated.
*/ */
public function __construct($web_root, $path_relative_to_web_root) public function __construct($web_root, $path_relative_to_web_root, $developmentMode)
{ {
$this->web_root = $web_root; $this->web_root = $web_root;
$this->path_relative_to_web_root = $path_relative_to_web_root; $this->path_relative_to_web_root = $path_relative_to_web_root;
$this->developmentMode = $developmentMode;
$this->assetic_manager = new AsseticHelper(); $this->assetic_manager = new AsseticHelper();
} }
@@ -73,7 +77,8 @@ class SmartyAssetsManager
URL::getInstance()->absoluteUrl($this->path_relative_to_web_root, null, URL::PATH_TO_FILE /* path only */), URL::getInstance()->absoluteUrl($this->path_relative_to_web_root, null, URL::PATH_TO_FILE /* path only */),
$assetType, $assetType,
$filters, $filters,
$debug $debug,
$this->developmentMode
); );
return $url; return $url;

View File

@@ -121,7 +121,7 @@ class AdminUtilities extends AbstractSmartyPlugin
} }
if (! empty($icon)) if (! empty($icon))
$output = sprintf('<i class="icon icon-chevron-%s"></i> ', $icon); $output = sprintf('<i class="glyphicon glyphicon-chevron-%s"></i> ', $icon);
else else
$output = ''; $output = '';

View File

@@ -32,13 +32,13 @@ class Assetic extends AbstractSmartyPlugin
{ {
public $assetManager; public $assetManager;
public function __construct() public function __construct($developmentMode)
{ {
$web_root = THELIA_WEB_DIR; $web_root = THELIA_WEB_DIR;
$asset_dir_from_web_root = ConfigQuery::read('asset_dir_from_web_root', 'assets'); $asset_dir_from_web_root = ConfigQuery::read('asset_dir_from_web_root', 'assets');
$this->assetManager = new SmartyAssetsManager($web_root, $asset_dir_from_web_root); $this->assetManager = new SmartyAssetsManager($web_root, $asset_dir_from_web_root, $developmentMode == 'dev');
} }
public function blockJavascripts($params, $content, \Smarty_Internal_Template $template, &$repeat) public function blockJavascripts($params, $content, \Smarty_Internal_Template $template, &$repeat)

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

@@ -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

@@ -47,6 +47,7 @@ class CacheClearTest extends \PHPUnit_Framework_TestCase
$fs = new Filesystem(); $fs = new Filesystem();
$fs->mkdir($this->cache_dir); $fs->mkdir($this->cache_dir);
$fs->mkdir(THELIA_WEB_DIR . "/assets");
} }
public function testCacheClear() public function testCacheClear()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@@ -0,0 +1,382 @@
/*! ============================================================
* bootstrapSwitch v1.8 by Larentis Mattia @SpiritualGuru
* http://www.larentis.eu/
*
* Enhanced for radiobuttons by Stein, Peter @BdMdesigN
* http://www.bdmdesign.org/
*
* Project site:
* http://www.larentis.eu/switch/
* ============================================================
* Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
* ============================================================ */
!function ($) {
"use strict";
$.fn['bootstrapSwitch'] = function (method) {
var inputSelector = 'input[type!="hidden"]';
var methods = {
init: function () {
return this.each(function () {
var $element = $(this)
, $div
, $switchLeft
, $switchRight
, $label
, $form = $element.closest('form')
, myClasses = ""
, classes = $element.attr('class')
, color
, moving
, onLabel = "ON"
, offLabel = "OFF"
, icon = false
, textLabel = false;
$.each(['switch-mini', 'switch-small', 'switch-large'], function (i, el) {
if (classes.indexOf(el) >= 0)
myClasses = el;
});
$element.addClass('has-switch');
if ($element.data('on') !== undefined)
color = "switch-" + $element.data('on');
if ($element.data('on-label') !== undefined)
onLabel = $element.data('on-label');
if ($element.data('off-label') !== undefined)
offLabel = $element.data('off-label');
if ($element.data('label-icon') !== undefined)
icon = $element.data('label-icon');
if ($element.data('text-label') !== undefined)
textLabel = $element.data('text-label');
$switchLeft = $('<span>')
.addClass("switch-left")
.addClass(myClasses)
.addClass(color)
.html(onLabel);
color = '';
if ($element.data('off') !== undefined)
color = "switch-" + $element.data('off');
$switchRight = $('<span>')
.addClass("switch-right")
.addClass(myClasses)
.addClass(color)
.html(offLabel);
$label = $('<label>')
.html("&nbsp;")
.addClass(myClasses)
.attr('for', $element.find(inputSelector).attr('id'));
if (icon) {
$label.html('<i class="icon ' + icon + '"></i>');
}
if (textLabel) {
$label.html('' + textLabel + '');
}
$div = $element.find(inputSelector).wrap($('<div>')).parent().data('animated', false);
if ($element.data('animated') !== false)
$div.addClass('switch-animate').data('animated', true);
$div
.append($switchLeft)
.append($label)
.append($switchRight);
$element.find('>div').addClass(
$element.find(inputSelector).is(':checked') ? 'switch-on' : 'switch-off'
);
if ($element.find(inputSelector).is(':disabled'))
$(this).addClass('deactivate');
var changeStatus = function ($this) {
if ($element.parent('label').is('.label-change-switch')) {
} else {
$this.siblings('label').trigger('mousedown').trigger('mouseup').trigger('click');
}
};
$element.on('keydown', function (e) {
if (e.keyCode === 32) {
e.stopImmediatePropagation();
e.preventDefault();
changeStatus($(e.target).find('span:first'));
}
});
$switchLeft.on('click', function (e) {
changeStatus($(this));
});
$switchRight.on('click', function (e) {
changeStatus($(this));
});
$element.find(inputSelector).on('change', function (e, skipOnChange) {
var $this = $(this)
, $element = $this.parent()
, thisState = $this.is(':checked')
, state = $element.is('.switch-off');
e.preventDefault();
$element.css('left', '');
if (state === thisState) {
if (thisState)
$element.removeClass('switch-off').addClass('switch-on');
else $element.removeClass('switch-on').addClass('switch-off');
if ($element.data('animated') !== false)
$element.addClass("switch-animate");
if (typeof skipOnChange === 'boolean' && skipOnChange)
return;
$element.parent().trigger('switch-change', {'el': $this, 'value': thisState})
}
});
$element.find('label').on('mousedown touchstart', function (e) {
var $this = $(this);
moving = false;
e.preventDefault();
e.stopImmediatePropagation();
$this.closest('div').removeClass('switch-animate');
if ($this.closest('.has-switch').is('.deactivate')) {
$this.unbind('click');
} else if ($this.closest('.switch-on').parent().is('.radio-no-uncheck')) {
$this.unbind('click');
} else {
$this.on('mousemove touchmove', function (e) {
var $element = $(this).closest('.make-switch')
, relativeX = (e.pageX || e.originalEvent.targetTouches[0].pageX) - $element.offset().left
, percent = (relativeX / $element.width()) * 100
, left = 25
, right = 75;
moving = true;
if (percent < left)
percent = left;
else if (percent > right)
percent = right;
$element.find('>div').css('left', (percent - right) + "%")
});
$this.on('click touchend', function (e) {
var $this = $(this)
, $myInputBox = $this.siblings('input');
e.stopImmediatePropagation();
e.preventDefault();
$this.unbind('mouseleave');
if (moving)
$myInputBox.prop('checked', !(parseInt($this.parent().css('left')) < -25));
else
$myInputBox.prop("checked", !$myInputBox.is(":checked"));
moving = false;
$myInputBox.trigger('change');
});
$this.on('mouseleave', function (e) {
var $this = $(this)
, $myInputBox = $this.siblings('input');
e.preventDefault();
e.stopImmediatePropagation();
$this.unbind('mouseleave mousemove');
$this.trigger('mouseup');
$myInputBox.prop('checked', !(parseInt($this.parent().css('left')) < -25)).trigger('change');
});
$this.on('mouseup', function (e) {
e.stopImmediatePropagation();
e.preventDefault();
$(this).trigger('mouseleave');
});
}
});
if ($form.data('bootstrapSwitch') !== 'injected') {
$form.bind('reset', function () {
setTimeout(function () {
$form.find('.make-switch').each(function () {
var $input = $(this).find(inputSelector);
$input.prop('checked', $input.is(':checked')).trigger('change');
});
}, 1);
});
$form.data('bootstrapSwitch', 'injected');
}
}
);
},
toggleActivation: function () {
var $this = $(this);
$this.toggleClass('deactivate');
$this.find(inputSelector).prop('disabled', $this.is('.deactivate'));
},
isActive: function () {
return !$(this).hasClass('deactivate');
},
setActive: function (active) {
var $this = $(this);
if (active) {
$this.removeClass('deactivate');
$this.find(inputSelector).removeAttr('disabled');
}
else {
$this.addClass('deactivate');
$this.find(inputSelector).attr('disabled', 'disabled');
}
},
toggleState: function (skipOnChange) {
var $input = $(this).find(':checkbox');
$input.prop('checked', !$input.is(':checked')).trigger('change', skipOnChange);
},
toggleRadioState: function (skipOnChange) {
var $radioinput = $(this).find(':radio');
$radioinput.not(':checked').prop('checked', !$radioinput.is(':checked')).trigger('change', skipOnChange);
},
toggleRadioStateAllowUncheck: function (uncheck, skipOnChange) {
var $radioinput = $(this).find(':radio');
if (uncheck) {
$radioinput.not(':checked').trigger('change', skipOnChange);
}
else {
$radioinput.not(':checked').prop('checked', !$radioinput.is(':checked')).trigger('change', skipOnChange);
}
},
setState: function (value, skipOnChange) {
$(this).find(inputSelector).prop('checked', value).trigger('change', skipOnChange);
},
setOnLabel: function (value) {
var $switchLeft = $(this).find(".switch-left");
$switchLeft.html(value);
},
setOffLabel: function (value) {
var $switchRight = $(this).find(".switch-right");
$switchRight.html(value);
},
setOnClass: function (value) {
var $switchLeft = $(this).find(".switch-left");
var color = '';
if (value !== undefined) {
if ($(this).attr('data-on') !== undefined) {
color = "switch-" + $(this).attr('data-on')
}
$switchLeft.removeClass(color);
color = "switch-" + value;
$switchLeft.addClass(color);
}
},
setOffClass: function (value) {
var $switchRight = $(this).find(".switch-right");
var color = '';
if (value !== undefined) {
if ($(this).attr('data-off') !== undefined) {
color = "switch-" + $(this).attr('data-off')
}
$switchRight.removeClass(color);
color = "switch-" + value;
$switchRight.addClass(color);
}
},
setAnimated: function (value) {
var $element = $(this).find(inputSelector).parent();
if (value === undefined) value = false;
$element.data('animated', value);
$element.attr('data-animated', value);
if ($element.data('animated') !== false) {
$element.addClass("switch-animate");
} else {
$element.removeClass("switch-animate");
}
},
setSizeClass: function (value) {
var $element = $(this);
var $switchLeft = $element.find(".switch-left");
var $switchRight = $element.find(".switch-right");
var $label = $element.find("label");
$.each(['switch-mini', 'switch-small', 'switch-large'], function (i, el) {
if (el !== value) {
$switchLeft.removeClass(el);
$switchRight.removeClass(el);
$label.removeClass(el);
} else {
$switchLeft.addClass(el);
$switchRight.addClass(el);
$label.addClass(el);
}
});
},
status: function () {
return $(this).find(inputSelector).is(':checked');
},
destroy: function () {
var $element = $(this)
, $div = $element.find('div')
, $form = $element.closest('form')
, $inputbox;
$div.find(':not(input)').remove();
$inputbox = $div.children();
$inputbox.unwrap().unwrap();
$inputbox.unbind('change');
if ($form) {
$form.unbind('reset');
$form.removeData('bootstrapSwitch');
}
return $inputbox;
}
};
if (methods[method])
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
else if (typeof method === 'object' || !method)
return methods.init.apply(this, arguments);
else
$.error('Method ' + method + ' does not exist!');
};
}(jQuery);
(function ($) {
$(function () {
$('.make-switch')['bootstrapSwitch']();
});
})(jQuery);

View File

@@ -3,6 +3,4 @@
/* Thelia Admin */ /* Thelia Admin */
@import "thelia/thelia.less"; @import "thelia/thelia.less";
// @import "thelia/responsive.less"; // @import "thelia/responsive.less";
//mmm

View File

@@ -0,0 +1,160 @@
.has-switch {
display: inline-block;
cursor: pointer;
border-radius: @input-border-radius;
border: 1px solid;
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
position: relative;
text-align: left;
overflow: hidden;
line-height: 8px;
.user-select(none);
vertical-align: middle;
min-width: 100px;
&.switch-mini {
min-width: 72px;
}
&.switch-mini i.switch-mini-icons {
height: 1.20em;
line-height: 9px;
vertical-align: text-top;
text-align: center;
transform: scale(0.6);
margin-top: -1px;
margin-bottom: -1px;
}
&.switch-small {
min-width: 80px;
}
&.switch-large {
min-width: 120px;
}
&.deactivate {
.opacity(50);
cursor: default !important;
label, span {
cursor: default !important;
}
}
> div {
display: inline-block;
width: 150%;
position: relative;
top: 0;
&.switch-animate {
.transition(left 0.5s);
}
&.switch-off {
left: -50%;
}
&.switch-on {
left: 0%;
}
}
input[type=radio],
input[type=checkbox] {
//debug
display: none;
//position: absolute;
//margin-left: 60%;
//z-index: 123;
}
span, label {
.box-sizing(border-box);
cursor: pointer;
position: relative;
display: inline-block;
height: 100%;
padding-bottom: 4px;
padding-top: 4px;
font-size: 14px;
line-height: 20px;
&.switch-mini {
padding-bottom: 4px;
padding-top: 4px;
font-size: 10px;
line-height: 9px;
}
&.switch-small {
padding-bottom: 3px;
padding-top: 3px;
font-size: 12px;
line-height: 18px;
}
&.switch-large {
padding-bottom: 9px;
padding-top: 9px;
font-size: 16px;
line-height: normal;
}
}
label {
text-align: center;
margin-top: -1px;
margin-bottom: -1px;
z-index: 100;
width: 34%;
border-left: 1px solid @btn-default-border;
border-right: 1px solid @btn-default-border;
.button-variant(@btn-default-color, @btn-default-bg, @btn-default-border);
i {
color: #000;
text-shadow: 0 1px 0 #fff;
line-height: 18px;
pointer-events: none;
}
}
span {
text-align: center;
z-index: 1;
width: 33%;
&.switch-left {
.border-left-radius(@input-border-radius);
}
&.switch-right {
.button-variant(@btn-default-color, @btn-default-bg, @btn-default-border);
.border-right-radius(@input-border-radius);
}
&.switch-primary, &.switch-left {
.button-variant(@btn-primary-color, @btn-primary-bg, @btn-primary-border);
}
&.switch-info {
.button-variant(@btn-info-color, @btn-info-bg, @btn-info-border);
}
&.switch-success {
.button-variant(@btn-success-color, @btn-success-bg, @btn-success-border);
}
&.switch-warning {
.button-variant(@btn-warning-color, @btn-warning-bg, @btn-warning-border);
}
&.switch-danger {
.button-variant(@btn-danger-color, @btn-danger-bg, @btn-danger-border);
}
&.switch-default {
.button-variant(@btn-default-color, @btn-default-bg, @btn-default-border);
}
}
}

View File

@@ -9,6 +9,7 @@
@import "tables.less"; @import "tables.less";
@import "tablesorter.less"; @import "tablesorter.less";
@import "bootstrap-editable.less"; @import "bootstrap-editable.less";
@import "bootstrap-switch.less";
// -- Base styling ------------------------------------------------------------ // -- Base styling ------------------------------------------------------------

View File

@@ -44,4 +44,10 @@
// Used for a bird's eye view of components dependent on the z-axis // Used for a bird's eye view of components dependent on the z-axis
// Try to avoid customizing these :) // Try to avoid customizing these :)
@zindex-dropdown: 1005; @zindex-dropdown: 1005;
// Forms
// -------------------------
@input-border-focus: @link-color;

View File

@@ -74,7 +74,7 @@
} }
</th> </th>
<th>&nbsp;</th> <th>{intl l='Actions'}</th>
</tr> </tr>
</thead> </thead>
@@ -83,7 +83,7 @@
<tr> <tr>
<td> <td>
i={$ID} {loop type="image" name="cat_image" source="category" source_id="$ID" limit="1" width="50" height="50" resize_mode="crop" backend_context="1"} i={$ID} {loop type="image" name="cat_image" source="category" source_id="$ID" limit="1" width="50" height="50" resize_mode="crop" backend_context="1"}
<a href="{url path='admin/catalog/category' id="$ID" action='browse'}" title="{intl l='Browse this category'}"><img src="#IMAGE_URL" alt="#TITLE" /></a> <a href="{url path='admin/catalog/category' id="$ID" action='browse'}" title="{intl l='Browse this category'}"><img class="img-thumbnail" src="#IMAGE_URL" alt="#TITLE" /></a>
{/loop} {/loop}
</td> </td>
@@ -97,11 +97,15 @@
<td> <td>
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.category.edit"} {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.category.edit"}
<input type="checkbox" data-id="{$ID}" class="categoryVisibleToggle" {if $VISIBLE == 1}checked="checked"{/if}> <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="categoryVisibleToggle" {if $VISIBLE == 1}checked="checked"{/if}>
</div>
{/loop} {/loop}
{elseloop rel="can_change"} {elseloop rel="can_change"}
<input type="checkbox" class="disabled" disabled="disabled" {if $VISIBLE == 1}checked="checked"{/if}> <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} {/elseloop}
</td> </td>
@@ -117,15 +121,17 @@
</td> </td>
<td> <td>
<a class="btn btn-default btn-xs" title="{intl l='Browse this category'}" href="{url path='admin/catalog/category' id="$ID" action='browse'}"><i class="glyphicon glyphicon-folder-open"></i></a> <div class="btn-group">
<a class="btn btn-default btn-xs" title="{intl l='Browse this category'}" href="{url path='admin/catalog/category' id="$ID" action='browse'}"><i class="glyphicon glyphicon-folder-open"></i></a>
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.category.edit"} {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.category.edit"}
<a class="btn btn-default btn-xs" title="{intl l='Edit this category'}" href="{url path='admin/catalog/category' id="$ID" action='edit'}"><i class="glyphicon glyphicon-edit"></i></a> <a class="btn btn-default btn-xs" title="{intl l='Edit this category'}" href="{url path='admin/catalog/category' id="$ID" action='edit'}"><i class="glyphicon glyphicon-edit"></i></a>
{/loop} {/loop}
{loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.category.delete"} {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.category.delete"}
<a class="btn btn-default btn-xs category-delete" title="{intl l='Delete this category and all its contents'}" href="#delete_category_dialog" data-id="{$ID}" data-toggle="modal"><i class="glyphicon glyphicon-trash"></i></a> <a class="btn btn-default btn-xs category-delete" title="{intl l='Delete this category and all its contents'}" href="#delete_category_dialog" data-id="{$ID}" data-toggle="modal"><i class="glyphicon glyphicon-trash"></i></a>
{/loop} {/loop}
</div>
</td> </td>
</tr> </tr>
{/loop} {/loop}
@@ -229,7 +235,9 @@
{module_include location='product_list_row'} {module_include location='product_list_row'}
<td> <td>
<input type="checkbox" data-id="{$ID}" class="displayToggle" {if $VISIBLE == 1}checked="checked"{/if}> <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>
</td> </td>
<td> <td>
@@ -255,7 +263,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}
@@ -273,72 +281,77 @@
{/block} {/block}
{block name="javascript-initialization"} {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'} {javascripts file='assets/js/bootstrap-editable/bootstrap-editable.js'}
<script src="{$asset_url}"></script> <script src="{$asset_url}"></script>
{/javascripts} {/javascripts}
<script> <script>
$(function() { $(function() {
{* display the form creation dialog if it contains errors *} {* display the form creation dialog if it contains errors *}
{form name="thelia.admin.category.creation"} {form name="thelia.admin.category.creation"}
{if #form_error} {if #form_error}
$('#add_category_dialog').modal(); $('#add_category_dialog').modal();
{/if} {/if}
{/form} {/form}
{* Always reset create dialog on close *} {* Always reset create dialog on close *}
$('#add_category_dialog').on('hidden',function() { $('#add_category_dialog').on('hidden',function() {
// Hide error message // Hide error message
$('#add_category_dialog_error').remove(); $('#add_category_dialog_error').remove();
// Clear error status // Clear error status
$("#add_category_dialog .error").removeClass('error'); $("#add_category_dialog .error").removeClass('error');
// Empty field values // Empty field values
$("#add_category_dialog input[type=text]").val(''); $("#add_category_dialog input[type=text]").val('');
}); });
{* Set the proper category ID in the delete confirmation dialog *} {* Set the proper category ID in the delete confirmation dialog *}
$(document).on("click", ".category-delete", function () { $(document).on("click", ".category-delete", function () {
$('#'+'delete-category-id').val($(this).data('id')); $('#'+'delete-category-id').val($(this).data('id'));
}); });
// Toggle category visibility // Toggle category visibility
$(".categoryVisibleToggle").click(function() { $(".categoryVisibleToggle").change(function() {
$.ajax({ $.ajax({
url : "{url path='admin/catalog/category'}", url : "{url path='admin/catalog/category'}",
data : { data : {
category_id : $(this).data('id'), category_id : $(this).data('id'),
action : 'visibilityToggle' action : 'visibilityToggle'
} }
}); });
}); });
{* Inline editing of object position using bootstrap-editable *} {* Inline editing of object position using bootstrap-editable *}
$('.categoryPositionChange').editable({ $('.categoryPositionChange').editable({
type : 'text', type : 'text',
title : '{intl l="Enter new category position"}', title : '{intl l="Enter new category position"}',
mode : 'popup', mode : 'popup',
inputclass : 'input-mini', inputclass : 'input-mini',
placement : 'left', placement : 'left',
success : function(response, newValue) { success : function(response, newValue) {
// The URL template // The URL template
var url = "{url path='admin/catalog/category' action='changePosition' category_id='__ID__' position='__POS__'}"; var url = "{url path='admin/catalog/category' action='changePosition' category_id='__ID__' position='__POS__'}";
// Perform subtitutions // Perform subtitutions
url = url.replace('__ID__', $(this).data('id')) url = url.replace('__ID__', $(this).data('id'))
.replace('__POS__', newValue); .replace('__POS__', newValue);
// Reload the page // Reload the page
location.href = url; location.href = url;
} }
}); });
}) });
</script> </script>
{/block} {/block}

View File

@@ -51,8 +51,8 @@
<th> <th>
{admin_sortable_header {admin_sortable_header
current_order=$order current_order=$order
order='alpha' order='name'
reverse_order='alpha_reverse' reverse_order='name_reverse'
path='/admin/configuration/currencies' path='/admin/configuration/currencies'
label="{intl l='Name'}" label="{intl l='Name'}"
} }
@@ -147,7 +147,9 @@
</td> </td>
<td class="text-center"> <td class="text-center">
<input class="change-default" type="radio" name="is_default" value="{$ID}" {if $IS_DEFAULT}checked="checked"{/if}/> <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 class="change-default" type="radio" name="is_default" value="{$ID}" {if $IS_DEFAULT}checked="checked"{/if}/>
</div>
</td> </td>
{module_include location='currencies_table_row'} {module_include location='currencies_table_row'}
@@ -311,6 +313,10 @@
{block name="javascript-initialization"} {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'} {javascripts file='assets/js/bootstrap-editable/bootstrap-editable.js'}
<script src="{$asset_url}"></script> <script src="{$asset_url}"></script>
{/javascripts} {/javascripts}
@@ -368,7 +374,7 @@
{* Change default status *} {* Change default status *}
$('.change-default').click(function(ev) { $('.change-default').change(function(ev) {
var url = "{url path='/admin/configuration/currencies/set-default' currency_id='__ID__'}"; var url = "{url path='/admin/configuration/currencies/set-default' currency_id='__ID__'}";
// Perform ID subtitutions // Perform ID subtitutions

View File

@@ -15,51 +15,50 @@
<form method="POST" action="{url path='/admin/catalog/category'}" {form_enctype form=$form}> <form method="POST" action="{url path='/admin/catalog/category'}" {form_enctype form=$form}>
{* the action processed by the controller *} {* the action processed by the controller *}
<input type="hidden" name="action" value="create" /> <input type="hidden" name="action" value="create" />
{form_hidden_fields form=$form} {form_hidden_fields form=$form}
{form_field form=$form field='parent'} {form_field form=$form field='parent'}
<input type="hidden" name="{$name}" value="{$current_category_id}" /> <input type="hidden" name="{$name}" value="{$current_category_id}" />
{/form_field} {/form_field}
{form_field form=$form field='success_url'} {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) *} {* 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'}" /> <input type="hidden" name="{$name}" value="{url path='admin/catalog/category' id="_ID_" action='edit'}" />
{/form_field} {/form_field}
<div class="modal-body"> <div class="modal-body">
{if #form_error}<div class="alert alert-block alert-error" id="add_category_dialog_error">#form_error_message</div>{/if} {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="form-group"> <div class="help-block">{intl l="Enter here the category title in the default language ($TITLE)"}</div>
<label class="control-label">
{intl l='Category Title *'}
</label>
{loop type="lang" name="default-lang" default_only="1"}
{form_field form=$form field='locale'}
<input type="hidden" name="{$name}" value="{$LOCALE}" />
{/form_field}
<div class="input-group input-block-level"> {form_field form=$form field='locale'}
{form_field form=$form field='title'} <input type="hidden" name="{$name}" value="{$LOCALE}" />
<span {if $error}class="error"{/if}>
<input type="text" required="required" name="{$name}" value="{$value}" title="{intl l='Category title'}" placeholder="{intl l='Category title'}" class="form-control input-block-level">
</span>
{/form_field} {/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 category title in the default language ($TITLE)"}</div> {/loop}
{/loop}
</div>
</div> {/form_field}
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true">{intl l="Cancel"}</button> <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">{intl l="Create this category"}</button> <button type="submit" class="btn btn-default btn-primary"><span class="glyphicon glyphicon-check"></span> {intl l="Create this category"}</button>
</div> </div>
</form> </form>

View File

@@ -1,42 +1,48 @@
{* Adding a new Category *} {* Adding a new Category *}
<div class="modal hide fade" id="delete_category_dialog" tabindex="-1" role="dialog" aria-hidden="true"> <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"> <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 category"}</h3> <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>
{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" data-dismiss="modal" aria-hidden="true">{intl l="No"}</button>
<button type="submit" class="btn btn-primary">{intl l="Yes"}</button>
</div>
</form>
{/form}
</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 *} {* Be sure to get the message ID, even if the form could not be validated *}
<input type="hidden" name="message_id" value="{$message_id}" /> <input type="hidden" name="message_id" value="{$message_id}" />
{include file="includes/inner-form-toolbar.html"} {include file="includes/inner-form-toolbar.html"}
{form_hidden_fields form=$form} {form_hidden_fields form=$form}
{form_field form=$form field='success_url'} {form_field form=$form field='success_url'}
<input type="hidden" name="{$name}" value="{url path='/admin/configuration/messages'}" /> <input type="hidden" name="{$name}" value="{url path='/admin/configuration/messages'}" />
{/form_field} {/form_field}
{form_field form=$form field='id'} {form_field form=$form field='id'}
<input type="hidden" name="{$name}" value="{$value|htmlspecialchars}" /> <input type="hidden" name="{$name}" value="{$value|htmlspecialchars}" />
{/form_field} {/form_field}
{form_field form=$form field='locale'} {form_field form=$form field='locale'}
<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}
{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|htmlspecialchars}" title="{intl l='Variable name'}" placeholder="{intl l='Variable name'}" class="form-control">
</div>
{/form_field}
{form_field form=$form field='secured'}
<div class="checkbox {if $error}has-error{/if}">
<label>
<input type="checkbox" name="{$name}" value="1" {if $value == 1}checked="checked"{/if}>
{intl l="{$label}"}
</label>
</div>
{/form_field}
<div class="control-group"> {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>
<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}
<label class="control-label"> {form_field form=$form field='subject'}
{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}" required="required" title="{intl l='Subject'}" placeholder="{intl l='Subject'}" class="form-control" value="{$value|htmlspecialchars}">
</div>
{/form_field}
<div class="controls"> {form_field form=$form field='html_message'}
{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">
<input type="text" required="required" name="{$name}" value="{$value|htmlspecialchars}" title="{intl l='Variable name'}" placeholder="{intl l='Variable name'}" class="input-block-level"> {intl l="{$label}"} :
</span> <span class="label-help-block">{intl l="The mailing template in HTML format."}</span>
{/form_field} </label>
</div> <textarea name="{$name}" id="{$label_attr.for}" rows="10" class="form-control">{$value|htmlspecialchars}</textarea>
</div> </div>
{/form_field}
<div class="control-group"> {form_field form=$form field='text_message'}
<label class="control-label"> <div class="form-group {if $error}has-error{/if}">
{intl l='Secured'} <label for="{$label_attr.for}" class="control-label">
</label> {intl l="{$label}"} :
<span class="label-help-block">{intl l="The mailing template in text-only format."}</span>
</label>
<textarea name="{$name}" id="{$label_attr.for}" rows="10" class="form-control">{$value|htmlspecialchars}</textarea>
</div>
{/form_field}
<div class="controls"> <div class="form-group">
{form_field form=$form field='secured'} <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>
<span {if $error}class="error"{/if}> </div>
<label class="checkbox">
<input type="checkbox" name="{$name}" value="1" {if $value == 1}checked="checked"{/if}>
{intl l="Prevent mailing template modification or deletion, except for super-admin"}
</label>
</span>
{/form_field}
</div>
</div>
{form_field form=$form field='title'}
<div class="control-group">
<label class="control-label">
{intl l='Title *'}
</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>
{/form_field}
{form_field form=$form field='subject'}
<div class="control-group">
<label class="control-label">
{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>
<tbody>
{loop name="mailing-templates" type="message" secured="*" backend_context="1" lang="$lang_id"}
<tr>
{loop name="mailing-templates" type="message" secured="*" backend_context="1" lang="$lang_id"} <td>{$TITLE}</td>
<tr>
<td>{$TITLE}</td> <td>
{if ! $SECURED}
<td> {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.messages.change"}
{if ! $SECURED} <a title="{intl l='Change this mailing template'}" href="{url path='/admin/configuration/messages/update' message_id="$ID"}">{$NAME}</a>
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.messages.change"} {/loop}
<a title="{intl l='Change this mailing template'}" href="{url path='/admin/configuration/messages/update' message_id="$ID"}">{$NAME}</a> {elseloop rel="can_change"}
{/loop} {$NAME}
{elseloop rel="can_change"} {/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-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 mailing template"}</h3> <h3>{intl l="Create a new mailing template"}</h3>
</div>
{form name="thelia.admin.message.creation"}
<form method="POST" action="{url path='/admin/configuration/messages/create'}" {form_enctype form=$form}>
{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">
<label class="control-label"> {form_field form=$form field='value'}
{intl l='Value'} <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|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">
<label class="control-label"> {form_field form=$form field='secured'}
{intl l='Secured'} <div class="checkbox {if $error}has-error{/if}">
</label> <label>
<input type="checkbox" name="{$name}" value="1" {if $value == 1}checked="checked"{/if}>
<div class="controls"> {intl l="{$label}"}
{form_field form=$form field='secured'} </label>
<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}
{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}
{form_field form=$form field='value'}
<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}" name="{$name}" value="{$value}" title="{intl l='Variable value'}" placeholder="{intl l='Variable value'}" 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>
<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='Name *'} <input type="hidden" name="edit_language_id" value="{$ID}" />
</label>
<div class="controls"> <div class="input-group">
{form_field form=$form field='name'} <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" required="required" name="{$name}" value="{$value}" title="{intl l='Variable name'}" placeholder="{intl l='Variable name'}" 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"> {form_field form=$form field='locale'}
{intl l='Value'}
</label>
<div class="controls">
{form_field form=$form field='value'}
<span {if $error}class="error"{/if}>
<input type="text" name="{$name}" value="{$value}" title="{intl l='Variable value'}" placeholder="{intl l='Variable value'}" class="input-block-level">
</span>
{/form_field}
</div>
</div>
<div class="control-group">
<label class="control-label">
{intl l='Purpose *'}
</label>
<div class="controls">
{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}> <div class="modal-footer">
<input type="text" required="required" name="{$name}" value="{$value}" title="{intl l='Variable purpose'}" placeholder="{intl l='Variable purpose'}" class="input-block-level"> <button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true"><span class="glyphicon glyphicon-remove"></span> {intl l="Cancel"}</button>
</span> <button type="submit" class="btn btn-default btn-primary"><span class="glyphicon glyphicon-check"></span> {intl l="Create this variable"}</button>
{/form_field} </div>
<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> </form>
{/loop} {/form}
</div> </div>
</div> </div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-default btn-primary">{intl l="Create this variable"}</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_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}