View source
<?php
function purr_messages_settings() {
$module_path = drupal_get_path('module', 'purr_messages');
$form['purr_messages_code_status'] = array(
'#type' => 'fieldset',
'#title' => t('Purr Messages settings'),
'#weight' => -10,
'#description' => purr_messages_status() !== FALSE ? t('You have a custom css file in: <br/>/%path/purrcss/') : t('You are using the default purr style. To use custom css and images simply
copy the <em>\'purrcss\'</em> folder from: <br/>%modulepath<br/> and place
it in your theme folder: <br/>%path<br/>Then make the alterations you want
to the copied version in your theme folder. This module will automatically
pick up the changes and this message will change if you\'ve done it
correctly.<br/>', array(
'%path' => path_to_theme(),
'%modulepath' => $module_path,
)),
);
$form['purr_messages_settings'] = array(
'#type' => 'fieldset',
'#title' => 'Plugin settings',
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['purr_messages_settings']['purr_messages_fade_in'] = array(
'#type' => 'textfield',
'#title' => t('Fade in speed'),
'#field_suffix' => t('ms'),
'#description' => t('The time in milliseconds for the notice to fade in.'),
'#default_value' => variable_get('purr_messages_fade_in', PURR_FADE_IN),
);
$form['purr_messages_settings']['purr_messages_fade_out'] = array(
'#type' => 'textfield',
'#title' => t('Fade out speed'),
'#field_suffix' => t('ms'),
'#description' => t('The time in milliseconds for the notice to fade out.'),
'#default_value' => variable_get('purr_messages_fade_out', PURR_FADE_OUT),
);
$form['purr_messages_settings']['purr_messages_timer'] = array(
'#type' => 'textfield',
'#title' => t('Show for'),
'#field_suffix' => t('ms'),
'#description' => t('The time in milliseconds the notice will display for, before fading out.'),
'#default_value' => variable_get('purr_messages_timer', PURR_TIMER),
);
$form['purr_messages_settings']['purr_messages_attachto'] = array(
'#type' => 'textfield',
'#title' => t('Attach to'),
'#description' => t('Enter the html element, using jQuery syntax, that the messages should to attach to in the DOM.
You only need to change this if you want more control in concert with custom css.'),
'#default_value' => variable_get('purr_messages_attachto', PURR_ATTACH_TO),
);
$form['purr_messages_settings']['purr_messages_hover'] = array(
'#type' => 'checkbox',
'#title' => t('Pause on hover'),
'#description' => t('Check to pause when cursor is over the message.'),
'#default_value' => variable_get('purr_messages_hover', TRUE),
);
$form['purr_messages_settings']['purr_messages_sticky'] = array(
'#type' => 'checkbox',
'#title' => t('Sticky messages'),
'#description' => t('Make all messages sticky so the must be closed by the user.'),
'#default_value' => variable_get('purr_messages_sticky', PURR_STICKY),
);
$form['purr_messages_settings']['purr_messages_transparent'] = array(
'#type' => 'checkbox',
'#title' => t('Use transparent png'),
'#description' => t('Uncheck if you are not using 24bit pngs in your custom theme.'),
'#default_value' => variable_get('purr_messages_transparent', TRUE),
);
$visibility = variable_get('purr_messages_visibility', 0);
$pages = variable_get('purr_messages_pages', '');
$form['page_vis_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Page specific visibility settings'),
'#collapsible' => TRUE,
);
$access = user_access('use PHP for message visibility');
if ($visibility == 2 && !$access) {
$form['page_vis_settings'] = array();
$form['page_vis_settings']['visibility'] = array(
'#type' => 'value',
'#value' => 2,
);
$form['page_vis_settings']['pages'] = array(
'#type' => 'value',
'#value' => $pages,
);
}
else {
$options = array(
t('Show on every page except the listed pages.'),
t('Show on only the listed pages.'),
);
$description = t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array(
'%blog' => 'blog',
'%blog-wildcard' => 'blog/*',
'%front' => '<front>',
));
if ($access) {
$options[] = t('Show if the following PHP code returns <code>TRUE</code> (PHP-mode, experts only).');
$description .= ' ' . t('If the PHP-mode is chosen, enter PHP code between %php. Note that executing incorrect PHP-code can break your Drupal site.', array(
'%php' => '<?php ?>',
));
}
$form['page_vis_settings']['visibility'] = array(
'#type' => 'radios',
'#title' => t('Show message on specific pages'),
'#options' => $options,
'#default_value' => $visibility,
);
$form['page_vis_settings']['pages'] = array(
'#type' => 'textarea',
'#title' => t('Pages'),
'#default_value' => $pages,
'#description' => $description,
);
}
$form['visibility']['other'] = array(
'#type' => 'fieldset',
'#title' => t('Other visibility settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#group' => 'visibility',
'#weight' => 10,
);
$form['visibility']['other']['purr_messages_admin_path'] = array(
'#type' => 'checkbox',
'#title' => t('Disable purr messages on admin paths'),
'#description' => t('Checking this box will disable purr messages on admin paths,
as determined by the path_is_admin() function.'),
'#default_value' => variable_get('purr_messages_admin_path', FALSE),
);
$form['visibility']['other']['purr_messages_explicit'] = array(
'#type' => 'checkbox',
'#title' => t('Only show purr message style if explicitly called'),
'#description' => t('This option will only display a purr style message
if called explicitly with the \'purr\' parameter as the type in
<code>drupal_set_message()</code>.<br/> For example:
<code>drupal_set_message(\'my message\', \'purr\');</code>'),
'#default_value' => variable_get('purr_messages_explicit', FALSE),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save configuration'),
);
return $form;
}
function purr_messages_settings_submit($form, &$form_state) {
if (!form_get_errors()) {
variable_set('purr_messages_fade_in', (int) $form_state['values']['purr_messages_fade_in']);
variable_set('purr_messages_fade_out', (int) $form_state['values']['purr_messages_fade_out']);
variable_set('purr_messages_timer', (int) $form_state['values']['purr_messages_timer']);
variable_set('purr_messages_hover', (bool) $form_state['values']['purr_messages_hover']);
variable_set('purr_messages_transparent', (bool) $form_state['values']['purr_messages_transparent']);
variable_set('purr_messages_admin_path', (bool) $form_state['values']['purr_messages_admin_path']);
variable_set('purr_messages_visibility', (int) $form_state['values']['visibility']);
variable_set('purr_messages_pages', trim($form_state['values']['pages']));
variable_set('purr_messages_explicit', (bool) $form_state['values']['purr_messages_explicit']);
variable_set('purr_messages_attachto', trim($form_state['values']['purr_messages_attachto']));
variable_set('purr_messages_sticky', (bool) $form_state['values']['purr_messages_sticky']);
drupal_set_message(t('The configuration has been saved.'));
}
}