function mobile_tools_create_mobile_url in Mobile Tools 6.2
Same name and namespace in other branches
- 5 mobile_tools.module \mobile_tools_create_mobile_url()
- 6.3 mobile_tools.module \mobile_tools_create_mobile_url()
- 6 mobile_tools.module \mobile_tools_create_mobile_url()
- 7.2 mobile_tools.admin.inc \mobile_tools_create_mobile_url()
Helper function to assist in making a mobile url (m.*) from a given url
@parm $url orginal url
Return value
the mobile url
2 calls to mobile_tools_create_mobile_url()
- mobile_tools_configuration_form in ./
mobile_tools.admin.inc - Configuration form.
- mobile_tools_detection_is_mobile_site in modules/
mobile_tools_detection/ mobile_tools_detection.module - Implementatation of hook_is_mobile_site().
File
- ./
mobile_tools.module, line 556 - Primarily Drupal hooks.
Code
function mobile_tools_create_mobile_url($url) {
$url_parsed = parse_url($url);
if (!empty($url_parsed) && !array_key_exists('path', $url_parsed)) {
$url_parsed['path'] = '';
}
$url = $url_parsed['host'];
$url = explode('.', $url);
$mobile_url = '';
if (count($url) == 3) {
$url[0] = 'm';
$mobile_url = 'http://' . implode('.', $url) . $url_parsed['path'];
}
elseif (count($url) == 2) {
$mobile_url = 'http://m.' . implode('.', $url) . $url_parsed['path'];
}
else {
$mobile_url = 'http://' . implode('.', $url) . $url_parsed['path'] . '/mobile';
}
return $mobile_url;
}