/**
  * Retrieves the currently selected theme on the settings form.
  *
  * @param array $form
  *   Nested array of form elements that comprise the form.
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The current state of the form.
  *
  * @return \Drupal\bootstrap\Theme|FALSE
  *   The currently selected theme object or FALSE if not a Bootstrap theme.
  */
 public static function getTheme(array &$form, FormStateInterface $form_state)
 {
     $build_info = $form_state->getBuildInfo();
     $theme = isset($build_info['args'][0]) ? Bootstrap::getTheme($build_info['args'][0]) : FALSE;
     // Do not continue if the theme is not Bootstrap specific.
     if (!$theme || !$theme->subthemeOf('bootstrap')) {
         unset($form['#submit'][0]);
         unset($form['#validate'][0]);
     }
     return $theme;
 }
 /**
  * {@inheritdoc}
  */
 public function applyAccountFormProtection(array &$form, FormStateInterface $form_state)
 {
     $build_info = $form_state->getBuildInfo();
     $account = $build_info['callback_object']->getEntity();
     if (isset($form['account']['status'])) {
         $form['account']['status']['#disabled'] = TRUE;
         $form['account']['status']['#value'] = $account->isActive();
         return TRUE;
     }
     return FALSE;
 }
 /**
  * {@inheritdoc}
  */
 public function applyAccountFormProtection(array &$form, FormStateInterface $form_state)
 {
     $build_info = $form_state->getBuildInfo();
     $account = $build_info['callback_object']->getEntity();
     // If for some reason the account has no mail, then don't protect it.
     if ($account->getEmail() && isset($form['account']['mail'])) {
         $form['account']['mail']['#disabled'] = TRUE;
         $form['account']['mail']['#value'] = $account->getEmail();
         return TRUE;
     }
     return FALSE;
 }
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     try {
         if (!empty($form_state->getBuildInfo()['args'][0]) && !empty($form_state->getBuildInfo()['args'][1])) {
             $smfSessionId = $form_state->getBuildInfo()['args'][0];
             /**
              * @var \Drupal\smfbridge\Smf\Member $smfMember
              */
             $smfMember = \Drupal::service('smfbridge.smfmember');
             if ($smfMember->setAdminTime($smfSessionId)) {
                 $form_state->setRedirectUrl(Url::fromUserInput($form_state->getBuildInfo()['args'][1]));
             } else {
                 throw new \Exception($this->t('Failed to get access to SMF admin area.'));
             }
         } else {
             throw new \Exception($this->t('Failed to get access to SMF admin area.'));
         }
     } catch (\Exception $e) {
         drupal_set_message($e->getMessage(), 'error');
     }
 }
 /**
  * {@inheritdoc}.
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $build_info = $form_state->getBuildInfo();
     if ($build_info['args'] && $build_info['args'][0] instanceof EntityInterface) {
         $this->entity = $build_info['args'][0];
     }
     $form['first_name'] = array('#type' => 'textfield', '#title' => $this->t('First name'));
     $form['last_name'] = array('#type' => 'textfield', '#title' => $this->t('Last name'));
     $form['email'] = array('#type' => 'email', '#title' => $this->t('Email'));
     $form['actions']['#type'] = 'actions';
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Submit'), '#button_type' => 'primary');
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $installModules = [];
     foreach ($form_state->getValues() as $key => $value) {
         if (strpos($key, 'install_modules') !== FALSE && $value) {
             preg_match('/install_modules_(?P<name>\\w+)/', $key, $values);
             $installModules[] = $values['name'];
         }
     }
     $buildInfo = $form_state->getBuildInfo();
     $install_state = $buildInfo['args'];
     $install_state[0]['thunder_additional_modules'] = $installModules;
     $install_state[0]['form_state_values'] = $form_state->getValues();
     $buildInfo['args'] = $install_state;
     $form_state->setBuildInfo($buildInfo);
 }
Example #7
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $bi = $form_state->getBuildInfo();
     $options = $bi['args'][0];
     if (count($options) <= 1) {
         return $form;
     }
     $default = NULL;
     if (!empty($_GET['graph'])) {
         if (is_string($_GET['graph']) && isset($options[$_GET['graph']])) {
             $default = $_GET['graph'];
         }
     }
     $form['graph'] = ['#type' => 'select', '#title' => $this->t('Graph'), '#options' => $options, '#default_value' => $default, '#description' => $this->t('The graph to load the entity from.')];
     $form['submit'] = ['#value' => $this->t('Select graph'), '#type' => 'submit'];
     $form['#method'] = 'get';
     return $form;
 }
 public function submitForm(array &$form, FormStateInterface $form_state) {
   $build_info = $form_state->getBuildInfo();
   $build_info['args'][0]['parameters']['langcode'] = $form_state->getValue('langcode');
   $build_info['args'][0]['parameters']['langcodes'] = $form_state->getValue('langcodes');
   $form_state->setBuildInfo($build_info);
 }
  /**
   * {@inheritdoc}
   */
  public function validateForm(array &$form, FormStateInterface $form_state) {
    $build_info = $form_state->getBuildInfo();
    $signup = $build_info['callback_object']->signup;

    // For forms that allow subscribing to multiple lists
    // ensure at least one list is checked.
    if (count($signup->mc_lists) > 1) {
      $values = $form_state->getValues();
      foreach ($values['mailchimp_lists'] as $list) {
        if ($list['subscribe']) {
          return;
        }
      }

      $form_state->setErrorByName('mailchimp_lists', t("Please select at least one list to subscribe to."));
    }
  }
 /**
  * {@inheritdoc}
  */
 public function getBuildInfo()
 {
     return $this->decoratedFormState->getBuildInfo();
 }
Example #11
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $build_info = $form_state->getBuildInfo();
     $account = $build_info['args'][0];
     $edit = $form_state->getValues();
     // Check out if any downloads were modified.
     if (isset($edit['file_download'])) {
         foreach ((array) $edit['file_download'] as $fid => $download_modification) {
             // Remove this user download?
             if ($download_modification['remove']) {
                 uc_file_remove_user_file_by_id($account, $fid);
             } else {
                 // Calculate the new expiration.
                 $download_modification['expiration'] = _uc_file_expiration_date($download_modification, $download_modification['expiration']);
                 // Don't touch anything if everything's the same.
                 if ($download_modification['download_limit'] == $download_modification['download_limit_old'] && $download_modification['address_limit'] == $download_modification['address_limit_old'] && $download_modification['expiration'] == $download_modification['expiration_old']) {
                     continue;
                 }
                 // Renew. (Explicit overwrite.)
                 uc_file_user_renew($fid, $account, NULL, $download_modification, TRUE);
             }
         }
     }
     // Check out if any downloads were added. We pass NULL to file_user_renew,
     // because this shouldn't be associated with a random product.
     if (isset($edit['file_add'])) {
         $file_config = $this->config('uc_file.settings');
         foreach ((array) $edit['file_add'] as $fid => $data) {
             $download_modification['download_limit'] = $file_config->get('download_limit_number');
             $download_modification['address_limit'] = $file_config->get('download_limit_addresses');
             $download_modification['expiration'] = _uc_file_expiration_date(array('time_polarity' => '+', 'time_quantity' => $file_config->get('download_limit_duration_qty'), 'time_granularity' => $file_config->get('download_limit_duration_granularity')), REQUEST_TIME);
             // Renew. (Explicit overwrite.)
             uc_file_user_renew($fid, $account, NULL, $download_modification, TRUE);
         }
     }
 }
