コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $cart_config = $this->config('uc_cart.settings');
     $form['cart-settings'] = array('#type' => 'vertical_tabs', '#attached' => array('library' => array('uc_cart/uc_cart.admin.scripts')));
     $form['general'] = array('#type' => 'details', '#title' => t('Basic settings'), '#group' => 'cart-settings');
     $form['general']['uc_cart_add_item_msg'] = array('#type' => 'checkbox', '#title' => t('Display a message when a customer adds an item to their cart.'), '#default_value' => $cart_config->get('add_item_msg'));
     $form['general']['uc_add_item_redirect'] = array('#type' => 'textfield', '#title' => t('Add to cart redirect'), '#description' => t('Enter the page to redirect to when a customer adds an item to their cart, or &lt;none&gt; for no redirect.'), '#default_value' => $cart_config->get('add_item_redirect'), '#size' => 32, '#field_prefix' => $this->url('<front>', [], ['absolute' => TRUE]));
     $form['general']['uc_cart_empty_button'] = array('#type' => 'checkbox', '#title' => t('Show an "Empty cart" button on the cart page.'), '#default_value' => $cart_config->get('empty_button'));
     $form['general']['uc_minimum_subtotal'] = array('#type' => 'uc_price', '#title' => t('Minimum order subtotal'), '#description' => t('Customers will not be allowed to check out if the subtotal of items in their cart is less than this amount.'), '#default_value' => $cart_config->get('minimum_subtotal'));
     $form['lifetime'] = array('#type' => 'details', '#title' => t('Cart lifetime'), '#description' => t('Set the length of time that products remain in the cart. Cron must be running for this feature to work.'), '#group' => 'cart-settings');
     $range = range(1, 60);
     $form['lifetime']['anonymous'] = array('#type' => 'fieldset', '#title' => t('Anonymous users'), '#attributes' => array('class' => array('uc-inline-form', 'clearfix')));
     $form['lifetime']['anonymous']['uc_cart_anon_duration'] = array('#type' => 'select', '#title' => t('Duration'), '#options' => array_combine($range, $range), '#default_value' => $cart_config->get('anon_duration'));
     $form['lifetime']['anonymous']['uc_cart_anon_unit'] = array('#type' => 'select', '#title' => t('Units'), '#options' => array('minutes' => t('Minute(s)'), 'hours' => t('Hour(s)'), 'days' => t('Day(s)'), 'weeks' => t('Week(s)'), 'years' => t('Year(s)')), '#default_value' => $cart_config->get('anon_unit'));
     $form['lifetime']['authenticated'] = array('#type' => 'fieldset', '#title' => t('Authenticated users'), '#attributes' => array('class' => array('uc-inline-form', 'clearfix')));
     $form['lifetime']['authenticated']['uc_cart_auth_duration'] = array('#type' => 'select', '#title' => t('Duration'), '#options' => array_combine($range, $range), '#default_value' => $cart_config->get('auth_duration'));
     $form['lifetime']['authenticated']['uc_cart_auth_unit'] = array('#type' => 'select', '#title' => t('Units'), '#options' => array('hours' => t('Hour(s)'), 'days' => t('Day(s)'), 'weeks' => t('Week(s)'), 'years' => t('Year(s)')), '#default_value' => $cart_config->get('auth_unit'));
     $form['continue_shopping'] = array('#type' => 'details', '#title' => t('Continue shopping element'), '#description' => t('These settings control the <em>continue shopping</em> option on the cart page.'), '#group' => 'cart-settings');
     $form['continue_shopping']['uc_continue_shopping_type'] = array('#type' => 'radios', '#title' => t('<em>Continue shopping</em> element'), '#options' => array('link' => t('Text link'), 'button' => t('Button'), 'none' => t('Do not display')), '#default_value' => $cart_config->get('continue_shopping_type'));
     $form['continue_shopping']['uc_continue_shopping_use_last_url'] = array('#type' => 'checkbox', '#title' => t('Make <em>continue shopping</em> go back to the last item that was added to the cart.'), '#description' => t('If this is disabled or the item is unavailable, the URL specified below will be used.'), '#default_value' => $cart_config->get('continue_shopping_use_last_url'));
     $form['continue_shopping']['uc_continue_shopping_url'] = array('#type' => 'textfield', '#title' => t('Default <em>continue shopping</em> destination'), '#default_value' => $cart_config->get('continue_shopping_url'), '#size' => 32, '#field_prefix' => $this->url('<front>', [], ['absolute' => TRUE]));
     $form['breadcrumb'] = array('#type' => 'details', '#title' => t('Cart breadcrumb'), '#description' => t('Drupal automatically adds a <em>Home</em> breadcrumb to the cart page, or you can use these settings to specify a custom breadcrumb.'), '#group' => 'cart-settings');
     $form['breadcrumb']['uc_cart_breadcrumb_text'] = array('#type' => 'textfield', '#title' => t('Cart page breadcrumb text'), '#description' => t('Leave blank to use the default <em>Home</em> breadcrumb.'), '#default_value' => $cart_config->get('breadcrumb_text'));
     $form['breadcrumb']['uc_cart_breadcrumb_url'] = array('#type' => 'textfield', '#title' => t('Cart page breadcrumb destination'), '#default_value' => $cart_config->get('breadcrumb_url'), '#size' => 32, '#field_prefix' => $this->url('<front>', [], ['absolute' => TRUE]));
     return parent::buildForm($form, $form_state);
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, Request $request = NULL)
 {
     $config = $this->config('easychart.settings');
     $load_defaults = FALSE;
     // Get defaults.
     foreach ($this->getDefaults() as $default) {
         // Verify default options.
         $default_value = $config->get($default);
         if (empty($default_value)) {
             // Set flag to true.
             $load_defaults = TRUE;
             $form['#attached']['drupalSettings']['easychart'][$default] = TRUE;
         }
     }
     if ($load_defaults) {
         $form['#attached']['library'][] = 'easychart/easychart.defaults';
         $form['#attached']['library'][] = 'easychart/lib.easycharts.full';
     }
     $options = $config->get('options');
     $form['options'] = ['#type' => 'textarea', '#title' => $this->t('Available options'), '#description' => $this->t('These Highcharts options will be configurable in the Easychart interface when creating/editing a chart. See <a href="@url" target="_blank">http://api.highcharts.com/highcharts</a> for all available options.', array('@url' => Url::fromUri('http://api.highcharts.com/highcharts')->toUriString())), '#default_value' => $options, '#attributes' => array('class' => array('easychart-options')), '#rows' => 15];
     $form['templates'] = ['#type' => 'textarea', '#title' => t('Available templates'), '#default_value' => $config->get('templates'), '#description' => t("These templates will be selectable in the Easychart interface when creating/editing a chart."), '#attributes' => array('class' => array('easychart-templates')), '#rows' => 15];
     $form['presets'] = ['#type' => 'textarea', '#title' => t('Presets'), '#default_value' => $config->get('presets'), '#description' => $this->t('Presets for every Easychart chart. If these preset are also mentioned in the available options, they will be shown, but not editable.'), '#attributes' => array('class' => array('easychart-presets')), '#rows' => 10];
     $interval = array(3600, 10800, 21600, 32400, 43200, 86400, 172800);
     $form['url_update_frequency'] = ['#type' => 'select', '#title' => t('Update frequency'), '#options' => array(0 => t('Never')) + array_map([\Drupal::service('date.formatter'), 'formatInterval'], array_combine($interval, $interval)), '#default_value' => $config->get('url_update_frequency'), '#description' => $this->t('When to update the data for charts using a CSV URL.'), '#rows' => 10];
     $form['actions']['reset'] = ['#type' => 'submit', '#value' => t('Reset to defaults'), '#submit' => array('::resetForm'), '#limit_validation_errors' => array(), '#weight' => 100];
     return parent::buildForm($form, $form_state);
 }
コード例 #3
0
ファイル: SettingsForm.php プロジェクト: DrupalTV/DrupalTV
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $form = parent::buildForm($form, $form_state);
     $config = $this->config('rules_test_ui_embed.settings');
     $form['css_file'] = ['#type' => 'textfield', '#title' => $this->t('CSS file'), '#default_value' => $config->get('css.0.file'), '#required' => TRUE];
     return $form;
 }
コード例 #4
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $config = $this->config('system.maintenance');
     $form['maintenance_mode'] = array('#type' => 'checkbox', '#title' => t('Put site into maintenance mode'), '#default_value' => $this->state->get('system.maintenance_mode'), '#description' => t('Visitors will only see the maintenance mode message. Only users with the "Access site in maintenance mode" <a href=":permissions-url">permission</a> will be able to access the site. Authorized users can log in directly via the <a href=":user-login">user login</a> page.', array(':permissions-url' => $this->url('user.admin_permissions'), ':user-login' => $this->url('user.login'))));
     $form['maintenance_mode_message'] = array('#type' => 'textarea', '#title' => t('Message to display when in maintenance mode'), '#default_value' => $config->get('message'));
     return parent::buildForm($form, $form_state);
 }
