~chroot64bit/zivios/gentoo-experimental

« back to all changes in this revision

Viewing changes to application/library/Zend/Pdf/Filter/Compression/Flate.php

  • Committer: Mustafa A. Hashmi
  • Date: 2008-12-04 13:32:21 UTC
  • Revision ID: mhashmi@zivios.org-20081204133221-0nd1trunwevijj38
Inclusion of new installation framework with ties to zend layout and dojo layout

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/**
 
3
 * Zend Framework
 
4
 *
 
5
 * LICENSE
 
6
 *
 
7
 * This source file is subject to the new BSD license that is bundled
 
8
 * with this package in the file LICENSE.txt.
 
9
 * It is also available through the world-wide-web at this URL:
 
10
 * http://framework.zend.com/license/new-bsd
 
11
 * If you did not receive a copy of the license and are unable to
 
12
 * obtain it through the world-wide-web, please send an email
 
13
 * to license@zend.com so we can send you a copy immediately.
 
14
 *
 
15
 * @package    Zend_Pdf
 
16
 * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
 
17
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 
18
 */
 
19
 
 
20
 
 
21
/** Zend_Pdf_Filter_Compression */
 
22
require_once 'Zend/Pdf/Filter/Compression.php';
 
23
 
 
24
 
 
25
/**
 
26
 * Flate stream filter
 
27
 *
 
28
 * @package    Zend_Pdf
 
29
 * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
 
30
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 
31
 */
 
32
class Zend_Pdf_Filter_Compression_Flate extends Zend_Pdf_Filter_Compression
 
33
{
 
34
    /**
 
35
     * Encode data
 
36
     *
 
37
     * @param string $data
 
38
     * @param array $params
 
39
     * @return string
 
40
     * @throws Zend_Pdf_Exception
 
41
     */
 
42
    public static function encode($data, $params = null)
 
43
    {
 
44
        if ($params != null) {
 
45
            $data = self::_applyEncodeParams($data, $params);
 
46
        }
 
47
 
 
48
        if (extension_loaded('zlib')) {
 
49
            $trackErrors = ini_get( "track_errors");
 
50
            ini_set('track_errors', '1');
 
51
 
 
52
            if (($output = @gzcompress($data)) === false) {
 
53
                ini_set('track_errors', $trackErrors);
 
54
                throw new Zend_Pdf_Exception($php_errormsg);
 
55
            }
 
56
 
 
57
            ini_set('track_errors', $trackErrors);
 
58
        } else {
 
59
            throw new Zend_Pdf_Exception('Not implemented yet. You have to use zlib extension.');
 
60
        }
 
61
 
 
62
        return $output;
 
63
    }
 
64
 
 
65
    /**
 
66
     * Decode data
 
67
     *
 
68
     * @param string $data
 
69
     * @param array $params
 
70
     * @return string
 
71
     * @throws Zend_Pdf_Exception
 
72
     */
 
73
    public static function decode($data, $params = null)
 
74
    {
 
75
        global $php_errormsg;
 
76
 
 
77
        if (extension_loaded('zlib')) {
 
78
            $trackErrors = ini_get( "track_errors");
 
79
            ini_set('track_errors', '1');
 
80
 
 
81
            if (($output = @gzuncompress($data)) === false) {
 
82
                ini_set('track_errors', $trackErrors);
 
83
                throw new Zend_Pdf_Exception($php_errormsg);
 
84
            }
 
85
 
 
86
            ini_set('track_errors', $trackErrors);
 
87
        } else {
 
88
            throw new Zend_Pdf_Exception('Not implemented yet');
 
89
        }
 
90
 
 
91
        if ($params !== null) {
 
92
            return self::_applyDecodeParams($output, $params);
 
93
        } else {
 
94
            return $output;
 
95
        }
 
96
    }
 
97
}