ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ILIAS\Style\Content\Style\CSSBuilder Class Reference
+ Collaboration diagram for ILIAS\Style\Content\Style\CSSBuilder:

Public Member Functions

 __construct (protected \ilObjStyleSheet $style, protected string $image_dir)
 
 getCss ()
 

Detailed Description

Definition at line 23 of file CSSBuilder.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Style\Content\Style\CSSBuilder::__construct ( protected \ilObjStyleSheet  $style,
protected string  $image_dir 
)

Definition at line 25 of file CSSBuilder.php.

28 {
29
30 }

Member Function Documentation

◆ getCss()

ILIAS\Style\Content\Style\CSSBuilder::getCss ( )

Definition at line 32 of file CSSBuilder.php.

32 : string
33 {
34 $style = $this->style->getStyle();
35 $css = "";
36 $page_background = "";
37
38 $mqs = array(array("mquery" => "", "id" => 0));
39 foreach ($this->style->getMediaQueries() as $mq) {
40 $mqs[] = $mq;
41 }
42 // iterate all media queries
43 foreach ($mqs as $mq) {
44 if ($mq["id"] > 0) {
45 $css .= "@media " . $mq["mquery"] . " {\n";
46 }
47 reset($style);
48 foreach ($style as $tag) {
49 if ($tag[0]["mq_id"] != $mq["id"]) {
50 continue;
51 }
52 if (is_int(strpos($tag[0]["class"], "before")) && !is_int(strpos($tag[0]["class"], "::before"))) {
53 $tag[0]["class"] = str_replace(":before", "::before", $tag[0]["class"]);
54 }
55 $css .= $tag[0]["tag"] . ".ilc_" . $tag[0]["type"] . "_" . $tag[0]["class"] . "\n";
56 // echo "<br>";
57 // var_dump($tag[0]["type"]);
58 if ($tag[0]["tag"] == "td") {
59 $css .= ",th" . ".ilc_" . $tag[0]["type"] . "_" . $tag[0]["class"] . "\n";
60 }
61 if (in_array($tag[0]["tag"], array("h1", "h2", "h3"))) {
62 $css .= ",div.ilc_text_block_" . $tag[0]["class"] . "\n";
63 $css .= ",html.il-no-tiny-bg body#tinymce.ilc_text_block_" . $tag[0]["class"] . "\n";
64 }
65 if ($tag[0]["type"] == "section") { // sections can use a tags, if links are used
66 $css .= ",a.ilc_" . $tag[0]["type"] . "_" . $tag[0]["class"] . "\n";
67 }
68 if ($tag[0]["type"] == "strong") {
69 $css .= ",span.ilc_text_inline_" . $tag[0]["class"] . "\n";
70 }
71 if ($tag[0]["type"] == "em") {
72 $css .= ",span.ilc_text_inline_" . $tag[0]["class"] . "\n";
73 }
74 if ($tag[0]["type"] == "text_block") {
75 $css .= ",html.il-no-tiny-bg body#tinymce.ilc_text_block_" . $tag[0]["class"] . "\n";
76 }
77 if ($tag[0]["class"] == "VAccordCntr" &&
78 $this->style->hasCharacteristic("va_cntr", "VAccordCntr")) {
79 $css .= ",div.ilc_va_cntr_AccordCntr\n";
80 }
81 if ($tag[0]["class"] == "VAccordICntr" &&
82 $this->style->hasCharacteristic("va_icntr", "VAccordICntr")) {
83 $css .= ",div.ilc_va_icntr_AccordICntr\n";
84 }
85 if ($tag[0]["class"] == "VAccordICont" &&
86 $this->style->hasCharacteristic("va_icont", "VAccordICont")) {
87 $css .= ",div.ilc_va_icont_AccordICont\n";
88 }
89 if ($tag[0]["class"] == "VAccordIHead" &&
90 $this->style->hasCharacteristic("va_ihead", "VAccordIHead")) {
91 $css .= ",div.ilc_va_ihead_AccordIHead\n";
92 }
93 if ($tag[0]["class"] == "VAccordIHead:hover" &&
94 $this->style->hasCharacteristic("va_ihead", "VAccordIHead")) {
95 $css .= ",div.ilc_va_ihead_AccordIHead:hover\n";
96 }
97 if ($tag[0]["class"] == "VAccordIHeadActive" &&
98 $this->style->hasCharacteristic("va_iheada", "VAccordIHeadActive")) {
99 $css .= ",div.ilc_va_iheada_AccordIHeadActive\n";
100 }
101 if ($tag[0]["class"] == "VAccordIHeadActive:hover" &&
102 $this->style->hasCharacteristic("va_iheada", "VAccordIHeadActive")) {
103 $css .= ",div.ilc_va_iheada_AccordIHeadActive:hover\n";
104 }
105 $css .= "{\n";
106
107 // collect table border attributes
108 $t_border = array();
109
110 foreach ($tag as $par) {
111 $cur_par = $par["parameter"];
112 $cur_val = $par["value"];
113
114 // replace named colors
115 if (is_int(strpos($cur_par, "color")) && substr(trim($cur_val), 0, 1) == "!") {
116 $cur_val = $this->style->getColorCodeForName(substr($cur_val, 1));
117 }
118
119 if ($tag[0]["type"] == "table" && is_int(strpos($par["parameter"], "border"))) {
120 $t_border[$cur_par] = $cur_val;
121 }
122
123 if (in_array($cur_par, array("background-image", "list-style-image"))) {
124 if (is_int(strpos($cur_val, "/"))) { // external
125 $cur_val = "url('" . $cur_val . "')";
126 } else { // internal
127 if ($this->image_dir == "") {
128 $cur_val = "url('images/" . $cur_val . "')";
129 } else {
130 $cur_val = "url('" . $this->image_dir . "/" . $cur_val . "')";
131 }
132 }
133 }
134
135 if ($cur_par == "opacity") {
136 $cur_val = ((int) $cur_val) / 100;
137 }
138
139 $css .= "\t" . $cur_par . ": " . $cur_val . ";\n";
140
141 // opacity fix
142 if ($cur_par == "opacity") {
143 $css .= "\t" . '-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=' . ($cur_val * 100) . ')"' . ";\n";
144 $css .= "\t" . 'filter: alpha(opacity=' . ($cur_val * 100) . ')' . ";\n";
145 $css .= "\t" . '-moz-opacity: ' . $cur_val . ";\n";
146 }
147
148 // transform fix
149 if ($cur_par == "transform") {
150 $css .= "\t" . '-webkit-transform: ' . $cur_val . ";\n";
151 $css .= "\t" . '-moz-transform: ' . $cur_val . ";\n";
152 $css .= "\t" . '-ms-transform: ' . $cur_val . ";\n";
153 }
154
155 // transform-origin fix
156 if ($cur_par == "transform-origin") {
157 $css .= "\t" . '-webkit-transform-origin: ' . $cur_val . ";\n";
158 $css .= "\t" . '-moz-transform-origin: ' . $cur_val . ";\n";
159 $css .= "\t" . '-ms-transform-origin: ' . $cur_val . ";\n";
160 }
161
162 // save page background
163 if ($tag[0]["tag"] == "div" && $tag[0]["class"] == "Page"
164 && $cur_par == "background-color") {
165 $page_background = $cur_val;
166 }
167 }
168 $css .= "}\n";
169 $css .= "\n";
170 }
171
172 if ($page_background != "") {
173 $css .= "td.ilc_Page\n";
174 $css .= "{\n";
175 $css .= "\t" . "background-color: " . $page_background . ";\n";
176 $css .= "}\n";
177 }
178 if ($mq["id"] > 0) {
179 $css .= "}\n";
180 }
181 }
182 return $css;
183 }

References ILIAS\Repository\int().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: