Ejemplo n.º 1
0
 /**
  * Creates a ZIP package.
  *
  * @param string $fileName The zip file name
  * @param array $files Files to include in the archive
  * @param string $removePath Path to remove within the archive
  *
  * @return EcrPearArchiveZip
  */
 public static function createZip($fileName, $files, $removePath = '')
 {
     $archive = new EcrPearArchiveZip($fileName);
     return $archive->create($files, array('remove_path' => $removePath));
 }
Ejemplo n.º 2
0
 /**
  * EcrPearArchiveZip::_check_parameters()
  *
  * { Description }
  *
  * @param integer $p_error_code
  * @param string $p_error_string
  */
 function _check_parameters(&$p_params, $p_default)
 {
     // ----- Check that param is an array
     if (!is_array($p_params)) {
         $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAMETER, 'Unsupported parameter, waiting for an array');
         return EcrPearArchiveZip::errorCode();
     }
     // ----- Check that all the params are valid
     for (reset($p_params); list($v_key, $v_value) = each($p_params);) {
         if (!isset($p_default[$v_key])) {
             $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAMETER, 'Unsupported parameter with key \'' . $v_key . '\'');
             return EcrPearArchiveZip::errorCode();
         }
     }
     // ----- Set the default values
     for (reset($p_default); list($v_key, $v_value) = each($p_default);) {
         if (!isset($p_params[$v_key])) {
             $p_params[$v_key] = $p_default[$v_key];
         }
     }
     // ----- Check specific parameters
     $v_callback_list = array('callback_pre_add', 'callback_post_add', 'callback_pre_extract', 'callback_post_extract');
     for ($i = 0; $i < count($v_callback_list); $i++) {
         $v_key = $v_callback_list[$i];
         if (isset($p_params[$v_key]) && $p_params[$v_key] != '') {
             if (!function_exists($p_params[$v_key])) {
                 $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAM_VALUE, "Callback '" . $p_params[$v_key] . "()' is not an existing function for " . "parameter '" . $v_key . "'");
                 return EcrPearArchiveZip::errorCode();
             }
         }
     }
     return 1;
 }