本文整理汇总了PHP中tao_helpers_File::addFilesToZip方法的典型用法代码示例。如果您正苦于以下问题:PHP tao_helpers_File::addFilesToZip方法的具体用法?PHP tao_helpers_File::addFilesToZip怎么用?PHP tao_helpers_File::addFilesToZip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tao_helpers_File
的用法示例。
在下文中一共展示了tao_helpers_File::addFilesToZip方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addFile
/**
* Add files or folders (and their content) to the Zip Archive that will contain all the files to the current export session.
* For instance, if you want to copy the file 'taoItems/data/i123/item.xml' as 'myitem.xml' to your archive call addFile('path_to_item_location/item.xml', 'myitem.xml').
* As a result, you will get a file entry in the final ZIP archive at '/i123/myitem.xml'.
*
* @param string | StreamInterface $src The path to the source file or folder to copy into the ZIP Archive.
* @param string *dest The <u>relative</u> to the destination within the ZIP archive.
* @return integer The amount of files that were transfered from TAO to the ZIP archive within the method call.
*/
public function addFile($src, $dest)
{
$zip = $this->getZip();
return tao_helpers_File::addFilesToZip($zip, $src, $dest);
}
示例2: exportCompiledDelivery
/**
* export a compiled delivery into an archive
*
* @param core_kernel_classes_Resource $compiledDelivery
* @throws Exception
* @return string
*/
public static function exportCompiledDelivery(core_kernel_classes_Resource $compiledDelivery)
{
$fileName = tao_helpers_Display::textCleaner($compiledDelivery->getLabel()) . '.zip';
$path = tao_helpers_File::concat(array(tao_helpers_Export::getExportPath(), $fileName));
if (!tao_helpers_File::securityCheck($path, true)) {
throw new Exception('Unauthorized file name');
}
$zipArchive = new ZipArchive();
if ($zipArchive->open($path, ZipArchive::CREATE) !== true) {
throw new Exception('Unable to create archive at ' . $path);
}
$taoDeliveryVersion = common_ext_ExtensionsManager::singleton()->getInstalledVersion('taoDelivery');
$data = array('dir' => array(), 'label' => $compiledDelivery->getLabel(), 'version' => $taoDeliveryVersion);
$directories = $compiledDelivery->getPropertyValues(new core_kernel_classes_Property(PROPERTY_COMPILEDDELIVERY_DIRECTORY));
foreach ($directories as $id) {
$directory = tao_models_classes_service_FileStorage::singleton()->getDirectoryById($id);
tao_helpers_File::addFilesToZip($zipArchive, $directory->getPath(), $directory->getRelativePath());
$data['dir'][$id] = $directory->getRelativePath();
}
$runtime = $compiledDelivery->getUniquePropertyValue(new core_kernel_classes_Property(PROPERTY_COMPILEDDELIVERY_RUNTIME));
$serviceCall = tao_models_classes_service_ServiceCall::fromResource($runtime);
$data['runtime'] = base64_encode($serviceCall->serializeToString());
$rdfExporter = new tao_models_classes_export_RdfExporter();
$rdfdata = $rdfExporter->getRdfString(array($compiledDelivery));
if (!$zipArchive->addFromString('delivery.rdf', $rdfdata)) {
throw common_Exception('Unable to add metadata to exported delivery assembly');
}
$data['meta'] = 'delivery.rdf';
$content = json_encode($data);
//'<?php return '.common_Utils::toPHPVariableString($data).";";
if (!$zipArchive->addFromString(self::MANIFEST_FILE, $content)) {
$zipArchive->close();
unlink($path);
throw common_Exception('Unable to add manifest to exported delivery assembly');
}
$zipArchive->close();
return $path;
}
示例3: recreatePackage
public function recreatePackage($directory, $destination)
{
$zipArchive = new \ZipArchive();
if ($zipArchive->open($destination, \ZipArchive::CREATE) !== TRUE) {
throw new \common_Exception('Unable to create zipfile ' . $path);
}
\tao_helpers_File::addFilesToZip($zipArchive, $directory, DIRECTORY_SEPARATOR);
$zipArchive->close();
}