You are here

function template_process_panels_add_content_modal in Panels 7.3

Process the panels add content modal.

This is run here so that preprocess can make changes before links are actually rendered.

File

includes/add-content.inc, line 46
Contains template preprocess files for the add content modal themes.

Code

function template_process_panels_add_content_modal(&$vars) {
  $content = !empty($vars['categories'][$vars['category']]['content']) ? $vars['categories'][$vars['category']]['content'] : array();

  // If no category is selected or the category is empty or our special empty
  // category render a 'header' that will appear instead of the columns.
  if (empty($vars['category']) || empty($content) || $vars['category'] == 'root') {
    $vars['header'] = t('Content options are divided by category. Please select a category from the left to proceed.');
  }
  else {
    $titles = array_keys($content);
    natcasesort($titles);

    // This will default to 2 columns in the theme definition but could be
    // changed by a preprocess. Ensure there is at least one column.
    $columns = max(1, $vars['column_count']);
    $vars['columns'] = array_fill(1, $columns, '');
    $col_size = count($titles) / $columns;
    $count = 0;
    foreach ($titles as $title) {
      $which = floor($count++ / $col_size) + 1;
      $vars['columns'][$which] .= theme('panels_add_content_link', array(
        'renderer' => $vars['renderer'],
        'region' => $vars['region'],
        'content_type' => $content[$title],
      ));
    }
  }
  $vars['messages'] = theme('status_messages');
}