| 1 |
<?php
|
| 2 |
// $Id: mobi_loader.module,v 1.4 2009/03/05 04:04:53 deekayen Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Intended to be used with the .mobi theme
|
| 7 |
*
|
| 8 |
* @author David Kent Norman <http://deekayen.net/>
|
| 9 |
* @link http://deekayen.net/
|
| 10 |
* @link http://m.deekayen.net/
|
| 11 |
*/
|
| 12 |
|
| 13 |
/**
|
| 14 |
* Implementation of hook_menu().
|
| 15 |
*/
|
| 16 |
function mobi_loader_menu() {
|
| 17 |
$items['admin/settings/mobi_loader'] = array(
|
| 18 |
'title' => '.mobi loader',
|
| 19 |
'description' => 'Toggle settings for the .mobi theme',
|
| 20 |
'page callback' => 'drupal_get_form',
|
| 21 |
'page arguments' => array('mobi_loader_admin_settings'),
|
| 22 |
'access arguments' => array('administer site configuration'),
|
| 23 |
'type' => MENU_NORMAL_ITEM
|
| 24 |
);
|
| 25 |
return $items;
|
| 26 |
}
|
| 27 |
|
| 28 |
/**
|
| 29 |
* Overrides the default theme to use the mobi theme
|
| 30 |
* when a domain ending in .mobi is requested
|
| 31 |
*/
|
| 32 |
function mobi_loader_boot() {
|
| 33 |
if (isset($_SERVER['HTTP_HOST'])) {
|
| 34 |
if ($_SERVER['HTTP_HOST'] == variable_get('mobi_loader_domain', '')) {
|
| 35 |
global $conf;
|
| 36 |
$conf['theme_default'] = 'mobi';
|
| 37 |
}
|
| 38 |
}
|
| 39 |
}
|
| 40 |
|
| 41 |
/**
|
| 42 |
* Implementation of hook_settings().
|
| 43 |
*
|
| 44 |
* @return array
|
| 45 |
*/
|
| 46 |
function mobi_loader_admin_settings() {
|
| 47 |
$form['mobi_loader_domain'] = array(
|
| 48 |
'#type' => 'textfield',
|
| 49 |
'#title' => t('Mobile domain'),
|
| 50 |
'#default_value' => variable_get('mobi_loader_domain', ''),
|
| 51 |
'#description' => t('Just the domain. No http:// stuff.')
|
| 52 |
);
|
| 53 |
return system_settings_form($form);
|
| 54 |
}
|