コード例 #5
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $config = $this->config('c4a_connect.fbconnectadmin_config');
     $form['application_id'] = array('#type' => 'textfield', '#title' => $this->t('Application ID'), '#description' => $this->t('Also called the <em>OAuth client_id</em> value on Facebook App settings pages. <a href="https://www.facebook.com/developers/createapp.php">Facebook Apps must first be created</a> before they can be added here'), '#default_value' => $config->get('application_id'));
     $form['application_secret'] = array('#type' => 'textfield', '#title' => $this->t('Application secret'), '#description' => $this->t('Also called the <em>OAuth client_secret</em> value on Facebook App settings pages.'), '#default_value' => $config->get('application_secret'));
     return parent::buildForm($form, $form_state);
 }
コード例 #6
0
ファイル: DemoForm.php プロジェクト: louhichi/d8-demo-modules
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $config = $this->config('event_dispatcher_demo.demo_form_config');
     $form['my_name'] = ['#type' => 'textfield', '#title' => $this->t('My name'), '#default_value' => $config->get('my_name')];
     $form['my_website'] = ['#type' => 'textfield', '#title' => $this->t('My website'), '#default_value' => $config->get('my_website')];
     return parent::buildForm($form, $form_state);
 }
コード例 #7
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $config = $this->config('mymodules.mysettings_config');
     $form['nom'] = array('#type' => 'textfield', '#title' => $this->t('nom'), '#description' => $this->t('tapez votre nom'), '#default_value' => $config->get('nom'));
     $form['pr_nom'] = array('#type' => 'textfield', '#title' => $this->t('prénom'), '#description' => $this->t(''), '#default_value' => $config->get('pr_nom'));
     return parent::buildForm($form, $form_state);
 }
コード例 #8
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $form = array();
     // Initialize a language list to the ones available, including English.
     $languages = $this->languageManager->getLanguages();
     $existing_languages = array();
     foreach ($languages as $langcode => $language) {
         $existing_languages[$langcode] = $language->getName();
     }
     // If we have no languages available, present the list of predefined languages
     // only. If we do have already added languages, set up two option groups with
     // the list of existing and then predefined languages.
     if (empty($existing_languages)) {
         $language_options = $this->languageManager->getStandardLanguageListWithoutConfigured();
     } else {
         $language_options = array($this->t('Existing languages') => $existing_languages, $this->t('Languages not yet added') => $this->languageManager->getStandardLanguageListWithoutConfigured());
     }
     $form['mappings'] = array('#tree' => TRUE, '#theme' => 'language_negotiation_configure_browser_form_table');
     $mappings = $this->language_get_browser_drupal_langcode_mappings();
     foreach ($mappings as $browser_langcode => $drupal_langcode) {
         $form['mappings'][$browser_langcode] = array('browser_langcode' => array('#title' => $this->t('Browser language code'), '#title_display' => 'invisible', '#type' => 'textfield', '#default_value' => $browser_langcode, '#size' => 20, '#required' => TRUE), 'drupal_langcode' => array('#title' => $this->t('Site language'), '#title_display' => 'invisible', '#type' => 'select', '#options' => $language_options, '#default_value' => $drupal_langcode, '#required' => TRUE));
     }
     // Add empty row.
     $form['new_mapping'] = array('#type' => 'details', '#title' => $this->t('Add a new mapping'), '#tree' => TRUE);
     $form['new_mapping']['browser_langcode'] = array('#type' => 'textfield', '#title' => $this->t('Browser language code'), '#description' => $this->t('Use language codes as <a href="@w3ctags">defined by the W3C</a> for interoperability. <em>Examples: "en", "en-gb" and "zh-hant".</em>', array('@w3ctags' => 'http://www.w3.org/International/articles/language-tags/')), '#size' => 20);
     $form['new_mapping']['drupal_langcode'] = array('#type' => 'select', '#title' => $this->t('Site language'), '#options' => $language_options);
     return parent::buildForm($form, $form_state);
 }
コード例 #9
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $config = $this->config('google_site_search.settings');
     $form['google_site_search_key'] = ['#type' => 'textfield', '#title' => $this->t('Google site search key'), '#description' => $this->t('Google Site Search Key'), '#maxlength' => 64, '#size' => 64, '#default_value' => $config->get('google_site_search_key')];
     $form['google_site_search_index'] = ['#type' => 'textfield', '#title' => $this->t('Google Site Search Index'), '#description' => $this->t('Google Site Search Index'), '#maxlength' => 64, '#size' => 64, '#default_value' => $config->get('google_site_search_index')];
     return parent::buildForm($form, $form_state);
 }
コード例 #10
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $config = $this->config('better_formats.settings');
     $form['control'] = ['#type' => 'fieldset', '#title' => t('Control')];
     $form['control']['per_field_core'] = ['#type' => 'checkbox', '#title' => t('Use field default'), '#description' => t('Use the core field module default value to set the default format. This will force the default format even when the default field value is empty. To set a default format you must re-edit a text field after saving it with the "Filtered text" option turned on.'), '#default_value' => $config->get('per_field_core')];
     return parent::buildForm($form, $form_state);
 }
