ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ContributorsTableBuilder.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Wiki\Page;
22
26use ILIAS\UI\Component\Listing\Unordered as UnorderedListing;
29
31{
32 public function __construct(
33 protected InternalDomainService $domain,
34 protected InternalGUIService $gui,
35 protected int $wiki_id,
36 object $parent_gui,
37 string $parent_cmd
38 ) {
39 parent::__construct($parent_gui, $parent_cmd);
40 }
41
42 protected function getId(): string
43 {
44 return "wiki_contributors";
45 }
46
47 protected function getTitle(): string
48 {
49 return $this->domain->lng()->txt("wiki_contributors");
50 }
51
52 protected function getRetrieval(): RetrievalInterface
53 {
54 return $this->domain->page()->contributorsRetrieval($this->wiki_id);
55 }
56
57 protected function transformRow(array $data_row): array
58 {
59 return [
60 "id" => $data_row["id"],
61 "name" => $data_row["name"],
62 "pages" => $this->buildPageListing($data_row["pages"]),
63 "grading" => $this->getGradingLabel(
64 $data_row["status"],
65 $data_row["status_date"]
66 ),
67 "mark" => $data_row["mark"]
68 ];
69 }
70
71 protected function buildPageListing(array $pages): UnorderedListing
72 {
73 $f = $this->gui->ui()->factory();
74 $items = [];
75 arsort($pages);
76
77 foreach ($pages as $page_id => $count) {
78 if ($page_id > 0) {
79 $link = $f->link()->standard(
80 \ilWikiPage::lookupTitle((int) $page_id) . " (" . $count . ")",
81 ""
82 )->withDisabled();
83 $items[] = $link;
84 }
85 }
86
87 return $f->listing()->unordered($items);
88 }
89
90 protected function getGradingLabel(int $status, ?string $status_date): string
91 {
92 $lng = $this->domain->lng();
93 $label = match ($status) {
94 \ilWikiContributor::STATUS_PASSED => $lng->txt("wiki_passed"),
95 \ilWikiContributor::STATUS_FAILED => $lng->txt("wiki_failed"),
96 default => $lng->txt("wiki_notgraded")
97 };
98
99 if ($status_date !== null && $status_date !== "") {
100 $label .= " (" . \ilDatePresentation::formatDate(
101 new \ilDateTime($status_date, IL_CAL_DATETIME)
102 ) . ")";
103 }
104
105 return $label;
106 }
107
109 {
110 $lng = $this->domain->lng();
111
112 return $table
113 ->textColumn("name", $lng->txt("wiki_contributors"), true)
114 ->linkListingColumn("pages", $lng->txt("wiki_page_changes"))
115 ->textColumn("grading", $lng->txt("wiki_grading"))
116 ->textColumn("mark", $lng->txt("wiki_mark"))
117 ->singleAction("editGrading", $lng->txt("wiki_grading"), true)
118 ->singleAction("editMark", $lng->txt("wiki_mark"), true);
119 }
120}
textColumn(string $key, string $title, bool $sortable=false)
getGradingLabel(int $status, ?string $status_date)
transformRow(array $data_row)
transform raw data array to table row data array
__construct(protected InternalDomainService $domain, protected InternalGUIService $gui, protected int $wiki_id, object $parent_gui, string $parent_cmd)
const IL_CAL_DATETIME
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
static lookupTitle(int $a_page_id, string $lang="-")
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $lng
Definition: privfeed.php:26