ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ILIAS\COPage\PC\Paragraph\MenuGUI Class Reference
+ Collaboration diagram for ILIAS\COPage\PC\Paragraph\MenuGUI:

Public Member Functions

 __construct (protected InternalDomainService $domain_service, protected InternalGUIService $gui_service, protected \ILIAS\Style\Content\InternalService $style_service)
 
 render (string $a_par_type, bool $a_int_links=false, bool $a_wiki_links=false, bool $a_keywords=false, $a_style_id=0, $a_paragraph_styles=true, $a_save_return=true, $a_anchors=false, $a_save_new=true, $a_user_links=false)
 

Detailed Description

Definition at line 26 of file MenuGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\COPage\PC\Paragraph\MenuGUI::__construct ( protected InternalDomainService  $domain_service,
protected InternalGUIService  $gui_service,
protected \ILIAS\Style\Content\InternalService  $style_service 
)

Definition at line 28 of file MenuGUI.php.

32 {
33 }

Member Function Documentation

◆ render()

ILIAS\COPage\PC\Paragraph\MenuGUI::render ( string  $a_par_type,
bool  $a_int_links = false,
bool  $a_wiki_links = false,
bool  $a_keywords = false,
  $a_style_id = 0,
  $a_paragraph_styles = true,
  $a_save_return = true,
  $a_anchors = false,
  $a_save_new = true,
  $a_user_links = false 
)

Definition at line 35 of file MenuGUI.php.

