Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 17241 | Rev 17244 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 17241 Rev 17242
Línea 248... Línea 248...
248
     */
248
     */
249
    private function handleHtmlRequest($currentCompany)
249
    private function handleHtmlRequest($currentCompany)
250
    {
250
    {
251
        $imageSize = $this->config['leaderslinked.image_sizes.microlearning_image_upload'];
251
        $imageSize = $this->config['leaderslinked.image_sizes.microlearning_image_upload'];
Línea 252... Línea 252...
252
        
252
        
253
        $formAdd = new CapsuleAddForm($currentCompany->internal);
253
        $formAdd = new CapsuleAddForm();
Línea 254... Línea 254...
254
        $formEdit = new CapsuleEditForm($currentCompany->internal);
254
        $formEdit = new CapsuleEditForm();
255
 
255
 
256
        $this->layout()->setTemplate('layout/layout-backend.phtml');
256
        $this->layout()->setTemplate('layout/layout-backend.phtml');
257
        $viewModel = new ViewModel();
257
        $viewModel = new ViewModel();
Línea 294... Línea 294...
294
            ];
294
            ];
Línea 295... Línea 295...
295
            
295
            
296
            return new JsonModel($data);
296
            return new JsonModel($data);
Línea 297... Línea 297...
297
        }
297
        }
298
 
298
 
Línea 299... Línea 299...
299
        $form = new  CapsuleAddForm($currentCompany->internal);
299
        $form = new  CapsuleAddForm();
Línea 300... Línea 300...
300
        $dataPost = array_merge($request->getPost()->toArray(), $request->getFiles()->toArray());
300
        $dataPost = array_merge($request->getPost()->toArray(), $request->getFiles()->toArray());
301
        
301
        
302
        $form->setData($dataPost);
302
        $form->setData($dataPost);
303
        
303
        
