Changeset 826


Ignore:
Timestamp:
Mar 25, 2015 5:22:41 PM (10 years ago)
Author:
dungnv
Message:
 
Location:
pro-violet-viettel/www/deploy/api/platform/modules/space
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • pro-violet-viettel/www/deploy/api/platform/modules/space/actions/actions.class.php

    r815 r826  
    140140    }
    141141
    142     private function changeParentDir($item, $destination) {
     142    private function ChangeParentDir($item, $destination) {
    143143        if ($item->type == 'directory') {
    144144            $tblfile = TblspacefilePeer::retrieveByPk($item->id);
     
    154154        return $item;
    155155    }
     156
     157    private function CreatePreview($fileurl, $userId, $fileid) {
     158        $url = "https://docs.google.com/gview?url=" .urlencode($fileurl) . "";
     159        file_put_contents("1.html", $url);
     160        $content="";
     161        $ch = curl_init();
     162        curl_setopt($ch, CURLOPT_URL, $url);
     163        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
     164        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     165        $content = curl_exec($ch);
     166        file_put_contents("1.html", $content);
     167        preg_match("'img\?id\\\u003d(.*?)%3D'si", $content, $matches);
     168        $count=0;
     169        if (isset($matches[1]))
     170        {
     171                $id = $matches[1];
     172                $count=0;
     173                for ($i = 0; $i <= 20; $i++) {
     174                        $imgurl = "https://docs.google.com/viewerng/img?id=" . $id . "&w=600&page=" . $i;
     175                        $ch = curl_init();
     176                        curl_setopt($ch, CURLOPT_URL, $imgurl);
     177                        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
     178                        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     179                        $image = curl_exec($ch);
     180                        $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     181                        if ($code == 200)
     182                        {
     183   
     184                                $count++;
     185                                if (!file_exists('previews/'. $userId."/")) {
     186                                        mkdir('previews/'. $userId."/", 0777, true);
     187                                }
     188   
     189                                if (!file_exists('previews/'. $userId."/".$fileid."/")) {
     190   
     191                                        mkdir('previews/'. $userId."/".$fileid."/", 0777, true);
     192   
     193                                }
     194                                file_put_contents("previews/" . $userId . "/" . $fileid . "/" . $i . ".png", $image);
     195   
     196                        } else {
     197                                break;
     198                        }
     199                }
     200   
     201        }
     202        return $count;
     203    }   
     204   
    156205    public function executePreview(){
    157206        $fileId = $this->getRequestParameter('fileId');
     
    170219            $fileName = $tblres->getFullFilename();
    171220            $fileUrl = str_replace("/srv/www/violet/web", "http://sbgapi.violet.vn", $fileName);
    172             $count=$this->createPreview($fileUrl, $userId, $fileId);
     221            $count=$this->CreatePreview($fileUrl, $userId, $fileId);
    173222        }
    174223        $data['fileid']=$fileId;
     
    346395                    }
    347396                } else if ($act == 'move') {
    348                     $this->changeParentDir($treeObj, $destination);
     397                    $this->ChangeParentDir($treeObj, $destination);
    349398                    if ($treeObj->type == 'directory')
    350399                        $aryNewTree['DIRECTORIES'][] = $treeObj;
     
    402451        if (in_array($ext, array("ppt","xls","doc","pdf","docx","pptx","xlsx")))
    403452        {
    404             $this->createPreview($fileUrl, $userId, $tblfile->getFileId());
     453            $this->CreatePreview($fileUrl, $userId, $tblfile->getFileId());
    405454        }
    406455        if ($response == 1) {
     
    420469
    421470        return sfView::NONE;
    422     }
    423 
    424     private function createPreview($fileurl, $userId, $fileid) {
    425 
    426        
    427         $url = "https://docs.google.com/gview?url=" .urlencode($fileurl) . "";
    428         file_put_contents("1.html", $url);
    429         $content="";
    430         $ch = curl_init();
    431         curl_setopt($ch, CURLOPT_URL, $url);
    432         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
    433         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    434         $content = curl_exec($ch);
    435        file_put_contents("1.html", $content);
    436         preg_match("'img\?id\\\u003d(.*?)%3D'si", $content, $matches);
    437         $count=0;
    438         if (isset($matches[1]))
    439         {
    440         $id = $matches[1];
    441         $count=0;
    442         for ($i = 0; $i <= 20; $i++) {
    443             $imgurl = "https://docs.google.com/viewerng/img?id=" . $id . "&w=600&page=" . $i;
    444             $ch = curl_init();
    445             curl_setopt($ch, CURLOPT_URL, $imgurl);
    446             curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
    447             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    448             $image = curl_exec($ch);
    449             $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    450             if ($code == 200)
    451             {
    452                
    453                 $count++;
    454                 if (!file_exists('previews/'. $userId."/")) {
    455                     mkdir('previews/'. $userId."/", 0777, true);
    456                 }
    457                
    458                 if (!file_exists('previews/'. $userId."/".$fileid."/")) {
    459                    
    460                     mkdir('previews/'. $userId."/".$fileid."/", 0777, true);
    461                    
    462                 }
    463                 file_put_contents("previews/" . $userId . "/" . $fileid . "/" . $i . ".png", $image);
    464 
    465             } else {
    466                 break;
    467             }
    468         }
    469        
    470         }
    471         return $count;
    472471    }
    473472
  • pro-violet-viettel/www/deploy/api/platform/modules/space/templates/copySuccess.php

    r784 r826  
    1 <data err="<?php echo $errMsg; ?>" errCode="<?php echo $errCode; ?>">
    2         <folderdata><?php echo json_encode($aryNewTree['DIRECTORIES'])?></folderdata>
    3         <filedata><?php echo json_encode($aryNewTree['FILES'])?></filedata>
    4 </data>
     1<tree err="<?php echo $errMsg; ?>" errCode="<?php echo $errCode; ?>">
     2<?php foreach ($aryDeletedObj as $obj): ?>
     3<?php   if ($obj->type == 'directory'):?>
     4                <folder id="<?php echo $obj->id;?>" parentid="<?php echo $obj->parentID;?>" name="<?php echo $obj->name;?>">
     5<?php           if (is_array($obj->childDirs)):?>
     6<?php                   foreach ($obj->childDirs as $childobj):?>
     7                                        <childdir id="<?php echo $childobj->id;?>" parentid="<?php echo $childobj->parentID;?>"><?php echo $childobj->name;?></childdir>
     8<?php                   endforeach;?>
     9<?php           endif;?>
     10<?php           if (is_array($obj->childFiles)):?>
     11<?php                   foreach ($obj->childFiles as $childobj):?>
     12                                        <childfile id="<?php echo $childobj->id;?>" parentid="<?php echo $childobj->parentID;?>"><?php echo $childobj->name;?></childfile>
     13<?php                   endforeach;?>
     14<?php           endif;?>
     15                </folder>
     16<?php   else:?>
     17                <file id="<?php echo $obj->id;?>" parentid="<?php echo $obj->parentID;?>" name="<?php echo $obj->name;?>"></file>
     18<?php   endif;?>
     19<?php endforeach; ?>
     20</tree>
  • pro-violet-viettel/www/deploy/api/platform/modules/space/templates/dirSuccess.php

    r815 r826  
    2424      $fileName = $tblres->getFullFilename();
    2525      $fileName = str_replace('/srv/www/violet/web', '', $fileName);
    26       $fileName = 'http://sbgapi.violet.vn'.$fileName;
     26      $fileName = 'http://sbgapi.violet.vn'.$fileName;     
    2727      $fileNames = explode("/", $fileName);
    2828      $name=$fileNames[(count($fileNames)-1)];
     
    3333          $thumbnail="http://sbgapi.violet.vn/previews/$userId/".$tblfile->getFileId()."/0.png";
    3434      }
     35      $fileSize = $tblres->getResFilesize();
    3536      ?>
    36     <file thumbnail="<?php echo $thumbnail;?>" fileurl="<?php echo $fileName;?>" id="<?php echo $tblfile->getFileId() ?>" parentid="<?php echo $tblfile->getFileCategory() ?>" filetype="<?php echo $tblfile->getFileType() ?>"><?php echo $tblfile->getFileName() ?></file>
     37    <file thumbnail="<?php echo $thumbnail;?>" fileurl="<?php echo $fileName;?>" id="<?php echo $tblfile->getFileId() ?>" parentid="<?php echo $tblfile->getFileCategory() ?>" filetype="<?php echo $tblfile->getFileType() ?>" size="<?php echo $fileSize;?>"><?php echo $tblfile->getFileName() ?></file>
    3738  <?php endforeach; ?>
    3839  </filelist>
Note: See TracChangeset for help on using the changeset viewer.