function tripal_core_content_type_toc_form

2.x tripal_core.toc.inc tripal_core_content_type_toc_form($form, &$form_state, $content_type)
3.x tripal_core.toc.inc tripal_core_content_type_toc_form($form, &$form_state, $content_type)
10 string references to 'tripal_core_content_type_toc_form'
tripal_analysis_menu in tripal_analysis/tripal_analysis.module
Implementation of hook_menu(). Entry points and paths of the module
tripal_contact_menu in tripal_contact/tripal_contact.module
Implemets hook_menu(). Adds menu items for the tripal_contact module menu. This section gives the outline for the main menu of the Tripal-contact module
tripal_example_menu in tripal_example/tripal_example.module
Implements hook_menu()
tripal_featuremap_menu in tripal_featuremap/tripal_featuremap.module
Implements hook_menu().
tripal_feature_menu in tripal_feature/tripal_feature.module
Implements hook_menu().

... See full list

File

tripal_core/includes/tripal_core.toc.inc, line 648

Code

function tripal_core_content_type_toc_form($form, &$form_state, $content_type) {

  // Get the type details
  $all_types = node_type_get_types();
  $type_info = $all_types[$content_type];

  $form["#tree"] = TRUE;

  // Get a single node of this type so we can get all the possible content
  // for it.
  $sql = "SELECT nid FROM {node} WHERE type = :type LIMIT 1 OFFSET 0";
  $nid = db_query($sql, array(':type' => $content_type))->fetchField();
  if (!$nid) {
    $form["not_available"] = array(
      '#markup' => t('Please sync at least one %type_name record. A node
          must exist before customizations to the Table of Contents (TOC) can
          be performed.', array('%type_name' => $type_info->name)),
    );
    return $form;
  }

  // Load the node
  $node = node_load($nid);

  // Get the content array for this node, then pass it through the
  // tripal_core_node_view_alter which generates the TOC.  After that
  // we can use the $build array to build the form. We have to add
  // a 'tripal_toc_mode' to the $node because we need to give the mode
  // to the tripal_core_node_view_build_toc function.
  $node->tripal_toc_mode = 'manage_type';

  node_build_content($node);
  $build = $node->content;
  $build["#node"] = $node;
  tripal_core_node_view_alter($build);

  $form["instructions"] = array(
    '#type' => 'fieldset',
    '#collapsed' => TRUE,
    '#collapsible' => TRUE,
    '#title' => 'Instructions',
  );
  $form["instructions"]["main"] = array(
    '#markup' => '</p>' . t('Below is a list of the titles of
      content panes that can appear on all %type_name pages.  You may rename
      the titles or drag and drop them to change the order.  Content that appears
      only on a single page can not be ordered here, but must be ordered using
      the TOC tab on the page itself.  If a page has customized TOC settings
      then those settings will take precedent over these.', 
    array('%type_name' => $type_info->name)) . '</p>' .
      '<p>' . t('The list below shows all possible content
      panes that can appear. However, those without content are automatically
      hidden and do not appear in the TOC.' . '</p>'),
  );

  $form['content_type'] = array(
    '#type' => 'value',
    '#value' => $content_type,
  );

  // Iterate through the built items and add form elemetns for each one.
  foreach (element_children($build) as $key) {
    $element = $build[$key];

    if (array_key_exists('#tripal_toc_id', $element)) {
      $toc_id = $element['#tripal_toc_id'];
      $toc_title = $element['#tripal_toc_title'];
      $toc_weight = $element['#weight'];
      $toc_hide = $element['#hide'];
      $form['toc_items'][$toc_id]['title'] = array(
        '#type' => 'textfield',
        '#default_value' => $toc_title,
      );
      $form['toc_items'][$toc_id]['hide'] = array(
        '#type' => 'checkbox',
        '#default_value' => $toc_hide,
      );
      $form['toc_items'][$toc_id]['weight'] = array(
        '#type' => 'textfield',
        '#default_value' => $toc_weight,
        '#attributes' => array(
          'class' => array('tripal-node-toc-items-weights'),
        ),
        '#size' => 5,
      );
    }
  }
  $form['toc_items']['#theme'] = 'tripal_node_toc_items_table';

  $form['submit'] = array(
    '#type' => 'submit',
    '#name' => 'toc_submit',
    '#value' => t('Submit'),
  );
  $form['unset'] = array(
    '#type' => 'submit',
    '#name' => 'toc_unset',
    '#value' => t('Reset to Defaults'),
  );

  return $form;
}