function tripal_phylogeny_default_plots_form

2.x tripal_phylogeny.admin.inc tripal_phylogeny_default_plots_form($form, &$form_state)
3.x tripal_chado.phylotree.inc tripal_phylogeny_default_plots_form($form, &$form_state)

_state

Parameters

unknown $form:

1 string reference to 'tripal_phylogeny_default_plots_form'
tripal_phylogeny_menu in tripal_phylogeny/tripal_phylogeny.module
Implements hook_menu().

File

tripal_phylogeny/includes/tripal_phylogeny.admin.inc, line 95
This file contains the functions used for administration of the module

Code

function tripal_phylogeny_default_plots_form($form, &$form_state) {
  $form = array();

  $form['plot_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('Plot Settings'),
    '#description' => t('You can customize settings for each plot'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE
  );

  $form['plot_settings']['phylogram_width'] = array(
    '#type' => 'textfield',
    '#title' => 'Tree Width',
    '#description' => 'Please specify the width in pixels for the phylogram',
    '#default_value' => variable_get('tripal_phylogeny_default_phylogram_width', 350),
    '#element_validate' => array(
      'element_validate_integer_positive'
    ),
    '#size' => 5,
  );

  $form['node_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('Node Settings'),
    '#description' => t('You can customize settings for the nodes on the trees.'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE
  );
  $form['node_settings']['root_node_size'] = array(
    '#type' => 'textfield',
    '#title' => 'Root Node Size',
    '#description' => 'Please specify a size for the root node size. If set to zero, the node will not appear.',
    '#default_value' => variable_get('tripal_phylogeny_default_root_node_size', 3),
    '#element_validate' => array(
      'element_validate_integer'
    ),
    '#size' => 3,
  );
  $form['node_settings']['interior_node_size'] = array(
    '#type' => 'textfield',
    '#title' => 'Interor Node Size',
    '#description' => 'Please specify a size for the interior node size. If set to zero, the node will not appear.',
    '#default_value' => variable_get('tripal_phylogeny_default_interior_node_size', 0),
    '#element_validate' => array(
      'element_validate_integer'
    ),
    '#size' => 3,
  );
  $form['node_settings']['leaf_node_size'] = array(
    '#type' => 'textfield',
    '#title' => 'Leaf Node Size',
    '#description' => 'Please specify a size for the leaf node size. If set to zero, the node will not appear.',
    '#default_value' => variable_get('tripal_phylogeny_default_leaf_node_size', 6),
    '#element_validate' => array(
      'element_validate_integer'
    ),
    '#size' => 3,
  );

  // Get the number of organism colors that already exist. If the site admin
  // has set colors then those settings will be in a Drupal variable which we
  // will retrieve.  Otherwise the num_orgs defaults to 1 and a single
  // set of fields is provided.
  $num_orgs = variable_get("tripal_phylogeny_num_orgs", 1);
  if (array_key_exists('values', $form_state) and array_key_exists('num_orgs', $form_state['values'])) {
    $num_orgs = $form_state['values']['num_orgs'];
  }
  // The default values for each organism color are provided in a d
  // Drupal variable that gets set when the form is set.
  $color_defaults = variable_get("tripal_phylogeny_org_colors", array('1' => array('organism' => '', 'color' => '')));

  $form['node_settings']['desc'] = array(
    '#type' => 'item',
    '#title' => t('Node Colors by Organism'),
    '#markup' => t('If the trees are associated with features (e.g. proteins)
      then the nodes can be color-coded by their organism.  This helps the user
      visualize which nodes belong to each organism.  Please enter the
      name of the organism and it\'s corresponding color in HEX code (e.g. #FF0000 == red).
      Organisms that are not given a color will be gray.'),
  );
  $form['node_settings']['org_table']['num_orgs'] = array(
    '#type' => 'value',
    '#value' => $num_orgs,
  );

  // Iterate through the number of organism colors and add a field for each one.
  for ($i = 0; $i < $num_orgs; $i++) {
    $form['node_settings']['org_table']['organism_' . $i] = array(
      '#type' => 'textfield',
      '#default_value' => array_key_exists($i, $color_defaults) ? $color_defaults[$i]['organism'] : '',
      '#autocomplete_path' => "admin/tripal/chado/tripal_organism/organism/auto_name",
      '#description' => t('Please enter the name of the organism.'),
      '#size' => 30,
    );
    $form['node_settings']['org_table']['color_' . $i] = array(
      '#type' => 'textfield',
      '#description' => t('Please provide a color in Hex format (e.g. #FF0000).'),
      '#default_value' => array_key_exists($i, $color_defaults) ? $color_defaults[$i]['color'] : '',
      '#suffix' => "<div id=\"color-box-$i\" style=\"width: 30px;\"></div>",
      '#size' => 10,
    );
  }
  $form['node_settings']['org_table']['add'] = array(
    '#type' => 'submit',
    '#name' => 'add',
    '#value' => 'Add',
    '#ajax' => array(
      'callback' => "tripal_phylogeny_default_plots_form_ajax_callback",
      'wrapper' => 'tripal_phylogeny_default_plots_form',
      'effect' => 'fade',
      'method' => 'replace',
    ),
  );
  $form['node_settings']['org_table']['remove'] = array(
    '#type' => 'submit',
    '#name' => 'remove',
    '#value' => 'Remove',
    '#ajax' => array(
      'callback' => "tripal_phylogeny_default_plots_form_ajax_callback",
      'wrapper' => 'tripal_phylogeny_default_plots_form',
      'effect' => 'fade',
      'method' => 'replace',
    ),
  );
  $form['node_settings']['org_table']['#theme'] = 'tripal_phylogeny_admin_org_color_tables';
  $form['node_settings']['org_table']['#prefix'] = '<div id="tripal_phylogeny_default_plots_form">';
  $form['node_settings']['org_table']['#suffix'] = '</div>';

  $form['submit'] = array(
    '#type' => 'submit',
    '#name' => 'submit',
    '#value' => 'Save Configuration',
  );

  $form['#submit'][] = 'tripal_phylogeny_default_plots_form_submit';

  return $form;
}