/[drupal]/contributions/modules/virtual_site/virtual_site_head.module
ViewVC logotype

Contents of /contributions/modules/virtual_site/virtual_site_head.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download) (as text)
Wed Apr 16 10:03:10 2008 UTC (19 months, 1 week ago) by fokke
Branch: MAIN
CVS Tags: DRUPAL-6--1-3, HEAD
Changes since 1.1: +26 -7 lines
File MIME type: text/x-php
Fixed access arguments missing for 6.2
1 <?php
2 // $Id: virtual_site_head.module,v 1.1 2008/03/19 18:43:27 fokke Exp $
3
4 /**
5 * Implementation of hook_preprocess_hook().
6 */
7 function virtual_site_head_preprocess_page(&$variables) {
8
9 if ($site = virtual_site_load_active()) {
10
11 // Insert inline CSS here to make sure it's the last CSS
12 if ($site->features['virtual_site_head_feature']['css_inline']) {
13 $variables['styles'] .= "\n<style type=\"text/css\">\n".$site->features['virtual_site_head_feature']['css_inline']."\n</style>\n";
14 }
15 }
16 }
17
18 /**
19 * Implementation of hook_footer().
20 */
21 function virtual_site_head_footer($main = 0) {
22
23 if ($site = virtual_site_load_active()) {
24
25 if ($site->features['virtual_site_head_feature']['html_footer']) {
26 return $site->features['virtual_site_head_feature']['html_footer'];
27 }
28 }
29 }
30
31 /**
32 * Implementation of hook_feature_info().
33 */
34 function virtual_site_head_feature_info() {
35 return array(
36 'virtual_site_head_feature' => array(
37 'name' => t('Head'),
38 'description' => t('Add styles, scripts and other stuff to <code>&lt;head /&gt;</code>'),
39 ),
40 );
41 }
42
43 function virtual_site_head_feature_form($context) {
44 $form = array();
45
46 $form['settings'] = array(
47 '#tree' => TRUE,
48 );
49 $form['settings']['html_head'] = array(
50 '#type' => 'textarea',
51 '#title' => t('HTML in header'),
52 '#description' => t('Enter HTML code to include in the <code>&lt;head /&gt;</code>.'),
53 '#default_value' => $context['html_head'],
54 );
55 $form['settings']['html_footer'] = array(
56 '#type' => 'textarea',
57 '#title' => t('HTML in closure'),
58 '#description' => t('Enter HTML code to include just before <code>&lt;/body&gt;</code>.'),
59 '#default_value' => $context['html_footer'],
60 );
61 $form['settings']['js_include'] = array(
62 '#type' => 'textarea',
63 '#title' => t('Referenced JavaScript files'),
64 '#description' => t('Enter URLs of JavaScript files (one on each line) to refer to.'),
65 '#default_value' => $context['js_include'],
66 );
67 $form['settings']['js_inline'] = array(
68 '#type' => 'textarea',
69 '#title' => t('Inline JavaScript'),
70 '#description' => t('Enter JavaScript code to include inline.'),
71 '#default_value' => $context['js_inline'],
72 );
73 $form['settings']['css_include'] = array(
74 '#type' => 'textarea',
75 '#title' => t('Referenced CSS files'),
76 '#description' => t('Enter URLs of CSS files (one on each line) to refer to.'),
77 '#default_value' => $context['css_include'],
78 );
79 $form['settings']['css_inline'] = array(
80 '#type' => 'textarea',
81 '#title' => t('Inline CSS'),
82 '#description' => t('Enter CSS code to include inline.'),
83 '#default_value' => $context['css_inline'],
84 );
85
86 return $form;
87 }
88
89 function virtual_site_head_feature_submit($form, $form_state) {
90 return $form_state['values']['settings'];
91 }
92
93 function virtual_site_head_feature($context) {
94
95 if (trim($context['html_head'])) {
96 drupal_set_html_head($context['html_head']);
97 }
98
99 if (trim($context['js_inline'])) {
100 drupal_add_js($context['js_inline'], 'inline');
101 }
102
103 if (trim($context['js_include'])) {
104 $files = preg_split('/[\n\r]+/s', $context['js_include']);
105
106 if (count($files)) {
107
108 foreach ($files as $file) {
109 drupal_add_js(check_url($file), 'module');
110 }
111 }
112 }
113
114 if (trim($context['css_include'])) {
115 $files = preg_split('/[\n\r]+/s', $context['css_include']);
116
117 if (count($files)) {
118
119 foreach ($files as $file) {
120 drupal_add_css(check_url($file), 'theme');
121 }
122 }
123 }
124 }
125
126 ?>

  ViewVC Help
Powered by ViewVC 1.1.2