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


PHP eZMimeType::findByName方法代码示例

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


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

示例1: changeMIMEType

 static function changeMIMEType(&$mimeInfo, $mimetype)
 {
     $mimeInfo['name'] = $mimetype;
     $newMimeInfo = eZMimeType::findByName($mimetype);
     $mimeInfo['suffixes'] = $newMimeInfo['suffixes'];
     $mimeInfo['prefixes'] = $newMimeInfo['prefixes'];
     $mimeInfo['suffix'] = $newMimeInfo['suffix'];
     $mimeInfo['prefix'] = $newMimeInfo['prefix'];
     $filename = $mimeInfo['filename'];
     $dotPosition = strrpos($filename, '.');
     $basename = $filename;
     if ($dotPosition !== false) {
         $basename = substr($filename, 0, $dotPosition);
     }
     $mimeInfo['filename'] = $basename . '.' . $mimeInfo['suffix'];
     if ($mimeInfo['dirpath']) {
         $mimeInfo['url'] = $mimeInfo['dirpath'] . '/' . $mimeInfo['filename'];
     } else {
         $mimeInfo['url'] = $mimeInfo['filename'];
     }
 }
开发者ID:runelangseid,项目名称:ezpublish,代码行数:21,代码来源:ezmimetype.php

示例2: outputMIMEType

 function outputMIMEType(&$manager, $currentMimeData, $wantedMimeData, $supportedFormatsOriginal, $aliasName = false)
 {
     if (is_array($this->conversionRules())) {
         $conversionRules = array_merge($manager->conversionRules(), $this->conversionRules());
     } else {
         $conversionRules = $manager->conversionRules();
     }
     $mimeData = false;
     $mimeType = false;
     if (!$this->isInputMIMETypeSupported($currentMimeData)) {
         return false;
     }
     if ($wantedMimeData) {
         $conversionRules = array_merge(array(array('from' => $currentMimeData['name'], 'to' => $wantedMimeData['name'])), $conversionRules);
     }
     $supportedFormats = array();
     foreach ($supportedFormatsOriginal as $supportedFormat) {
         if ($this->isOutputMIMETypeSupported($supportedFormat)) {
             $supportedFormats[] = $supportedFormat;
             $conversionRules[] = array('from' => $supportedFormat, 'to' => $supportedFormat);
         }
     }
     if ($wantedMimeData and in_array($wantedMimeData['name'], $supportedFormats)) {
         $mimeType = $wantedMimeData['name'];
     } else {
         if (is_array($conversionRules)) {
             foreach ($conversionRules as $rule) {
                 if (!$this->isOutputMIMETypeSupported($rule['to']) or !in_array($rule['to'], $supportedFormats)) {
                     continue;
                 }
                 $matchRule = false;
                 if (strpos($rule['from'], '*') !== false) {
                     $matchString = eZImageHandler::wildcardToRegexp($rule['from']);
                     if (preg_match("#^" . $matchString . "\$#", $currentMimeData['name'])) {
                         $matchRule = $rule;
                     }
                 } else {
                     if ($rule['from'] == $currentMimeData['name']) {
                         $matchRule = $rule;
                     }
                 }
                 if ($matchRule) {
                     if ($mimeType) {
                         if ($wantedMimeData and $matchRule['to'] == $wantedMimeData['name']) {
                             $mimeType = $matchRule['to'];
                         }
                     } else {
                         $mimeType = $matchRule['to'];
                     }
                 }
             }
         }
     }
     if ($mimeType) {
         $mimeData = eZMimeType::findByName($mimeType);
         $this->rewriteURL($currentMimeData, $mimeData, $this->outputRewriteType(), $aliasName);
     }
     return $mimeData;
 }
开发者ID:mugoweb,项目名称:ezpublish-legacy,代码行数:59,代码来源:ezimagehandler.php

