You are here

function panels_context_node_settings_form in Panels 6.2

Same name and namespace in other branches
  1. 5.2 contexts/node.inc \panels_context_node_settings_form()
1 string reference to 'panels_context_node_settings_form'
panels_node_panels_contexts in contexts/node.inc
@file contexts/node.inc

File

contexts/node.inc, line 74
contexts/node.inc

Code

function panels_context_node_settings_form($conf, $external = FALSE) {
  if (empty($conf)) {
    $conf = array(
      'nid' => '',
    );
  }
  if ($external) {
    $form['external'] = array(
      '#type' => 'checkbox',
      '#default_value' => $conf['external'],
      '#title' => t('Require this context from an external source (such as a containing panel page).'),
      '#description' => t('If selected, node selection (below) will be ignored.'),
    );
  }
  $form['node'] = array(
    '#prefix' => '<div class="no-float">',
    '#suffix' => '</div>',
    '#title' => t('Enter the title or NID of a post'),
    '#type' => 'textfield',
    '#maxlength' => 512,
    '#autocomplete_path' => 'panels/node/autocomplete',
    '#weight' => -10,
  );
  if (!empty($conf['nid'])) {
    $info = db_fetch_object(db_query("SELECT * FROM {node} n WHERE n.nid = %d", $conf['nid']));
    if ($info) {
      $link = l(t("'%title' [node id %nid]", array(
        '%title' => $info->title,
        '%nid' => $info->nid,
      )), "node/{$info->nid}", array(
        'target' => '_blank',
        'title' => t('Open in new window'),
      ));
      $form['node']['#description'] = t('Currently set to !link', array(
        '!link' => $link,
      ));
    }
  }
  $form['nid'] = array(
    '#type' => 'value',
    '#value' => $conf['nid'],
  );
  $form['set_identifier'] = array(
    '#type' => 'checkbox',
    '#default_value' => FALSE,
    '#title' => t('Reset identifier to node title'),
    '#description' => t('If checked, the identifier will be reset to the node title of the selected node.'),
  );
  return $form;
}