setCompilerAttributes(array('for')); TagDictionary::registerTag($taginfo, __FILE__); /** * Defines an action take, should a DataSource property have been set at runtime. * The opposite of the CoreDefaultTag * @see CoreDefaultTag * @see http://wact.sourceforge.net/index.php/CoreOptionalTag * @access protected * @package WACT_TAG */ class CoreOptionalTag extends CompilerDirectiveTag { /** * @var DataBindingExpression * @access private */ var $DBE; /** * @return int PARSER_REQUIRE_PARSING * @access protected */ function preParse() { $binding = $this->getAttribute('for'); if (empty($binding)) { RaiseError('compiler', 'MISSINGREQUIREATTRIBUTE', array( 'tag' => $this->tag, 'attribute' => 'for', 'file' => $this->SourceFile, 'line' => $this->StartingLineNo)); } $this->DBE =& new DataBindingExpression($binding, $this); return PARSER_REQUIRE_PARSING; } function prepare() { $this->DBE->prepare(); parent::prepare(); } /** * @param CodeWriter * @return void * @access protected */ function preGenerate(&$code) { parent::preGenerate($code); $tempvar = $code->getTempVariable(); $this->DBE->generatePreStatement($code); $code->writePHP('$' . $tempvar . ' = '); $this->DBE->generateExpression($code); $code->writePHP(';'); $this->DBE->generatePostStatement($code); $code->writePHP('if (!empty($' . $tempvar . ') || $' . $tempvar . ' === "0" || $' . $tempvar . ' === 0) {'); } /** * @param CodeWriter * @return void * @access protected */ function postGenerate(&$code) { $code->writePHP('}'); parent::postGenerate($code); } } ?>