Skip to content

Commit

Permalink
Badges: Add missing tables titles
Browse files Browse the repository at this point in the history
  • Loading branch information
mjansenDatabay committed Nov 11, 2024
1 parent 7a039ca commit 9cd2222
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public function renderTable(): void
$data_retrieval = $this->buildDataRetrievalObject($f, $r);

$table = $f->table()
->data('', $columns, $data_retrieval)
->data($this->lng->txt('badge_image_templates'), $columns, $data_retrieval)
->withActions($actions)
->withRequest($request);

Expand Down
16 changes: 0 additions & 16 deletions components/ILIAS/Badge/classes/class.ilBadgeManagementGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -864,22 +864,6 @@ protected function awardBadgeUserSelection(): void
$tbl->renderTable();
}

protected function applyAwardBadgeUserSelection(): void
{
$tbl = new ilBadgeUserTableGUI($this, 'awardBadgeUserSelection', $this->parent_ref_id);
$tbl->resetOffset();
$tbl->writeFilterToSession();
$this->awardBadgeUserSelection();
}

protected function resetAwardBadgeUserSelection(): void
{
$tbl = new ilBadgeUserTableGUI($this, 'awardBadgeUserSelection', $this->parent_ref_id);
$tbl->resetOffset();
$tbl->resetFilter();
$this->awardBadgeUserSelection();
}

protected function assignBadge(): void
{
$ilCtrl = $this->ctrl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public function renderTable(): void
$actions = $this->getActions($url_builder, $action_parameter_token, $row_id_token);

$table = $f->table()
->data('', $columns, $data_retrieval)
->data($this->lng->txt('badge_personal_badges'), $columns, $data_retrieval)
->withActions($actions)
->withRequest($request);

Expand Down
2 changes: 1 addition & 1 deletion components/ILIAS/Badge/classes/class.ilBadgeTableGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ public function renderTable(): void

$data_retrieval = $this->buildDataRetrievalObject($f, $r, $this->parent_id, $this->parent_type);
$actions = $this->getActions($url_builder, $action_parameter_token, $row_id_token);
$table = $f->table()->data('', $columns, $data_retrieval)
$table = $f->table()->data($this->lng->txt('obj_bdga'), $columns, $data_retrieval)
->withActions($actions)
->withRequest($request);
$out = [$table];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public function renderTable(): void
$data_retrieval = $this->buildDataRetrievalObject($f, $r);

$table = $f->table()
->data('', $columns, $data_retrieval)
->data($this->lng->txt('badge_types'), $columns, $data_retrieval)
->withActions($actions)
->withRequest($request);

Expand Down
35 changes: 28 additions & 7 deletions components/ILIAS/Badge/classes/class.ilBadgeUserTableGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,22 @@
use ilUserQuery;
use DateTimeImmutable;
use ILIAS\UI\URLBuilderToken;
use ilObjectDataDeletionLog;

class ilBadgeUserTableGUI
{
private readonly Factory $factory;
private readonly Renderer $renderer;
private readonly ServerRequestInterface|RequestInterface $request;
private readonly int $parent_ref_id;
private readonly ?ilBadge $award_badge;
private readonly ilLanguage $lng;
private readonly ilGlobalTemplateInterface $tpl;

public function __construct(int $parent_ref_id, ?ilBadge $award_badge = null)
{
public function __construct(
int $parent_ref_id,
private readonly ?ilBadge $award_badge = null,
private readonly int $restrict_badge_id = 0
) {
global $DIC;

$this->lng = $DIC->language();
Expand All @@ -61,7 +64,6 @@ public function __construct(int $parent_ref_id, ?ilBadge $award_badge = null)
$this->renderer = $DIC->ui()->renderer();
$this->request = $DIC->http()->request();
$this->parent_ref_id = $parent_ref_id;
$this->award_badge = $award_badge;
}

private function buildDataRetrievalObject(
Expand Down Expand Up @@ -196,7 +198,7 @@ public function getRows(
?array $additional_parameters
): Generator {
$records = $this->getRecords($range, $order);
foreach ($records as $idx => $record) {
foreach ($records as $record) {

$row_id = (string) $record['id'];
if ($this->award_badge !== null) {
Expand Down Expand Up @@ -313,9 +315,28 @@ public function renderTable(): void
$data_retrieval = $this->buildDataRetrievalObject($f, $r, $this->parent_ref_id, $this->award_badge);
$actions = $this->getActions($url_builder, $action_parameter_token, $row_id_token);

$title = '';
if ($this->award_badge) {
$title = $this->lng->txt("badge_award_badge") . ": " . $this->award_badge->getTitle();
$title = $this->lng->txt('badge_award_badge') . ': ' . $this->award_badge->getTitle();
} else {
$parent = '';
$parent_obj_id = ilObject::_lookupObjId($this->parent_ref_id);
if ($parent_obj_id) {
$title = ilObject::_lookupTitle($parent_obj_id);
if (!$title) {
$title = ilObjectDataDeletionLog::get($parent_obj_id);
if ($title) {
$title = $title['title'];
}
}

if ($this->restrict_badge_id) {
$badge = new ilBadge($this->restrict_badge_id);
$title .= ' - ' . $badge->getTitle();
}

$parent = $title . ': ';
}
$title = $parent . $this->lng->txt('users');
}
$table = $f->table()
->data($title, $columns, $data_retrieval)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,6 @@ protected function listObjectBadgeUsers(): void
{
$ilCtrl = $this->ctrl;
$lng = $this->lng;
$tpl = $this->tpl;

$parent_obj_id = $this->badge_request->getParentId();
$parent_ref_ids = ilObject::_getAllReferences($parent_obj_id);
Expand All @@ -657,7 +656,7 @@ protected function listObjectBadgeUsers(): void

$ilCtrl->saveParameter($this, 'pid');

$tbl = new ilBadgeUserTableGUI($parent_ref_id);
$tbl = new ilBadgeUserTableGUI($parent_ref_id, null, $this->badge_request->getBadgeId());
$tbl->renderTable();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ public function renderTable(): void
$actions = $this->getActions($url_builder, $action_parameter_token, $row_id_token);

$table = $f->table()
->data('', $columns, $data_retrieval)
->data($this->lng->txt('badge_object_badges'), $columns, $data_retrieval)
->withActions($actions)
->withRequest($request);

Expand Down

0 comments on commit 9cd2222

Please sign in to comment.