mobile not working on all platforms
Create an ecommerce website in few minutes with this amazing Joomla ecommerce VirtueMart template.
- GK User
- Fri Nov 22, 2013 2:15 am
I can get "mobile" for boutique to display in safari, but on my iphone, using Chrome, it shows the regular site.
Any way to make it recognize the mobile version of Chrome as well?
Any way to make it recognize the mobile version of Chrome as well?
-
- Senior Boarder
- GK User
- Fri Nov 22, 2013 11:24 am
Yes, we had this issue already...
To gk.browser.php you need to add this code :
To gk.browser.php you need to add this code :
- Code: Select all
case 'chrome':
if(preg_match('/Android/i', $browser->getAgentString())) {
$result->set('browser', 'android');
$result->set('mobile', true);
} else if(preg_match('/Mobile Safari/i', $browser->getAgentString())) {
$result->set('browser', 'iphone');
$result->set('mobile', true);
} else if(preg_match('/iPad/i', $browser->getAgentString())) {
$result->set('browser', 'iphone');
$result->set('mobile', true);
} else {
$result->set('browser', 'chrome');
$result->set('mobile', false);
$result->set('css3', true);
}
-
- Moderator
- GK User
- Fri Nov 22, 2013 11:25 am
Ps - do you have template updated to latest version?
-
- Moderator
- GK User
- Mon Nov 25, 2013 5:34 am
Cyberek wrote:Ps - do you have template updated to latest version?
I believe so - I am running it on latest version of Joomla, and when downloaded it, I downloaded for 3.x
Am afraid to update beyond that if it's available because of all of the many tweaks I've had to do to get certain things to work well w/ others
-
- Senior Boarder
- GK User
- Mon Nov 25, 2013 5:54 am
I have added the code you listed above to line 176 of the document you said. I uploaded to FTP, cleared cache in browser, cleared Joomla Cache as well, and refreshed on phone, still will not recognize mobile layout on Chrome on iOS 7
-
- Senior Boarder
- GK User
- Thu Nov 28, 2013 4:11 pm
Could You please post an url to your site?
-
- Moderator
- GK User
- Sat Nov 30, 2013 5:05 am
sent you a PM with URL and login details
-
- Senior Boarder
- GK User
- Sat Nov 30, 2013 11:43 am
Please post here entire gk.browser.php file. Use "[ code ]" and "[/ code ]" (remove spaces and " signs) to wrap the code.
-
- Moderator
- GK User
- Sat Nov 30, 2013 6:03 pm
- Code: Select all
<?php
/**
*
* Main framework class
*
* @version 1.0.0
* @package Gavern Framework
* @copyright Copyright (C) 2010 - 2011 GavickPro. All rights reserved.
*
*/
// No direct access.
defined('_JEXEC') or die;
if(!defined('DS')){
define('DS',DIRECTORY_SEPARATOR);
}
/*
* Main framework class
*/
class GKTemplate {
// template ID
public $TID = 1;
// access to the standard Joomla! template API
public $API;
/*
* detected browser:
*
* browser
* css3
* mobile
*
*/
public $browser;
// page config
public $config;
// page menu
public $menu;
// module styles
public $module_styles;
// page suffix
public $page_suffix;
// submenu
public $generateSubmenu;
// frontpage detection variables
public $globalMenuActive = null;
public $globalMenuLanguage = null;
// constructor
public function __construct($tpl, $module_styles, $embed_mode = false) {
$file = dirname(__file__) . DS . 'framework' . DS . 'gk.browser.php';
if (!is_file($file)) return null;
require_once ($file);
// load the mootools
JHtml::_('behavior.framework', true);
// create instance of GKBrowser class
$gkbrowser = new GKBrowser();
// put the template handler into API field
$this->API = $tpl;
// put the styles to class field
$this->module_styles = $module_styles;
// check the browser
$this->browser = $gkbrowser->detectBrowser();
// get the params
$this->getParameters();
// get the page suffix
$this->getSuffix();
// get the modules overrides
$this->getModuleStyles();
// get type and generate menu
$this->menu = $this->getMenuType();
// enable/disable mootools for pages
$this->getMooTools();
if(!$embed_mode) {
// mobile mode
if ($this->browser->get('mobile')) {
$this->getLayout('mobile');
} else {
if ($this->browser->get('browser') == 'facebook') { // facebook mode
$this->getLayout('facebook');
} else { // normal mode
$this->getLayout('normal');
}
}
}
// parse FB and Tweeter buttons
$this->socialApiParser($embed_mode);
// mobile parsing
$this->mobileParser();
// define an event for replacement
$dispatcher = JDispatcher::getInstance();
// set a proper event for GKParserPlugin
if($this->getParam('use_gk_cache', 0) == 0) {
$dispatcher->register('onAfterRender', 'GKParserPlugin');
} else {
$dispatcher->register('onBeforeCache', 'GKParserPlugin');
}
}
// get the template parameters in PHP form
public function getParameters() {
// create config object
$this->config = new JObject();
// set layout override param
$this->config->set('layout_override', $this->overrideArrayParse($this->getParam('layout_override', '')));
// set menu override param
$this->config->set('menu_override', $this->overrideArrayParse($this->getParam('menu_override', '')));
$this->config->set('suffix_override', $this->overrideArrayParse($this->getParam('suffix_override', '')));
$this->config->set('module_override', $this->overrideArrayParse($this->getParam('module_override', '')));
$this->config->set('tools_override', $this->overrideArrayParse($this->getParam('tools_for_pages', '')));
$this->config->set('mootools_override', $this->overrideArrayParse($this->getParam('mootools_for_pages', '')));
}
public function getMooTools() {
$isOverrided = $this->getMooToolsOverride();
if($isOverrided){
$document = &JFactory::getDocument();
$header = $document->getHeadData();
$scripts = $header['scripts'];
// table which contains scripts to disable
$toRemove = array('mootools-core.js', 'mootools-more.js', 'caption.js');
foreach ($scripts as $key => $value){
foreach ($toRemove as $remove){
if (strpos($key, $remove) !== false) unset($scripts[$key]);
}
}
$header['scripts'] = $scripts;
$document->setHeadData($header);
}
}
// Browser detection
//
//
//
// Functions usable for views
//
//
//
// function to get layout for specified mode
public function getLayout($mode) {
// check layout saved in cookie
$tpl_name = str_replace(' ', '_', JText::_('TPL_GK_LANG_NAME'));
$cookie_name = 'gkGavernMobile'.$tpl_name;
$cookie = (isset($_COOKIE[$cookie_name])) ? $_COOKIE[$cookie_name] : 'mobile';
if ($mode == 'mobile' && $cookie == 'mobile') { // mobile mode
if( $this->browser->get('browser') == 'iphone' ) { // iphone
$layoutpath = $this->URLtemplatepath() . DS . 'layouts' . DS . $this->getParam('iphone_layout', 'iphone') . '.php';
if (is_file($layoutpath)) include ($layoutpath);
else echo 'iPhone layout doesn\'t exist!';
} else if( $this->browser->get('browser') == 'android' ) { // android
$layoutpath = $this->URLtemplatepath() . DS . 'layouts' . DS . $this->getParam('android_layout', 'android') . '.php';
if (is_file($layoutpath)) include ($layoutpath);
else echo 'Android layout doesn\'t exist!';
} else { // handheld
$layoutpath = $this->URLtemplatepath() . DS . 'layouts' . DS . $this->getParam('handheld_layout', 'handheld') . '.php';
if (is_file($layoutpath)) include ($layoutpath);
else echo 'Handheld layout doesn\'t exist!';
}
} else {
if ($mode == 'facebook') { // facebook mode
$layoutpath = $this->URLtemplatepath() . DS . 'layouts' . DS . $this->getParam('facebook_layout', 'facebook') . '.php';
if (is_file($layoutpath)) include ($layoutpath);
else echo 'Facebook layout doesn\'t exist!';
} else { // normal mode
// check the override
$is_overrided = $this->getLayoutOverride();
// if current page is overrided
if ($is_overrided !== false) {
$layoutpath = $this->URLtemplatepath() . DS . 'layouts' . DS . $is_overrided . '.php';
if (is_file($layoutpath)) {
include ($layoutpath);
} else {
$layoutpath = $this->URLtemplatepath() . DS . 'layouts' . DS . $this->getParam('default_layout', 'default') . '.php';
if (is_file($layoutpath)) {
include ($layoutpath);
} else {
echo 'Default layout doesn\'t exist!';
}
}
} else { // else - load default layout
$layoutpath = $this->URLtemplatepath() . DS . 'layouts' . DS . $this->getParam('default_layout', 'default') . '.php';
if (is_file($layoutpath)) {
include ($layoutpath);
} else {
echo 'Default layout doesn\'t exist!';
}
}
}
}
}
// function to get page suffix
public function getSuffix() {
// check the override
$is_overrided = $this->getSuffixOverride();
// if current page is overrided
if ($is_overrided !== false) {
$this->page_suffix = $is_overrided;
} else {
$this->page_suffix = '';
}
}
// function to get page suffix
public function getModuleStyles() {
$keys = array_keys($this->module_styles);
$module_override = $this->config->get('module_override');
for($i = 0; $i < count($keys); $i++) {
if(isset($module_override[$keys[$i]])) {
$this->module_styles[$keys[$i]] = $module_override[$keys[$i]];
}
}
}
// function to load specified block
public function loadBlock($path) {
jimport('joomla.filesystem.file');
if(JFile::exists($this->URLtemplatepath() . DS . 'layouts' . DS . 'blocks' . DS . $path . '.php')) {
include($this->URLtemplatepath() . DS . 'layouts' . DS . 'blocks' . DS . $path . '.php');
}
}
// function to get menu type
public function getMenuType() {
// check layout saved in cookie
$tpl_name = str_replace(' ', '_', JText::_('TPL_GK_LANG_NAME'));
$cookie_name = 'gkGavernMobile'.$tpl_name;
$cookie = (isset($_COOKIE[$cookie_name])) ? $_COOKIE[$cookie_name] : 'mobile';
if(!$this->browser->get('mobile') || $cookie == 'desktop') {
// check the override
$is_overrided = $this->getMenuOverride();
$menu_type = 'gk_menu';
// if current menu is overrided
$menu_type = ($is_overrided !== false) ? $is_overrided : $this->getParam('menu_type', 0);
} else {
if(($this->browser->get('browser') == 'iphone' && $this->getParam('iphone_layout', 'iphone')!='iphone') || ($this->browser->get('browser') == 'android' && $this->getParam('android_layout', 'android')!='android') || ($this->browser->get('browser') == 'handheld' && $this->getParam('handheld_layout', 'handheld')!='handheld')){
$menu_type = $this->getParam('menu_type', 0);
} else {
$menu_type = ($this->browser->get('browser') == 'iphone' || $this->browser->get('browser') == 'android') ? 'gk_iphone' : 'gk_handheld';
}
}
// select the menu
switch ($menu_type) {
case 'gk_iphone' :
$file = dirname(__file__) . DS . 'menu' . DS . 'GKIPhone.php';
if (!is_file($file)) return null;
require_once ($file);
$menuclass = 'GKIPhone';
$this->generateSubmenu = false;
break;
case 'gk_handheld' :
$file = dirname(__file__) . DS . 'menu' . DS . 'GKHandheld.php';
if (!is_file($file)) return null;
require_once ($file);
$menuclass = 'GKHandheld';
$this->generateSubmenu = false;
break;
case 'gk_menu':
$file = dirname(__file__) . DS . 'menu' . DS . 'GKMenu.php';
if (!is_file($file)) return null;
require_once ($file);
$menuclass = 'GKMenu';
$this->generateSubmenu = false;
break;
case 'gk_dropline':
$file = dirname(__file__) . DS . 'menu' . DS . 'GKDropline.php';
if (!is_file($file)) return null;
require_once ($file);
$menuclass = 'GKDropline';
$this->generateSubmenu = true;
break;
case 'gk_split':
$file = dirname(__file__) . DS . 'menu' . DS . 'GKSplit.php';
if (!is_file($file)) return null;
require_once ($file);
$menuclass = 'GKSplit';
$this->generateSubmenu = true;
break;
default:
$file = dirname(__file__) . DS . 'menu' . DS . 'GKMenu.php';
if (!is_file($file)) return null;
require_once ($file);
$menuclass = 'GKMenu';
$this->generateSubmenu = false;
break;
}
$gkmenu = new $menuclass($this->API->params);
$gkmenu->_tmpl = $this->API;
return $gkmenu;
}
// function to get layout override
public function getLayoutOverride() {
// get current ItemID
$ItemID = JRequest::getInt('Itemid');
// get current option value
$option = JRequest::getCmd('option');
// override array
$layout_overrides = $this->config->get('layout_override');
// check the config
if (isset($layout_overrides[$ItemID])) {
return $layout_overrides[$ItemID];
} else {
if (isset($layout_overrides[$option])) {
return $layout_overrides[$option];
} else {
return false;
}
}
}
// function to get layout override
public function getSuffixOverride() {
// get current ItemID
$ItemID = JRequest::getInt('Itemid');
// get current option value
$option = JRequest::getCmd('option');
// override array
$suffix_overrides = $this->config->get('suffix_override');
// check the config
if (isset($suffix_overrides[$ItemID])) {
return $suffix_overrides[$ItemID];
} else {
if (isset($suffix_overrides[$option])) {
return $suffix_overrides[$option];
} else {
return false;
}
}
}
// function to get menu override
public function getMenuOverride() {
// get current ItemID
$ItemID = JRequest::getInt('Itemid');
// get current option value
$option = JRequest::getCmd('option');
// override array
$menu_overrides = $this->config->get('menu_override');
// check the config
if (isset($menu_overrides[$ItemID])) {
return $menu_overrides[$ItemID];
} else {
if (isset($menu_overrides[$option])) {
return $menu_overrides[$option];
} else {
return false;
}
}
}
// function to get tools override
public function getToolsOverride() {
// get current ItemID
$ItemID = JRequest::getInt('Itemid');
// get current option value
$option = JRequest::getCmd('option');
// override array
$tools_override = $this->config->get('tools_override');
// get current tools setting
$tools_type = $this->getParam('tools', 'all');
if($tools_type == 'all') { return true; }
else if($tools_type == 'none') { return false; }
else if($tools_type == 'selected') {
if (isset($tools_override[$ItemID])) { return true; }
else { return false; }
}
else {
if (isset($tools_override[$ItemID])) { return false; }
else { return true; }
}
}
public function getMooToolsOverride() {
// get current ItemID
$ItemID = JRequest::getInt('Itemid');
// get current option value
$option = JRequest::getCmd('option');
// override array
$mootools_override = $this->config->get('mootools_override');
// check the config
if (isset($mootools_override[$ItemID])) {
return $mootools_override[$ItemID];
} else {
if (isset($mootools_override[$option])) {
return $mootools_override[$option];
} else {
return false;
}
}
}
// function to generate columns block
public function generateColumnsBlock($amount, $base_name, $group_id, $start_num) {
// returns:
// array(
// [number] => array(
// "class" => // class of the position
// "width" => // width of the position
// "name" => // name of the position
// ),
// ...
// )
// possible classes: gkColLeft, gkColRight, gkColCenter, gkColFull
$amount_of_columns = 0;
// column existing
$columns = array();
// check how many columns you have to generate
for($i = $start_num; $i <= $amount + ($start_num - 1); $i++) {
if($this->modules($base_name . $i)) {
$columns[$i] = true;
$amount_of_columns++;
} else {
$columns[$i] = false;
}
}
// if any column exists
if($amount_of_columns > 0) {
// variable to store column width
$column_width = '100';
// check if more than one column exists
if($amount_of_columns > 1) {
// automatically recognize the widest column
$widest_column = $this->getParam($group_id . '_widest', '');
$widest_column_value = $this->getParam($group_id . '_widest_value', 0);
// check if the widest column is visible
if($this->modules($widest_column) && $widest_column_value != 0) {
$column_width = round((100 - $widest_column_value) / ($amount_of_columns - 1), 3);
$column_width = round($column_width - 0.005, 2);
$result = array();
$added_amount = 0;
//
for($i = $start_num; $i <= $amount + ($start_num - 1); $i++) {
if($columns[$i]) {
$added_amount++;
$column_class = ($added_amount == 1) ? 'gkColLeft' : (($added_amount == $amount_of_columns) ? 'gkColRight' : 'gkColCenter');
$result[$i-$start_num] = array(
"class" => $column_class,
"width" => ($base_name . $i == $widest_column) ? $widest_column_value : $column_width,
"name" => $base_name . $i
);
}
}
} else { // all columns are equal
$column_width = round(100 / $amount_of_columns, 3);
$column_width = round($column_width - 0.005, 2);
$result = array();
$added_amount = 0;
for($i = $start_num; $i <= $amount + ($start_num - 1); $i++) {
if($columns[$i]) {
$added_amount++;
$column_class = ($added_amount == 1) ? 'gkColLeft' : (($added_amount == $amount_of_columns) ? 'gkColRight' : 'gkColCenter');
$result[$i-$start_num] = array(
"class" => $column_class,
"width" => $column_width,
"name" => $base_name . $i
);
}
}
}
} else {
$active_index = 0;
for($i = $start_num; $i <= $amount + ($start_num - 1); $i++) {
if($columns[$i]) $active_index = $i;
}
$result = array(
"0" => array(
"class" => 'gkColFull',
"width" => '100',
"name" => $base_name . $active_index
)
);
}
return $result;
} else { // if any column exists - return null
return null;
}
}
// function to generate columns widths
public function generateColumnsWidth() {
// header column
if($this->modules('header1 and header2')) {
$this->addCSSRule('#gkHeader1 { width: ' . $this->getParam('header_column_width', '50'). '%; }');
$this->addCSSRule('#gkHeader2 { width: ' . (($this->getParam('header_spaces', 'nospace') == 'nospace' ? 100 : 98 ) - $this->getParam('header_column_width', '50')) . '%; }');
} else {
$this->addCSSRule('#gkHeader1 { width:100%}');
$this->addCSSRule('#gkHeader2 { width:100%}');
}
// left column
if($this->modules('left_left and left_right')) {
$this->addCSSRule('#gkLeftLeft { width: ' . $this->getParam('left2_column_width', '50'). '%; }');
$this->addCSSRule('#gkLeftRight { width: ' . (100 - $this->getParam('left2_column_width', '50')) . '%; }');
}
// right column
if($this->modules('right_left and right_right')) {
$this->addCSSRule('#gkRightLeft { width: ' . $this->getParam('right2_column_width', '50'). '%; }');
$this->addCSSRule('#gkRightRight { width: ' . (100 - $this->getParam('right2_column_width', '50')) . '%; }');
}
// main column
if($this->modules('inset1 and inset2')) {
$this->addCSSRule('#gkInset1 { width: ' . $this->getParam('inset_column_width', '20'). '%; }');
$this->addCSSRule('#gkInset2 { width: ' . $this->getParam('inset2_column_width', '20'). '%; }');
$this->addCSSRule('#gkComponentWrap { width: ' . (100 - ($this->getParam('inset_column_width', '20') + $this->getParam('inset2_column_width', '20'))) . '%; }');
} elseif($this->modules('inset1 or inset2')) {
if($this->modules('inset1')) {
$this->addCSSRule('#gkInset1 { width: ' . $this->getParam('inset_column_width', '20'). '%; }');
$this->addCSSRule('#gkComponentWrap { width: ' . (100 - $this->getParam('inset_column_width', '20')) . '%; }');
} else {
$this->addCSSRule('#gkInset2 { width: ' . $this->getParam('inset2_column_width', '20'). '%; }');
$this->addCSSRule('#gkComponentWrap { width: ' . (100 - $this->getParam('inset2_column_width', '20')) . '%; }');
}
}
// all columns
$left_column = $this->modules('left_top + left_bottom + left_left + left_right');
$right_column = $this->modules('right_top + right_bottom + right_left + right_right');
if($left_column && $right_column) {
$this->addCSSRule('#gkLeft { width: ' . $this->getParam('left_column_width', '20'). '%; }');
$this->addCSSRule('#gkRight { width: ' . $this->getParam('right_column_width', '20'). '%; }');
$this->addCSSRule('#gkContent { width: ' . (100 - ($this->getParam('left_column_width', '20') + $this->getParam('right_column_width', '20'))) . '%; }');
} elseif ( $left_column ) {
$this->addCSSRule('#gkLeft { width: ' . $this->getParam('left_column_width', '20'). '%; }');
$this->addCSSRule('#gkContent { width: ' . (100 - $this->getParam('left_column_width', '20')) . '%; }');
} elseif ( $right_column ) {
$this->addCSSRule('#gkRight { width: ' . $this->getParam('right_column_width', '20'). '%; }');
$this->addCSSRule('#gkContent { width: ' . (100 - $this->getParam('right_column_width', '20')) . '%; }');
}
}
// function to generate blocks paddings
public function generatePadding($block) {
// main blocks
if($block == 'gkMainBlock') return 'gkPaddingTLR';
// gkMainBlock
if($block == 'gkContentColumn') {
if($this->modules('right_top + right_bottom + right_left + right_right')) {
return 'gkPaddingR';
}
return '';
}
// Content
if($block == 'gkInset1') return 'gkPaddingTBL';
if($block == 'gkInset2') return 'gkPaddingTBR';
if($block == 'gkComponentWrap') return ($this->modules('inset1')) ? 'gkPaddingL' : '';
// left column
if($block == 'gkLeftLeft') return ($this->modules('left_right')) ? ' gkPaddingR' : '';
// right column
if($block == 'gkRightLeft') return ($this->modules('right_right')) ? ' gkPaddingR' : '';
// main column
if($block == 'gkContentTop' || $block == 'gkContentBottom') {
if($this->modules('right_top + right_bottom + right_left + right_right')) return 'gkPaddingTBL';
else return 'gkPaddingTBLR';
}
if($block == 'gkContentMainbody') {
if($this->modules('right_top + right_bottom + right_left + right_right')) {
return 'gkPaddingR';
}
return '';
}
}
// function to check if mainbody exists
public function mainExists($mode){
if($mode == 'all') {
return ($this->checkComponent() || $this->checkMainbody() || $this->modules('left_top + left_bottom + left_left + left_right + right_top + right_bottom + right_left + right_right + top + bottom + mainbody_top + mainbody_bottom + inset1 + inset2 + mainbody'));
} elseif($mode == 'content') {
return ($this->checkComponent() || $this->checkMainbody() || $this->modules('mainbody_top + mainbody_bottom + mainbody + inset1 + inset2 + top + bottom'));
} elseif($mode == 'content_mainbody') {
return ($this->checkComponent() || $this->checkMainbody() || $this->modules('mainbody_top + mainbody_bottom + mainbody + inset1 + inset2'));
} elseif($mode == 'component_wrap') {
return ($this->checkComponent() || $this->checkMainbody() || $this->modules('mainbody_top + mainbody_bottom + mainbody'));
} elseif($mode == 'component') {
return ($this->checkComponent() || $this->checkMainbody());
}
}
// function to check if component exists
function checkComponent() {
if($this->isFrontpage()) {
$result = ($this->getParam('mainbody_frontpage', '') != 'only_mainbody');
return (!isset($_POST['option'])) ? $result : true;
}else {
return !($this->getParam('mainbody_subpage', '') == 'mainbody_or_component' && $this->modules("mainbody") > 0);
}
}
// function to check if mainbody exists
function checkMainbody() {
if($this->isFrontpage()) {
return (($this->getParam('mainbody_frontpage', '') != 'only_component') && $this->modules("mainbody") > 0);
} else {
return ($this->getParam('mainbody_subpage', '') == 'mainbody_or_component' && $this->modules("mainbody") > 0);
}
}
function isFrontpage(){
// get all known languages
$languages = JLanguage::getKnownLanguages();
$menu = JSite::getMenu();
foreach($languages as $lang){
if ($menu->getActive() == $menu->getDefault( $lang['tag'] )) {
return true;
}
}
return false;
}
public function addTouchIcon() {
$touch_image = $this->getParam('touch_image', '');
if($touch_image == '') {
$touch_image = $this->URLtemplate() . '/images/touch-device.png';
} else {
$touch_image = $this->URLtemplate() . $touch_image;
}
$doc = JFactory::getDocument();
$doc->addCustomTag('<link rel="apple-touch-icon" href="'.$touch_image.'">');
$doc->addCustomTag('<link rel="apple-touch-icon-precompose" href="'.$touch_image.'">');
}
// function to generate the messages on specified position
public function messages($position) {
if($position == $this->getParam('messages_position', 'message-position-1')) {
echo '<jdoc:include type="message" />';
}
}
// Parse Facebook and Tweeter buttons
public function socialApiParser($embed_mode = false) {
// FB login
if(!($this->getParam('fb_api_id', '') != '' && $this->getParam('fb_login', '0') == 1) || $this->browser->get('mobile')) {
// clear FB login
GKParser::$customRules['/<gavern:fblogin(.*?)gavern:fblogin>/mis'] = '';
} else {
GKParser::$customRules['/<gavern:fblogin>/mi'] = '';
GKParser::$customRules['/<\/gavern:fblogin>/mi'] = '';
}
// get the informations about excluded articles and categories
$excluded_articles = explode(',', $this->getParam('excluded_arts', ''));
$excluded_categories = $this->getParam('excluded_cats', '');
if(is_array($excluded_categories) && $excluded_categories[0] == '') $excluded_categories = array(0);
else if(is_string($excluded_categories)) $excluded_categories = array($excluded_categories);
// get the variables from the URL
$option = JRequest::getCmd('option', '');
$view = JRequest::getCmd('view', '');
$id = JRequest::getVar('id', '');
if(strpos($id, ':')) $id = substr($id, 0, strpos($id, ':'));
$catid = JRequest::getVar('catid', '');
if(strpos($catid, ':')) $catid = substr($catid, 0, strpos($catid, ':'));
// find catid if it is not set in the URL
if($catid == '' && $option == 'com_content' && $view == 'article' && $id != '') {
$db = JFactory::getDBO();
$query = 'SELECT catid FROM #__content AS c WHERE c.id = ' . $id . ' LIMIT 1';
// Set the query
$db->setQuery($query);
$results = $db->loadObjectList();
// get the new category ID
if(count($results) > 0) {
$catid = $results[0]->catid;
}
}
// excluded
$is_excluded = false;
// FB like
if($this->getParam('fb_like', '0') == 1 && !$is_excluded && !$this->browser->get('mobile')) {
// configure FB like
$fb_like_attributes = '';
// configure FB like
if($this->getParam('fb_like_send', 1) == 1) { $fb_like_attributes .= ' send="true"'; }
$fb_like_attributes .= ' layout="'.$this->getParam('fb_like_layout', 'standard').'"';
$fb_like_attributes .= ' show_faces="'.$this->getParam('fb_like_show_faces', 'true').'"';
$fb_like_attributes .= ' width="'.$this->getParam('fb_like_width', '500').'"';
$fb_like_attributes .= ' action="'.$this->getParam('fb_like_action', 'like').'"';
$fb_like_attributes .= ' font="'.$this->getParam('fb_like_font', 'arial').'"';
$fb_like_attributes .= ' colorscheme="'.$this->getParam('fb_like_colorscheme', 'light').'"';
GKParser::$customRules['/GK_FB_LIKE_SETTINGS/'] = $fb_like_attributes;
} else {
// clear FB like
GKParser::$customRules['/<gavern:social><fb:like(.*?)fb:like><\/gavern:social>/mi'] = '';
}
// G+
if($this->getParam('google_plus', '1') == 1 && !$is_excluded && !$this->browser->get('mobile')) {
// configure FB like
$google_plus_attributes = '';
// configure FB like
if($this->getParam('google_plus_annotation', 'inline') != 'bubble') {
$google_plus_attributes .= ' annotation="'.$this->getParam('google_plus_annotation', 'inline').'"';
}
if($this->getParam('google_plus_size', 'medium') != 'standard') {
$google_plus_attributes .= ' size="'.$this->getParam('google_plus_size', 'medium').'"';
}
if($this->getParam('google_plus_annotation', 'inline') == 'inline') {
$google_plus_attributes .= ' width="'.$this->getParam('google_plus_width', '250').'"';
}
GKParser::$customRules['/GK_GOOGLE_PLUS_SETTINGS/'] = $google_plus_attributes;
} else {
// clear G+ button
GKParser::$customRules['/<gavern:social><g:plusone(.*?)g:plusone><\/gavern:social>/mi'] = '';
}
// G+ Share button
if($this->getParam('google_plus_share', '1') == 1 && !$is_excluded && !$this->browser->get('mobile')) {
$google_plus_share_attributes = '';
$google_plus_share_attributes .= ' annotation="'.$this->getParam('google_plus_share_annotation', 'vertical-bubble').'"';
if($this->getParam('google_plus_share_annotation', 'vertical-bubble') != 'vertical-bubble') {
$google_plus_share_attributes .= ' height="'.$this->getParam('google_plus_share_size', '20').'"';
}
GKParser::$customRules['/GK_GOOGLE_PLUS_SHARE_SETTINGS/'] = $google_plus_share_attributes;
} else {
// clear G+ share button
GKParser::$customRules['/<gavern:social><g:plus(.*?)g:plus><\/gavern:social>/mi'] = '';
}
// Twitter
if($this->getParam('tweet_btn', '0') == 1 && !$is_excluded && !$this->browser->get('mobile') && $option == 'com_content' && $view == 'article') {
// configure Twitter buttons
$tweet_btn_attributes = '';
$tweet_btn_attributes .= ' data-count="'.$this->getParam('tweet_btn_data_count', 'vertical').'"';
if($this->getParam('tweet_btn_data_via', '') != '') $tweet_btn_attributes .= ' data-via="'.$this->getParam('tweet_btn_data_via', '').'"';
$tweet_btn_attributes .= ' data-lang="'.$this->getParam('tweet_btn_data_lang', 'en').'"';
GKParser::$customRules['/GK_TWEET_BTN_SETTINGS/'] = $tweet_btn_attributes;
} else {
// clear Twitter buttons
GKParser::$customRules['/<gavern:social><a href="http:\/\/twitter.com\/share"(.*?)\/a><\/gavern:social>/mi'] = '';
}
// Digg
if($this->getParam('digg_btn', '0') == 1 && !$is_excluded && !$this->browser->get('mobile')) {
// configure Twitter buttons
$digg_btn_attributes = $this->getParam('digg_btn_style', 'DiggWide');
GKParser::$customRules['/GK_DIGG_SETTINGS/'] = $digg_btn_attributes;
} else {
// clear Twitter buttons
GKParser::$customRules['/<gavern:social><a class="DiggThisButton(.*?)\/a><\/gavern:social>/mi'] = '';
}
// Delicious
if($this->getParam('delicious_btn', '0') != 1 || $is_excluded || $this->browser->get('mobile')) {
// clear Delicious buttons
GKParser::$customRules['/<gavern:social><a href="https?:\/\/www.delicious.com\/save"(.*?)\/a><\/gavern:social>/mi'] = '';
}
// Instapaper
if($this->getParam('instapaper_btn', '0') != 1 || $is_excluded || $this->browser->get('mobile')) {
// clear Delicious buttons
GKParser::$customRules['/<gavern:social><a href="https?:\/\/www.instapaper.com\/hello2(.*?)\/a><\/gavern:social>/mi'] = '';
}
// Pinterest
if($this->getParam('pinterest_btn', '0') == 1 && !$is_excluded && !$this->browser->get('mobile')) {
// configure Pinterest buttons
$pinterest_btn_attributes = $this->getParam('pinterest_btn_style', 'horizontal');
GKParser::$customRules['/GK_PINTEREST_SETTINGS/'] = $pinterest_btn_attributes;
} else {
// clear Pinterest button
GKParser::$customRules['/<gavern:social><a href="https?:\/\/pinterest.com\/pin\/create\/button\/(.*?)\/a><\/gavern:social>/mi'] = '';
}
// check the excluded article IDs and category IDs
if(($option == 'com_content' && $view == 'article' && in_array($id, $excluded_articles, false)) ||
($catid != '' && $option == 'com_content' && $view == 'article' && in_array($catid, $excluded_categories, false)) || $embed_mode) {
$is_excluded = true;
// clear SocialAPI div
GKParser::$customRules['/<gavern:social(.*?)gavern:social>/mis'] = '';
GKParser::$customRules['/<gavern:socialAPI(.*?)gavern:socialAPI>/mis'] = '';
} else {
GKParser::$customRules['/<gavern:social>/mi'] = '';
GKParser::$customRules['/<\/gavern:social>/mi'] = '';
GKParser::$customRules['/<gavern:socialAPI>/mi'] = '';
GKParser::$customRules['/<\/gavern:socialAPI>/mi'] = '';
}
GKParser::$customRules['/<meta name="og:/'] = '<meta property="og:';
}
function mobileParser() {
if($this->browser->get('mobile')) {
// clear desktop elements
GKParser::$customRules['/<gavern:desktop(.*?)gavern:desktop>/mis'] = '';
GKParser::$customRules['/<gavern:mobile>/mis'] = '';
GKParser::$customRules['/<\/gavern:mobile>/mis'] = '';
if(($this->browser->get('browser') == 'iphone' || $this->browser->get('browser') == 'android') &&
$this->getParam('mobile_collapsible', '0') == '1') {
GKParser::$customRules['/<gavern:gk_collapsible\/>/mis'] = ' class="gkCollapsible"';
GKParser::$customRules['/<gavern:gk_collapsible_button\/>/mis'] = '<span class="gkToggle show">Toggle</span>';
} else {
GKParser::$customRules['/<gavern:gk_collapsible\/>/mis'] = ' class="gkFeaturedItemTitle"';
GKParser::$customRules['/<gavern:gk_collapsible_button\/>/mis'] = '';
}
} else {
// clear mobile elements
GKParser::$customRules['/<gavern:mobile(.*?)gavern:mobile>/mis'] = '';
GKParser::$customRules['/<gavern:desktop>/mis'] = '';
GKParser::$customRules['/<\/gavern:desktop>/mis'] = '';
GKParser::$customRules['/<gavern:gk_collapsible\/>/mis'] = '';
GKParser::$customRules['/<gavern:gk_collapsible_button\/>/mis'] = '';
}
}
function googleAnalyticsParser(){
$data = $this->getParam('google_analytics','');
$exploded_data = explode("\r\n", $data);
$script_code = '';
if(count($exploded_data) >= 1) {
for ($i = 0; $i < count($exploded_data); $i++) {
if(isset($exploded_data[$i])) {
$key = $exploded_data[$i];
if(preg_match('/^UA(.*)/i', $key)) {
if($this->getParam('cookie_consent', '0') == 0) {
$script_code .= '<script type="text/javascript">';
} else {
$script_code .= '<script type="text/plain" class="cc-onconsent-analytics">';
}
$script_code .= 'var _gaq = _gaq || []; _gaq.push([\'_setAccount\', \'' .$key. '\']); _gaq.push([\'_trackPageview\']);(function() { var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true;ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' : \'http://www\') + \'.google-analytics.com/ga.js\';var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s); })();</script>';
}
}
}
}
return $script_code;
}
//
//
//
// Other functions
//
//
//
public function overrideArrayParse($data)
{
$results = array();
// exploding settings
$exploded_data = explode("\r\n", $data);
// parsing
for ($i = 0; $i < count($exploded_data); $i++) {
if(isset($exploded_data[$i])) {
// preparing pair key-value
$pair = explode('=', trim($exploded_data[$i]));
// extracting key and value from pair
if(count($pair) == 2){
$key = $pair[0];
$value = $pair[1];
// checking existing of key in config array
if (!isset($this->results[$key])) {
// setting value for key
$results[$key] = $value;
}
}
}
}
// return results array
return $results;
}
//
//
// Function for CSS/JS compression
//
//
function registerCache() {
$dispatcher = JDispatcher::getInstance();
$dispatcher->register('onBeforeRender', 'useCache');
}
function registerJSCompression() {
$dispatcher = JDispatcher::getInstance();
$dispatcher->register('onBeforeCompileHead', 'useJSCompression');
}
//
//
//
// Override of the Joomla API functions
//
//
//
public function addCSS($url) {
$this->API->addStyleSheet($url);
}
public function addJS($url) {
$this->API->addScript($url);
}
public function addCSSRule($code) {
$this->API->addStyleDeclaration($code);
}
public function addJSFragment($code) {
$this->API->addScriptDeclaration($code);
}
public function getParam($key, $default) {
return $this->API->params->get($key, $default);
}
public function modules($rule) {
return $this->API->countModules($rule);
}
public function URLbase() {
return JURI::base();
}
public function URLtemplate() {
return JURI::base() . "templates/" . $this->API->template;
}
public function URLpath() {
return JPATH_SITE;
}
public function URLtemplatepath() {
return $this->URLpath() . DS . "templates" . DS . $this->API->template;
}
public function getPageName() {
$config = new JConfig();
return $config->sitename;
}
}
if(!function_exists('GKParserPlugin')){
function GKParserPlugin(){
$parser = new GKParser();
}
}
if(!function_exists('useCache')){
function useCache() {
$document = JFactory::getDocument();
$cache_css = $document->params->get('css_compression');
$overwrite = $document->params->get('css_cache');
$toAddURLs = array();
$toRemove = array();
$scripts = array();
$css_urls = array();
if($document->params->get('jscss_excluded') != '') {
$toRemove = explode(',',$document->params->get('jscss_excluded'));
}
if ($cache_css) {
foreach ($document->_styleSheets as $strSrc => $strAttr) {
if (!preg_match('/\?.{1,}$/', $strSrc) && (!isset($strAttr['media']) || $strAttr['media'] == '')) {
$break = false;
if(count($toRemove) > 0) {
foreach ($toRemove as $remove) {
$remove = str_replace(' ', '', $remove);
if(strpos($strSrc, $remove) !== false) {
$toAddURLs[] = $strSrc;
$break = true;
continue;
}
}
}
if(!$break) {
if (!preg_match('/\?.{1,}$/', $strSrc)) {
$srcurl =cleanUrl($strSrc);
if (!$srcurl) continue;
//remove this css and add later
if($srcurl != 'components/com_community/templates/gk_style/css/style.css') {
unset($document->_styleSheets[$strSrc]);
$path = str_replace('/', DS, $srcurl);
$css_urls[] = array(JPATH_SITE . DS . $path, $srcurl);
}
//$document->_styleSheets = array();
}
}
}
}
}
// re-add external scripts
foreach($toAddURLs as $url) {
$document->addStylesheet($url);
}
if ($cache_css) {
$url = optimizecss($css_urls, $overwrite);
if ($url) {
$document->addStylesheet($url);
} else {
foreach ($css_urls as $urls) {
$document->addStylesheet($urls[1]); //re-add stylesheet to head
}
}
}
}
}
if(!function_exists('useJSCompression')){
function useJSCompression()
{
$js_urls = array();
$toAddURLs = array();
$document = &JFactory::getDocument();
$toRemove = array();
$break = false;
if($document->params->get('jscss_excluded') != '') {
$toRemove = explode(',',$document->params->get('jscss_excluded'));
}
foreach ($document->_scripts as $strSrc => $strAttr) {
if(count($toRemove) > 0) {
foreach ($toRemove as $remove){
$remove = str_replace(' ', '', $remove);
if(strpos($strSrc, $remove) !== false) {
$toAddURLs[] = $strSrc;
$break = true;
continue;
}
}
}
if(!$break) {
$srcurl = cleanUrl($strSrc);
unset($document->_scripts[$strSrc]);
if (!$srcurl){
$js_urls[] = array($strSrc, $strSrc);
} else {
$path = str_replace('/', DS, $srcurl);
$js_urls[] = array(JPATH_SITE . DS . $path, JURI::base(true) . '/' . $srcurl);
}
}
$break = false;
}
// clean all scripts
$document->_scripts = array();
// optimize or re-add
$url = optimizejs($js_urls, false);
if ($url) {
$document->addScript($url);
} else {
foreach ($js_urls as $urls) $document->addScript($url[1]); //re-add stylesheet to head
}
// re-add external scripts
foreach($toAddURLs as $url) $document->addScript($url);
}
}
if(!function_exists('cleanUrl')){
function cleanUrl($strSrc) {
if (preg_match('/^https?\:/', $strSrc)) {
if (!preg_match('#^' . preg_quote(JURI::base()) . '#', $strSrc)) return false; //external css
$strSrc = str_replace(JURI::base(), '', $strSrc);
} else {
if (preg_match('/^\//', $strSrc)) {
if (!preg_match('#^' . preg_quote(JURI::base(true)) . '#', $strSrc)) return false; //same server, but outsite website
$strSrc = preg_replace('#^' . preg_quote(JURI::base(true)) . '#', '', $strSrc);
}
}
$strSrc = str_replace('//', '/', $strSrc);
$strSrc = preg_replace('/^\//', '', $strSrc);
return $strSrc;
}
}
if(!function_exists('optimizecss')){
function optimizecss($css_urls, $overwrite = false) {
$content = '';
$files = '';
//jimport('joomla.filesystem.file');
foreach ($css_urls as $url) {
$files .= $url[1];
//join css files into one file
$content .= "/* FILE: {$url[1]} */\n" . compresscss(JFile::read($url[1]), $url[1]) . "\n\n";
}
$file = md5($files) . '.css';
if(useGZip()) $file = $file.'.php';
$expireHeader = (int) 30 * 24 * 60 * 60;
if(useGZip()) {
$headers = "<?php if(extension_loaded('zlib')){ob_start('ob_gzhandler');} header(\"Content-type: text/css\");";
$headers .= "header(\"Content-Encoding: gzip\");";
}
$headers .= "header('Expires: " . gmdate('D, d M Y H:i:s', strtotime(date('D, d M Y H:i:s')) + $expireHeader) . " GMT');";
$headers .= "header('Last-Modified: " . gmdate('D, d M Y H:i:s', strtotime(date('D, d M Y H:i:s'))) . " GMT');";
$headers .= "header('Cache-Control: Public');";
$headers .= "header('Vary: Accept-Encoding');?>";
$content = $headers . $content;
$url = store_file($content, $file, $overwrite);
return $url;
}
}
if(!function_exists('optimizejs')){
function optimizejs($js_urls, $overwrite = false) {
$content = '';
$files = '';
jimport('joomla.filesystem.file');
foreach ($js_urls as $url) {
$files .= $url[1];
$srcurl = cleanUrl($url[1]);
if (!$srcurl){
if (preg_match('/http/', $url[0])) {
$external = file_get_contents($url[0]);
} else {
$external = file_get_contents('http:'.$url[0]);
}
$content .= "/* FILE: {$url[0]} */\n" . $external . "\n\n";
} else {
$content .= "/* FILE: {$url[1]} */\n" . @JFile::read($url[0]) . "\n\n";
}
}
$file = md5($files) . '.js';
if(useGZip()) $file = $file.'.php';
$path = JPATH_SITE . DS . 'cache' . DS . 'gk'. DS . $file;
if (is_file($path) && filesize($path) > 0) {
// skip compression and leave current URL
} else {
$content = compressjs($content);
}
$expireHeader = (int) 30 * 24 * 60 * 60;
if(useGZip()) {
$headers = "<?php if(extension_loaded('zlib')){ob_start('ob_gzhandler');} header(\"Content-type: text/javascript\");";
$headers .= "header(\"Content-Encoding: gzip\");";
}
$headers .= "header('Expires: " . gmdate('D, d M Y H:i:s', strtotime(date('D, d M Y H:i:s')) + $expireHeader) . " GMT');";
$headers .= "header('Last-Modified: " . gmdate('D, d M Y H:i:s', strtotime(date('D, d M Y H:i:s'))) . " GMT');";
$headers .= "header('Cache-Control: Public');";
$headers .= "header('Vary: Accept-Encoding');?>";
$content = $headers.$content;
$url = store_file($content, $file, true);
return $url;
}
}
if(!function_exists('compressjs')){
function compressjs($data) {
require_once(dirname(__file__) . DS . 'minify' . DS . 'JSMin.php');
$data = JSMin::minify($data);
return $data;
}
}
if(!function_exists('compresscss')){
function compresscss($data, $url) {
global $current_css_url;
$current_css_url = JURI::root() . $url;
/* remove comments */
$data = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $data);
/* remove tabs, spaces, new lines, etc. */
$data = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), ' ', $data);
/* remove unnecessary spaces */
$data = preg_replace('/[ ]+([{};,:])/', '\1', $data);
$data = preg_replace('/([{};,:])[ ]+/', '\1', $data);
/* remove empty class */
$data = preg_replace('/(\}([^\}]*\{\})+)/', '}', $data);
/* remove PHP code */
$data = preg_replace('/<\?(.*?)\?>/mix', '', $data);
/* replace url*/
$data = preg_replace_callback('/url\(([^\)]*)\)/', 'replaceurl', $data);
return $data;
}
}
if(!function_exists('replaceurl')){
function replaceurl($matches) {
$url = str_replace(array('"', '\''), '', $matches[1]);
global $current_css_url;
$url = converturl($url, $current_css_url);
return "url('$url')";
}
}
if(!function_exists('converturl')){
function converturl($url, $cssurl) {
$base = dirname($cssurl);
if (preg_match('/^(\/|http)/', $url))
return $url;
/*absolute or root*/
while (preg_match('/^\.\.\//', $url)) {
$base = dirname($base);
$url = substr($url, 3);
}
$url = $base . '/' . $url;
return $url;
}
}
if(!function_exists('store_file')){
function store_file($data, $filename, $overwrite = false) {
$path = 'cache' . DS . 'gk';
jimport('joomla.filesystem.folder');
if (!is_dir($path)) JFolder::create($path);
$path = $path . DS . $filename;
$url = JURI::base(true) .DS. 'cache'. DS .'gk' . DS. $filename;
if (is_file($path) && !$overwrite) return $url;
JFile::write($path, $data);
return is_file($path) ? $url : false;
}
}
if(!function_exists('useGZip')){
function useGZip() {
if (!isset($_SERVER['HTTP_ACCEPT_ENCODING'])) {
return false;
} elseif (!extension_loaded('zlib') || ini_get('zlib.output_compression')) {
return false;
} else {
return true;
}
}
}
// EOF
-
- Senior Boarder
- GK User
- Fri Dec 06, 2013 4:59 pm
You were editing gk.framework.php file
Please edit this file:
templates/gk_boutique/lib/framework/gk.browser.php
and correct it so "detect section" looks this way:
Please edit this file:
templates/gk_boutique/lib/framework/gk.browser.php
and correct it so "detect section" looks this way:
- Code: Select all
case 'mozilla':
if(preg_match('/Android/i', $browser->getAgentString())) {
$result->set('browser', 'android');
$result->set('mobile', true);
break;
} else if(preg_match('/iPhone/i', $browser->getAgentString())) {
$result->set('browser', 'iphone');
$result->set('mobile', true);
break;
} else {
$result->set('browser', 'ff');
break;
}
case 'chrome':
if(preg_match('/Android/i', $browser->getAgentString())) {
$result->set('browser', 'android');
$result->set('mobile', true);
} else if(preg_match('/Mobile Safari/i', $browser->getAgentString())) {
$result->set('browser', 'iphone');
$result->set('mobile', true);
} else if(preg_match('/iPad/i', $browser->getAgentString())) {
$result->set('browser', 'iphone');
$result->set('mobile', true);
} else {
$result->set('browser', 'chrome');
$result->set('mobile', false);
$result->set('css3', true);
}
case '':
foreach($userAgents as $item)
{
if(preg_match('/'.$item.'/i', $browser->getAgentString())){
$result->set('browser', 'ff');
$result->set('mobile', false);
$result->set('css3', true);
break;
} else {
$result->set('browser', 'handheld');
$result->set('mobile', true);
$result->set('css3', false);
}
}
break;
-
- Moderator
- GK User
- Tue Jan 07, 2014 6:40 am
Hi,
I'm not having success with the code posted by Cyberek on Fri Dec 06, 2013 4:59 pm. If I include the code, Chrome on the desktop also renders using the mobile template. Here's my user agent from whatsmyuseragent.com using Chrome on the desktop:
Kind regards,
Dave.
I'm not having success with the code posted by Cyberek on Fri Dec 06, 2013 4:59 pm. If I include the code, Chrome on the desktop also renders using the mobile template. Here's my user agent from whatsmyuseragent.com using Chrome on the desktop:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.68 Safari/537.36
Kind regards,
Dave.
-
- Senior Boarder
- GK User
- Tue Jan 07, 2014 1:24 pm
Could you please download modified file, compress it with system zip compressor and attach to this thread?
-
- Moderator
- GK User
- Tue Jan 07, 2014 8:22 pm
Hi,
I've attached the file as requested. I'm using a different theme instead (Black & White), however I presume gk.browser.php would not differ.
Kind regards,
Dave.
I've attached the file as requested. I'm using a different theme instead (Black & White), however I presume gk.browser.php would not differ.
Kind regards,
Dave.
-
- Senior Boarder
- GK User
- Wed Jan 08, 2014 5:39 pm
I have reported that problem to our devteam. Will write back as soon as I'll get correct fix.
-
- Moderator
- GK User
- Fri Jan 10, 2014 4:35 pm
Hi, While I don't use the same template - I have Game News. I accidentally stumbled upon this page because I was still having issues with the Chrome Mobile Browser not working properly on the iPad/iPhone platforms for my site - it was treating the site as if it was a normal desktop.
However the code that you gave out was pretty useful because I have now got this working on my site. I have no idea if it is 100% Stable but tests so far have proven positive.
Mind you the code had to be modified slightly because my template was different, but I think the reason the code you originally posted was not working was because it was missing some iPhone specific lines....
Anyway for me I edited the code from this location...../templates/gk_gamenews/lib/framework/gk.browser.php
From here I added your code....
But had to modify this slightly because the $result->set syntax part was written differently on my template i.e. it was written as follows...$this->result->set
I then slotted the modified code and added some extra lines thus it looked like this....
Note the extra code
And the break; line
Adding this seemed to sort the problem and now if I look at my website in the mobile version of Google Chorome via my iPhone 5s it treats it as the mobile version.
Here is the full code from this Php file to show how it fitted in.....
As I said I have no idea if it will help or if I have done this correctly but it seemed to work on my Game News Template, so it could prove useful - but make sure you backup your site and php file first
Brett
However the code that you gave out was pretty useful because I have now got this working on my site. I have no idea if it is 100% Stable but tests so far have proven positive.
Mind you the code had to be modified slightly because my template was different, but I think the reason the code you originally posted was not working was because it was missing some iPhone specific lines....
Anyway for me I edited the code from this location...../templates/gk_gamenews/lib/framework/gk.browser.php
From here I added your code....
- Code: Select all
case 'chrome':
if(preg_match('/Android/i', $browser->getAgentString())) {
$result->set('browser', 'android');
$result->set('mobile', true);
} else if(preg_match('/Mobile Safari/i', $browser->getAgentString())) {
$result->set('browser', 'iphone');
$result->set('mobile', true);
} else if(preg_match('/iPad/i', $browser->getAgentString())) {
$result->set('browser', 'iphone');
$result->set('mobile', true);
} else {
$result->set('browser', 'chrome');
$result->set('mobile', false);
$result->set('css3', true);
}
But had to modify this slightly because the $result->set syntax part was written differently on my template i.e. it was written as follows...$this->result->set
I then slotted the modified code and added some extra lines thus it looked like this....
- Code: Select all
case 'chrome':
if(preg_match('/Android/i', $browser->getAgentString())) {
$this->result->set('browser', 'android');
$this->result->set('mobile', true);
} else if(preg_match('/Mobile Safari/i', $browser->getAgentString())) {
$this->result->set('browser', 'iphone');
$this->result->set('mobile', true);
} else if(preg_match('/iPad/i', $browser->getAgentString())) {
$this->result->set('browser', 'iphone');
$this->result->set('mobile', true);
} else if(preg_match('/iPhone/i', $browser->getAgentString())) {
$this->result->set('browser', 'iphone');
$this->result->set('mobile', true);
} else {
$this->result->set('browser', 'chrome');
$this->result->set('mobile', false);
$this->result->set('css3', true);
}
break;
Note the extra code
- Code: Select all
} else if(preg_match('/iPhone/i', $browser->getAgentString())) {
$this->result->set('browser', 'iphone');
$this->result->set('mobile', true);
And the break; line
Adding this seemed to sort the problem and now if I look at my website in the mobile version of Google Chorome via my iPhone 5s it treats it as the mobile version.
Here is the full code from this Php file to show how it fitted in.....
- Code: Select all
<?php
/**
*
* GKBrowser class
*
* @version 3.0.0
* @package Gavern Framework
* @copyright Copyright (C) 2010 - 2012 GavickPro. All rights reserved.
*
*/
// No direct access.
defined('_JEXEC') or die;
class GKBrowser {
public $result;
public function __construct() {
jimport('joomla.environment.browser');
jimport('joomla.base.object');
$browser = JBrowser::getInstance();
$this->result = new JObject();
$this->result->set("tablet", false);
$this->result->set('mobile', false);
$userAgents = array(
'googlebot','msnbot','w3c','yahoo','acme.spider', 'ahoythehomepagefinder', 'aleksika spider', 'ia_archiver', 'alkaline', 'emcspider', 'antibot', 'arachnophilia','architext', 'aretha', 'ariadne', 'arks', 'aspider', 'atn.txt', 'atomz', 'auresys', 'awbot', 'backrub', 'baiduspider', 'bigbrother', 'bjaaland', 'blackwidow', 'blogsphere', 'isspider', 'blogshares bot', 'blogvisioneye', 'blogwatcher', 'blogwise.com-metachecker', 'bloodhound', 'bobby', 'bordermanager', 'boris', 'bravobrian bstop', 'brightnet', 'bspider', 'bumblebee', 'catvschemistryspider', 'calif', 'cassandra', 'ccgcrawl', 'checkbot', 'christcrawler', 'churl', 'cj spider', 'cmc', 'collective', 'combine', 'computer_and_automation_research_institute_crawler', 'robi', 'conceptbot', 'coolbot', 'cosmixcrawler', 'crawlconvera', 'cscrawler', 'cusco', 'cyberspyder', 'cydralspyder', 'daviesbot', 'deepindex', 'denmex websearch', 'deweb', 'blindekuh', 'dienstspider', 'digger','webreader', 'cgireader', 'diibot', 'digout4u', 'directhit', 'dnabot', 'downes', 'download_express', 'dragonbot', 'dwcp', 'e-collector', 'e-societyrobot', 'ebiness', 'echo', 'eit', 'elfinbot', 'emacs', 'enterprise_search', 'esther', 'evliyacelebi', 'exabot', 'exactseek', 'exalead ng', 'ezresult', 'fangcrawl', 'fast-webcrawler', 'fastbuzz.com', 'faxobot', 'feedster crawler', 'felix', 'fetchrover', 'fido', 'fish', 'flurryv', 'fdse', 'fouineur', 'franklin locator', 'freecrawl', 'frontier', 'funnelweb', 'gaisbot', 'galaxybot', 'gama', 'gazz', 'gcreep', 'getbot', 'puu', 'geturl', 'gigabot', 'gnodspider', 'golem', 'googlebot', 'gornker', 'grapnel', 'griffon', 'gromit', 'grub-client', 'hambot', 'hatena antenna', 'havindex', 'octopus', 'hometown', 'htdig', 'htmlgobble', 'pitkow', 'hyperdecontextualizer', 'finnish', 'irobot', 'iajabot', 'ibm', 'illinois state tech labs', 'imagelock', 'incywincy', 'informant', 'infoseek', 'infoseeksidewinder', 'infospider', 'ilse', 'ingrid', 'slurp', 'inspectorwww', 'intelliagent', 'cruiser', 'internet ninja', 'myweb', 'internetseer', 'iron33', 'israelisearch', 'javabee', 'jbot', 'jcrawler', 'jeeves', 'jennybot', 'jetbot', 'jobo', 'jobot', 'joebot', 'jumpstation', 'justview', 'katipo', 'kdd', 'kilroy', 'fireball', 'ko_yappo_robot', 'labelgrabber.txt', 'larbin', 'legs', 'linkidator', 'linkbot', 'linkchecker', 'linkfilter.net url verifier', 'linkscan', 'linkwalker', 'lockon', 'logo_gif', 'lycos', 'mac finder', 'macworm', 'magpie', 'marvin', 'mattie', 'mediafox', 'mediapartners-google', 'mercator', 'mercubot', 'merzscope', 'mindcrawler', 'moget', 'momspider', 'monster', 'mixcat', 'motor', 'mozdex', 'msiecrawler', 'msnbot', 'muscatferret', 'mwdsearch', 'my little bot', 'naverrobot', 'naverbot', 'meshexplorer', 'nederland.zoek', 'netresearchserver', 'netcarta', 'netcraft', 'netmechanic', 'netscoop', 'newscan-online', 'nextopiabot', 'nhse', 'nitle blog spider', 'nomad', 'gulliver', 'npbot', 'nutch', 'nzexplorer', 'obidos-bot', 'occam', 'sitegrabber', 'openfind', 'orb_search', 'overture-webcrawler', 'packrat', 'pageboy', 'parasite', 'patric', 'pegasus', 'perlcrawler', 'perman', 'petersnews', 'pka', 'phantom', 'piltdownman', 'pimptrain', 'pioneer', 'pipeliner', 'plumtreewebaccessor', 'polybot', 'pompos', 'poppi', 'iconoclast', 'pjspider', 'portalb', 'psbot', 'quepasacreep', 'raven', 'rbse', 'redalert', 'resumerobot', 'roadrunner', 'rhcs', 'robbie', 'robofox', 'francoroute', 'robozilla', 'roverbot', 'rules', 'seochat', 'safetynetrobot', 'scooter', 'search_au', 'searchprocess', 'searchspider', 'seekbot', 'semanticdiscovery', 'senrigan', 'sgscout', 'shaggy', 'shaihulud', 'sherlock-spider', 'shoutcast', 'sift', 'simbot', 'ssearcher', 'site-valet', 'sitespider', 'sitetech', 'slcrawler', 'slysearch', 'smartspider', 'snooper', 'solbot', 'soziopath', 'space bison', 'spanner', 'speedy', 'spiderbot', 'spiderline', 'spiderman', 'spiderview', 'spider_monkey', 'splatsearch.com', 'spry', 'steeler', 'suke', 'suntek', 'surveybot', 'sven', 'syndic8', 'szukacz', 'tach_bw', 'tarantula', 'tarspider', 'techbot', 'technoratibot', 'templeton', 'teoma_agent1', 'teradex', 'jubii', 'northstar', 'w3index', 'perignator', 'python', 'tkwww', 'webmoose', 'wombat', 'webfoot', 'wanderer', 'worm', 'timbobot', 'titan', 'titin', 'tlspider', 'turnitinbot', 'ucsd', 'udmsearch', 'ultraseek', 'unlost_web_crawler', 'urlck', 'vagabondo', 'valkyrie', 'victoria', 'visionsearch', 'voila', 'voyager', 'vspider', 'vwbot', 'w3m2', 'wmir', 'wapspider', 'appie', 'wallpaper', 'waypath scout', 'corev', 'web downloader', 'webbandit', 'webbase', 'webcatcher', 'webcompass', 'webcopy', 'webcraftboot', 'webfetcher', 'webfilter', 'webgather', 'weblayers', 'weblinker', 'webmirror', 'webquest', 'webrace', 'webreaper', 'websnarf', 'webspider', 'wolp', 'webstripper', 'webtrends link analyzer', 'webvac', 'webwalk', 'webwalker', 'webwatch', 'wz101', 'wget', 'whatuseek', 'whowhere', 'ferret', 'wired-digital', 'wisenutbot', 'wwwc', 'xenu link sleuth', 'xget', 'cosmos', 'yahoo', 'yandex', 'zao', 'zeus', 'zyborg'
);
$is_IE6 = preg_match('/msie\s(5\.[5-9]|[6]\.[0-9]*).*(win)/i', $browser->
getAgentString()) && !preg_match('/msie\s([7-9]\.[0-9]*).*(win)/i', $browser->
getAgentString());
$fb_crawler = preg_match('/facebook/i', $browser->getAgentString());
$w3c_validator = preg_match('/w3c/i', $browser->getAgentString());
// check if facebook crawler
if ($fb_crawler) {
$this->result->set('browser', 'facebook');
$this->result->set('mobile', false);
$this->result->set('css3', true);
} else {
switch ($browser->getBrowser()) {
case 'mozilla':
if(preg_match('/Android/i', $browser->getAgentString())) {
$this->result->set('browser', 'android');
$this->result->set('mobile', true);
break;
} else if(preg_match('/iPhone/i', $browser->getAgentString())) {
$this->result->set('browser', 'iphone');
$this->result->set('mobile', true);
break;
} else {
$this->result->set('browser', 'ff');
break;
}
case 'opera':
if(preg_match('/opera\smobi/i', $browser->getAgentString())) {
$this->result->set('browser', 'handheld');
$this->result->set('mobile', true);
} else {
$this->result->set('browser', 'opera');
$this->result->set('mobile', false);
$this->result->set('css3', true);
}
break;
case 'safari':
case 'konqueror':
if (preg_match('/chrome/i', $browser->getAgentString())) {
$this->result->set('browser', 'chrome');
} else {
if (preg_match('/android/i', $browser->getAgentString())) {
$this->result->set('browser', 'android');
if(preg_match('/mobile/i', $browser->getAgentString())) {
$this->result->set('mobile', true);
} else {
$this->result->set('tablet', true);
}
} else {
if (preg_match('/iphone/i', $browser->getAgentString())) {
$this->result->set('browser', 'iphone');
$this->result->set('mobile', true);
} else {
if (preg_match('/ipad/i', $browser->getAgentString())) {
$this->result->set('browser', 'ipad');
$this->result->set('tablet', true);
} else {
if (preg_match('/safari/i', $browser->getAgentString())) {
$this->result->set('browser', 'safari');
} else {
if (preg_match('/safari/i', $this->result->browser) || preg_match('/chrome/i', $this->result->browser)) {
$this->result->set('mobile', false);
$this->result->set('css3', true);
} else {
$this->result->set('mobile', true);
$this->result->set('css3', false);
}
}
}
}
}
}
break;
case 'msie':
if (preg_match('/iemobile/i', $browser->getAgentString())) {
$this->result->set('mobile', true);
$this->result->set('browser', 'handheld');
} else {
if ($is_IE6) {
$this->result->set('browser', 'ie6');
$this->result->set('css3', false);
} else {
if (preg_match('/msie\s[7]/i', $browser->getAgentString()))
$this->result->set('browser', 'ie7');
else
if (preg_match('/msie\s[8]/i', $browser->getAgentString()))
$this->result->set('browser', 'ie8');
else
if (preg_match('/msie\s[9]/i', $browser->getAgentString()))
$this->result->set('browser', 'ie9');
$this->result->set('css3', true);
}
$this->result->set('mobile', false);
}
break;
case 'chrome':
if(preg_match('/Android/i', $browser->getAgentString())) {
$this->result->set('browser', 'android');
$this->result->set('mobile', true);
} else if(preg_match('/Mobile Safari/i', $browser->getAgentString())) {
$this->result->set('browser', 'iphone');
$this->result->set('mobile', true);
} else if(preg_match('/iPad/i', $browser->getAgentString())) {
$this->result->set('browser', 'iphone');
$this->result->set('mobile', true);
} else if(preg_match('/iPhone/i', $browser->getAgentString())) {
$this->result->set('browser', 'iphone');
$this->result->set('mobile', true);
} else {
$this->result->set('browser', 'chrome');
$this->result->set('mobile', false);
$this->result->set('css3', true);
}
break;
case '':
foreach($userAgents as $item)
{
if(preg_match('/'.$item.'/i', $browser->getAgentString())){
$this->result->set('browser', 'ff');
$this->result->set('mobile', false);
$this->result->set('css3', true);
break;
} else {
$this->result->set('browser', 'handheld');
$this->result->set('mobile', true);
$this->result->set('css3', false);
}
}
break;
}
}
return $this->result;
}
}
// EOF
As I said I have no idea if it will help or if I have done this correctly but it seemed to work on my Game News Template, so it could prove useful - but make sure you backup your site and php file first
Brett
-
- Senior Boarder
- GK User
- Fri Jan 10, 2014 4:40 pm
@cbnew - thanks for sharing.
-
- Moderator
- GK User
- Mon Jan 13, 2014 6:02 pm
- Code: Select all
if ($fb_crawler) {
$result->set('browser', 'facebook');
$result->set('mobile', false);
$result->set('css3', true);
} else {
switch ($browser->getBrowser()) {
case 'opera':
if(preg_match('/opera\smobi/i', $browser->getAgentString())) {
$result->set('browser', 'handheld');
$result->set('mobile', true);
} else {
$result->set('browser', 'opera');
$result->set('mobile', false);
$result->set('css3', true);
}
break;
case 'chrome':
if(preg_match('/Android/i', $browser->getAgentString())) {
$result->set('browser', 'android');
$result->set('mobile', true);
} else if(preg_match('/Mobile Safari/i', $browser->getAgentString())) {
$result->set('browser', 'iphone');
$result->set('mobile', true);
} else if(preg_match('/iPad/i', $browser->getAgentString())) {
$result->set('browser', 'iphone');
$result->set('mobile', true);
} else if(preg_match('/iPhone/i', $browser->getAgentString())) {
$result->set('browser', 'iphone');
$result->set('mobile', true);
} else {
$result->set('browser', 'chrome');
$result->set('mobile', false);
$result->set('css3', true);
}
break;
case 'safari':
case 'konqueror':
if (preg_match('/chrome/i', $browser->getAgentString())) {
$result->set('browser', 'chrome');
} else {
if (preg_match('/android/i', $browser->getAgentString())) {
if(preg_match('/Android 3./i', $browser->getAgentString())) {
$result->set('browser', 'safari');
}
else {
$result->set('browser', 'android');
$result->set('mobile', true);
}
} else {
if (preg_match('/iphone/i', $browser->getAgentString())) {
$result->set('browser', 'iphone');
$result->set('mobile', true);
} else {
if (preg_match('/ipad/i', $browser->getAgentString())) {
$result->set('browser', 'ipad');
} else {
if (preg_match('/safari/i', $browser->getAgentString())) {
$result->set('browser', 'safari');
} else {
if (preg_match('/safari/i', $result->browser) || preg_match('/chrome/i', $result->browser)) {
$result->set('mobile', false);
$result->set('css3', true);
} else {
$result->set('mobile', true);
$result->set('css3', false);
}
}
}
}
}
}
break;
case 'msie':
if (preg_match('/iemobile/i', $browser->getAgentString())) {
$result->set('mobile', true);
$result->set('browser', 'handheld');
} else {
if ($is_IE6) {
$result->set('browser', 'ie6');
$result->set('css3', false);
} else {
if (preg_match('/msie\s[7]/i', $browser->getAgentString()))
$result->set('browser', 'ie7');
else
if (preg_match('/msie\s[8]/i', $browser->getAgentString()))
$result->set('browser', 'ie8');
else
if (preg_match('/msie\s[9]/i', $browser->getAgentString()))
$result->set('browser', 'ie9');
$result->set('css3', true);
}
$result->set('mobile', false);
}
break;
case 'blackberry':
if (preg_match('/blackberry/i',$browser->getAgentString())) {
$result->set('browser', 'handheld');
$result->set('mobile', true); }
break;
case 'mozilla':
if(preg_match('/Android/i', $browser->getAgentString())) {
$result->set('browser', 'android');
$result->set('mobile', true);
break;
} else if(preg_match('/iPhone/i', $browser->getAgentString())) {
$result->set('browser', 'iphone');
$result->set('mobile', true);
break;
} else {
$result->set('browser', 'ff');
break;
}
case '':
foreach($userAgents as $item)
{
if(preg_match('/'.$item.'/i', $browser->getAgentString())){
$result->set('browser', 'ff');
$result->set('mobile', false);
$result->set('css3', true);
break;
} else {
$result->set('browser', 'handheld');
$result->set('mobile', true);
$result->set('css3', false);
}
}
break;
}
}
This code we have confirmed works fine with all versions of iOS chrome.
-
- Moderator
- GK User
- Tue Jan 21, 2014 3:45 pm
Hi,
Thanks cbnew and Cyberek, I've successfully added your code and Chrome formats as follows:
I've made a small adjustment on the code so that iPad formats as the desktop version (just like Safari on the iPad formats as the desktop version):
Thanks for all your help!
Kind regards,
Dave.
Thanks cbnew and Cyberek, I've successfully added your code and Chrome formats as follows:
- Desktop: Desktop version
iPhone: Mobile version
iPad: Mobile version
I've made a small adjustment on the code so that iPad formats as the desktop version (just like Safari on the iPad formats as the desktop version):
- Code: Select all
else if(preg_match('/iPad/i', $browser->getAgentString())) {
$result->set('browser', 'ipad');
$result->set('mobile', false);
$result->set('css3', true);
}
Thanks for all your help!
Kind regards,
Dave.
-
- Senior Boarder
- GK User
- Tue Jan 21, 2014 5:30 pm
@dajvid - thanks for sharing the code
-
- Moderator
- GK User
- Thu Feb 27, 2014 11:40 pm
For samsung Galaxy also looks very poor, is there any solution?
-
- Gold Boarder
- GK User
- Sat Mar 01, 2014 8:55 am
Could you provide a screenshot and user agent of the build in browser?
-
- Moderator
- GK User
- Tue Mar 11, 2014 2:17 pm
This code worked great for me and my "The World News II" template
Cyberek wrote:
- Code: Select all
if ($fb_crawler) {
$result->set('browser', 'facebook');
$result->set('mobile', false);
$result->set('css3', true);
} else {
switch ($browser->getBrowser()) {
case 'opera':
if(preg_match('/opera\smobi/i', $browser->getAgentString())) {
$result->set('browser', 'handheld');
$result->set('mobile', true);
} else {
$result->set('browser', 'opera');
$result->set('mobile', false);
$result->set('css3', true);
}
break;
case 'chrome':
if(preg_match('/Android/i', $browser->getAgentString())) {
$result->set('browser', 'android');
$result->set('mobile', true);
} else if(preg_match('/Mobile Safari/i', $browser->getAgentString())) {
$result->set('browser', 'iphone');
$result->set('mobile', true);
} else if(preg_match('/iPad/i', $browser->getAgentString())) {
$result->set('browser', 'iphone');
$result->set('mobile', true);
} else if(preg_match('/iPhone/i', $browser->getAgentString())) {
$result->set('browser', 'iphone');
$result->set('mobile', true);
} else {
$result->set('browser', 'chrome');
$result->set('mobile', false);
$result->set('css3', true);
}
break;
case 'safari':
case 'konqueror':
if (preg_match('/chrome/i', $browser->getAgentString())) {
$result->set('browser', 'chrome');
} else {
if (preg_match('/android/i', $browser->getAgentString())) {
if(preg_match('/Android 3./i', $browser->getAgentString())) {
$result->set('browser', 'safari');
}
else {
$result->set('browser', 'android');
$result->set('mobile', true);
}
} else {
if (preg_match('/iphone/i', $browser->getAgentString())) {
$result->set('browser', 'iphone');
$result->set('mobile', true);
} else {
if (preg_match('/ipad/i', $browser->getAgentString())) {
$result->set('browser', 'ipad');
} else {
if (preg_match('/safari/i', $browser->getAgentString())) {
$result->set('browser', 'safari');
} else {
if (preg_match('/safari/i', $result->browser) || preg_match('/chrome/i', $result->browser)) {
$result->set('mobile', false);
$result->set('css3', true);
} else {
$result->set('mobile', true);
$result->set('css3', false);
}
}
}
}
}
}
break;
case 'msie':
if (preg_match('/iemobile/i', $browser->getAgentString())) {
$result->set('mobile', true);
$result->set('browser', 'handheld');
} else {
if ($is_IE6) {
$result->set('browser', 'ie6');
$result->set('css3', false);
} else {
if (preg_match('/msie\s[7]/i', $browser->getAgentString()))
$result->set('browser', 'ie7');
else
if (preg_match('/msie\s[8]/i', $browser->getAgentString()))
$result->set('browser', 'ie8');
else
if (preg_match('/msie\s[9]/i', $browser->getAgentString()))
$result->set('browser', 'ie9');
$result->set('css3', true);
}
$result->set('mobile', false);
}
break;
case 'blackberry':
if (preg_match('/blackberry/i',$browser->getAgentString())) {
$result->set('browser', 'handheld');
$result->set('mobile', true); }
break;
case 'mozilla':
if(preg_match('/Android/i', $browser->getAgentString())) {
$result->set('browser', 'android');
$result->set('mobile', true);
break;
} else if(preg_match('/iPhone/i', $browser->getAgentString())) {
$result->set('browser', 'iphone');
$result->set('mobile', true);
break;
} else {
$result->set('browser', 'ff');
break;
}
case '':
foreach($userAgents as $item)
{
if(preg_match('/'.$item.'/i', $browser->getAgentString())){
$result->set('browser', 'ff');
$result->set('mobile', false);
$result->set('css3', true);
break;
} else {
$result->set('browser', 'handheld');
$result->set('mobile', true);
$result->set('css3', false);
}
}
break;
}
}
This code we have confirmed works fine with all versions of iOS chrome.
-
- Fresh Boarder
- GK User
- Tue Mar 11, 2014 7:38 pm
@FondationHirondelle thanks for the info.
-
- Moderator
- GK User
- Wed Jul 01, 2015 9:17 pm
This Worked just fine on my iOS Mobile Chrome!
Cyberek wrote:
- Code: Select all
if ($fb_crawler) {
$result->set('browser', 'facebook');
$result->set('mobile', false);
$result->set('css3', true);
} else {
switch ($browser->getBrowser()) {
case 'opera':
if(preg_match('/opera\smobi/i', $browser->getAgentString())) {
$result->set('browser', 'handheld');
$result->set('mobile', true);
} else {
$result->set('browser', 'opera');
$result->set('mobile', false);
$result->set('css3', true);
}
break;
case 'chrome':
if(preg_match('/Android/i', $browser->getAgentString())) {
$result->set('browser', 'android');
$result->set('mobile', true);
} else if(preg_match('/Mobile Safari/i', $browser->getAgentString())) {
$result->set('browser', 'iphone');
$result->set('mobile', true);
} else if(preg_match('/iPad/i', $browser->getAgentString())) {
$result->set('browser', 'iphone');
$result->set('mobile', true);
} else if(preg_match('/iPhone/i', $browser->getAgentString())) {
$result->set('browser', 'iphone');
$result->set('mobile', true);
} else {
$result->set('browser', 'chrome');
$result->set('mobile', false);
$result->set('css3', true);
}
break;
case 'safari':
case 'konqueror':
if (preg_match('/chrome/i', $browser->getAgentString())) {
$result->set('browser', 'chrome');
} else {
if (preg_match('/android/i', $browser->getAgentString())) {
if(preg_match('/Android 3./i', $browser->getAgentString())) {
$result->set('browser', 'safari');
}
else {
$result->set('browser', 'android');
$result->set('mobile', true);
}
} else {
if (preg_match('/iphone/i', $browser->getAgentString())) {
$result->set('browser', 'iphone');
$result->set('mobile', true);
} else {
if (preg_match('/ipad/i', $browser->getAgentString())) {
$result->set('browser', 'ipad');
} else {
if (preg_match('/safari/i', $browser->getAgentString())) {
$result->set('browser', 'safari');
} else {
if (preg_match('/safari/i', $result->browser) || preg_match('/chrome/i', $result->browser)) {
$result->set('mobile', false);
$result->set('css3', true);
} else {
$result->set('mobile', true);
$result->set('css3', false);
}
}
}
}
}
}
break;
case 'msie':
if (preg_match('/iemobile/i', $browser->getAgentString())) {
$result->set('mobile', true);
$result->set('browser', 'handheld');
} else {
if ($is_IE6) {
$result->set('browser', 'ie6');
$result->set('css3', false);
} else {
if (preg_match('/msie\s[7]/i', $browser->getAgentString()))
$result->set('browser', 'ie7');
else
if (preg_match('/msie\s[8]/i', $browser->getAgentString()))
$result->set('browser', 'ie8');
else
if (preg_match('/msie\s[9]/i', $browser->getAgentString()))
$result->set('browser', 'ie9');
$result->set('css3', true);
}
$result->set('mobile', false);
}
break;
case 'blackberry':
if (preg_match('/blackberry/i',$browser->getAgentString())) {
$result->set('browser', 'handheld');
$result->set('mobile', true); }
break;
case 'mozilla':
if(preg_match('/Android/i', $browser->getAgentString())) {
$result->set('browser', 'android');
$result->set('mobile', true);
break;
} else if(preg_match('/iPhone/i', $browser->getAgentString())) {
$result->set('browser', 'iphone');
$result->set('mobile', true);
break;
} else {
$result->set('browser', 'ff');
break;
}
case '':
foreach($userAgents as $item)
{
if(preg_match('/'.$item.'/i', $browser->getAgentString())){
$result->set('browser', 'ff');
$result->set('mobile', false);
$result->set('css3', true);
break;
} else {
$result->set('browser', 'handheld');
$result->set('mobile', true);
$result->set('css3', false);
}
}
break;
}
}
This code we have confirmed works fine with all versions of iOS chrome.
-
- Expert Boarder
- GK User
- Mon Jul 06, 2015 11:25 am
@razor7 thanks for sharing.
-
- Moderator
25 posts
• Page 1 of 1