ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
class.ilObjectCopyProgressTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\Data\Factory as DataFactory;
22use ILIAS\UI\Renderer as UIRenderer;
23use ILIAS\UI\Factory as UIFactory;
24
31{
32 protected array $objects = [];
33
34 public function __construct(
35 private DataFactory $data_factory,
36 private UIRenderer $ui_renderer,
37 private UIFactory $ui_factory,
39 string $parent_cmd,
40 int $id,
41 ) {
42 $this->setId('obj_cp_prog_tbl_' . $id);
44 }
45
46 public function setObjectInfo(array $ref_ids): void
47 {
48 $this->objects = $ref_ids;
49 }
50
51 public function getObjects(): array
52 {
53 return $this->objects;
54 }
55
56 public function setRedirectionUrl(?string $url): void
57 {
58 $this->main_tpl->addOnLoadCode('il.CopyRedirection.setRedirectUrl("' . $url . '")');
59 }
60
61 public function init(): void
62 {
63 $this->main_tpl->addJavaScript('assets/js/ilCopyRedirection.js');
64 $this->main_tpl->addOnLoadCode('il.CopyRedirection.checkDone()');
65 $this->setExternalSorting(true);
66 $this->setFormAction($this->ctrl->getFormAction($this->getParentObject()));
67
68 $this->setRowTemplate('tpl.object_copy_progress_table_row.html', 'components/ILIAS/ILIASObject');
69
70 $this->addColumn($this->lng->txt('obj_target_location'));
71 $this->addColumn($this->lng->txt('obj_copy_progress'));
72 }
73
74 protected function fillRow(array $set): void
75 {
76 $this->tpl->setVariable('VAL_ID', $set['ref_id']);
77 $this->tpl->setVariable('OBJ_TITLE', $set['title']);
78
79 if (strlen($set['description'])) {
80 $this->tpl->setVariable('VAL_DESC', $set['description']);
81 }
82
83 $this->tpl->setVariable('TYPE_IMG', ilObject::_getIcon($set['obj_id'], "small", $set['type']));
84 $this->tpl->setVariable('TYPE_STR', $this->lng->txt('obj_' . $set['type']));
85
86 $this->ctrl->setParameter($this->getParentObject(), '_copy_id', $set['copy_id']);
87 $this->ctrl->setParameter($this->getParentObject(), '_max_steps', $set['max_steps']);
88
89 $progress_endpoint = $this->data_factory->uri(
90 ILIAS_HTTP_PATH . '/' .
91 $this->ctrl->getLinkTarget(
92 $this->getParentObject(),
93 'updateProgress',
94 '',
95 true
96 )
97 );
98
99 $progress_bar = $this->ui_factory->progress()->bar(
100 sprintf($this->lng->txt('obj_copy_progress_to'), $set['title']),
101 $progress_endpoint,
102 );
103
104 $this->tpl->setVariable('PROGRESS_BAR', $this->ui_renderer->render($progress_bar));
105
106 // start pulling progress from $progress_endpoint once the page has loaded
107 $this->main_tpl->addOnLoadCode("
108 il.UI.Progress.Bar.indeterminate(
109 '{$progress_bar->getUpdateSignal()}',
110 '{$this->lng->txt('obj_copy_progress_estimate')}'
111 );
112 ");
113 }
114
115 public function parse(): void
116 {
117 $counter = 0;
118 $set = [];
119 foreach ($this->getObjects() as $ref_id => $copy_id) {
120 $counter++;
121 $set[$counter]['ref_id'] = $ref_id;
122 $set[$counter]['copy_id'] = $copy_id;
123 $set[$counter]['obj_id'] = ilObject::_lookupObjId($ref_id);
127
128 $copy_info = ilCopyWizardOptions::_getInstance($copy_id);
129 $copy_info->read();
130 $set[$counter]['max_steps'] = $copy_info->getRequiredSteps();
131 }
132 $this->setData($set);
133 }
134}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
Builds data types.
Definition: Factory.php:36
static _getInstance(int $a_copy_id)
GUI class for the workflow of copying objects.
__construct(private DataFactory $data_factory, private UIRenderer $ui_renderer, private UIFactory $ui_factory, ilObjectCopyGUI $parent_obj, string $parent_cmd, int $id,)
fillRow(array $set)
Standard Version of Fill Row.
static _lookupType(int $id, bool $reference=false)
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
static _lookupDescription(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setFormAction(string $a_form_action, bool $a_multipart=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setExternalSorting(bool $a_val)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setData(array $a_data)
Set table data.
An entity that renders components to a string output.
Definition: Renderer.php:31
$ref_id
Definition: ltiauth.php:66
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$url
Definition: shib_logout.php:68
$counter