コード例 #11
0
 /**
  * Form constructor.
  *
  * @param array $form
  *   An associative array containing the structure of the form.
  * @param array $form_state
  *   An associative array containing the current state of the form.
  *
  * @return array
  *   The form structure.
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     global $base_url;
     $config = $this->config('login_security.settings');
     $form['track_time'] = array('#type' => 'number', '#min' => 0, '#title' => $this->t('Track time'), '#default_value' => $config->get('track_time'), '#size' => 3, '#description' => $this->t('The time window to check for security violations: the time in hours the login information is kept to compute the login attempts count. A common example could be 24 hours. After that time, the attempt is deleted from the list, and will never be considered again.'), '#field_suffix' => $this->t('Hours'));
     $form['user_wrong_count'] = array('#type' => 'number', '#min' => 0, '#title' => $this->t('Maximum number of login failures before blocking a user'), '#default_value' => $config->get('user_wrong_count'), '#size' => 3, '#description' => $this->t('Enter the number of login failures a user is allowed. After this amount is reached, the user will be blocked, no matter the host attempting to log in. Use this option carefully on public sites, as an attacker may block your site users. The user blocking protection will not disappear and should be removed manually from the <a href=":user">user management</a> interface.', array(':user' => $base_url . '/admin/people')), '#field_suffix' => $this->t('Failed attempts'));
     $form['host_wrong_count'] = array('#type' => 'number', '#min' => 0, '#title' => $this->t('Maximum number of login failures before soft blocking a host'), '#default_value' => $config->get('host_wrong_count'), '#size' => 3, '#description' => $this->t('Enter the number of login failures a host is allowed. After this amount is reached, the host will not be able to submit the log in form again, but can still browse the site contents as an anonymous user. This protection is effective during the time indicated at tracking time option.'), '#field_suffix' => $this->t('Failed attempts'));
     $form['host_wrong_count_hard'] = array('#type' => 'number', '#min' => 0, '#title' => $this->t('Maximum number of login failures before blocking a host'), '#default_value' => $config->get('host_wrong_count_hard'), '#size' => 3, '#description' => $this->t('Enter the number of login failures a host is allowed. After this number is reached, the host will be blocked, no matter the username attempting to log in. The host blocking protection will not disappear automatically and should be removed manually from the <a href=":access">access rules</a> administration interface.', array(':access' => $base_url . '/admin/config/people/ban')), '#field_suffix' => $this->t('Failed attempts'));
     $form['activity_threshold'] = array('#type' => 'number', '#min' => 0, '#title' => $this->t('Maximum number of login failures before detecting an ongoing attack'), '#default_value' => $config->get('activity_threshold'), '#size' => 3, '#description' => $this->t('Enter the number of login failures before creating a warning log entry about this suspicious activity. If the number of invalid login events currently being tracked reach this number, and ongoing attack is detected.'), '#field_suffix' => $this->t('Failed attempts'));
     $form['login_messages'] = array('#type' => 'fieldset', '#title' => $this->t('Notifications'));
     $form['login_messages']['disable_core_login_error'] = array('#type' => 'checkbox', '#title' => $this->t('Disable login failure error message'), '#description' => $this->t('Checking this option prevents the display of login error messages. A user attempting to login will not be aware if the account exists, an invalid user name or password has been submitted, or if the account is blocked. The core messages "Unrecognized username or password. Have you forgotten your password?" and "The username {username} has not been activated or is blocked." are also hidden.'), '#default_value' => $config->get('disable_core_login_error'));
     $form['login_messages']['notice_attempts_available'] = array('#type' => 'checkbox', '#title' => $this->t('Notify the user about the number of remaining login attempts'), '#default_value' => $config->get('notice_attempts_available'), '#description' => $this->t('Checking this option, the user is notified about the number of remaining login attempts before the account gets blocked. Security tip: If you enable this option, try to not disclose as much of your login policies as possible in the message shown on any failed login attempt.'));
     $form['login_messages']['last_login_timestamp'] = array('#type' => 'checkbox', '#title' => $this->t('Display last login timestamp'), '#description' => $this->t('Checking this option, when a user successfully logs in, a message will display the last time he logged into the site.'), '#default_value' => $config->get('last_login_timestamp'));
     $form['login_messages']['last_access_timestamp'] = array('#type' => 'checkbox', '#title' => $this->t('Display last access timestamp'), '#description' => $this->t('Checking this option, when a user successfully logs in, a message will display the last site access with this account.'), '#default_value' => $config->get('last_access_timestamp'));
     $form['login_messages']['user_blocked_email_user'] = array('#type' => 'textfield', '#title' => $this->t('Select who should get an email message when a user is blocked by this module'), '#description' => $this->t('No notification will be sent if the field is blank'), '#default_value' => $config->get('user_blocked_email_user'), '#autocomplete_path' => 'user/autocomplete', '#element_validate' => array(array(get_class($this), 'validUser')));
     $form['login_messages']['login_activity_email_user'] = array('#type' => 'textfield', '#title' => $this->t('Select who should get an email message when an ongoing attack is detected'), '#description' => $this->t('No notification will be sent if the field is blank'), '#default_value' => $config->get('login_activity_email_user'), '#autocomplete_path' => 'user/autocomplete', '#element_validate' => array(array(get_class($this), 'validUser')));
     $form['login_security']['Notifications'] = array('#type' => 'fieldset', '#title' => $this->t('Edit notification texts'), '#weight' => 3, '#collapsible' => TRUE, '#collapsed' => TRUE, '#description' => t("You may edit the notifications used by the Login Security module. Allowed placeholders for all the notifications include the following: <ul><li>%date                  :  The (formatted) date and time of the event.</li><li>%ip                    :  The IP address tracked for this event.</li><li>%username              :  The username entered in the login form (sanitized).</li><li>%email                 :  If the user exists, this will be the email address.</li><li>%uid                   :  If the user exists, this will be the user uid.</li><li>%site                  :  The name of the site as configured in the administration.</li><li>%uri                   :  The base url of this Drupal site.</li><li>%edit_uri              :  Direct link to the user (based on the name entered) edit page.</li><li>%hard_block_attempts   :  Configured maximum attempts before hard blocking the IP address.</li><li>%soft_block_attempts   :  Configured maximum attempts before soft blocking the IP address.</li><li>%user_block_attempts   :  Configured maximum login attempts before blocking the user.</li><li>%user_ip_current_count :  The total attempts for this user name tracked from this IP address.</li><li>%ip_current_count      :  The total login attempts tracked from from this IP address.</li><li>%user_current_count    :  The total login attempts tracked for this user name .</li><li>%tracking_time         :  The tracking time value: in hours.</li><li>%tracking_current_count:  Total tracked events</li><li>%activity_threshold    :  Value of attempts to detect ongoing attack.</li></ul>"));
     $form['login_security']['Notifications']['notice_attempts_message'] = array('#type' => 'textarea', '#title' => $this->t('Message to be shown on each failed login attempt'), '#rows' => 2, '#default_value' => $config->get('notice_attempts_message'), '#description' => $this->t('Enter the message string to be shown if the login fails after the form is submitted. You can use any of the placeholders here.'));
     $form['login_security']['Notifications']['host_soft_banned'] = array('#type' => 'textarea', '#title' => $this->t('Message for banned host (Soft IP ban)'), '#rows' => 2, '#default_value' => $config->get('host_soft_banned'), '#description' => $this->t('Enter the soft IP ban message to be shown when a host attempts to log in too many times.'));
     $form['login_security']['Notifications']['host_hard_banned'] = array('#type' => 'textarea', '#rows' => 2, '#title' => $this->t('Message for banned host (Hard IP ban)'), '#default_value' => $config->get('host_hard_banned'), '#description' => $this->t('Enter the hard IP ban message to be shown when a host attempts to log in too many times.'));
     $form['login_security']['Notifications']['user_blocked'] = array('#type' => 'textarea', '#rows' => 2, '#title' => $this->t('Message when user is blocked by uid'), '#default_value' => $config->get('user_blocked'), '#description' => $this->t('Enter the message to be shown when a user gets blocked due to enough failed login attempts.'));
     $form['login_security']['Notifications']['user_block_email'] = array('#type' => 'fieldset', '#title' => $this->t('Email to be sent to the defined user for blocked accounts.'), '#weight' => 3, '#description' => $this->t('Configure the subject and body of the email message.'));
     $form['login_security']['Notifications']['user_block_email']['user_blocked_email_subject'] = array('#type' => 'textfield', '#title' => $this->t('Email subject'), '#default_value' => $config->get('user_blocked_email_subject'));
     $form['login_security']['Notifications']['user_block_email']['user_blocked_email_body'] = array('#type' => 'textarea', '#title' => $this->t('Email body'), '#default_value' => $config->get('user_blocked_email_body'), '#description' => $this->t('Enter the message to be sent to the administrator informing a user has been blocked.'));
     $form['login_security']['Notifications']['login_activity_email'] = array('#type' => 'fieldset', '#title' => $this->t('Email to be sent to the defined user for ongoing attack detections.'), '#weight' => 3, '#description' => $this->t('Configure the subject and body of the email message.'));
     $form['login_security']['Notifications']['login_activity_email']['login_activity_email_subject'] = array('#type' => 'textfield', '#title' => $this->t('Email subject'), '#default_value' => $config->get('login_activity_email_subject'));
     $form['login_security']['Notifications']['login_activity_email']['login_activity_email_body'] = array('#type' => 'textarea', '#title' => $this->t('Email body'), '#default_value' => $config->get('login_activity_email_body'), '#description' => $this->t('Enter the message to be sent to the administrator informing about supicious activity.'));
     // Clean event tracking list.
     $form['buttons']['clean_tracked_events'] = array('#type' => 'submit', '#value' => $this->t('Clear event tracking information'), '#weight' => 20, '#submit' => array('::clean_tracked_events'));
     return parent::buildForm($form, $form_state);
 }
コード例 #12
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, Request $request = NULL)
 {
     MollomUtilities::displayMollomTestModeWarning();
     $config = $this->config('mollom.settings');
     // Only check and display the status message if the form is being shown
     // for the first time and not when displayed again after submission.
     $check = empty($_POST);
     if ($check) {
         $status = MollomUtilities::getAdminAPIKeyStatus($check);
         if ($status['isVerified'] && !$config->get('test_mode.enabled')) {
             drupal_set_message(t('Mollom servers verified your keys. The services are operating correctly.'));
         }
     }
     $form['keys'] = array('#type' => 'details', '#title' => t('Mollom API keys'), '#tree' => TRUE, '#description' => t('To obtain API keys, <a href="@signup-url">sign up</a> or log in to your <a href="@site-manager-url">Site manager</a>, register this site, and copy the keys into the fields below.', array('@signup-url' => 'https://mollom.com/pricing', '@site-manager-url' => 'https://mollom.com/site-manager')), '#open' => isset($status) ? !$status['isVerified'] : true);
     // Keys are not #required to allow to install this module and configure it
     // later.
     $form['keys']['public'] = array('#type' => 'textfield', '#title' => t('Public key'), '#default_value' => $config->get('keys.public'), '#description' => t('Used to uniquely identify this site.'));
     $form['keys']['private'] = array('#type' => 'textfield', '#title' => t('Private key'), '#default_value' => $config->get('keys.private'), '#description' => t('Used for authentication. Similar to a password, the private key should not be shared with anyone.'));
     $form['fallback'] = array('#type' => 'radios', '#title' => t('When the Mollom service is unavailable'), '#default_value' => $config->get('fallback'), '#options' => array(Settings::MOLLOM_FALLBACK_ACCEPT => t('Accept all form submissions'), Settings::MOLLOM_FALLBACK_BLOCK => t('Block all form submissions')), '#description' => t('Mollom offers a <a href="@pricing-url">high-availability</a> infrastructure for users on paid plans to reduce potential downtime.', array('@pricing-url' => 'https://mollom.com/pricing')));
     $options = DrupalClient::getSupportedLanguages();
     $default_languages = !empty($status['expectedLanguages']) ? $status['expectedLanguages'] : $config->get("languages_expected");
     // @todo: Add chosen UI functionality for improved UX when available.
     $form['languages_expected'] = array('#type' => 'select', '#title' => t('Expected languages'), '#options' => $options, '#multiple' => TRUE, '#size' => 6, '#default_value' => $default_languages, '#description' => t('Restricts all posts to selected languages. Used by text analysis only. Leave empty if users may post in other languages.'));
     $form['privacy_link'] = array('#type' => 'checkbox', '#title' => t("Show a link to Mollom's privacy policy"), '#return_value' => true, '#default_value' => $config->get('privacy_link'), '#description' => t('Only applies to forms protected with text analysis. When disabling this option, you should inform visitors about the privacy of their data through other means.'));
     $form['testing_mode'] = array('#type' => 'checkbox', '#title' => t('Enable testing mode'), '#return_value' => true, '#default_value' => $config->get('test_mode.enabled'), '#description' => t('Submitting "ham", "unsure", or "spam" triggers the corresponding behavior; image CAPTCHAs only respond to "correct" and audio CAPTCHAs only respond to "demo". Do not enable this option if this site is publicly accessible.'));
     $form['advanced'] = array('#type' => 'details', '#title' => t('Advanced configuration'), '#open' => FALSE);
     // Lower severity numbers indicate a high severity level.
     $form['advanced']['log_level'] = array('#type' => 'radios', '#title' => t('Mollom logging level warning'), '#options' => array(RfcLogLevel::WARNING => t('Only log warnings and errors'), RfcLogLevel::DEBUG => t('Log all Mollom messages')), '#default_value' => $config->get('log_level'));
     $form['advanced']['audio_captcha_enabled'] = array('#type' => 'checkbox', '#title' => t('Enable audio CAPTCHAs.'), '#description' => t('Allows users to switch to an audio verification using the <a href="!faq-url">NATO alphabet</a>.  This may not be appropriate for non-English language sites.', array('!faq-url' => 'https://mollom.com/faq/mollom-audible-captcha-language')), '#return_value' => true, '#default_value' => $config->get('captcha.audio.enabled'));
     $timeout = $config->get('connection_timeout_seconds');
     $form['advanced']['connection_timeout_seconds'] = array('#type' => 'number', '#title' => t('Time-out when attempting to contact Mollom servers.'), '#description' => t('This is the length of time that a call to Mollom will wait before timing out.'), '#default_value' => !empty($timeout) ? $config->get('connection_timeout_seconds') : 3, '#size' => 5, '#field_suffix' => t('seconds'), '#required' => TRUE);
     return parent::buildForm($form, $form_state);
 }
コード例 #13
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $form = parent::buildForm($form, $form_state);
     $config = $this->config('encrypt.settings');
     $form['check_profile_status'] = array('#type' => 'checkbox', '#title' => $this->t('Show the validation status of encryption profiles.'), '#description' => $this->t('On the encryption profiles overview page, automatically validate each encryption profile to check if there are problems with it. Disable when you have a lot of encryption profiles and are encountering performance issues, or if you do not want encryption keys to be loaded by the status check.'), '#default_value' => $config->get('check_profile_status'));
     return $form;
 }
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $system_roles = user_roles($membersonly = TRUE);
     $config = \Drupal::config('registration_role_with_approval.settings');
     $site_config = \Drupal::configFactory()->get('system.mail');
     $mailing_list = $config->get('mailing_list');
     if ($mailing_list == "") {
         $mailing_list .= $site_config->get('mail');
     }
     $email_subject = $config->get('email_subject');
     $email_body = $config->get('email_body');
     $profile_roles = $config->get('profile_roles');
     $form['roles'] = array('#type' => 'fieldset', '#title' => t('Avaliable Roles on registration form'), '#collapsible' => TRUE);
     foreach ($system_roles as $system_role) {
         $role_id = $system_role->id();
         if ($role_id != '0' && $role_id != 'authenticated') {
             $form['roles'][$system_role->id()] = array('#type' => 'checkbox', '#title' => t($system_role->label()), '#default_value' => $profile_roles[$system_role->id()]['default']);
             $form['roles'][$system_role->id() . "needs_approval"] = array('#type' => 'checkbox', '#title' => t('needs approval'), '#states' => array('invisible' => array(":input[name='{$role_id}']" => array('checked' => FALSE))), '#attributes' => array('style' => 'margin-left: 2em'), '#default_value' => $profile_roles[$system_role->id()]['needs_approval']);
         }
     }
     $form['custom_mail'] = array('#type' => 'fieldset', '#title' => t('Custom registration email configuration'), '#collapsible' => TRUE);
     $form['custom_mail']['new_email'] = array("#type" => "textfield", "#title" => "Enter valid email");
     $form['custom_mail']['add_email'] = array("#type" => "button", "#value" => "Add email", "#ajax" => array('callback' => 'Drupal\\registration_role_with_approval\\Form\\RegistrationRoleWithApprovalSettingsForm::addEmailCallback', 'event' => 'click', 'effect' => 'fade', 'progress' => array('type' => 'throbber')));
     $form['custom_mail']['mailing_list'] = array("#type" => "textarea", "#title" => "Mailing list", "#default_value" => $mailing_list);
     $form['custom_mail']['email_subject'] = array("#type" => "textfield", "#title" => "Email subject", "#default_value" => $email_subject);
     $form['custom_mail']['email_body'] = array("#type" => "textarea", "#title" => "Email body", "#default_value" => $email_body);
     return parent::buildForm($form, $form_state);
 }
コード例 #15
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $config = $this->config('swaps.swapsettings_config');
     $form['enable_bootstrap'] = array('#type' => 'checkbox', '#title' => $this->t('Enable Bootstrap'), '#description' => $this->t(''), '#default_value' => $config->get('enable_bootstrap'));
     $form['enable_fontawesome'] = array('#type' => 'checkbox', '#title' => $this->t('Enable FontAwesome'), '#description' => $this->t(''), '#default_value' => $config->get('enable_fontawesome'));
     return parent::buildForm($form, $form_state);
 }
コード例 #16
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $config = $this->config('coffee.configuration');
     $form['coffee_menus'] = ['#type' => 'checkboxes', '#title' => $this->t('Menus to include'), '#description' => $this->t('Select the menus that should be used by Coffee to search.'), '#options' => $this->getMenuLabels(), '#default_value' => $config->get('coffee_menus')];
     $form['max_results'] = ['#type' => 'number', '#title' => $this->t('Max results'), '#description' => $this->t('Maximum number of items to show in the search results.'), '#default_value' => $config->get('max_results'), '#required' => TRUE, '#min' => 1, '#max' => 50];
     return parent::buildForm($form, $form_state);
 }
コード例 #17
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $fblikebutton_node_options = node_type_get_names();
     $config = $this->config('fblikebutton.settings');
     $form['fblikebutton_dynamic_visibility'] = array('#type' => 'details', '#title' => $this->t('Visibility settings'), '#open' => TRUE);
     $form['fblikebutton_dynamic_visibility']['fblikebutton_node_types'] = array('#type' => 'checkboxes', '#title' => $this->t('Display the Like button on these content types:'), '#options' => $fblikebutton_node_options, '#default_value' => $config->get('node_types'), '#description' => $this->t('Each of these content types will have the "like" button automatically added to them.'));
     /** 
      * @TODO: Uncomment this when the module is also able to add the button to 
      * the links area
      * 
     $form['fblikebutton_dynamic_visibility']['fblikebutton_full_node_display'] = array(
       '#type' => 'radios',
       '#title' => $this->t('Where do you want to show the Like button (full node view)?'),
       '#options' => array(
         $this->t('Content area'),
         $this->t('Links area')
       ),
       '#default_value' => $config->get('full_node_display'),
       '#description' => $this->t('If <em>Content area</em> is selected, the button will appear in the same area as the node content. When you select <em>Links area</em> the Like button will be visible in the links area, usually at the bottom of the node (When you select this last option you may want to adjust the Appearance settings). You can also configure Static Like Button Blocks in'. \Drupal::l($this->t('block page'), Url::fromRoute('block.admin_display')) . '.'),
     );
     */
     $form['fblikebutton_dynamic_visibility']['fblikebutton_teaser_display'] = array('#type' => 'radios', '#title' => $this->t('Where do you want to show the Like button on teasers?'), '#options' => array($this->t('Don\'t show on teasers'), $this->t('Content area')), '#default_value' => $config->get('teaser_display'), '#description' => $this->t('If you want to show the like button on teasers you can select the display area.'));
     $form['fblikebutton_dynamic_appearance'] = array('#type' => 'details', '#title' => $this->t('Appearance settings'), '#open' => TRUE);
     $form['fblikebutton_dynamic_appearance']['fblikebutton_layout'] = array('#type' => 'select', '#title' => $this->t('Layout style'), '#options' => array('standard' => $this->t('Standard'), 'box_count' => $this->t('Box Count'), 'button_count' => $this->t('Button Count'), 'button' => $this->t('Button')), '#default_value' => $config->get('layout'), '#description' => $this->t('Determines the size and amount of social context next to the button.'));
     // The actial values passed in from the options will be converted to a boolean
     // in the validation function, so it doesn't really matter what we use.
     $form['fblikebutton_dynamic_appearance']['fblikebutton_show_faces'] = array('#type' => 'select', '#title' => $this->t('Show faces in the box?'), '#options' => array(t('Do not show faces'), $this->t('Show faces')), '#default_value' => $config->get('show_faces', TRUE), '#description' => $this->t('Show profile pictures below the button. Only works if <em>Layout style</em> (found above) is set to <em>Standard</em> (otherwise, value is ignored).'));
     $form['fblikebutton_dynamic_appearance']['fblikebutton_action'] = array('#type' => 'select', '#title' => $this->t('Verb to display'), '#options' => array('like' => $this->t('Like'), 'recommend' => $this->t('Recommend')), '#default_value' => $config->get('action'), '#description' => $this->t('The verbiage to display inside the button itself.'));
     $form['fblikebutton_dynamic_appearance']['fblikebutton_font'] = array('#type' => 'select', '#title' => $this->t('Font'), '#options' => array('arial' => 'Arial', 'lucida+grande' => 'Lucida Grande', 'segoe+ui' => 'Segoe UI', 'tahoma' => 'Tahoma', 'trebuchet+ms' => 'Trebuchet MS', 'verdana' => 'Verdana'), '#default_value' => $config->get('font', 'arial'), '#description' => $this->t('The font with which to display the text of the button.'));
     $form['fblikebutton_dynamic_appearance']['fblikebutton_color_scheme'] = array('#type' => 'select', '#title' => $this->t('Color scheme'), '#options' => array('light' => $this->t('Light'), 'dark' => $this->t('Dark')), '#default_value' => $config->get('color_scheme'), '#description' => $this->t('The color scheme of the box environtment.'));
     $form['fblikebutton_dynamic_appearance']['fblikebutton_weight'] = array('#type' => 'number', '#title' => $this->t('Weight'), '#default_value' => $config->get('weight'), '#description' => $this->t('The weight determines where, at the content block, the like button will appear. The larger the weight, the lower it will appear on the node. For example, if you want the button to appear more toward the top of the node, choose <em>-40</em> as opposed to <em>-39, -38, 0, 1,</em> or <em>50,</em> etc. To position the Like button in its own block, go to the ' . \Drupal::l($this->t('block page'), Url::fromRoute('block.admin_display')) . '.'));
     $form['fblikebutton_dynamic_appearance']['fblikebutton_language'] = array('#type' => 'textfield', '#title' => $this->t('Language'), '#default_value' => $config->get('language'), '#description' => $this->t('Specific language to use. Default is English. Examples:<br />French (France): <em>fr_FR</em><br />French (Canada): <em>fr_CA</em><br />More information can be found at http://developers.facebook.com/docs/internationalization/ and a full XML list can be found at http://www.facebook.com/translations/FacebookLocales.xml'));
     return parent::buildForm($form, $form_state);
 }
