Skip to content

Commit

Permalink
user files upload
Browse files Browse the repository at this point in the history
  • Loading branch information
behram committed Aug 2, 2015
1 parent b3f6568 commit 850ce8e
Show file tree
Hide file tree
Showing 36 changed files with 326 additions and 1,477 deletions.
2 changes: 0 additions & 2 deletions app/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ imports:
- { resource: swift.yml }
- { resource: media.yml }
parameters:
avatar_upload_dir: "%kernel.root_dir%/../web/uploads/avatarfiles/"
avatar_upload_base_url: %base_host%/uploads/avatarfiles/
admin_base_view: '::ojsbase.html.twig'
framework:
translator: { fallback: %locale% }
Expand Down
91 changes: 47 additions & 44 deletions app/config/media.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ knp_gaufrette:
local:
directory: %kernel.root_dir%/../web/uploads/journalindex/croped
create: true
user:
local:
directory: %kernel.root_dir%/../web/uploads/user
create: true
user_croped:
local:
directory: %kernel.root_dir%/../web/uploads/user/croped
create: true
issue:
local:
directory: %kernel.root_dir%/../web/uploads/issue
Expand All @@ -48,6 +56,12 @@ knp_gaufrette:
journalindex_croped:
adapter: journalindex_croped
alias: journalindex_croped_filesystem
user:
adapter: user
alias: user_filesystem
user_croped:
adapter: user_croped
alias: user_filesystem
issue:
adapter: issue
alias: issue_filesystem
Expand All @@ -57,10 +71,14 @@ oneup_uploader:
enable_progress: true
frontend: blueimp
allowed_mimetypes: ['application/pdf','image/jpeg','application/vnd.openxmlformats-officedocument.wordprocessingml.document','application/msword','application/vnd.ms-excel','image/png','image/svg+xml' ]
avatarfiles:
user:
enable_progress: true
frontend: blueimp
allowed_mimetypes: ['application/pdf','image/jpeg','application/vnd.openxmlformats-officedocument.wordprocessingml.document','application/msword','application/vnd.ms-excel','image/png','image/svg+xml' ]
allowed_mimetypes: ['image/jpeg','image/png','image/svg+xml' ]
storage:
type: gaufrette
filesystem: gaufrette.user_filesystem
stream_wrapper: gaufrette://user/
institution:
enable_progress: true
frontend: blueimp
Expand Down Expand Up @@ -97,10 +115,6 @@ oneup_uploader:
enable_progress: true
frontend: blueimp
allowed_mimetypes: ['application/pdf','image/jpeg','application/vnd.openxmlformats-officedocument.wordprocessingml.document','application/msword','application/vnd.ms-excel','image/png','image/svg+xml' ]
userfiles:
enable_progress: true
frontend: blueimp
allowed_mimetypes: ['application/pdf','image/jpeg','application/vnd.openxmlformats-officedocument.wordprocessingml.document','application/msword','application/vnd.ms-excel','image/png','image/svg+xml' ]
issue:
enable_progress: true
frontend: blueimp
Expand Down Expand Up @@ -130,12 +144,19 @@ liip_imagine:
stream.journalindex_croped_filesystem:
stream:
wrapper: gaufrette://journalindex_croped/
stream.user_filesystem:
stream:
wrapper: gaufrette://user/
stream.user_croped_filesystem:
stream:
wrapper: gaufrette://user_croped/
resolvers:
default:
web_path: ~

