Ejemplo n.º 1
0
  /**
   * Add settings for the ui.
   */
  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form, $form_state);

    $form['disable_sql_rewrite'] = array(
      '#title' => $this->t('Disable SQL rewriting'),
      '#description' => $this->t('Disabling SQL rewriting will omit all query tags, i. e. disable node access checks as well as override hook_query_alter() implementations in other modules.'),
      '#type' => 'checkbox',
      '#default_value' => !empty($this->options['disable_sql_rewrite']),
      '#suffix' => '<div class="messages messages--warning sql-rewrite-warning js-hide">' . $this->t('WARNING: Disabling SQL rewriting means that node access security is disabled. This may allow users to see data they should not be able to see if your view is misconfigured. Use this option only if you understand and accept this security risk.') . '</div>',
    );
    $form['distinct'] = array(
      '#type' => 'checkbox',
      '#title' => $this->t('Distinct'),
      '#description' => $this->t('This will make the view display only distinct items. If there are multiple identical items, each will be displayed only once. You can use this to try and remove duplicates from a view, though it does not always work. Note that this can slow queries down, so use it with caution.'),
      '#default_value' => !empty($this->options['distinct']),
    );
    $form['replica'] = array(
      '#type' => 'checkbox',
      '#title' => $this->t('Use Secondary Server'),
      '#description' => $this->t('This will make the query attempt to connect to a replica server if available.  If no replica server is defined or available, it will fall back to the default server.'),
      '#default_value' => !empty($this->options['replica']),
    );
    $form['query_comment'] = array(
      '#type' => 'textfield',
      '#title' => $this->t('Query Comment'),
      '#description' => $this->t('If set, this comment will be embedded in the query and passed to the SQL server. This can be helpful for logging or debugging.'),
      '#default_value' => $this->options['query_comment'],
    );
    $form['query_tags'] = array(
      '#type' => 'textfield',
      '#title' => $this->t('Query Tags'),
      '#description' => $this->t('If set, these tags will be appended to the query and can be used to identify the query in a module. This can be helpful for altering queries.'),
      '#default_value' => implode(', ', $this->options['query_tags']),
      '#element_validate' => array('views_element_validate_tags'),
    );
  }
Ejemplo n.º 2
0
 /**
  * Implements \Drupal\views\Plugin\views\query\QueryPluginBase::buildOptionsForm().
  */
 public function buildOptionsForm(&$form, &$form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     $form['test_setting'] = array('#title' => t('Test setting'), '#type' => 'textfield', '#default_value' => $this->options['test_setting']);
 }
Ejemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     $form['bypass_access'] = array('#type' => 'checkbox', '#title' => $this->t('Bypass access checks'), '#description' => $this->t('If the underlying search index has access checks enabled (e.g., through the "Content access" processor), this option allows you to disable them for this view. This will never disable any filters placed on this view.'), '#default_value' => $this->options['bypass_access']);
     if ($this->getEntityTypes(TRUE)) {
         $form['skip_access'] = array('#type' => 'checkbox', '#title' => $this->t('Skip entity access checks'), '#description' => $this->t("By default, an additional access check will be executed for each entity returned by the search query. However, since removing results this way will break paging and result counts, it is preferable to configure the view in a way that it will only return accessible results. If you are sure that only accessible results will be returned in the search, or if you want to show results to which the user normally wouldn't have access, you can enable this option to skip those additional access checks. This should be used with care."), '#default_value' => $this->options['skip_access'], '#weight' => -1);
         $form['bypass_access']['#states']['visible'][':input[name="query[options][skip_access]"]']['checked'] = TRUE;
     }
     // @todo Move this setting to the argument and filter plugins where it makes
     //   more sense for users.
     $form['parse_mode'] = array('#type' => 'select', '#title' => $this->t('Parse mode'), '#description' => $this->t('Choose how the search keys will be parsed.'), '#options' => array(), '#default_value' => $this->options['parse_mode']);
     foreach ($this->query->parseModes() as $key => $mode) {
         $form['parse_mode']['#options'][$key] = $mode['name'];
         if (!empty($mode['description'])) {
             $states['visible'][':input[name="query[options][parse_mode]"]']['value'] = $key;
             $form["parse_mode_{$key}_description"] = array('#type' => 'item', '#title' => $mode['name'], '#description' => $mode['description'], '#states' => $states);
         }
     }
 }
Ejemplo n.º 4
0
  /**
   * {@inheritdoc}
   */
  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form, $form_state);

    $form['search_api_bypass_access'] = array(
      '#type' => 'checkbox',
      '#title' => $this->t('Bypass access checks'),
      '#description' => $this->t('If the underlying search index has access checks enabled, this option allows you to disable them for this view.'),
      '#default_value' => $this->options['search_api_bypass_access'],
    );

    if ($this->getEntityTypes(TRUE)) {
      $form['entity_access'] = array(
        '#type' => 'checkbox',
        '#title' => $this->t('Additional access checks on result entities'),
        '#description' => $this->t("Execute an access check for all result entities. This prevents users from seeing inappropriate content when the index contains stale data, or doesn't provide access checks. However, result counts, paging and other things won't work correctly if results are eliminated in this way, so only use this as a last ressort (and in addition to other checks, if possible)."),
        '#default_value' => $this->options['entity_access'],
      );
    }

    // @todo Move this setting to the argument and filter plugins where it makes
    //   more sense for users.
    $form['parse_mode'] = array(
      '#type' => 'select',
      '#title' => $this->t('Parse mode'),
      '#description' => $this->t('Choose how the search keys will be parsed.'),
      '#options' => array(),
      '#default_value' => $this->options['parse_mode'],
    );
    foreach ($this->query->parseModes() as $key => $mode) {
      $form['parse_mode']['#options'][$key] = $mode['name'];
      if (!empty($mode['description'])) {
        $states['visible'][':input[name="query[options][parse_mode]"]']['value'] = $key;
        $form["parse_mode_{$key}_description"] = array(
          '#type' => 'item',
          '#title' => $mode['name'],
          '#description' => $mode['description'],
          '#states' => $states,
        );
      }
    }
  }