コード例 #18
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, Request $request = NULL)
 {
     $current_path = $request->attributes->get('_system_path');
     $current_url = Url::createFromRequest($request);
     $devel_config = $this->config('devel.settings');
     $form['queries'] = array('#type' => 'fieldset', '#title' => t('Query log'));
     $description = t('Display a log of the database queries needed to generate the current page, and the execution time for each. Also, queries which are repeated during a single page view are summed in the # column, and printed in red since they are candidates for caching.');
     $form['queries']['query_display'] = array('#type' => 'checkbox', '#title' => t('Display query log'), '#default_value' => $devel_config->get('query_display'), '#description' => $description);
     $form['queries']['settings'] = array('#type' => 'container', '#states' => array('invisible' => array('input[name="query_display"]' => array('checked' => FALSE))));
     $form['queries']['settings']['query_sort'] = array('#type' => 'radios', '#title' => t('Sort query log'), '#default_value' => $devel_config->get('query_sort'), '#options' => array(t('by source'), t('by duration')), '#description' => t('The query table can be sorted in the order that the queries were executed or by descending duration.'));
     $form['queries']['settings']['execution'] = array('#type' => 'textfield', '#title' => t('Slow query highlighting'), '#default_value' => $devel_config->get('execution'), '#size' => 4, '#maxlength' => 4, '#description' => t('Enter an integer in milliseconds. Any query which takes longer than this many milliseconds will be highlighted in the query log. This indicates a possibly inefficient query, or a candidate for caching.'));
     $form['api_url'] = array('#type' => 'textfield', '#title' => t('API Site'), '#default_value' => $devel_config->get('api_url'), '#description' => t('The base URL for your developer documentation links. You might change this if you run <a href="!url">api.module</a> locally.', array('!url' => Url::fromUri('http://drupal.org/project/api')->toString())));
     $form['timer'] = array('#type' => 'checkbox', '#title' => t('Display page timer'), '#default_value' => $devel_config->get('timer'), '#description' => t('Display page execution time in the query log box.'));
     $form['memory'] = array('#type' => 'checkbox', '#title' => t('Display memory usage'), '#default_value' => $devel_config->get('memory'), '#description' => t('Display how much memory is used to generate the current page. This will show memory usage when devel_init() is called and when devel_exit() is called.'));
     $form['redirect_page'] = array('#type' => 'checkbox', '#title' => t('Display redirection page'), '#default_value' => $devel_config->get('redirect_page'), '#description' => t('When a module executes drupal_goto(), the query log and other developer information is lost. Enabling this setting presents an intermediate page to developers so that the log can be examined before continuing to the destination page.'));
     $form['page_alter'] = array('#type' => 'checkbox', '#title' => t('Display $page array'), '#default_value' => $devel_config->get('page_alter'), '#description' => t('Display $page array from <a href="http://api.drupal.org/api/function/hook_page_alter/7">hook_page_alter()</a> in the messages area of each page.'));
     $form['raw_names'] = array('#type' => 'checkbox', '#title' => t('Display machine names of permissions and modules'), '#default_value' => $devel_config->get('raw_names'), '#description' => t('Display the language-independent machine names of the permissions in mouse-over hints on the !Permissions page and the module base file names on the @Permissions and !Modules pages.', array('!Permissions' => $this->l(t('Permissions'), Url::fromRoute('user.admin_permissions')), '@Permissions' => t('Permissions'), '!Modules' => $this->l(t('Modules'), Url::fromRoute('system.modules_list')))));
     $error_handlers = devel_get_handlers();
     $form['error_handlers'] = array('#type' => 'select', '#title' => t('Error handlers'), '#options' => array(DEVEL_ERROR_HANDLER_NONE => t('None'), DEVEL_ERROR_HANDLER_STANDARD => t('Standard Drupal'), DEVEL_ERROR_HANDLER_BACKTRACE_DPM => t('Krumo backtrace in the message area'), DEVEL_ERROR_HANDLER_BACKTRACE_KRUMO => t('Krumo backtrace above the rendered page')), '#multiple' => TRUE, '#default_value' => empty($error_handlers) ? DEVEL_ERROR_HANDLER_NONE : $error_handlers, '#description' => SafeMarkup::set(t('Select the error handler(s) to use, in case you <a href="@choose">choose to show errors on screen</a>.', array('@choose' => $this->url('system.logging_settings'))) . '<ul>' . '<li>' . t('<em>None</em> is a good option when stepping through the site in your debugger.') . '</li>' . '<li>' . t('<em>Standard Drupal</em> does not display all the information that is often needed to resolve an issue.') . '</li>' . '<li>' . t('<em>Krumo backtrace</em> displays nice debug information when any type of error is noticed, but only to users with the %perm permission.', array('%perm' => t('Access developer information'))) . '</li></ul>' . t('Depending on the situation, the theme, the size of the call stack and the arguments, etc., some handlers may not display their messages, or display them on the subsequent page. Select <em>Standard Drupal</em> <strong>and</strong> <em>Krumo backtrace above the rendered page</em> to maximize your chances of not missing any messages.') . '<br />' . t('Demonstrate the current error handler(s):') . ' ' . $this->l('notice', $current_url, array('query' => array('demo' => 'notice'))) . ', ' . $this->l('notice+warning', $current_url, array('query' => array('demo' => 'warning'))) . ', ' . $this->l('notice+warning+error', $current_url, array('query' => array('demo' => 'error'))) . ' ' . t('(The presentation of the @error is determined by PHP.)', array('@error' => 'error'))));
     $form['error_handlers']['#size'] = count($form['error_handlers']['#options']);
     if ($request->query->has('demo')) {
         if ($request->getMethod() == 'GET') {
             $this->demonstrateErrorHandlers($request->query->get('demo'));
         }
         $request->query->remove('demo');
     }
     $options = array('default', 'blue', 'green', 'orange', 'white', 'disabled');
     $form['krumo_skin'] = array('#type' => 'radios', '#title' => t('Krumo display'), '#description' => t('Select a skin for your debug messages or select <em>disabled</em> to display object and array output in standard PHP format.'), '#options' => array_combine($options, $options), '#default_value' => $devel_config->get('krumo_skin'));
     $form['rebuild_theme'] = array('#type' => 'checkbox', '#title' => t('Rebuild the theme information like the registry'), '#description' => t('While creating new templates, change the $theme.info.yml and theme_ overrides the theme information needs to be rebuilt.'), '#default_value' => $devel_config->get('rebuild_theme'));
     $form['use_uncompressed_jquery'] = array('#type' => 'checkbox', '#title' => t('Use uncompressed jQuery'), '#default_value' => $devel_config->get('use_uncompressed_jquery'), '#description' => t("Use a human-readable version of jQuery instead of the minified version that ships with Drupal, to make JavaScript debugging easier."));
     return parent::buildForm($form, $form_state);
 }
