Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 17002 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 17002 Rev 17018
Línea 163... Línea 163...
163
                if(!in_array($order_direction, ['ASC', 'DESC'])) {
163
                if(!in_array($order_direction, ['ASC', 'DESC'])) {
164
                    $order_direction = 'ASC';
164
                    $order_direction = 'ASC';
165
                }
165
                }
Línea 166... Línea 166...
166
                
166
                
167
     
167
     
Línea 168... Línea 168...
168
                $storage = Storage::getInstance($this->config);
168
                $storage = Storage::getInstance($this->config, $this->adapter);
169
                $target_path = $storage->getPathMedia();
169
                $target_path = $storage->getPathMedia();
Línea 335... Línea 335...
335
                $media_tmp_filename = '';
335
                $media_tmp_filename = '';
336
                $media_filename = '';
336
                $media_filename = '';
Línea 337... Línea 337...
337
                
337
                
338
                if (isset($files['file']) && empty($files['file']['error'])) {
338
                if (isset($files['file']) && empty($files['file']['error'])) {
339
                    $media_tmp_filename  = $files['file']['tmp_name'];
339
                    $media_tmp_filename  = $files['file']['tmp_name'];
Línea 340... Línea 340...
340
                    $media_filename      = $this->normalizeString($files['file']['name']);
340
                    $media_filename      = \LeadersLinked\Library\Functions::normalizeStringFilename($files['file']['name']);
Línea 341... Línea 341...
341
                    
341
                    
Línea 366... Línea 366...
366
                
366
                
367
                $fileMapper = MediaFileMapper::getInstance($this->adapter);
367
                $fileMapper = MediaFileMapper::getInstance($this->adapter);
368
                if($fileMapper->insert($mediaFile)) {
368
                if($fileMapper->insert($mediaFile)) {
Línea 369... Línea 369...
369
                    $mediaFile = $fileMapper->fetchOne($mediaFile->id);
369
                    $mediaFile = $fileMapper->fetchOne($mediaFile->id);
370
                    
370
                    
371
                    $storage = Storage::getInstance($this->config);
371
                    $storage = Storage::getInstance($this->config, $this->adapter);
372
                    $target_path = $storage->getPathMedia();
372
                    $target_path = $storage->getPathMedia();
373
                    $interal_path = 'data' . DIRECTORY_SEPARATOR . 'storage' . DIRECTORY_SEPARATOR . 'tmp';
373
                    $interal_path = 'data' . DIRECTORY_SEPARATOR . 'storage' . DIRECTORY_SEPARATOR . 'tmp';
374
                    if(!file_exists($interal_path)) {
374
                    if(!file_exists($interal_path)) {
Línea 383... Línea 383...
383
                            
383
                            
384
                            $fileMapper->update($mediaFile);
384
                            $fileMapper->update($mediaFile);
Línea 385... Línea 385...
385
                        }
385
                        }
386
                        
-
 
-
 
386
                        
Línea 387... Línea 387...
387
                    } else if ($media_type == MediaFile::TYPE_IMAGE) {
387
                    } else if ($media_type == MediaFile::TYPE_IMAGE) {
388
                        $image = Image::getInstance($this->config);
-
 
Línea -... Línea 388...
-
 
388
                       
389
 
389
 
390
                        $generate_media_filename = substr($media_filename, 0, strrpos($media_filename, '.')).  '.png';
390
                        $filename = substr($media_filename, 0, strrpos($media_filename, '.')).  '.png';
-
 
391
                        
-
 
392
                        $image = Image::getInstance($this->config);
391
                        $unlink_source = true;
393
                        $full_tmp_filename = $image->uploadProcessWithOutChangeSize($media_tmp_filename, $filename);
392
                        
394
                        
393
                        if($image->uploadImageRaw($media_tmp_filename, $target_path, $mediaFile->uuid, $generate_media_filename, $unlink_source)) {    
395
                        if($full_tmp_filename) {
394
                            
396
                            if($storage->putFile($target_path, $mediaFile->uuid,  $full_tmp_filename)) {
395
                            $mediaFile->type    = $media_type;
397
                                $mediaFile->type    = $media_type;
-
 
398
                                $mediaFile->file    = $media_filename;
396
                            $mediaFile->file    = $media_filename;
399
                                
-
 
400
                                
-
 
401
                                $fileMapper->update($mediaFile);
397
                            
402
                            }
398
        
403
                        }
399
                            $fileMapper->update($mediaFile);
404
                        
400
                        }
405
                   
401
                    } else if ($media_type == MediaFile::TYPE_VIDEO) {
406
                    } else if ($media_type == MediaFile::TYPE_VIDEO) {
Línea 563... Línea 568...
563
            
568
            
564
            $result = $fileMapper->delete($file);
569
            $result = $fileMapper->delete($file);
565
            if($result) {
570
            if($result) {
Línea 566... Línea 571...
566
                $this->logger->info('Se borro el el archivo de la media query : ' .  $file->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
571
                $this->logger->info('Se borro el el archivo de la media query : ' .  $file->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
567
                
572
                
Línea 568... Línea 573...
568
                $storage = Storage::getInstance($this->config);
573
                $storage = Storage::getInstance($this->config, $this->adapter);
Línea 601... Línea 606...
601
        }
606
        }
Línea 602... Línea 607...
602
        
607
        
603
        return new JsonModel($data);
608
        return new JsonModel($data);
Línea 604... Línea -...
604
    }
-
 
605
    
-
 
606
    /**
-
 
607
     *
-
 
608
     * @param string $str
-
 
609
     * @return string
-
 
610
     */
-
 
611
    private function normalizeString($str = '')
-
 
612
    {
-
 
613
        $basename  = substr($str, 0, strrpos($str, '.'));
-
 
614
        $basename  = str_replace('.', '-', $basename);
-
 
615
        
609
    }
616
        $extension  = substr($str, strrpos($str, '.'));
-
 
617
        
-
 
618
        $str = $basename . $extension;
-
 
619
        
-
 
620
        $str = strip_tags($str);
-
 
621
        $str = preg_replace('/[\r\n\t ]+/', ' ', $str);
-
 
622
        $str = preg_replace('/[\"\*\/\:\<\>\?\'\|\,]+/', ' ', $str);
-
 
623
        $str = strtolower($str);
-
 
624
        $str = html_entity_decode($str, ENT_QUOTES, "utf-8");
-
 
625
        $str = htmlentities($str, ENT_QUOTES, "utf-8");
-
 
626
        $str = preg_replace("/(&)([a-z])([a-z]+;)/i", '$2', $str);
-
 
627
        $str = str_replace(' ', '-', $str);
-
 
628
        $str = rawurlencode($str);
-
 
629
        $str = str_replace('%', '-', $str);
-
 
630
        
-
 
631
        
-
 
Línea 632... Línea 610...
632
        return trim(strtolower($str));
610