filter_sets:
original: ~
cache: ~
journal_original:
data_loader: stream.journal_filesystem
quality: 90
Expand All @@ -154,44 +175,18 @@ liip_imagine:
journalindex_croped:
data_loader: stream.journalindex_croped_filesystem
quality: 90
cache: ~
user_original:
data_loader: stream.user_filesystem
quality: 90
user_croped:
data_loader: stream.user_croped_filesystem
quality: 90
avatar_thumb:
data_loader: stream.user_croped_filesystem
quality: 90
filters:
relative_resize: { widen: 200 }
crop: {start:[0,0], size: [200, 200]}
avatar_thumb_crop:
quality: 90
filters:
crop: { start : [0,0], size: [200, 200]}
medium:
quality: 90
filters:
upscale: { min: [800,600]} #resize
height_60:
quality: 90
filters:
relative_resize: { heighten: 60 }
height_200:
quality: 90
filters:
relative_resize: { heighten: 200 }
height_60:
quality: 90
filters:
relative_resize: { heighten: 60 }
wide_100:
quality: 90
filters:
relative_resize: { widen: 100 }
wide_200:
quality: 90
filters:
relative_resize: { widen: 200 }
wide_960:
quality: 90
filters:
relative_resize: { widen: 960 }
issue_cover:
data_loader: stream.journal_croped_filesystem
quality: 90
Expand Down Expand Up @@ -243,11 +238,6 @@ liip_imagine:
filters:
relative_resize: { widen: 960 }
crop: {start:[0,0], size: [960, 200]}
user_header:
quality: 90
filters:
relative_resize: { widen: 960 }
crop: {start:[0,0], size: [1200, 300]}
issue_cover_medium:
data_loader: stream.journal_croped_filesystem
quality: 90
Expand Down Expand Up @@ -275,6 +265,12 @@ jb_file_uploader:
journalindex_croped:
assets:
directory: uploads/journalindex/croped
user:
assets:
directory: uploads/user
user_croped:
assets:
directory: uploads/user/croped
journalCompeting:
assets:
directory: uploads/journal
Expand Down Expand Up @@ -304,10 +300,17 @@ jb_file_uploader:
croped_fs: journalindex_croped
upload_validators: {}
crop_validators: {}
user:
upload_resolver: user
croped_resolver: user_croped
croped_fs: user_croped
upload_validators: {}
crop_validators: {}

parameters:
jb_fileuploader.resolver.asset.prototype.class: Ojs\Common\Services\FileUploadResolver\AssetsResolver
jb_fileuploader.file_history.manager.class: Ojs\Common\Services\FileHistoryManager
jb_fileuploader.croper.class: Ojs\Common\Services\Croper
jb_fileuploader.crop.manager.class: Ojs\Common\Services\CropFileManager
oneup_uploader.namer.uniqid.class : Ojs\Common\Services\FileNamer\UniqidNamer
oneup_uploader.routing.loader.class : Ojs\Common\Services\Routing\RouteLoader
7 changes: 0 additions & 7 deletions app/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ services:
- @security.token_storage
- @session
- "%cms_show_routes%"
- "%avatar_upload_base_url%"
- "%defaultInstitutionSlug%"
- "%ojs_logo%"
- "%ojs_tw%"
Expand Down Expand Up @@ -69,12 +68,6 @@ services:
tags:
- { name: kernel.event_listener, event: security.switch_user, method: onSecuritySwitchUser }

# ojs.ojs_upload_listener:
# class: Ojs\Common\Services\UploadListener
# arguments: ["%kernel.root_dir%"]
# tags:
# - { name: kernel.event_listener, event: oneup_uploader.post_persist, method: onUpload }

ojs.ojs_mailer:
class: Ojs\UserBundle\Service\MailerService
arguments: [@mailer, @templating, @doctrine.orm.entity_manager, "%system_email%"]
Expand Down
22 changes: 0 additions & 22 deletions docs/developers/Images.md

This file was deleted.

4 changes: 2 additions & 2 deletions src/Ojs/AdminBundle/Controller/AdminIndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function createAction(Request $request)
}
$entity = new JournalIndex();
$form = $this->createCreateForm($entity)
->add('c', 'submit');
->add('create', 'submit', array('label' => 'c'));
$form->handleRequest($request);

if ($form->isValid()) {
Expand Down Expand Up @@ -114,7 +114,7 @@ public function newAction()
}
$entity = new JournalIndex();
$form = $this->createCreateForm($entity)
->add('c', 'submit');
->add('create', 'submit', array('label' => 'c'));