Example #12
0
 /**
  * {@inheritdoc}
  */
 public function blockForm($form, FormStateInterface $form_state)
 {
     // Fish the page object from the form args.
     // Prevent serialization error.
     $form['admin_label']['#markup'] = (string) $form['admin_label']['#markup'];
     foreach ($form_state->getBuildInfo()['args'] as $arg) {
         if ($arg instanceof Page) {
             $this->page = $arg->getExecutable();
         }
     }
     $block_plugins = \Drupal::service('plugin.manager.block')->getDefinitionsForContexts($this->getContexts());
     $block_options = array();
     foreach ($block_plugins as $plugin_id => $block_definition) {
         $block_options[(string) $block_definition['category']][$plugin_id] = (string) $block_definition['admin_label'];
     }
     $widget_blocks = $form_state->hasValue(array('settings', 'blocks')) ? $form_state->getValue(array('settings', 'blocks')) : $this->configuration['blocks'];
     $layout = $form_state->hasValue(array('settings', 'layout')) ? $form_state->getValue(array('settings', 'layout')) : $this->configuration['layout'];
     $classes = $form_state->hasValue(array('settings', 'classes')) ? $form_state->getValue(array('settings', 'classes')) : $this->configuration['classes'];
     $ajax_properties = array('#ajax' => array('callback' => array($this, 'widgetBlockAJAXCallback'), 'wrapper' => 'widget-block-wrapper', 'effect' => 'fade'));
     $form = parent::blockForm($form, $form_state);
     $layouts = array();
     foreach (Layout::layoutPluginManager()->getDefinitions() as $id => $definition) {
         if ($definition['type'] == 'partial') {
             $layouts[$id] = $definition['label'];
         }
     }
     $form['layout'] = array('#type' => 'select', '#required' => TRUE, '#title' => t('Widget layout'), '#options' => $layouts, '#default_value' => $layout) + $ajax_properties;
     $form['blocks'] = array('#type' => 'container', '#prefix' => '<div id="widget-block-wrapper">', '#suffix' => '</div>');
     $form['classes'] = array('#type' => 'textfield', '#title' => t('CSS Classes'), '#default_value' => $classes);
     if (!$layout) {
         return $form;
     }
     if ($layout != $this->configuration['layout']) {
         $this->configuration['layout'] = $layout;
         $this->configuration['regions'] = NULL;
         $this->layoutRegionBag = NULL;
     }
     foreach ($this->getLayoutRegions() as $region_id => $region_definition) {
         $block_config = isset($widget_blocks[$region_id]) ? $widget_blocks[$region_id] : array();
         $form['blocks'][$region_id] = array('#type' => 'details', '#title' => $region_definition->getConfiguration()['label'], '#open' => TRUE);
         $form['blocks'][$region_id]['id'] = array('#type' => 'select', '#title' => t('Block'), '#options' => $block_options, '#default_value' => isset($block_config['id']) ? $block_config['id'] : NULL, '#empty_option' => t('- None -')) + $ajax_properties;
         $form['blocks'][$region_id]['region'] = array('#type' => 'value', '#value' => $region_id);
         if (!empty($block_config['id'])) {
             $block_plugin = \Drupal::service('plugin.manager.block')->createInstance($block_config['id'], $block_config);
             $form['blocks'][$region_id] += $block_plugin->buildConfigurationForm(array(), $form_state);
             if ($block_plugin instanceof ContextAwarePluginInterface) {
                 $form['blocks'][$region_id]['context_mapping'] = $this->addContextAssignmentElement($block_plugin, $this->getContexts());
             }
             // @todo Support per-block caching and visibility. Breaks UI right now.
             unset($form['blocks'][$region_id]['cache']);
             unset($form['blocks'][$region_id]['visibility']);
             unset($form['blocks'][$region_id]['visibility_tabs']);
         } else {
             //unset($form['blocks'][$region_id]);
         }
     }
     return $form;
 }
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $this->_move_all_config_files_directory('general');
    $this->_move_all_config_files_directory('seven');
    $this->_move_all_config_files_directory('bfc_admin_theme');
    $this->_move_all_config_files_directory('bootstrap');
    $this->_move_all_config_files_directory('text_formats_editors');
    $this->_move_all_config_files_directory('user');
    $this->_move_all_config_files_directory('linkit');

    if(!empty($_GET['langcodes'])){
      # Enabled multilanguage modules
      $this->_move_all_config_files_directory('multilanguage');
    }

    if ($form_state->getValue('editor') == 1) {
      $this->_move_config_file('user.role.editor.yml', 'roles');
    }
    if ($form_state->getValue('administrator') == 1) {
      $this->_move_config_file('user.role.administrator.yml', 'roles');
    }
    if ($form_state->getValue('article') == 1) {
      $this->_move_all_config_files_directory('article');
    }
    if ($form_state->getValue('page') == 1) {
      $this->_move_all_config_files_directory('page');
    }

    $build_info = $form_state->getBuildInfo();
    $build_info['args'][0]['parameters']['configuration'] = TRUE;
    $form_state->setBuildInfo($build_info);
  }
/**
 * Implements hook_form_FORM_ID_alter().
 */
