本文整理汇总了PHP中eZFileHandler::copy方法的典型用法代码示例。如果您正苦于以下问题:PHP eZFileHandler::copy方法的具体用法?PHP eZFileHandler::copy怎么用?PHP eZFileHandler::copy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZFileHandler
的用法示例。
在下文中一共展示了eZFileHandler::copy方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: install
function install( $package, $installType, $parameters,
$name, $os, $filename, $subdirectory,
$content, &$installParameters,
&$installData )
{
$collectionName = $parameters['collection'];
$installVariables = array();
if ( isset( $installParameters['variables'] ) )
$installVariables = $installParameters['variables'];
$iniFileVariables = false;
if ( isset( $installParameters['ini'] ) )
$iniFileVariables = $installParameters['ini'];
$fileList = $package->fileList( $collectionName );
if ( $fileList )
{
foreach ( $fileList as $fileItem )
{
$newFilePath = false;
if ( $fileItem['type'] == 'thumbnail' )
{
}
else
{
$filePath = $package->fileItemPath( $fileItem, $collectionName );
if ( is_dir( $filePath ) )
{
$newFilePath = $package->fileStorePath( $fileItem, $collectionName, $installParameters['path'], $installVariables );
eZDir::mkdir( $newFilePath, false, true );
}
else
{
$newFilePath = $package->fileStorePath( $fileItem, $collectionName, $installParameters['path'], $installVariables );
if ( preg_match( "#^(.+)/[^/]+$#", $newFilePath, $matches ) )
{
eZDir::mkdir( $matches[1], false, true );
}
eZFileHandler::copy( $filePath, $newFilePath );
}
}
if ( $fileItem['type'] == 'ini' and $iniFileVariables and $newFilePath )
{
$fileRole = $fileItem['role'];
$fileRoleValue = $fileItem['role-value'];
$fileVariableName = $fileItem['variable-name'];
$fileName = $fileItem['name'];
if ( $fileVariableName and
isset( $installParameters['variables'][$fileVariableName] ) )
$fileRoleValue = $installParameters['variables'][$fileVariableName];
if ( isset( $iniFileVariables[$fileRole][$fileRoleValue][$fileName] ) )
{
$variables = $iniFileVariables[$fileRole][$fileRoleValue][$fileName];
$ini = eZINI::fetchFromFile( $newFilePath );
$ini->setVariables( $variables );
$ini->save( false, false, false, false, false );
}
}
}
}
return true;
}
示例2: archiveFile
public function archiveFile($path, $seeds, $prefix = null, $realm = null)
{
$archiveFileName = $this->getArchiveFileName($path, $seeds, $prefix, $realm);
if (eZFileHandler::copy($path, $archiveFileName)) {
return array('archive_file_name' => $archiveFileName, 'seeds' => $seeds, 'prefix' => $prefix, 'realm' => $realm);
} else {
return false;
}
}
示例3: convert
//.........这里部分代码省略.........
$nextMimeData = $outputMimeData;
$nextHandler = $handler;
}
}
if ( !$nextMimeData )
{
eZDebug::writeError( "None of the handlers can convert MIME-Type " . $currentMimeData['name'], __METHOD__ );
if ( isset( $sourceFile ) )
$sourceFile->deleteLocal();
return false;
}
$useTempImage = false;
if ( $nextMimeData['name'] == $destinationMimeData['name'] and
count( $leftoverFilters ) == 0 )
{
$nextMimeData['dirpath'] = $destinationMimeData['dirpath'];
}
else
{
$useTempImage = true;
$nextMimeData['dirpath'] = $this->temporaryImageDirPath();
}
eZMimeType::changeDirectoryPath( $nextMimeData, $nextMimeData['dirpath'] );
if ( $nextMimeData['dirpath'] and
!file_exists( $nextMimeData['dirpath'] ) )
eZDir::mkdir( $nextMimeData['dirpath'], false, true );
if ( $currentMimeData['name'] == $nextMimeData['name'] and
count( $handlerFilters ) == 0 )
{
if ( $currentMimeData['url'] != $nextMimeData['url'] )
{
if ( eZFileHandler::copy( $currentMimeData['url'], $nextMimeData['url'] ) )
{
if ( $useTempImage )
$tempFiles[] = $nextMimeData['url'];
}
else
{
$result = false;
break;
}
}
$currentMimeData = $nextMimeData;
}
else
{
if ( $nextHandler->convert( $this, $currentMimeData, $nextMimeData, $handlerFilters ) )
{
if ( $useTempImage )
$tempFiles[] = $nextMimeData['url'];
}
else
{
$result = false;
break;
}
// store the converted file to cluster if the conversion is between mime name
$fileHandler = eZClusterFileHandler::instance();
$fileHandler->fileStore( $nextMimeData['url'], 'image', false, $nextMimeData['name'] );
$currentMimeData = $nextMimeData;
}
$filters = $leftoverFilters;
}
示例4: fileCopy
/**
* Copy file.
*
* \public
* \static
*/
function fileCopy($srcPath, $dstPath)
{
eZDebugSetting::writeDebug('kernel-clustering', "fs::fileCopy( '{$srcPath}', '{$dstPath}' )", __METHOD__);
eZDebug::accumulatorStart('dbfile', false, 'dbfile');
eZFileHandler::copy($srcPath, $dstPath);
eZDebug::accumulatorStop('dbfile');
}
示例5: move
static function move( $sourceFilename, $destinationFilename )
{
if ( !file_exists( $sourceFilename ) and
!is_link( $sourceFilename ) )
{
eZDebug::writeError( "Cannot rename file $sourceFilename, it does not exist", __METHOD__ );
return false;
}
$isDir = false;
if ( is_dir( $destinationFilename ) )
{
$isDir = true;
$dirPosition = strrpos( $sourceFilename, '/' );
$filePosition = 0;
if ( $dirPosition !== false )
$filePosition = $dirPosition + 1;
if ( strlen( $destinationFilename ) > 0 and
$destinationFilename[strlen( $destinationFilename ) - 1] == '/' )
$destinationFilename .= substr( $sourceFilename, $filePosition );
else
$destinationFilename .= '/' . substr( $sourceFilename, $filePosition );
}
// If source and destination are the same files we just return true
if ( $sourceFilename == $destinationFilename )
{
return true;
}
if ( file_exists( $destinationFilename ) and
!is_dir( $destinationFilename ) )
{
if ( !@unlink( $destinationFilename ) )
{
eZDebug::writeError( "Cannot move file $sourceFilename to destination $destinationFilename, destination file cannot be removed", __METHOD__ );
return false;
}
}
$isLink = false;
if ( is_link( $sourceFilename ) )
{
$isLink = true;
}
if ( !$isLink and
eZFile::rename( $sourceFilename, $destinationFilename ) )
{
return true;
}
if ( eZFileHandler::copy( $sourceFilename, $destinationFilename ) )
{
if ( !@unlink( $sourceFilename ) )
{
eZDebug::writeError( "Cannot remove source file $sourceFilename, file was not succesfully moved", __METHOD__ );
@unlink( $destinationFilename );
return false;
}
return true;
}
eZDebug::writeError( "Failed to copy $sourceFilename to $destinationFilename, file was not succesfully moved", __METHOD__ );
return false;
}
示例6: switch
if ($attributeStringContent != '') {
switch ($datatypeString = $attribute->attribute('data_type_string')) {
case 'ezimage':
$imagePathParts = explode('/', $attributeStringContent);
$imageFile = array_pop($imagePathParts);
// here it would be nice to add a check if such file allready exists
$success = eZFileHandler::copy($attributeStringContent, $storageDir . '/' . $imageFile);
if (!$success) {
$status = false;
}
$attributeStringContent = $imageFile;
break;
case 'ezbinaryfile':
case 'ezmedia':
$binaryData = explode('|', $attributeStringContent);
$success = eZFileHandler::copy($binaryData[0], $storageDir . '/' . $binaryData[1]);
if (!$success) {
$status = false;
}
$attributeStringContent = $binaryData[1];
break;
default:
}
}
$objectData[] = $attributeStringContent;
}
if (!$fp) {
$cli->error("Can not open output file");
$script->shutdown(5);
}
if (!fputcsv($fp, $objectData, ';')) {
示例7: createInstallNode
function createInstallNode($package, $installNode, $installItem, $installType)
{
$installNode->setAttribute('original-path', $installItem['path']);
$installNode->setAttribute('database-type', $installItem['database-type']);
$originalPath = $installItem['path'];
$installDirectory = $package->path() . '/' . eZDBPackageHandler::sqlDirectory();
if ($installItem['database-type']) {
$installDirectory .= '/' . $installItem['database-type'];
}
if (!file_exists($installDirectory)) {
eZDir::mkdir($installDirectory, false, true);
}
eZFileHandler::copy($originalPath, $installDirectory . '/' . $installItem['filename']);
}
示例8: installTemplates
function installTemplates( $templateList, $package, $subdirectory, &$installParameters )
{
if ( !$templateList )
{
return true;
}
$siteAccessDesignPathArray = array();
$templateRootPath = $package->path() . '/' . $subdirectory;
foreach( $templateList->getElementsByTagName( 'file' ) as $fileNode )
{
$originalSiteAccess = $fileNode->getAttribute( 'site-access' );
if ( isset( $installParameters['site_access_map'][$originalSiteAccess] ) )
{
$newSiteAccess = $installParameters['site_access_map'][$originalSiteAccess];
}
else
{
$newSiteAccess = $installParameters['site_access_map']['*'];
}
if ( !isset( $siteAccessDesignPathArray[$newSiteAccess] ) )
{
$ini = eZINI::instance( 'site.ini', 'settings', null, null, true );
$ini->prependOverrideDir( "siteaccess/$newSiteAccess", false, 'siteaccess' );
$ini->loadCache();
if ( isset( $installParameters['design_map'] ) )
{
$designMap = $installParameters['design_map'];
if ( isset( $designMap[$originalSiteAccess] ) )
$siteAccessDesignPathArray[$newSiteAccess] = eZTemplateDesignResource::designStartPath() . '/' . $designMap[$originalSiteAccess];
else
$siteAccessDesignPathArray[$newSiteAccess] = eZTemplateDesignResource::designStartPath() . '/' . $designMap['*'];
}
else
{
$siteAccessDesignPathArray[$newSiteAccess] = eZTemplateDesignResource::designStartPath() . '/' . $ini->variable( "DesignSettings", "StandardDesign" );
}
}
$path = '';
foreach( $fileNode->childNodes as $pathNode )
{
if ( $pathNode->nodeName == 'path' )
{
$path = $pathNode->nodeValue;
break;
}
}
$sourcePath = $templateRootPath . $path;
$destinationPath = $siteAccessDesignPathArray[$newSiteAccess] . $path;
eZDir::mkdir( eZDir::dirpath( $destinationPath ), false, true );
if ( !eZFileHandler::copy( $sourcePath, $destinationPath ) )
return false;
// eZDebug::writeNotice( 'Copied: "' . $sourcePath . '" to: "' . $destinationPath . '"', __METHOD__ );
}
return true;
}
示例9: retrieveRemotePackagesList
/**
* Retrieve list of packages available to download.
*
* Example of return value:
* array(
* 'packages' => array(
* '<package_name1>' => array( "name" =>... , "version" =>... , "summary" => ... "url" =>... ),
* '<package_name2>' => array( "name" =>... , "version" =>... , "summary" => ... "url" =>... )
* )
* );
*
*/
function retrieveRemotePackagesList($onlySitePackages = false)
{
// Download index file.
$idxFileName = $this->downloadFile($this->XMLIndexURL, eZStepSiteTypes::tempDir(), 'index.xml');
if ($idxFileName === false) {
// Searching for a local index.xml file to use for offline installation
$destIndexPath = eZStepSiteTypes::tempDir() . DIRECTORY_SEPARATOR . 'index.xml';
$repo = eZPackage::systemRepositoryInformation();
if ($repo) {
$sourceIndexPath = $repo['path'] . DIRECTORY_SEPARATOR . 'index.xml';
if (file_exists($sourceIndexPath)) {
eZFileHandler::copy($sourceIndexPath, $destIndexPath);
$idxFileName = $destIndexPath;
// Removing error message from downloadFile
$this->ErrorMsg = false;
}
}
}
if ($idxFileName === false) {
$this->ErrorMsg = ezpI18n::tr('design/standard/setup/init', 'Retrieving remote site packages list failed. ' . 'You may upload packages manually.');
eZDebug::writeNotice("Cannot download remote packages index file from '{$this->XMLIndexURL}'.");
return false;
}
// Parse it.
$dom = new DOMDocument('1.0', 'utf-8');
$dom->preserveWhiteSpace = false;
$success = $dom->load(realpath($idxFileName));
@unlink($idxFileName);
if (!$success) {
eZDebug::writeError("Unable to open index file.");
return false;
}
$root = $dom->documentElement;
if ($root->localName != 'packages') {
eZDebug::writeError("Malformed index file.");
return false;
}
$packageList = array();
foreach ($root->childNodes as $packageNode) {
if ($packageNode->localName != 'package') {
// skip unwanted chilren
continue;
}
if ($onlySitePackages && $packageNode->getAttribute('type') != 'site') {
// skip non-site packages
continue;
}
$packageAttributes = array();
foreach ($packageNode->attributes as $attributeNode) {
$packageAttributes[$attributeNode->localName] = $attributeNode->value;
}
$packageList[$packageAttributes['name']] = $packageAttributes;
}
return $packageList;
}
示例10: 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);
}
示例11: copy
static function copy( $sourceDirectory, &$destinationDirectory,
$asChild = true, $recursive = true, $includeHidden = false, $excludeItems = false )
{
if ( !is_dir( $sourceDirectory ) )
{
eZDebug::writeError( "Source $sourceDirectory is not a directory, cannot copy from it", __METHOD__ );
return false;
}
if ( !is_dir( $destinationDirectory ) )
{
eZDebug::writeError( "Destination $destinationDirectory is not a directory, cannot copy to it", __METHOD__ );
return false;
}
if ( $asChild )
{
if ( preg_match( "#^.+/([^/]+)$#", $sourceDirectory, $matches ) )
{
eZDir::mkdir( $destinationDirectory . '/' . $matches[1], eZDir::directoryPermission(), false );
$destinationDirectory .= '/' . $matches[1];
}
}
$items = eZDir::findSubitems( $sourceDirectory, 'df', false, $includeHidden, $excludeItems );
$totalItems = $items;
while ( count( $items ) > 0 )
{
$currentItems = $items;
$items = array();
foreach ( $currentItems as $item )
{
$fullPath = $sourceDirectory . '/' . $item;
if ( is_file( $fullPath ) )
eZFileHandler::copy( $fullPath, $destinationDirectory . '/' . $item );
else if ( is_dir( $fullPath ) )
{
eZDir::mkdir( $destinationDirectory . '/' . $item, eZDir::directoryPermission(), false );
$newItems = eZDir::findSubitems( $fullPath, 'df', $item, $includeHidden, $excludeItems );
$items = array_merge( $items, $newItems );
$totalItems = array_merge( $totalItems, $newItems );
unset( $newItems );
}
}
}
// eZDebugSetting::writeNotice( 'lib-ezfile-copy',
// "Copied directory $sourceDirectory to destination $destinationDirectory",
// 'eZDir::copy' );
return $totalItems;
}
示例12: 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 );
}
示例13:
$newSuffix = $suffix;
$contentVersion = eZContentObjectVersion::fetchVersion($attributeVersion, $objectID);
if ($contentVersion) {
$objectName = $imageAliasHandler->imageName($contentObjectAttribute, $contentVersion);
$objectPathString = $imageAliasHandler->imagePath($contentObjectAttribute, $contentVersion);
$newDirPath = $objectPathString;
$newFileName = $objectName . '.' . $mimeInfo['suffix'];
$newSuffix = $mimeInfo['suffix'];
$newFilePath = $newDirPath . '/' . $newFileName;
$newBaseName = $objectName;
}
if ($newFilePath != $filePath) {
if (!file_exists($newDirPath)) {
eZDir::mkdir($newDirPath, false, true);
}
eZFileHandler::copy($filePath, $newFilePath);
$filePath = $newFilePath;
$fileName = $newFileName;
$suffix = $newSuffix;
$dirPath = $newDirPath;
$baseName = $newBaseName;
}
}
}
$mimeData = eZMimeType::findByFileContents($fileName);
$imageManager->analyzeImage($mimeData);
$imageNode->setAttribute('serial_number', false);
$imageNode->setAttribute('is_valid', $isValid);
$imageNode->setAttribute('filename', $fileName);
$imageNode->setAttribute('suffix', $suffix);
$imageNode->setAttribute('basename', $baseName);
示例14: 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();
}