translation update
[phpmyadmin/last10db.git] / libraries / ob.lib.php
blob246b6a44cf1f2e7561ab8b47635a844929a122be
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
6 /**
7 * Output buffer functions for phpMyAdmin
9 * Copyright 2001 Jeremy Brand <jeremy@nirvani.net>
10 * http://www.jeremybrand.com/Jeremy/Brand/Jeremy_Brand.html
12 * Check for all the needed functions for output buffering
13 * Make some wrappers for the top and bottoms of our files.
16 /**
17 * This function be used eventually to support more modes. It is needed
18 * because both header and footer functions must know what each other is
19 * doing.
21 * @return integer the output buffer mode
23 function PMA_outBufferModeGet()
25 if (@function_exists('ob_start')) {
26 $mode = 1;
27 } else {
28 $mode = 0;
31 // If a user sets the output_handler in php.ini to ob_gzhandler, then
32 // any right frame file in phpMyAdmin will not be handled properly by
33 // the browser. My fix was to check the ini file within the
34 // PMA_outBufferModeGet() function.
36 // (Patch by Garth Gillespie, modified by Marc Delisle)
37 if (@ini_get('output_handler') == 'ob_gzhandler') {
38 $mode = 0;
40 if (@get_cfg_var('output_handler') == 'ob_gzhandler') {
41 $mode = 0;
43 // End patch
45 // If output buffering is enabled in php.ini it's not possible to
46 // add the ob_gzhandler without a warning message from php 4.3.0.
47 // Being better safe than sorry, check for any existing output handler
48 // instead of just checking the 'output_buffering' setting.
50 if (@function_exists('ob_get_level')) {
51 if (ob_get_level() > 0) {
52 $mode = 0;
56 // Zero (0) is no mode or in other words output buffering is OFF.
57 // Follow 2^0, 2^1, 2^2, 2^3 type values for the modes.
58 // Usefull if we ever decide to combine modes. Then a bitmask field of
59 // the sum of all modes will be the natural choice.
61 header('X-ob_mode: ' . $mode);
63 return $mode;
64 } // end of the 'PMA_outBufferModeGet()' function
67 /**
68 * This function will need to run at the top of all pages if output
69 * output buffering is turned on. It also needs to be passed $mode from
70 * the PMA_outBufferModeGet() function or it will be useless.
72 * @param integer the output buffer mode
74 * @return boolean whether output buffering is enabled or not
76 function PMA_outBufferPre($mode)
78 switch($mode)
80 case 1:
81 ob_start('ob_gzhandler');
82 $retval = TRUE;
83 break;
85 case 0:
86 $retval = FALSE;
87 break;
89 // loic1: php3 fix
90 default:
91 $retval = FALSE;
92 break;
93 } // end switch
95 return $retval;
96 } // end of the 'PMA_outBufferPre()' function
99 /**
100 * This function will need to run at the bottom of all pages if output
101 * buffering is turned on. It also needs to be passed $mode from the
102 * PMA_outBufferModeGet() function or it will be useless.
104 * @param integer the output buffer mode
106 * @return boolean whether data has been send from the buffer or not
108 function PMA_outBufferPost($mode)
110 switch($mode)
112 case 1:
113 # This output buffer doesn't need a footer.
114 $retval = TRUE;
115 break;
117 case 0:
118 $retval = FALSE;
119 break;
121 // loic1: php3 fix
122 default:
123 $retval = FALSE;
124 break;
125 } // end switch
127 return $retval;
128 } // end of the 'PMA_outBufferPost()' function