-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworkbench_nodequeue.pages.inc
More file actions
149 lines (125 loc) · 4.63 KB
/
workbench_nodequeue.pages.inc
File metadata and controls
149 lines (125 loc) · 4.63 KB
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
<?php
function workbench_nodequeue_overview() {
$module = 'nodequeue';
$name = 'includes/nodequeue.admin';
$type = 'inc';
if (module_load_include($type, $module, $name) === FALSE) {
return drupal_not_found();
}
$output = array();
// Allow other modules to add content here.
$output['#attributes'] = array('class' => array('admin', 'my-workbench'));
$output['#attached'] = array(
'css' => array(drupal_get_path('module', 'workbench') . '/css/workbench.my-workbench.css'),
);
$output['#theme'] = 'workbench_element';
// This left column is given a width of 35% by workbench.myworkbench.css.
$output['workbench_nodequeue_overview'] = array(
'#title' => t('Node Queues Overview'),
'#markup' => '<img src="http://www.thimothoeye.be/sub.png"/>',
'#attributes' => array('class' => array('left', 'clearfix')),
'#theme' => 'workbench_element',
);
// !! What follows is a shameless steal of nodequeue_view_queues !!
// Fetch all of the queues.
$queues = nodequeue_load_queues(nodequeue_get_all_qids(25));
// Access Control
foreach ($queues as $queue) {
if (!nodequeue_queue_access($queue)) {
unset($queues[$queue->qid]);
}
}
if (empty($queues)) {
return $output . t('No nodequeues exist.');
}
$header = array(
array('data' => t('Title'), 'field' => 'title', 'sort' => 'asc'),
array('data' => t('Max nodes'), 'field' => 'size'),
array('data' => t('Current Nodes'), 'field' => 'subqueues'),
);
$table_sort = tablesort_init($header);
$qids = array();
$sort_primary = array();
$sort_secondary = array();
$sort_direction_regular = array('asc' => SORT_ASC, 'desc' => SORT_DESC);
$sort_direction_reverse = array('asc' => SORT_DESC, 'desc' => SORT_ASC);
foreach ($queues as $queue) {
// If a queue has only one subqueue, store the qid so we can display
// the number of nodes in the subqueue.
if ($queue->subqueues == 1) {
$qids[] = $queue->qid;
}
$sort_secondary[] = drupal_strtolower($queue->title);
switch ($table_sort['sql']) {
case 'title':
default:
$sort_primary[] = drupal_strtolower($queue->title);
$sort_direction = $sort_direction_regular;
break;
case 'size':
$sort_primary[] = $queue->size;
$sort_direction = $sort_direction_reverse;
break;
case 'subqueues':
$sort_primary[] = $queue->subqueues;
$sort_direction = $sort_direction_regular;
break;
}
}
$subqueues = nodequeue_load_subqueues_by_queue($qids);
// Relate all the subqueues we loaded back to our queues.
foreach ($subqueues as $subqueue) {
if (nodequeue_api_subqueue_access($subqueue, NULL, $queues[$subqueue->qid])) {
$queues[$subqueue->qid]->subqueue = $subqueue;
}
}
if (!empty($table_sort)) {
if (strtolower($table_sort['sort']) == 'desc') {
array_multisort($sort_primary, $sort_direction['desc'], $sort_secondary, $queues); // Re-indexes array keys; key no longer equals qid.
}
else {
array_multisort($sort_primary, $sort_direction['asc'], $sort_secondary, $queues); // Re-indexes array keys; key no longer equals qid.
}
}
$rows = array();
foreach ($queues as $queue) {
$sub_text = $queue->subqueues;
// If this queue has only one subqueue.
if ($sub_text == 1) {
$sub_text = nodequeue_subqueue_size_text($queue->size, $queue->subqueue->count);
}
$link = l(check_plain($queue->title), "admin/workbench/queues/$queue->qid");
$rows[] = array(
array('data' => $link),
array('data' => $queue->size == 0 ? t('Infinite') : $queue->size),
array('data' => $sub_text),
);
}
$output['workbench_nodequeue_list'] = array(
'#attributes' => array('class' => array('right', 'clearfix')),
'#theme' => 'workbench_element',
'#markup' => theme('table', array('header' => $header, 'rows' => $rows))
);
// $output .= theme('pager', array('tags' => NULL));
return $output;
}
function workbench_nodequeue_queue_view($qid) {
$module = 'nodequeue';
$name = 'includes/nodequeue.admin';
$type = 'inc';
if (module_load_include($type, $module, $name) === FALSE) {
return drupal_not_found();
}
$queue = nodequeue_load($qid);
$subqueues = array();
if ($queue->subqueues == 1) {
$subqueues = nodequeue_load_subqueues_by_queue($queue->qid);
} else {
// @TODO Error reporting: Only simple queues allowed
return drupal_not_found();
}
$subqueue = reset($subqueues);
// // get nodes from the queue
$nodes = _nodequeue_dragdrop_get_nodes($queue, $subqueue);
return drupal_get_form('nodequeue_arrange_subqueue_form_' . $subqueue->sqid, $queue, $nodes, $subqueue);
}