2 /* vim: set expandtab tabstop=4 shiftwidth=4: */
4 // Copyright (c) 2003 Laurent Bedubourg
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // Authors: Laurent Bedubourg <laurent.bedubourg@free.fr>
23 class PHPTAL_OutputControl
26 var $_buffers = array();
27 var $_quoteStyle = ENT_COMPAT
;
28 var $_encoding = 'UTF-8';
31 function PHPTAL_OutputControl(&$context, $encoding='UTF-8')
33 $this->_context
= $context;
34 $this->_encoding
= $encoding;
39 $this->_buffers
[] = $this->_buffer
;
45 $res = $this->_buffer
;
46 $this->_buffer
= array_pop($this->_buffers
);
52 if (is_object($str)) {
53 if (PEAR
::isError($str)) {
54 $str = "[". get_class($str) . ": " . $str->message
. "]";
55 // $this->_context->cleanError();
57 $str = Types
::toString($str);
61 if (defined("PHPTAL_DIRECT_OUTPUT") && count($this->_buffers
) == 0) {
62 // echo htmlentities($str);
63 // support for cyrillic strings thanks to Igor E. Poteryaev
64 echo htmlentities($str, $this->_quoteStyle
, $this->_encoding
);
66 // $this->_buffer .= htmlentities($str);
67 // support for cyrillic strings thanks to Igor E. Poteryaev
68 $this->_buffer
.= htmlentities($str, $this->_quoteStyle
, $this->_encoding
);
72 function writeStructure($str)
74 if (is_object($str)) {
75 if (PEAR
::isError($str)) {
76 $str = "[" . $str->message
. "]";
77 // $this->_context->cleanError();
79 $str = Types
::toString($str);
83 if (defined("PHPTAL_DIRECT_OUTPUT") && count($this->_buffers
) == 0) {
86 $this->_buffer
.= $str;
92 return $this->_buffer
;