function mbase_form_system_theme_settings_alter(&$form, FormStateInterface $form_state, $form_id = NULL)
{
    // Do not add Bootstrap specific settings to non-bootstrap based themes,
    // including a work-around for a core bug affecting admin themes.
    // @see https://drupal.org/node/943212
    $args = $form_state->getBuildInfo()['args'];
    // Do not add Bootstrap specific settings to non-bootstrap based themes.
    $theme = !empty($args[0]) ? $args[0] : FALSE;
    if (isset($form_id) || $theme === FALSE || !in_array('mbase', _mbase_get_base_themes($theme, TRUE))) {
        return;
    }
    $form['mbase'] = array('#type' => 'vertical_tabs', '#attached' => array('library' => array('mbase/adminscript')), '#prefix' => '<h2><small>' . t('Modern Base theme Settings') . '</small></h2>', '#weight' => -10);
    // General.
    $form['general'] = array('#type' => 'details', '#title' => t('General'), '#group' => 'mbase');
    // Container.
    $form['general']['container'] = array('#type' => 'fieldset', '#title' => t('Container'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['general']['container']['mbase_fluid_container'] = array('#type' => 'checkbox', '#title' => t('Fluid container'), '#default_value' => _mbase_setting('fluid_container', $theme), '#description' => t('Use <code>.container-fluid</code> class. See <a href="http://getbootstrap.com/css/#grid-example-fluid">Fluid container</a>'));
    // Buttons.
    $form['general']['buttons'] = array('#type' => 'details', '#title' => t('Buttons'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['general']['buttons']['mbase_button_size'] = array('#type' => 'select', '#title' => t('Default button size'), '#default_value' => _mbase_setting('button_size', $theme), '#empty_option' => t('Normal'), '#options' => array('btn-xs' => t('Extra Small'), 'btn-sm' => t('Small'), 'btn-lg' => t('Large')));
    $form['general']['buttons']['mbase_button_colorize'] = array('#type' => 'checkbox', '#title' => t('Colorize Buttons'), '#default_value' => _mbase_setting('button_colorize', $theme), '#description' => t('Adds classes to buttons based on their text value. See: <a href="!bootstrap_url" target="_blank">Buttons</a> and <a href="!api_url" target="_blank">hook_mbase_colorize_text_alter()</a>', array('!bootstrap_url' => 'http://getbootstrap.com/css/#buttons', '!api_url' => 'http://drupalcode.org/project/bootstrap.git/blob/refs/heads/7.x-3.x:/bootstrap.api.php#l13')));
    $form['general']['buttons']['mbase_button_iconize'] = array('#type' => 'checkbox', '#title' => t('Iconize Buttons'), '#default_value' => _mbase_setting('button_iconize', $theme), '#description' => t('Adds icons to buttons based on the text value. See: <a href="!api_url" target="_blank">hook_mbase_iconize_text_alter()</a>', array('!api_url' => 'http://drupalcode.org/project/bootstrap.git/blob/refs/heads/7.x-3.x:/bootstrap.api.php#l37')));
    // Forms.
    $form['general']['forms'] = array('#type' => 'details', '#title' => t('Forms'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['general']['forms']['mbase_forms_required_has_error'] = array('#type' => 'checkbox', '#title' => t('Make required elements display as an error'), '#default_value' => _mbase_setting('forms_required_has_error', $theme), '#description' => t('If an element in a form is required, enabling this will always display the element with a <code>.has-error</code> class. This turns the element red and helps in usability for determining which form elements are required to submit the form.  This feature compliments the "JavaScript > Forms > Automatically remove error classes when values have been entered" feature.'));
    // Images.
    $form['general']['images'] = array('#type' => 'details', '#title' => t('Images'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['general']['images']['mbase_image_shape'] = array('#type' => 'select', '#title' => t('Default image shape'), '#description' => t('Add classes to an <code>&lt;img&gt;</code> element to easily style images in any project. Note: Internet Explorer 8 lacks support for rounded corners. See: <a href="!bootstrap_url" target="_blank">Image Shapes</a>', array('!bootstrap_url' => 'http://getbootstrap.com/css/#images-shapes')), '#default_value' => _mbase_setting('image_shape', $theme), '#empty_option' => t('None'), '#options' => array('img-rounded' => t('Rounded'), 'img-circle' => t('Circle'), 'img-thumbnail' => t('Thumbnail')));
    $form['general']['images']['mbase_image_responsive'] = array('#type' => 'checkbox', '#title' => t('Responsive Images'), '#default_value' => _mbase_setting('image_responsive', $theme), '#description' => t('Images in Bootstrap 3 can be made responsive-friendly via the addition of the <code>.img-responsive</code> class. This applies <code>max-width: 100%;</code> and <code>height: auto;</code> to the image so that it scales nicely to the parent element.'));
    // Tables.
    $form['general']['tables'] = array('#type' => 'details', '#title' => t('Tables'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['general']['tables']['mbase_table_bordered'] = array('#type' => 'checkbox', '#title' => t('Bordered table'), '#default_value' => _mbase_setting('table_bordered', $theme), '#description' => t('Add borders on all sides of the table and cells.'));
    $form['general']['tables']['mbase_table_condensed'] = array('#type' => 'checkbox', '#title' => t('Condensed table'), '#default_value' => _mbase_setting('table_condensed', $theme), '#description' => t('Make tables more compact by cutting cell padding in half.'));
    $form['general']['tables']['mbase_table_hover'] = array('#type' => 'checkbox', '#title' => t('Hover rows'), '#default_value' => _mbase_setting('table_hover', $theme), '#description' => t('Enable a hover state on table rows.'));
    $form['general']['tables']['table_striped'] = array('#type' => 'checkbox', '#title' => t('Striped rows'), '#default_value' => _mbase_setting('table_striped', $theme), '#description' => t('Add zebra-striping to any table row within the <code>&lt;tbody&gt;</code>. <strong>Note:</strong> Striped tables are styled via the <code>:nth-child</code> CSS selector, which is not available in Internet Explorer 8.'));
    $form['general']['tables']['mbase_table_responsive'] = array('#type' => 'checkbox', '#title' => t('Responsive tables'), '#default_value' => _mbase_setting('table_responsive', $theme), '#description' => t('Makes tables responsive by wrapping them in <code>.table-responsive</code> to make them scroll horizontally up to small devices (under 768px). When viewing on anything larger than 768px wide, you will not see any difference in these tables.'));
    // Components.
    $form['components'] = array('#type' => 'details', '#title' => t('Components'), '#group' => 'mbase');
    // Breadcrumbs.
    $form['components']['breadcrumbs'] = array('#type' => 'details', '#title' => t('Breadcrumbs'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['components']['breadcrumbs']['mbase_breadcrumb'] = array('#type' => 'select', '#title' => t('Breadcrumb visibility'), '#default_value' => _mbase_setting('breadcrumb', $theme), '#options' => array(0 => t('Hidden'), 1 => t('Visible'), 2 => t('Only in admin areas')));
    $form['components']['breadcrumbs']['mbase_breadcrumb_home'] = array('#type' => 'checkbox', '#title' => t('Show "Home" breadcrumb link'), '#default_value' => _mbase_setting('breadcrumb_home', $theme), '#description' => t('If your site has a module dedicated to handling breadcrumbs already, ensure this setting is enabled.'), '#states' => array('invisible' => array(':input[name="mbase_breadcrumb"]' => array('value' => 0))));
    $form['components']['breadcrumbs']['mbase_breadcrumb_title'] = array('#type' => 'checkbox', '#title' => t('Show current page title at end'), '#default_value' => _mbase_setting('breadcrumb_title', $theme), '#description' => t('If your site has a module dedicated to handling breadcrumbs already, ensure this setting is disabled.'), '#states' => array('invisible' => array(':input[name="mbase_breadcrumb"]' => array('value' => 0))));
    $form['components']['breadcrumbs']['mbase_breadcrumb_text'] = array('#type' => 'textfield', '#title' => t('Prefix text'), '#description' => t('Enter the prefix text for breadcrumbs.'), '#default_value' => _mbase_setting('breadcrumb_text', $theme));
    // Navbar.
    $form['components']['navbar'] = array('#type' => 'details', '#title' => t('Navbar'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['components']['navbar']['mbase_navbar_position'] = array('#type' => 'select', '#title' => t('Navbar Position'), '#description' => t('Select your Navbar position.'), '#default_value' => _mbase_setting('navbar_position', $theme), '#options' => array('default' => t('Default'), 'static-top' => t('Static Top'), 'fixed-top' => t('Fixed Top'), 'fixed-bottom' => t('Fixed Bottom')));
    $form['components']['navbar']['mbase_navbar_inverse'] = array('#type' => 'checkbox', '#title' => t('Inverse navbar style'), '#description' => t('Select if you want the inverse navbar style.'), '#default_value' => _mbase_setting('navbar_inverse', $theme));
    // Region wells.
    $wells = array('' => t('None'), 'well' => t('.well (normal)'), 'well well-sm' => t('.well-sm (small)'), 'well well-lg' => t('.well-lg (large)'));
    $form['components']['region_wells'] = array('#type' => 'details', '#title' => t('Region wells'), '#description' => t('Enable the <code>.well</code>, <code>.well-sm</code> or <code>.well-lg</code> classes for specified regions. See: documentation on !wells.', array('!wells' => \Drupal::l(t('Bootstrap Wells'), Url::fromUri('http://getbootstrap.com/components/#wells')))), '#collapsible' => TRUE, '#collapsed' => TRUE);
    // Get defined regions.
    $regions = system_region_list('mbase');
    foreach ($regions as $name => $title) {
        $form['components']['region_wells']['mbase_region_well-' . $name] = array('#title' => $title, '#type' => 'select', '#attributes' => array('class' => array('input-sm')), '#options' => $wells, '#default_value' => _mbase_setting('region_well-' . $name, $theme));
    }
    // Region visibility.
    $breakpoints = array('xs' => t('Extra small devices (Phones)'), 'sm' => t('Small devices (Tablets)'), 'md' => t('Medium devices (Desktops)'), 'lg' => t('Large devices (Desktops)'));
    $form['components']['region_visibility'] = array('#type' => 'details', '#title' => t('Region Visibility'), '#description' => t('Choose the visibility per breakpoints per region. See: documentation on !responsive.', array('!responsive' => \Drupal::l(t('Bootstrap Responsive utilities'), Url::fromUri('http://getbootstrap.com/css/#responsive-utilities')))), '#collapsible' => TRUE, '#collapsed' => TRUE);
    foreach ($regions as $name => $title) {
        $form['components']['region_visibility'][$name] = array('#type' => 'details', '#title' => $name, '#collapsible' => FALSE);
        foreach ($breakpoints as $devicekey => $devicename) {
            $visibility_options = array('visible-' . $devicekey . '-block' => t('Display as block'), 'visible-' . $devicekey . '-inline' => t('Display as inline'), 'visible-' . $devicekey . '-inline-block' => t('Display as inline block'), 'hidden-' . $devicekey => t('Hide from display'));
            $form['components']['region_visibility'][$name]['mbase_region_visibility-' . $name . '-' . $devicekey] = array('#title' => $devicename, '#type' => 'select', '#attributes' => array('class' => array('input-sm')), '#options' => $visibility_options, '#default_value' => _mbase_setting('region_visibility-' . $name . '-' . $devicekey, $theme));
        }
    }
    // JavaScript settings.
    $form['javascript'] = array('#type' => 'details', '#title' => t('JavaScript'), '#group' => 'mbase');
    // Anchors.
    $form['javascript']['anchors'] = array('#type' => 'details', '#title' => t('Anchors'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['javascript']['anchors']['mbase_anchors_fix'] = array('#type' => 'checkbox', '#title' => t('Fix anchor positions'), '#default_value' => _mbase_setting('anchors_fix', $theme), '#description' => t('Ensures anchors are correctly positioned only when there is margin or padding detected on the BODY element. This is useful when fixed navbar or administration menus are used.'));
    $form['javascript']['anchors']['mbase_anchors_smooth_scrolling'] = array('#type' => 'checkbox', '#title' => t('Enable smooth scrolling'), '#default_value' => _mbase_setting('anchors_smooth_scrolling', $theme), '#description' => t('Animates page by scrolling to an anchor link target smoothly when clicked.'), '#states' => array('invisible' => array(':input[name="mbase_anchors_fix"]' => array('checked' => FALSE))));
    // Forms.
    $form['javascript']['forms'] = array('#type' => 'details', '#title' => t('Forms'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['javascript']['forms']['mbase_forms_has_error_value_toggle'] = array('#type' => 'checkbox', '#title' => t('Automatically remove error classes when values have been entered'), '#default_value' => _mbase_setting('forms_has_error_value_toggle', $theme), '#description' => t('If an element has a <code>.has-error</code> class attached to it, enabling this will automatically remove that class when a value is entered. This feature compliments the "General > Forms > Make required elements display as an error" feature.'));
    // Other settings.
    $form['javascript']['others'] = array('#type' => 'details', '#title' => t('Other Settings'), '#description' => t("Other Bootstrap Js settings"), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['javascript']['others']['mbase_alert_dismissible'] = array('#type' => 'checkbox', '#title' => t('Dismissible Alert'), '#description' => t("Makes the alert messages dismissable."), '#default_value' => _mbase_setting('alert_dismissible', $theme));
    // Advanced settings.
    $form['advanced'] = array('#type' => 'details', '#title' => t('Advanced'), '#group' => 'mbase');
    $form['advanced']['mbase_bsflatit'] = array('#type' => 'checkbox', '#title' => t('Bootstrap Flat.it'), '#description' => t('Select to Remove all border radiuses to zero. Using <a href="@flatitlink" target = "_blank">Bootstrap Rate.it</a> CSS.', array('@flatitlink' => 'https://github.com/cmsbots/bsflat.it')), '#default_value' => _mbase_setting('bsflatit', $theme));
    $form['advanced']['mbase_animatecss'] = array('#type' => 'checkbox', '#title' => t('Add animate.css'), '#description' => t('Select to add CSS3 animations to site. Using <a href="@animation" target = "_blank">Animate.css</a> CSS.', array('@animation' => 'https://github.com/daneden/animate.css')), '#default_value' => _mbase_setting('animatecss', $theme));
    $form['advanced']['mbase_fontawesome'] = array('#type' => 'checkbox', '#title' => t('Add Font awesome'), '#description' => t('Add fontawesome icons, it will override the default glyphicon icons comes with Bootstrap. Make sure you added right CDN file for fontawesome to work.'), '#default_value' => _mbase_setting('fontawesome', $theme));
    $theme_info = \Drupal::service('theme_handler')->listInfo();
    $default_cdn_css = trim(_mbase_setting('addbscsscdn', $theme));
    $default_cdn_css = $default_cdn_css ? $default_cdn_css : $theme_info['mbase']->info['bs-cdn-css'];
    $form['advanced']['mbase_addbscsscdn'] = array('#type' => 'textfield', '#title' => t('Add Bootstrap CDN CSS file.'), '#description' => t("Add Bootstrap CSS CDN file. Enter Fully qualified URL."), '#default_value' => $default_cdn_css, '#required' => TRUE);
    $default_cdn_js = trim(_mbase_setting('addbsjsscdn', $theme));
    $default_cdn_js = $default_cdn_js ? $default_cdn_js : $theme_info['mbase']->info['bs-cdn-css'];
    $form['advanced']['mbase_addbsjsscdn'] = array('#type' => 'textfield', '#title' => t('Add Bootstrap CDN Javascript file.'), '#description' => t("Add Bootstrap Javascript CDN file. Enter Fully qualified URL."), '#default_value' => $default_cdn_js, '#required' => TRUE);
    $form['advanced']['mbase_include_cdn_css'] = array('#type' => 'textarea', '#title' => t('Add CSS files from CDN'), '#description' => t("Add one css file per line. It must be full URL."), '#default_value' => _mbase_setting('include_cdn_css', $theme));
    $form['advanced']['mbase_include_cdn_js'] = array('#type' => 'textarea', '#title' => t('Add JS files from CDN'), '#description' => t("Add one Javascript file per line. It must be full URL."), '#default_value' => _mbase_setting('include_cdn_js', $theme));
}
Example #15
0
 /**
  * {@inheritdoc}
  */
 public function getBuildInfo()
 {
     return $this->mainFormState->getBuildInfo();
 }
Example #16
0
 /**
  * {@inheritdoc}
  */
 public function prepareForm($form_id, &$form, FormStateInterface &$form_state)
 {
     $user = $this->currentUser();
     $form['#type'] = 'form';
     // Only update the action if it is not already set.
     if (!isset($form['#action'])) {
         $form['#action'] = $this->buildFormAction();
     }
     // Fix the form method, if it is 'get' in $form_state, but not in $form.
     if ($form_state->isMethodType('get') && !isset($form['#method'])) {
         $form['#method'] = 'get';
     }
     // Generate a new #build_id for this form, if none has been set already.
     // The form_build_id is used as key to cache a particular build of the form.
     // For multi-step forms, this allows the user to go back to an earlier
     // build, make changes, and re-submit.
     // @see self::buildForm()
     // @see self::rebuildForm()
     if (!isset($form['#build_id'])) {
         $form['#build_id'] = 'form-' . Crypt::randomBytesBase64();
     }
     $form['form_build_id'] = array('#type' => 'hidden', '#value' => $form['#build_id'], '#id' => $form['#build_id'], '#name' => 'form_build_id', '#parents' => array('form_build_id'));
     // Add a token, based on either #token or form_id, to any form displayed to
     // authenticated users. This ensures that any submitted form was actually
     // requested previously by the user and protects against cross site request
     // forgeries.
     // This does not apply to programmatically submitted forms. Furthermore,
     // since tokens are session-bound and forms displayed to anonymous users are
     // very likely cached, we cannot assign a token for them.
     // During installation, there is no $user yet.
     if ($user && $user->isAuthenticated() && !$form_state->isProgrammed()) {
         // Form constructors may explicitly set #token to FALSE when cross site
         // request forgery is irrelevant to the form, such as search forms.
         if (isset($form['#token']) && $form['#token'] === FALSE) {
             unset($form['#token']);
         } else {
             $form['#token'] = $form_id;
             $form['form_token'] = array('#id' => Html::getUniqueId('edit-' . $form_id . '-form-token'), '#type' => 'token', '#default_value' => $this->csrfToken->get($form['#token']), '#parents' => array('form_token'));
         }
     }
     if (isset($form_id)) {
         $form['form_id'] = array('#type' => 'hidden', '#value' => $form_id, '#id' => Html::getUniqueId("edit-{$form_id}"), '#parents' => array('form_id'));
     }
     if (!isset($form['#id'])) {
         $form['#id'] = Html::getUniqueId($form_id);
         // Provide a selector usable by JavaScript. As the ID is unique, its not
         // possible to rely on it in JavaScript.
         $form['#attributes']['data-drupal-selector'] = Html::getId($form_id);
     }
     $form += $this->elementInfo->getInfo('form');
     $form += array('#tree' => FALSE, '#parents' => array());
     $form['#validate'][] = '::validateForm';
     $form['#submit'][] = '::submitForm';
     $build_info = $form_state->getBuildInfo();
     // If no #theme has been set, automatically apply theme suggestions.
     // The form theme hook itself, which is rendered by form.html.twig,
     // is in #theme_wrappers. Therefore, the #theme function only has to care
     // for rendering the inner form elements, not the form itself.
     if (!isset($form['#theme'])) {
         $form['#theme'] = array($form_id);
         if (isset($build_info['base_form_id'])) {
             $form['#theme'][] = $build_info['base_form_id'];
         }
     }
     // Invoke hook_form_alter(), hook_form_BASE_FORM_ID_alter(), and
     // hook_form_FORM_ID_alter() implementations.
     $hooks = array('form');
     if (isset($build_info['base_form_id'])) {
         $hooks[] = 'form_' . $build_info['base_form_id'];
     }
     $hooks[] = 'form_' . $form_id;
     $this->moduleHandler->alter($hooks, $form, $form_state, $form_id);
     $this->themeManager->alter($hooks, $form, $form_state, $form_id);
 }
Example #17
0
 /**
  * {@inheritdoc}
  */
 public function prepareForm($form_id, &$form, FormStateInterface &$form_state)
 {
     $user = $this->currentUser();
     $form['#type'] = 'form';
     // Only update the action if it is not already set.
     if (!isset($form['#action'])) {
         // Instead of setting an actual action URL, we set the placeholder, which
         // will be replaced at the very last moment. This ensures forms with
         // dynamically generated action URLs don't have poor cacheability.
         // Use the proper API to generate the placeholder, when we have one. See
         // https://www.drupal.org/node/2562341.
         $placeholder = 'form_action_' . hash('crc32b', __METHOD__);
         $form['#attached']['placeholders'][$placeholder] = ['#lazy_builder' => ['form_builder:renderPlaceholderFormAction', []]];
         $form['#action'] = $placeholder;
     }
     // Fix the form method, if it is 'get' in $form_state, but not in $form.
     if ($form_state->isMethodType('get') && !isset($form['#method'])) {
         $form['#method'] = 'get';
     }
     // GET forms should not use a CSRF token.
     if (isset($form['#method']) && $form['#method'] === 'get') {
         // Merges in a default, this means if you've explicitly set #token to the
         // the $form_id on a GET form, which we don't recommend, it will work.
         $form += ['#token' => FALSE];
     }
     // Generate a new #build_id for this form, if none has been set already.
     // The form_build_id is used as key to cache a particular build of the form.
     // For multi-step forms, this allows the user to go back to an earlier
     // build, make changes, and re-submit.
     // @see self::buildForm()
     // @see self::rebuildForm()
     if (!isset($form['#build_id'])) {
         $form['#build_id'] = 'form-' . Crypt::randomBytesBase64();
     }
     $form['form_build_id'] = array('#type' => 'hidden', '#value' => $form['#build_id'], '#id' => $form['#build_id'], '#name' => 'form_build_id', '#parents' => array('form_build_id'));
     // Add a token, based on either #token or form_id, to any form displayed to
     // authenticated users. This ensures that any submitted form was actually
     // requested previously by the user and protects against cross site request
     // forgeries.
     // This does not apply to programmatically submitted forms. Furthermore,
     // since tokens are session-bound and forms displayed to anonymous users are
     // very likely cached, we cannot assign a token for them.
     // During installation, there is no $user yet.
     // Form constructors may explicitly set #token to FALSE when cross site
     // request forgery is irrelevant to the form, such as search forms.
     if ($form_state->isProgrammed() || isset($form['#token']) && $form['#token'] === FALSE) {
         unset($form['#token']);
     } else {
         $form['#cache']['contexts'][] = 'user.roles:authenticated';
         if ($user && $user->isAuthenticated()) {
             // Generate a public token based on the form id.
             $form['#token'] = $form_id;
             $form['form_token'] = array('#id' => Html::getUniqueId('edit-' . $form_id . '-form-token'), '#type' => 'token', '#default_value' => $this->csrfToken->get($form['#token']), '#parents' => array('form_token'), '#cache' => ['max-age' => 0]);
         }
     }
     if (isset($form_id)) {
         $form['form_id'] = array('#type' => 'hidden', '#value' => $form_id, '#id' => Html::getUniqueId("edit-{$form_id}"), '#parents' => array('form_id'));
     }
     if (!isset($form['#id'])) {
         $form['#id'] = Html::getUniqueId($form_id);
         // Provide a selector usable by JavaScript. As the ID is unique, its not
         // possible to rely on it in JavaScript.
         $form['#attributes']['data-drupal-selector'] = Html::getId($form_id);
     }
     $form += $this->elementInfo->getInfo('form');
     $form += array('#tree' => FALSE, '#parents' => array());
     $form['#validate'][] = '::validateForm';
     $form['#submit'][] = '::submitForm';
     $build_info = $form_state->getBuildInfo();
     // If no #theme has been set, automatically apply theme suggestions.
     // The form theme hook itself, which is rendered by form.html.twig,
     // is in #theme_wrappers. Therefore, the #theme function only has to care
     // for rendering the inner form elements, not the form itself.
     if (!isset($form['#theme'])) {
         $form['#theme'] = array($form_id);
         if (isset($build_info['base_form_id'])) {
             $form['#theme'][] = $build_info['base_form_id'];
         }
     }
     // Invoke hook_form_alter(), hook_form_BASE_FORM_ID_alter(), and
     // hook_form_FORM_ID_alter() implementations.
     $hooks = array('form');
     if (isset($build_info['base_form_id'])) {
         $hooks[] = 'form_' . $build_info['base_form_id'];
     }
     $hooks[] = 'form_' . $form_id;
     $this->moduleHandler->alter($hooks, $form, $form_state, $form_id);
     $this->themeManager->alter($hooks, $form, $form_state, $form_id);
 }
Example #18
0
 /**
  * Loads the cached form state.
  *
  * @param string $form_build_id
  *   The unique form build ID.
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The current state of the form.
  */
 protected function loadCachedFormState($form_build_id, FormStateInterface $form_state)
 {
     if ($stored_form_state = $this->keyValueExpirableFactory->get('form_state')->get($form_build_id)) {
         // Re-populate $form_state for subsequent rebuilds.
         $form_state->setFormState($stored_form_state);
         // If the original form is contained in include files, load the files.
         // @see \Drupal\Core\Form\FormStateInterface::loadInclude()
         $build_info = $form_state->getBuildInfo();
         $build_info += ['files' => []];
         foreach ($build_info['files'] as $file) {
             if (is_array($file)) {
                 $file += array('type' => 'inc', 'name' => $file['module']);
                 $this->moduleHandler->loadInclude($file['module'], $file['type'], $file['name']);
             } elseif (file_exists($file)) {
                 require_once $this->root . '/' . $file;
             }
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $view = $form_state->getBuildInfo()['args'][0];
     // Call the submit method on every field handler that has it.
     foreach ($view->field as $field) {
         if (method_exists($field, 'viewsFormSubmit')) {
             $field->viewsFormSubmit($form, $form_state);
         }
     }
     // Call the submit method on every area handler that has it.
     foreach (array('header', 'footer') as $area) {
         foreach ($view->{$area} as $area_handler) {
             if (method_exists($area_handler, 'viewsFormSubmit')) {
                 $area_handler->viewsFormSubmit($form, $form_state);
             }
         }
     }
 }
Example #20
0
/**
 * Implements hook_form_FORM_ID_alter().
 */
function bootstrap_form_system_theme_settings_alter(&$form, FormStateInterface $form_state, $form_id = NULL)
{
    // Do not add Bootstrap specific settings to non-bootstrap based themes,
    // including a work-around for a core bug affecting admin themes.
    // @see https://drupal.org/node/943212
    $args = $form_state->getBuildInfo()['args'];
    // Do not add Bootstrap specific settings to non-bootstrap based themes.
    $theme = !empty($args[0]) ? $args[0] : FALSE;
    if (isset($form_id) || $theme === FALSE || !in_array('bootstrap', _bootstrap_get_base_themes($theme, TRUE))) {
        return;
    }
    $form['bootstrap'] = array('#type' => 'vertical_tabs', '#attached' => array('library' => array('bootstrap/adminscript')), '#prefix' => '<h2><small>' . t('Bootstrap Settings') . '</small></h2>', '#weight' => -10);
    // General.
    $form['general'] = array('#type' => 'details', '#title' => t('General'), '#group' => 'bootstrap');
    // Container.
    $form['general']['container'] = array('#type' => 'fieldset', '#title' => t('Container'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['general']['container']['bootstrap_fluid_container'] = array('#type' => 'checkbox', '#title' => t('Fluid container'), '#default_value' => bootstrap_setting('fluid_container', $theme), '#description' => t('Use <code>.container-fluid</code> class. See <a href=":url">Fluid container</a>', array(':url' => 'http://getbootstrap.com/css/#grid-example-fluid')));
    // Buttons.
    $form['general']['buttons'] = array('#type' => 'details', '#title' => t('Buttons'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['general']['buttons']['bootstrap_button_size'] = array('#type' => 'select', '#title' => t('Default button size'), '#default_value' => bootstrap_setting('button_size', $theme), '#empty_option' => t('Normal'), '#options' => array('btn-xs' => t('Extra Small'), 'btn-sm' => t('Small'), 'btn-lg' => t('Large')));
    $form['general']['buttons']['bootstrap_button_colorize'] = array('#type' => 'checkbox', '#title' => t('Colorize Buttons'), '#default_value' => bootstrap_setting('button_colorize', $theme), '#description' => t('Adds classes to buttons based on their text value. See: <a href=":bootstrap_url" target="_blank">Buttons</a> and <a href=":api_url" target="_blank">hook_bootstrap_colorize_text_alter()</a>', array(':bootstrap_url' => 'http://getbootstrap.com/css/#buttons', ':api_url' => 'http://drupal-bootstrap.org/apis/hook_bootstrap_colorize_text_alter')));
    $form['general']['buttons']['bootstrap_button_iconize'] = array('#type' => 'checkbox', '#title' => t('Iconize Buttons'), '#default_value' => bootstrap_setting('button_iconize', $theme), '#description' => t('Adds icons to buttons based on the text value. See: <a href=":api_url" target="_blank">hook_bootstrap_iconize_text_alter()</a>', array(':api_url' => 'http://drupal-bootstrap.org/apis/hook_bootstrap_iconize_text_alter')));
    // Forms.
    $form['general']['forms'] = array('#type' => 'details', '#title' => t('Forms'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['general']['forms']['bootstrap_forms_required_has_error'] = array('#type' => 'checkbox', '#title' => t('Make required elements display as an error'), '#default_value' => bootstrap_setting('forms_required_has_error', $theme), '#description' => t('If an element in a form is required, enabling this will always display the element with a <code>.has-error</code> class. This turns the element red and helps in usability for determining which form elements are required to submit the form.  This feature compliments the "JavaScript > Forms > Automatically remove error classes when values have been entered" feature.'));
    $form['general']['forms']['bootstrap_forms_smart_descriptions'] = array('#type' => 'checkbox', '#title' => t('Smart form descriptions (via Tooltips)'), '#description' => t('Convert descriptions into tooltips (must be enabled) automatically based on certain criteria. This helps reduce the, sometimes unnecessary, amount of noise on a page full of form elements.'), '#default_value' => bootstrap_setting('forms_smart_descriptions', $theme));
    $form['general']['forms']['bootstrap_forms_smart_descriptions_limit'] = array('#type' => 'textfield', '#title' => t('"Smart form descriptions" maximum character limit'), '#description' => t('Prevents descriptions from becoming tooltips by checking the character length of the description (HTML is not counted towards this limit). To disable this filtering criteria, leave an empty value.'), '#default_value' => bootstrap_setting('forms_smart_descriptions_limit', $theme), '#states' => array('visible' => array(':input[name="bootstrap_forms_smart_descriptions"]' => array('checked' => TRUE))));
    $form['general']['forms']['bootstrap_forms_smart_descriptions_allowed_tags'] = array('#type' => 'textfield', '#title' => t('"Smart form descriptions" allowed (HTML) tags'), '#description' => t('Prevents descriptions from becoming tooltips by checking for HTML not in the list above (i.e. links). Separate by commas. To disable this filtering criteria, leave an empty value.'), '#default_value' => bootstrap_setting('forms_smart_descriptions_allowed_tags', $theme), '#states' => array('visible' => array(':input[name="bootstrap_forms_smart_descriptions"]' => array('checked' => TRUE))));
    // Images.
    $form['general']['images'] = array('#type' => 'details', '#title' => t('Images'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['general']['images']['bootstrap_image_shape'] = array('#type' => 'select', '#title' => t('Default image shape'), '#description' => t('Add classes to an <code>&lt;img&gt;</code> element to easily style images in any project. Note: Internet Explorer 8 lacks support for rounded corners. See: <a href=":bootstrap_url" target="_blank">Image Shapes</a>', array(':bootstrap_url' => 'http://getbootstrap.com/css/#images-shapes')), '#default_value' => bootstrap_setting('image_shape', $theme), '#empty_option' => t('None'), '#options' => array('img-rounded' => t('Rounded'), 'img-circle' => t('Circle'), 'img-thumbnail' => t('Thumbnail')));
    $form['general']['images']['bootstrap_image_responsive'] = array('#type' => 'checkbox', '#title' => t('Responsive Images'), '#default_value' => bootstrap_setting('image_responsive', $theme), '#description' => t('Images in Bootstrap 3 can be made responsive-friendly via the addition of the <code>.img-responsive</code> class. This applies <code>max-width: 100%;</code> and <code>height: auto;</code> to the image so that it scales nicely to the parent element.'));
    // Tables.
    $form['general']['tables'] = array('#type' => 'details', '#title' => t('Tables'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['general']['tables']['bootstrap_table_bordered'] = array('#type' => 'checkbox', '#title' => t('Bordered table'), '#default_value' => bootstrap_setting('table_bordered', $theme), '#description' => t('Add borders on all sides of the table and cells.'));
    $form['general']['tables']['bootstrap_table_condensed'] = array('#type' => 'checkbox', '#title' => t('Condensed table'), '#default_value' => bootstrap_setting('table_condensed', $theme), '#description' => t('Make tables more compact by cutting cell padding in half.'));
    $form['general']['tables']['bootstrap_table_hover'] = array('#type' => 'checkbox', '#title' => t('Hover rows'), '#default_value' => bootstrap_setting('table_hover', $theme), '#description' => t('Enable a hover state on table rows.'));
    $form['general']['tables']['bootstrap_table_striped'] = array('#type' => 'checkbox', '#title' => t('Striped rows'), '#default_value' => bootstrap_setting('table_striped', $theme), '#description' => t('Add zebra-striping to any table row within the <code>&lt;tbody&gt;</code>. <strong>Note:</strong> Striped tables are styled via the <code>:nth-child</code> CSS selector, which is not available in Internet Explorer 8.'));
    $form['general']['tables']['bootstrap_table_responsive'] = array('#type' => 'checkbox', '#title' => t('Responsive tables'), '#default_value' => bootstrap_setting('table_responsive', $theme), '#description' => t('Makes tables responsive by wrapping them in <code>.table-responsive</code> to make them scroll horizontally up to small devices (under 768px). When viewing on anything larger than 768px wide, you will not see any difference in these tables.'));
    // Components.
    $form['components'] = array('#type' => 'details', '#title' => t('Components'), '#group' => 'bootstrap');
    // Breadcrumbs.
    $form['components']['breadcrumbs'] = array('#type' => 'details', '#title' => t('Breadcrumbs'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['components']['breadcrumbs']['bootstrap_breadcrumb'] = array('#type' => 'select', '#title' => t('Breadcrumb visibility'), '#default_value' => bootstrap_setting('breadcrumb', $theme), '#options' => array(0 => t('Hidden'), 1 => t('Visible'), 2 => t('Only in admin areas')));
    $form['components']['breadcrumbs']['bootstrap_breadcrumb_home'] = array('#type' => 'checkbox', '#title' => t('Show "Home" breadcrumb link'), '#default_value' => bootstrap_setting('breadcrumb_home', $theme), '#description' => t('If your site has a module dedicated to handling breadcrumbs already, ensure this setting is enabled.'), '#states' => array('invisible' => array(':input[name="bootstrap_breadcrumb"]' => array('value' => 0))));
    $form['components']['breadcrumbs']['bootstrap_breadcrumb_title'] = array('#type' => 'checkbox', '#title' => t('Show current page title at end'), '#default_value' => bootstrap_setting('breadcrumb_title', $theme), '#description' => t('If your site has a module dedicated to handling breadcrumbs already, ensure this setting is disabled.'), '#states' => array('invisible' => array(':input[name="bootstrap_breadcrumb"]' => array('value' => 0))));
    // Navbar.
    $form['components']['navbar'] = array('#type' => 'details', '#title' => t('Navbar'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['components']['navbar']['bootstrap_navbar_position'] = array('#type' => 'select', '#title' => t('Navbar Position'), '#description' => t('Select your Navbar position.'), '#default_value' => bootstrap_setting('navbar_position', $theme), '#options' => array('static-top' => t('Static Top'), 'fixed-top' => t('Fixed Top'), 'fixed-bottom' => t('Fixed Bottom')), '#empty_option' => t('Normal'));
    $form['components']['navbar']['bootstrap_navbar_inverse'] = array('#type' => 'checkbox', '#title' => t('Inverse navbar style'), '#description' => t('Select if you want the inverse navbar style.'), '#default_value' => bootstrap_setting('navbar_inverse', $theme));
    // Region wells.
    $wells = array('' => t('None'), 'well' => t('.well (normal)'), 'well well-sm' => t('.well-sm (small)'), 'well well-lg' => t('.well-lg (large)'));
    $form['components']['region_wells'] = array('#type' => 'details', '#title' => t('Region wells'), '#description' => t('Enable the <code>.well</code>, <code>.well-sm</code> or <code>.well-lg</code> classes for specified regions. See: documentation on <a href=":wells" target="_blank">Bootstrap Wells</a>.', array(':wells' => 'http://getbootstrap.com/components/#wells')), '#collapsible' => TRUE, '#collapsed' => TRUE);
    // Get defined regions.
    $regions = system_region_list('bootstrap');
    foreach ($regions as $name => $title) {
        $form['components']['region_wells']['bootstrap_region_well-' . $name] = array('#title' => $title, '#type' => 'select', '#attributes' => array('class' => array('input-sm')), '#options' => $wells, '#default_value' => bootstrap_setting('region_well-' . $name, $theme));
    }
    // JavaScript settings.
    $form['javascript'] = array('#type' => 'details', '#title' => t('JavaScript'), '#group' => 'bootstrap');
    // Anchors.
    $form['javascript']['anchors'] = array('#type' => 'details', '#title' => t('Anchors'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#description' => t('This plugin is not able to be configured from the UI as it is severely broken. In an effort to balance not break backwards compatibility and to prevent new users from running into unforeseen issues, you must manually opt-in/out inside your theme\'s setting configuration file. Please see the following issue for more details: <a href=":url" target="_blank">Replace custom JS with the bootstrap-anchor plugin</a>', array(':url' => 'https://www.drupal.org/node/2462645')));
    $form['javascript']['anchors']['bootstrap_anchors_fix'] = array('#type' => 'checkbox', '#title' => t('Fix anchor positions'), '#default_value' => bootstrap_setting('anchors_fix', $theme), '#description' => t('Ensures anchors are correctly positioned only when there is margin or padding detected on the BODY element. This is useful when fixed navbar or administration menus are used.'), '#disabled' => TRUE);
    $form['javascript']['anchors']['bootstrap_anchors_smooth_scrolling'] = array('#type' => 'checkbox', '#title' => t('Enable smooth scrolling'), '#default_value' => bootstrap_setting('anchors_smooth_scrolling', $theme), '#description' => t('Animates page by scrolling to an anchor link target smoothly when clicked.'), '#states' => array('invisible' => array(':input[name="bootstrap_anchors_fix"]' => array('checked' => FALSE))), '#disabled' => TRUE);
    // Forms.
    $form['javascript']['forms'] = array('#type' => 'details', '#title' => t('Forms'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['javascript']['forms']['bootstrap_forms_has_error_value_toggle'] = array('#type' => 'checkbox', '#title' => t('Automatically remove error classes when values have been entered'), '#default_value' => bootstrap_setting('forms_has_error_value_toggle', $theme), '#description' => t('If an element has a <code>.has-error</code> class attached to it, enabling this will automatically remove that class when a value is entered. This feature compliments the "General > Forms > Make required elements display as an error" feature.'));
    // Popovers.
    $form['javascript']['popovers'] = array('#type' => 'details', '#title' => t('Popovers'), '#description' => t('Add small overlays of content, like those on the iPad, to any element for housing secondary information.'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['javascript']['popovers']['bootstrap_popover_enabled'] = array('#type' => 'checkbox', '#title' => t('Enable popovers.'), '#description' => t('Elements that have the <code>data-toggle="popover"</code> attribute set will automatically initialize the popover upon page load. <strong class="error text-error">WARNING: This feature can sometimes impact performance. Disable if pages appear to "hang" after initial load.</strong>'), '#default_value' => bootstrap_setting('popover_enabled', $theme));
    $form['javascript']['popovers']['options'] = array('#type' => 'details', '#title' => t('Options'), '#description' => t('These are global options. Each popover can independently override desired settings by appending the option name to <code>data-</code>. Example: <code>data-animation="false"</code>.'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#states' => array('visible' => array(':input[name="bootstrap_popover_enabled"]' => array('checked' => TRUE))));
    $form['javascript']['popovers']['options']['bootstrap_popover_animation'] = array('#type' => 'checkbox', '#title' => t('animate'), '#description' => t('Apply a CSS fade transition to the popover.'), '#default_value' => bootstrap_setting('popover_animation', $theme));
    $form['javascript']['popovers']['options']['bootstrap_popover_html'] = array('#type' => 'checkbox', '#title' => t('HTML'), '#description' => t("Insert HTML into the popover. If false, jQuery's text method will be used to insert content into the DOM. Use text if you're worried about XSS attacks."), '#default_value' => bootstrap_setting('popover_html', $theme));
    $options = array('top', 'bottom', 'left', 'right', 'auto', 'auto top', 'auto bottom', 'auto left', 'auto right');
    $form['javascript']['popovers']['options']['bootstrap_popover_placement'] = array('#type' => 'select', '#title' => t('placement'), '#description' => t('Where to position the popover. When "auto" is specified, it will dynamically reorient the popover. For example, if placement is "auto left", the popover will display to the left when possible, otherwise it will display right.'), '#default_value' => bootstrap_setting('popover_placement', $theme), '#options' => array_combine($options, $options));
    $form['javascript']['popovers']['options']['bootstrap_popover_selector'] = array('#type' => 'textfield', '#title' => t('selector'), '#description' => t('If a selector is provided, tooltip objects will be delegated to the specified targets. In practice, this is used to enable dynamic HTML content to have popovers added. See <a href=":this" target="_blank">this</a> and <a href=":example" target="_blank">an informative example</a>.', array(':this' => 'https://github.com/twbs/bootstrap/issues/4215', ':example' => 'http://jsfiddle.net/fScua/')), '#default_value' => bootstrap_setting('popover_selector', $theme));
    $options = array('click', 'hover', 'focus', 'manual');
    $form['javascript']['popovers']['options']['bootstrap_popover_trigger'] = array('#type' => 'checkboxes', '#title' => t('trigger'), '#description' => t('How a popover is triggered.'), '#default_value' => bootstrap_setting('popover_trigger', $theme), '#options' => array_combine($options, $options));
    $form['javascript']['popovers']['options']['bootstrap_popover_trigger_autoclose'] = array('#type' => 'checkbox', '#title' => t('Auto-close on document click'), '#description' => t('Will automatically close the current popover if a click occurs anywhere else other than the popover element.'), '#default_value' => bootstrap_setting('popover_trigger_autoclose', $theme));
    $form['javascript']['popovers']['options']['bootstrap_popover_title'] = array('#type' => 'textfield', '#title' => t('title'), '#description' => t("Default title value if \"title\" attribute isn't present."), '#default_value' => bootstrap_setting('popover_title', $theme));
    $form['javascript']['popovers']['options']['bootstrap_popover_content'] = array('#type' => 'textfield', '#title' => t('content'), '#description' => t('Default content value if "data-content" or "data-target" attributes are not present.'), '#default_value' => bootstrap_setting('popover_content', $theme));
    $form['javascript']['popovers']['options']['bootstrap_popover_delay'] = array('#type' => 'textfield', '#title' => t('delay'), '#description' => t('The amount of time to delay showing and hiding the popover (in milliseconds). Does not apply to manual trigger type.'), '#default_value' => bootstrap_setting('popover_delay', $theme));
    $form['javascript']['popovers']['options']['bootstrap_popover_container'] = array('#type' => 'textfield', '#title' => t('container'), '#description' => t('Appends the popover to a specific element. Example: "body". This option is particularly useful in that it allows you to position the popover in the flow of the document near the triggering element - which will prevent the popover from floating away from the triggering element during a window resize.'), '#default_value' => bootstrap_setting('popover_container', $theme));
    // Tooltips.
    $form['javascript']['tooltips'] = array('#type' => 'details', '#title' => t('Tooltips'), '#description' => t('Inspired by the excellent jQuery.tipsy plugin written by Jason Frame; Tooltips are an updated version, which don\'t rely on images, use CSS3 for animations, and data-attributes for local title storage. See <a href=":url" target="_blank">Bootstrap tooltips</a> for more documentation.', array(':url' => 'http://getbootstrap.com/javascript/#tooltips')), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['javascript']['tooltips']['bootstrap_tooltip_enabled'] = array('#type' => 'checkbox', '#title' => t('Enable tooltips'), '#description' => t('Elements that have the <code>data-toggle="tooltip"</code> attribute set will automatically initialize the tooltip upon page load. <strong class="error text-error">WARNING: This feature can sometimes impact performance. Disable if pages appear to "hang" after initial load.</strong>'), '#default_value' => bootstrap_setting('tooltip_enabled', $theme));
    $form['javascript']['tooltips']['options'] = array('#type' => 'details', '#title' => t('Options'), '#description' => t('These are global options. Each tooltip can independently override desired settings by appending the option name to <code>data-</code>. Example: <code>data-animation="false"</code>.'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#states' => array('visible' => array(':input[name="bootstrap_tooltip_enabled"]' => array('checked' => TRUE))));
    $form['javascript']['tooltips']['options']['bootstrap_tooltip_animation'] = array('#type' => 'checkbox', '#title' => t('animate'), '#description' => t('Apply a CSS fade transition to the tooltip.'), '#default_value' => bootstrap_setting('tooltip_animation', $theme));
    $form['javascript']['tooltips']['options']['bootstrap_tooltip_html'] = array('#type' => 'checkbox', '#title' => t('HTML'), '#description' => t("Insert HTML into the tooltip. If false, jQuery's text method will be used to insert content into the DOM. Use text if you're worried about XSS attacks."), '#default_value' => bootstrap_setting('tooltip_html', $theme));
    $options = array('top', 'bottom', 'left', 'right', 'auto', 'auto top', 'auto bottom', 'auto left', 'auto right');
    $form['javascript']['tooltips']['options']['bootstrap_tooltip_placement'] = array('#type' => 'select', '#title' => t('placement'), '#description' => t('Where to position the tooltip. When "auto" is specified, it will dynamically reorient the tooltip. For example, if placement is "auto left", the tooltip will display to the left when possible, otherwise it will display right.'), '#default_value' => bootstrap_setting('tooltip_placement', $theme), '#options' => array_combine($options, $options));
    $form['javascript']['tooltips']['options']['bootstrap_tooltip_selector'] = array('#type' => 'textfield', '#title' => t('selector'), '#description' => t('If a selector is provided, tooltip objects will be delegated to the specified targets.'), '#default_value' => bootstrap_setting('tooltip_selector', $theme));
    $options = array('click', 'hover', 'focus', 'manual');
    $form['javascript']['tooltips']['options']['bootstrap_tooltip_trigger'] = array('#type' => 'checkboxes', '#title' => t('trigger'), '#description' => t('How a tooltip is triggered.'), '#default_value' => bootstrap_setting('tooltip_trigger', $theme), '#options' => array_combine($options, $options));
    $form['javascript']['tooltips']['options']['bootstrap_tooltip_delay'] = array('#type' => 'textfield', '#title' => t('delay'), '#description' => t('The amount of time to delay showing and hiding the tooltip (in milliseconds). Does not apply to manual trigger type.'), '#default_value' => bootstrap_setting('tooltip_delay', $theme));
    $form['javascript']['tooltips']['options']['bootstrap_tooltip_container'] = array('#type' => 'textfield', '#title' => t('container'), '#description' => t('Appends the tooltip to a specific element. Example: "body"'), '#default_value' => bootstrap_setting('tooltip_container', $theme));
    // Advanced settings.
    $form['advanced'] = array('#type' => 'details', '#title' => t('Advanced'), '#group' => 'bootstrap');
    // BootstrapCDN.
    bootstrap_cdn_provider_settings_form($form, $form_state, $theme);
}
Example #21
0
 /**
  * Loads the cached form state.
  *
  * @param string $form_build_id
  *   The unique form build ID.
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The current state of the form.
  */
 protected function loadCachedFormState($form_build_id, FormStateInterface $form_state)
 {
     if ($stored_form_state = $this->keyValueExpirableFactory->get('form_state')->get($form_build_id)) {
         // Re-populate $form_state for subsequent rebuilds.
         $form_state->setFormState($stored_form_state);
         // If the original form is contained in include files, load the files.
         // @see \Drupal\Core\Form\FormStateInterface::loadInclude()
         $build_info = $form_state->getBuildInfo();
         $build_info += ['files' => []];
         foreach ($build_info['files'] as $file) {
             if (is_array($file)) {
                 $file += array('type' => 'inc', 'name' => $file['module']);
                 $this->moduleHandler->loadInclude($file['module'], $file['type'], $file['name']);
             } elseif (file_exists($file)) {
                 require_once $this->root . '/' . $file;
             }
         }
         // Retrieve the list of previously known safe strings and store it for
         // this request.
         // @todo Ensure we are not storing an excessively large string list
         //   in: https://www.drupal.org/node/2295823
         $build_info += ['safe_strings' => []];
         SafeMarkup::setMultiple($build_info['safe_strings']);
         unset($build_info['safe_strings']);
         $form_state->setBuildInfo($build_info);
     }
 }
 /**
  * @covers ::getBuildInfo
  */
 public function testGetBuildInfo()
 {
     $build_info = ['FOO' => 'BAR'];
     $this->decoratedFormState->getBuildInfo()->willReturn($build_info)->shouldBeCalled();
     $this->assertSame($build_info, $this->formStateDecoratorBase->getBuildInfo());
 }