Skip to content

Commit

Permalink
Merge pull request ImpressModules#3 from fiammybe/master
Browse files Browse the repository at this point in the history
Upgrade ZIP archive creation
  • Loading branch information
fiammybe authored Feb 23, 2017
2 parents 5387779 + 725786e commit b4e00f8
Show file tree
Hide file tree
Showing 12 changed files with 120 additions and 601 deletions.
49 changes: 49 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio

*.iml

## Directory-based project format:
.idea/
# if you remove the above rule, at least ignore the following:

# User-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/dictionaries

# Sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml
# .idea/uiDesigner.xml

# Gradle:
# .idea/gradle.xml
# .idea/libraries

# Mongo Explorer plugin:
# .idea/mongoSettings.xml

## File-based project format:
*.ipr
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties

# Created by .ignore support plugin (hsz.mobi)
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[![License](https://img.shields.io/github/license/ImpressCMS/impresscms-module-imbuilding.svg?maxAge=2592000)](License.txt)
[![GitHub release](https://img.shields.io/github/release/ImpressCMS/impresscms-module-imbuilding.svg?maxAge=2592000)](https://github.com/ImpressCMS/impresscms-module-imbuilding/releases)
[![This is ImpressCMS module](https://img.shields.io/badge/ImpressCMS-module-F3AC03.svg?maxAge=2592000)](http://impresscms.org)

#imBuilding
Module to generate base code of new modules :-)

3 changes: 3 additions & 0 deletions SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Summary


6 changes: 6 additions & 0 deletions book.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"plugins": [
"add-header"
],
"pluginsConfig": {}
}
37 changes: 33 additions & 4 deletions class/Newmodule.php
Original file line number Diff line number Diff line change
Expand Up @@ -672,16 +672,45 @@ private function getAdminMenuItems() {
}

/**
* Generate zip archive of generated module source
* Generate zip archive of generated module source - based heavily on
* this response in stackoverflow :
* http://stackoverflow.com/questions/4914750/how-to-zip-a-whole-folder-using-php
*/
private function createArchive() {
//icms::$logger->disableLogger();
include_once IMBUILDING_ROOT_PATH . 'include/easyarchives/EasyArchive.class.php';
$arch = new archive;

$zip = new ZipArchive();

$fileName = $this->moduleinfo['modulename'] . '_' . time() . '.zip';
$archiveFilePath = ICMS_UPLOAD_PATH . '/imbuilding/packages/' . $fileName;
$archiveSource = ICMS_CACHE_PATH . '/imbuilding/' . $this->moduleinfo['modulename'];
$arch->make($archiveSource, $archiveFilePath);

$zip->open($archiveFilePath, ZipArchive::CREATE | ZipArchive::OVERWRITE);

// Create recursive directory iterator
/** @var SplFileInfo[] $files */
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($archiveSource),
RecursiveIteratorIterator::LEAVES_ONLY
);

foreach ($files as $name => $file)
{
// Skip directories (they would be added automatically)
if (!$file->isDir())
{
// Get real and relative path for current file
$filePath = $file->getRealPath();
$relativePath = substr($filePath, strlen($rootPath) + 1);

// Add current file to archive
$zip->addFile($filePath, $relativePath);
}
}

// Zip archive will be created only after closing object
$zip->close();

$this->archiveUrl = ICMS_UPLOAD_URL . '/imbuilding/packages/' . $fileName;
}

Expand Down
27 changes: 27 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "impresscms/impresscms-module-imbuilding",
"description": "A module to help you jumpstart development of ImpressCMS modules",
"minimum-stability": "beta",
"license": "GPL",
"authors": [
{
"name": "David Janssens (fiammybe)",
"email": "[email protected]"
},
{
"name": "INBOX International Inc.",
"email": "[email protected]"
},
{
"name": "Steve Kenow (skenow)",
"email": "[email protected]"
},
{
"name": "René Sato (sato-san)",
"email": "[email protected]"
},
{
"name": "Steffen Floher (QM-B)"
}
]
}
189 changes: 0 additions & 189 deletions include/easyarchives/EasyArchive.class.php

This file was deleted.

55 changes: 0 additions & 55 deletions include/easyarchives/EasyBzip2.class.php

This file was deleted.

Loading

0 comments on commit b4e00f8

Please sign in to comment.