-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsse_noticefilter.module
62 lines (55 loc) · 1.48 KB
/
sse_noticefilter.module
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
<?php
/**
* implement hook_ds_fields_info()
*/
function sse_noticefilter_ds_fields_info($entity_type) {
$views_fields = [];
$views_fields['notice_filter_block'] = [
'title' => t('通知:筛选区块'),
'field_type' => DS_FIELD_TYPE_BLOCK,
'properties' => [
'block' => 'sse_noticefilter|notice_filter_block',
'block_render' => DS_BLOCK_CONTENT
]
];
return ['ds_views' => $views_fields];
}
/**
* implement hook_block_info()
*/
function sse_noticefilter_block_info() {
$blocks = [];
$blocks['notice_filter_block']['info'] = t('SSE: 通知筛选区块');
$blocks['notice_filter_block']['cache'] = DRUPAL_NO_CACHE;
return $blocks;
}
/**
* implement hook_block_view()
*/
function sse_noticefilter_block_view($delta = '') {
if ($delta === 'notice_filter_block') {
$block = [];
$block['subject'] = t('通知筛选');
$block['content'] = theme('notice_filter_block', [
'filters' => _sse_noticefilter_get_filters()
]);
return $block;
}
}
/**
* 获取过滤术语
*/
function _sse_noticefilter_get_filters() {
$filters = [];
$filters[] = _sse_noticefilter_get_filter('target', 'notice_target');
$filters[] = _sse_noticefilter_get_filter('category', 'notice_category');
return $filters;
}
function _sse_noticefilter_get_filter($meta, $taxonomy_name) {
$data = sse_util_get_nested_taxonomy_tree($taxonomy_name, true);
return [
'title' => $data['vocabulary']->name,
'meta' => $meta,
'tree' => $data['tree']
];
}