You are here

function panels_views_panes_edit in Panels 6.2

1 string reference to 'panels_views_panes_edit'
panels_views_panels_content_types in panels_views/panels_views.module
Implementation of hook_panels_content_types()

File

panels_views/panels_views.module, line 494
panels_views.module

Code

function panels_views_panes_edit($id, $parents, $conf) {
  list($name, $display_id) = explode('-', $id);
  $view = views_get_view($name);
  if (!$view) {
    return;
  }
  $view
    ->set_display($display_id);
  $allow = $view->display_handler
    ->get_option('allow');

  // Provide defaults for everything in order to prevent warnings.
  if (empty($conf)) {
    $conf['link_to_view'] = $view->display_handler
      ->get_option('link_to_view');
    $conf['more_link'] = $view->display_handler
      ->get_option('more_link');
    $conf['feed_icons'] = $pv->feed_icons;
    $conf['use_pager'] = $view->display_handler
      ->get_option('use_pager');
    $conf['element_id'] = $view->display_handler
      ->get_option('element_id');
    $conf['items_per_page'] = $view->display_handler
      ->get_option('items_per_page');
    $conf['offset'] = $view->display_handler
      ->get_option('offset');
    $conf['path_override'] = FALSE;
    $conf['url'] = $view
      ->get_path();
  }
  foreach ($view->display_handler
    ->get_argument_input() as $id => $argument) {
    if ($argument['type'] == 'user') {
      $form['arguments'][$id] = array(
        '#type' => 'textfield',
        '#default_value' => isset($conf['arguments'][$id]) ? $conf['arguments'][$id] : '',
        '#title' => $argument['label'],
      );
    }
  }
  if ($view->display_handler
    ->has_path()) {
    if ($allow['link_to_view']) {
      $form['link_to_view'] = array(
        '#type' => 'checkbox',
        '#default_value' => $conf['link_to_view'],
        '#title' => t('Link title to page'),
        '#description' => t('If checked, the title will be a link to the page.'),
      );
    }
    if ($allow['more_link']) {
      $form['more_link'] = array(
        '#type' => 'checkbox',
        '#default_value' => $conf['more_link'],
        '#title' => t('Provide a "more" link that links to the view'),
        '#description' => t('This is independent of any more link that may be provided by the view itself; if you see two more links, turn this one off. Views will only provide a more link if using the "block" type, however, so if using embed, use this one.'),
      );
    }
  }
  if ($allow['feed_icons']) {
    $form['feed_icons'] = array(
      '#type' => 'checkbox',
      '#default_value' => $conf['feed_icons'],
      '#title' => t('Display feed icons'),
      '#description' => t('If checked, any feed icons provided will be displayed.'),
    );
  }
  if ($allow['use_pager']) {
    $form['pager_aligner_start'] = array(
      '#value' => '<div class="option-text-aligner">',
    );
    $form['use_pager'] = array(
      '#type' => 'checkbox',
      '#title' => t('Use pager'),
      '#default_value' => $conf['use_pager'],
      '#id' => 'use-pager-checkbox',
    );
    $form['pager_id'] = array(
      '#type' => 'textfield',
      '#default_value' => $conf['pager_id'],
      '#title' => t('Pager ID'),
      '#size' => 4,
      '#id' => 'use-pager-textfield',
    );
    $form['pager_aligner_stop'] = array(
      '#value' => '</div><div style="clear: both; padding: 0; margin: 0"></div>',
    );
  }
  if ($allow['items_per_page']) {
    $form['items_per_page'] = array(
      '#type' => 'textfield',
      '#default_value' => $conf['items_per_page'],
      '#title' => t('Num items'),
      '#size' => 4,
      '#description' => t('Select the number of items to display, or 0 to display all results.'),
    );
  }
  if ($allow['offset']) {
    $form['offset'] = array(
      '#type' => 'textfield',
      '#default_value' => $conf['offset'],
      '#title' => t('Offset'),
      '#size' => 4,
      '#description' => t('Enter the number of items to skip; enter 0 to skip no items.'),
    );
  }
  if ($allow['path_override']) {

    // TODO: Because javascript in the dialogs is kind of weird, dependent checkboxes
    // don't work right for external modules. This needs fixing in panels itself.
    $form['path'] = array(
      '#type' => 'textfield',
      '#default_value' => $conf['path'],
      '#title' => t('Override path'),
      '#size' => 30,
      '#description' => t('If this is set, override the View URL path; this can sometimes be useful to set to the panel URL.'),
    );
  }
  return $form;
}