-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.php
405 lines (360 loc) · 13 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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
<?php
/**
* @file
* Contains the theme's functions to manipulate Drupal's default markup.
*
* Complete documentation for this file is available online.
* @see https://drupal.org/node/1728096
*/
/**
* Override or insert variables into the maintenance page template.
*
* @param array $variables
* Variables to pass to the theme template.
* @param string $hook
* The name of the template being rendered ("maintenance_page" in this case.)
*/
/* -- Delete this line if you want to use this function
function wesnoth_hu_theme_preprocess_maintenance_page(&$variables, $hook) {
// When a variable is manipulated or added in preprocess_html or
// preprocess_page, that same work is probably needed for the maintenance page
// as well, so we can just re-use those functions to do that work here.
STARTERKIT_preprocess_html($variables, $hook);
STARTERKIT_preprocess_page($variables, $hook);
}
// */
/**
* Override or insert variables into the html templates.
*
* @param array $variables
* Variables to pass to the theme template.
* @param string $hook
* The name of the template being rendered ("html" in this case.)
*/
/* -- Delete this line if you want to use this function
function wesnoth_hu_theme_preprocess_html(&$variables, $hook) {
$variables['sample_variable'] = t('Lorem ipsum.');
// The body tag's classes are controlled by the $classes_array variable. To
// remove a class from $classes_array, use array_diff().
$variables['classes_array'] = array_diff($variables['classes_array'],
array('class-to-remove')
);
}
// */
/**
* Override or insert variables into the page templates.
*
* @param array $variables
* Variables to pass to the theme template.
* @param string $hook
* The name of the template being rendered ("page" in this case.)
*/
/* -- Delete this line if you want to use this function
function wesnoth_hu_theme_preprocess_page(&$variables, $hook) {
$variables['sample_variable'] = t('Lorem ipsum.');
}
// */
/**
* Override or insert variables into the region templates.
*
* @param array $variables
* Variables to pass to the theme template.
* @param string $hook
* The name of the template being rendered ("region" in this case.)
*/
/* -- Delete this line if you want to use this function
function wesnoth_hu_theme_preprocess_region(&$variables, $hook) {
// Don't use Zen's region--no-wrapper.tpl.php template for sidebars.
if (strpos($variables['region'], 'sidebar_') === 0) {
$variables['theme_hook_suggestions'] = array_diff(
$variables['theme_hook_suggestions'], array('region__no_wrapper')
);
}
}
// */
/**
* Override or insert variables into the block templates.
*
* @param array $variables
* Variables to pass to the theme template.
* @param string $hook
* The name of the template being rendered ("block" in this case.)
*/
/* -- Delete this line if you want to use this function
function wesnoth_hu_theme_preprocess_block(&$variables, $hook) {
// Add a count to all the blocks in the region.
// $variables['classes_array'][] = 'count-' . $variables['block_id'];
// By default, Zen will use the block--no-wrapper.tpl.php for the main
// content. This optional bit of code undoes that:
if ($variables['block_html_id'] == 'block-system-main') {
$variables['theme_hook_suggestions'] = array_diff(
$variables['theme_hook_suggestions'], array('block__no_wrapper')
);
}
}
// */
/**
* Override or insert variables into the node templates.
*
* @param array $variables
* Variables to pass to the theme template.
* @param string $hook
* The name of the template being rendered ("node" in this case.)
*/
/* -- Delete this line if you want to use this function
function wesnoth_hu_theme_preprocess_node(&$variables, $hook) {
$variables['sample_variable'] = t('Lorem ipsum.');
// Optionally, run node-type-specific preprocess functions, like
// STARTERKIT_preprocess_node_page() or STARTERKIT_preprocess_node_story().
$function = __FUNCTION__ . '_' . $variables['node']->type;
if (function_exists($function)) {
$function($variables, $hook);
}
}
// */
/**
* Override or insert variables into the comment templates.
*
* @param array $variables
* Variables to pass to the theme template.
* @param string $hook
* The name of the template being rendered ("comment" in this case.)
*/
/* -- Delete this line if you want to use this function
function wesnoth_hu_theme_preprocess_comment(&$variables, $hook) {
$variables['sample_variable'] = t('Lorem ipsum.');
}
// */
/**
* Implementation of HOOK_theme().
*/
/*
function wesnoth_hu_theme_theme(&$existing, $type, $theme, $path) {
// insert a large indexed value, so advanced_forum_theme_register_alter can't override it
$existing['forum_list']['theme paths'][99] = 'sites/all/themes/wesnoth_hu_theme/templates/';
$existing['forum_icon']['theme paths'][99] = 'sites/all/themes/wesnoth_hu_theme/templates/';
$existing['forum_topic_list']['theme paths'][99] = 'sites/all/themes/wesnoth_hu_theme/templates/';
$existing['comment_wrapper']['theme paths'][99] = 'sites/all/themes/wesnoth_hu_theme/templates/';
$existing['author_pane']['theme paths'][99] = 'sites/all/themes/wesnoth_hu_theme/templates/';
return zen_theme($existing, $type, $theme, $path);
}
*/
/**
* Override or insert PHPTemplate variables into all templates.
*
* @param $vars
* A sequential array of variables to pass to the theme template.
* @param $hook
* The name of the theme function being called (name of the .tpl.php file.)
*/
// /* -- Delete this line if you want to use this function
/*
function wesnoth_hu_theme_preprocess(&$vars, $hook) {
global $theme_key;
$path_to_theme = drupal_get_path('theme', $theme_key);
if($hook == 'comment'){
// tegyük bele az osztályokba az online felhasználók kijelzését
$timestamp = time() - 1800; // 3600s is one hour.
$result = db_query('SELECT COUNT(*) FROM {sessions} WHERE uid = %d AND timestamp >= %d', $vars['account']->uid, $timestamp);
$r = db_result($result);
if( $r > 0 ) $vars['classes_array'][] = 'author-online';
// user location
$vars['location_user_location'] = $vars['account']->profile_user_from;
}
}
// */
/**
* The rel="nofollow" attribute is missing from anonymous users' URL in Drupal 6.0-6.2.
*/
///* -- Delete this line if you want to use this function
/*
function wesnoth_hu_theme_username($object) {
if ($object->uid && $object->name) {
// Shorten the name when it is too long or it will break many tables.
if (drupal_strlen($object->name) > 20) {
$name = drupal_substr($object->name, 0, 15) . '...';
}
else {
$name = $object->name;
}
if (user_access('access user profiles')) {
$output = l($name, 'user/' . $object->uid, array('attributes' => array('title' => t('View user profile.'))));
}
else {
$output = check_plain($name);
}
}
else if ($object->name) {
// Sometimes modules display content composed by people who are
// not registered members of the site (e.g. mailing list or news
// aggregator modules). This clause enables modules to display
// the true author of the content.
if (!empty($object->homepage)) {
$output = l($object->name, $object->homepage, array('attributes' => array('rel' => 'nofollow')));
}
else {
$output = check_plain($object->name);
}
$output .= ' (' . t('not verified') . ')';
}
else {
$output = variable_get('anonymous', t('Anonymous'));
}
return $output;
}
// */
/**
* Return a multidimensional array of links for a navigation menu.
*
* @param $menu_name
* The name of the menu.
* @param $level
* Optional, the depth of the menu to be returned.
* @return
* An array of links of the specified menu and level.
*/
function wesnoth_hu_theme_navigation_links($menu_name, $level = 0) {
// Don't even bother querying the menu table if no menu is specified.
if (empty($menu_name)) {
return array();
}
// Get the menu hierarchy for the current page.
$tree_page = menu_tree_page_data($menu_name);
// Also get the full menu hierarchy.
$tree_all = menu_tree_all_data($menu_name);
// Go down the active trail until the right level is reached.
while ($level-- > 0 && $tree_page) {
// Loop through the current level's items until we find one that is in trail.
while ($item = array_shift($tree_page)) {
if ($item['link']['in_active_trail']) {
// If the item is in the active trail, we continue in the subtree.
$tree_page = empty($item['below']) ? array() : $item['below'];
break;
}
}
}
return wesnoth_hu_theme_navigation_links_level($tree_page, $tree_all);
}
/**
* Helper function for wesnoth_hu_theme_navigation_links to recursively create an array of links.
* (Both trees are required in order to include every menu item and active trail info.)
*/
function wesnoth_hu_theme_navigation_links_level($tree_page, $tree_all) {
$links = array();
foreach ($tree_all as $key => $item) {
$item_page = $tree_page[$key];
$item_all = $tree_all[$key];
if (!$item_all['link']['hidden']) {
$class = '';
$l = $item_all['link']['localized_options'];
$l['href'] = $item_all['link']['href'];
$l['title'] = $item_all['link']['title'];
if ($item_page['link']['in_active_trail']) {
$class = ' active-trail';
}
if ($item_all['below']) {
$l['children'] = wesnoth_hu_theme_navigation_links_level($item_page['below'], $item_all['below']);
}
// Keyed with the unique mlid to generate classes in theme_links().
$links['menu-'. $item_all['link']['mlid'] . $class] = $l;
}
}
return $links;
}
/**
* Helper function to retrieve the primary links using wesnoth_hu_theme_navigation_links().
*/
function wesnoth_hu_theme_primary_links() {
return wesnoth_hu_theme_navigation_links(variable_get('menu_primary_links_source', 'primary-links'));
}
/**
* Return a themed set of links. (Extended to support multidimensional arrays of links.)
*
* @param $links
* A keyed array of links to be themed.
* @param $attributes
* A keyed array of attributes
* @return
* A string containing an unordered list of links.
*/
function wesnoth_hu_theme_links($links, $attributes = array('class' => 'links')) {
$output = '';
if (count($links) > 0) {
$output = '<ul'. drupal_attributes($attributes) .'>';
$num_links = count($links);
$i = 1;
foreach ($links as $key => $link) {
$class = $key;
// Add first, last and active classes to the list of links to help out themers.
if ($i == 1) {
$class .= ' first';
}
if ($i == $num_links) {
$class .= ' last';
}
if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))) {
$class .= ' active';
}
// Added: if the link has child items, add a haschildren class
if (isset($link['children'])) {
$class .= ' haschildren';
}
$output .= '<li'. drupal_attributes(array('class' => $class)) .'>';
if (isset($link['href'])) {
// Pass in $link as $options, they share the same keys.
$output .= l($link['title'], $link['href'], $link);
}
else if (!empty($link['title'])) {
// Some links are actually not links, but we wrap these in <span> for adding title and class attributes
if (empty($link['html'])) {
$link['title'] = check_plain($link['title']);
}
$span_attributes = '';
if (isset($link['attributes'])) {
$span_attributes = drupal_attributes($link['attributes']);
}
$output .= '<span'. $span_attributes .'>'. $link['title'] .'</span>';
}
// Added: if the link has child items, print them out recursively
if (isset($link['children'])) {
$output .= "\n" . theme('links', $link['children'], array('class' =>'sublinks'));
}
$i++;
$output .= "</li>\n";
}
$output .= '</ul>';
}
return $output;
}
/**
* Calculates the number of unread replies for each forum and returns the
* count for the requested forum.
*/
/*
function wesnoth_hu_theme_unread_comments_in_forum($tid, $uid) {
static $result_cache = NULL;
$r = 0;
if (is_NULL($result_cache)) {
$result_cache = array();
$sql = "SELECT COUNT(c.cid) AS count, f.tid, t.parent
FROM {comments} c
INNER JOIN {forum} f ON c.nid = f.nid
INNER JOIN {node} n ON f.vid = n.vid
INNER JOIN {term_hierarchy} t ON t.tid = f.tid
LEFT JOIN {history} h ON c.nid = h.nid AND h.uid = %d
WHERE c.status = 0 AND c.timestamp > %d AND (c.timestamp > h.timestamp OR h.timestamp IS NULL)
GROUP BY f.tid";
$sql = db_rewrite_sql($sql, 'c', 'cid');
$result = db_query($sql, $uid, NODE_NEW_LIMIT);
while ($row = db_fetch_array($result)) {
$result_cache[$row['tid']] = $row['count'];
if($row['parent'] > 0){
// ha van szülője, akkor a szülőnek is könyveljük el
$result_cache[$row['parent']] += $row['count'];
}
}
}
if(isset($result_cache[$tid])) $r = $result_cache[$tid];
return $r;
}
*/