modxcms/xpdo — pull request #37 by exside (2014-05-10 14:57:22+00:00)
Title: Refactored and improved xpdozip class

Small improvements of the xpdozip class:

- just cosmetic, changed $filename to $file, as this variable actually holds the whole path to the file and not just the filename

- Refactored the constructor that the class can be loaded via $modx->getService() like that:

```
$ziparchive = MODX_ASSETS_PATH . 'somezipfile.zip';
$targetdir = MODX_ASSETS_PATH . 'target/directory/';

$modx->getService('zip', 'compression.xPDOZip', XPDO_CORE_PATH, array('file' => $ziparchive));
// then it could extracted like that
$results = $modx->zip->unpack($targetdir); // the $results variable contains an array of unpacked folders an files (full paths)
$modx->zip->close();
```
the changes look a bit ugly, but as I don't want to break any current implementations, I had to do it like that...if somebody knows a better way, please tell =)

- Made the unpack() method actually return what it seems to be supposed to return as of @return array An array of results for the operation. This wasn't the case as the ZipArchive method extractTo() returns a boolean and not an array of files/paths, so I added the logic to do that

- Improved the unpack method so it writes a directory tree if the target path does not exist, before it just failed...pclzip does this on its own

PR related to https://github.com/modxcms/revolution/pull/11356 and https://github.com/modxcms/revolution/pull/11355