/** * Render the CSS version of the... CSS! * * @return string */ public function renderCss() { XenForo_Template_Abstract::setLanguageId(0); $bbCodeCache = $this->_params['bbCodeCache']; $templateParams = array('displayStyles' => array(), 'smilieSprites' => $this->_params['smilieSprites'], 'xenOptions' => XenForo_Application::get('options')->getOptions(), 'customBbCodes' => !empty($bbCodeCache['bbCodes']) ? $bbCodeCache['bbCodes'] : array(), 'dir' => $this->_params['dir'], 'pageIsRtl' => $this->_params['dir'] == 'RTL'); $templates = array(); foreach ($this->_params['css'] as $cssTemplate) { if (strpos($cssTemplate, 'public:') === 0) { $templates[$cssTemplate] = new XenForo_Template_Public(substr($cssTemplate, strlen('public:')), $templateParams); } else { $templates[$cssTemplate] = $this->createTemplateObject($cssTemplate, $templateParams); } } if (XenForo_Application::isRegistered('adminStyleModifiedDate')) { $modifyDate = XenForo_Application::get('adminStyleModifiedDate'); } else { $modifyDate = XenForo_Application::$time; } $this->_response->setHeader('Expires', 'Wed, 01 Jan 2020 00:00:00 GMT', true); $this->_response->setHeader('Last-Modified', gmdate('D, d M Y H:i:s', $modifyDate) . ' GMT', true); $this->_response->setHeader('Cache-Control', 'private', true); $css = XenForo_CssOutput::renderCssFromObjects($templates, true); $css = XenForo_CssOutput::prepareCssForOutput($css, $this->_params['dir'], false); return $css; }
public function actionAdmin() { /** @var XenForo_Model_Admin $adminModel */ $adminModel = $this->getModelFromCache('XenForo_Model_Admin'); $visitor = XenForo_Visitor::getInstance(); $admin = $adminModel->getAdminById($visitor->user_id); if ($this->_input->inRequest('language_id')) { $this->_checkCsrfFromToken($this->_input->filterSingle('_xfToken', XenForo_Input::STRING)); $languageId = $this->_input->filterSingle('language_id', XenForo_Input::UINT); if ($languageId) { $languages = XenForo_Application::isRegistered('languages') ? XenForo_Application::get('languages') : XenForo_Model::create('XenForo_Model_Language')->getAllLanguagesForCache(); if (!isset($languages[$languageId])) { $languageId = 0; } } $dw = XenForo_DataWriter::create('XenForo_DataWriter_Admin'); $dw->setExistingData($admin); $dw->set('admin_language_id', $languageId); $dw->save(); return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $this->getDynamicRedirect(false, false)); } else { $viewParams = array('languages' => $this->getModelFromCache('XenForo_Model_Language')->getAllLanguages(), 'redirect' => $this->_input->filterSingle('redirect', XenForo_Input::STRING)); return $this->responseView('XenForo_ViewAdmin_Language_Admin', 'language_chooser', $viewParams); } }
/** * * @see XenForo_Route_Prefix_Forums::buildLink() */ public function buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, array &$extraParams) { if (isset($data['social_forum_id'])) { if (ThemeHouse_SocialGroups_SocialForum::hasInstance()) { $socialForum = ThemeHouse_SocialGroups_SocialForum::getInstance()->toArray(); } else { $socialForum = $data; } $class = XenForo_Application::resolveDynamicClass('ThemeHouse_SocialGroups_Route_Prefix_SocialForums', 'route_prefix'); $router = new $class(); $link = $router->buildLink('social-forums', 'social-forums', $action, $extension, $socialForum, $extraParams); if (XenForo_Application::isRegistered('routeFiltersOut')) { $routeFilters = XenForo_Application::get('routeFiltersOut'); if (isset($routeFilters['social-forums'])) { foreach ($routeFilters['social-forums'] as $filter) { if (array_key_exists('find_route', $filter) && array_key_exists('replace_route', $filter)) { list($from, $to) = XenForo_Link::translateRouteFilterToRegex($filter['find_route'], $filter['replace_route']); $newLink = preg_replace($from, $to, $link); } else { $newLink = $link; } if ($newLink != $link) { $link = $newLink; break; } } } } return $link; } return parent::buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, $extraParams); }
/** * Fetches all notices applicable to the visiting user * * @param array $params * @param array $containerData * * @return array */ protected function _getSocialNoticesContainerParams(XenForo_ControllerResponse_View $controllerResponse, array $notices = array()) { $socialForum = ThemeHouse_SocialGroups_SocialForum::getInstance(); /* @var $noticeModel XenForo_Model_Notice */ $noticeModel = XenForo_Model::create('XenForo_Model_Notice'); if (XenForo_Application::get('options')->enableNotices) { $user = XenForo_Visitor::getInstance()->toArray(); if (XenForo_Application::isRegistered('session')) { $dismissedNotices = XenForo_Application::getSession()->get('dismissedNotices'); } if (!isset($dismissedNotices) || !is_array($dismissedNotices)) { $dismissedNotices = array(); } // handle style overrides $user['style_id'] = XenForo_Application::get('options')->defaultStyleId; $noticeTokens = array('{name}' => $user['username'] !== '' ? $user['username'] : new XenForo_Phrase('guest'), '{user_id}' => $user['user_id']); $allNotices = $noticeModel->getNoticesForSocialForum($socialForum['social_forum_id']); foreach ($allNotices as $noticeId => $notice) { if (!in_array($noticeId, $dismissedNotices) && XenForo_Helper_Criteria::userMatchesCriteria($notice['user_criteria'], true, $user) && XenForo_Helper_Criteria::pageMatchesCriteria($notice['page_criteria'], true, $controllerResponse->params, $controllerResponse->containerParams)) { $notices[$noticeId] = array('title' => $notice['title'], 'message' => str_replace(array_keys($noticeTokens), $noticeTokens, $notice['message']), 'wrap' => $notice['wrap'], 'dismissible' => $notice['dismissible'] && XenForo_Visitor::getUserId()); } } } return $notices; }
/** * Setup the session. * * @param string $action */ protected function _setupSession($action) { if (XenForo_Application::isRegistered('session')) { return; } XenForo_Session::startAdminSession($this->_request); }
public static function doJob($method, $uri, array $params) { if (XenForo_Application::isRegistered('_bdApi_disableBatch') && XenForo_Application::get('_bdApi_disableBatch')) { return array('_job_result' => 'error', '_job_error' => 'Batch running has been disabled.'); } $fc = self::getFc(); $request = new bdApi_Zend_Controller_Request_Http(bdApi_Data_Helper_Core::safeConvertApiUriToAbsoluteUri($uri, true)); $request->setMethod($method); foreach ($params as $key => $value) { $request->setParam($key, $value); } $fc->setRequest($request); // routing $routeMatch = $fc->getDependencies()->route($request); if (!$routeMatch or !$routeMatch->getControllerName()) { list($controllerName, $action) = $fc->getDependencies()->getNotFoundErrorRoute(); $routeMatch->setControllerName($controllerName); $routeMatch->setAction($action); } $response = $fc->dispatch($routeMatch); if ($response instanceof XenForo_ControllerResponse_Error) { return array('_job_result' => 'error', '_job_error' => $response->errorText); } elseif ($response instanceof XenForo_ControllerResponse_Exception) { return array('_job_result' => 'error', '_job_error' => $response->getMessage()); } elseif ($response instanceof XenForo_ControllerResponse_Message) { return array('_job_result' => 'message', '_job_message' => $response->message); } elseif ($response instanceof XenForo_ControllerResponse_View) { return array('_job_result' => 'ok', '_job_response' => $response); } throw new XenForo_Exception('Unexpected $response occurred.'); }
public function renderCss() { // re-implement XenForo_CssOutput::renderCss() so we can change how caching works $cacheId = $this->getCacheId(); if ($cacheObject = XenForo_Application::getCache()) { if ($cacheCss = $cacheObject->load($cacheId, true)) { return $cacheCss . "\n/* CSS returned from cache. */"; } } $this->_prepareForOutput(); if (XenForo_Application::isRegistered('bbCode')) { $bbCodeCache = XenForo_Application::get('bbCode'); } else { $bbCodeCache = XenForo_Model::create('XenForo_Model_BbCode')->getBbCodeCache(); } $params = array('displayStyles' => $this->_displayStyles, 'smilieSprites' => $this->_smilieSprites, 'customBbCodes' => !empty($bbCodeCache['bbCodes']) ? $bbCodeCache['bbCodes'] : array(), 'xenOptions' => XenForo_Application::get('options')->getOptions(), 'dir' => $this->_textDirection, 'pageIsRtl' => $this->_textDirection == 'RTL'); $templates = array(); foreach ($this->_cssRequested as $cssName) { $cssName = trim($cssName); if (!$cssName) { continue; } $templateName = $cssName . '.css'; if (!isset($templates[$templateName])) { $templates[$templateName] = new XenForo_Template_Public($templateName, $params); } } $css = self::renderCssFromObjects($templates, XenForo_Application::debugMode()); $css = self::prepareCssForOutput($css, $this->_textDirection, XenForo_Application::get('options')->minifyCss && $cacheObject); if ($cacheObject) { $cacheObject->save($css, $cacheId, array(), 86400); } return $css; }
public static function controllerPreDispatch(XenForo_Controller $controller, $action) { if ($controller instanceof XenForo_ControllerPublic_Abstract) { if (self::$_updatedMediaCounts === false) { self::$_updatedMediaCounts = true; $options = XenForo_Application::getOptions(); $visitor = XenForo_Visitor::getInstance(); if ($options->xengalleryUnviewedCounter['enabled'] && $visitor->xengallery_unviewed_media_count && XenForo_Application::isRegistered('session')) { $time = XenForo_Application::$time; $session = XenForo_Application::get('session'); $mediaUnviewed = $session->get('mediaUnviewed'); if ($mediaUnviewed === false || $mediaUnviewed['lastUpdateDate'] < $time - $options->xengalleryUnviewedCounter['length'] * 60) { /** @var $mediaModel XenGallery_Model_Media */ $mediaModel = XenForo_Model::create('XenGallery_Model_Media'); $unviewedIds = $mediaModel->getUnviewedMediaIds($visitor->user_id, array('viewCategoryIds' => $mediaModel->getViewableCategoriesForVisitor($visitor->toArray()), 'viewAlbums' => XenForo_Permission::hasPermission($visitor->permissions, 'xengallery', 'viewAlbums'))); if ($unviewedIds !== false) { if (sizeof($unviewedIds)) { $mediaUnviewed = array('unviewed' => array_combine($unviewedIds, $unviewedIds), 'lastUpdateDate' => $time); } else { $mediaUnviewed = self::_getDefaultUnviewedArray(); } } } elseif (!$visitor->user_id) { $mediaUnviewed = self::_getDefaultUnviewedArray(); } $session->set('mediaUnviewed', $mediaUnviewed); } } } }
public function actionIndex() { $codes = $this->_getBbmBBCodeModel()->getAllBbCodes(); $bbcodesWithCallbackErrors = $this->_classAndMethodIntegrityCheck($codes); //Add class foreach ($codes as &$code) { if ($code['tag'][0] == '@') { $code['class'] = 'orphanButton'; $code['orphanButton'] = true; } else { $code['class'] = 'normalButton'; $code['orphanButton'] = false; } $code['disableAddon'] = false; if (XenForo_Application::isRegistered('addOns')) { $enableAddons = XenForo_Application::get('addOns'); if (!empty($code['bbcode_addon']) && !isset($enableAddons[$code['bbcode_addon']])) { $code['class'] .= ' disableAddon'; $code['disableAddon'] = true; } } } $viewParams = array('codes' => $codes, 'callbackErrors' => $bbcodesWithCallbackErrors, 'permsBbm' => XenForo_Visitor::getInstance()->hasAdminPermission('bbm_BbCodesAndButtons')); return $this->responseView('Bbm_ViewAdmin_Bbm_BbCodes_List', 'bbm_bb_codes_list', $viewParams); }
public function bakeBbmTags() { $bbmTags = BBM_Helper_Bbm::getBbmBbCodes(); $activeAddons = XenForo_Application::isRegistered('addOns') ? XenForo_Application::get('addOns') : array(); $visitor = XenForo_Visitor::getInstance(); if (!is_array($bbmTags)) { return false; } $allBbmTags = array(); foreach ($bbmTags as $bbm) { if (!$bbm['active']) { continue; } if (!empty($activeAddons) && !empty($bbm['bbcode_addon'])) { if (!isset($activeAddons[$bbm['bbcode_addon']])) { //Skip Bb Codes linked to an addon when this addon is disabled continue; } } $tagName = $bbm['tag']; if (!empty($bbm['preParser'])) { $this->addPreParserBbCode($tagName); } } $this->_bbmTags = $allBbmTags; /**** * XenForo Options - only need to call once the options ***/ $options = XenForo_Application::get('options'); if (!empty($options->Bbm_PreCache_XenTags)) { foreach ($options->Bbm_PreCache_XenTags as $tagName) { $this->addPreParserBbCode($tagName); } } }
/** * Displays a list of active reports for the visiting user. * * @return XenForo_ControllerResponse_Abstract */ public function actionIndex() { $reportId = $this->_input->filterSingle('report_id', XenForo_Input::UINT); if ($reportId) { return $this->responseReroute(__CLASS__, 'view'); } $reportModel = $this->_getReportModel(); $activeReports = $reportModel->getActiveReports(); if (XenForo_Application::isRegistered('reportCounts')) { $reportCounts = XenForo_Application::get('reportCounts'); if (count($activeReports) != $reportCounts['activeCount']) { $reportModel->rebuildReportCountCache(count($activeReports)); } } XenForo_Application::getSession()->set('reportLastRead', XenForo_Application::$time); $reports = $reportModel->getVisibleReportsForUser($activeReports); $session = XenForo_Application::get('session'); $sessionReportCounts = $session->get('reportCounts'); if (!is_array($sessionReportCounts) || $sessionReportCounts['total'] != count($reports)) { $sessionReportCounts = $reportModel->getSessionCountsForReports($reports, XenForo_Visitor::getUserId()); $sessionReportCounts['lastBuildDate'] = XenForo_Application::$time; $session->set('reportCounts', $sessionReportCounts); } $closedReportsRaw = $reportModel->getClosedReportsInTimeFrame(XenForo_Application::$time - 86400, XenForo_Application::$time); $viewParams = array('reports' => $reports, 'recentlyClosed' => $reportModel->getVisibleReportsForUser($closedReportsRaw)); return $this->responseView('XenForo_ViewPublic_Report_List', 'report_list', $viewParams); }
/** * Attempts to match the routing path. See {@link XenForo_Route_Interface} for further details. * * @param string $routePath Routing path * @param Zend_Controller_Request_Http $request Request object * @param XenForo_Router $router Routing object * * @return XenForo_RouteMatch|bool */ public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router) { if (!XenForo_Application::isRegistered('routeFiltersIn')) { return false; } $filters = XenForo_Application::get('routeFiltersIn'); if (!$filters) { return false; } foreach ($filters as $filter) { if (isset($filter['match_regex'])) { $from = $filter['match_regex']; $to = $filter['match_replace']; } else { list($from, $to) = XenForo_Link::translateRouteFilterToRegex(urldecode($filter['replace_route']), urldecode($filter['find_route'])); } $newRoutePath = preg_replace($from, $to, $routePath); if ($newRoutePath != $routePath) { $match = $router->getRouteMatch(); $match->setModifiedRoutePath($newRoutePath); return $match; } } return false; }
public static function get($key) { if (self::$_options === null) { self::$_options = XenForo_Application::get('options'); } switch ($key) { case 'applicationVersionId': return XenForo_Application::$versionId; case 'cacheCutoffDays': return 7; case 'indexTabId': return 'WidgetFramework_home'; case 'layoutEditorEnabled': if (self::$_layoutEditorEnabled === null) { if (!XenForo_Application::isRegistered('session')) { // no session yet... return false; } $session = XenForo_Application::getSession(); self::$_layoutEditorEnabled = $session->get('_WidgetFramework_layoutEditor') === true; if (!self::$_layoutEditorEnabled and !empty($_REQUEST['_layoutEditor'])) { $visitor = XenForo_Visitor::getInstance(); if ($visitor->hasAdminPermission('style')) { self::$_layoutEditorEnabled = true; } } } // use the cached value return self::$_layoutEditorEnabled; } return self::$_options->get('wf_' . $key); }
public static function templatePostRender($templateName, &$content, array &$containerData, XenForo_Template_Abstract $template) { $param = array(); switch ($templateName) { case 'node_list.css': $cacheDataForum = XenForo_Application::isRegistered('brcnsCacheDataForum') ? XenForo_Application::get('brcnsCacheDataForum') : XenForo_Model::create('XenForo_Model_DataRegistry')->get('brcnsCacheDataForum'); $cacheDataPage = XenForo_Application::isRegistered('brcnsCacheDataPage') ? XenForo_Application::get('brcnsCacheDataPage') : XenForo_Model::create('XenForo_Model_DataRegistry')->get('brcnsCacheDataPage'); $cacheDataLink = XenForo_Application::isRegistered('brcnsCacheDataLink') ? XenForo_Application::get('brcnsCacheDataLink') : XenForo_Model::create('XenForo_Model_DataRegistry')->get('brcnsCacheDataLink'); $cacheDataCategory = XenForo_Application::isRegistered('brcnsCacheDataCategory') ? XenForo_Application::get('brcnsCacheDataCategory') : XenForo_Model::create('XenForo_Model_DataRegistry')->get('brcnsCacheDataCategory'); $cacheDataCategoryRoot = XenForo_Application::isRegistered('brcnsCacheDataCateRoot') ? XenForo_Application::get('brcnsCacheDataCateRoot') : XenForo_Model::create('XenForo_Model_DataRegistry')->get('brcnsCacheDataCateRoot'); XenForo_Application::set('brcnsCustomNodeStylesForum', $cacheDataForum); XenForo_Application::set('brcnsCustomNodeStylesPage', $cacheDataPage); XenForo_Application::set('brcnsCustomNodeStylesLink', $cacheDataLink); XenForo_Application::set('brcnsCustomNodeStylesCategory', $cacheDataCategory); XenForo_Application::set('brcnsCustomNodeStylesCategoryRoot', $cacheDataCategoryRoot); $param['CustomNodeStylesForums'] = XenForo_Application::get('brcnsCustomNodeStylesForum'); $param['CustomNodeStylesPages'] = XenForo_Application::get('brcnsCustomNodeStylesPage'); $param['CustomNodeStylesLinks'] = XenForo_Application::get('brcnsCustomNodeStylesLink'); $param['CustomNodeStylescategories'] = XenForo_Application::get('brcnsCustomNodeStylesCategory'); $param['CustomNodeStylesCategoriesRoot'] = XenForo_Application::get('brcnsCustomNodeStylesCategoryRoot'); $options = XenForo_Application::get('options'); $param['size'] = $options->BRCNS_size_icon; $newTemplate = $template->create('BRCNS_custom_node_style.css', $template->getParams()); $newTemplate->setParams($param); $content = $content . $newTemplate->render(); break; } }
/** * Post-save handling. * * Note: not run when importing */ protected function _postSave() { parent::_postSave(); if ($this->isInsert() && !empty(XenForo_Application::getOptions()->dpAnalyticsEvents['registration']) && !empty(XenForo_Application::getOptions()->dpAnalyticsInternal['v'])) { if (XenForo_Application::isRegistered('fc')) { $action = preg_split('/\\b/', strtolower(trim(XenForo_Application::getFc()->route()->getAction()))); switch ($action[1]) { case 'facebook': $label = 'Facebook'; break; case 'google': $label = 'Google'; break; case 'twitter': $label = 'Twitter'; break; default: $label = 'Standard'; // would have preferred to leave this blank, but a null value causes it to be omitted from certain reports in Analytics } } else { $label = null; } $user = $this->getMergedData(); if (XenForo_Application::isRegistered('fc')) { $analyticsClientId = XenForo_Application::getFc()->getRequest()->getCookie('_ga'); } else { $analyticsClientId = null; } DigitalPointBetterAnalytics_Helper_Analytics::getInstance()->event(XenForo_Application::getOptions()->googleAnalyticsWebPropertyId, $analyticsClientId, $user['user_id'], @$_SERVER['REMOTE_ADDR'], 'User', 'Registration', $label); } }
protected function _preSave() { parent::_preSave(); if (XenForo_Application::isRegistered('show_notification_popup')) { $this->set('show_notification_popup', XenForo_Application::get('show_notification_popup'), 'xf_user_option'); } }
protected function _postDispatch($controllerResponse, $controllerName, $action) { if (XenForo_Application::isRegistered('nodesAsTabsAPI')) { $nodeId = isset($controllerResponse->params['widgetPage']['node_id']) ? $controllerResponse->params['widgetPage']['node_id'] : 0; call_user_func(array('NodesAsTabs_API', 'postDispatch'), $this, $nodeId, $controllerResponse, $controllerName, $action); } }
public static function listen($hookName, &$content, array $hookParams, XenForo_Template_Abstract $template) { if ($hookName == 'editor') { $params = $template->getParams(); $options = XenForo_Application::get('options'); if ($options->dark_minorin_enabled) { $smilies = array(); $toolbar_bbcode = array(); $toolbar_bbcode_temp = explode("\n", str_replace("\r", "", trim($options->dark_minorin_bbcode))); foreach ($toolbar_bbcode_temp as $bbcode) { $bbcode = explode(":", trim($bbcode)); $toolbar_bbcode[$bbcode[0]] = $bbcode[1]; } if (XenForo_Application::isRegistered('smilies')) { $smilies = XenForo_Application::get('smilies'); } else { $smilies = XenForo_Model::create('XenForo_Model_Smilie')->getAllSmiliesForCache(); XenForo_Application::set('smilies', $smilies); } foreach ($smilies as &$smilie) { $smilie['text'] = $smilie['smilieText'][0]; $smilie['sprite_mode'] = array_key_exists('sprite_params', $smilie); } $params += array('minorin' => array("toolbar_bbcode" => $toolbar_bbcode, "toolbar_smilies" => $smilies, "enabled" => $options->dark_minorin_enabled, "js_modification" => filemtime("js/dark/minorin.js"))); } $content .= $template->create('dark_minorin_toolbar', $params); } }
public static function getTaigaChatStuff(&$response, $action, $dis = false) { $options = XenForo_Application::get('options'); $visitor = XenForo_Visitor::getInstance(); $smilies = array(); $toolbar_bbcode = array(); if ($options->dark_taigachat_toolbar) { $toolbar_bbcode_temp = explode("\n", str_replace("\r", "", trim($options->dark_taigachat_toolbar_bbcode))); foreach ($toolbar_bbcode_temp as $bbcode) { $bbcode = explode(":", trim($bbcode)); $toolbar_bbcode[$bbcode[0]] = $bbcode[1]; } if (XenForo_Application::isRegistered('smilies')) { $smilies = XenForo_Application::get('smilies'); } else { $smilies = XenForo_Model::create('XenForo_Model_Smilie')->getAllSmiliesForCache(); XenForo_Application::set('smilies', $smilies); } foreach ($smilies as &$smilie) { $smilie['text'] = $smilie['smilieText'][0]; $smilie['sprite_mode'] = array_key_exists('sprite_params', $smilie); } } if (empty($response->params['taigachat'])) { $response->params['taigachat'] = array(); } // Don't forget to add to dark_taigachat template too $response->params['taigachat'] += array("refreshtime" => $options->dark_taigachat_refreshtime, "maxrefreshtime" => $options->dark_taigachat_maxrefreshtime, "enabled" => $options->dark_taigachat_enabled, "maxlength" => $options->dark_taigachat_maxlength, "reverse" => $options->dark_taigachat_direction, "height" => $options->dark_taigachat_height, "route" => $options->dark_taigachat_route, "timedisplay" => $options->dark_taigachat_timedisplay, "toolbar" => $options->dark_taigachat_toolbar, "toolbar_bbcode" => $toolbar_bbcode, "toolbar_smilies" => $smilies, "thumbzoom" => $options->dark_taigachat_imagemode == 'ThumbZoom', "js_modification" => filemtime("js/dark/taigachat.js"), "canView" => $visitor->hasPermission('dark_taigachat', 'view'), "canPost" => $visitor->hasPermission('dark_taigachat', 'post'), "sidebar" => $response->viewName != "Dark_TaigaChat_ViewPublic_TaigaChat_Index" && $action != 'popup', "popup" => $action == 'popup', "limit" => $response->viewName != "Dark_TaigaChat_ViewPublic_TaigaChat_Index" && $action != 'popup' ? $options->dark_taigachat_sidebarperpage : $options->dark_taigachat_fullperpage); }
/** * Displays a form to change the visitor's language, or changes it if a language_id is present. * * @return XenForo_ControllerResponse_Abstract */ public function actionLanguage() { $visitor = XenForo_Visitor::getInstance(); if ($this->_input->inRequest('language_id')) { $this->_checkCsrfFromToken($this->_input->filterSingle('_xfToken', XenForo_Input::STRING)); $languageId = $this->_input->filterSingle('language_id', XenForo_Input::UINT); if ($languageId) { $languages = XenForo_Application::isRegistered('languages') ? XenForo_Application::get('languages') : XenForo_Model::create('XenForo_Model_Language')->getAllLanguagesForCache(); if (!isset($languages[$languageId])) { $languageId = 0; } } if ($visitor['user_id']) { $dw = XenForo_DataWriter::create('XenForo_DataWriter_User'); $dw->setExistingData($visitor['user_id']); $dw->set('language_id', $languageId); $dw->save(); XenForo_Helper_Cookie::deleteCookie('language_id'); } else { XenForo_Helper_Cookie::setCookie('language_id', $languageId, 86400 * 365); } return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $this->getDynamicRedirect(false, false)); } else { $languages = XenForo_Application::isRegistered('languages') ? XenForo_Application::get('languages') : XenForo_Model::create('XenForo_Model_Language')->getAllLanguagesForCache(); $viewParams = array('languages' => $this->getModelFromCache('XenForo_Model_Language')->getAllLanguages(), 'redirect' => $this->getDynamicRedirect(false, false)); return $this->responseView('XenForo_ViewPublic_Misc_Language', 'language_chooser', $viewParams); } }
protected function _preSave() { parent::_preSave(); if (XenForo_Application::isRegistered('vtPhong_can_add_slide')) { $this->set('can_add_slide', XenForo_Application::get('vtPhong_can_add_slide'), 'xf_forum'); } }
public static function isBot() { if (!XenForo_Application::isRegistered('session')) { return false; } $session = XenForo_Application::getSession(); return $session->get('robotId'); }
public function getAllCategories() { if (!XenForo_Application::isRegistered('elportal_allcategories')) { $categories = $this->getCategories(); XenForo_Application::set('elportal_allcategories', $categories); } return XenForo_Application::get('elportal_allcategories'); }
/** * Helper function to get moods from data registry. * * @return array List of moods */ protected function _getMoodData() { if (XenForo_Application::isRegistered('moods')) { return XenForo_Application::get('moods'); } else { return $this->_getMoodModel()->getAllMoods(); } }
public static function getInternalDataUrl() { if (!XenForo_Application::isRegistered('config')) { return ''; } else { return XenForo_Application::get('config')->internalDataUrl; } }
public function actionValidateField() { $response = parent::actionValidateField(); if (XenForo_Application::isRegistered('nodesAsTabsAPI')) { call_user_func(array('NodesAsTabs_API', 'actionValidateField'), $response, $this); } return $response; }
public static function getTaigaChatStuff(&$response, $action, $dis = false) { $options = XenForo_Application::get('options'); $visitor = XenForo_Visitor::getInstance(); /** @var Dark_TaigaChat_Model_TaigaChat */ $taigamodel = XenForo_Model::create("Dark_TaigaChat_Model_TaigaChat"); $visitor = XenForo_Visitor::getInstance(); /** @var Dark_TaigaChat_Model_TaigaChat */ $taigamodel->updateActivity($visitor['user_id'], false); $smilies = array(); $toolbar_bbcode = array(); if ($options->dark_taigachat_toolbar) { $toolbar_bbcode_temp2 = preg_replace('#(^//.+$)#mi', '', trim($options->dark_taigachat_toolbar_bbcode)); $toolbar_bbcode_temp2 = str_replace("\r", "", $toolbar_bbcode_temp2); if (!empty($toolbar_bbcode_temp2)) { $toolbar_bbcode_temp = explode("\n", $toolbar_bbcode_temp2); foreach ($toolbar_bbcode_temp as $bbcode) { $bbcode = trim($bbcode); if (!empty($bbcode)) { $bbcode = explode(":", trim($bbcode)); if (!empty($bbcode)) { $toolbar_bbcode[$bbcode[0]] = $bbcode[1]; } } } } if (XenForo_Application::isRegistered('smilies')) { $smilies = XenForo_Application::get('smilies'); } else { $smilies = XenForo_Model::create('XenForo_Model_Smilie')->getAllSmiliesForCache(); XenForo_Application::set('smilies', $smilies); } foreach ($smilies as &$smilie) { $smilie['text'] = $smilie['smilieText'][0]; $smilie['sprite_mode'] = array_key_exists('sprite_params', $smilie); } } if (empty($response->params['taigachat'])) { $response->params['taigachat'] = array(); } if (!XenForo_Application::isRegistered('config')) { $path = 'data'; } else { $path = XenForo_Application::get('config')->externalDataPath; } if ($path == 'data' && $options->dark_taigachat_speedmode == 'Https') { $path = $options->boardUrl . '/' . $path; } $isSidebar = $response->viewName != "Dark_TaigaChat_ViewPublic_TaigaChat_Index" && $action != 'popup' && $action != 'xenporta_alt'; //$bbCodeParser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Base')); //$motd = new XenForo_BbCode_TextWrapper($options->dark_taigachat_motd, $bbCodeParser); $motd = false; if (!empty($options->dark_taigachat_motd)) { $motd = " "; } // Don't forget to add to dark_taigachat template too $response->params['taigachat'] += array("focusedrefreshtime" => $options->dark_taigachat_focusedrefreshtime, "unfocusedrefreshtime" => $options->dark_taigachat_unfocusedrefreshtime, "tabunfocusedrefreshtime" => $options->dark_taigachat_tabunfocusedrefreshtime, "enabled" => true, "maxlength" => $options->dark_taigachat_maxlength, "reverse" => $options->dark_taigachat_direction, "height" => $options->dark_taigachat_height, "route" => $options->dark_taigachat_route, "timedisplay" => $options->dark_taigachat_timedisplay, "toolbar" => $options->dark_taigachat_toolbar, "ignorehide" => $options->dark_taigachat_ignorehide, "showAlert" => $options->dark_taigachat_showalert, "toolbar_bbcode" => $toolbar_bbcode, "toolbar_smilies" => $smilies, "activity_newtab" => $options->dark_taigachat_activity_newtab, "thumbzoom" => $options->dark_taigachat_imagemode == 'ThumbZoom', "js_modification" => filemtime("js/dark/taigachat.js"), "canView" => $visitor->hasPermission('dark_taigachat', 'view'), "canPost" => $visitor->hasPermission('dark_taigachat', 'post'), "canBan" => $visitor->hasPermission('dark_taigachat', 'ban'), "canColor" => $taigamodel->canUseColor(), "color" => $visitor->taigachat_color, "canModify" => $visitor->hasPermission('dark_taigachat', 'modify'), "canModifyAll" => $visitor->hasPermission('dark_taigachat', 'modifyAll'), "canMotd" => $visitor->hasPermission('dark_taigachat', 'motd'), "motd" => $motd, "sidebar" => $isSidebar, "popup" => $action == 'popup', "limit" => $isSidebar ? $options->dark_taigachat_sidebarperpage : $options->dark_taigachat_fullperpage, "speed" => $options->dark_taigachat_speedmode != 'Disabled', "speedurl" => $isSidebar ? $path . '/taigachat/messagesmini.html' : $path . '/taigachat/messages.html'); }
/** * Render the CSS version of the... CSS! * * @return string */ public function renderCss() { $params = $this->_params; $styleModel = XenForo_Model::create('XenForo_Model_Style'); $styleModel->setAdminStyles(true); $styles = XenForo_Application::isRegistered('adminStyles') ? XenForo_Application::get('adminStyles') : $styleModel->getAllStyles(); $styleId = $params['styleId']; if (!empty($styleId) && isset($styles[$styleId])) { $style = $styles[$styleId]; } else { $style = reset($styles); } $adminStyleProperties = XenForo_Application::get('adminStyleProperties'); $properties = unserialize($style['properties']); $properties = is_array($properties) ? $properties : array(); if (empty($properties)) { $properties = $adminStyleProperties; } else { $tmpAdminStyleProperties = array(); if (!isset($properties['contentWidth']) && isset($tmpAdminStyleProperties['contentWidth'])) { $properties['contentWidth'] = $tmpAdminStyleProperties['contentWidth']; } if (!isset($properties['formWidth']) && isset($tmpAdminStyleProperties['formWidth'])) { $properties['formWidth'] = $tmpAdminStyleProperties['formWidth']; } if (!isset($properties['nonResponsiveMinWidth']) && isset($tmpAdminStyleProperties['nonResponsiveMinWidth'])) { $properties['nonResponsiveMinWidth'] = $tmpAdminStyleProperties['nonResponsiveMinWidth']; } } $styleId = $style['style_id']; $styleModifiedDate = $style['last_modified_date']; $defaultProperties = XenForo_Application::get('defaultStyleProperties'); XenForo_Template_Helper_Core::setStyleProperties(XenForo_Application::mapMerge($defaultProperties, $properties)); Brivium_AdminStyleSystem_Template_Admin::setStyleId($style['style_id']); XenForo_Template_Abstract::setLanguageId(0); $bbCodeCache = !empty($params['bbCodeCache']) ? $params['bbCodeCache'] : array(); $templateParams = array('displayStyles' => array(), 'smilieSprites' => !empty($params['smilieSprites']) ? $params['smilieSprites'] : array(), 'xenOptions' => XenForo_Application::get('options')->getOptions(), 'customBbCodes' => !empty($bbCodeCache['bbCodes']) ? $bbCodeCache['bbCodes'] : array(), 'dir' => $this->_params['dir'], 'pageIsRtl' => $this->_params['dir'] == 'RTL'); $templates = array(); foreach ($this->_params['css'] as $cssTemplate) { if (strpos($cssTemplate, 'public:') === 0) { $templates[$cssTemplate] = new XenForo_Template_Public(substr($cssTemplate, strlen('public:')), $templateParams); } else { $templates[$cssTemplate] = new Brivium_AdminStyleSystem_Template_Admin($cssTemplate, $templateParams); } } if (XenForo_Application::isRegistered('adminStyleModifiedDate')) { $modifyDate = XenForo_Application::get('adminStyleModifiedDate'); } else { $modifyDate = XenForo_Application::$time; } $this->_response->setHeader('Expires', 'Wed, 01 Jan 2020 00:00:00 GMT', true); $this->_response->setHeader('Last-Modified', gmdate('D, d M Y H:i:s', $modifyDate) . ' GMT', true); $this->_response->setHeader('Cache-Control', 'private', true); $css = XenForo_CssOutput::renderCssFromObjects($templates, true); $css = XenForo_CssOutput::prepareCssForOutput($css, $this->_params['dir'], false); return $css; }
/** * Setup the session. * * @param string $action */ protected function _setupSession($action) { if (XenForo_Application::isRegistered('session')) { return; } $session = new XenForo_Session(array('admin' => true)); XenForo_Application::set('session', $session); $session->start(); XenForo_Visitor::setup($session->get('user_id')); }
/** * Initialise the code event. * * @param XenForo_FrontController * @param XenForo_ControllerResponse_Abstract * @param XenForo_ViewRenderer_Abstract * @param array Parameters used to help prepare the container * * @return void */ public static function init(XenForo_FrontController $fc, XenForo_ControllerResponse_Abstract &$controllerResponse, XenForo_ViewRenderer_Abstract &$viewRenderer, array &$containerParams) { // only execute if we are a public-facing view // assumes init_dependencies listener runs correctly! if ($controllerResponse instanceof XenForo_ControllerResponse_View and XenForo_Application::isRegistered('moods')) { $moodModel = self::_getMoodModel(); $params = array('moods' => self::_getMoodData(), 'defaultMoodId' => $moodModel->getDefaultMoodId(self::_getMoodData()), 'canViewMoods' => $moodModel->canViewMoods(), 'canHaveMood' => $moodModel->canHaveMood()); $controllerResponse->params = array_merge($controllerResponse->params, $params); $containerParams = array_merge($containerParams, $params); } }