* * Websites: http://www.joomlashine.com * Technical Support: Feedback - http://www.joomlashine.com/contact-us/get-support.html */ // No direct access to this file defined('_JEXEC') or die('Restricted access'); error_reporting(0); // Include helper class require_once JPATH_ROOT . '/administrator/components/com_mobilize/mobilize.defines.php'; require_once dirname(__FILE__) . '/helpers/mobilize.php'; require_once JPATH_ROOT . '/administrator/components/com_mobilize/helpers/mobilize.php'; // Initialize variables $app = JFactory::getApplication(); $jCfg = JFactory::getConfig(); $device = $app->input->getCmd('_device'); $mCfg = JSNMobilizeTemplateHelper::getConfig($device, $app->input->getInt('jsn_mobilize_preview')); $switch = $app->input->getVar('_request') . (strpos($app->input->getVar('_request'), '?') === false ? '?' : '&') . 'switch_to_desktop_ui=1'; $preview = $app->input->getInt('jsn_mobilize_preview'); $language = JFactory::getLanguage()->getTag(); $menuLanguages = $mCfg->get('menu-language'); if ($app->input->getInt('jsn_mobilize_preview') == '1') { $menuLanguages = json_decode($menuLanguages); } // Get user selected style JHtml::_('behavior.framework', true); if (!empty($mCfg)) { $cssFile = $mCfg->get('css-file') ? $mCfg->get('css-file') : ""; $cookieStyle = $mCfg->get('profile-style') ? $mCfg->get('profile-style') : ""; $cookieStl = $mCfg->get('style') ? $mCfg->get('style') : ""; $customCssFiles = $mCfg->get('custom-css-files') ? $mCfg->get('custom-css-files') : ""; $customCssCode = $mCfg->get('custom-css-code') ? $mCfg->get('custom-css-code') : "";
/** * Render content block. * * @param string $name Content block name. * @param string $device Client device type. * @param integer $preview Previewing or not? * @param String $IDBlock ID Block * @param String $class Class css * * @return void */ public static function renderHtmlBlock($bgstyke = NULL, $name, $device, $preview, $IDBlock = '', $class = 'row-fluid') { // Initialize variables $mCfg = JSNMobilizeTemplateHelper::getConfig($device, $preview); $detect = new JSN_Mobile_Detect(); $classPreview = ""; $urlRequest = isset($_SERVER["REQUEST_URI"]) ? $_SERVER["REQUEST_URI"] : ""; $getPreView = !empty($_GET['jsn_mobilize_preview']) ? $_GET['jsn_mobilize_preview'] : ''; if ($getPreView == 1) { $classPreview = "jsn-mobilize-block "; } if (!empty($name)) { $nameLeft = $name . '-left'; $nameRight = $name . '-right'; // Counting block content $counted[$name] = is_array($mCfg->get($name)) ? count($mCfg->get($name)) : 0; $counted[$nameLeft] = is_array($mCfg->get($nameLeft)) ? count($mCfg->get($nameLeft)) : 0; $counted[$nameRight] = is_array($mCfg->get($nameRight)) ? count($mCfg->get($nameRight)) : 0; $htmlBlock = ""; // Render block content $html[$nameLeft] = JSNMobilizeTemplateHelper::renderBlock($mCfg->get($nameLeft), true); $html[$nameRight] = JSNMobilizeTemplateHelper::renderBlock($mCfg->get($nameRight), true); $classSpan = 'span6'; if (!empty($html[$nameLeft]) or !empty($html[$nameRight])) { //echo '<div id="jsn-mobilize-' . str_replace('_', '-', $name) . '" class="row-fluid">'; if (!empty($html[$nameLeft])) { $htmlBlock .= "\t" . '<div id="jsn-mobilize-' . str_replace('_', '-', $nameLeft) . '" class="' . $classPreview . (!empty($html[$nameRight]) ? $classSpan : 'span12') . '">' . "\n\t\t" . $html[$nameLeft] . "\n\t" . '</div>'; } if (!empty($html[$nameRight])) { $htmlBlock .= "\t" . '<div id="jsn-mobilize-' . str_replace('_', '-', $nameRight) . '" class=" ' . $classPreview . (!empty($html[$nameLeft]) ? $classSpan : 'span12') . '">' . "\n\t\t" . $html[$nameRight] . "\n\t" . '</div>'; } //echo '</div>'; } if (!empty($htmlBlock)) { $class = !empty($class) ? 'class="' . $class . '"' : ''; echo '<div id="' . $IDBlock . '"' . $class . '>' . $bgstyke . '<div class="row-fluid">' . $htmlBlock . '</div></div>'; } } }
/** * Alter response body if necessary. * * - Mobile/tablet site: alter URI based on detected client device type. * - Desktop site: inject switcher link if visitor viewing desktop site on either mobile device or tablet PC. * * @return void */ public static function onAfterRender() { self::$_app = JFactory::getApplication(); if (!self::$_app->isAdmin()) { require_once dirname(__FILE__) . '/libraries/joomlashine/client/mobiledetect.php'; $detect = new JSN_Mobile_Detect(); $deviceType = $detect->isMobile() ? 'mobilize' : 'desktop'; $getPreview = !empty($_GET['jsn_mobilize_preview']) ? $_GET['jsn_mobilize_preview'] : ''; $getSwitch = !empty($_GET['switch_to_desktop_ui']) ? $_GET['switch_to_desktop_ui'] : ''; if (JSNMobilizeTemplateHelper::getConfig("mobilize")) { if (!defined('JSN_MOBILIZE_LAST_EXECUTION')) { return; } } if (!self::$_app->isAdmin() && self::$_device == "mobilize" && ($device = $deviceType) == 'desktop') { // Alter and/or optimize response body based on detected client device type self::_finalizeResponse(); } elseif (self::$_device == 'desktop' && ($device = $deviceType) != 'desktop' || $getSwitch == 1 && $getPreview == 1) { // Inject UI switcher link if visitor viewing desktop site on either mobile device or tablet PC self::_injectUISwitcher($device); } if (self::$_device != 'desktop') { self::Optimize(); } } }