32 protected \ILIAS\COPage\InternalGUIService
$gui;
35 protected \ILIAS\DI\UIServices
$ui;
36 protected \ilLanguage
$lng;
47 $this->
ui = $DIC->ui();
48 $this->
lng = $DIC->language();
50 $this->
user = $DIC->user();
51 $this->
ctrl = $DIC->ctrl();
52 $this->component_factory = $DIC[
"component.factory"];
53 $this->gui = $DIC->copage()->internal()->gui();
56 $this->ui_wrapper =
new Server\UIWrapper($this->
ui, $this->
lng);
57 $this->pc_definition = $DIC
68 public function handle(array $query): Server\Response
70 switch ($query[
"action"]) {
74 case "component.edit.form":
77 throw new Exception(
"Unknown action " . $query[
"action"]);
83 $f = $this->
ui->factory();
84 $dd =
$f->dropdown()->standard([
85 $f->link()->standard(
"label",
"#")
87 $r = $this->
ui->renderer();
89 $dd_html = preg_replace(
'/\s*id="[^"]*"/',
'',
$r->render($dd));
91 $o->dropdown = $dd_html;
108 $o->backUrl = $ctrl->getLinkTarget($this->page_gui,
"edit");
110 count($this->
user->getPCClipboardContent()) > 0;
113 if ($this->pc_id !==
"") {
114 $type = $this->page_gui->getPageObject()->getContentObjectForPcId($this->pc_id)->getType();
115 $def = $this->pc_definition->getPCDefinitionByType($type);
116 $o->initialComponent = $def[
"name"];
119 $o->initialComponent =
"";
120 $o->initialPCId =
"";
123 return new Server\Response($o);
128 $config = new \stdClass();
129 $config->user = $this->
user->getLogin();
130 $config->content_css =
133 "./components/ILIAS/COPage/css/tiny_extra.css";
134 $config->text_formats = \ilPCParagraphGUI::_getTextCharacteristics($this->page_gui->getStyleId());
135 $config->text_block_formats = [];
136 foreach ([
"text_block",
"heading1",
"heading2",
"heading3"] as $type) {
137 $dummy_pc = new \ilPCParagraphGUI($this->page_gui->getPageObject(),
null,
"");
138 $dummy_pc->setStyleId($this->page_gui->getStyleId());
139 $dummy_pc->getCharacteristicsOfCurrentStyle([$type]);
140 foreach ($dummy_pc->getCharacteristics() as $char =>
$txt) {
141 $config->text_block_formats[$char] =
$txt;
144 $config->editPlaceholders = $this->page_gui->getPageConfig()->getEnablePCType(
"PlaceHolder");
145 $config->activatedProtection =
158 $config = $this->page_gui->getPageConfig();
159 foreach ($config->getEnabledTopPCTypes() as $def) {
160 $commands[$def[
"pc_type"]] = $lng->
txt(
"cont_ed_insert_" . $def[
"pc_type"]);
164 if (count($this->page_gui->getPageObject()->getContentTemplates()) > 0) {
165 $commands[
"templ"] = $lng->txt(
"cont_ed_insert_templ");
169 foreach ($this->component_factory->getActivePluginsInSlot(
"pgcp") as
$plugin) {
170 if (
$plugin->isValidParentType($this->page_gui->getPageObject()->getParentType())) {
171 $commands[
"plug_" .
$plugin->getPluginName()] =
185 $tpl = new \ilTemplate(
"tpl.page_edit_help.html",
true,
true,
"components/ILIAS/COPage/Editor");
186 $tpl->setCurrentBlock(
"help");
187 $tpl->setVariable(
"TXT_ADD_EL", $lng->txt(
"cont_add_elements"));
188 $tpl->setVariable(
"PLUS", $this->gui->symbol()->glyph(
"add")->render());
189 $tpl->setVariable(
"DRAG_ARROW", $this->gui->symbol()->glyph(
"next")->render());
190 $tpl->setVariable(
"TXT_DRAG", $lng->txt(
"cont_drag_and_drop_elements"));
191 $tpl->setVariable(
"TXT_EDIT", $lng->txt(
"cont_click_edit"));
192 $tpl->setVariable(
"TXT_SEL", $lng->txt(
"cont_shift_click_to_select"));
193 $tpl->parseCurrentBlock();
205 $tpl = new \ilTemplate(
"tpl.page_edit_help.html",
true,
true,
"components/ILIAS/COPage/Editor");
206 $tpl->setCurrentBlock(
"multi-help");
207 $tpl->setVariable(
"TXT_SEL", $lng->txt(
"cont_click_multi_select"));
208 $tpl->parseCurrentBlock();
219 $tpl = new \ilTemplate(
"tpl.top_actions.html",
true,
true,
"components/ILIAS/COPage/Editor");
222 $tpl->setVariable(
"DROPDOWN", $ui->renderer()->renderAsync($dd));
224 if ($this->page_gui->getPageObject()->getEffectiveEditLockTime() > 0) {
225 $mess = $this->page_gui->getBlockingInfoMessage();
226 $tpl->setVariable(
"MESSAGE", $mess);
227 $b = $ui->factory()->button()->standard(
228 $lng->txt(
"cont_finish_editing"),
229 $ctrl->getLinkTarget($this->page_gui,
"releasePageLock")
232 $b = $ui->factory()->button()->standard(
233 $lng->txt(
"cont_finish_editing"),
234 $ctrl->getLinkTarget($this->page_gui,
"finishEditing")
238 $tpl->setVariable(
"QUIT_BUTTON", $ui->renderer()->renderAsync(
$b));
240 $html = $this->ui_wrapper->getRenderedViewControl(
242 [
"Page",
"switch.single", $lng->txt(
"cont_edit_comp")],
243 [
"Page",
"switch.multi", $lng->txt(
"cont_edit_multi")]
246 $tpl->setVariable(
"SWITCH", $html);
256 $config = $this->page_gui->getPageConfig();
257 $page = $this->page_gui->getPageObject();
262 $sel_media_mode = ($user->getPref(
"ilPageEditor_MediaMode") !=
"disable");
263 $sel_html_mode = ($user->getPref(
"ilPageEditor_HTMLMode") !=
"disable");
267 if ($config->getEnableActivation()) {
268 $captions = $this->page_gui->getActivationCaptions();
270 if ($page->getActive()) {
271 $items[] = $ui->factory()->link()->standard(
272 $captions[
"deactivatePage"],
273 $ctrl->getLinkTarget($this->page_gui,
"deactivatePage")
276 $items[] = $ui->factory()->link()->standard(
277 $captions[
"activatePage"],
278 $ctrl->getLinkTarget($this->page_gui,
"activatePage")
284 if ($config->getUseAttachedContent()) {
285 $items[] = $ui->factory()->link()->standard(
286 $lng->txt(
"cont_initial_attached_content"),
287 $ctrl->getLinkTarget($this->page_gui,
"initialOpenedContent")
299 if ($sel_media_mode) {
300 $ctrl->setParameter($this->page_gui,
"media_mode",
"disable");
301 $items[] = $ui->factory()->link()->standard(
302 $lng->txt(
"cont_deactivate_media"),
303 $ctrl->getLinkTarget($this->page_gui,
"setEditMode")
306 $ctrl->setParameter($this->page_gui,
"media_mode",
"enable");
307 $items[] = $ui->factory()->link()->standard(
308 $lng->txt(
"cont_activate_media"),
309 $ctrl->getLinkTarget($this->page_gui,
"setEditMode")
312 $ctrl->setParameter($this,
"media_mode",
"");
315 if (!$config->getPreventHTMLUnmasking()) {
316 if ($sel_html_mode) {
317 $ctrl->setParameter($this->page_gui,
"html_mode",
"disable");
318 $items[] = $ui->factory()->link()->standard(
319 $lng->txt(
"cont_deactivate_html"),
320 $ctrl->getLinkTarget($this->page_gui,
"setEditMode")
323 $ctrl->setParameter($this->page_gui,
"html_mode",
"enable");
324 $items[] = $ui->factory()->link()->standard(
325 $lng->txt(
"cont_activate_html"),
326 $ctrl->getLinkTarget($this->page_gui,
"setEditMode")
330 $ctrl->setParameter($this->page_gui,
"html_mode",
"");
332 $lm_set = new \ilSetting(
"lm");
335 if (
$lm_set->get(
"page_history", 1)) {
336 $items[] = $ui->factory()->link()->standard(
337 $lng->txt(
"history"),
338 $ctrl->getLinkTarget($this->page_gui,
"history")
342 if ($config->getEnableScheduledActivation()) {
343 $items[] = $ui->factory()->link()->standard(
344 $lng->txt(
"cont_activation"),
345 $ctrl->getLinkTarget($this->page_gui,
"editActivation")
350 $items[] = $ui->factory()->link()->standard(
351 $lng->txt(
"clipboard"),
352 $ctrl->getLinkTargetByClass([get_class($this->page_gui),
"ilEditClipboardGUI"],
"view")
355 if ($this->page_gui->getEnabledNews()) {
356 $items[] = $ui->factory()->link()->standard(
358 $ctrl->getLinkTargetByClass([get_class($this->page_gui),
"ilnewsitemgui"],
"editNews")
362 if (($md_link = $this->page_gui->getMetaDataLink()) !==
"") {
363 $items[] = $ui->factory()->link()->standard(
364 $lng->txt(
"meta_data"),
370 if ($this->page_gui->use_meta_data) {
371 $mdgui = new \ilObjectMetaDataGUI(
372 $this->page_gui->meta_data_rep_obj,
373 $this->page_gui->meta_data_type,
374 $this->page_gui->meta_data_sub_obj_id
376 $mdtab = $mdgui->getTab();
378 $items[] = $ui->factory()->link()->standard(
379 $lng->txt(
"meta_data"),
386 if ($this->page_gui->getEnabledNews()) {
387 $items[] = $ui->factory()->link()->standard(
389 $ctrl->getLinkTargetByClass([get_class($this->page_gui), \ilNewsItemGUI::class],
"editNews")
395 foreach ($this->page_gui->getAdditionalPageActions() as $item) {
399 return $ui->factory()->dropdown()->standard($items);
407 $config = $this->page_gui->getPageConfig();
408 $page = $this->page_gui->getPageObject();
417 if ($config->getMultiLangSupport()) {
420 if ($ot->getContentActivated()) {
421 $lng->loadLanguageModule(
"meta");
423 if ($page->getLanguage() !=
"-") {
424 $l = $ot->getMasterLanguage();
425 $items[] = $ui->factory()->link()->standard(
426 $lng->txt(
"cont_edit_language_version") .
": " .
427 $lng->txt(
"meta_l_" . $l),
428 $ctrl->getLinkTarget($this->page_gui,
"editMasterLanguage")
432 foreach ($ot->getLanguages() as $al =>
$lang) {
433 if ($page->getLanguage() != $al &&
434 $al != $ot->getMasterLanguage()) {
435 $ctrl->setParameter($this->page_gui,
"totransl", $al);
436 $items[] = $ui->factory()->link()->standard(
437 $lng->txt(
"cont_edit_language_version") .
": " .
438 $lng->txt(
"meta_l_" . $al),
439 $ctrl->getLinkTarget($this->page_gui,
"switchToLanguage")
441 $ctrl->setParameter($this->page_gui,
"totransl",
"");
454 $config = $this->page_gui->getPageConfig();
455 $page = $this->page_gui->getPageObject();
460 if ($config->getMultiLangSupport()) {
463 if ($ot->getContentActivated()) {
464 $lng->loadLanguageModule(
"meta");
466 $ml_gui = new \ilPageMultiLangGUI(
467 $page->getParentType(),
470 $info = $ml_gui->getMultiLangInfo($page->getLanguage());
471 $info = $ui->renderer()->renderAsync($ui->factory()->messageBox()->info($info));
487 "all" =>
"select_all",
488 "none" =>
"cont_select_none",
491 "activate" =>
"cont_ed_enable",
492 "characteristic" =>
"cont_assign_characteristic" 496 return $this->ui_wrapper->getRenderedButtonGroups($groups);
506 $html = $this->ui_wrapper->getRenderedInfoBox($lng->txt(
"cont_sel_el_use_paste"));
516 $html = $this->ui_wrapper->getRenderedFailureBox();
523 $html = $this->ui_wrapper->getRenderedModalFailureBox();
532 $tpl = new \ilTemplate(
"tpl.format_selection.html",
true,
true,
"components/ILIAS/COPage/Editor");
533 $tpl->setVariable(
"TXT_PAR", $lng->txt(
"cont_choose_characteristic_text"));
534 $tpl->setVariable(
"TXT_SECTION", $lng->txt(
"cont_choose_characteristic_section"));
535 $tpl->setVariable(
"TXT_MEDIA", $lng->txt(
"cont_media"));
538 $tpl->setVariable(
"PAR_SELECTOR", $ui->renderer()->renderAsync($par_sel->getStyleSelector(
"",
"format",
"format.paragraph",
"format")));
541 $tpl->setVariable(
"SEC_SELECTOR", $ui->renderer()->renderAsync($sec_sel->getStyleSelector(
"",
"format",
"format.section",
"format")));
544 $tpl->setVariable(
"MEDIA_SELECTOR", $ui->renderer()->renderAsync($med_sel->getStyleSelector(
"",
"format",
"format.media",
"format")));
548 $this->ui_wrapper->getRenderedButton(
556 $this->ui_wrapper->getRenderedButton(
571 return $this->page_gui->getPageObject()->getPCModel();
576 $pc_edit = $this->pc_definition->getPCEditorInstanceByName($query[
"cname"]);
578 if (!is_null($pc_edit)) {
579 $form = $pc_edit->getEditComponentForm(
581 $this->page_gui->getPageObject()->getParentType(),
587 $o = new \stdClass();
588 $o->editForm = $form;
589 return new Server\Response($o);
598 $config = $this->page_gui->getPageConfig();
599 foreach ($this->pc_definition->getPCDefinitions() as $def) {
600 $pc_edit = $this->pc_definition->getPCEditorInstanceByName($def[
"name"]);
601 if ($config->getEnablePCType($def[
"name"])) {
602 if (!is_null($pc_edit)) {
603 $ui[$def[
"name"]] = $pc_edit->getEditorElements(
605 $this->page_gui->getPageObject()->getParentType(),
618 foreach ($this->pc_definition->getPCDefinitions() as $def) {
619 $pcdef[
"types"][$def[
"name"]] = $def[
"pc_type"];
620 $pcdef[
"names"][$def[
"pc_type"]] = $def[
"name"];
621 $pcdef[
"txt"][$def[
"pc_type"]] = $this->
lng->txt(
"cont_" .
"pc_" . $def[
"pc_type"]);
629 $modal = $ui->factory()->modal()->roundtrip(
'#title#', $ui->factory()->legacy()->content(
'#content#'))
630 ->withActionButtons([
631 $ui->factory()->button()->standard(
'#button_title#',
'#'),
633 $modalt[
"signal"] = $modal->getShowSignal()->getId();
634 $modalt[
"closeSignal"] = $modal->getCloseSignal()->getId();
635 $modalt[
"template"] = $ui->renderer()->renderAsync($modal);
647 $confirmation = $ui->factory()->messageBox()->confirmation(
"#text#");
649 return $ui->renderer()->renderAsync($confirmation);
657 $aset = new \ilSetting(
"adve");
658 return (
int) $aset->get(
"autosave");
static getStyleSheetLocation(string $mode="output", string $a_css_name="")
get full style sheet file name (path inclusive) of current user
const SEC_PROTECT_PROTECTED
getPageEditHelp()
Get page help (general)
ilPageObjectGUI $page_gui
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
getAutoSaveInterval()
Get auto save interval.
Interface Observer Contains several chained tasks and infos about them.
__construct(\ilPageObjectGUI $page_gui, string $pc_id="")
getPasteMessage()
Confirmation screen for cut/paste step.
componentEditFormResponse(array $query)
loadLanguageModule(string $a_module)
Load language module.
getConfirmationTemplate()
Get confirmation template.
getErrorMessage()
Confirmation screen for cut/paste step.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getComponentsEditorUI()
Get components ui elements.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getComponentsDefinitions()
getMultiLangActions()
Add multi-language actions to menu.
static getInstance(int $obj_id)
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
ILIAS COPage PC PCDefinition $pc_definition
getPCModel()
Get page component model.
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)
Server UIWrapper $ui_wrapper
ilComponentFactory $component_factory
getMultiEditHelp()
Get page help (multi editing)
ILIAS COPage InternalGUIService $gui