Zikula 1.0.1
[ class tree: Zikula 1.0.1 ] [ index: Zikula 1.0.1 ] [ all elements ]

Source for file adodb-compress-bzip2.php

Documentation is available at adodb-compress-bzip2.php

  1. <?php
  2.  
  3. /*
  4. V4.97 22 Jan 2008  (c) 2000-2008 John Lim (jlim#natsoft.com.my). All rights reserved.
  5.          Contributed by Ross Smith (adodb@netebb.com). 
  6.   Released under both BSD license and Lesser GPL library license.
  7.   Whenever there is any discrepancy between the two licenses,
  8.   the BSD license will take precedence.
  9.       Set tabs to 4 for best viewing.
  10.  
  11. */
  12.  
  13. if (!function_exists('bzcompress')) {
  14.     trigger_error('bzip2 functions are not available'E_USER_ERROR);
  15.     return 0;
  16. }
  17.  
  18. /*
  19. */
  20.     /**
  21.      */
  22.     var $_block_size = null;
  23.  
  24.     /**
  25.      */
  26.     var $_work_level = null;
  27.  
  28.     /**
  29.      */
  30.     var $_min_length = 1;
  31.  
  32.     /**
  33.      */
  34.     function getBlockSize({
  35.         return $this->_block_size;
  36.     }
  37.  
  38.     /**
  39.      */
  40.     function setBlockSize($block_size{
  41.         assert('$block_size >= 1');
  42.         assert('$block_size <= 9');
  43.         $this->_block_size = (int) $block_size;
  44.     }
  45.  
  46.     /**
  47.      */
  48.     function getWorkLevel({
  49.         return $this->_work_level;
  50.     }
  51.  
  52.     /**
  53.      */
  54.     function setWorkLevel($work_level{
  55.         assert('$work_level >= 0');
  56.         assert('$work_level <= 250');
  57.         $this->_work_level = (int) $work_level;
  58.     }
  59.  
  60.     /**
  61.      */
  62.     function getMinLength({
  63.         return $this->_min_length;
  64.     }
  65.  
  66.     /**
  67.      */
  68.     function setMinLength($min_length{
  69.         assert('$min_length >= 0');
  70.         $this->_min_length = (int) $min_length;
  71.     }
  72.  
  73.     /**
  74.      */
  75.     function ADODB_Compress_Bzip2($block_size null$work_level null$min_length null{
  76.         if (!is_null($block_size)) {
  77.             $this->setBlockSize($block_size);
  78.         }
  79.  
  80.         if (!is_null($work_level)) {
  81.             $this->setWorkLevel($work_level);
  82.         }
  83.  
  84.         if (!is_null($min_length)) {
  85.             $this->setMinLength($min_length);
  86.         }
  87.     }
  88.  
  89.     /**
  90.      */
  91.     function write($data$key{
  92.         if (strlen($data$this->_min_length{
  93.             return $data;
  94.         }
  95.  
  96.         if (!is_null($this->_block_size)) {
  97.             if (!is_null($this->_work_level)) {
  98.                 return bzcompress($data$this->_block_size$this->_work_level);
  99.             else {
  100.                 return bzcompress($data$this->_block_size);
  101.             }
  102.         }
  103.  
  104.         return bzcompress($data);
  105.     }
  106.  
  107.     /**
  108.      */
  109.     function read($data$key{
  110.         return $data bzdecompress($data$data;
  111.     }
  112.  
  113. }
  114.  
  115. return 1;
  116.  
  117. ?>

Documentation generated on Fri, 18 Jul 2008 21:39:07 +0200 by phpDocumentor 1.4.1