function chado_add_admin_form_set_url

2.x chado_add_admin_form_set_url(&$form, &$form_state, $details)

Generic "Set Node URL" sub-form for setting the url of any chado node


$form: The Drupal form array into which the property form elements will be added

$form_state: The corresponding form_state array for the form

$details: An array defining details used by this form. Required keys that are always required: -module: the name of the module implementing the node. For example, for features the module is tripal_feature. -options: an array of quick-choice options to supply to the user. The key should be the token and the value should be a human-readable description of the option Optional keys include: -content_type: the name of the content type. Defaults to module name. -fieldset_title: the title to use for the fieldset. Defaults to "Set Page url". -default_option: the default format to use which matches one of those in $details['options'] -custom_tokens: an array of custom tokens that follow the same format as those generated by chado_node_generate_tokens().

Related topics

9 calls to chado_add_admin_form_set_url()
tripal_analysis_admin in tripal_analysis/includes/
Administration page callbacks for the Tripal Analysis module
tripal_contact_admin in tripal_contact/includes/
Administrative settings form
tripal_featuremap_admin in tripal_featuremap/includes/
Administrative settings form
tripal_feature_admin in tripal_feature/includes/
Feature Settings page
tripal_library_admin in tripal_library/includes/
Administrative settings form

... See full list


tripal_core/api/, line 763
Contains API functions to set titles and paths for all chado nodes


function chado_add_admin_form_set_url(&$form, &$form_state, $details) {

  // Get Node Info
  if (isset($details['module'])) {
    $node_info = call_user_func($details['module'] . '_node_info');
    $chado_node_api = $node_info[$details['content_type']]['chado_node_api'];
  else {
    "Set URL API: When calling chado_add_admin_form_set_url, you \$details array must include 'module' => [name of your module] in order to pull out all the information provided in your implementation of hook_node_info"

  // Defaults
  $details['fieldset_title'] = (isset($details['fieldset_title'])) ? $details['fieldset_title'] : 'Set Page URLs';
  $details['additional_instructions'] = (isset($details['additional_instructions'])) ? $details['additional_instructions'] : '';
  $details['custom_tokens'] = (isset($details['custom_tokens'])) ? $details['custom_tokens'] : array();
  $details['content_type'] = (isset($details['content_type'])) ? $details['content_type'] : $details['module'];

  $tokens = array();
  if (empty($tokens)) {
    $tokens = chado_node_generate_tokens($chado_node_api['base_table']);
  $tokens = array_merge($tokens, $details['custom_tokens']);
  $token_list = chado_node_format_tokens($tokens);
  $current_format = chado_node_get_url_format($details['content_type'], $tokens);
  $details['default_option'] = (isset($details['default_option'])) ? $details['default_option'] : $current_format;

  $msg = t(
  'Each synced %singular must have a unique page URL, however, %plural may have the
      same name if they are of different types or from different organisms. Therefore,
      we must be sure that the page URLs can uniquely identify the %singular being viewed.
      Select an option below that will uniquely identify all %plural on your site.'
    . $details['additional_instructions'], 
  array('%singular' => $chado_node_api['record_type_title']['singular'],
    '%plural' => $chado_node_api['record_type_title']['plural'])
  $form['set_url'] = array(
    '#type' => 'fieldset',
    '#title' => t($details['fieldset_title']),
    '#description' => $msg,
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#prefix' => "<div id='set_url-fieldset'>",
    '#suffix' => '</div>',

  $form['set_url']['content_type'] = array(
    '#type' => 'hidden',
    '#value' => $node_info[$details['content_type']]['base'],

  $details['options']['custom'] = 'Custom: See the text field below.';

  $form['set_url']['url_option'] = array(
    '#title' => t('%singular Page URL', array('%singular' => $chado_node_api['record_type_title']['singular'])),
    '#type' => 'radios',
    '#description' => t("Choose a URL type from the list above that is
      guaranteed to be unique for all %plural. If in doubt it is safest to choose
      the 'Unique Constaint' option as that guarantees uniqueness.", 
    array('%plural' => $chado_node_api['record_type_title']['plural'])),
    '#required' => FALSE,
    '#options' => $details['options'],
    '#default_value' => (isset($details['options'][$details['default_option']])) ? $details['default_option'] : 'custom',

  $form['set_url']['url_format_variable'] = array(
    '#type' => 'hidden',
    '#value' => $details['module'] . '_url_format'

  $form['set_url']['custom_url'] = array(
    '#type' => 'textarea',
    '#title' => 'Custom Page URL',
    '#description' => 'You may rearrange elements in this text box to customize the page
      URLs. The available tokens are listed below. You can separate or include any text
      between the tokens. <strong>Important: be sure that whatever you choose
      will always be unique even considering future data that may be added. If in doubt,
      please select the unique constraint title option above.</strong>',
    '#default_value' => $current_format,
    '#rows' => 1

  $form['set_url']['token_display'] = array(
    '#type' => 'fieldset',
    '#title' => 'Available Tokens',
    '#description' => 'Copy the token and paste it into the "Custom Page URL" text field above.',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE

  $form['set_url']['token_display']['content'] = array(
    '#type' => 'item',
    '#markup' => $token_list

  $form['set_url']['tokens'] = array(
    '#type' => 'hidden',
    '#value' => serialize($tokens)

  $form['set_url']['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Set URLs',
    '#validate' => array('chado_add_admin_form_set_url_form_validate'),
    '#submit' => array('chado_add_admin_form_set_url_form_submit')