46 : string {
47 $style_service = $this->style_service;
48
49 $user_id = $this->domain_service->user()->getId();
50 $ui_wrapper = $this->gui_service->edit()->uiWrapper();
51 $lng = $this->domain_service->lng();
52 $lng->loadLanguageModule("copg");
53 $ctrl = $this->gui_service->ctrl();
54 $ui = $this->gui_service->ui();
55
56 $ui->renderer()->renderAsync($ui->factory()->legacy()->content(""));
57
58 $page_config = $this->domain_service->pageConfig($a_par_type);
59
60 $style_access_manager = $style_service->domain()->access(
61 0,
63 );
64 $char_manager = $style_service->domain()->characteristic(
65 $a_style_id,
66 $style_access_manager
67 );
68
69 $aset = new \ilSetting("adve");
70
71 $f = static function (string $type, string $code) use ($char_manager, $lng): string {
72 $title = $char_manager->getPresentationTitle("text_inline", $type);
73 if ($title === $type) {
74 $title = $lng->txt("cont_char_style_" . $code);
75 }
76 return $title;
77 };
78
79 // character styles
80 $chars = [];
81 if ($a_style_id === 0) {
82 $chars = array(
83 "Comment" => array("code" => "com", "txt" => $f("Comment", "com")),
84 "Quotation" => array("code" => "quot", "txt" => $f("Quotation", "quot")),
85 "Accent" => array("code" => "acc", "txt" => $f("Accent", "acc")),
86 "Code" => array("code" => "code", "txt" => $f("Code", "code"))
87 );
88 }
89 foreach (\ilPCParagraphGUI::_getTextCharacteristics($a_style_id, true) as $c) {
90 if (in_array($c, ["Strong", "Important", "Emph"])) {
91 continue;
92 }
93 if (!isset($chars[$c])) {
94 $title = $char_manager->getPresentationTitle("text_inline", $c);
95 switch ($c) {
96 case "CodeInline":
97 $chars["Code"] = array("code" => "code", "txt" => $f("Code", "code"));
98 break;
99 case "Comment":
100 $chars["Comment"] = array("code" => "com", "txt" => $f("Comment", "com"));
101 break;
102 case "Quotation":
103 $chars["Quotation"] = array("code" => "quot", "txt" => $f("Quotation", "quot"));
104 break;
105 case "Accent":
106 $chars["Accent"] = array("code" => "acc", "txt" => $f("Accent", "acc"));
107 break;
108 default:
109 $chars[$c] = array("code" => "", "txt" => $title);
110 break;
111 }
112 }
113 }
114 $char_formats = [];
115 foreach ($chars as $key => $char) {
117 $a_par_type,
118 "active_" . $char["code"],
119 "1"
120 )) {
121 $t = "text_inline";
122 $tag = "span";
123 switch ($key) {
124 case "Code": $tag = "code";
125 break;
126 }
127 $html = '<' . $tag . ' class="ilc_' . $t . '_' . $key . '" style="font-size:90%; margin-top:2px; margin-bottom:2px; position:static;">' . $char["txt"] . "</" . $tag . ">";
128 $char_formats[] = ["text" => $html, "action" => "selection.format", "data" => ["format" => $key]];
129 }
130 }
131
132
133 $numbered_list = $ui->renderer()->render(
134 $ui->factory()->symbol()->glyph()->numberedlist(null)
135 );
136
137 $bullet_list = $ui->renderer()->render(
138 $ui->factory()->symbol()->glyph()->bulletlist(null)
139 );
140
141 $indent = $ui->renderer()->render(
142 $ui->factory()->symbol()->glyph()->listindent(null)
143 );
144
145 $outdent = $ui->renderer()->render(
146 $ui->factory()->symbol()->glyph()->listoutdent(null)
147 );
148
149 // menu
150 $str = "str";
151 $emp = "emp";
152 $imp = "imp";
153 if ($aset->get("use_physical")) {
154 $str = "B";
155 $emp = "I";
156 $imp = "U";
157 }
158 $c_formats = [];
159 foreach (["str", "emp", "imp", "sup", "sub"] as $c) {
161 $a_par_type,
162 "active_" . $c,
163 "1"
164 )) {
165 switch ($c) {
166 case "str":
167 $c_formats[] = ["text" => '<span class="ilc_text_inline_Strong">' . $str . '</span>',
168 "action" => "selection.format",
169 "data" => ["format" => "Strong"],
170 "aria-label" => $lng->txt("cont_text_str")
171 ];
172 break;
173 case "emp":
174 $c_formats[] = ["text" => '<span class="ilc_text_inline_Emph">' . $emp . '</span>',
175 "action" => "selection.format",
176 "data" => ["format" => "Emph"],
177 "aria-label" => $lng->txt("cont_text_emp")
178 ];
179 break;
180 case "imp":
181 $c_formats[] = ["text" => '<span class="ilc_text_inline_Important">' . $imp . '</span>',
182 "action" => "selection.format",
183 "data" => ["format" => "Important"],
184 "aria-label" => $lng->txt("cont_text_imp")
185 ];
186 break;
187 case "sup":
188 $c_formats[] = ["text" => 'x<sup>2</sup>',
189 "action" => "selection.format",
190 "data" => ["format" => "Sup"],
191 "aria-label" => $lng->txt("cont_text_sup")
192 ];
193 break;
194 case "sub":
195 $c_formats[] = ["text" => 'x<sub>2</sub>',
196 "action" => "selection.format",
197 "data" => ["format" => "Sub"],
198 "aria-label" => $lng->txt("cont_text_sub")
199 ];
200 break;
201 }
202 }
203 }
204 $c_formats[] = ["text" => "<i>A</i>",
205 "action" => $char_formats,
206 "aria-label" => $lng->txt("copg_more_character_formats")
207 ];
208 $c_formats[] = ["text" => '<i><strong><u>T</u></strong><sub>x</sub></i>',
209 "action" => "selection.removeFormat",
210 "data" => [],
211 "aria-label" => $lng->txt("copg_remove_formats")
212 ];
213 $menu = [
214 "cont_char_format" => $c_formats,
215 "cont_lists" => [
216 [
217 "text" => $bullet_list,
218 "action" => "list.bullet",
219 "data" => [],
220 "aria-label" => $lng->txt("cont_bullet_list")
221 ],
222 [
223 "text" => $numbered_list,
224 "action" => "list.number",
225 "data" => [],
226 "aria-label" => $lng->txt("cont_numbered_list")
227 ],
228 [
229 "text" => $outdent,
230 "action" => "list.outdent",
231 "data" => [],
232 "aria-label" => $lng->txt("cont_list_outdent")
233 ],
234 [
235 "text" => $indent,
236 "action" => "list.indent",
237 "data" => [],
238 "aria-label" => $lng->txt("cont_list_indent")
239 ]
240 ]
241 ];
242
243 // bullet lists
244 $ulists = \ilPCListGUI::_getListCharacteristics($a_style_id, "list_u");
245 $olists = \ilPCListGUI::_getListCharacteristics($a_style_id, "list_o");
246 $ilists = \ilPCListGUI::_getListCharacteristics($a_style_id, "list_item");
247 if (count($ulists) > 1) {
248 $la = [];
249 foreach ($ulists as $c) {
250 $la[] = ["action" => "list.bulletStyle", "text" => $c, "data" => ["format" => $c]];
251 }
252 $menu["copg_list_styles"][] = ["text" => $lng->txt("copg_list_style"), "action" => $la];
253 }
254 if (count($olists) > 1) {
255 $la = [];
256 foreach ($olists as $c) {
257 $la[] = ["action" => "list.numberStyle", "text" => $c, "data" => ["format" => $c]];
258 }
259 $menu["copg_list_styles"][] = ["text" => $lng->txt("copg_list_style"), "action" => $la];
260 }
261 if (count($ilists) > 1) {
262 $la = [];
263 foreach ($ilists as $c) {
264 $la[] = ["action" => "list.itemStyle", "text" => $c, "data" => ["format" => $c]];
265 }
266 $menu["copg_list_styles"][] = ["text" => $lng->txt("copg_list_item_style"), "action" => $la];
267 }
268
269 // more...
270
271 // links
272 $links = [];
273 if ($a_wiki_links) {
274 $links[] = ["text" => $lng->txt("cont_wiki_link_dialog"), "action" => "link.wikiSelection", "data" => [
275 "url" => $ctrl->getLinkTargetByClass("ilwikipagegui", "")]];
276 $links[] = ["text" => "[[" . $lng->txt("cont_wiki_page") . "]]", "action" => "link.wiki", "data" => []];
277 }
278 if ($a_int_links) {
279 $links[] = ["text" => $lng->txt("cont_text_iln_link"), "action" => "link.internal", "data" => []];
280 }
282 $a_par_type,
283 "active_xln",
284 "1"
285 )) {
286 $links[] = ["text" => $lng->txt("cont_text_xln"), "action" => "link.external", "data" => []];
287 }
288 if ($a_user_links) {
289 $links[] = ["text" => $lng->txt("cont_link_user"), "action" => "link.user", "data" => []];
290 }
291
292
293 // more
294 $menu["cont_more_functions"] = [];
295 $menu["cont_more_functions"][] = ["text" => $lng->txt("cont_link") . '<i class="mce-ico mce-i-link"></i>', "action" => $links];
296
297 if ($a_keywords) {
298 $menu["cont_more_functions"][] = ["text" => $lng->txt("cont_keyword"), "action" => "selection.keyword", "data" => []];
299 }
300 $mathJaxSetting = new \ilSetting("MathJax");
302 $a_par_type,
303 "active_tex",
304 "1"
305 )) {
306 $menu["cont_more_functions"][] = ["text" => 'Tex', "action" => "selection.tex", "data" => []];
307 }
309 $a_par_type,
310 "active_fn",
311 "1"
312 )) {
313 $menu["cont_more_functions"][] = ["text" => $lng->txt("cont_footnote"), "action" => "selection.fn", "data" => []];
314 }
315 if ($a_anchors) {
316 $menu["cont_more_functions"][] = ["text" => $lng->txt("cont_anchor"), "action" => "selection.anchor", "data" => []];
317 }
318
319 // text templates
320 $templates = [];
321 foreach ($page_config->getTextTemplates() as $k => $v) {
322 $k = $this->gui_service->html()->escape($k);
323 $v = $this->gui_service->html()->escape($v);
324 $templates[] = ["text" => $k, "action" => "text.template", "data" => [
325 "content" => $v
326 ]];
327 }
328 if (count($templates) > 0) {
329 $menu[""][] = ["text" => $page_config->getTextTemplatesDropdownCaption() . '<i class="mce-ico mce-i-link"></i>', "action" => $templates];
330 }
331
332 $btpl = new \ilTemplate("tpl.tiny_menu.html", true, true, "components/ILIAS/COPage");
333
334 foreach ($menu as $section_title => $section) {
335 foreach ($section as $item) {
336 if (is_array($item["action"])) {
337 $buttons = [];
338 foreach ($item["action"] as $i) {
339 $buttons[] = $ui_wrapper->getButton(
340 $i["text"],
341 "par-action",
342 $i["action"],
343 $i["data"],
344 "",
345 false,
346 $i["aria-label"] ?? ""
347 );
348 }
349 $dd = $ui->factory()->dropdown()->standard($buttons)->withLabel($item["text"])
350 ->withAriaLabel($item["aria-label"] ?? "");
351 $btpl->setCurrentBlock("button");
352 $btpl->setVariable("BUTTON", $ui->renderer()->renderAsync($dd));
353 } else {
354 $b = $ui_wrapper->getRenderedButton(
355 $item["text"],
356 "par-action",
357 $item["action"],
358 $item["data"],
359 "",
360 false,
361 $item["aria-label"] ?? ""
362 );
363 $btpl->setCurrentBlock("button");
364 $btpl->setVariable("BUTTON", $b);
365 }
366 $btpl->parseCurrentBlock();
367 }
368 if ($section_title !== "") {
369 $btpl->setCurrentBlock("sec_head");
370 $btpl->setVariable("TXT_SECTION", $lng->txt($section_title));
371 $btpl->parseCurrentBlock();
372 }
373 $btpl->setCurrentBlock("section");
374 $btpl->parseCurrentBlock();
375 }
376
377
378 if ($a_paragraph_styles) {
379 $sel = new \ParagraphStyleSelector($ui_wrapper, $a_style_id);
380 $dd = $sel->getStyleSelector(" ");
381 $btpl->setCurrentBlock("par_edit");
382 $btpl->setVariable("TXT_PAR_FORMAT", $lng->txt("cont_par_format"));
383
384 $btpl->setVariable("STYLE_SELECTOR", $ui->renderer()->renderAsync($dd));
385
386 $btpl->parseCurrentBlock();
387 }
388
389 // block styles
390 $sel = new \SectionStyleSelector($ui_wrapper, $a_style_id);
391 $dd = $sel->getStyleSelector(" ", $type = "par-action", $action = "sec.class", $attr = "class", true);
392 $btpl->setVariable("TXT_BLOCK", $lng->txt("cont_sur_block_format"));
393 $btpl->setVariable("BLOCK_STYLE_SELECTOR", $ui->renderer()->renderAsync($dd));
394
395 $btpl->setVariable("TINY_HEADER", $lng->txt("cont_text_editing"));
396 $btpl->setVariable(
397 "SPLIT_BUTTON",
398 $ui_wrapper->getRenderedButton($lng->txt("cont_quit_text_editing"), "par-action", "save.return")
399 );
400
401 $btpl->setVariable("TXT_SAVING", $lng->txt("cont_saving"));
402 $btpl->setVariable("SRC_LOADER", \ilUtil::getImagePath("media/loader.svg"));
403
404 return $btpl->get();
405 }
static _getListCharacteristics(int $a_style_id, string $type)
static lookupSettingByParentType(string $a_par_type, string $a_name, string $a_default='0')
Lookup setting by parent type.
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
$c
Definition: deliver.php:25
global $lng
Definition: privfeed.php:31

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