-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnodequeue.theme.inc
122 lines (105 loc) · 3.05 KB
/
nodequeue.theme.inc
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
<?php
/**
* @file
* Theme and preprocess functions for the Nodequeue module.
*/
/**
* Theme the subqueue overview as a sortable list.
*
* @ingroup themeable
*/
function theme_nodequeue_arrange_subqueue_form_table($variables) {
$form = $variables['form'];
$output = '';
// Get css to hide some of the help text if javascript is disabled.
backdrop_add_css(backdrop_get_path('module', 'nodequeue') . '/css/nodequeue.css');
$table_id = 'nodequeue-dragdrop-' . $form['#subqueue']['sqid'];
$table_classes = array(
'nodequeue-dragdrop',
'nodequeue-dragdrop-qid-' . $form['#subqueue']['qid'],
'nodequeue-dragdrop-sqid-' . $form['#subqueue']['sqid'],
'nodequeue-dragdrop-reference-' . $form['#subqueue']['reference'],
);
backdrop_add_tabledrag($table_id, 'order', 'sibling', 'node-position');
backdrop_add_js(backdrop_get_path('module', 'nodequeue') . '/js/nodequeue_dragdrop.js');
$reverse[str_replace('-', '_', $table_id)] = (bool) $form['#queue']['reverse'];
backdrop_add_js(
array(
'nodequeue' => array(
'reverse' => $reverse,
)
),
array(
'type' => 'setting',
'scope' => JS_DEFAULT,
)
);
// Render form as table rows.
$rows = array();
$counter = 1;
foreach (element_children($form) as $key) {
if (isset($form[$key]['title'])) {
$row = array();
$row[] = backdrop_render($form[$key]['title']);
$row[] = backdrop_render($form[$key]['author']);
$row[] = backdrop_render($form[$key]['date']);
$row[] = backdrop_render($form[$key]['position']);
$row[] = backdrop_render($form[$key]['operations']);
$row[] = array(
'data' => $counter,
'class' => array('position')
);
$classes = !empty($form[$key]['#attributes']['class']) ? $form[$key]['#attributes']['class'] : array();
$classes[] = 'draggable';
$rows[] = array(
'data' => $row,
'class' => $classes,
);
}
$counter++;
}
if (empty($rows)) {
$rows[] = array(array('data' => t('There is no content in this queue.'), 'colspan' => 6));
}
// Render the main nodequeue table.
$header = array(
t('Title'),
t('Author'),
t('Post Date'),
t('Position Field'),
t('Operations'),
t('Position'),
);
// Allow other modules to alter the table setup before output.
backdrop_alter('nodequeue_arrange_subqueue_form', $form, $header, $rows);
$output .= theme('table', array(
'header' => $header,
'rows' => $rows,
'attributes' => array('id' => $table_id, 'class' => $table_classes),
));
return $output;
}
/**
* Return a "queue is empty" message.
*
* @ingroup themeable
*/
function theme_nodequeue_subqueue_empty_text() {
return t('Queue empty');
}
/**
* Return a "queue is full" message.
*
* @ingroup themeable
*/
function theme_nodequeue_subqueue_full_text() {
return t('Queue full');
}
/**
* Return a count of elements in the queue.
*
* @ingroup themeable
*/
function theme_nodequeue_subqueue_count_text($variables) {
return t('@count in queue', array('@count' => $variables['count']));
}