You are here

function views_content_views_row_edit in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 views_content/plugins/content_types/views_row.inc \views_content_views_row_edit()

File

views_content/plugins/content_types/views_row.inc, line 79

Code

function views_content_views_row_edit(&$form, &$form_state) {
  $conf = $form_state['conf'];
  if (empty($form_state['contexts'][$conf['context']])) {
    $form['markup'] = array(
      '#value' => '<p>' . t('Invalid context selected.') . '</p>',
    );
    return;
  }
  $view = views_content_context_get_view($form_state['contexts'][$conf['context']]);
  if (empty($view)) {
    $form['markup'] = array(
      '#value' => '<p>' . t('Context contains an invalid view.') . '</p>',
    );
    return;
  }
  $rows = $view
    ->get_items_per_page();
  if (empty($rows)) {
    $form['markup'] = array(
      '#value' => '<p>' . t('The view must have a maximum number of items set to use this content type.') . '</p>',
    );
    return;
  }
  foreach (range(1, $rows) as $row) {
    $options[$row] = t('Row @number', array(
      '@number' => $row,
    ));
  }
  $form['rows'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Display'),
    '#options' => $options,
    '#default_value' => $conf['rows'],
  );
  if ($view->display_handler
    ->uses_fields()) {
    $form['use_fields'] = array(
      '#type' => 'checkbox',
      '#title' => t('Display specific fields'),
      '#default_value' => $conf['use_fields'],
    );
    ctools_include('dependent');
    $form['fields'] = array(
      '#type' => 'checkboxes',
      '#options' => $view->display_handler
        ->get_field_labels(),
      '#default_value' => $conf['fields'],
      '#prefix' => '<div id="edit-fields-wrapper"><div id="edit-fields">',
      '#suffix' => '</div></div>',
      '#process' => array(
        'ctools_dependent_process',
        'expand_checkboxes',
      ),
      '#dependency' => array(
        'edit-use-fields' => array(
          TRUE,
        ),
      ),
    );
  }
}