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 // **** hacked to htmlspecialchars() to avoid messing with text.
69 // **** PHP prior to 4.3.7 contains bugs that mess up Greek.
70 // **** removed encoding parameter, this messed up titles in older versions of php
71 // **** we deal with encoding in Language.php
72 $this->_buffer
.= htmlspecialchars($str, $this->_quoteStyle
);
76 function writeStructure($str)
78 if (is_object($str)) {
79 if (PEAR
::isError($str)) {
80 $str = "[" . $str->message
. "]";
81 // $this->_context->cleanError();
83 $str = Types
::toString($str);
87 if (defined("PHPTAL_DIRECT_OUTPUT") && count($this->_buffers
) == 0) {
90 $this->_buffer
.= $str;
96 return $this->_buffer
;