You are here

function _views_gantt_build_tasks in Views Gantt 7

Adds tasks to XML.

Parameters

object $parent: SimpleXMLElement object with parent tag ('project' or 'task')

array $tasks: Array of tasks which will be attached to $parent

1 call to _views_gantt_build_tasks()
views_gantt_build_xml in ./views_gantt.module
Builds XML file for dhtmlxGantt Chart.

File

./views_gantt.module, line 242
Module file for Views Gantt

Code

function _views_gantt_build_tasks(&$parent, $tasks) {
  foreach ($tasks as $key => $row) {

    // Add task tag to XML.
    $task = $parent
      ->addChild('task');
    $task
      ->addAttribute('id', $key);

    // Add task info to XML.
    foreach ($row as $field_key => $field_value) {
      if ($field_key == 'parent_id') {
        continue;
      }
      if (is_array($field_value)) {
        $field_value = '';
      }
      $task
        ->addChild($field_key, $field_value);
    }

    // If task have subtasks, we add them to XML recursively.
    if (is_array($row['childtasks'])) {
      _views_gantt_build_tasks($task->childtasks, $row['childtasks']);
    }
  }
}