1 | <?php |
---|
2 | |
---|
3 | /** |
---|
4 | * @file |
---|
5 | * Rendering of the accessible content summary page and tabs |
---|
6 | */ |
---|
7 | |
---|
8 | /** |
---|
9 | * Return as a themed table a content summary of the site filtered by the |
---|
10 | * access rights of the logged-in user. |
---|
11 | * |
---|
12 | * @param $access |
---|
13 | * one of 'view', 'update' or 'delete' |
---|
14 | * @param $is_published |
---|
15 | * 1 for published-only, 0 for unpublished-only, NO_FILTER for don't care |
---|
16 | * @param $user_filter |
---|
17 | * One of NO_FILTER, I_CREATED or I_LAST_MODIFIED |
---|
18 | * @param $is_moderated |
---|
19 | * 1 for moderated, 0 for not moderated, NO_FILTER for don't care |
---|
20 | * @param $is_pending |
---|
21 | * TRUE for in draft/pending, FALSE otherwise |
---|
22 | * @return |
---|
23 | * themed HTML |
---|
24 | */ |
---|
25 | function module_grants_monitor_accessible_content_summary($access = 'view', $is_published = -1, |
---|
26 | $user_filter = NO_FILTER, $is_moderated = NO_FILTER, $is_pending = FALSE) { |
---|
27 | global $user; |
---|
28 | $creator_id = ($user_filter == I_CREATED) ? $user->uid : -1; |
---|
29 | $modifier_id = ($user_filter == I_LAST_MODIFIED) ? $user->uid : -1; |
---|
30 | $nodes = node_tools_get_nodes($access, (int)$is_published, $creator_id, $modifier_id, (int)$is_moderated, $is_pending); |
---|
31 | return theme('module_grants_monitor_nodes_summary', $nodes); |
---|
32 | } |
---|
33 | |
---|
34 | /** |
---|
35 | * Theme the passed-in nodes as a table. |
---|
36 | * |
---|
37 | * Uses the following subthemes: |
---|
38 | * o 'table_nodes', falling back to theme.inc/theme_table() if not defined |
---|
39 | * o 'username', i.e. theme.inc/theme_username() |
---|
40 | * |
---|
41 | * @param $nodes |
---|
42 | * Array of nodes to display. |
---|
43 | * @return |
---|
44 | * Themed table HTML or a paragraph saying 'No content found.' if the supplied |
---|
45 | * array is empty. |
---|
46 | * |
---|
47 | * @ingroup themeable |
---|
48 | */ |
---|
49 | function theme_module_grants_monitor_nodes_summary($nodes) { |
---|
50 | $css_path = drupal_get_path('module', 'module_grants_monitor') .'/module_grants_monitor.css'; |
---|
51 | drupal_add_css($css_path, 'module', 'all', FALSE); |
---|
52 | if (!empty($nodes)) { |
---|
53 | // Note the specification of fields doesn't seem to work properly |
---|
54 | // See theme.inc/theme_table(), which uses tablesort.inc/tablesort_header() |
---|
55 | $header = array( |
---|
56 | array('data' => t('Title'), 'field' => 'r.title'), |
---|
57 | array('data' => t('Type'), 'field' => 'n.type'), |
---|
58 | array('data' => t('Creator'), 'field' => 'n.uid'), |
---|
59 | array('data' => t('Last updated'), 'field' => 'timestamp', 'sort' => 'desc'), |
---|
60 | array('data' => t('By'), 'field' => 'r.uid'), |
---|
61 | array('data' => t('Published?'), 'field' => 'status') |
---|
62 | ); |
---|
63 | $show_taxonomy_terms = module_exists('taxonomy') && |
---|
64 | (count(taxonomy_get_vocabularies()) > 0) && variable_get("show_taxonomy_terms", TRUE); |
---|
65 | $show_workflow_state = module_exists('workflow'); |
---|
66 | if ($show_taxonomy_terms) { |
---|
67 | $header[] = array('data' => t('Term'), 'field' => 'term'); |
---|
68 | } |
---|
69 | if ($show_workflow_state) { |
---|
70 | $header[] = array('data' => t('Workflow state'), 'field' => 'ws.state'); |
---|
71 | } |
---|
72 | $rows = array(); |
---|
73 | foreach ($nodes as $node) { |
---|
74 | $row = array( |
---|
75 | l($node->title, 'node/'. $node->nid), |
---|
76 | check_plain(node_get_types('name', $node)), |
---|
77 | theme('username', user_load(array('uid' => $node->creator_uid))), |
---|
78 | format_date($node->timestamp), |
---|
79 | theme('username', user_load(array('uid' => $node->uid))), |
---|
80 | $node->status ? t('Yes') : t('No') |
---|
81 | ); |
---|
82 | if ($show_taxonomy_terms) { |
---|
83 | $row[] = empty($node->term) ? '' : check_plain($node->term); |
---|
84 | } |
---|
85 | if ($show_workflow_state) { |
---|
86 | $row[] = empty($node->state) ? t('No state') : check_plain($node->state); |
---|
87 | } |
---|
88 | $rows[] = $row; |
---|
89 | } |
---|
90 | $attributes = array('class' => 'table-nodes'); |
---|
91 | return theme(array('table_nodes', 'table'), $header, $rows, $attributes, $caption = NULL); |
---|
92 | } |
---|
93 | return '<p>'. t('No content found.') .'</p>'; |
---|
94 | } |
---|
95 | |
---|
96 | /** |
---|
97 | * Implement (in your own module) the function below if you want to override |
---|
98 | * the default way in which the nodes summary table is displayed. |
---|
99 | * If you do, don't forget to register this theme_hook() via <your_module>_theme() |
---|
100 | * in a manner similar to module_grants_module_theme() |
---|
101 | * |
---|
102 | * @param $header |
---|
103 | * @param $rows |
---|
104 | * @return themed HTML, see for instance /includes/theme.inc/theme_table() |
---|
105 | * |
---|
106 | * @ingroup themeable |
---|
107 | * |
---|
108 | function theme_table_nodes($header, $rows) { |
---|
109 | } |
---|
110 | */ |
---|