diff --git a/composer.lock b/composer.lock index efa62a9f2..731d38164 100755 --- a/composer.lock +++ b/composer.lock @@ -397,12 +397,12 @@ "source": { "type": "git", "url": "https://github.com/simplepie/simplepie.git", - "reference": "f5436d69a8efa9d4ab3a9abc65d17317eb24b7f4" + "reference": "f97c8ef9be655c35e6fecdb608bdf5af05a4374a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/simplepie/simplepie/zipball/f5436d69a8efa9d4ab3a9abc65d17317eb24b7f4", - "reference": "f5436d69a8efa9d4ab3a9abc65d17317eb24b7f4", + "url": "https://api.github.com/repos/simplepie/simplepie/zipball/f97c8ef9be655c35e6fecdb608bdf5af05a4374a", + "reference": "f97c8ef9be655c35e6fecdb608bdf5af05a4374a", "shasum": "" }, "require": { @@ -443,7 +443,7 @@ "feeds", "rss" ], - "time": "2013-04-29 06:13:26" + "time": "2013-08-31 01:38:46" }, { "name": "smarty/smarty", @@ -1622,12 +1622,12 @@ "source": { "type": "git", "url": "https://github.com/fzaninotto/Faker.git", - "reference": "feb6492762a77db946bc13cc44a20a01546be0e6" + "reference": "77a4e394d99a67e7fb611e8b402c2da4b80fa4f8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/feb6492762a77db946bc13cc44a20a01546be0e6", - "reference": "feb6492762a77db946bc13cc44a20a01546be0e6", + "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/77a4e394d99a67e7fb611e8b402c2da4b80fa4f8", + "reference": "77a4e394d99a67e7fb611e8b402c2da4b80fa4f8", "shasum": "" }, "require": { @@ -1660,7 +1660,7 @@ "faker", "fixtures" ], - "time": "2013-08-12 10:05:47" + "time": "2013-08-29 19:11:59" }, { "name": "phpunit/php-code-coverage", diff --git a/core/lib/Thelia/Action/Config.php b/core/lib/Thelia/Action/Config.php index bf0f47b4f..609f566a5 100644 --- a/core/lib/Thelia/Action/Config.php +++ b/core/lib/Thelia/Action/Config.php @@ -77,7 +77,7 @@ class Config extends BaseAction implements EventSubscriberInterface $search = ConfigQuery::create(); - if (null !== $config = $search->findById($event->getConfigId())) { + if (null !== $config = $search->findOneById($event->getConfigId())) { $config ->setDispatcher($this->getDispatcher()) @@ -98,7 +98,7 @@ class Config extends BaseAction implements EventSubscriberInterface $search = ConfigQuery::create(); - if (null !== $config = ConfigQuery::create()->findById($event->getConfigId())) { + if (null !== $config = ConfigQuery::create()->findOneById($event->getConfigId())) { $config ->setDispatcher($this->getDispatcher()) @@ -127,10 +127,10 @@ class Config extends BaseAction implements EventSubscriberInterface { $this->checkAuth("ADMIN", "admin.configuration.variables.delete"); - if (null !== $config = ConfigQuery::create()->findById($event->getConfigId())) { - + if (null !== ($config = ConfigQuery::create()->findOneById($event->getConfigId()))) { if (! $config->getSecured()) { - $config->setDispatcher($this->getDispatcher())->delete(); + $config->setDispatcher($this->getDispatcher()); + $config->delete(); } } } diff --git a/core/lib/Thelia/Config/Resources/action.xml b/core/lib/Thelia/Config/Resources/action.xml index 7d21eadee..9ecfad939 100755 --- a/core/lib/Thelia/Config/Resources/action.xml +++ b/core/lib/Thelia/Config/Resources/action.xml @@ -32,6 +32,11 @@ + + + + + diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index 9c235dc39..a522303c0 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -35,22 +35,22 @@ Thelia\Controller\Admin\CategoryController::processAction - + - - Thelia\Controller\Admin\ConfigController::defaultAction + + Thelia\Controller\Admin\VariablesController::defaultAction - - Thelia\Controller\Admin\ConfigController::createAction + + Thelia\Controller\Admin\VariablesController::createAction - - Thelia\Controller\Admin\ConfigController::changeAction + + Thelia\Controller\Admin\VariablesController::changeAction - - Thelia\Controller\Admin\ConfigController::deleteAction + + Thelia\Controller\Admin\VariablesController::deleteAction diff --git a/core/lib/Thelia/Controller/Admin/ConfigController.php b/core/lib/Thelia/Controller/Admin/VariablesController.php similarity index 84% rename from core/lib/Thelia/Controller/Admin/ConfigController.php rename to core/lib/Thelia/Controller/Admin/VariablesController.php index 78979676b..b5e2dce0f 100644 --- a/core/lib/Thelia/Controller/Admin/ConfigController.php +++ b/core/lib/Thelia/Controller/Admin/VariablesController.php @@ -23,16 +23,24 @@ namespace Thelia\Controller\Admin; -class ConfigController extends BaseAdminController +use Thelia\Core\Event\ConfigDeleteEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Tools\URL; +class VariablesController extends BaseAdminController { public function defaultAction() { - $this->render('config'); + return $this->render('variables'); } public function createAction() { } public function deleteAction() { + $event = new ConfigDeleteEvent($this->getRequest()->get('id')); + + $this->dispatch(TheliaEvents::CONFIG_DELETE, $event); + + $this->redirect(URL::adminViewUrl('variables')); } public function updateAction() { diff --git a/core/lib/Thelia/Core/Template/Loop/CategoryPath.php b/core/lib/Thelia/Core/Template/Loop/CategoryPath.php index 5e41c4288..ed0acf972 100755 --- a/core/lib/Thelia/Core/Template/Loop/CategoryPath.php +++ b/core/lib/Thelia/Core/Template/Loop/CategoryPath.php @@ -81,7 +81,7 @@ class CategoryPath extends BaseI18nLoop $search = CategoryQuery::create(); - $this->configureI18nProcessing($search, array('TITLE')); + $locale = $this->configureI18nProcessing($search, array('TITLE')); $search->filterById($id); if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible); @@ -99,7 +99,7 @@ class CategoryPath extends BaseI18nLoop $loopResultRow ->set("TITLE",$category->getVirtualColumn('i18n_TITLE')) - ->set("URL", $category->getUrl()) + ->set("URL", $category->getUrl($locale)) ->set("ID", $category->getId()) ; diff --git a/core/lib/Thelia/Core/Template/Loop/CategoryTree.php b/core/lib/Thelia/Core/Template/Loop/CategoryTree.php index 330466f49..63f1e9cfb 100755 --- a/core/lib/Thelia/Core/Template/Loop/CategoryTree.php +++ b/core/lib/Thelia/Core/Template/Loop/CategoryTree.php @@ -22,9 +22,7 @@ /*************************************************************************************/ namespace Thelia\Core\Template\Loop; - use Propel\Runtime\ActiveQuery\Criteria; -use Thelia\Core\Template\Element\BaseLoop; use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResultRow; @@ -34,6 +32,7 @@ use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Model\CategoryQuery; use Thelia\Type; use Thelia\Type\BooleanOrBothType; +use Thelia\Core\Template\Element\BaseI18nLoop; /** * @@ -46,19 +45,17 @@ use Thelia\Type\BooleanOrBothType; * @package Thelia\Core\Template\Loop * @author Franck Allimant */ -class CategoryTree extends BaseLoop +class CategoryTree extends BaseI18nLoop { /** * @return ArgumentCollection */ protected function getArgDefinitions() { - return new ArgumentCollection( - Argument::createIntTypeArgument('category', null, true), - Argument::createIntTypeArgument('depth', PHP_INT_MAX), - Argument::createBooleanOrBothTypeArgument('visible', true, false), - Argument::createIntListTypeArgument('exclude', array()) - ); + return new ArgumentCollection(Argument::createIntTypeArgument('category', null, true), + Argument::createIntTypeArgument('depth', PHP_INT_MAX), + Argument::createBooleanOrBothTypeArgument('visible', true, false), + Argument::createIntListTypeArgument('exclude', array())); } // changement de rubrique @@ -66,7 +63,11 @@ class CategoryTree extends BaseLoop { if ($level > $max_level) return; - $search = CategoryQuery::create(); + $search = CategoryQuery::create(); + + $locale = $this->configureI18nProcessing($search, array( + 'TITLE' + )); $search->filterByParent($parent); @@ -82,18 +83,15 @@ class CategoryTree extends BaseLoop $loopResultRow = new LoopResultRow(); - $loopResultRow - ->set("ID", $result->getId()) - ->set("TITLE",$result->getTitle()) - ->set("PARENT", $result->getParent()) - ->set("URL", $result->getUrl()) - ->set("VISIBLE", $result->getVisible() ? "1" : "0") - ->set("LEVEL", $level) + $loopResultRow + ->set("ID", $result->getId())->set("TITLE", $result->getVirtualColumn('i18n_TITLE')) + ->set("PARENT", $result->getParent())->set("URL", $result->getUrl($locale)) + ->set("VISIBLE", $result->getVisible() ? "1" : "0")->set("LEVEL", $level) ; - $loopResult->addRow($loopResultRow); + $loopResult->addRow($loopResultRow); - $this->buildCategoryTree($result->getId(), $visible, 1 + $level, $max_level, $exclude, $loopResult); + $this->buildCategoryTree($result->getId(), $visible, 1 + $level, $max_level, $exclude, $loopResult); } } @@ -105,7 +103,7 @@ class CategoryTree extends BaseLoop public function exec(&$pagination) { $id = $this->getCategory(); - $depth = $this->getDepth(); + $depth = $this->getDepth(); $visible = $this->getVisible(); $exclude = $this->getExclude(); diff --git a/core/lib/Thelia/Core/Template/Loop/Config.php b/core/lib/Thelia/Core/Template/Loop/Config.php index ba83f92c1..2c2be0359 100644 --- a/core/lib/Thelia/Core/Template/Loop/Config.php +++ b/core/lib/Thelia/Core/Template/Loop/Config.php @@ -57,7 +57,7 @@ class Config extends BaseI18nLoop return new ArgumentCollection( Argument::createIntTypeArgument('id'), Argument::createIntListTypeArgument('exclude'), - Argument::createAnyTypeArgument('name'), + Argument::createAnyTypeArgument('variable'), Argument::createBooleanOrBothTypeArgument('hidden'), Argument::createBooleanOrBothTypeArgument('secured') ); @@ -71,11 +71,11 @@ class Config extends BaseI18nLoop public function exec(&$pagination) { $id = $this->getId(); - $name = $this->getName(); + $name = $this->getVariable(); $search = ConfigQuery::create(); - $this->configureI18nProcessing($search); + $this->configureI18nProcessing($search); if (! is_null($id)) $search->filterById($id); @@ -113,6 +113,7 @@ class Config extends BaseI18nLoop ->set("DESCRIPTION" , $result->getVirtualColumn('i18n_DESCRIPTION')) ->set("POSTSCRIPTUM" , $result->getVirtualColumn('i18n_POSTSCRIPTUM')) ->set("HIDDEN" , $result->getHidden()) + ->set("SECURED" , $result->getSecured()) ->set("CREATE_DATE" , $result->getCreatedAt()) ->set("UPDATE_DATE" , $result->getUpdatedAt()) ; diff --git a/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php b/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php index b7d86a4da..ed74fe3f0 100755 --- a/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php +++ b/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php @@ -219,7 +219,7 @@ class SmartyParser extends Smarty implements ParserInterface $fileName .= ".html"; if (!file_exists($fileName)) { - throw new ResourceNotFoundException(sprintf("%s file (%s) not found in %s template", $file, $fileName, $this->template)); + throw new ResourceNotFoundException(sprintf("%s file not found in %s template", $file, $this->template)); } } diff --git a/core/lib/Thelia/Model/Config.php b/core/lib/Thelia/Model/Config.php index 276823530..bb3898a4b 100755 --- a/core/lib/Thelia/Model/Config.php +++ b/core/lib/Thelia/Model/Config.php @@ -59,6 +59,8 @@ class Config extends BaseConfig { public function preDelete(ConnectionInterface $con = null) { $this->dispatchEvent(TheliaEvents::BEFORE_DELETECONFIG, new ConfigEvent($this)); + + return true; } public function postDelete(ConnectionInterface $con = null) diff --git a/core/lib/Thelia/Model/Customer.php b/core/lib/Thelia/Model/Customer.php index 621f39652..8f3de28d1 100755 --- a/core/lib/Thelia/Model/Customer.php +++ b/core/lib/Thelia/Model/Customer.php @@ -102,38 +102,6 @@ class Customer extends BaseCustomer implements UserInterface } } - public function preInsert(ConnectionInterface $con = null) - { - $this->setRef($this->generateRef()); - $customerEvent = new CustomerEvent($this); - - $this->dispatchEvent(TheliaEvents::BEFORE_CREATECUSTOMER, $customerEvent); - - return true; - } - - public function postInsert(ConnectionInterface $con = null) - { - $customerEvent = new CustomerEvent($this); - - $this->dispatchEvent(TheliaEvents::AFTER_CREATECUSTOMER, $customerEvent); - - } - - public function preUpdate(ConnectionInterface $con = null) - { - $customerEvent = new CustomerEvent($this); - $this->dispatchEvent(TheliaEvents::BEFORE_CHANGECUSTOMER, $customerEvent); - - return true; - } - - public function postUpdate(ConnectionInterface $con = null) - { - $customerEvent = new CustomerEvent($this); - $this->dispatchEvent(TheliaEvents::AFTER_CHANGECUSTOMER, $customerEvent); - } - protected function generateRef() { return uniqid(substr($this->getLastname(), 0, (strlen($this->getLastname()) >= 3) ? 3 : strlen($this->getLastname())), true); @@ -202,4 +170,57 @@ class Customer extends BaseCustomer implements UserInterface public function getRoles() { return array(new Role('CUSTOMER')); } + + /** + * {@inheritDoc} + */ + public function preInsert(ConnectionInterface $con = null) + { + $this->setRef($this->generateRef()); + + $this->dispatchEvent(TheliaEvents::BEFORE_CREATECUSTOMER, new CustomerEvent($this)); + return true; + } + + /** + * {@inheritDoc} + */ + public function postInsert(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_CREATECUSTOMER, new CustomerEvent($this)); + } + + /** + * {@inheritDoc} + */ + public function preUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_CHANGECUSTOMER, new CustomerEvent($this)); + return true; + } + + /** + * {@inheritDoc} + */ + public function postUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_CHANGECUSTOMER, new CustomerEvent($this)); + } + + /** + * {@inheritDoc} + */ + public function preDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_DELETECONFIG, new CustomerEvent($this)); + return true; + } + + /** + * {@inheritDoc} + */ + public function postDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_DELETECONFIG, new CustomerEvent($this)); + } } diff --git a/core/lib/Thelia/Model/Tools/ModelEventDispatcherTrait.php b/core/lib/Thelia/Model/Tools/ModelEventDispatcherTrait.php index aeaadc1f3..7e2e34d83 100644 --- a/core/lib/Thelia/Model/Tools/ModelEventDispatcherTrait.php +++ b/core/lib/Thelia/Model/Tools/ModelEventDispatcherTrait.php @@ -40,6 +40,8 @@ trait ModelEventDispatcherTrait { public function setDispatcher(EventDispatcherInterface $dispatcher) { $this->dispatcher = $dispatcher; + + return $this; } protected function dispatchEvent($eventName, ActionEvent $event) diff --git a/templates/admin/default/assets/css/admin.less b/templates/admin/default/assets/css/admin.less index 66a03ab37..8e7999ae6 100755 --- a/templates/admin/default/assets/css/admin.less +++ b/templates/admin/default/assets/css/admin.less @@ -703,9 +703,12 @@ label { line-height: 30px; - .btn-add-item { + .action-btn { display: block; float: right; + margin-left: 10px; + + text-transform: none; } } @@ -757,4 +760,14 @@ label { text-align: left; text-transform: uppercase; } +} + +.table-left-aligned { + th, td { + text-align: left; + } + + select, textarea, input[type="text"], input[type="password"], input[type="datetime"], input[type="datetime-local"], input[type="date"], input[type="month"], input[type="time"], input[type="week"], input[type="number"], input[type="email"], input[type="url"], input[type="search"], input[type="tel"], input[type="color"], .uneditable-input { + margin-bottom: 0; + } } \ No newline at end of file diff --git a/templates/admin/default/categories.html b/templates/admin/default/categories.html index 5d2ef5842..00f2bb9a7 100755 --- a/templates/admin/default/categories.html +++ b/templates/admin/default/categories.html @@ -32,7 +32,7 @@ {module_include location='category_list_caption'} {loop type="auth" name="can_create" context="admin" roles="ADMIN" permissions="admin.category.create"} - + {/loop} @@ -185,7 +185,7 @@ {module_include location='product_list_caption'} - + diff --git a/templates/admin/default/config.html b/templates/admin/default/config.html deleted file mode 100644 index 46d257ff3..000000000 --- a/templates/admin/default/config.html +++ /dev/null @@ -1,44 +0,0 @@ -{check_auth context="admin" roles="ADMIN" permissions="admin.configuration.variables.view" login_tpl="/admin/login"} - -{$page_title={intl l='Configuration'}} - -{include file='includes/header.inc.html'} - - - - - - {module_include location='config_top'} - - {intl l="Thelia system variables "} - - - - - - - {intl l='Product catalog configuration'} - {loop name="config" type="config" hidden="0"} - - {$TITLE} - {$NAME} - - - {if ! $secured} - {loop type="auth" name="can_delete" context="admin" roles="ADMIN" permissions="admin.configuration.variables.delete"} - - {/loop} - {/if} - - - {/loop} - - - - - - - -{include file='includes/js.inc.html'} - -{include file='includes/footer.inc.html'} \ No newline at end of file diff --git a/templates/admin/default/configuration.html b/templates/admin/default/configuration.html index 88454c6e5..6973807c7 100644 --- a/templates/admin/default/configuration.html +++ b/templates/admin/default/configuration.html @@ -112,8 +112,8 @@ {loop type="auth" name="pcc2" context="admin" roles="ADMIN" permissions="admin.configuration.variables"} - {intl l='System variables'} - + {intl l='System variables'} + {/loop} diff --git a/templates/admin/default/variables.html b/templates/admin/default/variables.html new file mode 100644 index 000000000..3084e2196 --- /dev/null +++ b/templates/admin/default/variables.html @@ -0,0 +1,77 @@ +{check_auth context="admin" roles="ADMIN" permissions="admin.configuration.variables.view" login_tpl="/admin/login"} + +{$page_title={intl l='Configuration'}} + +{include file='includes/header.inc.html'} + + + + + + {module_include location='config_top'} + + {intl l="Thelia system variables configuration"} + + + + + + + + + {intl l='Thelia system variables'} + {loop type="auth" name="can_create" context="admin" roles="ADMIN" permissions="admin.category.create"} + + + + {intl l='Save changes'} + {/loop} + + + + {intl l="Purpose"} + {intl l="Name"} + {intl l="Value"} + + + {loop name="config" type="config" hidden="0" secured="*" backend_context="1"} + + {$TITLE} + {$NAME} + + {if $SECURED} + {$VALUE} + {else} + + {/if} + + + {if ! $SECURED} + {loop type="auth" name="can_delete" context="admin" roles="ADMIN" permissions="admin.configuration.variables.delete"} + + {/loop} + {/if} + + + {/loop} + + + + + + + + +{include file='includes/js.inc.html'} + + +{include file='includes/footer.inc.html'} \ No newline at end of file