function hosting_task_view in Hosting 6.2
Same name and namespace in other branches
- 5 task/hosting_task.module \hosting_task_view()
- 7.4 task/hosting_task.module \hosting_task_view()
- 7.3 task/hosting_task.module \hosting_task_view()
Implementation of hook_view().
File
- task/
hosting_task.module, line 716 - Web server node type is defined here.
Code
function hosting_task_view($node, $teaser = FALSE, $page = FALSE) {
drupal_add_js(drupal_get_path('module', 'hosting') . '/hosting.js');
$node = node_prepare($node, $teaser);
$ref = node_load($node->rid);
hosting_set_breadcrumb($node);
$node->content['info']['#prefix'] = '<div id="hosting-task-info" class="clear-block">';
$node->content['info']['reference'] = array(
'#type' => 'item',
'#title' => drupal_ucfirst($ref->type),
'#value' => _hosting_node_link($node->rid),
);
if ($node->task_status != HOSTING_TASK_QUEUED) {
if ($node->task_status == HOSTING_TASK_PROCESSING) {
$node->content['info']['started'] = array(
'#type' => 'item',
'#title' => t('Started'),
'#value' => format_date($node->executed),
'#weight' => 1,
);
$node->content['info']['delta'] = array(
'#type' => 'item',
'#title' => t('Processing time'),
'#value' => format_interval(time() - $node->executed),
'#weight' => 2,
);
}
else {
$node->content['info']['executed'] = array(
'#type' => 'item',
'#title' => t('Executed'),
'#value' => format_date($node->executed),
'#weight' => 1,
);
$node->content['info']['delta'] = array(
'#type' => 'item',
'#title' => t('Execution time'),
'#value' => format_interval($node->delta),
'#weight' => 2,
);
}
}
else {
$queues = hosting_get_queues();
$queue = $queues['tasks'];
$next = _hosting_queue_next_run($queue);
$node->content['info']['notexecuted'] = array(
'#type' => 'item',
'#title' => t('This task has not been processed yet'),
'#value' => t('It will be processed around %date, if the queue is not too crowded. The queue is currently run every %freq, was last run %last and processes %items items at a time. Server time is %time.', array(
'%freq' => format_interval($queue['frequency']),
'%date' => format_date($next, 'custom', 'H:i:sO'),
'%last' => hosting_format_interval($queue['last_run']),
'%items' => $queue['items'],
'%time' => format_date(time(), 'custom', 'H:i:sO'),
)),
);
}
if ($node->task_status) {
$node->content['info']['status'] = array(
'#type' => 'item',
'#title' => t('Status'),
'#value' => _hosting_parse_error_code($node->task_status),
);
}
$node->content['info']['#suffix'] = '</div>';
if (user_access('retry failed tasks') && $node->task_status == HOSTING_TASK_ERROR) {
$node->content['retry'] = array(
'#type' => 'markup',
'#value' => drupal_get_form('hosting_task_retry_form', $node->nid),
'#weight' => 5,
);
}
if (user_access('update status of tasks') && $node->task_status == HOSTING_TASK_PROCESSING) {
$node->content['update-status'] = array(
'#type' => 'markup',
'#value' => drupal_get_form('hosting_task_update_status_form', $node->vid),
'#weight' => 5,
);
}
if (user_access('access task logs')) {
if ($table = _hosting_task_log_table($node->vid)) {
$node->content['hosting_log'] = array(
'#weight' => 10,
'#type' => 'item',
'#value' => $table,
);
}
}
return $node;
}