You are here

protected function crumbs_Admin_WeightsTable::gridOfDescriptions in Crumbs, the Breadcrumbs suite 7.2

Return value

array

1 call to crumbs_Admin_WeightsTable::gridOfDescriptions()
crumbs_Admin_WeightsTable::getRows in lib/Admin/WeightsTable.php

File

lib/Admin/WeightsTable.php, line 73

Class

crumbs_Admin_WeightsTable
This class is a helper for theme_crumbs_weights_tabledrag()

Code

protected function gridOfDescriptions() {
  $offsets = array();
  $n = 0;
  foreach ($this->descriptions as $row_key => $row_descriptions) {
    $offset = 0;
    foreach ($row_descriptions as $key => $descriptions) {
      if (0 || !isset($offsets[$key]) || $offsets[$key] < $offset) {
        $offsets[$key] = $offset;
      }
      $offset += count($descriptions);
    }
    $n = max($n, $offset);
  }
  $empty_row = array_fill(0, $n, '');
  $grid = array();
  foreach ($this->descriptions as $row_key => $row_descriptions) {
    $row = $empty_row;
    $cell_offset = 0;
    foreach ($row_descriptions as $key => $descriptions) {
      $offset = $offsets[$key];
      foreach ($descriptions as $i => $description) {
        $cell_offset = $offset + $i;
        $row[$cell_offset] = $description;
      }
    }
    $colspan = $n - $cell_offset;
    if ($colspan > 1) {
      $row[$cell_offset] = array(
        'colspan' => $colspan,
        'data' => $row[$cell_offset],
      );
      $row = array_slice($row, 0, $cell_offset + 1);
    }
    $rule_key = substr($row_key, 6);
    $row_weight = $this->pluginInfo->weightMap
      ->valueAtKey($rule_key);
    $row[] = is_numeric($row_weight) ? t('!key:&nbsp;!value', array(
      '!key' => t('Weight'),
      '!value' => $row_weight,
    )) : t('Disabled');
    $grid[$row_key] = $row;
  }
  return array(
    $grid,
    $n + 1,
  );
}