diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml
index 41e49d7d7..db2b1db82 100755
--- a/core/lib/Thelia/Config/Resources/config.xml
+++ b/core/lib/Thelia/Config/Resources/config.xml
@@ -54,6 +54,7 @@
+
diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml
index af7c950af..8f2e54f86 100755
--- a/core/lib/Thelia/Config/Resources/routing/admin.xml
+++ b/core/lib/Thelia/Config/Resources/routing/admin.xml
@@ -100,6 +100,10 @@
Thelia\Controller\Admin\CategoryController::addRelatedContentAction
+
+ Thelia\Controller\Admin\CategoryController::addRelatedPictureAction
+
+
Thelia\Controller\Admin\CategoryController::deleteRelatedContentAction
diff --git a/core/lib/Thelia/Controller/Admin/CategoryController.php b/core/lib/Thelia/Controller/Admin/CategoryController.php
index 8c74c31ec..1c7854416 100755
--- a/core/lib/Thelia/Controller/Admin/CategoryController.php
+++ b/core/lib/Thelia/Controller/Admin/CategoryController.php
@@ -27,6 +27,7 @@ use Thelia\Core\Event\CategoryDeleteEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\CategoryUpdateEvent;
use Thelia\Core\Event\CategoryCreateEvent;
+use Thelia\Form\CategoryPictureCreationForm;
use Thelia\Model\CategoryQuery;
use Thelia\Form\CategoryModificationForm;
use Thelia\Form\CategoryCreationForm;
@@ -306,6 +307,39 @@ class CategoryController extends AbstractCrudController
$this->redirectToEditionTemplate();
}
+ /**
+ * Add category pictures
+ *
+ * @return \Symfony\Component\HttpFoundation\Response
+ */
+ public function addRelatedPictureAction()
+ {
+ // Check current user authorization
+ if (null !== $response = $this->checkAuth("admin.categories.update")) {
+ return $response;
+ }
+
+// $content_id = intval($this->getRequest()->get('content_id'));
+//
+// if ($content_id > 0) {
+//
+// $event = new CategoryAddContentEvent(
+// $this->getExistingObject(),
+// $content_id
+// );
+//
+// try {
+// $this->dispatch(TheliaEvents::CATEGORY_ADD_CONTENT, $event);
+// }
+// catch (\Exception $ex) {
+// // Any error
+// return $this->errorPage($ex);
+// }
+// }
+
+ $this->redirectToEditionTemplate();
+ }
+
public function deleteRelatedContentAction() {
// Check current user authorization
@@ -331,4 +365,30 @@ class CategoryController extends AbstractCrudController
$this->redirectToEditionTemplate();
}
+
+ /**
+ * @todo remove
+ * @return Symfony\Component\HttpFoundation\Response|void
+ */
+ public function updateAction()
+ {
+ var_dump('updateAction');
+ if ($this->getRequest()->isMethod('POST')) {
+ var_dump('getRequest', $this->getRequest()->files);
+ // Create the form from the request
+ $creationForm = new CategoryPictureCreationForm($this->getRequest());
+
+ // Check the form against constraints violations
+ $form = $this->validateForm($creationForm, 'POST');
+ var_dump('$form', $form);
+
+ // Get the form field values
+ $data = $form->getData();
+ var_dump('$data', $data);
+ }
+
+
+ return parent::updateAction();
+ }
+
}
diff --git a/core/lib/Thelia/Form/CategoryPictureCreationForm.php b/core/lib/Thelia/Form/CategoryPictureCreationForm.php
new file mode 100644
index 000000000..2dffc61c3
--- /dev/null
+++ b/core/lib/Thelia/Form/CategoryPictureCreationForm.php
@@ -0,0 +1,100 @@
+. */
+/* */
+/*************************************************************************************/
+namespace Thelia\Form;
+
+use Symfony\Component\Validator\Constraints\Image;
+use Symfony\Component\Validator\Constraints\NotBlank;
+use Thelia\Core\Translation\Translator;
+
+class CategoryPictureCreationForm extends BaseForm
+{
+ protected function buildForm()
+ {
+ $this->formBuilder
+// ->add('alt')
+ ->add('file', 'file', array(
+ 'constraints' => array(
+ new NotBlank(),
+ new Image(
+ array(
+ 'minWidth' => 200,
+ 'maxWidth' => 400,
+ 'minHeight' => 200,
+ 'maxHeight' => 400,
+ )
+ )
+ )))
+// ->add('category_id', 'model', array(
+// 'disabled' => false,
+// 'class' => 'Thelia\Model\ProductImage'
+// ))
+// ->add('position', 'integer', array(
+// 'constraints' => array(
+// new NotBlank()
+// )
+// ))
+ ->add('title', 'text', array(
+ 'constraints' => array(
+// new NotBlank()
+ ),
+// 'label' => Translator::getInstance()->trans('Category picture title *'),
+// 'label_attr' => array(
+// 'for' => 'title'
+// )
+ ))
+// ->add('description', 'text', array(
+// 'constraints' => array(
+// new NotBlank()
+// ),
+// 'label' => Translator::getInstance()->trans('Category picture description *'),
+// 'label_attr' => array(
+// 'for' => 'description'
+// )
+// ))
+// ->add('chapo', 'text', array(
+// 'constraints' => array(
+// new NotBlank()
+// ),
+// 'label' => Translator::getInstance()->trans('Category picture chapo *'),
+// 'label_attr' => array(
+// 'for' => 'chapo'
+// )
+// ))
+// ->add('postscriptum', 'text', array(
+// 'constraints' => array(
+// new NotBlank()
+// ),
+// 'label' => Translator::getInstance()->trans('Category picture postscriptum *'),
+// 'label_attr' => array(
+// 'for' => 'postscriptum'
+// )
+// ))
+
+ ;
+ }
+
+ public function getName()
+ {
+ return 'thelia_category_picture_creation';
+ }
+}
diff --git a/core/lib/Thelia/Model/CategoryImage.php b/core/lib/Thelia/Model/CategoryImage.php
index 5bf964e10..aca77615a 100755
--- a/core/lib/Thelia/Model/CategoryImage.php
+++ b/core/lib/Thelia/Model/CategoryImage.php
@@ -25,4 +25,48 @@ class CategoryImage extends BaseCategoryImage
return true;
}
+
+ /**
+ * Get picture absolute path
+ *
+ * @return null|string
+ */
+ public function getAbsolutePath()
+ {
+ return null === $this->file
+ ? null
+ : $this->getUploadRootDir().'/'.$this->file;
+ }
+
+ /**
+ * Get picture web path
+ *
+ * @return null|string
+ */
+ public function getWebPath()
+ {
+ return null === $this->file
+ ? null
+ : $this->getUploadDir().'/'.$this->file;
+ }
+
+ /**
+ * The absolute directory path where uploaded
+ * documents should be saved
+ * @return string
+ */
+ protected function getUploadRootDir()
+ {
+ return __DIR__.'/../../../../../'.$this->getUploadDir();
+ }
+
+ /**
+ * Get rid of the __DIR__ so it doesn't screw up
+ * when displaying uploaded doc/image in the view.
+ * @return string
+ */
+ protected function getUploadDir()
+ {
+ return 'local/media/images/category';
+ }
}
diff --git a/templates/admin/default/category-edit.html b/templates/admin/default/category-edit.html
index 723cf8242..6d1c4a9c2 100755
--- a/templates/admin/default/category-edit.html
+++ b/templates/admin/default/category-edit.html
@@ -246,6 +246,31 @@
+ image
+ {form name="thelia.admin.category.picture.creation"}
+
+ {/form}