function ctools_context_node_settings_form

1 string reference to 'ctools_context_node_settings_form'
node.inc in plugins/contexts/node.inc
Plugin to provide a node context. A node context is a node wrapped in a context object that can be utilized by anything that accepts contexts.

File

plugins/contexts/node.inc, line 70

Code

function ctools_context_node_settings_form($form, &$form_state) {
    $conf =& $form_state['conf'];
    $form['node'] = array(
        '#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_query('SELECT * FROM {node} WHERE nid = :nid', array(
            ':nid' => $conf['nid'],
        ))->fetchObject();
        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;
}