Exemplo n.º 1
0
/**
 * Implements hook_form_alter().
 */
function eu_projects_theme_form_alter(&$form, &$form_state, $form_id)
{
    // Alters the project search form.
    if ($form_id == 'views_exposed_form' && $form_state['view']->name == 'search_projects' && in_array($form_state['view']->current_display, array('page_1', 'page_2', 'page_3'))) {
        // Replaces the country code by its name.
        include_once DRUPAL_ROOT . '/includes/locale.inc';
        $countries = country_get_list();
        $eu_countries_code = array('BE', 'BG', 'CZ', 'DK', 'DE', 'EE', 'IE', 'GR', 'ES', 'FR', 'HR', 'IT', 'CY', 'LV', 'LT', 'LU', 'HU', 'MT', 'NL', 'AT', 'PL', 'PT', 'RO', 'SI', 'SK', 'FI', 'SE', 'GB');
        $options = $form['project_country']['#options'];
        $eu_countries = array();
        $first = array();
        foreach ($options as $code => $country) {
            if (isset($countries[$code])) {
                if (in_array($options[$code], $eu_countries_code)) {
                    $eu_countries[$code] = $countries[$code];
                    unset($options[$code]);
                } else {
                    $options[$code] = $countries[$code];
                }
            } elseif ($code == 'All') {
                $first[$code] = $country;
                unset($options[$code]);
            }
        }
        asort($options);
        asort($eu_countries);
        $form['project_country']['#options'] = array_merge($first, $eu_countries, $options);
        // Avoids auto complete on the keyword search.
        $form['combine']['#attributes'] = array('class' => array('ctools-auto-submit-exclude'));
    }
}
Exemplo n.º 2
0
/**
 * Form API array definition for site configuration.
 */
function _install_configure_form($form, &$form_state, &$install_state)
{
    include_once DRUPAL_ROOT . '/includes/locale.inc';
    $form['site_information'] = array('#type' => 'fieldset', '#title' => st('Site information'), '#collapsible' => FALSE);
    $form['site_information']['site_name'] = array('#type' => 'textfield', '#title' => st('Site name'), '#required' => TRUE, '#weight' => -20);
    $form['site_information']['site_mail'] = array('#type' => 'textfield', '#title' => st('Site e-mail address'), '#default_value' => ini_get('sendmail_from'), '#description' => st("Automated e-mails, such as registration information, will be sent from this address. Use an address ending in your site's domain to help prevent these e-mails from being flagged as spam."), '#required' => TRUE, '#weight' => -15);
    $form['admin_account'] = array('#type' => 'fieldset', '#title' => st('Site maintenance account'), '#collapsible' => FALSE);
    $form['admin_account']['account']['#tree'] = TRUE;
    $form['admin_account']['account']['name'] = array('#type' => 'textfield', '#title' => st('Username'), '#maxlength' => USERNAME_MAX_LENGTH, '#description' => st('Spaces are allowed; punctuation is not allowed except for periods, hyphens, and underscores.'), '#required' => TRUE, '#weight' => -10, '#attributes' => array('class' => array('username')));
    $form['admin_account']['account']['mail'] = array('#type' => 'textfield', '#title' => st('E-mail address'), '#maxlength' => EMAIL_MAX_LENGTH, '#required' => TRUE, '#weight' => -5);
    $form['admin_account']['account']['pass'] = array('#type' => 'password_confirm', '#required' => TRUE, '#size' => 25, '#weight' => 0);
    $form['server_settings'] = array('#type' => 'fieldset', '#title' => st('Server settings'), '#collapsible' => FALSE);
    $countries = country_get_list();
    $countries = array_merge(array('' => st('No default country')), $countries);
    $form['server_settings']['site_default_country'] = array('#type' => 'select', '#title' => t('Default country'), '#default_value' => variable_get('site_default_country', ''), '#options' => $countries, '#description' => st('Select the default country for the site.'), '#weight' => 0);
    $form['server_settings']['date_default_timezone'] = array('#type' => 'select', '#title' => st('Default time zone'), '#default_value' => date_default_timezone_get(), '#options' => system_time_zones(), '#description' => st('By default, dates in this site will be displayed in the chosen time zone.'), '#weight' => 5, '#attributes' => array('class' => array('timezone-detect')));
    $form['server_settings']['clean_url'] = array('#type' => 'hidden', '#default_value' => 0, '#attributes' => array('class' => array('install')));
    $form['update_notifications'] = array('#type' => 'fieldset', '#title' => st('Update notifications'), '#collapsible' => FALSE);
    $form['update_notifications']['update_status_module'] = array('#type' => 'checkboxes', '#options' => array(1 => st('Check for updates automatically'), 2 => st('Receive e-mail notifications')), '#default_value' => array(1, 2), '#description' => st('The system will notify you when updates and important security releases are available for installed components. Anonymous information about your site is sent to <a href="@drupal">Drupal.org</a>.', array('@drupal' => 'http://drupal.org')), '#weight' => 15);
    $form['submit'] = array('#type' => 'submit', '#value' => st('Save and continue'), '#weight' => 15);
    // Allow the profile to alter this form. $form_state isn't available
    // here, but to conform to the hook_form_alter() signature, we pass
    // an empty array.
    $hook_form_alter = $install_state['parameters']['profile'] . '_form_alter';
    if (function_exists($hook_form_alter)) {
        $hook_form_alter($form, array(), 'install_configure');
    }
    return $form;
}
Exemplo n.º 3
0
/**
 * Form API array definition for site configuration.
 */