コード例 #19
0
  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $config = $this->config('form_example.config_config');
    $form['first_name'] = array(
      '#type' => 'textfield',
      '#title' => $this->t('First Name'),
      '#description' => $this->t('Enter your first name'),
      '#maxlength' => 256,
      '#size' => 40,
      '#default_value' => $config->get('first_name'),
    );
    $form['last_name'] = array(
      '#type' => 'textfield',
      '#title' => $this->t('Last Name'),
      '#description' => $this->t('Enter your Last Name'),
      '#maxlength' => 256,
      '#size' => 40,
      '#default_value' => $config->get('last_name'),
    );
    $form['dob'] = array(
      '#type' => 'date',
      '#title' => $this->t('DOB'),
      '#description' => $this->t('Enter your DOB'),
      '#default_value' => $config->get('dob'),
    );

    return parent::buildForm($form, $form_state);
  }
コード例 #20
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $config = $this->config('itk_cookie_message.settings');
     $settings = $config->get();
     $settings = itk_cookie_message_get_settings();
     $form['tabs'] = array('#type' => 'vertical_tabs', '#weight' => 99);
     $form['general'] = array('#type' => 'details', '#group' => 'tabs', '#title' => $this->t('General settings'));
     $key = 'cookie_name';
     $form['general'][$this->getKey($key)] = array('#type' => 'textfield', '#title' => $this->t('Cookie name'), '#required' => TRUE, '#default_value' => $settings[$key]);
     $key = 'cookie_lifetime';
     $form['general'][$this->getKey($key)] = array('#type' => 'select', '#options' => array(1 * 30 * 24 * 60 * 60 => $this->t('One month'), 1 * 365 * 24 * 60 * 60 => $this->t('One year')), '#title' => $this->t('Cookie lifetime'), '#default_value' => $settings[$key]);
     $languages = \Drupal::languageManager()->getLanguages();
     foreach ($languages as $language) {
         $language_id = $language->getId();
         $settings = $config->get($language_id);
         $settings = itk_cookie_message_get_settings($language);
         $form[$language_id] = array('#type' => 'details', '#group' => 'tabs', '#title' => $this->t($language->getName()));
         $key = 'text';
         $form[$language_id][$this->getKey($key, $language)] = array('#type' => 'textfield', '#required' => TRUE, '#default_value' => $settings[$key], '#title' => $this->t('Text'), '#description' => $this->t('The maximum time a page can be cached. This is used as the value for max-age in Cache-Control headers.'));
         $key = 'read_more_url';
         $form[$language_id][$this->getKey($key, $language)] = array('#type' => 'textfield', '#default_value' => $settings[$key], '#title' => $this->t('Read more url'));
         $key = 'read_more_text';
         $form[$language_id][$this->getKey($key, $language)] = array('#type' => 'textfield', '#default_value' => $settings[$key], '#title' => $this->t('Read more text'));
         $key = 'accept_button_text';
         $form[$language_id][$this->getKey($key, $language)] = array('#type' => 'textfield', '#required' => TRUE, '#default_value' => $settings[$key], '#title' => $this->t('Accept button text'));
     }
     return parent::buildForm($form, $form_state);
 }
