Пример #1
0
 /**
  * Gets the view renderer for the specified response type.
  *
  * @param string Response type (eg, html, xml, json)
  *
  * @return XenForo_ViewRenderer_Abstract
  */
 protected function _getViewRenderer($responseType)
 {
     $viewRenderer = $this->getViewRenderer(self::$_fc->getResponse(), $responseType, self::$_fc->getRequest(), self::$_fc->getDependencies());
     if ($viewRenderer) {
         return $viewRenderer;
     }
     return $this->_viewRenderer;
 }
Пример #2
0
 public static function frontControllerPreView(XenForo_FrontController $fc, XenForo_ControllerResponse_Abstract &$controllerResponse, XenForo_ViewRenderer_Abstract &$viewRenderer, array &$containerParams)
 {
     $dependencies = $fc->getDependencies();
     if ($dependencies instanceof XenForo_Dependencies_Admin) {
         if ($controllerResponse->controllerAction == 'RunDeferred') {
             return;
         }
         $xenAddons = XenForo_Application::get('addOns');
         if (empty($xenAddons['Brivium_AdminStyleSystem'])) {
             return;
         }
         $dataRegistryModel = self::getModelFromCache('XenForo_Model_DataRegistry');
         $dataRegistries = $dataRegistryModel->getMulti(array('adminStyles', 'BRASS_rebuildTemplate'));
         $adminStyles = !empty($dataRegistries['adminStyles']) ? $dataRegistries['adminStyles'] : false;
         if (!is_array($adminStyles)) {
             $styleModel = XenForo_Model::create('XenForo_Model_Style');
             $styleModel->setAdminStyles(true);
             $adminStyles = $styleModel->rebuildStyleCache();
         }
         XenForo_Application::set('adminStyles', $adminStyles);
         if (!empty($dataRegistries['BRASS_rebuildTemplate']) && $dataRegistries['BRASS_rebuildTemplate'] < XenForo_Application::$time - 60) {
             XenForo_Application::defer('Atomic', array('simple' => array('Brivium_AdminStyleSystem_Deferred_RebuildAllAdminTemplate', 'Brivium_AdminStyleSystem_Deferred_AdminTemplateReparse', 'Brivium_AdminStyleSystem_Deferred_AdminTemplate')), 'BRASS_rebuildAllAdminTemplates', true);
             return;
         }
         $brAdminTemplateModel = self::getModelFromCache('Brivium_AdminStyleSystem_Model_AdminTemplate');
         if (!$brAdminTemplateModel->isRebuildTemplate()) {
             return;
         }
         $tmpDependencies = new Brivium_AdminStyleSystem_Dependencies_Admin();
         list(self::$_defaultTemplateParams, self::$_setStyleProperties) = $tmpDependencies->preRenderView();
         if ($viewRenderer instanceof XenForo_ViewRenderer_HtmlAdmin) {
             $viewRenderer = new Brivium_AdminStyleSystem_ViewRenderer_HtmlAdmin($dependencies, $fc->getResponse(), $fc->getRequest());
         } elseif ($viewRenderer instanceof XenForo_ViewRenderer_Json) {
             $viewRenderer = new XenForo_ViewRenderer_Json($tmpDependencies, $fc->getResponse(), $fc->getRequest());
         }
     }
 }
Пример #3
0
 public static function front_controller_pre_route(XenForo_FrontController $fc)
 {
     // use cookie flag to change web UI interface to match requested language_id from api
     $request = $fc->getRequest();
     $apiLanguageId = $request->getParam('_apiLanguageId');
     if (!empty($apiLanguageId) && preg_match('#^(?<timestamp>\\d+) (?<data>.+)$#', $apiLanguageId, $matches)) {
         try {
             $languageId = bdApi_Crypt::decryptTypeOne($matches['data'], $matches['timestamp']);
             if ($languageId > 0) {
                 $cookiePrefix = XenForo_Application::getConfig()->get('cookie')->get('prefix');
                 XenForo_Helper_Cookie::setCookie('language_id', $languageId);
                 $_COOKIE[$cookiePrefix . 'language_id'] = $languageId;
                 $fc->getResponse()->setHeader('X-Api-Language', $languageId);
             }
         } catch (XenForo_Exception $e) {
             // ignore
         }
     }
 }
Пример #4
0
 /**
  *
  * @return boolean true if response code match, false otherwise
  * @param int $responseCode
  */
 protected function _assertResponseCode($responseCode)
 {
     if ($this->_fc->getResponse()->getHttpResponseCode() != $responseCode) {
         throw new XenForo_Exception('Incorrect response code');
     }
 }
Пример #5
0
 public static function front_controller_post_view(XenForo_FrontController $fc, &$output)
 {
     if (defined('WIDGET_FRAMEWORK_LOADED')) {
         $core = WidgetFramework_Core::getInstance();
         if (!empty($_REQUEST['_getRender']) && !empty($_REQUEST['_renderedIds'])) {
             $controllerResponse = new XenForo_ControllerResponse_View();
             $controllerResponse->viewName = 'WidgetFramework_ViewPublic_Widget_Render';
             $controllerResponse->params = $_REQUEST;
             $viewRenderer = $fc->getDependencies()->getViewRenderer($fc->getResponse(), 'json', $fc->getRequest());
             $output = $fc->renderView($controllerResponse, $viewRenderer);
         }
         if (WidgetFramework_Option::get('layoutEditorEnabled')) {
             foreach (array_keys(self::$_layoutEditorRendered) as $key) {
                 $fc->getResponse()->setHeader('X-Widget-Framework-Rendered', $key, false);
             }
         }
         $core->shutdown();
     }
 }