* @author Kornel LesiƄski * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License * @version SVN: $Id$ * @link http://phptal.org/ */ /** * TAL Specifications 1.4 * * argument ::= (['text'] | 'structure') expression * * Example: * *

* My name is .
* (My login name is * Unknown) *

* * @package PHPTAL * @subpackage Php.attribute.tal * @author Laurent Bedubourg */ class PHPTAL_Php_Attribute_TAL_OnError extends PHPTAL_Php_Attribute { public function before(PHPTAL_Php_CodeWriter $codewriter) { $codewriter->doTry(); $codewriter->pushCode('ob_start()'); } public function after(PHPTAL_Php_CodeWriter $codewriter) { $var = $codewriter->createTempVariable(); $codewriter->pushCode('ob_end_flush()'); $codewriter->doCatch('Exception '.$var); $codewriter->pushCode('$tpl->addError('.$var.')'); $codewriter->pushCode('ob_end_clean()'); $expression = $this->extractEchoType($this->expression); $code = $codewriter->evaluateExpression($expression); switch ($code) { case PHPTAL_Php_TalesInternal::NOTHING_KEYWORD: break; case PHPTAL_Php_TalesInternal::DEFAULT_KEYWORD: $codewriter->pushHTML('
');
                $codewriter->doEcho($var);
                $codewriter->pushHTML('
'); break; default: $this->doEchoAttribute($codewriter, $code); break; } $codewriter->doEnd('catch'); $codewriter->recycleTempVariable($var); } }