addressfield_tokens.admin.inc 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. // $Id$
  3. /*
  4. * Copyright © 2012 New Signature
  5. *
  6. * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  7. * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  8. * You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
  9. * You can contact New Signature by electronic mail at labs@newsignature.com -or- by U.S. Postal Service at 1100 H St. NW, Suite 940, Washington, DC 20005.
  10. */
  11. /**
  12. * @file Provides an Administrative UI for the addressfield_tokens module.
  13. */
  14. /**
  15. * Provides a form for configuring regional options for addresses.
  16. *
  17. * @param array $form
  18. * @param array $form_state
  19. * @return array The form.
  20. */
  21. function addressfield_tokens_admin_form($form, &$form_state) {
  22. $options = array('' => t('- None -')) + _addressfield_tokens_countries();
  23. $form['addressfield_tokens_default_country'] = array(
  24. '#type' => 'select',
  25. '#title' => t('Default country'),
  26. '#description' => t('In the city/state views, addresses in this country will not display the country.'),
  27. '#options' => $options,
  28. '#default_value' => addressfield_tokens_default_country(),
  29. );
  30. $form['addressfield_tokens_property_names'] = array(
  31. '#type' => 'fieldset',
  32. '#title' => t('Custom address property names'),
  33. '#description' => t('Change the names of address fields when selecting tokens.'),
  34. '#collapsible' => TRUE,
  35. '#collapsed' => FALSE,
  36. '#tree' => TRUE,
  37. );
  38. $names = addressfield_tokens_property_names();
  39. $props = addressfield_data_property_info();
  40. foreach ($props as $name => $prop) {
  41. $form['addressfield_tokens_property_names'][$name] = array(
  42. '#type' => 'textfield',
  43. '#title' => $prop['label'],
  44. '#description' => $name,
  45. '#default_value' => !empty($names[$name]) ? $names[$name] : $prop['label'],
  46. );
  47. }
  48. return system_settings_form($form);
  49. }