diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 07e0a1d07..ddc17111b 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -166,17 +166,23 @@ - + - + + + + + + + diff --git a/core/lib/Thelia/Controller/Admin/BaseAdminController.php b/core/lib/Thelia/Controller/Admin/BaseAdminController.php index 8160033fe..b4b10e9be 100755 --- a/core/lib/Thelia/Controller/Admin/BaseAdminController.php +++ b/core/lib/Thelia/Controller/Admin/BaseAdminController.php @@ -155,7 +155,7 @@ class BaseAdminController extends BaseController */ protected function getCurrentEditionLangId() { return $this->getRequest()->get( - 'edition_language', + 'edit_language_id', $this->getSession()->getAdminEditionLangId() ); } @@ -196,29 +196,32 @@ class BaseAdminController extends BaseController $session = $this->getSession(); - // Find the current edit language ID $edition_language = $this->getCurrentEditionLangId(); // Current back-office (not edition) language - $current_lang = LangQuery::create()->findOneById($session->getLangId()); + $current_lang = LangQuery::create()->findOneById($session->getLangId()); + + // Find the current edit language ID + $edition_language = LangQuery::create()->findOneById($this->getCurrentEditionLangId()); // Prepare common template variables $args = array_merge($args, array( - 'locale' => $session->getLocale(), - 'lang_code' => $session->getLang(), - 'lang_id' => $session->getLangId(), + 'locale' => $session->getLocale(), + 'lang_code' => $session->getLang(), + 'lang_id' => $session->getLangId(), - 'datetime_format' => $current_lang->getDateTimeFormat(), - 'date_format' => $current_lang->getDateFormat(), - 'time_format' => $current_lang->getTimeFormat(), + 'datetime_format' => $current_lang->getDateTimeFormat(), + 'date_format' => $current_lang->getDateFormat(), + 'time_format' => $current_lang->getTimeFormat(), - 'edition_language' => $edition_language, + 'edit_language_id' => $edition_language->getId(), + 'edit_language_locale' => $edition_language->getLocale(), - 'current_url' => htmlspecialchars($this->getRequest()->getUri()) + 'current_url' => htmlspecialchars($this->getRequest()->getUri()) )); // Update the current edition language in session - $this->getSession()->setAdminEditionLangId($edition_language); + $this->getSession()->setAdminEditionLangId($edition_language->getId()); // Render the template. try { diff --git a/core/lib/Thelia/Controller/Admin/CategoryController.php b/core/lib/Thelia/Controller/Admin/CategoryController.php index 9966034f8..6cba34e39 100755 --- a/core/lib/Thelia/Controller/Admin/CategoryController.php +++ b/core/lib/Thelia/Controller/Admin/CategoryController.php @@ -188,7 +188,7 @@ class CategoryController extends BaseAdminController // Find the current order $category_order = $this->getRequest()->get( - 'category_order', + 'order', $this->getSession()->get('admin.category_order', 'manual') ); diff --git a/core/lib/Thelia/Controller/Admin/ConfigController.php b/core/lib/Thelia/Controller/Admin/ConfigController.php index 8f761ed7e..c6fab6b1b 100644 --- a/core/lib/Thelia/Controller/Admin/ConfigController.php +++ b/core/lib/Thelia/Controller/Admin/ConfigController.php @@ -42,6 +42,25 @@ use Thelia\Form\ConfigCreationForm; */ class ConfigController extends BaseAdminController { + /** + * Render the currencies list, ensuring the sort order is set. + * + * @return Symfony\Component\HttpFoundation\Response the response + */ + protected function renderList() { + + // Find the current order + $order = $this->getRequest()->get( + 'order', + $this->getSession()->get('admin.variables_order', 'name') + ); + + // Store the current sort order in session + $this->getSession()->set('admin.variables_order', $order); + + return $this->render('variables', array('order' => $order)); + } + /** * The default action is displaying the variables list. * @@ -51,7 +70,7 @@ class ConfigController extends BaseAdminController if (null !== $response = $this->checkAuth("admin.configuration.variables.view")) return $response; - return $this->render('variables'); + return $this->renderList(); } /** @@ -124,7 +143,7 @@ class ConfigController extends BaseAdminController } // At this point, the form has error, and should be redisplayed. - return $this->render('variables'); + return $this->renderList(); } /** @@ -276,7 +295,7 @@ class ConfigController extends BaseAdminController $this->dispatch(TheliaEvents::CONFIG_SETVALUE, $event); } - $this->redirect(URL::adminViewUrl('variables')); + $this->redirect(URL::absoluteUrl('/admin/configuration/variables')); } /** @@ -294,6 +313,6 @@ class ConfigController extends BaseAdminController $this->dispatch(TheliaEvents::CONFIG_DELETE, $event); - $this->redirect(URL::adminViewUrl('variables')); + $this->redirect(URL::absoluteUrl('/admin/configuration/variables')); } } \ No newline at end of file diff --git a/core/lib/Thelia/Controller/Admin/CurrencyController.php b/core/lib/Thelia/Controller/Admin/CurrencyController.php index 69cc60117..b9ca98083 100644 --- a/core/lib/Thelia/Controller/Admin/CurrencyController.php +++ b/core/lib/Thelia/Controller/Admin/CurrencyController.php @@ -101,7 +101,9 @@ class CurrencyController extends BaseAdminController ->setCurrencyName($data['name']) ->setLocale($data["locale"]) ->setSymbol($data['symbol']) - ; + ->setCode($data['code']) + ->setRate($data['rate']) + ; $this->dispatch(TheliaEvents::CURRENCY_CREATE, $createEvent); diff --git a/core/lib/Thelia/Core/Template/Loop/Config.php b/core/lib/Thelia/Core/Template/Loop/Config.php index 5cc1b2b44..684803385 100644 --- a/core/lib/Thelia/Core/Template/Loop/Config.php +++ b/core/lib/Thelia/Core/Template/Loop/Config.php @@ -34,6 +34,8 @@ use Thelia\Model\LangQuery; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Model\ConfigQuery; use Thelia\Type\BooleanOrBothType; +use Thelia\Type\TypeCollection; +use Thelia\Type\EnumListType; /** * Config loop, to access configuration variables @@ -59,7 +61,21 @@ class Config extends BaseI18nLoop Argument::createIntListTypeArgument('exclude'), Argument::createAnyTypeArgument('variable'), Argument::createBooleanOrBothTypeArgument('hidden'), - Argument::createBooleanOrBothTypeArgument('secured') + Argument::createBooleanOrBothTypeArgument('secured'), + new Argument( + 'order', + new TypeCollection( + new EnumListType( + array( + 'id', 'id_reverse', + 'name', 'name_reverse', + 'title', 'title_reverse', + 'value', 'value_reverse', + ) + ) + ), + 'name' + ) ); } @@ -94,7 +110,39 @@ class Config extends BaseI18nLoop if (! is_null($secured) && $secured != BooleanOrBothType::ANY) $search->filterBySecured($secured ? 1 : 0); - $search->orderByName(Criteria::ASC); + $orders = $this->getOrder(); + + foreach($orders as $order) { + switch ($order) { + case 'id': + $search->orderById(Criteria::ASC); + break; + case 'id_reverse': + $search->orderById(Criteria::DESC); + break; + + case 'name': + $search->orderByName(Criteria::ASC); + break; + case 'name_reverse': + $search->orderByName(Criteria::DESC); + break; + + case 'title': + $search->addAscendingOrderByColumn('i18n_TITLE'); + break; + case 'title_reverse': + $search->addDescendingOrderByColumn('i18n_TITLE'); + break; + + case 'value': + $search->orderByValue(Criteria::ASC); + break; + case 'value_reverse': + $search->orderByValue(Criteria::DESC); + break; + } + } $results = $this->search($search, $pagination); diff --git a/core/lib/Thelia/Core/Template/Loop/Currency.php b/core/lib/Thelia/Core/Template/Loop/Currency.php index 2fb296070..b6756fbe6 100755 --- a/core/lib/Thelia/Core/Template/Loop/Currency.php +++ b/core/lib/Thelia/Core/Template/Loop/Currency.php @@ -66,8 +66,9 @@ class Currency extends BaseI18nLoop 'code', 'code_reverse', 'symbol', 'symbol_reverse', 'rate', 'rate_reverse', + 'is_default', 'is_default_reverse', 'manual', 'manual_reverse') - ) + ) ), 'manual' ) @@ -143,6 +144,13 @@ class Currency extends BaseI18nLoop $search->orderByRate(Criteria::DESC); break; + case 'is_default': + $search->orderByByDefault(Criteria::ASC); + break; + case 'is_default_reverse': + $search->orderByByDefault(Criteria::DESC); + break; + case 'manual': $search->orderByPosition(Criteria::ASC); break; diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/AdminUtilities.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/AdminUtilities.php new file mode 100644 index 000000000..aab63177a --- /dev/null +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/AdminUtilities.php @@ -0,0 +1,144 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Template\Smarty\Plugins; + +use Thelia\Core\Template\Smarty\SmartyPluginDescriptor; +use Thelia\Core\Template\Smarty\AbstractSmartyPlugin; +use Thelia\Tools\URL; +use Thelia\Core\HttpFoundation\Request; +use Thelia\Core\Security\SecurityContext; + +/** + * This class implements variour admin template utilities + * + * @author Franck Allimant + */ +class AdminUtilities extends AbstractSmartyPlugin +{ + private $securityContext; + + public function __construct(SecurityContext $securityContext) + { + $this->securityContext = $securityContext; + } + + public function generatePositionChangeBlock($params, &$smarty) { + // The required permissions + $permission = $this->getParam($params, 'permission'); + + // The base position change path + $path = $this->getParam($params, 'path'); + + // The URL parameter the object ID is assigned + $url_parameter = $this->getParam($params, 'url_parameter'); + + // The current object position + $position = $this->getParam($params, 'position'); + + // The object ID + $id = $this->getParam($params, 'id'); + + // The in place dition class + $in_place_edit_class = $this->getParam($params, 'in_place_edit_class'); + + /* + + {$POSITION} + + */ + + if ($permissions == null || $this->securityContext->isGranted("ADMIN", array($permission))) { + return sprintf( + '%s', + URL::absoluteUrl("$path/positionUp", array($url_parameter => $id)), + $in_place_edit_class, + $id, + $position, + URL::absoluteUrl("$path/positionDown", array($url_parameter => $id)) + ); + } + else { + return $position; + } + } + + + /** + * Generates the link of a sortable column header + * + * @param array $params + * @param unknown $smarty + * @return string no text is returned. + */ + public function generateSortableColumnHeader($params, &$smarty) + { + // The current order of the table + $current_order = $this->getParam($params, 'current_order'); + + // The column ascending order + $order = $this->getParam($params, 'order'); + + // The column descending order label + $reverse_order = $this->getParam($params, 'reverse_order'); + + // The order change path + $path = $this->getParam($params, 'path'); + + // The column label + $label = $this->getParam($params, 'label'); + + if ($current_order == $order) { + $icon = 'up'; + $order_change = $reverse_order; + } + else if ($current_order == $reverse_order) { + $icon = 'down'; + $order_change = $order; + } + else { + $order_change = $order; + } + + if (! empty($icon)) + $output = sprintf(' ', $icon); + else + $output = ''; + + return sprintf('%s%s', $output, URL::absoluteUrl($path, array('order' => $order_change)), $label); + } + + + /** + * Define the various smarty plugins handled by this class + * + * @return an array of smarty plugin descriptors + */ + public function getPluginDescriptors() + { + return array( + new SmartyPluginDescriptor('function', 'admin_sortable_header', $this, 'generateSortableColumnHeader'), + new SmartyPluginDescriptor('function', 'admin_position_block' , $this, 'generatePositionChangeBlock'), + ); + } +} \ No newline at end of file diff --git a/templates/admin/default/assets/css/admin.less b/templates/admin/default/assets/css/admin.less index 85cef27da..9a01cfb67 100755 --- a/templates/admin/default/assets/css/admin.less +++ b/templates/admin/default/assets/css/admin.less @@ -621,6 +621,7 @@ form .info .input-append .add-on { li.active a { opacity: 1; background-color: #E7E7E7; + border: 1px solid #E9720F; } } } @@ -725,6 +726,17 @@ label { td, th { text-align: center; + + &.text-center { + text-align: center; + } + &.text-left { + text-align: left; + } + &.text-right { + text-align: right; + } + } td.object-title, th.object-title { diff --git a/templates/admin/default/categories.html b/templates/admin/default/categories.html index 1548140bf..65902e5d7 100755 --- a/templates/admin/default/categories.html +++ b/templates/admin/default/categories.html @@ -47,54 +47,40 @@   + - {if $category_order == 'alpha'} - - {$order_change = 'alpha_reverse'} - {elseif $category_order == 'alpha_reverse'} - - {$order_change = 'alpha'} - {else} - {$order_change = 'alpha'} - {/if} - - {intl l="Category title"} - - + {admin_sortable_header + current_order=$category_order + order='alpha' + reverse_order='alpha_reverse' + path={url path='/admin/catalog/category' id="{$current_category_id}"} + label={intl l='Category title'} + } + {module_include location='category_list_header'} - {if $category_order == 'visible'} - - {$order_change = 'visible_reverse'} - {elseif $category_order == 'visible_reverse'} - - {$order_change = 'visible'} - {else} - {$order_change = 'visible'} - {/if} - - - {intl l="Online"} - + {admin_sortable_header + current_order=$category_order + order='visible' + reverse_order='visible_reverse' + path={url path='/admin/catalog/category' id="{$current_category_id}"} + label={intl l='Online'} + } - {if $category_order == 'manual'} - - {$order_change = 'manual_reverse'} - {elseif $category_order == 'manual_reverse'} - - {$order_change = 'manual'} - {else} - {$order_change = 'manual'} - {/if} - - {intl l="Position"} + {admin_sortable_header + current_order=$category_order + order='manual' + reverse_order='manual_reverse' + path={url path='/admin/catalog/category' id="{$current_category_id}"} + label={intl l='Position'} + } - {intl l="Actions"} +   @@ -126,15 +112,14 @@ - {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.category.edit"} - - {$POSITION} - - {/loop} - - {elseloop rel="can_change"} - {$POSITION} - {/elseloop} + {admin_position_block + permission="admin.category.edit" + path={url path='admin/catalog/category' category_id="{$ID}"} + url_parameter="category_id" + in_place_edit_class="categoryPositionChange" + position="$POSITION" + id="$ID" + } @@ -200,13 +185,38 @@   - {intl l="Product title"} + + {admin_sortable_header + current_order=$product_order + order='alpha' + reverse_order='alpha_reverse' + path={url path='/admin/catalog/product' id="{$current_category_id}"} + label={intl l='Product title'} + } {module_include location='product_list_header'} - {intl l="Online"} - {intl l="Position"} - {intl l="Actions"} + + {admin_sortable_header + current_order=$product_order + order='visible' + reverse_order='visible_reverse' + path={url path='/admin/catalog/product' id="{$current_category_id}"} + label={intl l='Online'} + } + + + + {admin_sortable_header + current_order=$product_order + order='manual' + reverse_order='manual_reverse' + path={url path='/admin/catalog/product' id="{$current_category_id}"} + label={intl l='Position'} + } + + +   @@ -229,13 +239,18 @@ - - {$POSITION} - + {admin_position_block + permission="admin.product.edit" + path={url path='admin/catalog/product' category_id="{$ID}"} + url_parameter="product_id" + in_place_edit_class="productPositionChange" + position="$POSITION" + id="$ID" + } - + diff --git a/templates/admin/default/currencies.html b/templates/admin/default/currencies.html index 762bb47ee..6671c131f 100644 --- a/templates/admin/default/currencies.html +++ b/templates/admin/default/currencies.html @@ -40,94 +40,75 @@ - {if $order == 'id'} - - {$order_change = 'id_reverse'} - {elseif $order == 'id_reverse'} - - {$order_change = 'id'} - {else} - {$order_change = 'id'} - {/if} - - {intl l="ID"} - + {admin_sortable_header + current_order=$order + order='id' + reverse_order='id_reverse' + path='/admin/configuration/currencies' + label="{intl l='ID'}" + } - {if $order == 'alpha'} - - {$order_change = 'alpha_reverse'} - {elseif $order == 'alpha_reverse'} - - {$order_change = 'alpha'} - {else} - {$order_change = 'alpha'} - {/if} - - {intl l="Name"} - + {admin_sortable_header + current_order=$order + order='alpha' + reverse_order='alpha_reverse' + path='/admin/configuration/currencies' + label="{intl l='Name'}" + } - - {if $order == 'code'} - - {$order_change = 'code_reverse'} - {elseif $order == 'code_reverse'} - - {$order_change = 'code'} - {else} - {$order_change = 'code'} - {/if} - {intl l="ISO 4217 Code"} + + {admin_sortable_header + current_order=$order + order='code' + reverse_order='code_reverse' + path='/admin/configuration/currencies' + label="{intl l="ISO 4217 Code"}" + } - - {if $order == 'symbol'} - - {$order_change = 'symbol_reverse'} - {elseif $order == 'symbol_reverse'} - - {$order_change = 'symbol'} - {else} - {$order_change = 'symbol'} - {/if} - - {intl l="Symbol"} - + + {admin_sortable_header + current_order=$order + order='symbol' + reverse_order='symbol_reverse' + path='/admin/configuration/currencies' + label="{intl l="Symbol"}" + } - - {if $order == 'rate'} - - {$order_change = 'rate_reverse'} - {elseif $order == 'rate_reverse'} - - {$order_change = 'rate'} - {else} - {$order_change = 'rate'} - {/if} - - {intl l="Rate in €"} - + + {admin_sortable_header + current_order=$order + order='rate' + reverse_order='rate_reverse' + path='/admin/configuration/currencies' + label="{intl l="Rate in €"}" + } - - {if $order == 'manual'} - - {$order_change = 'manual_reverse'} - {elseif $order == 'manual_reverse'} - - {$order_change = 'manual'} - {else} - {$order_change = 'manual'} - {/if} - - {intl l="Position"} + + {admin_sortable_header + current_order=$order + order='manual' + reverse_order='manual_reverse' + path='/admin/configuration/currencies' + label="{intl l="Position"}" + } - {intl l="Default"} + + {admin_sortable_header + current_order=$order + order='is_default' + reverse_order='is_default_reverse' + path='/admin/configuration/currencies' + label="{intl l="Default"}" + } + {module_include location='currencies_table_header'} @@ -148,25 +129,24 @@ {/elseloop} - {$ISOCODE} + {$ISOCODE} - {$SYMBOL} + {$SYMBOL} - {$RATE|string_format:"%.4f"} + {$RATE|string_format:"%.4f"} - - {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.category.edit"} - - {$POSITION} - - {/loop} - - {elseloop rel="can_change"} - {$POSITION} - {/elseloop} + + {admin_position_block + permission="admin.currencies.edit" + path="/admin/configuration/currencies" + url_parameter="currency_id" + in_place_edit_class="currencyPositionChange" + position="$POSITION" + id="$ID" + } - + {module_include location='currencies_table_row'} @@ -238,6 +218,10 @@
{loop type="lang" name="default-lang" default_only="1"} + + {* Switch edition to the current locale *} + + {form_field form=$form field='locale'} {/form_field} diff --git a/templates/admin/default/edit_category.html b/templates/admin/default/edit_category.html index 65c5f9c56..3d70e5cdb 100755 --- a/templates/admin/default/edit_category.html +++ b/templates/admin/default/edit_category.html @@ -12,7 +12,7 @@
- {loop name="category_edit" type="category" visible="*" id="{$current_category_id}" backend_context="1" lang="$edition_language"} + {loop name="category_edit" type="category" visible="*" id="{$current_category_id}" backend_context="1" lang="$edit_language_id"}
diff --git a/templates/admin/default/includes/inner-form-toolbar.html b/templates/admin/default/includes/inner-form-toolbar.html index 082ad34e2..3edcbf794 100755 --- a/templates/admin/default/includes/inner-form-toolbar.html +++ b/templates/admin/default/includes/inner-form-toolbar.html @@ -11,8 +11,8 @@