コード例 #21
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $config = $this->config('language.negotiation');
     $form['language_negotiation_session_param'] = array('#title' => $this->t('Request/session parameter'), '#type' => 'textfield', '#default_value' => $config->get('session.parameter'), '#description' => $this->t('Name of the request/session parameter used to determine the desired language.'));
     $form_state->setRedirect('language.negotiation');
     return parent::buildForm($form, $form_state);
 }
コード例 #22
0
ファイル: QuestionsForm.php プロジェクト: anyforsoft/csua_d8
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $faq_settings = $this->config('faq.settings');
     $display_options['questions_inline'] = $this->t('Questions inline');
     $display_options['questions_top'] = $this->t('Clicking on question takes user to answer further down the page');
     $display_options['hide_answer'] = $this->t('Clicking on question opens/hides answer under question');
     $display_options['new_page'] = $this->t('Clicking on question opens the answer in a new page');
     $form['faq_display'] = array('#type' => 'radios', '#options' => $display_options, '#title' => $this->t('Page layout'), '#description' => $this->t('This controls how the questions and answers are displayed on the page and what happens when someone clicks on the question.'), '#default_value' => $faq_settings->get('display'));
     $form['faq_questions_misc'] = array('#type' => 'details', '#title' => $this->t('Miscellaneous layout settings'), '#open' => TRUE);
     $form['faq_questions_misc']['faq_question_listing'] = array('#type' => 'select', '#options' => array('ol' => $this->t('Ordered list'), 'ul' => $this->t('Unordered list')), '#title' => $this->t('Questions listing style'), '#description' => $this->t("This allows to select how the questions listing is presented.  It only applies to the layouts: 'Clicking on question takes user to answer further down the page' and 'Clicking on question opens the answer in a new page'.  An ordered listing would number the questions, whereas an unordered list will have a bullet to the left of each question."), '#default_value' => $faq_settings->get('question_listing'));
     $form['faq_questions_misc']['faq_qa_mark'] = array('#type' => 'checkbox', '#title' => $this->t('Label questions and answers'), '#description' => $this->t('This option is only valid for the "Questions Inline" and "Clicking on question takes user to answer further down the page" layouts.  It labels all questions on the faq page with the "question label" setting and all answers with the "answer label" setting.  For example these could be set to "Q:" and "A:".'), '#default_value' => $faq_settings->get('qa_mark'));
     $form['faq_questions_misc']['faq_question_label'] = array('#type' => 'textfield', '#title' => $this->t('Question Label'), '#description' => $this->t('The label to pre-pend to the question text in the "Questions Inline" layout if labelling is enabled.'), '#default_value' => $faq_settings->get('question_label'));
     $form['faq_questions_misc']['faq_answer_label'] = array('#type' => 'textfield', '#title' => $this->t('Answer Label'), '#description' => $this->t('The label to pre-pend to the answer text in the "Questions Inline" layout if labelling is enabled.'), '#default_value' => $faq_settings->get('answer_label'));
     $form['faq_questions_misc']['faq_question_length'] = array('#type' => 'radios', '#title' => $this->t('Question length'), '#options' => array('long' => $this->t('Display longer text'), 'short' => $this->t('Display short text'), 'both' => $this->t('Display both short and long questions')), '#description' => t("The length of question text to display on the FAQ page.  The short question will always be displayed in the FAQ blocks."), '#default_value' => $faq_settings->get('question_length'));
     $form['faq_questions_misc']['faq_question_long_form'] = array('#type' => 'checkbox', '#title' => $this->t('Allow long question text to be configured'), '#default_value' => $faq_settings->get('question_long_form'));
     $form['faq_questions_misc']['faq_hide_qa_accordion'] = array('#type' => 'checkbox', '#title' => $this->t('Use accordion effect for "opens/hides answer under question" layout'), '#description' => $this->t('This enables an "accordion" style effect where when a question is clicked, the answer appears beneath, and is then hidden when another question is opened.'), '#default_value' => $faq_settings->get('hide_qa_accordion'));
     $form['faq_questions_misc']['faq_show_expand_all'] = array('#type' => 'checkbox', '#title' => $this->t('Show "expand / collapse all" links for collapsed questions'), '#description' => $this->t('The links will only be displayed if using the "opens/hides answer under question" or "opens/hides questions and answers under category" layouts.'), '#default_value' => $faq_settings->get('show_expand_all'));
     $form['faq_questions_misc']['faq_use_teaser'] = array('#type' => 'checkbox', '#title' => $this->t('Use answer teaser'), '#description' => t("This enables the display of the answer teaser text instead of the full answer when using the 'Questions inline' or 'Clicking on question takes user to answer further down the page' display options.  This is useful when you have long descriptive text.  The user can see the full answer by clicking on the question."), '#default_value' => $faq_settings->get('use_teaser'));
     // This setting has no meaning in D8 since comments are fields and read more link depends on view mode settings
     //$form['faq_questions_misc']['faq_show_node_links'] = array(
     //  '#type' => 'checkbox',
     //  '#title' => $this->t('Show node links'),
     //  '#description' => $this->t('This enables the display of links under the answer text on the faq page.  Examples of these links include "Read more", "Add comment".'),
     //  '#default_value' => $faq_settings->get('show_node_links')
     //);
     $form['faq_questions_misc']['faq_back_to_top'] = array('#type' => 'textfield', '#title' => $this->t('"Back to Top" link text'), '#description' => $this->t('This allows the user to change the text displayed for the links which return the user to the top of the page on certain page layouts.  Defaults to "Back to Top".  Leave blank to have no link.'), '#default_value' => $faq_settings->get('back_to_top'));
     $form['faq_questions_misc']['faq_disable_node_links'] = array('#type' => 'checkbox', '#title' => $this->t('Disable question links to nodes'), '#description' => $this->t('This allows the user to prevent the questions being links to the faq node in all layouts except "Clicking on question opens the answer in a new page".'), '#default_value' => $faq_settings->get('disable_node_links'));
     $form['faq_questions_misc']['faq_default_sorting'] = array('#type' => 'select', '#title' => $this->t('Default sorting for unordered FAQs'), '#options' => array('DESC' => $this->t('Date Descending'), 'ASC' => $this->t('Date Ascending')), '#description' => t("This controls the default ordering behaviour for new FAQ nodes which haven't been assigned a position."), '#default_value' => $faq_settings->get('default_sorting'));
     return parent::buildForm($form, $form_state);
 }
