<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Res\Converter; use Illuminate\Support\Facades\Log; use ModStart\Core\Exception\BizException; use ModStart\Core\Input\Response; use ModStart\Data\DataManager; abstract class AbstractResConverter { public abstract function name(); public abstract function title(); public function init() { } public function enabled() { return true; } public function orderConfigName() { return 'Res_ConverterOrder_' . $this->name(); } public function fileTypesConfigName() { return 'Res_ConverterTypes_' . $this->name(); } public function fileExtsConfigName() { return 'Res_ConverterExts_' . $this->name(); } public function order() { return modstart_config($this->orderConfigName(), 100); } public function fileTypesEnabled() { goto OynDa; gPYAD: $NhLmu = modstart_config()->getArray($this->fileTypesConfigName(), array()); goto UXHtw; OynDa: $Ub4by = $this->fileTypes(); goto gPYAD; UXHtw: return array_values(array_intersect($Ub4by, $NhLmu)); goto Pma27; Pma27: } public function fileExtsEnabled() { goto PcItx; Jqpn_: return array_values(array_intersect($B5PEf, $NhLmu)); goto TMtHC; PcItx: $B5PEf = $this->fileExts(); goto ehZFX; ehZFX: $NhLmu = modstart_config()->getArray($this->fileExtsConfigName(), array()); goto Jqpn_; TMtHC: } protected function convertIgnoreResponse($nXCfA = null) { if ($nXCfA) { Log::info('Res.ConvertIgnore - ' . $nXCfA); } return Response::generateSuccessData(array('previewType' => null)); } public abstract function fileTypes(); public abstract function fileExts(); public function convert($zk4Tz, $qOrzw = array()) { BizException::throws('You should implements convert'); } public function preview($zk4Tz, $qOrzw = array()) { return Response::generateSuccessData(array()); } protected function uploadLocalFiles($ls0xp, $rChGZ = true) { goto GWDUD; LrZ5X: foreach ($ls0xp as $dG73t) { goto ibxUU; KxaB0: if (Response::isError($Tbn6c)) { BizException::throws($Tbn6c['msg']); } goto mgngn; ibxUU: $Tbn6c = DataManager::upload('file', basename($dG73t), file_get_contents($dG73t)); goto KxaB0; nBReR: if ($rChGZ) { @unlink($dG73t); } goto RKiuy; mgngn: $fHGBD[] = DataManager::fix($Tbn6c['data']['fullPath']); goto nBReR; RKiuy: } goto zOP8w; GWDUD: $fHGBD = array(); goto LrZ5X; zOP8w: return $fHGBD; goto vqxOr; vqxOr: } protected function uploadLocalFileData($L1N0l, $n16LT) { goto bq_fM; E4BAn: return DataManager::fix($Tbn6c['data']['fullPath']); goto NvI2H; bq_fM: $Tbn6c = DataManager::upload('file', $L1N0l, $n16LT); goto GB6r4; GB6r4: if (Response::isError($Tbn6c)) { BizException::throws($Tbn6c['msg']); } goto E4BAn; NvI2H: } }