Prechádzať zdrojové kódy

Merge branch 'master' of https://github.com/unaio/una

AntonLV 7 rokov pred
rodič
commit
51fe186806

+ 69 - 57
inc/classes/BxDolTranscoder.php

@@ -406,80 +406,92 @@ class BxDolTranscoder extends BxDolFactory implements iBxDolFactoryObject
     public function transcode ($mixedHandler, $iProfileId = 0)
     {
         $sExtChange = false;
+        $bRet = true;
 
         $this->_oDb->updateQueueStatus($mixedHandler, BX_DOL_QUEUE_PROCESSING, '', gethostname());
 
-        // create tmp file locally
-        $sSuffix = $this->_sQueueStorage ? 'Queue' : $this->_aObject['source_type'];
-        $sMethodStoreFile = 'storeFileLocally_' . $sSuffix;
-        $sTmpFile = $this->$sMethodStoreFile($mixedHandler);
-        if (!$sTmpFile) {
-            $this->_oDb->updateQueueStatus($mixedHandler, BX_DOL_QUEUE_FAILED, "store local tmp file failed ($sMethodStoreFile)");
-            return false;
-        }
+        do {
 
-        // appply filters to tmp file
-        $this->initFilters ();
-        foreach ($this->_aObject['filters'] as $aParams) {
-            $this->clearLog();
-            $sMethodFilter = 'applyFilter_' . $aParams['filter'];
-            if (!method_exists($this, $sMethodFilter))
-                continue;
-            if (!$this->$sMethodFilter($sTmpFile, $aParams['filter_params'])) {
-                unlink($sTmpFile);
-                $this->_oDb->updateQueueStatus($mixedHandler, BX_DOL_QUEUE_FAILED, "filter failed: $sMethodFilter\n" . $this->getLog());
-                return false;
+            // create tmp file locally
+            $sSuffix = $this->_sQueueStorage ? 'Queue' : $this->_aObject['source_type'];
+            $sMethodStoreFile = 'storeFileLocally_' . $sSuffix;
+            $sTmpFile = $this->$sMethodStoreFile($mixedHandler);
+            if (!$sTmpFile) {
+                $this->_oDb->updateQueueStatus($mixedHandler, BX_DOL_QUEUE_FAILED, "store local tmp file failed ($sMethodStoreFile)");
+                $bRet = false;
+                break;
             }
 
-            if (!empty($aParams['filter_params']['force_type'])) {
-                switch ($aParams['filter_params']['force_type']) {
-                    case 'jpeg':
-                    case 'jpg':
-                        $sExtChange = 'jpg';
-                        break;
-                    default:
-                        $sExtChange = $aParams['filter_params']['force_type'];
+            // appply filters to tmp file
+            $this->initFilters ();
+            foreach ($this->_aObject['filters'] as $aParams) {
+                $this->clearLog();
+                $sMethodFilter = 'applyFilter_' . $aParams['filter'];
+                if (!method_exists($this, $sMethodFilter))
+                    continue;
+                if (!$this->$sMethodFilter($sTmpFile, $aParams['filter_params'])) {
+                    unlink($sTmpFile);
+                    $this->_oDb->updateQueueStatus($mixedHandler, BX_DOL_QUEUE_FAILED, "filter failed: $sMethodFilter\n" . $this->getLog());
+                    $bRet = false;
+                    break 2;
                 }
-            }
 
-            if ($sExtChange) {
-                $iDotPos = strrpos($sTmpFile, '.');
-                $sExtOld = false === $iDotPos ? '' : substr($sTmpFile, $iDotPos+1);
-                if ($sExtOld != $sExtChange) {
-                    $sTmpFileOld = $sTmpFile;
-                    $sTmpFile = false === $iDotPos ? $sTmpFile . '.' . $sExtChange : substr_replace($sTmpFile, $sExtChange, $iDotPos+1, strlen($sExtOld));
-                    if (!rename($sTmpFileOld, $sTmpFile)) {
-                        @unlink($sTmpFileOld);
-                        $this->_oDb->updateQueueStatus($mixedHandler, BX_DOL_QUEUE_FAILED, "change file extension failed: $sTmpFileOld => $sTmpFile");
-                        return false;
+                if (!empty($aParams['filter_params']['force_type'])) {
+                    switch ($aParams['filter_params']['force_type']) {
+                        case 'jpeg':
+                        case 'jpg':
+                            $sExtChange = 'jpg';
+                            break;
+                        default:
+                            $sExtChange = $aParams['filter_params']['force_type'];
+                    }
+                }
+
+                if ($sExtChange) {
+                    $iDotPos = strrpos($sTmpFile, '.');
+                    $sExtOld = false === $iDotPos ? '' : substr($sTmpFile, $iDotPos+1);
+                    if ($sExtOld != $sExtChange) {
+                        $sTmpFileOld = $sTmpFile;
+                        $sTmpFile = false === $iDotPos ? $sTmpFile . '.' . $sExtChange : substr_replace($sTmpFile, $sExtChange, $iDotPos+1, strlen($sExtOld));
+                        if (!rename($sTmpFileOld, $sTmpFile)) {
+                            @unlink($sTmpFileOld);
+                            $this->_oDb->updateQueueStatus($mixedHandler, BX_DOL_QUEUE_FAILED, "change file extension failed: $sTmpFileOld => $sTmpFile");
+                            $bRet = false;
+                            break 2;
+                        }
                     }
                 }
             }
-        }
 
-        $mixedHandler = $this->processHandlerForRetinaDevice($mixedHandler);
-        
-        $bRet = true;
-        if ($this->_sQueueStorage) {
+            $mixedHandler = $this->processHandlerForRetinaDevice($mixedHandler);
+                    
+            if ($this->_sQueueStorage) {
 
-            $sFileUrlResult = '';
-            if (!($iFileIdResult = $this->storeTranscodedFileInQueueStorage($mixedHandler, $sTmpFile, $sFileUrlResult)))
-                $this->_oDb->updateQueueStatus($mixedHandler, BX_DOL_QUEUE_FAILED, "store queue tmp file failed:\n" . $this->getLog());
-            else
-                $this->_oDb->updateQueueStatus($mixedHandler, BX_DOL_QUEUE_COMPLETE, '', '', $iFileIdResult, $sFileUrlResult, $sExtChange);
+                $sFileUrlResult = '';
+                if (!($iFileIdResult = $this->storeTranscodedFileInQueueStorage($mixedHandler, $sTmpFile, $sFileUrlResult)))
+                    $this->_oDb->updateQueueStatus($mixedHandler, BX_DOL_QUEUE_FAILED, "store queue tmp file failed:\n" . $this->getLog());
+                else
+                    $this->_oDb->updateQueueStatus($mixedHandler, BX_DOL_QUEUE_COMPLETE, '', '', $iFileIdResult, $sFileUrlResult, $sExtChange);
 
-        } else {
+            } else {
 
-            $bRet = $this->storeTranscodedFile($mixedHandler, $sTmpFile, $iProfileId);
-            
-            if ($bRet)
-                $this->deleteFromQueue($mixedHandler);
-            else
-                $this->_oDb->updateQueueStatus($mixedHandler, BX_DOL_QUEUE_FAILED, "store file failed:\n" . $this->getLog());
+                $bRet = $this->storeTranscodedFile($mixedHandler, $sTmpFile, $iProfileId);
                 
-        }
+                if ($bRet)
+                    $this->deleteFromQueue($mixedHandler);
+                else
+                    $this->_oDb->updateQueueStatus($mixedHandler, BX_DOL_QUEUE_FAILED, "store file failed:\n" . $this->getLog());
+                    
+            }
+
+            @unlink($sTmpFile);
+
+        } while (false);
 
-        @unlink($sTmpFile);
+        bx_alert($this->_aObject['object'], 'transcoded', $mixedHandler, false, array(
+            'object' => $this,
+            'ret' => $bRet,
+        ));
 
         return $bRet;
     }

+ 2 - 2
modules/base/profile/template/uploader_form_crop_cover.html

@@ -30,12 +30,12 @@ setTimeout(function () {
         },
         viewport: {
             width: 240,
-            height: 90,
+            height: 120,
             // type: 'circle'
         },
         boundary: {
             width: 280,
-            height: 130
+            height: 160
         },
         enableOrientation: true
     });