You are here

function panels_renderer_editor::ajax_select_content in Panels 6.3

Same name and namespace in other branches
  1. 7.3 plugins/display_renderers/panels_renderer_editor.class.php \panels_renderer_editor::ajax_select_content()

AJAX command to present a dialog with a list of available content.

1 call to panels_renderer_editor::ajax_select_content()
panels_renderer_editor::ajax_add_pane in plugins/display_renderers/panels_renderer_editor.class.php
AJAX entry point to add a new pane.

File

plugins/display_renderers/panels_renderer_editor.class.php, line 504
Class file to control the main Panels editor.

Class

panels_renderer_editor
@file Class file to control the main Panels editor.

Code

function ajax_select_content($region = NULL, $category = NULL) {
  if (!array_key_exists($region, $this->plugins['layout']['panels'])) {
    ctools_modal_render(t('Error'), t('Invalid input'));
  }
  $title = t('Add content to !s', array(
    '!s' => $this->plugins['layout']['panels'][$region],
  ));
  $categories = $this
    ->get_categories($this->cache->content_types);
  if (empty($categories)) {
    $output = t('There are no content types you may add to this display.');
  }
  else {
    $output = '<div class="panels-add-content-modal">';
    $selector = $this
      ->render_category_selector($categories, $category, $region);
    $content = !empty($categories[$category]['content']) ? $categories[$category]['content'] : array();
    $center = $this
      ->render_category($content, $category, $region);
    $output .= '<div class="panels-section-column panels-section-column-categories">' . '<div class="inside">' . $selector . '</div></div>';
    $output .= $center;
    $output .= '</div>';

    // panels-add-content-modal
  }
  $this->commands[] = ctools_modal_command_display($title, $output);
}