AdminPageFramework_Zip::compress PHP Method

compress() public method

public compress ( )
    public function compress()
    {
        if (!$this->isFeasible($this->sSource)) {
            return false;
        }
        if (file_exists($this->sDestination)) {
            unlink($this->sDestination);
        }
        $_oZip = new ZipArchive();
        if (!$_oZip->open($this->sDestination, ZIPARCHIVE::CREATE)) {
            return false;
        }
        $this->sSource = $this->_getSanitizedSourcePath($this->sSource);
        $_aMethods = array('unknown' => '_replyToReturnFalse', 'directory' => '_replyToCompressDirectory', 'file' => '_replyToCompressFile');
        $_sMethodName = $_aMethods[$this->_getSourceType($this->sSource)];
        return call_user_func_array(array($this, $_sMethodName), array($_oZip, $this->sSource, $this->aCallbacks, $this->aOptions['include_directory'], $this->aOptions['additional_source_directories']));
    }

Usage Example

 /**
  * Generates the framework zip data.
  * 
  * @since       3.5.4
  * @return      string      The binary zip data.
  */
 private function _getDownloadFrameworkZipFile($sFrameworkDirPath, $sDestinationPath)
 {
     $_oZip = new AdminPageFramework_Zip($sFrameworkDirPath, $sDestinationPath, array('include_directory' => false, 'additional_source_directories' => apply_filters(AdminPageFrameworkLoader_Registry::HOOK_SLUG . '_filter_generator_additional_source_directories', array())), array('file_name' => array($this, '_replyToModifyPathInArchive'), 'directory_name' => array($this, '_replyToModifyPathInArchive'), 'file_contents' => array($this, '_replyToModifyFileContents')));
     $_bSucceed = $_oZip->compress();
     if (!$_bSucceed) {
         return '';
     }
     return file_get_contents($sDestinationPath);
 }
All Usage Examples Of AdminPageFramework_Zip::compress