Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / views / src / Plugin / views / style / HtmlList.php
1 <?php
2
3 namespace Drupal\views\Plugin\views\style;
4
5 use Drupal\Core\Form\FormStateInterface;
6
7 /**
8  * Style plugin to render each item in an ordered or unordered list.
9  *
10  * @ingroup views_style_plugins
11  *
12  * @ViewsStyle(
13  *   id = "html_list",
14  *   title = @Translation("HTML List"),
15  *   help = @Translation("Displays rows as HTML list."),
16  *   theme = "views_view_list",
17  *   display_types = {"normal"}
18  * )
19  */
20 class HtmlList extends StylePluginBase {
21
22   /**
23    * {@inheritdoc}
24    */
25   protected $usesRowPlugin = TRUE;
26
27   /**
28    * Does the style plugin support custom css class for the rows.
29    *
30    * @var bool
31    */
32   protected $usesRowClass = TRUE;
33
34   /**
35    * Set default options
36    */
37   protected function defineOptions() {
38     $options = parent::defineOptions();
39
40     $options['type'] = ['default' => 'ul'];
41     $options['class'] = ['default' => ''];
42     $options['wrapper_class'] = ['default' => 'item-list'];
43
44     return $options;
45   }
46
47   /**
48    * Render the given style.
49    */
50   public function buildOptionsForm(&$form, FormStateInterface $form_state) {
51     parent::buildOptionsForm($form, $form_state);
52     $form['type'] = [
53       '#type' => 'radios',
54       '#title' => $this->t('List type'),
55       '#options' => ['ul' => $this->t('Unordered list'), 'ol' => $this->t('Ordered list')],
56       '#default_value' => $this->options['type'],
57     ];
58     $form['wrapper_class'] = [
59       '#title' => $this->t('Wrapper class'),
60       '#description' => $this->t('The class to provide on the wrapper, outside the list.'),
61       '#type' => 'textfield',
62       '#size' => '30',
63       '#default_value' => $this->options['wrapper_class'],
64     ];
65     $form['class'] = [
66       '#title' => $this->t('List class'),
67       '#description' => $this->t('The class to provide on the list element itself.'),
68       '#type' => 'textfield',
69       '#size' => '30',
70       '#default_value' => $this->options['class'],
71     ];
72   }
73
74 }