features['virtual_site_head_feature']['css_inline']) {
$variables['styles'] .= "\n\n";
}
}
}
/**
* Implementation of hook_footer().
*/
function virtual_site_head_footer($main = 0) {
if ($site = virtual_site_load_active()) {
if ($site->features['virtual_site_head_feature']['html_footer']) {
return $site->features['virtual_site_head_feature']['html_footer'];
}
}
}
/**
* Implementation of hook_feature_info().
*/
function virtual_site_head_feature_info() {
return array(
'virtual_site_head_feature' => array(
'name' => t('Head'),
'description' => t('Add styles, scripts and other stuff to <head />
'),
),
);
}
function virtual_site_head_feature_form($context) {
$form = array();
$form['settings'] = array(
'#tree' => TRUE,
);
$form['settings']['html_head'] = array(
'#type' => 'textarea',
'#title' => t('HTML in header'),
'#description' => t('Enter HTML code to include in the <head />
.'),
'#default_value' => $context['html_head'],
);
$form['settings']['html_footer'] = array(
'#type' => 'textarea',
'#title' => t('HTML in closure'),
'#description' => t('Enter HTML code to include just before </body>
.'),
'#default_value' => $context['html_footer'],
);
$form['settings']['js_include'] = array(
'#type' => 'textarea',
'#title' => t('Referenced JavaScript files'),
'#description' => t('Enter URLs of JavaScript files (one on each line) to refer to.'),
'#default_value' => $context['js_include'],
);
$form['settings']['js_inline'] = array(
'#type' => 'textarea',
'#title' => t('Inline JavaScript'),
'#description' => t('Enter JavaScript code to include inline.'),
'#default_value' => $context['js_inline'],
);
$form['settings']['css_include'] = array(
'#type' => 'textarea',
'#title' => t('Referenced CSS files'),
'#description' => t('Enter URLs of CSS files (one on each line) to refer to.'),
'#default_value' => $context['css_include'],
);
$form['settings']['css_inline'] = array(
'#type' => 'textarea',
'#title' => t('Inline CSS'),
'#description' => t('Enter CSS code to include inline.'),
'#default_value' => $context['css_inline'],
);
return $form;
}
function virtual_site_head_feature_submit($form, $form_state) {
return $form_state['values']['settings'];
}
function virtual_site_head_feature($context) {
if (trim($context['html_head'])) {
drupal_set_html_head($context['html_head']);
}
if (trim($context['js_inline'])) {
drupal_add_js($context['js_inline'], 'inline');
}
if (trim($context['js_include'])) {
$files = preg_split('/[\n\r]+/s', $context['js_include']);
if (count($files)) {
foreach ($files as $file) {
drupal_add_js(check_url($file), 'module');
}
}
}
if (trim($context['css_include'])) {
$files = preg_split('/[\n\r]+/s', $context['css_include']);
if (count($files)) {
foreach ($files as $file) {
drupal_add_css(check_url($file), 'theme');
}
}
}
}
?>