You are here

function organigrams_generate_items_list in Organigrams 7

Create a nested array with items to be used for generating an item list.

The orgchart library will extract the node data from the list item attributes.

Parameters

array $hierarchical_list: An array containing all organigrams items sorted by parent.

int $parent: The parent ID of an organigrams item.

Return value

array Nested array ready for the item list theme.

1 call to organigrams_generate_items_list()
organigrams_compose_organigrams in ./organigrams.module
Generate an renderable item list array for the specified organigram.

File

./organigrams.module, line 1234
Defines the organigrams functions and entity types.

Code

function organigrams_generate_items_list($hierarchical_list = array(), $parent = 0) {
  $ul_list = array();
  if (isset($hierarchical_list[$parent])) {
    foreach ($hierarchical_list[$parent] as $item) {

      // Create the HTML content for the li.
      $html_name = str_replace('[br]', '<br />', check_plain($item->name));
      if (!empty($item->url)) {
        $attributes = array(
          'html' => TRUE,
          'attributes' => array(),
        );
        if (strtolower(substr($item->url, 0, 4)) == 'http') {
          $attributes['attributes']['target'] = '_blank';
        }
        $html_name = l($html_name, $item->url, $attributes);
      }
      $ul_list[] = array(
        'data' => $html_name,
        'children' => organigrams_generate_items_list($hierarchical_list, $item->iid),
        'item_id' => check_plain($item->iid),
        'parent' => empty($item->parent) ? '' : check_plain($item->parent),
        'position' => check_plain($item->position),
        'text' => decode_entities(check_plain($item->name)),
        'bold_border' => check_plain($item->bold_border),
        'url' => decode_entities(check_plain($item->url)),
        'border_color' => check_plain($item->border_color),
        'border_color_hover' => check_plain($item->border_color_hover),
        'background_color' => check_plain($item->background_color),
        'background_color_hover' => check_plain($item->background_color_hover),
        'font_color' => check_plain($item->font_color),
        'font_color_hover' => check_plain($item->font_color_hover),
        'image_url' => check_plain($item->image_url),
        'image_alignment' => check_plain($item->image_alignment),
      );
    }
  }
  return $ul_list;
}