/** * Renders the specified template and returns the output. * * @return string */ public function render() { $__template = $this->_loadTemplate($this->_templateName); if ($__template === '') { return ''; } XenForo_Phrase::loadPhrases(); set_error_handler(array($this, 'handleTemplateError')); $this->_templateErrors = array(); $__output = $this->_renderInternal($__template, $__extraData); restore_error_handler(); XenForo_CodeEvent::fire('template_post_render', array($this->_templateName, &$__output, &$__extraData, $this), $this->_templateName); if (is_array($__extraData) && !empty($__extraData)) { $this->_mergeExtraContainerData($__extraData); } if ($this->_templateErrors && XenForo_Application::debugMode()) { if ($this->_usingTemplateFiles()) { $templateCode = file_get_contents($__template); } else { $templateCode = $__template; } $lines = preg_split('/\\r?\\n/', $__template); echo "<div class=\"baseHtml\"><h4>Template Errors: " . htmlspecialchars($this->_templateName) . "</h4><ol>\n"; foreach ($this->_templateErrors as $error) { $contextLine = $error['line'] > 1 ? $error['line'] - 2 : 0; $context = array_slice($lines, $contextLine, 3, true); echo "\t<li><i>" . htmlspecialchars($error['error']) . "</i> in " . htmlspecialchars($error['file']) . ", line {$error['line']}"; if ($context) { echo ": <pre>"; foreach ($context as $lineNum => $contextLine) { echo $lineNum + 1 . ": " . htmlspecialchars($contextLine) . "\n"; } echo "</pre>"; } echo "</li>\n"; } echo "</ol></div>\n\n"; } return $__output === null ? '' : $__output; }