ILIAS  release_7 Revision v7.30-3-g800a261c036
class.SectionStyleSelector.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 protected $lng;
29
33 public function __construct($ui_wrapper, $style_id)
34 {
35 global $DIC;
36
37 $this->ui = $DIC->ui();
38 $this->ui_wrapper = $ui_wrapper;
39 $this->style_id = $style_id;
40 $this->lng = $DIC->language();
41 }
42
46 public function getStyleSelector($a_selected, $type = "sec-action", $action = "sec.class", $attr = "class", $include_none = false)
47 {
48 $a_chars = \ilPCSectionGUI::_getCharacteristics($this->style_id);
50 $ui = $this->ui;
52
53 $buttons = [];
54 if ($include_none) {
55 $t = "section";
56 $tag = "div";
57 $html = '<div class="ilCOPgEditStyleSelectionItem"><' . $tag . ' class="" style="' . self::$style_selector_reset . '">' . $lng->txt("cont_none") . "</" . $tag . "></div>";
58 $buttons[] = $ui_wrapper->getButton($html, $type, $action, [$attr => ""]);
59 }
60 foreach ($a_chars as $char => $char_lang) {
61 $t = "section";
62 $tag = "div";
63 $html = '<div class="ilCOPgEditStyleSelectionItem"><' . $tag . ' class="ilc_' . $t . '_' . $char . '" style="' . self::$style_selector_reset . '">' . $char_lang . "</" . $tag . "></div>";
64 $buttons[] = $ui_wrapper->getButton($html, $type, $action, [$attr => $char]);
65 }
66 $dd = $ui->factory()->dropdown()->standard($buttons)->withLabel($a_selected);
67 return $dd;
68 }
69}
An exception for terminatinating execution or to throw for unit testing.
getStyleSelector($a_selected, $type="sec-action", $action="sec.class", $attr="class", $include_none=false)
Get style selector.
static _getCharacteristics($a_style_id)
Get characteristics.
global $DIC
Definition: goto.php:24
$type
ui()
Definition: ui.php:5