-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgn_theme_includes.module
More file actions
113 lines (104 loc) · 3.3 KB
/
gn_theme_includes.module
File metadata and controls
113 lines (104 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
/**
* Implementation of hook_menu().
*/
function gn_theme_includes_menu() {
$items["gn_theme_includes/%"] = array(
'page callback' => '_gn_theme',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
$items["theme/header"] = array(
'page callback' => '_gn_theme_theme_header',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
$items["theme/footer"] = array(
'page callback' => '_gn_theme_theme_footer',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
return $items;
}
/**
* Implementation of hook_theme().
*/
function gn_theme_includes_theme($existing, $type, $theme, $path) {
$themes = array(
'theme_header' => array(
'arguments' => array('vars'=>NULL),
'template' => 'theme_header',
),
'theme_footer' => array(
'arguments' => array('vars'=>NULL),
'template' => 'theme_footer',
),
);
return $themes;
}
/**
* Implementation of hook_preprocess_NAME().
*
*/
function gn_theme_includes_preprocess_page(&$variables) {
if($_GET['q'] == 'theme/header' || $_GET['q'] == 'theme/footer'){
}elseif($_GET['q'] == 'gn_theme_includes/page'){
$variables['template_files'][] = 'theme_bookingengine';
$variables['theme_header'] = theme('theme_header', $variables);
$variables['theme_footer'] = theme('theme_footer', $variables);
$variables['theme_header'] = _gn_theme_includes_replacerelativebyabsolute($variables['theme_header']);
$variables['theme_footer'] = _gn_theme_includes_replacerelativebyabsolute($variables['theme_footer']);
}else{
$variables['theme_header'] = theme('theme_header', $variables);
$variables['theme_footer'] = theme('theme_footer', $variables);
}
}
/**
* Implementation of hook_theme_registry_alter().
*
* Make gn_theme's page preprocess function run *after* everything else's,
* so that a theme can't call other variables and mess everything up.
*/
function gn_theme_includes_theme_registry_alter(&$theme_registry) {
if (isset($theme_registry['page'])) {
if (count($theme_registry['page']['preprocess functions']) > 0) {
// If jquery_update's preprocess function is there already, remove it.
if ($key = array_search('gn_theme_includes_preprocess_page', $theme_registry['page']['preprocess functions'])) {
unset($theme_registry['page']['preprocess functions'][$key]);
}
}
// Now tack it on at the end so it runs after everything else.
$theme_registry['page']['preprocess functions'][] = 'gn_theme_includes_preprocess_page';
}
}
/**
* Implementation of hook_preprocess_NAME().
*
*/
function gn_theme_includes_preprocess_theme_header(&$variables, $othervars) {
$vars = $variables;
$variables = array_merge($vars, $vars['vars']);
$variables['template_files'][] = 'theme_header';
}
/**
* Implementation of hook_preprocess_NAME().
*
*/
function gn_theme_includes_preprocess_theme_footer(&$variables, $othervars) {
$vars = $variables;
$variables = array_merge($vars, $vars['vars']);
$variables['template_files'][] = 'theme_footer';
}
function _gn_theme_theme_header(){
print theme('page');
}
function _gn_theme(){
print theme('page');
}
function _gn_theme_theme_footer(){
print theme('page');
}
function _gn_theme_includes_replacerelativebyabsolute($valeur){
$new_valeur = str_replace('href="/', 'href="http://' . $_SERVER['HTTP_HOST'] . '/', $valeur);
return $new_valeur;
}