示例3: fetchNodeInfo

 /**
  * Gathers information about a given node specified as parameter.
  *
  * The format of the returned array is:
  * <code>
  * array( 'name' => node name (eg. 'Group picture'),
  *        'size' => storage size of the_node in bytes (eg. 57123),
  *        'mimetype' => mime type of the node (eg. 'image/jpeg'),
  *        'ctime' => creation time as timestamp,
  *        'mtime' => latest modification time as timestamp,
  *        'href' => the path to the node (eg. '/plain_site_user/Content/Folder1/file1.jpg')
  * </code>
  *
  * @param string $target Eg. '/plain_site_user/Content/Folder1/file1.jpg
  * @param eZContentObject &$node The node corresponding to $target
  * @return array(string=>mixed)
  * @todo remove/replace .ini calls, eZContentUpload, eZMimeType, eZSys RequestURI
  * @todo handle articles as files
  */
 protected function fetchNodeInfo($target, &$node)
 {
     // When finished, we'll return an array of attributes/properties.
     $entry = array();
     $classIdentifier = $node->attribute('class_identifier');
     $object = $node->attribute('object');
     $urlAlias = $node->urlAlias();
     // By default, everything is displayed as a folder:
     // Trim the name of the node, it is in some cases whitespace in eZ Publish
     $name = trim($node->attribute('name'));
     // @as 2009-03-09: return node_id as displayname in case name is missing
     // displayname is not actually used by WebDAV clients
     $entry["name"] = $name !== '' && $name !== NULL ? $name : $node->attribute('node_id');
     $entry["size"] = 0;
     $entry["mimetype"] = self::DIRECTORY_MIMETYPE;
     eZWebDAVContentBackend::appendLogEntry('FetchNodeInfo:' . $node->attribute('name') . '/' . $urlAlias);
     // @todo handle articles as files
     // if ( $classIdentifier === 'article' )
     // {
     //     $entry["mimetype"] = 'application/ms-word';
     // }
     $entry["ctime"] = $object->attribute('published');
     $entry["mtime"] = $object->attribute('modified');
     $upload = new eZContentUpload();
     $info = $upload->objectFileInfo($object);
     $suffix = '';
     $class = $object->contentClass();
     $isObjectFolder = $this->isObjectFolder($object, $class);
     if ($isObjectFolder) {
         // We do nothing, the default is to see it as a folder
     } else {
         if ($info) {
             $filePath = $info['filepath'];
             $entry['filepath'] = $filePath;
             $entry["mimetype"] = false;
             $entry["size"] = false;
             if (isset($info['filesize'])) {
                 $entry['size'] = $info['filesize'];
             }
             if (isset($info['mime_type'])) {
                 $entry['mimetype'] = $info['mime_type'];
             }
             // Fill in information from the actual file if they are missing.
             $file = eZClusterFileHandler::instance($filePath);
             if (!$entry['size'] and $file->exists()) {
                 $entry["size"] = $file->size();
             }
             if (!$entry['mimetype']) {
                 $mimeInfo = eZMimeType::findByURL($filePath);
                 $entry["mimetype"] = $mimeInfo['name'];
                 $suffix = $mimeInfo['suffix'];
                 if (strlen($suffix) > 0) {
                     $entry["name"] .= '.' . $suffix;
                 }
             } else {
                 // eZMimeType returns first suffix in its list
                 // this could be another one than the original file extension
                 // so let's try to get the suffix from the file path first
                 $suffix = eZFile::suffix($filePath);
                 if (!$suffix) {
                     $mimeInfo = eZMimeType::findByName($entry['mimetype']);
                     $suffix = $mimeInfo['suffix'];
                 }
                 if (strlen($suffix) > 0) {
                     $entry["name"] .= '.' . $suffix;
                 }
             }
             if ($file->exists()) {
                 $entry["ctime"] = $file->mtime();
                 $entry["mtime"] = $file->mtime();
             }
         } else {
             // Here we only show items as folders if they have
             // is_container set to true, otherwise it's an unknown binary file
             if (!$class->attribute('is_container')) {
                 $entry['mimetype'] = 'application/octet-stream';
             }
         }
     }
     $scriptURL = $target;
     if (strlen($scriptURL) > 0 and $scriptURL[strlen($scriptURL) - 1] !== "/") {
//.........这里部分代码省略.........
开发者ID:EVE-Corp-Center,项目名称:ECC-Website,代码行数:101,代码来源:ezwebdavcontentbackend.php

示例4: fetchNodeInfo

    function fetchNodeInfo( &$node )
    {
        // When finished, we'll return an array of attributes/properties.
        $entry = array();

        // Grab settings from the ini file:
        $webdavINI = eZINI::instance( eZWebDAVContentServer::WEBDAV_INI_FILE );
        $iniSettings = $webdavINI->variable( 'DisplaySettings', 'FileAttribute' );

        $classIdentifier = $node->attribute( 'class_identifier' );

        $object = $node->attribute( 'object' );

        // By default, everything is displayed as a folder:
        // Trim the name of the node, it is in some cases whitespace in eZ Publish
        $entry["name"] = trim( $node->attribute( 'name' ) );
        $entry["size"] = 0;
        $entry["mimetype"] = 'httpd/unix-directory';
        $entry["ctime"] = $object->attribute( 'published' );
        $entry["mtime"] = $object->attribute( 'modified' );

        $upload = new eZContentUpload();
        $info = $upload->objectFileInfo( $object );
        $suffix = '';
        $class = $object->contentClass();
        $isObjectFolder = $this->isObjectFolder( $object, $class );

        if ( $isObjectFolder )
        {
            // We do nothing, the default is to see it as a folder
        }
        else if ( $info )
        {
            $filePath = $info['filepath'];
            $entry["mimetype"] = false;
            $entry["size"] = false;
            if ( isset( $info['filesize'] ) )
                $entry['size'] = $info['filesize'];
            if ( isset( $info['mime_type'] ) )
                $entry['mimetype'] = $info['mime_type'];

            // Fill in information from the actual file if they are missing.
            $file = eZClusterFileHandler::instance( $filePath );
            if ( !$entry['size'] and $file->exists() )
            {
                $entry["size"] = $file->size();
            }
            if ( !$entry['mimetype']  )
            {
                $mimeInfo = eZMimeType::findByURL( $filePath );
                $entry["mimetype"] = $mimeInfo['name'];
                $suffix = $mimeInfo['suffix'];
                if ( strlen( $suffix ) > 0 )
                    $entry["name"] .= '.' . $suffix;
            }
            else
            {
                // eZMimeType returns first suffix in its list
                // this could be another one than the original file extension
                // so let's try to get the suffix from the file path first
                $suffix = eZFile::suffix( $filePath );
                if ( !$suffix )
                {
                    $mimeInfo = eZMimeType::findByName( $entry['mimetype'] );
                    $suffix = $mimeInfo['suffix'];
                }
                if ( strlen( $suffix ) > 0 )
                    $entry["name"] .= '.' . $suffix;
            }

            if ( $file->exists() )
            {
                $entry["ctime"] = $file->mtime();
                $entry["mtime"] = $file->mtime();
            }
        }
        else
        {
            // Here we only show items as folders if they have
            // is_container set to true, otherwise it's an unknown binary file
            if ( !$class->attribute( 'is_container' ) )
            {
                $entry['mimetype'] = 'application/octet-stream';
            }
        }

        $scriptURL = eZSys::instance()->RequestURI;
        if ( strlen( $scriptURL ) > 0 and $scriptURL[ strlen( $scriptURL ) - 1 ] != "/" )
            $scriptURL .= "/";

        $trimmedScriptURL = trim( $scriptURL, '/' );
        $scriptURLParts = explode( '/', $trimmedScriptURL );

        $siteAccess = $scriptURLParts[0];
        $virtualFolder = $scriptURLParts[1];

        $startURL = '/' . $siteAccess . '/' . $virtualFolder . '/';

        // Set the href attribute (note that it doesn't just equal the name).
        if ( !isset( $entry['href'] ) )
//.........这里部分代码省略.........
开发者ID:nottavi,项目名称:ezpublish,代码行数:101,代码来源:ezwebdavcontentserver.php

示例5: initializeFromHTTPFile

 /**
  * Initializes the content object attribute with the uploaded HTTP file
  *
  * @param eZHTTPFile $httpFile
  * @param string $imageAltText Optional image ALT text
  *
  * @return TODO: FIXME
  */
 function initializeFromHTTPFile($httpFile, $imageAltText = false)
 {
     $this->increaseImageSerialNumber();
     $mimeData = eZMimeType::findByFileContents($httpFile->attribute('filename'));
     if (!$mimeData['is_valid']) {
         $mimeData = eZMimeType::findByName($httpFile->attribute('mime_type'));
         if (!$mimeData['is_valid']) {
             $mimeData = eZMimeType::findByURL($httpFile->attribute('original_filename'));
         }
     }
     $attr = false;
     $this->removeAliases($attr);
     $this->setOriginalAttributeDataValues($this->ContentObjectAttributeData['id'], $this->ContentObjectAttributeData['version'], $this->ContentObjectAttributeData['language_code']);
     $contentVersion = eZContentObjectVersion::fetchVersion($this->ContentObjectAttributeData['version'], $this->ContentObjectAttributeData['contentobject_id']);
     $objectName = $this->imageName($this->ContentObjectAttributeData, $contentVersion);
     $objectPathString = $this->imagePath($this->ContentObjectAttributeData, $contentVersion, true);
     eZMimeType::changeBaseName($mimeData, $objectName);
     eZMimeType::changeDirectoryPath($mimeData, $objectPathString);
     $httpFile->store(false, false, $mimeData);
     $originalFilename = $httpFile->attribute('original_filename');
     return $this->initialize($mimeData, $originalFilename, $imageAltText);
 }
开发者ID:,项目名称:,代码行数:30,代码来源:

示例6: createImageAlias

    /**
     * Creates the image alias $aliasName if it's not already part of the
     * existing aliases
     *
     * @param string $aliasName Name of the alias to create
     * @param array $existingAliasList
     *        Reference to the current alias list. The created alias will be
     *        added to the list.
     * @param array $parameters
     *        Optional array that can be used to specify the image's basename
     * @return bool true if the alias was created, false if it wasn't
     */
    function createImageAlias( $aliasName, &$existingAliasList, $parameters = array() )
    {
        $fname = "createImageAlias( $aliasName )";

        // check for $aliasName validity
        $aliasList = $this->aliasList();
        if ( !isset( $aliasList[$aliasName] ) )
        {
            eZDebug::writeWarning( "Alias name $aliasName does not exist, cannot create it" );
            return false;
        }

        // check if the reference alias is defined, and if no, use original as ref
        $currentAliasInfo = $aliasList[$aliasName];
        $referenceAlias = $currentAliasInfo['reference'];
        if ( $referenceAlias and !$this->hasAlias( $referenceAlias ) )
        {
            eZDebug::writeError( "The referenced alias '$referenceAlias' for image alias '$aliasName' does not exist, cannot use it for reference.\n" .
                                 "Will use 'original' alias instead.",
                                 __METHOD__ );
            $referenceAlias = false;
        }
        if ( !$referenceAlias )
            $referenceAlias = 'original';

        // generate the reference alias if it hasn't been generated yet
        $hasReference = false;
        if ( array_key_exists( $referenceAlias, $existingAliasList ) )
        {
            $fileHandler = eZClusterFileHandler::instance();
            if ( $fileHandler->fileExists( $existingAliasList[$referenceAlias]['url'] ) )
            {
                $hasReference = true;
            }
            else
            {
                eZDebug::writeError( "The reference alias $referenceAlias file {$existingAliasList[$referenceAlias]['url']} does not exist", __METHOD__ );
            }
        }
        if ( !$hasReference )
        {
            $ini = eZINI::instance( 'image.ini' );
            
            if ( $ini->hasVariable( 'AliasSettings', 'AlwaysGenerate') && $ini->variable( 'AliasSettings', 'AlwaysGenerate' ) == 'enabled' ) 
            {
                $mimeData = eZMimeType::findByURL( $existingAliasList[$referenceAlias]['url'] );
                $destinationMimeData = eZMimeType::findByName( $mimeData['name'] );

                if ( $aliasName != 'original' )
                {
                    foreach ( array( 'url', 'filename', 'basename') as $k )
                    {
                        $mimeData[$k] = preg_replace('#(\.[^.]+)$#', '_'.strtolower($aliasName).'.'.$destinationMimeData['suffix'], $mimeData[$k]);
                    }
                }
                $existingAliasList[$aliasName] = $mimeData;
                return true;
            } 
            else 
            {
                if ( $referenceAlias == 'original' )
                {
                    eZDebug::writeError( "Original alias does not exist, cannot create other aliases without it" );
                    return false;
                }
                if ( !$this->createImageAlias( $referenceAlias, $existingAliasList, $parameters ) )
                {
                    eZDebug::writeError( "Failed creating the referenced alias $referenceAlias, cannot create alias $aliasName", __METHOD__ );
                    return false;
                }
            }
        }

        // from now on, our reference image (either reference or original)
        // exists
        $aliasInfo = $existingAliasList[$referenceAlias];
        $aliasFilePath = $aliasInfo['url'];
        $aliasKey = $currentAliasInfo['alias_key'];

        $sourceMimeData = eZMimeType::findByFileContents( $aliasFilePath );

        /**
         * at first, destinationMimeData (mimedata for the alias we're
         * generating) is the same as sourceMimeData. It will evolve as
         * alias generation goes on
         */
        $destinationMimeData = $sourceMimeData;
        if ( isset( $parameters['basename'] ) )
//.........这里部分代码省略.........
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:101,代码来源:ezimagemanager.php


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