芝麻web文件管理V1.00
编辑当前文件:/home/pulsehostuk9/www/cloud.pulsehost.co.uk/modules/MailSaveMessageAsPdfPlugin/Module.php
aErrors = [ Enums\ErrorCodes::LibraryNoFound => $this->i18N('ERROR_NO_PDF_GENERATOR_FOUND'), ]; } /** * @return Module */ public static function getInstance() { return parent::getInstance(); } /** * @return Module */ public static function Decorator() { return parent::Decorator(); } /** * @return Settings */ public function getModuleSettings() { return $this->oModuleSettings; } /** * @param int $UserId * @param string $FileName * @param string $Html * @return boolean */ public function GeneratePdfFile($UserId, $FileName, $Html) { \Aurora\System\Api::checkUserRoleIsAtLeast(\Aurora\System\Enums\UserRole::NormalUser); $sFileName = $FileName . '.pdf'; $sUUID = \Aurora\System\Api::getUserUUIDById($UserId); $sTempName = md5($sUUID . $sFileName . microtime(true)); $sExec = \Aurora\System\Api::DataPath() . '/system/wkhtmltopdf/linux/wkhtmltopdf'; if (!\file_exists($sExec)) { $sExec = \Aurora\System\Api::DataPath() . '/system/wkhtmltopdf/win/wkhtmltopdf.exe'; if (!\file_exists($sExec)) { $sExec = ''; } } if (0 < \strlen($sExec)) { $oSnappy = new \Knp\Snappy\Pdf($sExec); $oSnappy->setOption('quiet', true); $oSnappy->setOption('disable-javascript', true); $oSnappy->setOption('encoding', 'utf-8'); $oApiFileCache = new \Aurora\System\Managers\Filecache(); $oSnappy->generateFromHtml( $Html, $oApiFileCache->generateFullFilePath($sUUID, $sTempName, '', self::GetName()), array(), true ); return \Aurora\System\Utils::GetClientFileResponse( self::GetName(), $UserId, $sFileName, $sTempName, $oApiFileCache->fileSize($sUUID, $sTempName, '', self::GetName()) ); } else { throw new \Aurora\System\Exceptions\ApiException(Enums\ErrorCodes::LibraryNoFound); } return false; } }