You are here

function ctools_context_add_item_table_buttons in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 includes/context-admin.inc \ctools_context_add_item_table_buttons()
2 calls to ctools_context_add_item_table_buttons()
ctools_context_add_item_table in includes/context-admin.inc
Add the context table to the page.
ctools_context_ajax_item_add in includes/context-admin.inc
Ajax entry point to add an context

File

includes/context-admin.inc, line 296
includes/common-context.inc Provide API for adding contexts for modules that embed displays.

Code

function ctools_context_add_item_table_buttons($type, $module, &$form, $available_contexts) {
  $form['buttons'] = array(
    '#tree' => TRUE,
  );
  if (!empty($available_contexts)) {
    $type_info = ctools_context_info($type);
    $module = $form['#ctools_context_module'];
    $name = $form['#object_name'];

    // The URL for this ajax button
    $form['buttons'][$type]['add-url'] = array(
      '#attributes' => array(
        'class' => "ctools-{$type}-add-url",
      ),
      '#type' => 'hidden',
      '#value' => url("ctools/context/ajax/add/{$module}/{$type}/{$name}", array(
        'absolute' => TRUE,
      )),
    );

    // This also will be in the URL.
    $form['buttons'][$type]['item'] = array(
      '#attributes' => array(
        'class' => "ctools-{$type}-add-url",
      ),
      '#type' => 'select',
      '#options' => $available_contexts,
    );
    $form['buttons'][$type]['add'] = array(
      '#type' => 'submit',
      '#attributes' => array(
        'class' => 'ctools-use-modal',
      ),
      '#id' => "ctools-{$type}-add",
      '#value' => $type_info['add button'],
    );
  }
}