TYPO3 CMS  TYPO3_7-6
adodb-compress-bzip2.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4 @version v5.20.3 01-Jan-2016
5 @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
6 @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
7  Contributed by Ross Smith (adodb@netebb.com).
8  Released under both BSD license and Lesser GPL library license.
9  Whenever there is any discrepancy between the two licenses,
10  the BSD license will take precedence.
11  Set tabs to 4 for best viewing.
12 
13 */
14 
15 if (!function_exists('bzcompress')) {
16  trigger_error('bzip2 functions are not available', E_USER_ERROR);
17  return 0;
18 }
19 
20 /*
21 */
25  var $_block_size = null;
26 
29  var $_work_level = null;
30 
33  var $_min_length = 1;
34 
37  function getBlockSize() {
38  return $this->_block_size;
39  }
40 
43  function setBlockSize($block_size) {
44  assert('$block_size >= 1');
45  assert('$block_size <= 9');
46  $this->_block_size = (int) $block_size;
47  }
48 
51  function getWorkLevel() {
52  return $this->_work_level;
53  }
54 
57  function setWorkLevel($work_level) {
58  assert('$work_level >= 0');
59  assert('$work_level <= 250');
60  $this->_work_level = (int) $work_level;
61  }
62 
65  function getMinLength() {
66  return $this->_min_length;
67  }
68 
71  function setMinLength($min_length) {
72  assert('$min_length >= 0');
73  $this->_min_length = (int) $min_length;
74  }
75 
78  function __construct($block_size = null, $work_level = null, $min_length = null) {
79  if (!is_null($block_size)) {
80  $this->setBlockSize($block_size);
81  }
82 
83  if (!is_null($work_level)) {
84  $this->setWorkLevel($work_level);
85  }
86 
87  if (!is_null($min_length)) {
88  $this->setMinLength($min_length);
89  }
90  }
91 
94  function write($data, $key) {
95  if (strlen($data) < $this->_min_length) {
96  return $data;
97  }
98 
99  if (!is_null($this->_block_size)) {
100  if (!is_null($this->_work_level)) {
101  return bzcompress($data, $this->_block_size, $this->_work_level);
102  } else {
103  return bzcompress($data, $this->_block_size);
104  }
105  }
106 
107  return bzcompress($data);
108  }
109 
112  function read($data, $key) {
113  return $data ? bzdecompress($data) : $data;
114  }
115 
116 }
117 
118 return 1;
if(!defined('ADODB_ERROR_HANDLER_TYPE')) define('ADODB_ERROR_HANDLER_TYPE' E_USER_ERROR
__construct($block_size=null, $work_level=null, $min_length=null)