function template_preprocess_mobile_switch_block_switch_content in Mobile Switch Block 7.2
Same name and namespace in other branches
- 6 mobile_switch_block.module \template_preprocess_mobile_switch_block_switch_content()
- 7 mobile_switch_block.module \template_preprocess_mobile_switch_block_switch_content()
Processes variables for mobile-switch-block-switch-content.tpl.php.
Returns HTML content for the Mobile switch block.
See also
mobile_switch_block_view()
mobile_switch_block_get_block_content()
File
- ./
mobile_switch_block.module, line 217 - Extends the Mobile Switch module with an theme switch block.
Code
function template_preprocess_mobile_switch_block_switch_content(&$variables) {
global $conf;
$variables['op_mode'] = mobile_switch_get_operating_mode();
$detect = mobile_switch_mobile_detect();
$variables['mobile_switch_detect'] = $detect;
$variables['mobile_switch_ismobiledevice'] = $detect['ismobiledevice'];
$variables['mobile_switch_block_content'] = variable_get('mobile_switch_block_content', 'link');
$variables['query_value'] = '';
$variables['version'] = '';
$variables['version_text'] = '';
$variables['class'] = '';
$variables['switch_link'] = '';
$variables['switch_message'] = '';
$items = array();
$theme_cookie_use = _mobile_switch_check_theme_cookie_use();
// Make it possible to use the manual switch by visitor if the
// operating mode 'redirect' enabled.
$query_value_extend = '';
if ($variables['op_mode'] === 'redirect') {
// The letters 'rm' mean the operating 'redirect' mode.
$query_value_extend = '-rm';
}
// Prepare the link values.
if ($variables['mobile_switch_ismobiledevice'] && $theme_cookie_use == FALSE || ($theme_cookie_use === 'mobile' || $theme_cookie_use === 'mobile-rm')) {
$variables['query_value'] = 'standard' . $query_value_extend;
$variables['version'] = 'mobile';
$variables['version_text'] = variable_get('mobile_switch_block_desktop_device_name', 'standard');
$variables['class'] = 'mobile-switch-to-standard';
}
else {
$variables['query_value'] = 'mobile' . $query_value_extend;
$variables['version'] = variable_get('mobile_switch_block_desktop_device_name', 'standard');
$variables['version_text'] = 'mobile';
$variables['class'] = 'mobile-switch-to-mobile';
}
// Prepare the switch content.
switch ($variables['mobile_switch_block_content']) {
case 'link':
$variables['switch_link'] = t('<a href="!switch-url">!version !view</a>', array(
'!view' => variable_get('mobile_switch_block_switch_link_text', 'view'),
'!switch-url' => _mobile_switch_block_url($variables['query_value'], TRUE),
'!version' => ucfirst($variables['version_text']),
));
$items[] = array(
'class' => array(
'leaf',
),
'data' => $variables['switch_link'],
);
break;
case 'message_link':
$switch_message = $variables['switch_message'] = '<span class="mobile-switch-inform">' . t('This is the !version-text !version of the site.', array(
'!version-text' => $variables['version'],
'!version' => variable_get('mobile_switch_block_switch_link_text', 'view'),
)) . '</span>' . "\n";
$variables['switch_link'] = t('<a href="!switch-url">!version !view</a>', array(
'!view' => variable_get('mobile_switch_block_switch_link_text', 'view'),
'!switch-url' => _mobile_switch_block_url($variables['query_value'], TRUE),
'!version' => ucfirst($variables['version_text']),
));
$items[] = array(
'class' => array(
'leaf',
),
'data' => $variables['switch_link'],
);
break;
}
// Usage of theme_item_list() needed for the use with a Mobile jQuery sub-theme.
// This ensures the Mobile jQuery like display of the switch content.
$variables['content'] = $variables['switch_message'] . theme('item_list', array(
'attributes' => array(
'class' => array(
'menu clearfix',
),
),
'items' => $items,
));
}