You are here

function ctools_context_node_edit_form_settings_form in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 plugins/contexts/node_edit_form.inc \ctools_context_node_edit_form_settings_form()
1 string reference to 'ctools_context_node_edit_form_settings_form'
node_edit_form.inc in plugins/contexts/node_edit_form.inc
Plugin to provide a node_edit_form context

File

plugins/contexts/node_edit_form.inc, line 95
Plugin to provide a node_edit_form context

Code

function ctools_context_node_edit_form_settings_form($conf) {
  if (empty($conf)) {
    $conf = array(
      'nid' => '',
    );
  }
  $form['node'] = array(
    '#prefix' => '<div class="no-float">',
    '#suffix' => '</div>',
    '#title' => t('Enter the title or NID of a node'),
    '#type' => 'textfield',
    '#maxlength' => 512,
    '#autocomplete_path' => 'ctools/autocomplete/node',
    '#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(
        'attributes' => array(
          'target' => '_blank',
          'title' => t('Open in new window'),
        ),
        'html' => TRUE,
      ));
      $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;
}