本文整理汇总了PHP中eZFile::suffix方法的典型用法代码示例。如果您正苦于以下问题:PHP eZFile::suffix方法的具体用法?PHP eZFile::suffix怎么用?PHP eZFile::suffix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZFile
的用法示例。
在下文中一共展示了eZFile::suffix方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: trashStoredObjectAttribute
function trashStoredObjectAttribute($contentObjectAttribute, $version = null)
{
$contentObjectAttributeID = $contentObjectAttribute->attribute("id");
$imageHandler = $contentObjectAttribute->attribute('content');
$imageFiles = eZImageFile::fetchForContentObjectAttribute($contentObjectAttributeID);
foreach ($imageFiles as $imageFile) {
if ($imageFile == null) {
continue;
}
$existingFilepath = $imageFile;
// Check if there are any other records in ezimagefile that point to that filename.
$imageObjectsWithSameFileName = eZImageFile::fetchByFilepath(false, $existingFilepath);
$file = eZClusterFileHandler::instance($existingFilepath);
if ($file->exists() and count($imageObjectsWithSameFileName) <= 1) {
$orig_dir = dirname($existingFilepath) . '/trashed';
$fileName = basename($existingFilepath);
// create dest filename in the same manner as eZHTTPFile::store()
// grab file's suffix
$fileSuffix = eZFile::suffix($fileName);
// prepend dot
if ($fileSuffix) {
$fileSuffix = '.' . $fileSuffix;
}
// grab filename without suffix
$fileBaseName = basename($fileName, $fileSuffix);
// create dest filename
$newFileBaseName = md5($fileBaseName . microtime() . mt_rand());
$newFileName = $newFileBaseName . $fileSuffix;
$newFilepath = $orig_dir . '/' . $newFileName;
// rename the file, and update the database data
$imageHandler->updateAliasPath($orig_dir, $newFileBaseName);
if ($imageHandler->isStorageRequired()) {
$imageHandler->store($contentObjectAttribute);
$contentObjectAttribute->store();
}
}
}
}
示例2: appendSimpleFile
function appendSimpleFile($key, $filepath)
{
if (!isset($this->Parameters['simple-file-list'])) {
$this->Parameters['simple-file-list'] = array();
}
$suffix = eZFile::suffix($filepath);
//$sourcePath = $fileInfo['original-path'];
$packagePath = eZPackage::simpleFilesDirectory() . '/' . substr(md5(mt_rand()), 0, 8) . '.' . $suffix;
$destinationPath = $this->path() . '/' . $packagePath;
eZDir::mkdir(eZDir::dirpath($destinationPath), false, true);
//SP DBfile
$fileHandler = eZClusterFileHandler::instance();
$fileHandler->fileFetch($filepath);
eZFileHandler::copy($filepath, $destinationPath);
$this->Parameters['simple-file-list'][$key] = array('original-path' => $filepath, 'package-path' => $packagePath);
}
示例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] !== "/") {
//.........这里部分代码省略.........
示例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'] ) )
//.........这里部分代码省略.........
示例5: array
$script->startup();
$options = $script->getOptions('', '', array());
$script->initialize();
$limit = 20;
$offset = 0;
$db = eZDB::instance();
$script->setIterationData('.', '~');
while ($binaryFiles = eZPersistentObject::fetchObjectList(eZBinaryFile::definition(), null, null, null, array('offset' => $offset, 'limit' => $limit))) {
foreach ($binaryFiles as $binaryFile) {
$fileName = $binaryFile->attribute('filename');
if (strpos($fileName, '.') !== false) {
$text = "skipping {$fileName}, it contains a suffix";
$script->iterate($cli, true, $text);
continue;
}
$suffix = eZFile::suffix($binaryFile->attribute('original_filename'));
if ($suffix) {
$newFileName = $fileName . '.' . $suffix;
$db->begin();
$oldFilePath = $binaryFile->attribute('filepath');
$binaryFile->setAttribute('filename', $newFileName);
$binaryFile->store();
$newFilePath = $binaryFile->attribute('filepath');
$file = eZClusterFileHandler::instance($oldFilePath);
if ($file->exists()) {
$text = "renamed {$fileName} to {$newFileName}";
$file->move($newFilePath);
} else {
$text = "file not found: {$oldFilePath}";
$script->iterate($cli, false, $text);
$db->rollback();
示例6: fetchList
/**
* Fetches the list of available translations, as an eZTSTranslator for each translation.
*
* @param array $localList
*
* @return array( eZTSTranslator ) list of eZTranslator objects representing available translations
*/
static function fetchList($localeList = array())
{
$ini = eZINI::instance();
$dir = $ini->variable('RegionalSettings', 'TranslationRepository');
$fileInfoList = array();
$translationList = array();
$locale = '';
if (count($localeList) == 0) {
$localeList = eZDir::findSubdirs($dir);
}
foreach ($localeList as $locale) {
if ($locale != 'untranslated') {
$translationFiles = eZDir::findSubitems($dir . '/' . $locale, 'f');
foreach ($translationFiles as $translationFile) {
if (eZFile::suffix($translationFile) == 'ts') {
$translationList[] = new eZTSTranslator($locale, $translationFile);
}
}
}
}
return $translationList;
}
示例7: unserializeContentObjectAttribute
function unserializeContentObjectAttribute( $package, $objectAttribute, $attributeNode )
{
$fileNode = $attributeNode->getElementsByTagName( 'binary-file' )->item( 0 );
if ( !is_object( $fileNode ) or !$fileNode->hasAttributes() )
{
return;
}
$binaryFile = eZBinaryFile::create( $objectAttribute->attribute( 'id' ), $objectAttribute->attribute( 'version' ) );
$sourcePath = $package->simpleFilePath( $fileNode->getAttribute( 'filekey' ) );
if ( !file_exists( $sourcePath ) )
{
eZDebug::writeError( "The file '$sourcePath' does not exist, cannot initialize file attribute with it", __METHOD__ );
return false;
}
$ini = eZINI::instance();
$mimeType = $fileNode->getAttribute( 'mime-type' );
list( $mimeTypeCategory, $mimeTypeName ) = explode( '/', $mimeType );
$destinationPath = eZSys::storageDirectory() . '/original/' . $mimeTypeCategory . '/';
if ( !file_exists( $destinationPath ) )
{
$oldumask = umask( 0 );
if ( !eZDir::mkdir( $destinationPath, false, true ) )
{
umask( $oldumask );
return false;
}
umask( $oldumask );
}
$basename = basename( $fileNode->getAttribute( 'filename' ) );
while ( file_exists( $destinationPath . $basename ) )
{
$basename = substr( md5( mt_rand() ), 0, 8 ) . '.' . eZFile::suffix( $fileNode->getAttribute( 'filename' ) );
}
eZFileHandler::copy( $sourcePath, $destinationPath . $basename );
eZDebug::writeNotice( 'Copied: ' . $sourcePath . ' to: ' . $destinationPath . $basename, __METHOD__ );
$binaryFile->setAttribute( 'contentobject_attribute_id', $objectAttribute->attribute( 'id' ) );
$binaryFile->setAttribute( 'filename', $basename );
$binaryFile->setAttribute( 'original_filename', $fileNode->getAttribute( 'original-filename' ) );
$binaryFile->setAttribute( 'mime_type', $fileNode->getAttribute( 'mime-type' ) );
$binaryFile->store();
$fileHandler = eZClusterFileHandler::instance();
$fileHandler->fileStore( $destinationPath . $basename, 'binaryfile', true );
}
示例8: unserializeContentObjectAttribute
function unserializeContentObjectAttribute($package, $objectAttribute, $attributeNode)
{
$mediaNode = $attributeNode->getElementsByTagName('media-file')->item(0);
if (!$mediaNode) {
// No media type data found.
return;
}
$mediaFile = eZMedia::create($objectAttribute->attribute('id'), $objectAttribute->attribute('version'));
$sourcePath = $package->simpleFilePath($mediaNode->getAttribute('filekey'));
$ini = eZINI::instance();
$mimeType = $mediaNode->getAttribute('mime-type');
list($mimeTypeCategory, $mimeTypeName) = explode('/', $mimeType);
$destinationPath = eZSys::storageDirectory() . '/original/' . $mimeTypeCategory . '/';
if (!file_exists($destinationPath)) {
if (!eZDir::mkdir($destinationPath, false, true)) {
return false;
}
}
$basename = basename($mediaNode->getAttribute('filename'));
while (file_exists($destinationPath . $basename)) {
$basename = substr(md5(mt_rand()), 0, 8) . '.' . eZFile::suffix($mediaNode->getAttribute('filename'));
}
eZFileHandler::copy($sourcePath, $destinationPath . $basename);
eZDebug::writeNotice('Copied: ' . $sourcePath . ' to: ' . $destinationPath . $basename, __METHOD__);
$mediaFile->setAttribute('contentobject_attribute_id', $objectAttribute->attribute('id'));
$mediaFile->setAttribute('filename', $basename);
$mediaFile->setAttribute('original_filename', $mediaNode->getAttribute('original-filename'));
$mediaFile->setAttribute('mime_type', $mediaNode->getAttribute('mime-type'));
$mediaFile->setAttribute('width', $mediaNode->getAttribute('width'));
$mediaFile->setAttribute('height', $mediaNode->getAttribute('height'));
$mediaFile->setAttribute('has_controller', $mediaNode->getAttribute('has-controller'));
$mediaFile->setAttribute('controls', $mediaNode->getAttribute('controls'));
$mediaFile->setAttribute('is_autoplay', $mediaNode->getAttribute('is-autoplay'));
$mediaFile->setAttribute('pluginspage', $mediaNode->getAttribute('plugins-page'));
$mediaFile->setAttribute('quality', $mediaNode->getAttribute('quality'));
$mediaFile->setAttribute('is_loop', $mediaNode->getAttribute('is-loop'));
$fileHandler = eZClusterFileHandler::instance();
$fileHandler->fileStore($destinationPath . $basename, 'mediafile', true);
$mediaFile->store();
}