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


PHP eZMimeType::changeFileData方法代码示例

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


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

示例1: convert

    /**
     * Converts the source image $sourceMimeData into the destination image
     * $destinationMimeData.
     *
     * @param mixed $sourceMimeData Source image, either a mimedata array or the
     *        source image path
     * @param mixed $destinationMimeData
     *        Either a mimedata array or the target image path
     * @param mixed $aliasName
     *        Target alias (small, medium, large...)
     * @param array $parameters
     *        Optional parameters. Known ones so far: (basename)
     * @return bool
     */
    function convert( $sourceMimeData, &$destinationMimeData, $aliasName = false, $parameters = array() )
    {
        // if the local file doesn't exist, we need to fetch it locally
        if ( !file_exists( $sourceMimeData['url'] ) )
        {
            $sourceFileHandler = eZClusterFileHandler::instance( $sourceMimeData['url'] );
            $sourceFileHandler->fetch();
        }

        if ( is_string( $sourceMimeData ) )
            $sourceMimeData = eZMimeType::findByFileContents( $sourceMimeData );

        $this->analyzeImage( $sourceMimeData );
        $currentMimeData = $sourceMimeData;
        $handlers = $this->ImageHandlers;
        $supportedMIMEMap = $this->SupportedMIMEMap;
        if ( is_string( $destinationMimeData ) )
        {
            $destinationPath = $destinationMimeData;
            $destinationMimeData = eZMimeType::findByFileContents( $destinationPath );
        }

        $filters = array();
        $alias = false;
        if ( $aliasName )
        {
            $aliasList = $this->aliasList();
            if ( isset( $aliasList[$aliasName] ) )
            {
                $alias = $aliasList[$aliasName];
                $filters = $alias['filters'];
                if ( $alias['mime_type'] )
                {
                    eZMimeType::changeMIMEType( $destinationMimeData, $alias['mime_type'] );
                }
            }
        }
        $mimeTypeOverride = $this->mimeTypeOverride( $sourceMimeData );
        if ( $mimeTypeOverride )
            $alias['override_mime_type'] = $mimeTypeOverride;

        if ( isset( $parameters['filters'] ) )
        {
            $filters = array_merge( $filters, $parameters['filters'] );
        }

        $wantedFilters = $filters;
        $mimeTypeFilters = $this->mimeTypeFilters( $sourceMimeData );
        if ( is_array( $mimeTypeFilters ) )
            $wantedFilters = array_merge( $wantedFilters, $mimeTypeFilters );
        $filters = array();
        foreach ( array_keys( $wantedFilters ) as $wantedFilterKey )
        {
            $wantedFilter = $wantedFilters[$wantedFilterKey];
            if ( !$this->isFilterSupported( $wantedFilter['name'] ) )
            {
                eZDebug::writeWarning( "The filter '" . $wantedFilter['name'] . "' is not supported by any of the image handlers, will ignore this filter", __METHOD__ );
                continue;
            }
            $filters[] = $wantedFilter;
        }
        if ( !$destinationMimeData['is_valid'] )
        {
            $destinationDirPath = $destinationMimeData['dirpath'];
            $destinationBasename = $destinationMimeData['basename'];
            if ( isset( $supportedMIMEMap[$sourceMimeData['name']] ) )
            {
                $destinationMimeData = $sourceMimeData;
                if ( $alias['mime_type'] )
                {
                    eZMimeType::changeMIMEType( $destinationMimeData, $alias['mime_type'] );
                }
                eZMimeType::changeFileData( $destinationMimeData, $destinationDirPath, $destinationBasename );
            }
            else
            {
                $hasDestination = false;
                foreach ( $handlers as $handler )
                {
                    $gotMimeData = true;
                    while( $gotMimeData )
                    {
                        $gotMimeData = false;
                        $outputMimeData = $handler->outputMIMEType( $this, $sourceMimeData, false, $this->SupportedFormats, $aliasName );
                        if ( $outputMimeData and
                             isset( $supportedMIMEMap[$outputMimeData['name']] ) )
//.........这里部分代码省略.........
开发者ID:nottavi,项目名称:ezpublish,代码行数:101,代码来源:ezimagemanager.php

示例2: updateAliasPath

 function updateAliasPath($dirpath, $name)
 {
     if (!file_exists($dirpath)) {
         eZDir::mkdir($dirpath, false, true);
     }
     $aliasList = $this->aliasList();
     $this->resetImageSerialNumber();
     foreach ($aliasList as $aliasName => $alias) {
         if ($alias['dirpath'] != $dirpath) {
             $oldDirpath = $alias['url'];
             $oldURL = $alias['url'];
             $basename = $name;
             if ($aliasName != 'original') {
                 $basename .= '_' . $aliasName;
             }
             eZMimeType::changeFileData($alias, $dirpath, $basename);
             $alias['full_path'] = $alias['url'];
             if ($this->isImageOwner()) {
                 if ($oldURL == '') {
                     continue;
                 }
                 $fileHandler = eZClusterFileHandler::instance();
                 $fileHandler->fileMove($oldURL, $alias['url']);
                 eZDir::cleanupEmptyDirectories($oldDirpath);
                 eZImageFile::moveFilepath($this->ContentObjectAttributeData['id'], $oldURL, $alias['url']);
             } else {
                 $fileHandler = eZClusterFileHandler::instance();
                 $fileHandler->fileLinkCopy($oldURL, $alias['url'], false);
                 eZImageFile::appendFilepath($this->ContentObjectAttributeData['id'], $alias['url']);
             }
             $this->setAliasVariation($aliasName, $alias);
         }
     }
     $this->recreateDOMTree();
     $this->setStorageRequired();
 }
开发者ID:,项目名称:,代码行数:36,代码来源:


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