Changeset 918


Ignore:
Timestamp:
May 11, 2015 11:28:53 AM (10 years ago)
Author:
quyenla
Message:

thumbnail for docs

Location:
pro-violet-viettel/www/deploy/api/platform
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • pro-violet-viettel/www/deploy/api/platform/lib/violetUtil.class.php

    r916 r918  
    4040
    4141   public function createThumb($pathToImage="") {
    42 
    4342        if (is_file($pathToImage)) {
    4443            $info = pathinfo($pathToImage);
  • pro-violet-viettel/www/deploy/api/platform/modules/space/actions/actions.class.php

    r916 r918  
    181181
    182182    private function createPreview($fileurl, $userId, $fileid) {
     183        $thumbnail="";
    183184        $url = "https://docs.google.com/gview?url=" . urlencode($fileurl) . "";
    184185        file_put_contents("1.html", $url);
     
    215216                    }
    216217                    file_put_contents("previews/" . $userId . "/" . $fileid . "/" . $i . ".png", $image);
     218                    if ($count==1)
     219                    {
     220                    $file_path= str_replace("http://" . $_SERVER['SERVER_NAME'], $_SERVER['DOCUMENT_ROOT'], $fileurl);
     221                    $file_path= str_replace(pathinfo($file_path, PATHINFO_EXTENSION), "png", $file_path);
     222                    file_put_contents($file_path, $image);   
     223                    $thumbnail=violetUtil::createThumb($file_path);
     224                    }
    217225                } else {
    218226                    break;
     
    220228            }
    221229        }
    222         return $count;
     230        return $thumbnail;
    223231    }
    224232
     
    464472        $ext = pathinfo($fileUrl, PATHINFO_EXTENSION);
    465473        $ext = strtolower($ext);
    466 
     474        $thumbnail="";
    467475        if (in_array($ext, array("ppt", "xls", "doc", "pdf", "docx", "pptx", "xlsx"))) {
    468             $this->createPreview($fileUrl, $userId, $tblfile->getFileId());
     476            $thumbnail=$this->createPreview($fileUrl, $userId, $tblfile->getFileId());
    469477        }
    470478
     
    472480            $aryError = array('err' => "", 'errCode' => 0);
    473481            $ext = pathinfo($fileUrl, PATHINFO_EXTENSION);
    474             $thumbnail = "";
     482            if ($thumbnail=="")
     483            {
    475484            if (in_array(strtolower($ext), array("jpg", "jpeg", "png", "gif"/* , "tiff", "dvg", "bmp" */))) {
    476485                $thumbnail=violetUtil::createThumb($filePath);
    477486            }
    478             if (file_exists("previews/$userId/" . $tblfile->getFileId() . "/0.png")) {
    479                 $thumbnail = "previews/$userId/" . $tblfile->getFileId() . "/0.png";
    480             }
     487            }
     488           
    481489            $aryFiles = array(
    482490                0 => array('id' => $tblfile->getFileId(), 'thumbnail' => $thumbnail, 'fileurl' => $fileUrl, 'name' => $fileName, 'minetype' => $ext, 'size' => $fileSize, 'parentID' => $catId),
  • pro-violet-viettel/www/deploy/api/platform/modules/space/templates/dirSuccess.php

    r916 r918  
    3232      $filePath="";
    3333      $thumbnail="";
    34       if (in_array($ext, array("jpg","png","jpeg","gif")))
     34      if (in_array($ext, array("jpg","png","jpeg","gif","")))
    3535      {
    3636          $names = explode(".", $name);
     
    3838          $filePath = str_replace($_SERVER['DOCUMENT_ROOT'], '', $filePath);
    3939          $thumbnail = str_replace($name, "", $fileName). $names[0].'_thumb.'.$ext;
     40          $thumbnail=   ltrim ($thumbnail, '/');
    4041      }
    4142      else
    4243      {
    43         if (file_exists("previews/$userId/".$tblfile->getFileId()."/0.png"))
    44         {
    45             $thumbnail="previews/$userId/".$tblfile->getFileId()."/0.png";
    46         }
     44          $names = explode(".", $name);
     45          $filePath = $tblres->getFullFilename();
     46          $filePath = str_replace($_SERVER['DOCUMENT_ROOT'], '', $filePath);
     47          $thumbnail = str_replace($name, "", $fileName). $names[0].'_thumb.png';
     48          $thumbnail=   ltrim ($thumbnail, '/');
     49          if (!file_exists($thumbnail))
     50          {
     51              $thumbnail="";
     52          }
     53         
    4754      }
    4855
Note: See TracChangeset for help on using the changeset viewer.