function install_configure_form(&$form_state, $url)
{
    include_once DRUPAL_ROOT . '/includes/locale.inc';
    $form['intro'] = array('#markup' => st('To configure your website, please provide the following information.'), '#weight' => -10);
    $form['site_information'] = array('#type' => 'fieldset', '#title' => st('Site information'), '#collapsible' => FALSE);
    $form['site_information']['site_name'] = array('#type' => 'textfield', '#title' => st('Site name'), '#required' => TRUE, '#weight' => -20);
    $form['site_information']['site_mail'] = array('#type' => 'textfield', '#title' => st('Site e-mail address'), '#default_value' => ini_get('sendmail_from'), '#description' => st("The <em>From</em> address in automated e-mails sent during registration and new password requests, and other notifications. (Use an address ending in your site's domain to help prevent this e-mail being flagged as spam.)"), '#required' => TRUE, '#weight' => -15);
    $form['admin_account'] = array('#type' => 'fieldset', '#title' => st('Administrator account'), '#collapsible' => FALSE);
    $form['admin_account']['account']['#tree'] = TRUE;
    $form['admin_account']['markup'] = array('#markup' => '<p class="description">' . st('The administrator account has complete access to the site; it will automatically be granted all permissions and can perform any administrative activity. This will be the only account that can perform certain activities, so keep its credentials safe.') . '</p>', '#weight' => -10);
    $form['admin_account']['account']['name'] = array('#type' => 'textfield', '#title' => st('Username'), '#maxlength' => USERNAME_MAX_LENGTH, '#description' => st('Spaces are allowed; punctuation is not allowed except for periods, hyphens, and underscores.'), '#required' => TRUE, '#weight' => -10, '#attributes' => array('class' => 'username'));
    $form['admin_account']['account']['mail'] = array('#type' => 'textfield', '#title' => st('E-mail address'), '#maxlength' => EMAIL_MAX_LENGTH, '#description' => st('All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail.'), '#required' => TRUE, '#weight' => -5);
    $form['admin_account']['account']['pass'] = array('#type' => 'password_confirm', '#required' => TRUE, '#size' => 25, '#weight' => 0);
    $form['server_settings'] = array('#type' => 'fieldset', '#title' => st('Server settings'), '#collapsible' => FALSE);
    $countries = country_get_list();
    $countries = array_merge(array('' => st('No default country')), $countries);
    $form['server_settings']['site_default_country'] = array('#type' => 'select', '#title' => t('Default country'), '#default_value' => variable_get('site_default_country', ''), '#options' => $countries, '#description' => st('Select the default country for the site.'), '#weight' => 0);
    $form['server_settings']['date_default_timezone'] = array('#type' => 'select', '#title' => st('Default time zone'), '#default_value' => date_default_timezone_get(), '#options' => system_time_zones(), '#description' => st('By default, dates in this site will be displayed in the chosen time zone.'), '#weight' => 5, '#attributes' => array('class' => 'timezone-detect'));
    $form['server_settings']['clean_url'] = array('#type' => 'hidden', '#default_value' => 0, '#attributes' => array('class' => 'install'));
    $form['server_settings']['update_status_module'] = array('#type' => 'checkboxes', '#title' => st('Update notifications'), '#options' => array(1 => st('Check for updates automatically')), '#default_value' => array(1), '#description' => st('With this option enabled, Drupal will notify you when new releases are available. This will significantly enhance your site\'s security and is <strong>highly recommended</strong>. This requires your site to periodically send anonymous information on its installed components to <a href="@drupal">drupal.org</a>. For more information please see the <a href="@update">update notification information</a>.', array('@drupal' => 'http://drupal.org', '@update' => 'http://drupal.org/handbook/modules/update')), '#weight' => 15);
    $form['submit'] = array('#type' => 'submit', '#value' => st('Save and continue'), '#weight' => 15);
    $form['#action'] = $url;
    $form['#redirect'] = FALSE;
    // Allow the profile to alter this form. $form_state isn't available
    // here, but to conform to the hook_form_alter() signature, we pass
    // an empty array.
    $hook_form_alter = $_GET['profile'] . '_form_alter';
    if (function_exists($hook_form_alter)) {
        $hook_form_alter($form, array(), 'install_configure');
    }
    return $form;
}