public function renderTemplate($name, $params = array(), $styleId = null, $languageId = null) { // user $user = $this->getUser(); // Template $template = new XenForo_Template_Public($name, $params); $template->setStyleId($styleId !== null ? $styleId : $user['style_id']); $template->setLanguageId($languageId !== null ? $languageId : $user['language_id']); return $template->render(); }
/** * Does any preparations necessary for outputting to be done. */ protected function _prepareForOutput() { $this->_displayStyles = XenForo_Application::get('displayStyles'); $styles = XenForo_Application::get('styles'); $smilieSprites = XenForo_Model::create('XenForo_Model_DataRegistry')->get('smilieSprites'); if (is_array($smilieSprites)) { $this->_smilieSprites = $smilieSprites; } if ($this->_styleId && isset($styles[$this->_styleId])) { $style = $styles[$this->_styleId]; } else { $style = reset($styles); } if ($style) { $properties = unserialize($style['properties']); $this->_styleId = $style['style_id']; $this->_styleModifiedDate = $style['last_modified_date']; } else { $properties = array(); $this->_styleId = 0; } $defaultProperties = XenForo_Application::get('defaultStyleProperties'); XenForo_Template_Helper_Core::setStyleProperties(XenForo_Application::mapMerge($defaultProperties, $properties), false); XenForo_Template_Public::setStyleId($this->_styleId); XenForo_Template_Abstract::setLanguageId(0); }
/** * Does any preperations necessary for outputting to be done. */ protected function _prepareForOutput() { $cacheData = XenForo_Model::create('XenForo_Model_DataRegistry')->getMulti(array('styles', 'displayStyles', 'options')); if (is_array($cacheData['displayStyles'])) { $this->_displayStyles = $cacheData['displayStyles']; } $styles = $cacheData['styles']; if (!is_array($styles)) { $styles = XenForo_Model::create('XenForo_Model_Style')->rebuildStyleCache(); } if (!is_array($cacheData['options'])) { $cacheData['options'] = XenForo_Model::create('XenForo_Model_Option')->rebuildOptionCache(); } $options = new XenForo_Options($cacheData['options']); XenForo_Application::setDefaultsFromOptions($options); XenForo_Application::set('options', $options); if ($this->_styleId && isset($styles[$this->_styleId])) { $style = $styles[$this->_styleId]; } else { $style = reset($styles); } if ($style) { $properties = unserialize($style['properties']); $this->_styleId = $style['style_id']; $this->_styleModifiedDate = $style['last_modified_date']; } else { $properties = array(); $this->_styleId = 0; } XenForo_Template_Helper_Core::setStyleProperties($properties, false); XenForo_Template_Public::setStyleId($this->_styleId); XenForo_Template_Abstract::setLanguageId(0); }
/** * Performs any pre-view rendering setup, such as getting style information and * ensuring the correct data is registered. * * @param XenForo_ControllerResponse_Abstract|null $controllerResponse */ public function preRenderView(XenForo_ControllerResponse_Abstract $controllerResponse = null) { parent::preRenderView($controllerResponse); if (!empty($this->_viewStateChanges['styleId'])) { $styleId = $this->_viewStateChanges['styleId']; $forceStyleId = true; } else { $user = XenForo_Visitor::getInstance(); $styleId = !empty($user['style_id']) ? $user['style_id'] : 0; $forceStyleId = $user['is_admin'] ? true : false; } XenForo_Template_Abstract::setLanguageId(XenForo_Phrase::getLanguageId()); $styles = XenForo_Application::isRegistered('styles') ? XenForo_Application::get('styles') : XenForo_Model::create('XenForo_Model_Style')->getAllStyles(); if ($styleId && isset($styles[$styleId]) && ($styles[$styleId]['user_selectable'] || $forceStyleId)) { $style = $styles[$styleId]; } else { $defaultStyleId = XenForo_Application::get('options')->defaultStyleId; $style = isset($styles[$defaultStyleId]) ? $styles[$defaultStyleId] : reset($styles); } $defaultProperties = XenForo_Application::get('defaultStyleProperties'); if ($style) { $properties = XenForo_Helper_Php::safeUnserialize($style['properties']); XenForo_Template_Helper_Core::setStyleProperties(XenForo_Application::mapMerge($defaultProperties, $properties)); XenForo_Template_Public::setStyleId($style['style_id']); } else { XenForo_Template_Helper_Core::setStyleProperties($defaultProperties); } // setup the default template params if ($style) { $this->_defaultTemplateParams['visitorStyle'] = $style; } // expose the user fields info array $this->_defaultTemplateParams['userFieldsInfo'] = XenForo_Application::get('userFieldsInfo'); }
/** * Does any preperations necessary for outputting to be done. */ protected function _prepareForOutput() { $styles = XenForo_Application::get('styles'); if ($this->_styleId && isset($styles[$this->_styleId])) { $style = $styles[$this->_styleId]; } else { $style = reset($styles); } if ($style) { $properties = unserialize($style['properties']); $this->_styleId = $style['style_id']; $this->_styleModifiedDate = $style['last_modified_date']; } else { $properties = array(); $this->_styleId = 0; } $languages = XenForo_Application::get('languages'); if ($this->_languageId && isset($languages[$this->_languageId])) { $language = $languages[$this->_languageId]; } else { $language = reset($languages); } if ($language) { $this->_textDirection = $language['text_direction']; $this->_languageId = $language['language_id']; } else { $this->_textDirection = 'LTR'; $this->_languageId = 0; } XenForo_Template_Helper_Core::setStyleProperties($properties, false); XenForo_Template_Public::setStyleId($this->_styleId); XenForo_Template_Abstract::setLanguageId($this->_languageId); }