304
        if(!$form->isValid()) {  
304
        if(!$form->isValid()) {  
305
            $messages = [];
-
 
306
            $form_messages = (array) $form->getMessages();
305
            $messages = [];
307
            foreach($form_messages  as $fieldname => $field_messages)
306
            $form_messages = (array) $form->getMessages();
Línea 308... Línea 307...
308
            {
307
            foreach($form_messages  as $fieldname => $field_messages)
309
                
308
            { 
Línea 336... Línea 335...
336
        $capsule = $capsuleMapper->fetchOne($capsule->id);
335
        $capsule = $capsuleMapper->fetchOne($capsule->id);
337
        $storage = Storage::getInstance($this->config, $this->adapter);
336
        $storage = Storage::getInstance($this->config, $this->adapter);
Línea 338... Línea 337...
338
 
337
 
Línea 339... Línea 338...
339
        $storage->setFiles($request->getFiles()->toArray());
338
        $storage->setFiles($request->getFiles()->toArray());
340
        
339
        
341
        if (!$storage->setCurrentFilename('file')) {
340
        if (!$storage->setCurrentFilename('image')) {
342
            return new JsonModel([
341
            return new JsonModel([
343
                'success'   => false,
342
                'success'   => false,
344
                'data'      => 'ERROR_UPLOAD_IMAGE'
343
                'data'      => 'ERROR_UPLOAD_IMAGE'
Línea 361... Línea 360...
361
                'success'   => false,
360
                'success'   => false,
362
                'data'      => 'ERROR_UPLOAD_IMAGE'
361
                'data'      => 'ERROR_UPLOAD_IMAGE'
363
            ]);
362
            ]);
364
        }
363
        }
Línea 365... Línea -...
365
 
-
 
366
        /* if(!$storage->setCurrentFilename('marketplace')) {
-
 
367
            return new JsonModel([
-
 
368
                'success'   => false,
-
 
369
                'data'      => 'ERROR_UPLOAD_IMAGE'
-
 
370
            ]);
-
 
371
        }
-
 
372
 
-
 
373
        $target_size = $this->config['leaderslinked.image_sizes.marketplace'];
-
 
374
        list($target_width, $target_height) = explode('x', $target_size);
-
 
375
 
-
 
376
        $marketplace_source_filename = $storage->getTmpFilename();
-
 
377
        $marketplace_filename = 'marketplace-' . uniqid() . '.jpg';
-
 
378
        $marketplace_target_filename = $storage->composePathToFilename(
-
 
379
            Storage::TYPE_MICROLEARNING_CAPSULE,
-
 
380
            $capsule->uuid,
-
 
381
            $marketplace_filename
-
 
382
        );
-
 
383
 
-
 
384
        if (!$storage->uploadImageCrop($marketplace_source_filename, $marketplace_target_filename, $target_width, $target_height)) {
-
 
385
            return new JsonModel([
-
 
386
                'success'   => false,
-
 
387
                'data'      => 'ERROR_UPLOAD_IMAGE'
-
 
388
            ]);
-
 
389
        }
-
 
390
 
-
 
391
        $capsule->marketplace = $marketplace_filename; */
364
 
Línea 392... Línea 365...
392
        $capsule->image = $filename;
365
        $capsule->image = $filename;
393
 
366
 
394
        if(!$capsuleMapper->update($capsule)) {
367
        if(!$capsuleMapper->update($capsule)) {
Línea 446... Línea 419...
446
                $storage = Storage::getInstance($this->config, $this->adapter);
419
                $storage = Storage::getInstance($this->config, $this->adapter);
447
                $target_path = $storage->getPathMicrolearningCapsule();
420
                $target_path = $storage->getPathMicrolearningCapsule();
Línea 448... Línea 421...
448
                
421
                
Línea 449... Línea 422...
449
                $storage->deleteFile($target_path, $capsule->uuid, $capsule->image);
422
                $storage->deleteFile($target_path, $capsule->uuid, $capsule->image);
Línea 450... Línea -...
450
                
-
 
451
                if($capsule->marketplace) {
-
 
452
                
-
 
453
                    $storage->deleteFile($target_path, $topic->uuid, $capsule->marketplace);
423
                
454
                }
424
                $storage->deleteFile($target_path, $capsule->uuid, $capsule->image);
455
 
425
                
456
                $data = [
426
                $data = [
457
                    'success' => true,
427
                    'success' => true,
Línea 519... Línea 489...
519
            ];
489
            ];
Línea 520... Línea 490...
520
            
490
            
521
            return new JsonModel($data);
491
            return new JsonModel($data);
522
        } 
492
        } 
523
        else if($request->isPost()) {
493
        else if($request->isPost()) {
524
            $form = new  CapsuleEditForm($currentCompany->internal);
494
            $form = new  CapsuleEditForm();
Línea 525... Línea 495...
525
            $dataPost = array_merge($request->getPost()->toArray(), $request->getFiles()->toArray());
495
            $dataPost = array_merge($request->getPost()->toArray(), $request->getFiles()->toArray());
Línea 526... Línea 496...
526
            
496
            
527
            $form->setData($dataPost);
497
            $form->setData($dataPost);
Línea 528... Línea 498...
528
            
498
            
529
            if($form->isValid()) {
499
            if($form->isValid()) {
530
                $dataPost = (array) $form->getData();
-
 
531
                
-
 
532
                $capsule->name = $dataPost['name'];
-
 
533
                $capsule->description = $dataPost['description'];
-
 
534
                $capsule->image = '';
-
 
535
                
-
 
536
                if(!$capsuleMapper->update($capsule)) {
-
 
537
                    return new JsonModel([
-
 
Línea 538... Línea -...
538
                        'success'   => false,
-
 
539
                        'data'      => $capsuleMapper->getError()
500
                $dataPost = (array) $form->getData();
540
                    ]);
501
                
Línea 541... Línea 502...
541
                }
502
                $capsule->name = $dataPost['name'];
Línea 542... Línea 503...
542
                
503
                $capsule->description = $dataPost['description'];
543
                $capsule = $capsuleMapper->fetchOne($capsule->id);
504
                
544
                $storage = Storage::getInstance($this->config, $this->adapter);
505
                $storage = Storage::getInstance($this->config, $this->adapter);
545
                $target_path = $storage->getPathMicrolearningCapsule();
506
                $target_path = $storage->getPathMicrolearningCapsule();
546
 
507
 
547
                $storage->setFiles($request->getFiles()->toArray());
508
                $storage->setFiles($request->getFiles()->toArray());
Línea 569... Línea 530...
569
                        'success'   => false,
530
                        'success'   => false,
570
                        'data'      => 'ERROR_UPLOAD_IMAGE'
531
                        'data'      => 'ERROR_UPLOAD_IMAGE'
571
                    ]);
532
                    ]);
572
                }
533
                }
Línea 573... Línea 534...
573
 
534
 
574
                if($capsule->image) {
535
                if($capsule->image) {   
575
                    $storage->deleteFile($target_path, $capsule->uuid, $capsule->image);
536
                    $storage->deleteFile($target_path, $capsule->uuid, $capsule->image);
Línea 576... Línea 537...
576
                }
537
                }