コード例 #23
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $config = $this->configFactory->get('youtube.settings');
     $form['text'] = array('#type' => 'markup', '#markup' => '<p>' . t('The following settings will be used as default
     values on all YouTube video fields.  Many of these settings can be
     overridden on a per-field basis.') . '</p>');
     $form['youtube_global'] = array('#type' => 'fieldset', '#title' => t('Video parameters'));
     $form['youtube_global']['youtube_suggest'] = array('#type' => 'checkbox', '#title' => t('Show suggested videos when the video finishes'), '#default_value' => $config->get('youtube_suggest'));
     $form['youtube_global']['youtube_modestbranding'] = array('#type' => 'checkbox', '#title' => t('Do not show YouTube logo on video player control bar
     (modestbranding).'), '#default_value' => $config->get('youtube_modestbranding'));
     $form['youtube_global']['youtube_theme'] = array('#type' => 'checkbox', '#title' => t('Use a light colored control bar for video player controls
     (theme).'), '#default_value' => $config->get('youtube_theme'));
     $form['youtube_global']['youtube_color'] = array('#type' => 'checkbox', '#title' => t('Use a white colored video progress bar (color).'), '#default_value' => $config->get('youtube_color'), '#description' => t('Note: the modestbranding parameter will be ignored
     when this is in use.'));
     $form['youtube_global']['youtube_enablejsapi'] = array('#type' => 'checkbox', '#title' => t('Enable use of the IFrame API (enablejsapi, origin).'), '#default_value' => $config->get('youtube_enablejsapi'), '#description' => t('For more information on the IFrame API and how to use
     it, see the <a href="@api_reference">IFrame API documentation</a>.', array('@api_reference' => 'https://developers.google.com/youtube/iframe_api_reference')));
     $form['youtube_global']['youtube_wmode'] = array('#type' => 'checkbox', '#title' => t('Fix overlay problem on IE8 and lower'), '#default_value' => $config->get('youtube_wmode'), '#description' => t('Checking this will fix the issue of a YouTube video
     showing above a modal window (including Drupal\'s Overlay). This is
     needed if you have Overlay users in IE or have modal windows throughout
     your site.'));
     $form['youtube_thumbs'] = array('#type' => 'fieldset', '#title' => t('Thumbnails'));
     $form['youtube_thumbs']['youtube_thumb_dir'] = array('#type' => 'textfield', '#title' => t('YouTube thumbnail directory'), '#field_prefix' => Settings::get('file_public_path', \Drupal::service('kernel')->getSitePath() . '/files') . '/', '#field_suffix' => '/thumbnail.png', '#description' => t('Location, within the files directory, where you would
     like the YouTube thumbnails stored.'), '#default_value' => $config->get('youtube_thumb_dir'));
     $form['youtube_thumbs']['youtube_thumb_hires'] = array('#type' => 'checkbox', '#title' => t('Save higher resolution thumbnail images'), '#description' => t('This will save thumbnails larger than the default
     size, 480x360, to the thumbnails directory specified above.'), '#default_value' => $config->get('youtube_thumb_hires'));
     $form['youtube_thumbs']['youtube_thumb_delete_all'] = array('#type' => 'submit', '#value' => t('Refresh existing thumbnail image files'), '#submit' => array('youtube_thumb_delete_all'));
     $form['youtube_privacy'] = array('#type' => 'checkbox', '#title' => t('Enable privacy-enhanced mode'), '#default_value' => $config->get('youtube_privacy'), '#description' => t('Checking this box will prevent YouTube from setting
     cookies in your site visitors browser.'));
     $form['youtube_player_class'] = array('#type' => 'textfield', '#title' => t('YouTube player class'), '#default_value' => $config->get('youtube_player_class'), '#description' => t('The iframe of every player will be given this class.
     They will also be given IDs based off of this value.'));
     return parent::buildForm($form, $form_state);
 }
コード例 #24
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $config = $this->config('fastpaced_videos.importsettings');
     $form['import_max'] = array('#type' => 'number', '#title' => $this->t('Import Max'), '#description' => $this->t('Maximum amount of nodes to import pre cron run'), '#default_value' => $config->get('import_max'));
     $form['search_terms'] = array('#type' => 'textfield', '#title' => $this->t('Search Terms'), '#maxlength' => 225, '#size' => 64, '#default_value' => $config->get('search_terms'));
     return parent::buildForm($form, $form_state);
 }
コード例 #25
0
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $config = $this->config('intranet_petitions.settings');
     $form['intranet_petitions_expired_days'] = ['#type' => 'number', '#title' => $this->t('Number of days petition life'), '#default_value' => $config->get('intranet_petitions_expired_days')];
     $form['intranet_petitions_likes_level'] = ['#type' => 'number', '#title' => $this->t('Number of likes to change petition status on "Scored"'), '#default_value' => $config->get('intranet_petitions_likes_level')];
     return parent::buildForm($form, $form_state);
 }
コード例 #26
0
ファイル: HelloConfigForm.php プロジェクト: nickgs/hellod8
 /**
  * {@inheritdoc}.
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $config = $this->config('hello.settings');
     $form['default_count'] = array('#type' => 'number', '#title' => $this->t('How many times do we say hi?'), '#default_value' => $config->get('default_count'));
     $form['phrase'] = array('#type' => 'textfield', '#title' => $this->t('How do you want to say hi?'), '#default_value' => $config->get('phrase'));
     return parent::buildForm($form, $form_state);
 }
コード例 #27
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $form = parent::buildForm($form, $form_state);
     $config = $this->config('views.settings');
     $options = array();
     foreach ($this->themeHandler->listInfo() as $name => $theme) {
         if ($theme->status) {
             $options[$name] = $theme->info['name'];
         }
     }
     // This is not currently a fieldset but we may want it to be later,
     // so this will make it easier to change if we do.
     $form['basic'] = array();
     $form['basic']['ui_show_master_display'] = array('#type' => 'checkbox', '#title' => $this->t('Always show the master (default) display'), '#default_value' => $config->get('ui.show.master_display'));
     $form['basic']['ui_show_advanced_column'] = array('#type' => 'checkbox', '#title' => $this->t('Always show advanced display settings'), '#default_value' => $config->get('ui.show.advanced_column'));
     $form['basic']['ui_show_display_embed'] = array('#type' => 'checkbox', '#title' => t('Allow embedded displays'), '#description' => t('Embedded displays can be used in code via views_embed_view().'), '#default_value' => $config->get('ui.show.display_embed'));
     $form['basic']['ui_exposed_filter_any_label'] = array('#type' => 'select', '#title' => $this->t('Label for "Any" value on non-required single-select exposed filters'), '#options' => array('old_any' => '<Any>', 'new_any' => $this->t('- Any -')), '#default_value' => $config->get('ui.exposed_filter_any_label'));
     $form['live_preview'] = array('#type' => 'details', '#title' => $this->t('Live preview settings'), '#open' => TRUE);
     $form['live_preview']['ui_always_live_preview'] = array('#type' => 'checkbox', '#title' => $this->t('Automatically update preview on changes'), '#default_value' => $config->get('ui.always_live_preview'));
     $form['live_preview']['ui_show_preview_information'] = array('#type' => 'checkbox', '#title' => $this->t('Show information and statistics about the view during live preview'), '#default_value' => $config->get('ui.show.preview_information'));
     $form['live_preview']['options'] = array('#type' => 'container', '#states' => array('visible' => array(':input[name="ui_show_preview_information"]' => array('checked' => TRUE))));
     $form['live_preview']['options']['ui_show_sql_query_enabled'] = array('#type' => 'checkbox', '#title' => $this->t('Show the SQL query'), '#default_value' => $config->get('ui.show.sql_query.enabled'));
     $form['live_preview']['options']['ui_show_sql_query_where'] = array('#type' => 'radios', '#states' => array('visible' => array(':input[name="ui_show_sql_query_enabled"]' => array('checked' => TRUE))), '#title' => t('Show SQL query'), '#options' => array('above' => $this->t('Above the preview'), 'below' => $this->t('Below the preview')), '#default_value' => $config->get('ui.show.sql_query.where'));
     $form['live_preview']['options']['ui_show_performance_statistics'] = array('#type' => 'checkbox', '#title' => $this->t('Show performance statistics'), '#default_value' => $config->get('ui.show.performance_statistics'));
     $form['live_preview']['options']['ui_show_additional_queries'] = array('#type' => 'checkbox', '#title' => $this->t('Show other queries run during render during live preview'), '#description' => $this->t("Drupal has the potential to run many queries while a view is being rendered. Checking this box will display every query run during view render as part of the live preview."), '#default_value' => $config->get('ui.show.additional_queries'));
     return $form;
 }
コード例 #28
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, Request $request = NULL)
 {
     $current_url = Url::createFromRequest($request);
     $devel_config = $this->config('devel.settings');
     $form['page_alter'] = array('#type' => 'checkbox', '#title' => t('Display $page array'), '#default_value' => $devel_config->get('page_alter'), '#description' => t('Display $page array from <a href="http://api.drupal.org/api/function/hook_page_alter/7">hook_page_alter()</a> in the messages area of each page.'));
     $form['raw_names'] = array('#type' => 'checkbox', '#title' => t('Display machine names of permissions and modules'), '#default_value' => $devel_config->get('raw_names'), '#description' => t('Display the language-independent machine names of the permissions in mouse-over hints on the <a href=":permissions_url">Permissions</a> page and the module base file names on the Permissions and <a href=":modules_url">Modules</a> pages.', array(':permissions_url' => Url::fromRoute('user.admin_permissions')->toString(), ':modules_url' => Url::fromRoute('system.modules_list')->toString())));
     $error_handlers = devel_get_handlers();
     $form['error_handlers'] = array('#type' => 'select', '#title' => t('Error handlers'), '#options' => array(DEVEL_ERROR_HANDLER_NONE => t('None'), DEVEL_ERROR_HANDLER_STANDARD => t('Standard Drupal'), DEVEL_ERROR_HANDLER_BACKTRACE_DPM => t('Kint backtrace in the message area'), DEVEL_ERROR_HANDLER_BACKTRACE_KINT => t('Kint backtrace above the rendered page')), '#multiple' => TRUE, '#default_value' => empty($error_handlers) ? DEVEL_ERROR_HANDLER_NONE : $error_handlers, '#description' => [['#markup' => $this->t('Select the error handler(s) to use, in case you <a href=":choose">choose to show errors on screen</a>.', [':choose' => $this->url('system.logging_settings')])], ['#theme' => 'item_list', '#items' => [$this->t('<em>None</em> is a good option when stepping through the site in your debugger.'), $this->t('<em>Standard Drupal</em> does not display all the information that is often needed to resolve an issue.'), $this->t('<em>Kint backtrace</em> displays nice debug information when any type of error is noticed, but only to users with the %perm permission.', ['%perm' => t('Access developer information')])]], ['#markup' => $this->t('Depending on the situation, the theme, the size of the call stack and the arguments, etc., some handlers may not display their messages, or display them on the subsequent page. Select <em>Standard Drupal</em> <strong>and</strong> <em>Kint backtrace above the rendered page</em> to maximize your chances of not missing any messages.') . '<br />' . $this->t('Demonstrate the current error handler(s):') . ' ' . $this->l('notice', $current_url->setOption('query', ['demo' => 'notice'])) . ', ' . $this->l('notice+warning', $current_url->setOption('query', ['demo' => 'warning'])) . ', ' . $this->l('notice+warning+error', $current_url->setOption('query', ['demo' => 'error'])) . ' (' . $this->t('The presentation of the @error is determined by PHP.', ['@error' => 'error']) . ')']]);
     $form['error_handlers']['#size'] = count($form['error_handlers']['#options']);
     if ($request->query->has('demo')) {
         if ($request->getMethod() == 'GET') {
             $this->demonstrateErrorHandlers($request->query->get('demo'));
         }
         $request->query->remove('demo');
     }
     $form['rebuild_theme'] = array('#type' => 'checkbox', '#title' => t('Rebuild the theme information like the registry'), '#description' => t('While creating new templates, change the $theme.info.yml and theme_ overrides the theme information needs to be rebuilt.'), '#default_value' => $devel_config->get('rebuild_theme'));
     $dumper = $devel_config->get('devel_dumper');
     $default = $this->dumperManager->isPluginSupported($dumper) ? $dumper : $this->dumperManager->getFallbackPluginId(NULL);
     $form['dumper'] = array('#type' => 'radios', '#title' => $this->t('Variables Dumper'), '#options' => [], '#default_value' => $default, '#description' => $this->t('Select the debugging tool used for formatting and displaying the variables inspected through the debug functions of Devel. You can enable the <a href=":kint_install">Kint module</a> (shipped with Devel) and select the Kint debugging tool for an improved debugging experience. <strong>NOTE</strong>: Some of these plugins require external libraries for to be enabled. Learn how install external libraries with <a href=":url">Composer</a>.', [':url' => 'https://www.drupal.org/node/2404989', ':kint_install' => Url::fromRoute('system.modules_list')->toString()]));
     foreach ($this->dumperManager->getDefinitions() as $id => $definition) {
         $form['dumper']['#options'][$id] = $definition['label'];
         $supported = $this->dumperManager->isPluginSupported($id);
         $form['dumper'][$id]['#disabled'] = !$supported;
         $form['dumper'][$id]['#description'] = ['#type' => 'inline_template', '#template' => '{{ description }}{% if not supported %}<div><small>{% trans %}<strong>Not available</strong>. You may need to install external dependencies for use this plugin.{% endtrans %}</small></div>{% endif %}', '#context' => ['description' => $definition['description'], 'supported' => $supported]];
     }
     return parent::buildForm($form, $form_state);
 }
コード例 #29
0
 /**
  * {@inheritdoc}.
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $form = parent::buildForm($form, $form_state);
     $config = $this->config('configform_example.settings');
     $form['email'] = ['#type' => 'email', '#title' => $this->t('Your .com email address.'), '#default_value' => $config->get('email_address')];
     return $form;
 }
コード例 #30
0
ファイル: DefaultForm.php プロジェクト: nfouka/drupal8_module
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $config = $this->config('mymodules.default_config');
     $form['firstname'] = array('#type' => 'textfield', '#title' => $this->t('FirstName'), '#description' => $this->t('Your last Name'), '#maxlength' => 25, '#size' => 25, '#default_value' => $config->get('firstname'));
     $form['lastname'] = array('#type' => 'textfield', '#title' => $this->t('LastName'), '#description' => $this->t('Last Name'), '#maxlength' => 25, '#default_value' => $config->get('lastname'));
     return parent::buildForm($form, $form_state);
 }