// Compile condition tags $template = preg_replace_callback( '='.preg_quote($this->start).'if\s+([A-Z0-9_]+)'.preg_quote($this->end).'(.*)'.preg_quote($this->start).'endif\s+(\\1+)'.preg_quote($this->end).'=Usi', array(&$this, '_compile_condition'), $template );
// Compile condition tags $template = preg_replace_callback( '='.preg_quote($this->start).'if\s+([A-Z0-9_]+)'.preg_quote($this->end).'=Usi', array(&$this, '_compile_condition_start'), $template ); $template = preg_replace_callback( '='.preg_quote($this->start).'endif\s+([A-Z0-9_]+)'.preg_quote($this->end).'=Usi', array(&$this, '_compile_condition_end'), $template ); $template = preg_replace_callback( '='.preg_quote($this->start).'ifno\s+([A-Z0-9_]+)'.preg_quote($this->end).'=Usi', array(&$this, '_compile_condition_no_start'), $template ); $template = preg_replace_callback( '='.preg_quote($this->start).'endifno\s+([A-Z0-9_]+)'.preg_quote($this->end).'=Usi', array(&$this, '_compile_condition_no_end'), $template );
function _compile_condition(&$matches) { return '<?php if (!empty($' . trim($matches[1]) . ') && $' . trim($matches[1]) . ' != REPLACE_EMPTY): ?>' . $matches[2] . '<?php endif; ?>'; }
function _compile_condition_start(&$matches) { return '<?php if (!empty($' . trim($matches[1]) . ') && $' . trim($matches[1]) . ' != REPLACE_EMPTY){ ?>'; } function _compile_condition_end(&$matches) { return '<?php } ?>'; } function _compile_condition_no_start(&$matches) { return '<?php if (empty($' . trim($matches[1]) . ') || $' . trim($matches[1]) . ' == REPLACE_EMPTY){ ?>'; } function _compile_condition_no_end(&$matches) { return '<?php } ?>'; }