| 1 |
<?php
|
| 2 |
|
| 3 |
function splash_admin_when() {
|
| 4 |
$splash_when = variable_get('splash_when', array());
|
| 5 |
|
| 6 |
$form['general'] = array(
|
| 7 |
'#type' => 'fieldset',
|
| 8 |
'#title' => t('Settings'),
|
| 9 |
);
|
| 10 |
$form['general']['frequency'] = array(
|
| 11 |
'#type' => 'select',
|
| 12 |
'#title' => t('Display with frequency'),
|
| 13 |
'#default_value' => $splash_when['frequency'],
|
| 14 |
'#options' => array(
|
| 15 |
'' => t('Never (off)'),
|
| 16 |
'always' => t('Always'),
|
| 17 |
'once' => t('Once'),
|
| 18 |
'daily' => t('Daily'),
|
| 19 |
'weekly' => t('Weekly'),
|
| 20 |
),
|
| 21 |
'#description' => t('How often should visitors see the splash page?'),
|
| 22 |
);
|
| 23 |
$form['general']['cookie'] = array(
|
| 24 |
'#type' => 'checkbox',
|
| 25 |
'#title' => t('Force display on next visit'),
|
| 26 |
'#description' => t('Reset the name of the cookie to force the display of the splash on next visit. This is useful to preview changes to the splash content in development.'),
|
| 27 |
'#default_value' => 0,
|
| 28 |
);
|
| 29 |
|
| 30 |
if (module_exists('condition')) {
|
| 31 |
$form = array_merge($form, module_invoke('condition', 'selection_form', $splash_when['conditions']));
|
| 32 |
}
|
| 33 |
|
| 34 |
$form = system_settings_form($form);
|
| 35 |
|
| 36 |
unset($form['#submit']);
|
| 37 |
|
| 38 |
return $form;
|
| 39 |
}
|
| 40 |
|
| 41 |
function splash_admin_when_submit($form, &$form_state) {
|
| 42 |
|
| 43 |
if ($op == t('Reset to defaults')) {
|
| 44 |
variable_del('splash_when');
|
| 45 |
|
| 46 |
drupal_set_message(t('The configuration options have been reset to their default values.'));
|
| 47 |
}
|
| 48 |
|
| 49 |
else {
|
| 50 |
$splash_when = variable_get('splash_when', array());
|
| 51 |
$splash_when['frequency'] = $form_state['values']['frequency'];
|
| 52 |
|
| 53 |
if ($form_state['values']['cookie']) {
|
| 54 |
$splash_when['cookie'] = 'splash_cookie_'.time();
|
| 55 |
}
|
| 56 |
|
| 57 |
if (module_exists('condition')) {
|
| 58 |
$splash_when['conditions'] = $form_state['values']['conditions'];
|
| 59 |
}
|
| 60 |
|
| 61 |
variable_set('splash_when', $splash_when);
|
| 62 |
|
| 63 |
drupal_set_message(t('The configuration options have been saved.'));
|
| 64 |
}
|
| 65 |
|
| 66 |
cache_clear_all();
|
| 67 |
drupal_rebuild_theme_registry();
|
| 68 |
}
|
| 69 |
|
| 70 |
function splash_admin_what() {
|
| 71 |
$splash_what = variable_get('splash_what', array());
|
| 72 |
|
| 73 |
$form['splash_what'] = array(
|
| 74 |
'#tree' => TRUE,
|
| 75 |
);
|
| 76 |
$form['splash_what']['mode'] = array(
|
| 77 |
'#type' => 'select',
|
| 78 |
'#title' => t('Content mode'),
|
| 79 |
'#options' => array(
|
| 80 |
'' => t('Pick random path or URL from the list'),
|
| 81 |
'sequence' => t('Pick next path or URL from the list'),
|
| 82 |
'template' => t('Display entered text in the site template'),
|
| 83 |
'fullscreen' => t('Display entered text/HTML full screen'),
|
| 84 |
),
|
| 85 |
'#default_value' => $splash_what['mode'],
|
| 86 |
'#description' => t('Determines how the content field below will be used.'),
|
| 87 |
);
|
| 88 |
|
| 89 |
$form['splash_what']['content'] = array(
|
| 90 |
'#type' => 'textarea',
|
| 91 |
'#title' => t('Content'),
|
| 92 |
'#default_value' => $splash_what['content'],
|
| 93 |
'#description' => t('Text to show or paths/URLs (one on each line) to use. To open a non-Drupal path, use an absolute URL, i.e. http://example.com/splash.html'),
|
| 94 |
);
|
| 95 |
|
| 96 |
$form['splash_what']['filter'] = filter_form($splash_what['format']);
|
| 97 |
$form['splash_what']['format'] = array(
|
| 98 |
'#type' => 'value',
|
| 99 |
'#value' => $splash_what['format'],
|
| 100 |
);
|
| 101 |
|
| 102 |
$form['#submit'][] = 'splash_admin_what_submit';
|
| 103 |
|
| 104 |
return system_settings_form($form);
|
| 105 |
}
|
| 106 |
|
| 107 |
function splash_admin_what_submit($form, &$form_state) {
|
| 108 |
$form_state['values']['splash_what']['format'] = $form_state['values']['format'];
|
| 109 |
}
|
| 110 |
|
| 111 |
function splash_admin_how() {
|
| 112 |
$splash_how = variable_get('splash_how', array());
|
| 113 |
|
| 114 |
$options = array(
|
| 115 |
'redirect' => t('Redirect'),
|
| 116 |
'window' => t('Open in new window'),
|
| 117 |
);
|
| 118 |
if (module_exists('thickbox')) {
|
| 119 |
$options['thickbox'] = t('Open in ThickBox');
|
| 120 |
}
|
| 121 |
else {
|
| 122 |
drupal_set_message(t('This module now uses the <a href="http://drupal.org/project/thickbox">Thickbox</a> contributed module rather than bundling it\'s own copy of Thickbox. Please go to the <a href="http://drupal.org/project/thickbox">Thickbox project page</a> and download it if you wish to use Thickbox to display splash pages.'));
|
| 123 |
}
|
| 124 |
if (module_exists('lightbox2')) {
|
| 125 |
$options['lightbox2'] = t('Open in Lightbox2');
|
| 126 |
}
|
| 127 |
|
| 128 |
$form['splash_how'] = array(
|
| 129 |
'#tree' => TRUE,
|
| 130 |
);
|
| 131 |
$form['splash_how']['mode'] = array(
|
| 132 |
'#type' => 'radios',
|
| 133 |
'#required' => TRUE,
|
| 134 |
'#title' => t('Display mode'),
|
| 135 |
'#options' => $options,
|
| 136 |
'#default_value' => $splash_how['mode'],
|
| 137 |
'#description' => t('Redirect to the splash page, open it in a new window or in a fancy !thickbox.', array('!thickbox' => l(t('ThickBox'), 'http://jquery.com/demo/thickbox/'))),
|
| 138 |
);
|
| 139 |
$form['splash_how']['size'] = array(
|
| 140 |
'#type' => 'textfield',
|
| 141 |
'#title' => t('Window/Box size'),
|
| 142 |
'#default_value' => $splash_how['size'],
|
| 143 |
'#description' => t('Size (<code>WIDTHxHEIGHT</code>, e.g. 400x300) of the window or ThickBox.'),
|
| 144 |
);
|
| 145 |
|
| 146 |
return system_settings_form($form);
|
| 147 |
}
|
| 148 |
|
| 149 |
function splash_admin_how_validate($form, &$form_state) {
|
| 150 |
|
| 151 |
if (!empty($form_state['values']['splash_how']['size']) && !preg_match('/^[1-9][0-9]*x[1-9][0-9]*$/i', $form_state['values']['splash_how']['size'])) {
|
| 152 |
form_set_error('size', t('Invalid Window/Box size. Use <code>WIDTHxHEIGHT</code>, e.g. 400x300.'));
|
| 153 |
}
|
| 154 |
}
|
| 155 |
|
| 156 |
?>
|