diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 198c49228..974de091c 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -185,6 +185,7 @@ + diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index 313fb3a57..2257a9459 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -113,10 +113,19 @@ Thelia\Controller\Admin\CurrencyController::deleteAction - + + Thelia\Controller\Admin\AttributeController::defaultAction + + + + + Thelia\Controller\Admin\CurrencyController::updatePositionAction + + + diff --git a/core/lib/Thelia/Controller/Admin/AttributeController.php b/core/lib/Thelia/Controller/Admin/AttributeController.php new file mode 100644 index 000000000..d2c1ea351 --- /dev/null +++ b/core/lib/Thelia/Controller/Admin/AttributeController.php @@ -0,0 +1,57 @@ +. */ +/* */ +/*************************************************************************************/ + +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 + */ +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'); + } + +} \ No newline at end of file diff --git a/core/lib/Thelia/Controller/Admin/ConfigController.php b/core/lib/Thelia/Controller/Admin/ConfigController.php index a67ecbaaa..b84368c2f 100644 --- a/core/lib/Thelia/Controller/Admin/ConfigController.php +++ b/core/lib/Thelia/Controller/Admin/ConfigController.php @@ -241,7 +241,7 @@ class ConfigController extends BaseAdminController if ($this->getRequest()->get('save_mode') == 'stay') { $this->redirectToRoute( - "admin.configuration.variables.change", + "admin.configuration.variables.update", array('variable_id' => $variable_id) ); } diff --git a/core/lib/Thelia/Controller/BaseController.php b/core/lib/Thelia/Controller/BaseController.php index 04d3d7ba0..776a1266b 100755 --- a/core/lib/Thelia/Controller/BaseController.php +++ b/core/lib/Thelia/Controller/BaseController.php @@ -226,7 +226,7 @@ class BaseController extends ContainerAware $route = $this->container->get($routerName)->getRouteCollection()->get($routeId); 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(); diff --git a/core/lib/Thelia/Core/Template/Loop/Attribute.php b/core/lib/Thelia/Core/Template/Loop/Attribute.php index e967709f3..ecdc551d2 100755 --- a/core/lib/Thelia/Core/Template/Loop/Attribute.php +++ b/core/lib/Thelia/Core/Template/Loop/Attribute.php @@ -162,7 +162,8 @@ class Attribute extends BaseI18nLoop ->set("TITLE",$attribute->getVirtualColumn('i18n_TITLE')) ->set("CHAPO", $attribute->getVirtualColumn('i18n_CHAPO')) ->set("DESCRIPTION", $attribute->getVirtualColumn('i18n_DESCRIPTION')) - ->set("POSTSCRIPTUM", $attribute->getVirtualColumn('i18n_POSTSCRIPTUM')); + ->set("POSTSCRIPTUM", $attribute->getVirtualColumn('i18n_POSTSCRIPTUM')) + ->set("POSITION", $attribute->getPosition()); $loopResult->addRow($loopResultRow); } diff --git a/core/lib/Thelia/Core/Template/Loop/AttributeAvailability.php b/core/lib/Thelia/Core/Template/Loop/AttributeAvailability.php index cd5ad6564..ca4618f53 100755 --- a/core/lib/Thelia/Core/Template/Loop/AttributeAvailability.php +++ b/core/lib/Thelia/Core/Template/Loop/AttributeAvailability.php @@ -131,7 +131,8 @@ class AttributeAvailability extends BaseI18nLoop ->set("TITLE",$attributeAv->getVirtualColumn('i18n_TITLE')) ->set("CHAPO", $attributeAv->getVirtualColumn('i18n_CHAPO')) ->set("DESCRIPTION", $attributeAv->getVirtualColumn('i18n_DESCRIPTION')) - ->set("POSTSCRIPTUM", $attributeAv->getVirtualColumn('i18n_POSTSCRIPTUM')); + ->set("POSTSCRIPTUM", $attributeAv->getVirtualColumn('i18n_POSTSCRIPTUM')) + ->set("POSITION", $attributeAv->getPosition()); $loopResult->addRow($loopResultRow); } diff --git a/core/lib/Thelia/Core/Template/Loop/Country.php b/core/lib/Thelia/Core/Template/Loop/Country.php index aee6492f7..0aeb62b15 100755 --- a/core/lib/Thelia/Core/Template/Loop/Country.php +++ b/core/lib/Thelia/Core/Template/Loop/Country.php @@ -113,10 +113,10 @@ class Country extends BaseI18nLoop ->set("TITLE",$country->getVirtualColumn('i18n_TITLE')) ->set("CHAPO", $country->getVirtualColumn('i18n_CHAPO')) ->set("DESCRIPTION", $country->getVirtualColumn('i18n_DESCRIPTION')) - ->set("POSTSCRIPTUM", $country->getVirtualColumn('i18n_POSTSCRIPTUM')); - $loopResultRow->set("ISOCODE", $country->getIsocode()); - $loopResultRow->set("ISOALPHA2", $country->getIsoalpha2()); - $loopResultRow->set("ISOALPHA3", $country->getIsoalpha3()); + ->set("POSTSCRIPTUM", $country->getVirtualColumn('i18n_POSTSCRIPTUM')) + ->set("ISOCODE", $country->getIsocode()) + ->set("ISOALPHA2", $country->getIsoalpha2()) + ->set("ISOALPHA3", $country->getIsoalpha3()); $loopResult->addRow($loopResultRow); } diff --git a/core/lib/Thelia/Core/Template/Loop/Feature.php b/core/lib/Thelia/Core/Template/Loop/Feature.php index 6c2401f42..14b7afaf5 100755 --- a/core/lib/Thelia/Core/Template/Loop/Feature.php +++ b/core/lib/Thelia/Core/Template/Loop/Feature.php @@ -154,7 +154,8 @@ class Feature extends BaseI18nLoop ->set("TITLE",$feature->getVirtualColumn('i18n_TITLE')) ->set("CHAPO", $feature->getVirtualColumn('i18n_CHAPO')) ->set("DESCRIPTION", $feature->getVirtualColumn('i18n_DESCRIPTION')) - ->set("POSTSCRIPTUM", $feature->getVirtualColumn('i18n_POSTSCRIPTUM')); + ->set("POSTSCRIPTUM", $feature->getVirtualColumn('i18n_POSTSCRIPTUM')) + ->set("POSITION", $feature->getPosition()); $loopResult->addRow($loopResultRow); } diff --git a/core/lib/Thelia/Core/Template/Loop/FeatureAvailability.php b/core/lib/Thelia/Core/Template/Loop/FeatureAvailability.php index 45eed6dc3..38bee46f0 100755 --- a/core/lib/Thelia/Core/Template/Loop/FeatureAvailability.php +++ b/core/lib/Thelia/Core/Template/Loop/FeatureAvailability.php @@ -129,7 +129,8 @@ class FeatureAvailability extends BaseI18nLoop ->set("TITLE",$featureAv->getVirtualColumn('i18n_TITLE')) ->set("CHAPO", $featureAv->getVirtualColumn('i18n_CHAPO')) ->set("DESCRIPTION", $featureAv->getVirtualColumn('i18n_DESCRIPTION')) - ->set("POSTSCRIPTUM", $featureAv->getVirtualColumn('i18n_POSTSCRIPTUM')); + ->set("POSTSCRIPTUM", $featureAv->getVirtualColumn('i18n_POSTSCRIPTUM')) + ->set("POSITION", $featureAv->getPosition()); $loopResult->addRow($loopResultRow); } diff --git a/core/lib/Thelia/Core/Template/Loop/FeatureValue.php b/core/lib/Thelia/Core/Template/Loop/FeatureValue.php index 700eff39c..998dfe4e0 100755 --- a/core/lib/Thelia/Core/Template/Loop/FeatureValue.php +++ b/core/lib/Thelia/Core/Template/Loop/FeatureValue.php @@ -149,7 +149,8 @@ class FeatureValue extends BaseI18nLoop ->set("TITLE",$featureValue->getVirtualColumn(FeatureAvTableMap::TABLE_NAME . '_i18n_TITLE')) ->set("CHAPO", $featureValue->getVirtualColumn(FeatureAvTableMap::TABLE_NAME . '_i18n_CHAPO')) ->set("DESCRIPTION", $featureValue->getVirtualColumn(FeatureAvTableMap::TABLE_NAME . '_i18n_DESCRIPTION')) - ->set("POSTSCRIPTUM", $featureValue->getVirtualColumn(FeatureAvTableMap::TABLE_NAME . '_i18n_POSTSCRIPTUM')); + ->set("POSTSCRIPTUM", $featureValue->getVirtualColumn(FeatureAvTableMap::TABLE_NAME . '_i18n_POSTSCRIPTUM')) + ->set("POSITION", $featureValue->getPosition()); $loopResult->addRow($loopResultRow); } diff --git a/core/lib/Thelia/Core/Template/Loop/Title.php b/core/lib/Thelia/Core/Template/Loop/Title.php index 38dcb3fe3..4243f83f1 100755 --- a/core/lib/Thelia/Core/Template/Loop/Title.php +++ b/core/lib/Thelia/Core/Template/Loop/Title.php @@ -89,7 +89,8 @@ class Title extends BaseI18nLoop ->set("LOCALE",$locale) ->set("DEFAULT", $title->getByDefault()) ->set("SHORT", $title->getVirtualColumn('i18n_SHORT')) - ->set("LONG", $title->getVirtualColumn('i18n_LONG')); + ->set("LONG", $title->getVirtualColumn('i18n_LONG')) + ->set("POSITION", $title->getPosition()); $loopResult->addRow($loopResultRow); } diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/AdminUtilities.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/AdminUtilities.php index 12ac13276..bb9770520 100644 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/AdminUtilities.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/AdminUtilities.php @@ -121,7 +121,7 @@ class AdminUtilities extends AbstractSmartyPlugin } if (! empty($icon)) - $output = sprintf(' ', $icon); + $output = sprintf(' ', $icon); else $output = ''; diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php index a2fd10c15..1fdb6e4bf 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php @@ -23,10 +23,20 @@ namespace Thelia\Core\Template\Smarty\Plugins; +use Propel\Runtime\ActiveQuery\ModelCriteria; +use Symfony\Component\HttpFoundation\Request; use Thelia\Core\Template\Smarty\AbstractSmartyPlugin; use Thelia\Core\Security\SecurityContext; use Thelia\Core\Template\ParserContext; use Thelia\Core\Template\Smarty\SmartyPluginDescriptor; +use Thelia\Model\CategoryQuery; +use Thelia\Model\ContentQuery; +use Thelia\Model\FolderQuery; +use Thelia\Model\Product; +use Thelia\Model\ProductQuery; +use Thelia\Model\Tools\ModelCriteriaTools; +use Thelia\Tools\DateTimeFormat; + /** * Implementation of data access to main Thelia objects (users, cart, etc.) * @@ -37,10 +47,13 @@ class DataAccessFunctions extends AbstractSmartyPlugin { private $securityContext; protected $parserContext; + protected $request; - public function __construct(SecurityContext $securityContext, ParserContext $parserContext) + public function __construct(Request $request, SecurityContext $securityContext, ParserContext $parserContext) { $this->securityContext = $securityContext; + $this->parserContext = $parserContext; + $this->request = $request; } /** @@ -52,7 +65,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin */ public function adminDataAccess($params, &$smarty) { - return $this->userDataAccess("Admin User", $this->securityContext->getAdminUser(), $params); + return $this->dataAccess("Admin User", $params, $this->securityContext->getAdminUser()); } /** @@ -64,37 +77,146 @@ class DataAccessFunctions extends AbstractSmartyPlugin */ public function customerDataAccess($params, &$smarty) { - return $this->userDataAccess("Customer User", $this->securityContext->getCustomerUser(), $params); + return $this->dataAccess("Customer User", $params, $this->securityContext->getCustomerUser()); } + public function productDataAccess($params, &$smarty) + { + $productId = $this->request->get('product_id'); + + if($productId !== null) { + + $search = ProductQuery::create() + ->filterById($productId); + + return $this->dataAccessWithI18n("Product", $params, $search); + } + } + + public function categoryDataAccess($params, &$smarty) + { + $categoryId = $this->request->get('category_id'); + + if($categoryId !== null) { + + $search = CategoryQuery::create() + ->filterById($categoryId); + + return $this->dataAccessWithI18n("Category", $params, $search); + } + } + + public function contentDataAccess($params, &$smarty) + { + $contentId = $this->request->get('content_id'); + + if($contentId !== null) { + + $search = ContentQuery::create() + ->filterById($contentId); + + return $this->dataAccessWithI18n("Content", $params, $search); + } + } + + public function folderDataAccess($params, &$smarty) + { + $folderId = $this->request->get('folder_id'); + + if($folderId !== null) { + + $search = FolderQuery::create() + ->filterById($folderId); + + return $this->dataAccessWithI18n("Folder", $params, $search); + } + } + /** - * @param $objectLabel - * @param $user - * @param $params + * @param $objectLabel + * @param $params + * @param ModelCriteria $search + * @param array $columns + * @param null $foreignTable + * @param string $foreignKey + * + * @return string + */ + protected function dataAccessWithI18n($objectLabel, $params, ModelCriteria $search, $columns = array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), $foreignTable = null, $foreignKey = 'ID') + { + $lang = $this->getNormalizedParam($params, array('lang')); + if($lang === null) { + $lang = $this->request->getSession()->getLang()->getId(); + } + + ModelCriteriaTools::getI18n( + false, + $lang, + $search, + $this->request->getSession()->getLang()->getLocale(), + $columns, + $foreignTable, + $foreignKey, + true + ); + + $data = $search->findOne(); + + $noGetterData = array(); + foreach($columns as $column) { + $noGetterData[$column] = $data->getVirtualColumn('i18n_' . $column); + } + + return $this->dataAccess($objectLabel, $params, $data, $noGetterData); + } + + /** + * @param $objectLabel + * @param $params + * @param $data + * @param array $noGetterData * * @return string * @throws \InvalidArgumentException */ - protected function userDataAccess($objectLabel, $user, $params) - { - $attribute = $this->getNormalizedParam($params, array('attribute', 'attrib', 'attr')); + protected function dataAccess($objectLabel, $params, $data, $noGetterData = array()) + { + $attribute = $this->getNormalizedParam($params, array('attribute', 'attrib', 'attr')); - if (! empty($attribute)) { + if (! empty($attribute)) { - if (null != $user) { - $getter = sprintf("get%s", ucfirst($attribute)); + if (null != $data) { - if (method_exists($user, $getter)) { - return $user->$getter(); - } + $keyAttribute = strtoupper($attribute); + if(array_key_exists($keyAttribute, $noGetterData)) { + return $noGetterData[$keyAttribute]; + } - throw new \InvalidArgumentException(sprintf("%s has no '%s' attribute", $objectLabel, $attribute)); + $getter = sprintf("get%s", ucfirst($attribute)); + if (method_exists($data, $getter)) { + $return = $data->$getter(); - } - } + if($return instanceof \DateTime) { + if (array_key_exists("format", $params)) { + $format = $params["format"]; + } else { + $format = DateTimeFormat::getInstance($this->request)->getFormat(array_key_exists("output", $params) ? $params["output"] : null); + } + + $return = $return->format($format); + } + + return $return; + } + + throw new \InvalidArgumentException(sprintf("%s has no '%s' attribute", $objectLabel, $attribute)); + + } + } + + return ''; + } - return ''; - } /** * Define the various smarty plugins hendled by this class * @@ -104,7 +226,11 @@ class DataAccessFunctions extends AbstractSmartyPlugin { return array( new SmartyPluginDescriptor('function', 'admin', $this, 'adminDataAccess'), - new SmartyPluginDescriptor('function', 'customer', $this, 'customerDataAccess') + new SmartyPluginDescriptor('function', 'customer', $this, 'customerDataAccess'), + new SmartyPluginDescriptor('function', 'product', $this, 'productDataAccess'), + new SmartyPluginDescriptor('function', 'category', $this, 'categoryDataAccess'), + new SmartyPluginDescriptor('function', 'content', $this, 'contentDataAccess'), + new SmartyPluginDescriptor('function', 'folder', $this, 'folderDataAccess'), ); } } diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Format.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Format.php index a095f214a..daaff3fc1 100644 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Format.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Format.php @@ -27,6 +27,7 @@ use Thelia\Core\HttpFoundation\Request; use Thelia\Core\Template\Smarty\AbstractSmartyPlugin; use Thelia\Core\Template\Smarty\Exception\SmartyPluginException; use Thelia\Core\Template\Smarty\SmartyPluginDescriptor; +use Thelia\Tools\DateTimeFormat; /** * @@ -79,29 +80,10 @@ class Format extends AbstractSmartyPlugin return ""; } - $format = null; - $output = array_key_exists("output", $params) ? $params["output"] : null; - if (array_key_exists("format", $params)) { $format = $params["format"]; } else { - $session = $this->request->getSession(); - $lang = $session->getLang(); - - if($lang) { - switch ($output) { - case "date" : - $format = $lang->getDateFormat(); - break; - case "time" : - $format = $lang->getTimeFormat(); - break; - default: - case "datetime" : - $format = $lang->getDateTimeFormat(); - break; - } - } + $format = DateTimeFormat::getInstance($this->request)->getFormat(array_key_exists("output", $params) ? $params["output"] : null); } return $date->format($format); diff --git a/core/lib/Thelia/Form/BaseDescForm.php b/core/lib/Thelia/Form/BaseDescForm.php index c4f4f90c3..2b35f3e6e 100644 --- a/core/lib/Thelia/Form/BaseDescForm.php +++ b/core/lib/Thelia/Form/BaseDescForm.php @@ -43,12 +43,31 @@ abstract class BaseDescForm extends BaseForm ->add("title", "text", array( "constraints" => array( new NotBlank() + ), + "label" => "Title", + "label_attr" => array( + "for" => "title" ) ) ) - ->add("chapo", "text", array()) - ->add("description", "text", array()) - ->add("postscriptum", "text", array()) + ->add("chapo", "text", array( + "label" => "Summary", + "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" + ) + )) ; } } \ No newline at end of file diff --git a/core/lib/Thelia/Form/CategoryCreationForm.php b/core/lib/Thelia/Form/CategoryCreationForm.php index 9935eec19..a125ad090 100755 --- a/core/lib/Thelia/Form/CategoryCreationForm.php +++ b/core/lib/Thelia/Form/CategoryCreationForm.php @@ -32,6 +32,10 @@ class CategoryCreationForm extends BaseForm ->add("title", "text", array( "constraints" => array( new NotBlank() + ), + "label" => "Category title *", + "label_attr" => array( + "for" => "title" ) )) ->add("parent", "integer", array( diff --git a/core/lib/Thelia/Form/ConfigCreationForm.php b/core/lib/Thelia/Form/ConfigCreationForm.php index 5594830bc..b2a0c11bb 100644 --- a/core/lib/Thelia/Form/ConfigCreationForm.php +++ b/core/lib/Thelia/Form/ConfigCreationForm.php @@ -40,11 +40,19 @@ class ConfigCreationForm extends BaseForm $this->formBuilder ->add("name", "text", array( - "constraints" => $name_constraints + "constraints" => $name_constraints, + "label" => "Name *", + "label_attr" => array( + "for" => "name" + ) )) ->add("title", "text", array( "constraints" => array( new Constraints\NotBlank() + ), + "label" => "Purpose *", + "label_attr" => array( + "for" => "purpose" ) )) ->add("locale", "hidden", array( @@ -52,9 +60,16 @@ class ConfigCreationForm extends BaseForm new Constraints\NotBlank() ) )) - ->add("value", "text", array()) + ->add("value", "text", array( + "label" => "Value *", + "label_attr" => array( + "for" => "value" + ) + )) ->add("hidden", "hidden", array()) - ->add("secured", "hidden", array()) + ->add("secured", "hidden", array( + "label" => "Prevent variable modification or deletion, except for super-admin" + )) ; } diff --git a/core/lib/Thelia/Form/ConfigModificationForm.php b/core/lib/Thelia/Form/ConfigModificationForm.php index dd0a0e42f..295c0403d 100644 --- a/core/lib/Thelia/Form/ConfigModificationForm.php +++ b/core/lib/Thelia/Form/ConfigModificationForm.php @@ -44,11 +44,22 @@ class ConfigModificationForm extends BaseDescForm ->add("name", "text", array( "constraints" => array( 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("secured", "hidden", array()) + ->add("secured", "hidden", array( + "label" => "Prevent variable modification or deletion, except for super-admin" + )) ; } diff --git a/core/lib/Thelia/Form/MessageCreationForm.php b/core/lib/Thelia/Form/MessageCreationForm.php index a3444c733..6ce84cb06 100644 --- a/core/lib/Thelia/Form/MessageCreationForm.php +++ b/core/lib/Thelia/Form/MessageCreationForm.php @@ -40,11 +40,19 @@ class MessageCreationForm extends BaseForm $this->formBuilder ->add("name", "text", array( - "constraints" => $name_constraints + "constraints" => $name_constraints, + "label" => "Name *", + "label_attr" => array( + "for" => "name" + ) )) ->add("title", "text", array( "constraints" => array( new Constraints\NotBlank() + ), + "label" => "Purpose *", + "label_attr" => array( + "for" => "purpose" ) )) ->add("locale", "hidden", array( diff --git a/core/lib/Thelia/Form/MessageModificationForm.php b/core/lib/Thelia/Form/MessageModificationForm.php index 539a8babc..a23f66e28 100644 --- a/core/lib/Thelia/Form/MessageModificationForm.php +++ b/core/lib/Thelia/Form/MessageModificationForm.php @@ -33,13 +33,43 @@ class MessageModificationForm extends BaseForm { $this->formBuilder ->add("id" , "hidden", array("constraints" => array(new GreaterThan(array('value' => 0))))) - ->add("name" , "text" , array("constraints" => array(new NotBlank()))) - ->add("secured" , "text" , array()) + ->add("name" , "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("title" , "text" , array("constraints" => array(new NotBlank()))) - ->add("subject" , "text" , array("constraints" => array(new NotBlank()))) - ->add("html_message" , "text" , array()) - ->add("text_message" , "text" , array()) + ->add("title" , "text" , array( + "constraints" => array(new NotBlank()), + "label" => "Title *", + "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" + ) + )) ; } diff --git a/core/lib/Thelia/Model/Tools/ModelCriteriaTools.php b/core/lib/Thelia/Model/Tools/ModelCriteriaTools.php index 5e22f08e9..5e5dae010 100755 --- a/core/lib/Thelia/Model/Tools/ModelCriteriaTools.php +++ b/core/lib/Thelia/Model/Tools/ModelCriteriaTools.php @@ -113,7 +113,7 @@ class ModelCriteriaTools $localeSearch = LangQuery::create()->findOneById($requestedLangId); if ($localeSearch === null) { - throw new \InvalidArgumentException(sprintf('Incorrect lang argument given in attribute loop: lang ID %d not found', $requestedLangId)); + throw new \InvalidArgumentException(sprintf('Incorrect lang argument given : lang ID %d not found', $requestedLangId)); } $locale = $localeSearch->getLocale(); diff --git a/core/lib/Thelia/Tools/DateTimeFormat.php b/core/lib/Thelia/Tools/DateTimeFormat.php new file mode 100755 index 000000000..bd6161389 --- /dev/null +++ b/core/lib/Thelia/Tools/DateTimeFormat.php @@ -0,0 +1,66 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tools; + +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\DependencyInjection\ContainerInterface; + +class DateTimeFormat +{ + protected $request; + + public function __construct(Request $request) + { + $this->request = $request; + } + + public static function getInstance(Request $request) + { + return new DateTimeFormat($request); + } + + public function getFormat($output = null) + { + $lang = $this->request->getSession()->getLang(); + + $format = null; + + if($lang) { + switch ($output) { + case "date" : + $format = $lang->getDateFormat(); + break; + case "time" : + $format = $lang->getTimeFormat(); + break; + default: + case "datetime" : + $format = $lang->getDateTimeFormat(); + break; + } + } + + return $format; + } +} \ No newline at end of file diff --git a/templates/admin/default/assets/img/flags/en.gif b/templates/admin/default/assets/img/flags/en.gif index 3a7661fdb..91b2b0090 100755 Binary files a/templates/admin/default/assets/img/flags/en.gif and b/templates/admin/default/assets/img/flags/en.gif differ diff --git a/templates/admin/default/assets/img/flags/es.gif b/templates/admin/default/assets/img/flags/es.gif index 9ac64ad37..bdf09f8f7 100755 Binary files a/templates/admin/default/assets/img/flags/es.gif and b/templates/admin/default/assets/img/flags/es.gif differ diff --git a/templates/admin/default/assets/img/flags/fr.gif b/templates/admin/default/assets/img/flags/fr.gif index 46f4d122d..2f6cf9ea3 100755 Binary files a/templates/admin/default/assets/img/flags/fr.gif and b/templates/admin/default/assets/img/flags/fr.gif differ diff --git a/templates/admin/default/assets/img/flags/it.gif b/templates/admin/default/assets/img/flags/it.gif index fddb02499..cdd750a54 100755 Binary files a/templates/admin/default/assets/img/flags/it.gif and b/templates/admin/default/assets/img/flags/it.gif differ diff --git a/templates/admin/default/assets/js/bootstrap-switch/bootstrap-switch.js b/templates/admin/default/assets/js/bootstrap-switch/bootstrap-switch.js new file mode 100644 index 000000000..1538f9df1 --- /dev/null +++ b/templates/admin/default/assets/js/bootstrap-switch/bootstrap-switch.js @@ -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 = $('') + .addClass("switch-left") + .addClass(myClasses) + .addClass(color) + .html(onLabel); + + color = ''; + if ($element.data('off') !== undefined) + color = "switch-" + $element.data('off'); + + $switchRight = $('') + .addClass("switch-right") + .addClass(myClasses) + .addClass(color) + .html(offLabel); + + $label = $('