30 protected \ILIAS\COPage\PC\DomainService
$pc_def;
31 protected \ILIAS\DI\UIServices
$ui;
32 protected \ilLanguage
$lng;
40 $this->pc_def = $DIC->copage()->internal()->domain()->pc();
43 $this->
lng->loadLanguageModule(
"copg");
51 string $component =
"",
52 bool $primary =
false,
53 string $aria_label =
"" 58 $b =
$f->button()->primary($content,
"");
60 $b =
$f->button()->standard($content,
"");
65 $b =
$b->withOnLoadCode(
66 function (
$id) use ($type,
$data, $action, $component, $aria_label) {
67 $code =
"document.querySelector('#$id').setAttribute('data-copg-ed-type', '$type'); 68 document.querySelector('#$id').setAttribute('data-copg-ed-component', '$component'); 69 document.querySelector('#$id').setAttribute('data-copg-ed-action', '$action'); ";
70 if ($aria_label !==
"") {
71 $code .=
"document.querySelector('#$id').setAttribute('aria-label', '$aria_label'); ";
73 foreach (
$data as $key => $val) {
74 $code .=
"\n document.querySelector('#$id').setAttribute('data-copg-ed-par-$key', '$val');";
87 $ui->renderer()->renderAsync($ui->factory()->legacy()->content(
""));
90 $m =
$f->messageBox()->info($text);
91 if (count($buttons)) {
92 $m = $m->withButtons($buttons);
94 return $ui->renderer()->renderAsync($m);
102 $ui->renderer()->renderAsync($ui->factory()->legacy()->content(
""));
105 $m =
$f->messageBox()->success($text);
106 return $ui->renderer()->renderAsync($m);
114 $ui->renderer()->renderAsync($ui->factory()->legacy()->content(
""));
117 $m =
$f->messageBox()->failure($this->
lng->txt(
"copg_an_error_occured"))
118 ->withLinks([
$f->link()->standard($this->
lng->txt(
"copg_details"),
"#")]);
120 return $ui->renderer()->renderAsync($m);
128 string $component =
"",
129 bool $primary =
false,
130 string $aria_label =
"" 135 $ui->renderer()->renderAsync($ui->factory()->legacy()->content(
""));
144 $b = $this->
getButton($content, $type, $action,
$data, $component, $primary, $aria_label);
145 return $ui->renderer()->renderAsync(
$b);
153 $ui->renderer()->renderAsync($ui->factory()->legacy()->content(
""));
156 $m =
$f->messageBox()->failure($this->
lng->txt(
"copg_error_occured_modal"))
157 ->withButtons([
$f->button()->standard($this->
lng->txt(
"copg_reload_page"),
"#")->
withOnLoadCode(
function (
$id) {
159 "$(\"#$id\").click(function() { location.reload(); return false;});";
162 return $ui->renderer()->renderAsync($m) .
"<p>" . $this->
lng->txt(
"copg_details") .
":</p>";
168 $r = $ui->renderer();
171 $ui->renderer()->renderAsync($ui->factory()->legacy()->content(
""));
174 $tpl = new \ilTemplate(
"tpl.editor_button_group.html",
true,
true,
"components/ILIAS/COPage");
176 foreach ($groups as $buttons) {
177 foreach ($buttons as $action => $lng_key) {
178 $tpl->setCurrentBlock(
"button");
179 $b = $this->
getButton($this->
lng->txt($lng_key),
"multi", $action);
180 $tpl->setVariable(
"BUTTON",
$r->renderAsync(
$b));
181 $tpl->parseCurrentBlock();
183 $tpl->setCurrentBlock(
"section");
184 $tpl->parseCurrentBlock();
193 $r = $ui->renderer();
196 $ui->renderer()->renderAsync($ui->factory()->legacy()->content(
""));
198 $tpl = new \ilTemplate(
"tpl.form_footer.html",
true,
true,
"components/ILIAS/COPage");
201 foreach ($buttons as
$b) {
202 $html .= $ui->renderer()->renderAsync($b);
205 $tpl->setVariable(
"BUTTONS", $html);
216 foreach ($buttons as $button) {
222 foreach ($buttons as $button) {
225 "id='cmd-" . $cnt .
"'",
226 " data-copg-ed-type='form-button' data-copg-ed-action='" . $button[1] .
"' data-copg-ed-component='" . $button[0] .
"'",
237 bool $in_modal =
false 240 foreach ($buttons as $button) {
251 $del_count = $in_modal ? 2 : 1;
252 $html = preg_replace(
"#\\<" . $tag .
"([^>]*)btn-default(.*)/" . $tag .
">#iUs",
"", $html, $del_count);
253 $footer_pos = stripos($html,
"il-standard-form-footer");
254 if (!is_int($footer_pos)) {
255 $footer_pos = stripos($html,
"c-form__footer");
259 substr($html, 0, $footer_pos) .
260 preg_replace(
"#\\<" . $tag .
"([^>]*)btn-default(.*)/" . $tag .
">#iUs", $button_html, substr($html, $footer_pos), 1);
263 $html = str_replace(
"<form ",
"<form id='$id' ", $html);
282 if ($updated !==
true) {
283 if (is_array($updated)) {
285 foreach ($updated as $u) {
287 $error .= implode(
"<br />", $u);
292 } elseif (is_string($updated)) {
295 $error = print_r($updated,
true);
306 $data = new \stdClass();
307 $data->renderedContent = $page_data . $this->getOnloadCode($page_gui);
308 $data->pcModel = $pc_model;
321 $defs = $this->pc_def->definition()->getPCDefinitions();
322 $all_onload_code = [];
323 foreach ($defs as $def) {
324 $pc_class = $def[
"pc_class"];
326 $pc_obj =
new $pc_class($page);
329 $onload_code = $pc_obj->getOnloadCode(
"edit");
330 foreach ($onload_code as $code) {
331 $all_onload_code[] = $code;
335 if (count($all_onload_code) > 0) {
336 $code_str =
"<script>" . implode(
"\n", $all_onload_code) .
"</script>";
344 $data = new \stdClass();
345 $data->formError =
true;
356 foreach ($actions as $act) {
358 $view_modes[$act[2]] =
"cmd-" . $cnt;
360 $vc = $ui->factory()->viewControl()->mode($view_modes,
"");
361 $html = $ui->renderer()->renderAsync($vc);
363 foreach ($actions as $act) {
366 'data-action="cmd-' . $cnt .
'"',
367 " data-copg-ed-type='view-control' data-copg-ed-action='" . $act[1] .
"' data-copg-ed-component='" . $act[0] .
"'",
371 $html = str_replace(
"id=",
"data-id=", $html);
385 $l =
$f->button()->shy($content,
"");
389 $l = $l->withOnLoadCode(
390 function (
$id) use ($component, $type,
$data, $action) {
391 $code =
"document.querySelector('#$id').setAttribute('data-copg-ed-component', '$component'); 392 document.querySelector('#$id').setAttribute('data-copg-ed-type', '$type'); 393 document.querySelector('#$id').setAttribute('data-copg-ed-action', '$action')";
394 foreach (
$data as $key => $val) {
395 $code .=
"\n document.querySelector('#$id').setAttribute('data-copg-ed-par-$key', '$val');";
412 $ui->renderer()->renderAsync($ui->factory()->legacy()->content(
""));
413 $l = $this->
getLink($content, $component, $type, $action,
$data);
414 return $ui->renderer()->renderAsync($l);
421 $r = $ui->renderer();
422 $i =
$f->symbol()->icon()->standard($type, $type,
'medium');
423 return $r->render($i);
428 bool $leading_image =
false 432 $r = $ui->renderer();
433 $dd =
$f->dropdown()->standard([
434 $f->link()->standard(
"#link-label#",
"#")
437 $item =
$f->item()->standard(
"#item-title#")->withActions($dd);
438 if ($leading_image) {
439 $item = $item->withLeadImage(
440 $f->image()->responsive(
"#img-src#",
"#img-alt#")
443 $p =
$f->panel()->listing()->standard(
451 return $r->renderAsync($p);
static array static setUseRelativeDates(bool $a_status)
set use relative dates
getRenderedButtonGroups(array $groups)
getRenderedListingPanelTemplate(string $title="", bool $leading_image=false)
setOutputMode(string $a_mode=self::PRESENTATION)
getRenderedIcon(string $type)
getRenderedViewControl(array $actions)
Interface Observer Contains several chained tasks and infos about them.
getRenderedAdapterForm(FormAdapterGUI $form, array $buttons, string $id="", bool $in_modal=false)
getRenderedSuccessBox(string $text)
getRenderedFormFooter(array $buttons)
getLink(string $content, string $component, string $type, string $action, ?array $data=null)
ILIAS COPage PC DomainService $pc_def
getButton(string $content, string $type, string $action, ?array $data=null, string $component="", bool $primary=false, string $aria_label="")
getRenderedButton(string $content, string $type, string $action, ?array $data=null, string $component="", bool $primary=false, string $aria_label="")
__construct(\ILIAS\DI\UIServices $ui, \ilLanguage $lng)
setTemplateOutput(bool $a_output=true)
withOnLoadCode(Closure $binder)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getRenderedForm(\ilPropertyFormGUI $form, array $buttons)
getRenderedInfoBox(string $text, array $buttons=[])
getRenderedLink(string $content, string $component, string $type, string $action, ?array $data=null)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
showPage()
display content of page
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
getRenderedModalFailureBox()
sendPage(\ilPageObjectGUI $page_gui, $updated)
Send whole page as response.
sendFormError(string $form)