function views_gantt_plugin_style_gantt::render in Views Gantt 7
Same name and namespace in other branches
- 7.2 views_gantt_plugin_style_gantt.inc \views_gantt_plugin_style_gantt::render()
Render the given style.
Overrides views_plugin_style::render
File
- ./
views_gantt_plugin_style_gantt.inc, line 145 - Contains the list style plugin.
Class
- views_gantt_plugin_style_gantt
- Style plugin to render Gantt charts.
Code
function render() {
// Check for live preview.
if (isset($this->view->live_preview)) {
return t('Gantt Chart not compatible with live preview.');
}
$this
->options_fields();
$this
->options_node();
// Get project data.
if (!$this
->get_project()) {
return;
}
// Get array of tasks.
foreach ($this->view->result as $row) {
$this
->add_task($row);
}
foreach ($this->tasks as $key => $task) {
$this
->load_missing_tasks($key);
$this
->load_missing_values($key);
}
// Allow to alter tasks array before next modifications.
drupal_alter('views_gantt_tasks_prerender', $this->tasks);
// Remove tasks marked for deletion
foreach ($this->tasks as $key => $value) {
if ($this
->is_delete($key)) {
unset($this->tasks[$key]);
}
}
$this
->fill_child_ids();
// Build hierarchical tree of tasks and fix incorrect values.
$tree = $this
->build_tree($this->tasks);
foreach ($tree as $key => $task) {
$this
->check_date($task);
$this
->check_duration($task);
$this
->calculate_progress($task);
}
// Exclude incorrect tasks.
foreach ($this->tasks as $key => $value) {
$this
->check_predecessor($key);
if (!$this
->is_correct($key)) {
unset($this->tasks[$key]);
}
}
// If there are no correct tasks.
if (!$this->tasks) {
drupal_set_message(t('There are no tasks that can be displayed in Gantt Chart.'), 'warning');
return;
}
$this
->mark_modified_tasks();
$this
->views_gantt_before_render();
return parent::render();
}