public static function get() { //Check if mobile if (class_exists('Sedo_DetectBrowser_Listener_Visitor')) { //External addon $visitor = XenForo_Visitor::getInstance(); if (!$visitor->getBrowser['isMobile']) { return; } //Tablets if ($visitor->getBrowser['isTablet']) { foreach ($visitor->getBrowser['mobile']['tablets'] as $key => $value) { if ($key != 'isGenericTablet' && $value != false) { return $key; } } return 'isTablet'; } //Phones foreach ($visitor->getBrowser['mobile']['phones'] as $key => $value) { if ($key != 'isGenericPhone' && $value != false) { return $key; } } return 'isMobile'; } //XenForo if (!XenForo_Visitor::isBrowsingWith('mobile')) { return; } return 'isMobile'; }
public static function getVisitor(XenForo_Visitor &$visitor) { if (class_exists('Sedo_DetectBrowser_Listener_Visitor') && isset($visitor->getBrowser['isMobile'])) { //External Addon $isMobile = $visitor->getBrowser['isMobile']; $isTablet = $visitor->getBrowser['isTablet']; } else { //XenForo $isMobile = XenForo_Visitor::isBrowsingWith('mobile'); $isTablet = ''; } if (!empty($isMobile)) { $options = XenForo_Application::get('options'); $mobileStyle = $options->sedoDefaultMobileStyle; if (!empty($isTablet)) { $mobileStyle = $options->sedoDefaultTabletStyle; } if (!empty($visitor['user_id'])) { //Only for members => guests use the default style option (unless they have choosen to use another style =>cookie: style_id) XenForo_Helper_Cookie::deleteCookie('style_id'); //case: visitor changed the default style, then log $getCookie = XenForo_Helper_Cookie::getCookie('mobile_style_id'); // the mobile_style_id is set here: Sedo_MobileStyleSelector_ControllerPublic_Misc if ($getCookie == false) { //No cookie => continue to force mobile style $visitor['style_id'] = $mobileStyle; } } //Force style if ($options->sedoForceMobileStyle && $visitor->style_id != $mobileStyle) { $visitor['style_id'] = $mobileStyle; } } }
public static function Diktat(XenForo_Controller $controller, $action) { $visitor = XenForo_Visitor::getInstance(); if (class_exists('Sedo_DetectBrowser_Listener_Visitor') && isset($visitor->getBrowser['isMobile'])) { //External Addon $isMobile = $visitor->getBrowser['isMobile']; $isTablet = $visitor->getBrowser['isTablet']; } else { //XenForo $isMobile = XenForo_Visitor::isBrowsingWith('mobile'); $isTablet = ''; } if (!empty($isMobile)) { $options = XenForo_Application::get('options'); $mobileStyle = $options->sedoDefaultMobileStyle; //$visitor->style_id = $mobileStyle; if (!empty($isTablet)) { $mobileStyle = $options->sedoDefaultTabletStyle; } $options->defaultStyleId = $mobileStyle; if ($options->sedoForceMobileStyle && $visitor->style_id != $mobileStyle) { //Should not be needed XenForo_Helper_Cookie::setCookie('style_id', $mobileStyle, 86400 * 365); } } }
public function actionToBbCode() { $html = $this->_input->filterSingle('html', XenForo_Input::STRING); $options = array('stripLinkPathTraversal' => XenForo_Visitor::isBrowsingWith('firefox')); $bbCode = trim(XenForo_Html_Renderer_BbCode::renderFromHtml($html, $options)); return $this->responseView('XenForo_ViewPublic_Editor_ToBbCode', '', array('bbCode' => $bbCode)); }
public static function CheckMobile($option = null) { $options = XenForo_Application::get('options'); $visitor = XenForo_Visitor::getInstance(); if ($option == 'ifForced' && !$options->sedoForceMobileStyle) { return false; } if ($option == 'ifMember' && empty($visitor['user_id'])) { return false; } if (class_exists('Sedo_DetectBrowser_Listener_Visitor') && isset($visitor->getBrowser['isMobile'])) { //External Addon $isMobile = $visitor->getBrowser['isMobile']; $isTablet = $visitor->getBrowser['isTablet']; } else { //XenForo $isMobile = XenForo_Visitor::isBrowsingWith('mobile'); $isTablet = ''; } if (empty($isMobile)) { return false; } $mobileStyle = $options->sedoDefaultMobileStyle; if (!empty($isTablet)) { $mobileStyle = $options->sedoDefaultTabletStyle; } return $mobileStyle; }
public static function template_hook($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template) { $options = XenForo_Application::get('options'); $enableadvxenforo = $options->enableadvxenforo; $thread_id = $hookParams['thread']['thread_id']; if ($enableadvxenforo) { $PermissionEnable = XenForo_Visitor::getInstance()->hasPermission('adv_xenforo', 'adv_xenforo_enable_adv') ? TRUE : FALSE; if ($hookName == 'account_preferences_options' && $PermissionEnable) { $ourTemplate = $template->create('adv_xenforo_account_options', $template->getparams()); $rendered = $ourTemplate->render(); $contents = $contents . $rendered; } $hasPermission = XenForo_Visitor::getInstance()->hasPermission('adv_xenforo', 'adv_xenforo_show') ? TRUE : FALSE; $advs = XenForo_Application::getSimpleCacheData('adv_xenforo'); $user = XenForo_Visitor::getInstance()->toArray(); $enable_adv = $PermissionEnable === TRUE ? $user['enable_adv'] : TRUE; $containerData = self::$containerData; if (empty(self::$containerData)) { $containerData = XenForo_Template_Public::getExtraContainerData(); } if ($enable_adv) { if ($hasPermission === TRUE && $advs["AdvsHook"]) { $isMobile = XenForo_Visitor::isBrowsingWith('mobile'); switch (TRUE) { case $isMobile == TRUE: $adv_adv = 'adv_small'; break; default: $adv_adv = 'adv_large'; break; } foreach ($advs["AdvsHook"] as $_asv) { if ($_asv['active'] && XenForo_Helper_Criteria::userMatchesCriteria($_asv['user_criteria'], TRUE, $user) && XenForo_Helper_Criteria::pageMatchesCriteria($_asv['page_criteria'], TRUE, $template->getParams(), $containerData)) { $ourTemplate = $template->create('ads_xf_ar_xenforo', array('advanced' => $_asv[$adv_adv])); $rendered = $ourTemplate->render(); if ($hookName == 'message_content' && Turki_Adv_Helper_Criteria::postCriteria($_asv['post_criteria'], TRUE) === FALSE) { if ($hookParams['message']['thread_id']) { $decode = XenForo_Helper_Criteria::prepareCriteriaForSelection($_asv['post_criteria']); $position = $decode['active']['page'] ? $hookParams['message']['position'] % $options->messagesPerPage : $hookParams['message']['position']; if ($position == $decode['active']['post_id'] - 1) { $contents = $decode['active']['position'] ? Turki_Adv_Helper_Helpers::advhtml($contents, $rendered) : $contents . $rendered; } } } else { if ($hookName == $_asv['adv_hook_name'] && Turki_Adv_Helper_Criteria::postCriteria($_asv['post_criteria'], TRUE)) { $contents = $_asv['display'] == 'top' ? $rendered . $contents : $contents . $rendered; } } } } } } self::_templateHook($hookName, $contents, $hookParams, $template); } }
public static function goToTop(&$templateName, array &$params, XenForo_Template_Abstract $template) { switch ($templateName) { case 'PAGE_CONTAINER': //Init $visitor = XenForo_Visitor::getInstance(); $GttBrowser = ''; // Type: Normal/Mini/(None) $GttType = XenForo_Template_Helper_Core::styleProperty('gototopType'); $typeMobile = XenForo_Template_Helper_Core::styleProperty('gototopTypeMobile'); $typeTablet = XenForo_Template_Helper_Core::styleProperty('gototopTypeTablet'); //External Addon if (class_exists('Sedo_DetectBrowser_Listener_Visitor') && isset($visitor->getBrowser)) { //Check if mobile and not tablet if ($visitor->getBrowser['isMobile'] && !$visitor->getBrowser['isTablet']) { if ($typeMobile == 'none') { break; } $GttType = $typeMobile; } //Check if tablet if ($visitor->getBrowser['isTablet']) { if (in_array($typeTablet, array('none', 'error'))) { break; } $GttType = $typeTablet; } //Check if IE6 if ($visitor->getBrowser['IEis'] == 6) { $GttBrowser = 'IE'; } } else { //XenForo Mobile if (XenForo_Visitor::isBrowsingWith('mobile')) { if ($typeMobile == 'none') { break; } $GttType = $typeMobile; } //IE6 self function $checkIE6 = self::isBadIE('target', '1-6'); if ($checkIE6 === true) { $GttBrowser = 'IE'; } } $extraParams['goToTop'] = array('type' => $GttType, 'browser' => $GttBrowser); $params += $extraParams; break; } }
public static function isMobile() { if (XenForo_Visitor::isBrowsingWith('mobile')) { return true; } $options = XenForo_Application::getOptions(); if ($options->ChipXF_MS_MobileDetect and !empty($_SERVER['HTTP_USER_AGENT'])) { $mobileDetect = explode(',', $options->ChipXF_MS_MobileDetect); if (preg_match('/(' . implode('|', array_map('preg_quote', $mobileDetect)) . ')/i', strtolower($_SERVER['HTTP_USER_AGENT']), $match)) { return $match[1]; } } return false; }
/** * Gets the editor template. The WYSIWYG editor will be used if supported by * the browser. * * @param XenForo_View $view * @param string $formCtrlName Name of the textarea. If using the WYSIWYG editor, this will have _html appended to it. * @param string $message Default message to put in editor. This should contain BB code * @param array $editorOptions Array of options for the editor. Defaults are provided for any unspecified * Currently supported: * editorId - (string) override normal {formCtrlName}_html id * templateName - (string) override normal 'editor' name * disable - (boolean) true to prevent WYSIWYG from activating * * @return XenForo_Template_Abstract */ public static function getEditorTemplate(XenForo_View $view, $formCtrlName, $message = '', array $editorOptions = array()) { $messageHtml = ''; if (!empty($editorOptions['disable'])) { $showWysiwyg = false; } else { if (!XenForo_Visitor::getInstance()->enable_rte) { $showWysiwyg = false; } else { $showWysiwyg = !XenForo_Visitor::isBrowsingWith('mobile'); } } if ($showWysiwyg) { if (substr($formCtrlName, -1) == ']') { $formCtrlNameHtml = substr($formCtrlName, 0, -1) . '_html]'; } else { $formCtrlNameHtml = $formCtrlName . '_html'; } if ($message !== '') { $bbCodeParser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Wysiwyg', array('view' => $view))); $messageHtml = $bbCodeParser->render($message, array('lightBox' => false)); } } else { $formCtrlNameHtml = $formCtrlName; } // get editor id if (isset($editorOptions['editorId'])) { $editorId = $editorOptions['editorId']; } else { $ctrlInc = 0; do { $editorId = 'ctrl_' . $formCtrlName . ($ctrlInc ? "_{$ctrlInc}" : ''); $ctrlInc++; } while (isset(self::$_editorIds[$editorId]) && $ctrlInc < 100); self::$_editorIds[$editorId] = true; } $templateName = isset($editorOptions['templateName']) ? $editorOptions['templateName'] : 'editor'; $height = isset($editorOptions['height']) ? $editorOptions['height'] : '260px'; return $view->createTemplateObject($templateName, array('showWysiwyg' => $showWysiwyg, 'height' => $height, 'formCtrlNameHtml' => $formCtrlNameHtml, 'formCtrlName' => $formCtrlName, 'editorId' => $editorId, 'message' => $message, 'messageHtml' => $messageHtml, 'smilies' => $showWysiwyg ? self::getEditorSmilies() : array())); }
public function render(array $widget, $positionCode, array $params, XenForo_Template_Abstract $template, &$output) { $html = false; $containerData = array(); $requiredExternals = array(); try { if (!$this->_testConditional($widget, $params)) { // expression failed, stop rendering... if (WidgetFramework_Option::get('layoutEditorEnabled')) { $html = new XenForo_Phrase('wf_layout_editor_widget_conditional_failed'); } else { $html = ''; } } } catch (Exception $e) { // problem while testing conditional, stop rendering... if (WidgetFramework_Core::debugMode() or WidgetFramework_Option::get('layoutEditorEnabled')) { $html = $e->getMessage(); } else { $html = ''; } } // add check for mobile (user agent spoofing) // since 2.2.2 if (!empty($widget['options']['deactivate_for_mobile'])) { if (XenForo_Visitor::isBrowsingWith('mobile')) { $html = ''; } } // check for cache // since 1.2.1 $cacheId = false; $useUserCache = false; $useLiveCache = false; $lockId = ''; if ($html === false and $this->useCache($widget)) { // sondh@2013-04-02 // please keep this block of code in-sync'd with its copycat // implemented in WidgetFramework_WidgetRenderer::prepare $cacheId = $this->_getCacheId($widget, $positionCode, $params); $useUserCache = $this->useUserCache($widget); $useLiveCache = $this->useLiveCache($widget); $cached = WidgetFramework_Core::loadCachedWidget($cacheId, $useUserCache, $useLiveCache); if (!empty($cached) and is_array($cached)) { if ($this->isCacheUsable($cached, $widget)) { // found fresh cached html, use it asap $this->_restoreFromCache($cached, $html, $containerData, $requiredExternals); } else { // cached html has expired: try to acquire lock $lockId = $this->_acquireLock($widget, $positionCode, $params); if ($lockId === false) { // a lock cannot be acquired, an expired cached html is the second best choice $this->_restoreFromCache($cached, $html, $containerData, $requiredExternals); } } } else { // no cache found $lockId = $this->_acquireLock($widget, $positionCode, $params); } } if ($html === false and $lockId === false) { // a lock is required but we failed to acquired it // also, a cached could not be found // stop rendering $html = ''; } // conditional executed just fine if ($html === false) { $renderTemplate = $this->_getRenderTemplate($widget, $positionCode, $params); if (!empty($renderTemplate)) { $renderTemplateObject = $template->create($renderTemplate, array_merge($params, array('widget' => $widget))); // reset required externals $existingRequiredExternals = WidgetFramework_Template_Extended::WidgetFramework_getRequiredExternals(); WidgetFramework_Template_Extended::WidgetFramework_setRequiredExternals(array()); $html = $this->_render($widget, $positionCode, $params, $renderTemplateObject); // get container data (using template_post_render listener) $containerData = self::_getContainerData($widget); // get widget required externals $requiredExternals = WidgetFramework_Template_Extended::WidgetFramework_getRequiredExternals(); WidgetFramework_Template_Extended::WidgetFramework_setRequiredExternals($existingRequiredExternals); } else { $html = $this->_render($widget, $positionCode, $params, $template); } $html = trim($html); if ($cacheId !== false) { $extraData = array(); if (!empty($containerData)) { $extraData[self::EXTRA_CONTAINER_DATA] = $containerData; } if (!empty($requiredExternals)) { $extraData[self::EXTRA_REQUIRED_EXTERNALS] = $requiredExternals; } WidgetFramework_Core::preSaveWidget($widget, $positionCode, $params, $html); WidgetFramework_Core::saveCachedWidget($cacheId, $html, $extraData, $useUserCache, $useLiveCache); } } $this->_releaseLock($lockId); if (!empty($containerData)) { // apply container data WidgetFramework_Template_Extended::WidgetFramework_mergeExtraContainerData($containerData); } if (!empty($requiredExternals)) { // register required external foreach ($requiredExternals as $type => $requirements) { foreach ($requirements as $requirement) { $template->addRequiredExternal($type, $requirement); } } } return $html; }
public function isMobileiOS() { if (!$this->isMobileDevice()) { return false; } if (XenForo_Visitor::isBrowsingWith('webkit')) { if (!isset($_SERVER['HTTP_USER_AGENT'])) { return false; } if (preg_match('/(iPhone.*Mobile|iPod.*Mobile|iPad.*Mobile)/is', $_SERVER['HTTP_USER_AGENT'], $matchiOS)) { if (preg_match('/OS ((\\d+_?){2,3})\\s/', $_SERVER['HTTP_USER_AGENT'], $matchVersion)) { if (intval($matchVersion[1] < 6)) { return true; } } } } return false; }
protected function _replaceEmptyContent(array $match) { $emptyParaText = XenForo_Visitor::isBrowsingWith('ie') ? ' ' : '<br />'; if (strlen(trim($match[2])) == 0) { // paragraph is actually empty $output = $emptyParaText; } else { $test = strip_tags($match[2], '<empty-content><img><br><hr>'); if (trim($test) == '<empty-content />') { $output = str_replace('<empty-content />', $emptyParaText, $match[2]); } else { // we had a break $output = str_replace('<empty-content />', '', $match[2]); } } return $match[1] . $output . $match[3]; }
public static function isMobile($option = false) { $visitor = XenForo_Visitor::getInstance(); if (!class_exists('Sedo_DetectBrowser_Listener_Visitor') || !isset($visitor->getBrowser['isMobile'])) { return XenForo_Visitor::isBrowsingWith('mobile'); } else { //External addon if ($option == 'onlyTablet') { return $visitor->getBrowser['isTablet']; } return $visitor->getBrowser['isMobile']; } }
protected static function _bakeEditorConfig($myConfigs, $theoricalEditor) { $options = XenForo_Application::get('options'); $visitor = XenForo_Visitor::getInstance(); /**** * Check Text Direction ***/ $config_type = strtolower(self::$textDirection); //The framework for Redactor doesn't make a difference between RTL/LTR if (self::$editor == 'xen') { $config_type = 'redactor'; } /**** * Check controller datas ***/ $custConfigs = $options->Bbm_Bm_Cust_Config; if (!empty($custConfigs) && is_array($custConfigs)) { $controllerName = self::$controllerName; $controllerAction = self::$controllerAction; $viewName = self::$viewName; $scores = array('0' => $config_type); foreach ($custConfigs as $custConfig) { $points = 1; $points = $controllerName == $custConfig['controllername'] ? $points + 1 : $points; $points = $controllerAction == $custConfig['controlleraction'] ? $points + 1 : $points; $points = $viewName == $custConfig['viewname'] ? $points + 1 : $points; if ($points > 1) { $configType = $custConfig['configtype']; $configEd = isset($custConfig['editor']) ? $custConfig['editor'] : null; $scores[$points] = array('editor' => $configEd, 'type' => $configType); } } $winnerKey = max(array_keys($scores)); //Sorry but if competitors are ex aequo, the last one wins $winner = $scores[$winnerKey]; if (isset($winner['editor']) && isset($winner['type'])) { $winnerEd = $winner['editor']; $winnerConfig = $winner['type']; if (empty($winnerEd)) { //Might occur if user didn't save again its configuration $winnerEd = $theoricalEditor; } //Anti-doping test if (isset($myConfigs[$winnerEd][$winnerConfig])) { $config_type = $winnerConfig; $theoricalEditor = $winnerEd; self::$editor = $winnerEd; } } } /**** * Check forum config (option) ***/ if ($options->Bbm_Bm_Forum_Config) { $editorOptions = false; if (XenForo_Application::isRegistered('bbm_bm_editor')) { $editorOptions = XenForo_Application::get('bbm_bm_editor'); } if ($editorOptions !== false && $editorOptions != 'disable') { $config_type = $editorOptions; $theoricalEditor = self::_mceOrXenDetectByConfigType($myConfigs, $config_type); } } /**** * Check if mobile ***/ if (!class_exists('Sedo_DetectBrowser_Listener_Visitor') || !isset($visitor->getBrowser['isMobile'])) { //No external addon has been installed or activated if (XenForo_Visitor::isBrowsingWith('mobile') && $options->Bbm_Bm_Mobile != 'disable') { //is mobile and editor has a style option $checkEdAndConfig = self::_mceOrXenDetectByConfigType($myConfigs, $options->Bbm_Bm_Mobile); if ($checkEdAndConfig) { $config_type = $options->Bbm_Bm_Mobile; $theoricalEditor = $checkEdAndConfig; } } return array($theoricalEditor, $config_type); } else { //External addon is installed if (!$visitor->getBrowser['isMobile']) { //is not mobile return array($theoricalEditor, $config_type); } if ($visitor->getBrowser['isTablet'] && !in_array($options->Bbm_Bm_Tablets, array('transparent', 'disable'))) { //is a tablet & transparent mode has been activated $config_type = $options->Bbm_Bm_Tablets; } if ($visitor->getBrowser['isMobile'] && $options->Bbm_Bm_Mobile != 'disable') { //is a mobile device and mobile configuration has been activated $checkEdAndConfig = self::_mceOrXenDetectByConfigType($myConfigs, $options->Bbm_Bm_Mobile); if ($checkEdAndConfig) { $config_type = $options->Bbm_Bm_Mobile; $theoricalEditor = $checkEdAndConfig; } } if ($visitor->getBrowser['isTablet'] && $options->Bbm_Bm_Tablets != 'disable') { //is a tablet & tablet configuration has been activated $checkEdAndConfig = self::_mceOrXenDetectByConfigType($myConfigs, $options->Bbm_Bm_Tablets); if ($checkEdAndConfig) { $config_type = $options->Bbm_Bm_Tablets; $theoricalEditor = $checkEdAndConfig; } } return array($theoricalEditor, $config_type); } }