You are here

function panels_views_edit_view_form in Panels 5.2

Form to add or edit add a view pane.

4 string references to 'panels_views_edit_view_form'
panels_views_add_view in panels_views/panels_views.module
Page callback to add a new view pane from an existing view.
panels_views_edit_view in panels_views/panels_views.module
Page callback to edit a view pane.
panels_views_import_form_submit in panels_views/panels_views.module
Handle the submit button on importing a view pane.
panels_views_import_view in panels_views/panels_views.module
Page callback to import a view pane.

File

panels_views/panels_views.module, line 238
panels_views.module

Code

function panels_views_edit_view_form($view, $panel_view) {
  panels_views_pane_arguments($view, $panel_view);
  $form['basic'] = array(
    '#type' => 'fieldset',
    '#title' => t('Basic information'),
  );
  if (!empty($panel_view->pvid) && is_numeric($panel_view->pvid)) {
    $form['pvid'] = array(
      '#type' => 'value',
      '#value' => $panel_view->pvid,
    );
  }
  $form['view'] = array(
    '#type' => 'value',
    '#value' => $panel_view->view,
  );
  $form['basic']['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Panel view name'),
    '#description' => t('Enter a unique name for this view pane. It must contain only letters and numbers.'),
    '#default_value' => $panel_view->name,
  );
  $form['basic']['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Panel view title'),
    '#description' => t('The title of the pane; this will appear in the add content dialog.'),
    '#default_value' => $panel_view->title,
  );
  $form['basic']['description'] = array(
    '#type' => 'textfield',
    '#title' => t('Description'),
    '#description' => t('This description will be shown to the user when as a hover tip when adding this pane.'),
    '#default_value' => $panel_view->description,
  );
  $form['basic']['category'] = array(
    '#type' => 'textfield',
    '#title' => t('Category'),
    '#category' => t('The category this view will appear in using the add content dialog.'),
    '#default_value' => $panel_view->category,
  );
  $form['basic']['category_weight'] = array(
    '#type' => 'select',
    '#default_value' => $panel_view->category_weight,
    '#title' => t('Category weight'),
    '#description' => t('The weight of the category; lower numbers will appear closer to the top of the dialog.'),
    '#options' => drupal_map_assoc(range(-10, 10)),
  );
  $form['basic']['view_type'] = array(
    '#type' => 'select',
    '#default_value' => $panel_view->view_type,
    '#title' => t('View type'),
    '#description' => t('Select which type of the view to display.'),
    '#options' => array(
      'page' => t('Page'),
      'block' => t('Block'),
      'embed' => t('Embedded'),
    ),
  );
  $form['contexts'] = array(
    '#tree' => TRUE,
  );
  views_load_cache();
  $arginfo = _views_get_arguments();
  panels_load_include('plugins');
  $contexts = panels_get_contexts();
  $context_options = array(
    'any' => t('Any context'),
  );
  foreach ($contexts as $name => $context) {
    $context_options[$name] = $context['title'];
  }
  asort($context_options);
  foreach ($panel_view->contexts as $id => $info) {
    $name = $arginfo[$view->argument[$id]['type']]['name'];
    $form['contexts'][$id] = array(
      '#type' => 'fieldset',
      '#title' => t('Argument: @arg', array(
        '@arg' => $name,
      )),
      '#tree' => TRUE,
    );
    $form['contexts'][$id]['type'] = array(
      '#type' => 'select',
      '#options' => array(
        'wildcard' => t('Argument wildcard'),
        'none' => t('No argument'),
        'context' => t('From context'),
        'panel' => t('From panel argument'),
        'fixed' => t('Fixed'),
        'user' => t('Input on pane config'),
      ),
      '#title' => t('Argument source'),
      '#default_value' => $panel_view->contexts[$id]['type'],
    );
    $form['contexts'][$id]['context'] = array(
      '#type' => 'select',
      '#title' => t('Required context'),
      '#description' => t('If "From context" is selected, which context to require.'),
      '#default_value' => $panel_view->contexts[$id]['context'],
      '#options' => $context_options,
    );
    $form['contexts'][$id]['panel'] = array(
      '#type' => 'select',
      '#title' => t('Panel argument'),
      '#description' => t('If "From panel argument" is selected, which panel argument to use.'),
      '#default_value' => $panel_view->contexts[$id]['panel'],
      '#options' => array(
        0 => t('First'),
        1 => t('Second'),
        2 => t('Third'),
        3 => t('Fourth'),
        4 => t('Fifth'),
        5 => t('Sixth'),
      ),
    );
    $form['contexts'][$id]['fixed'] = array(
      '#type' => 'textfield',
      '#title' => t('Fixed argument'),
      '#description' => t('If "Fixed" is selected, what to use as an argument.'),
      '#default_value' => $panel_view->contexts[$id]['fixed'],
    );
    $form['contexts'][$id]['label'] = array(
      '#type' => 'textfield',
      '#title' => t('Label'),
      '#description' => t('If this argument is presented to the panels user, what label to apply to it.'),
      '#default_value' => empty($panel_view->contexts[$id]['label']) ? $name : $panel_view->contexts[$id]['label'],
    );
  }
  $form['pager'] = array(
    '#type' => 'fieldset',
    '#title' => t('Paging information'),
  );
  $form['pager']['use_pager'] = array(
    '#type' => 'checkbox',
    '#title' => t('Use pager'),
    '#description' => t('Use a pager with this view'),
    '#default_value' => $panel_view->use_pager,
  );
  $form['pager']['pager_id'] = array(
    '#type' => 'textfield',
    '#title' => t('Pager ID'),
    '#description' => t('If using a pager, what pager ID to use; every pager on the page should be unique and you should always use the lowest pager ID available. Use 0 if at all possible.'),
    '#default_value' => $panel_view->pager_id,
  );
  $form['pager']['allow_use_pager'] = array(
    '#type' => 'checkbox',
    '#title' => t('Allow the pane configuration to modify the use pager setting.'),
    '#default_value' => $panel_view->allow_use_pager,
  );
  $form['pager']['nodes_per_page'] = array(
    '#type' => 'textfield',
    '#title' => t('Items to display'),
    '#description' => t('The maximum number of nodes to display.'),
    '#default_value' => $panel_view->nodes_per_page,
  );
  $form['pager']['allow_nodes_per_page'] = array(
    '#type' => 'checkbox',
    '#title' => t('Allow the pane configuration to modify the items to display setting'),
    '#default_value' => $panel_view->allow_nodes_per_page,
  );
  $form['pager']['offset'] = array(
    '#type' => 'textfield',
    '#title' => t('Offset'),
    '#description' => t('Enter the item number to start at; this option only works if "use pager" is not checked. Enter 0 to start at the first item, 1 to start at the second, etc.'),
    '#default_value' => $panel_view->offset,
  );
  $form['pager']['allow_offset'] = array(
    '#type' => 'checkbox',
    '#title' => t('Allow the pane configuration to modify the offset setting'),
    '#default_value' => $panel_view->allow_offset,
  );
  $form['deco'] = array(
    '#type' => 'fieldset',
    '#title' => t('Pane decorations'),
  );
  $form['deco']['link_to_view'] = array(
    '#type' => 'checkbox',
    '#title' => t('Link to view'),
    '#description' => t('If checked, link the title of the pane to the view.'),
    '#default_value' => $panel_view->link_to_view,
  );
  $form['deco']['allow_link_to_view'] = array(
    '#type' => 'checkbox',
    '#title' => t('Allow the pane configuration to modify the link to view setting.'),
    '#default_value' => $panel_view->allow_link_to_view,
  );
  $form['deco']['more_link'] = array(
    '#type' => 'checkbox',
    '#title' => t('More link'),
    '#description' => t('If checked, Panels will provide a "more" link that links to the view URL; this is different from the view\'s "more" link which will automatically be disabled.'),
    '#default_value' => $panel_view->more_link,
  );
  $form['deco']['allow_more_link'] = array(
    '#type' => 'checkbox',
    '#title' => t('Allow the pane configuration to modify the "more" link setting.'),
    '#default_value' => $panel_view->allow_more_link,
  );
  $form['deco']['more_text'] = array(
    '#type' => 'textfield',
    '#title' => t('More link text'),
    '#description' => t('If you checked the above box allowing Panels to provide its own "more" link, Panels will render that link using the text you enter here. If left blank, defaults to "more".'),
    '#default_value' => $panel_view->more_text,
  );
  $form['deco']['allow_more_text'] = array(
    '#type' => 'checkbox',
    '#title' => t('Allow the pane configuration to modify the "more" link text.'),
    '#default_value' => $panel_view->allow_more_text,
  );
  $form['deco']['feed_icons'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show feed icons'),
    '#description' => t('If checked, any feed icons provided by the view will be visible in the pane.'),
    '#default_value' => $panel_view->feed_icons,
  );
  $form['deco']['allow_feed_icons'] = array(
    '#type' => 'checkbox',
    '#title' => t('Allow the pane configuration to modify the feed icon setting.'),
    '#default_value' => $panel_view->allow_feed_icons,
  );
  $form['deco']['url_override'] = array(
    '#type' => 'checkbox',
    '#title' => t('Override the panel URL with a manually set URL.'),
    '#default_value' => $panel_view->url_override,
  );
  $form['deco']['url'] = array(
    '#type' => 'textfield',
    '#title' => t('Override view URL'),
    '#description' => t('If override URL is set, the URL the view thinks it is using; all "more", "exposed filters", "summary" and "feed" type links will use this URL.') . ' ' . t('You may use $arg to pass panel arguments to the view.'),
    '#default_value' => $panel_view->url,
  );
  $form['deco']['allow_url_override'] = array(
    '#type' => 'checkbox',
    '#title' => t('Allow the pane configuration to modify the URL override setting.'),
    '#default_value' => $panel_view->allow_url_override,
  );
  $form['deco']['url_from_panel'] = array(
    '#type' => 'checkbox',
    '#title' => t('Set view URL to panel URL'),
    '#description' => t('If checked, the URL of the view will be changed to the URL of the panel; this setting is ignored if the "Override view URL" setting, above, is set or allowed.'),
    '#default_value' => $panel_view->url_from_panel,
  );
  $form['deco']['allow_url_from_panel'] = array(
    '#type' => 'checkbox',
    '#title' => t('Allow the pane configuration to modify the "set view URL to panel URL" setting.'),
    '#default_value' => $panel_view->allow_url_from_panel,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  return $form;
}