View source
<?php
function total_control_workflow_overview_ctools_content_types() {
return array(
'single' => TRUE,
'icon' => 'icon_node_form.png',
'no title override' => TRUE,
'title' => t('Workflow Overview'),
'description' => t('Displays workflow and state information.'),
'category' => t('Admin Dashboard'),
);
}
function total_control_workflow_overview_content_type_admin_title($subtype, $conf, $context) {
return t('Workflow Overview');
}
function total_control_workflow_overview_content_type_admin_info($subtype, $conf, $context) {
$block = new stdClass();
$block->title = t('Displays workflow and state information.');
return $block;
}
function total_control_workflow_overview_content_type_render($subtype, $conf, $panel_args, &$context) {
$block = new stdClass();
$block->module = t('total_control_workflow');
$workflows = workflow_get_all();
$rows = array();
foreach ($workflows as $wid => $name) {
if (in_array($wid, $conf['wids'])) {
$workflow_query = db_query("SELECT count(*) FROM {node} n INNER JOIN {workflow_node} wn ON n.nid = wn.nid INNER JOIN {workflow_states} ws ON wn.sid = wn.sid INNER JOIN {workflows} w ON w.wid = ws.wid WHERE w.wid = %d", $wid);
$count = format_plural(db_result($workflow_query), '1 item', '@count total items');
$row = '<div class="workflow"><strong>' . $name . '</strong>: ' . $count . '</div>';
$states = workflow_get_states($wid);
foreach ($states as $sid => $state_name) {
if ($state_name != '(creation)') {
if (!workflow_is_system_state(t($state_name))) {
$state_query = db_query("SELECT count(*) FROM {node} n INNER JOIN {workflow_node} wn ON n.nid = wn.nid WHERE wn.sid = %d", $sid);
$state_count = format_plural(db_result($state_query), '1 item', '@count items');
$row .= '<div class="state-info"><span class="state">' . $state_name . ':</span> ' . $state_count . '</div>';
}
}
}
$rows[] = $row;
}
}
$pane = total_control_workflow_overview_ctools_content_types();
$content = '<div class="total-control-content-overview">';
$content .= ' <h2 class="title">' . $pane['title'] . '</h2>';
$content .= ' <div class="content">';
$content .= theme('item_list', $rows);
$content .= ' </div>';
$content .= '</div>';
$block->content = $content;
return $block;
}
function total_control_workflow_overview_content_type_edit_form(&$form, &$form_state) {
$conf = $form_state['conf'];
$workflows = workflow_get_all();
$workflow_options = array();
$workflow_defaults = array();
foreach ($workflows as $wid => $name) {
$workflow_options[$wid] = $name;
$workflow_defaults[] = $wid;
}
$form['wids'] = array(
'#type' => 'checkboxes',
'#title' => t('Include Workflows'),
'#multiple' => true,
'#options' => $workflow_options,
'#default_value' => $form_state['op'] == 'add' ? $workflow_defaults : $conf['wids'],
);
return $form;
}
function total_control_workflow_overview_content_type_edit_form_submit(&$form, &$form_state) {
foreach ($form_state['values'] as $key => $data) {
$form_state['conf'][$key] = $form_state['values'][$key];
}
}