protected function _renderTemplate($template, array $params = array()) { extract($params); $compiler = new XenForo_Template_Compiler($template); XenForo_Application::disablePhpErrorHandler(); @eval($compiler->compile()); XenForo_Application::enablePhpErrorHandler(); return htmlspecialchars_decode($__output, ENT_QUOTES); }
public function __construct() { $startTime = microtime(true); $xf_path = Yii::getPathOfAlias('webroot') . '/forum'; Yii::registerAutoloader(array('XenforeLoader', 'autoload'), true); XenForo_Autoloader::getInstance()->setupAutoloader($xf_path . '/library'); XenForo_Application::initialize($xf_path . '/library', $xf_path); XenForo_Application::set('page_start_time', $startTime); XenForo_Application::disablePhpErrorHandler(); error_reporting(E_ALL ^ E_NOTICE ^ E_USER_NOTICE ^ E_WARNING); $dependencies = new XenForo_Dependencies_Public(); $dependencies->preLoadData(); XenForo_Session::startPublicSession(); $this->visitor = XenForo_Visitor::getInstance(); /*$fc = new XenForo_FrontController(new XenForo_Dependencies_Public()); ob_start(); $fc->run(); $content = ob_get_clean();*/ }
/** * Default consturctor, instalizes XenForo classes and models. */ public function __construct() { $this->xfDir = dirname(__FILE__); require_once $this->xfDir . '/library/XenForo/Autoloader.php'; XenForo_Autoloader::getInstance()->setupAutoloader($this->xfDir . '/library'); XenForo_Application::initialize($this->xfDir . '/library', $this->xfDir); XenForo_Application::set('page_start_time', microtime(TRUE)); $deps = new XenForo_Dependencies_Public(); $deps->preLoadData(); // Disable XenForo's PHP error handler. XenForo_Application::disablePhpErrorHandler(); // Enable error logging for PHP. error_reporting(E_ALL & ~E_NOTICE); $this->models = new Models(); // TODO: Don't create models on init, only create them if they're being used (see Models::checkModel($model_name, $model)). $this->getModels()->setUserModel(XenForo_Model::create('XenForo_Model_User')); $this->getModels()->setAlertModel(XenForo_Model::create('XenForo_Model_Alert')); $this->getModels()->setUserFieldModel(XenForo_Model::create('XenForo_Model_UserField')); $this->getModels()->setAvatarModel(XenForo_Model::create('XenForo_Model_Avatar')); $this->getModels()->setModel('addon', XenForo_Model::create('XenForo_Model_AddOn')); $this->getModels()->setModel('database', XenForo_Application::get('db')); if ($this->hasAddon('XenResource') && $this->hasModel('XenResource_Model_Resource')) { $this->getModels()->setModel('resource', XenForo_Model::create('XenResource_Model_Resource')); } }
/** * Prepares the subject, plain text body, and HTML body. * * @param string|null $emailTitle Title of email to send. If not specified, uses value from consructor. * @param array|null $params Params to pass to email template. If not specified, uses value from constructor. * * @return array|false False if the template can't be found; otherwise array with subject, bodyText, and bodyHtml keys */ public function prepareMailContents($emailTitle = null, array $params = null) { if ($emailTitle === null) { $emailTitle = $this->_emailTitle; } if ($params === null) { $params = $this->_params; } $__template = $this->_loadEmailTemplate($emailTitle); if (!$__template) { return false; } $__defaultLanguage = XenForo_Template_Helper_Core::getDefaultLanguage(); $__languages = XenForo_Application::get('languages'); if (isset($__languages[$this->_languageId])) { XenForo_Template_Helper_Core::setDefaultLanguage($__languages[$this->_languageId]); } $xenOptions = XenForo_Application::get('options')->getOptions(); extract($params); $__oldErrors = error_reporting(E_ALL & ~E_NOTICE); XenForo_Application::disablePhpErrorHandler(); // these variables come from the $__template $__subject = $__bodyText = $__bodyHtml = ''; eval($__template); XenForo_Application::enablePhpErrorHandler(); error_reporting($__oldErrors); XenForo_Template_Helper_Core::setDefaultLanguage($__defaultLanguage); return array('subject' => $__subject, 'bodyText' => $__bodyText, 'bodyHtml' => $__bodyHtml); }
//****************************************************************************** // Pull instantiate and pull the template from the Xenforo system //****************************************************************************** if (!is_admin()) { $XenDynamic_container = true; $startTime = microtime(true); $XenDynamic_indexFile = "../../../.." . getThemeOption("xenforo_path"); $fileDir = dirname(__FILE__) . "/{$XenDynamic_indexFile}"; // $fileDir = ABSPATH . getThemeOption("xenforo_path"); // $fileDir = dirname(__FILE__) . "/../../../.." . getThemeOption("xenforo_path"); if (!class_exists("XenForo_Autoloader")) { require $fileDir . '/library/XenForo/Autoloader.php'; XenForo_Autoloader::getInstance()->setupAutoloader($fileDir . '/library'); XenForo_Application::initialize($fileDir . '/library', $fileDir); XenForo_Application::set('page_start_time', $startTime); XenForo_Application::disablePhpErrorHandler(); error_reporting(E_ALL ^ E_NOTICE ^ E_USER_NOTICE ^ E_WARNING); } ob_start(); $XenDynamic_fc = new RCBD_XenDynamic_FrontController(new XenForo_Dependencies_Public()); $xenforoOutput = $XenDynamic_fc->runXenDynamic(ob_get_clean()); global $templateParts; $templateParts = getTemplateParts($xenforoOutput, getThemeOption("xenforo_path")); } //****************************************************************************** // This function takes the raw buffer from Xenforo and breaks it into the header // and the rest of the file it also does some jquery replacements for elements // that need to be changed on all wordpress templates. // RCBD TODO: It's ugly and I'm going to try to find a better way to do it. //****************************************************************************** function getTemplateParts($buffer, $fileDir)
/** * Prepares the subject, plain text body, and HTML body. * * @param string|null $emailTitle Title of email to send. If not specified, uses value from consructor. * @param array|null $params Params to pass to email template. If not specified, uses value from constructor. * * @return array|false False if the template can't be found; otherwise array with subject, bodyText, and bodyHtml keys */ public function prepareMailContents($emailTitle = null, array $params = null) { if ($emailTitle === null) { $emailTitle = $this->_emailTitle; } if ($params === null) { $params = $this->_params; } $__template = $this->_loadEmailTemplate($emailTitle); if (!$__template) { return false; } $__defaultLanguage = XenForo_Template_Helper_Core::getDefaultLanguage(); $__languages = XenForo_Application::get('languages'); if (isset($__languages[$this->_languageId])) { XenForo_Template_Helper_Core::setDefaultLanguage($__languages[$this->_languageId]); } $xenOptions = XenForo_Application::get('options')->getOptions(); extract($params); $emailLanguage = XenForo_Template_Helper_Core::getDefaultLanguage(); $emailIsRtl = isset($emailLanguage['text_direction']) && $emailLanguage['text_direction'] == 'RTL'; $__oldErrors = error_reporting(E_ALL & ~E_NOTICE); XenForo_Application::disablePhpErrorHandler(); // these variables come from the $__template $__subject = $__bodyText = $__bodyHtml = ''; eval($__template); XenForo_Application::enablePhpErrorHandler(); error_reporting($__oldErrors); XenForo_Template_Helper_Core::setDefaultLanguage($__defaultLanguage); if ($emailIsRtl) { $__bodyHtml = preg_replace_callback('/<rtlcss>(.*)<\\/rtlcss>/sU', array($this, '_replaceRtlCss'), $__bodyHtml); } else { $__bodyHtml = preg_replace('/<rtlcss>(.*)<\\/rtlcss>/sU', '\\1', $__bodyHtml); } return array('subject' => $__subject, 'bodyText' => $__bodyText, 'bodyHtml' => $__bodyHtml); }