ILIAS  trunk Revision v11.0_alpha-1753-gb21ca8c4367
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ParagraphStyleSelector.php
Go to the documentation of this file.
1 <?php
2 
21 
26 {
27  public static string $style_selector_reset = "margin-top:2px; margin-bottom:2px; text-indent:0px; position:static; float:none; width: auto;";
28  protected int $style_id = 0;
29 
31  protected \ILIAS\DI\UIServices $ui;
32 
33  public function __construct(
34  UIWrapper $ui_wrapper,
35  int $style_id
36  ) {
37  global $DIC;
38 
39  $this->ui = $DIC->ui();
40  $this->ui_wrapper = $ui_wrapper;
41  $this->style_id = $style_id;
42  }
43 
47  public function getStyleSelector(
48  string $a_selected,
49  string $type = "par-action",
50  string $action = "par.class",
51  string $attr = "class"
52  ): Dropdown {
53  $a_chars = \ilPCParagraphGUI::_getCharacteristics($this->style_id);
54  $ui_wrapper = $this->ui_wrapper;
55  $ui = $this->ui;
56  $buttons = [];
57  foreach ($a_chars as $char => $char_lang) {
58  $t = "text_block";
59  $tag = "p";
60  switch ($char) {
61  case "Headline1": $t = "heading1";
62  $tag = "h1";
63  break;
64  case "Headline2": $t = "heading2";
65  $tag = "h2";
66  break;
67  case "Headline3": $t = "heading3";
68  $tag = "h3";
69  break;
70  }
71  $html = '<div class="ilCOPgEditStyleSelectionItem"><' . $tag . ' class="ilc_' . $t . '_' . $char . '" style="' . self::$style_selector_reset . '">' . $char_lang . "</" . $tag . "></div>";
72  $buttons[] = $ui_wrapper->getButton($html, $type, $action, [$attr => $char]);
73  }
74  $dd = $ui->factory()->dropdown()->standard($buttons)->withLabel($a_selected);
75  return $dd;
76  }
77 }
getStyleSelector(string $a_selected, string $type="par-action", string $action="par.class", string $attr="class")
Get style selector.
getButton(string $content, string $type, string $action, ?array $data=null, string $component="", bool $primary=false, string $aria_label="")
This describes commonalities between all types of Dropdowns.
Definition: Dropdown.php:34
__construct(UIWrapper $ui_wrapper, int $style_id)
global $DIC
Definition: shib_login.php:22
static _getCharacteristics(int $a_style_id)
Get characteristics.