function _mobile_switch_block_url in Mobile Switch Block 7.2
Same name and namespace in other branches
- 6 mobile_switch_block.module \_mobile_switch_block_url()
- 7 mobile_switch_block.module \_mobile_switch_block_url()
Get the mobile switch URL.
Parameters
$mode: A string with the possible values:
- standard
- mobile
$manual: A boolean value.
See also
theme_mobile_switch_block()
1 call to _mobile_switch_block_url()
- template_preprocess_mobile_switch_block_switch_content in ./
mobile_switch_block.module - Processes variables for mobile-switch-block-switch-content.tpl.php.
File
- ./
mobile_switch_block.module, line 440 - Extends the Mobile Switch module with an theme switch block.
Code
function _mobile_switch_block_url($mode, $manual = FALSE) {
$get['op_mode'] = mobile_switch_get_operating_mode();
$get['link_target'] = (bool) variable_get('mobile_switch_block_link_target', 1);
$url = '<front>';
$current_path = current_path();
if ($get['link_target'] === TRUE) {
$current_path = '';
}
switch ($get['op_mode']) {
// Operating mode redirect.
case 'redirect':
$options['query']['mobile_switch'] = $manual ? $mode : 0;
$get['redirect_url_to_mobile'] = variable_get('mobile_switch_redirect_url_to_mobile', '');
$get['redirect_url_to_desktop'] = variable_get('mobile_switch_redirect_url_to_desktop', '');
// Multisite with shared content?
$get['shared_content'] = (bool) variable_get('mobile_switch_redirect_shared_content', 0);
// The current host URL.
$get['current_url'] = 'http://' . $_SERVER['HTTP_HOST'];
// Identify the current website version - desktop or mobile.
$get['site_variant'] = FALSE;
if ($get['current_url'] == $get['redirect_url_to_desktop']) {
$get['site_variant'] = 'desktop';
}
if ($get['current_url'] == $get['redirect_url_to_mobile']) {
$get['site_variant'] = 'mobile';
}
switch ($get['site_variant']) {
case 'desktop':
$path = $get['redirect_url_to_mobile'];
if ($get['shared_content']) {
$path .= '/' . $current_path;
}
break;
case 'mobile':
$path = $get['redirect_url_to_desktop'];
if ($get['shared_content']) {
$path .= '/' . $current_path;
}
break;
}
$url = url($path, $options);
break;
// Operating mode theme switch.
case 'themeswitch':
$options['query']['mobile_switch'] = $manual ? $mode : 0;
$options['absolute'] = TRUE;
$url = url($current_path, $options);
break;
}
return $url;
}