本文整理汇总了PHP中Zip::create_zip方法的典型用法代码示例。如果您正苦于以下问题:PHP Zip::create_zip方法的具体用法?PHP Zip::create_zip怎么用?PHP Zip::create_zip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zip
的用法示例。
在下文中一共展示了Zip::create_zip方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_zip
public function action_zip($articulo_id = null)
{
is_null($articulo_id) and Response::redirect('diagramador');
$articulos = Model_Articulo::find('all', array('related' => array('fotos', 'seccion'), 'where' => array(array('id', '=', $articulo_id))));
$files_to_zip = array();
$archivo_informacion = '';
foreach ($articulos as $articulo) {
$archivo_informacion .= "Nombre del Articulo: " . $articulo->nombre . "\n";
$archivo_informacion .= "Seccion del Articulo: " . $articulo->seccion->descripcion . "\n";
$archivo_informacion .= "Fecha del Articulo: " . date('Y-m-d H:i:s', $articulo->fecha_publicacion) . "\n";
$archivo_informacion .= "\n ==========================\n";
foreach ($articulo->fotos as $foto) {
if ($foto->estado == 1) {
array_push($files_to_zip, $foto->imagen);
$nombre_archivo = str_ireplace(".jpg", "-" . $articulo->pagina->descripcion . ".jpg", $foto->imagen);
$pieces = explode("/", $nombre_archivo);
$count_foto = count($pieces);
$nombre_archivo = $pieces[$count_foto - 1];
$archivo_informacion .= $nombre_archivo . "\n" . "Medida: " . $foto->dimension->descipcion . "\n" . "Pagina: " . $articulo->pagina->descripcion . "\n ==========================\n";
}
}
}
$time = time();
File::create(DOCROOT . "zip/", "info_{$articulo_id}_{$time}.txt", $archivo_informacion);
array_push($files_to_zip, "/gr/public/zip/info_{$articulo_id}_{$time}.txt");
Zip::create_zip($files_to_zip, $articulo_id, true, $time, $articulo->pagina->descripcion);
}
示例2: action_zip
public function action_zip($articulo_id)
{
include DOCROOT . 'phpthumb/phpthumb.class.php';
\Config::load('phpthumb');
$document_root = str_replace("\\", "/", Config::get('document_root'));
is_null($articulo_id) and Response::redirect('articulo');
$articulo = Model_Articulo::find('first', array('related' => array('fotos', 'seccion'), 'where' => array(array('id', '=', $articulo_id))));
$fotos_web = null;
foreach ($articulo->fotos as $foto) {
$phpThumb = new phpThumb();
$phpThumb->setParameter('w', Config::get('web_size'));
$phpThumb->setParameter('q', 75);
$phpThumb->setParameter('aoe', true);
$phpThumb->setParameter('config_output_format', 'jpeg');
$phpThumb->setParameter('f', 'jpeg');
$nombre_archivo = str_ireplace(".jpg", Config::get('photos_texto') . '.jpg', $foto->imagen);
$pieces = explode("/", $nombre_archivo);
$count_foto = count($pieces);
$nombre_archivo = $pieces[$count_foto - 1];
$output_filename = $document_root . "/web/" . $nombre_archivo;
$phpThumb->setSourceData(file_get_contents($document_root . $foto->imagen));
if ($phpThumb->GenerateThumbnail()) {
if ($phpThumb->RenderToFile($output_filename)) {
Log::info('Imagen para web generada con exito' . $output_filename);
$fotos_web[] = $output_filename;
} else {
Log::info('Error al generar imagen para web ' . $phpThumb->debugmessages);
}
$phpThumb->purgeTempFiles();
} else {
Log::info('Error Fatal al generar imagen para web ' . $phpThumb->fatalerror . "|" . $phpThumb->debugmessages);
}
unset($phpThumb);
}
$time = time();
Zip::create_zip($fotos_web, $articulo_id, true, $time);
}
示例3: generate
//.........这里部分代码省略.........
fwrite($fp, json_encode($json));
fclose($fp);
$files[] = array('source' => 'data_products.json', 'dest' => 'data_products.json');
///generate categories
$json_categories = array();
$categories = array();
foreach ($this->request->post['selected'] as $product_id) {
$result_categories = $this->model_catalog_product->getProductCategories($product_id);
foreach ($result_categories as $category_id) {
if (!in_array($category_id, $categories)) {
$categories[] = $category_id;
}
}
}
foreach ($categories as $category_id) {
$json_categories[] = $this->model_opentshirts_product_export->dump_category($category_id);
$files = array_merge($files, $this->model_opentshirts_product_export->dump_category_files($category_id));
}
$fp = fopen('data_categories.json', 'w');
fwrite($fp, json_encode($json_categories));
fclose($fp);
$files[] = array('source' => 'data_categories.json', 'dest' => 'data_categories.json');
/// end generate categories
///generate colors
$json_colors = array();
$colors = array();
$this->load->model('product/product');
foreach ($this->request->post['selected'] as $product_id) {
$result_colors = $this->model_product_product->getColors($product_id);
foreach ($result_colors as $id_product_color) {
if (!in_array($id_product_color, $colors)) {
$colors[] = $id_product_color;
}
}
}
foreach ($colors as $id_product_color) {
$json_colors[] = $this->model_opentshirts_product_export->dump_product_color($id_product_color);
}
$fp = fopen('data_colors.json', 'w');
fwrite($fp, json_encode($json_colors));
fclose($fp);
$files[] = array('source' => 'data_colors.json', 'dest' => 'data_colors.json');
/// end generate colors
///generate sizes
$json_sizes = array();
$sizes = array();
$this->load->model('product/product');
foreach ($this->request->post['selected'] as $product_id) {
$result_sizes = $this->model_product_product->getSizes($product_id);
foreach ($result_sizes as $id_product_size) {
if (!in_array($id_product_size, $sizes)) {
$sizes[] = $id_product_size;
}
}
}
foreach ($sizes as $id_product_size) {
$json_sizes[] = $this->model_opentshirts_product_export->dump_product_size($id_product_size);
}
$fp = fopen('data_sizes.json', 'w');
fwrite($fp, json_encode($json_sizes));
fclose($fp);
$files[] = array('source' => 'data_sizes.json', 'dest' => 'data_sizes.json');
/// end generate sizes
///generate manufacturers
$json_manufacturers = array();
$manufacturers = array();
foreach ($this->request->post['selected'] as $product_id) {
$result = $this->model_catalog_product->getProduct($product_id);
$manufacturer_id = $result['manufacturer_id'];
if ($manufacturer_id) {
if (!in_array($manufacturer_id, $manufacturers)) {
$manufacturers[] = $manufacturer_id;
}
}
}
foreach ($manufacturers as $manufacturer_id) {
$json_manufacturers[] = $this->model_opentshirts_product_export->dump_manufacturer($manufacturer_id);
$files = array_merge($files, $this->model_opentshirts_product_export->dump_manufacturer_files($manufacturer_id));
}
$fp = fopen('data_manufacturers.json', 'w');
fwrite($fp, json_encode($json_manufacturers));
fclose($fp);
$files[] = array('source' => 'data_manufacturers.json', 'dest' => 'data_manufacturers.json');
/// end generate manufacturers
$date = date('Y-m-d G-i-s');
$part = isset($this->request->get['page']) ? "part-" . $this->request->get['page'] . '-' : '';
$installer = DIR_DOWNLOAD . 'product-export-' . $part . $date . '.zip';
$this->load->library('zip');
$zip = new Zip();
$zip->create_zip($files, $installer, false);
$this->session->data['product_export_link'] = HTTP_CATALOG . basename(DIR_DOWNLOAD) . '/' . basename($installer);
$this->session->data['success'] = $this->language->get('text_success');
@unlink('data_products.json');
@unlink('data_categories.json');
@unlink('data_colors.json');
@unlink('data_sizes.json');
@unlink('data_manufacturers.json');
}
$this->index();
}