return $this->render(
'OjsAdminBundle:AdminIndex:new.html.twig',
Expand Down
17 changes: 1 addition & 16 deletions src/Ojs/AdminBundle/Controller/AdminInstitutionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,7 @@ public function createAction(Request $request)
$form->handleRequest($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$header = $request->request->get('header');
$cover = $request->request->get('logo');
if ($header) {
$entity->setHeaderOptions(json_encode($header));
}
if ($cover) {
$entity->setLogoOptions(json_encode($cover));
}

$entity->setTranslatableLocale($request->getDefaultLocale());
$em->persist($entity);
$em->flush();
Expand Down Expand Up @@ -227,14 +220,6 @@ public function updateAction(Request $request, $id)
$editForm = $this->createEditForm($entity);
$editForm->handleRequest($request);
if ($editForm->isValid()) {
$header = $request->request->get('header');
$cover = $request->request->get('logo');
if ($header) {
$entity->setHeaderOptions(json_encode($header));
}
if ($cover) {
$entity->setLogoOptions(json_encode($cover));
}
$em->persist($entity);
$em->flush();
$this->successFlashBag('successful.update');
Expand Down
23 changes: 9 additions & 14 deletions src/Ojs/AdminBundle/Controller/AdminUserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use APY\DataGridBundle\Grid\Column\ActionsColumn;
use APY\DataGridBundle\Grid\Source\Entity;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ORM\ORMException;
use Ojs\Common\Controller\OjsController as Controller;
use Ojs\UserBundle\Entity\User;
Expand Down Expand Up @@ -67,15 +66,15 @@ public function createAction(Request $request)
throw new AccessDeniedException("You are not authorized for this page!");
}
$entity = new User();
$form = $this->createCreateForm($entity);
$form = $this->createCreateForm($entity)
->add('create', 'submit', array('label' => 'c'));
$form->handleRequest($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$factory = $this->get('security.encoder_factory');
$encoder = $factory->getEncoder($entity);
$password = $encoder->encodePassword($entity->getPassword(), $entity->getSalt());
$entity->setPassword($password);
$entity->setAvatar($request->get('user_avatar'));
$em->persist($entity);
$em->flush();

Expand Down Expand Up @@ -108,7 +107,8 @@ public function newAction()
throw new AccessDeniedException("You are not authorized for this page!");
}
$entity = new User();
$form = $this->createCreateForm($entity);
$form = $this->createCreateForm($entity)
->add('create', 'submit', array('label' => 'c'));

return $this->render(
'OjsAdminBundle:AdminUser:new.html.twig',
Expand Down Expand Up @@ -192,7 +192,8 @@ public function editAction($id)
throw new AccessDeniedException("You are not authorized for this page!");
}

$editForm = $this->createEditForm($entity);
$editForm = $this->createEditForm($entity)
->add('save','submit');

return $this->render(
'OjsAdminBundle:AdminUser:edit.html.twig',
Expand Down Expand Up @@ -239,10 +240,10 @@ public function updateAction(Request $request, $id)
throw new AccessDeniedException("You are not authorized for this page!");
}
$oldPassword = $entity->getPassword();
$editForm = $this->createEditForm($entity);
$editForm = $this->createEditForm($entity)
->add('save','submit');
$editForm->handleRequest($request);
/** @var DocumentManager $dm */
$dm = $this->get('doctrine.odm.mongodb.document_manager');

if ($editForm->isValid()) {
$password = $entity->getPassword();
if (empty($password)) {
Expand All @@ -254,12 +255,6 @@ public function updateAction(Request $request, $id)
$entity->setPassword($password);
}

$avatar = $request->request->get('avatar');
$ir = $dm->getRepository('OjsSiteBundle:ImageOptions');
$imageOptions = $ir->init($avatar, $entity, 'avatar');
$dm->persist($imageOptions);
$dm->flush();

$em->flush();

$this->successFlashBag('successful.update');
Expand Down
11 changes: 9 additions & 2 deletions src/Ojs/AdminBundle/Form/Type/UserType.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,15 @@ public function buildForm(FormBuilderInterface $builder, array $options)
)
)
->add('tags', 'tags')
->add('avatar', 'hidden')
->add('header', 'hidden')
->add('avatar', 'jb_crop_image_ajax', array(
'endpoint' => 'user',
'img_width' => 200,
'img_height' => 200,
'crop_options' => array(
'aspect-ratio' => 200 / 200,
'maxSize' => "[200, 200]"
)
))
->addEventSubscriber(new AddProvinceFieldSubscriber())
->addEventSubscriber(new AddCountryFieldSubscriber('/location/cities/'));
}
Expand Down
Loading

0 comments on commit 850ce8e

Please sign in to comment.