ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ParagraphStyleSelector.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2020 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
6 
12 {
13  public static $style_selector_reset = "margin-top:2px; margin-bottom:2px; text-indent:0px; position:static; float:none; width: auto;";
14 
18  protected $ui_wrapper;
19 
23  protected $ui;
24 
28  public function __construct($ui_wrapper, $style_id)
29  {
30  global $DIC;
31 
32  $this->ui = $DIC->ui();
33  $this->ui_wrapper = $ui_wrapper;
34  $this->style_id = $style_id;
35  }
36 
40  public function getStyleSelector($a_selected, $type = "par-action", $action = "par.class", $attr = "class")
41  {
42  $a_chars = \ilPCParagraphGUI::_getCharacteristics($this->style_id);
44  $ui = $this->ui;
45  $buttons = [];
46  foreach ($a_chars as $char => $char_lang) {
47  $t = "text_block";
48  $tag = "div";
49  switch ($char) {
50  case "Headline1": $t = "heading1"; $tag = "h1"; break;
51  case "Headline2": $t = "heading2"; $tag = "h2"; break;
52  case "Headline3": $t = "heading3"; $tag = "h3"; break;
53  }
54  $html = '<div class="ilCOPgEditStyleSelectionItem"><' . $tag . ' class="ilc_' . $t . '_' . $char . '" style="' . self::$style_selector_reset . '">' . $char_lang . "</" . $tag . "></div>";
55  $buttons[] = $ui_wrapper->getButton($html, $type, $action, [$attr => $char]);
56  }
57  $dd = $ui->factory()->dropdown()->standard($buttons)->withLabel($a_selected);
58  return $dd;
59  }
60 }
$type
static _getCharacteristics($a_style_id)
Get characteristics.
getStyleSelector($a_selected, $type="par-action", $action="par.class", $attr="class")
Get style selector.
global $DIC
Definition: goto.php:24
ui()
Definition: ui.php:5