-
Notifications
You must be signed in to change notification settings - Fork 1
/
template.php
executable file
·187 lines (163 loc) · 5.33 KB
/
template.php
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<?php
/**
* @author Semyon Dragunov <[email protected]>
* https://github.com/SemyonDragunov
*/
/**
* Implements hook_theme().
*/
function lifu_theme($existing, $type, $theme, $path) {
$theme = array();
// Rewrite checkboxes.
$theme['checkbox'] = array(
'render element' => 'element',
'template' => 'templates/fields/field--type-checkbox',
);
// Rewrite radios.
$theme['radio'] = array(
'render element' => 'element',
'template' => 'templates/fields/field--type-radio',
);
// Header.
$theme['header'] = array(
'template' => 'templates/themes/header',
'variables' => array(),
);
// Footer.
$theme['footer'] = array(
'template' => 'templates/themes/footer',
'variables' => array(),
);
return $theme;
}
/**
* Implements hook_preprocess_page().
*/
function lifu_preprocess_page(&$variables) {
global $user;
// Templates for node.
// page--node--blog.tpl.php for "blog" machine name node type.
if (!empty($variables['node']) && !empty($variables['node']->type)) {
$variables['theme_hook_suggestions'][] = 'page__node__' . $variables['node']->type;
}
// Special login page and a password recovery.
if (arg(0) == 'user' && !arg(1) && !$user->uid) {
$variables['theme_hook_suggestions'][] = 'page__user__login';
}
if (arg(0) == 'user' && arg(1) == 'password' && !$user->uid) {
$variables['theme_hook_suggestions'][] = 'page__user__password';
}
// Error pages.
// Files in /templates/errors/ folder.
// page--403.tpl.php & page--404.tpl.php
$status = drupal_get_http_header("status");
if ($status == "404 Not Found") {
$variables['theme_hook_suggestions'][] = 'page__404';
drupal_set_title('404 - Страница не найдена');
}
if ($status == "403 Forbidden") {
$variables['theme_hook_suggestions'][] = 'page__403';
drupal_set_title('403 - Доступ запрещён');
}
// Regions.
$variables['header'] = theme('header');
$variables['footer'] = theme('footer');
}
/**
* Implements hook_preprocess_html().
*/
function lifu_preprocess_html(&$variables) {
global $user;
// HTML Attributes
$html_attributes = array(
'lang' => $variables['language']->language,
'dir' => $variables['language']->dir,
);
$variables['html_attributes'] = drupal_attributes($html_attributes);
// Login and a password recovery pages.
if(arg(0) == 'user' && !arg(1) && !$user->uid) {
$variables['theme_hook_suggestions'][] = 'html__user__login';
}
if(arg(0) == 'user' && arg(1) == 'password' && !$user->uid) {
$variables['theme_hook_suggestions'][] = 'html__user__login';
}
}
/**
* Implements hook_preprocess_block().
*/
function lifu_preprocess_block(&$variables, $hook) {
$variables['title'] = isset($variables['block']->subject) ? $variables['block']->subject : '';
}
/**
* Implements hook_preprocess_footer().
*
* For footer.tpl.php
*/
function lifu_preprocess_footer(&$variables) {
$variables['footer_left'] = block_get_blocks_by_region('footer_left');
$variables['footer_center'] = block_get_blocks_by_region('footer_center');
$variables['footer_right'] = block_get_blocks_by_region('footer_right');
$variables['footer'] = block_get_blocks_by_region('footer');
}
/**
* Implements hook_preprocess_header().
*
* For header.tpl.php
*/
function lifu_preprocess_header(&$variables) {
$variables['header'] = block_get_blocks_by_region('header');
$variables['action'] = block_get_blocks_by_region('action');
$variables['search'] = block_get_blocks_by_region('search');
}
/**
* Implements hook_css_alter().
* Disable unnecessary css
*/
function lifu_css_alter(&$css) {
unset($css[drupal_get_path('module', 'system') . '/system.menus.css']);
unset($css[drupal_get_path('module', 'system') . '/system.theme.css']);
}
/**
* Implements hook_form_FORM_ID_alter().
* Login and a password recovery pages.
*/
if (theme_get_setting('lifu_login_page')) {
function lifu_form_user_login_block_alter(&$form, &$form_state) {
$form['name']['#title_display'] = 'invisible';
$form['name']['#attributes'] = array('placeholder' => 'Логин');
$form['pass']['#title_display'] = 'invisible';
$form['pass']['#attributes'] = array('placeholder' => 'Пароль');
$form['actions']['submit']['#attributes']['class'][] = 'expand';
}
function lifu_form_user_login_alter(&$form, &$form_state) {
$form['name']['#title_display'] = 'invisible';
$form['name']['#attributes'] = array('placeholder' => 'Логин');
$form['name']['#description'] = '';
$form['pass']['#title_display'] = 'invisible';
$form['pass']['#attributes'] = array('placeholder' => 'Пароль');
$form['pass']['#description'] = '';
$form['actions']['submit']['#attributes']['class'][] = 'expand';
}
function lifu_form_user_pass_alter(&$form, &$form_state) {
$form['name']['#title_display'] = 'invisible';
$form['name']['#attributes'] = array('placeholder' => 'E-mail');
$form['name']['#description'] = '';
$form['actions']['submit']['#attributes']['class'][] = 'expand';
}
}
/**
* Implements template_preprocess_html().
*/
function lifu_process_html(&$variables) {
if (module_exists('color')) {
_color_html_alter($variables);
}
}
/**
* Implements template_process_page().
*/
function lifu_process_page(&$variables, $hook) {
if (module_exists('color')) {
_color_page_alter($variables);
}
}