当前位置: 首页>>代码示例>>PHP>>正文


PHP Themes::previewConversionResults方法代码示例

本文整理汇总了PHP中Themes::previewConversionResults方法的典型用法代码示例。如果您正苦于以下问题:PHP Themes::previewConversionResults方法的具体用法?PHP Themes::previewConversionResults怎么用?PHP Themes::previewConversionResults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Themes的用法示例。


在下文中一共展示了Themes::previewConversionResults方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: processConversion

function processConversion($files, $converter, $pipeline, $autoPipeline, $afterConversion, $setupOpenOfficeOrg, $outputZip, $justShowPreviewDirectory = null)
{
    $forcedPipeline = getGlobalConfigItem('forcePipeline');
    if ($forcedPipeline != null) {
        $pipeline = 'fake:' . $forcedPipeline;
    }
    ensureClientType();
    if (thereWasAFileGiven($files, $pipeline) || $justShowPreviewDirectory) {
        $returnZipPath = null;
        $previewDirectory = null;
        if (!$justShowPreviewDirectory) {
            $previewDirectory = getTemporaryDirectoryInsideDirectory(getWritableDirectory(), 'preview');
            $temporaryDirectory = getTemporaryDirectory();
            $pipelineToRunOnDocuments = substringAfter($pipeline, ':');
            foreach ($files as $file) {
                if ($file['size'] != 0) {
                    $documentPath = moveUploadToConversionDirectory($file, $temporaryDirectory);
                    $oasisOpenDocumentPath = '';
                    if (!isAnOasisOpenDocument($file)) {
                        $oasisOpenDocumentPath = makeOasisOpenDocument($documentPath, $converter);
                        silentlyUnlink($documentPath);
                    } else {
                        $oasisOpenDocumentPath = $documentPath;
                    }
                    if ($pipelineToRunOnDocuments != "none") {
                        extractUsefulOasisOpenDocumentFiles($oasisOpenDocumentPath);
                        silentlyUnlink($oasisOpenDocumentPath);
                        $oasisOpenDocumentContentPath = dirname($oasisOpenDocumentPath) . DIRECTORY_SEPARATOR . 'docvert-content.xml';
                        applyPipeline($oasisOpenDocumentContentPath, $pipelineToRunOnDocuments, $autoPipeline, $previewDirectory);
                        silentlyUnlink($oasisOpenDocumentContentPath);
                    }
                }
            }
            $returnZipPath = zipAndDeleteTemporaryFiles($temporaryDirectory);
            if ($afterConversion == 'preview') {
                include_once dirname(__FILE__) . '/webpage.php';
                $themes = new Themes();
                //$returnZipPath = $themes->unzipConversionResults($returnZipPath, $previewDirectory); //WTF
            }
        } else {
            $previewDirectory = getWritableDirectory() . $justShowPreviewDirectory;
            $zipsInPreviewDirectory = glob($previewDirectory . DIRECTORY_SEPARATOR . '*.zip');
            if (count($zipsInPreviewDirectory) != 1) {
                $errorData = array('zipsInPreviewDirectory' => count($zipsInPreviewDirectory), 'previewDirectory' => $previewDirectory);
                webServiceError('&docvert-internal-error-no-zip-file;', 500, $errorData);
            }
            $returnZipPath = $zipsInPreviewDirectory[0];
        }
        if ($afterConversion == 'preview') {
            include_once dirname(__FILE__) . '/webpage.php';
            $themes = new Themes();
            $themes->previewConversionResults($returnZipPath, $previewDirectory);
        } elseif ($afterConversion == 'saveZip') {
            if (DOCVERT_CLIENT_TYPE == 'command line') {
                moveFile($returnZipPath, $outputZip);
                print 'Ok! File saved to ' . $outputZip . "\n";
                deleteDirectoryRecursively($temporaryDirectory);
                die;
            } else {
                webServiceError('&error-after-conversion-flag;');
            }
        } elseif ($afterConversion == 'downloadZip') {
            //TODO: different versions of IE want different "content disposition" header syntaxes
            //perhaps we could detect versions of IE and serve up what they need? Will need quite a bit of research.
            header('Content-Type: application/x-zip-compressed');
            header('Content-disposition: attachment; filename=' . basename($returnZipPath));
            $zipContents = file_get_contents($returnZipPath);
            print $zipContents;
            flush();
            silentlyUnlink($returnZipPath);
            deleteDirectoryRecursively($temporaryDirectory);
            die;
        } else {
            webServiceError('&error-unsupported-after-conversion;', 500, array('after-conversion' => revealXml($afterConversion)));
        }
    } elseif ($setupOpenOfficeOrg) {
        setupOpenOfficeOrg();
    } else {
        /* TODO: so there's been no upload and what do we do?
         * I suppose an http status code would be appropriate.
         *     http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
         * The 4xx series are for user error, which seems appropriate.
         * ...but none of them seem quite appropriate for a casual
         * "you didn't give me files" response.
         * They talk about malformed requests.
         *
         * So I'm doing a "400 Bad Request" in the meantime.
         */
        webServiceError('&error-no-files-uploaded;', '400 Bad Request');
    }
}
开发者ID:Nolfneo,项目名称:docvert,代码行数:91,代码来源:lib.php


注:本文中的Themes::previewConversionResults方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。