/** * Verification callback for an email template plain text body. * * @param string Uncompiled body * * @return boolean */ protected function _verifyBodyHtml($body) { try { $compiler = new XenForo_Template_Compiler_Email($body); $parsed = $compiler->lexAndParse(); if ($this->getOption(self::OPTION_TEST_COMPILE)) { $compiler->setFollowExternal(false); $compiler->compileParsed($parsed, $this->get('title'), 0, 0); } } catch (XenForo_Template_Compiler_Exception $e) { $this->error($e->getMessage(), 'body_html'); return false; } $this->set('body_html_parsed', serialize($parsed)); return true; }
protected function _verifyTemplateField($string, $fieldName) { $modifications = $this->_getTemplateModifications(); foreach ($modifications as $k => $modification) { if ($modification['search_location'] != $fieldName) { unset($modifications[$k]); } } $templateWithModifications = $this->_getModificationModel()->applyTemplateModifications($string, $modifications, $modificationStatuses); $standardParse = true; $parsed = null; if ($modificationStatuses) { try { $compiler = new XenForo_Template_Compiler_Email($templateWithModifications); $parsed = $compiler->lexAndParse(); if ($this->getOption(self::OPTION_TEST_COMPILE)) { $compiler->setFollowExternal(false); $compiler->compileParsed($parsed, $this->get('title'), 0, 0); } $standardParse = false; } catch (XenForo_Template_Compiler_Exception $e) { foreach ($modificationStatuses as &$status) { if (is_int($status)) { $status = 'error_compile'; } } } } if ($standardParse) { try { $compiler = new XenForo_Template_Compiler_Email($string); $parsed = $compiler->lexAndParse(); if ($this->getOption(self::OPTION_TEST_COMPILE)) { $compiler->setFollowExternal(false); $compiler->compileParsed($parsed, $this->get('title'), 0, 0); } } catch (XenForo_Template_Compiler_Exception $e) { $this->error($e->getMessage(), $fieldName); return false; } } $this->set($fieldName . '_parsed', serialize($parsed)); if (!is_array($this->_modificationStatuses)) { $this->_modificationStatuses = array(); } $this->_modificationStatuses += $modificationStatuses; return true; }