Skip to content

Commit ec6407c

Browse files
committed
wiki: add missing classes
1 parent 77cb754 commit ec6407c

2 files changed

Lines changed: 171 additions & 0 deletions

File tree

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
3+
/**
4+
* This file is part of ILIAS, a powerful learning management system
5+
* published by ILIAS open source e-Learning e.V.
6+
*
7+
* ILIAS is licensed with the GPL-3.0,
8+
* see https://www.gnu.org/licenses/gpl-3.0.en.html
9+
* You should have received a copy of said license along with the
10+
* source code, too.
11+
*
12+
* If this is not the case or you just want to try ILIAS, you'll find
13+
* us at:
14+
* https://www.ilias.de
15+
* https://github.com/ILIAS-eLearning
16+
*
17+
*********************************************************************/
18+
19+
declare(strict_types=1);
20+
21+
namespace ILIAS\Wiki\Page;
22+
23+
use ILIAS\Data\Order;
24+
use ILIAS\Data\Range;
25+
use ILIAS\Repository\RetrievalBase;
26+
use ILIAS\Repository\RetrievalInterface;
27+
28+
class PageTemplateRetrieval implements RetrievalInterface
29+
{
30+
use RetrievalBase;
31+
32+
public function __construct(
33+
protected int $wiki_id
34+
) {
35+
}
36+
37+
public function getData(
38+
array $fields,
39+
?Range $range = null,
40+
?Order $order = null,
41+
array $filter = [],
42+
array $parameters = []
43+
): \Generator {
44+
$data = [];
45+
$templates = new \ilWikiPageTemplate($this->wiki_id);
46+
foreach ($templates->getAllInfo() as $template) {
47+
$template['id'] = (int) $template['wpage_id'];
48+
$data[] = $template;
49+
}
50+
51+
$data = $this->applyOrder($data, $order);
52+
$data = $this->applyRange($data, $range);
53+
54+
foreach ($data as $template) {
55+
yield $template;
56+
}
57+
}
58+
59+
public function count(array $filter, array $parameters): int
60+
{
61+
$templates = new \ilWikiPageTemplate($this->wiki_id);
62+
return count($templates->getAllInfo());
63+
}
64+
65+
public function isFieldNumeric(string $field): bool
66+
{
67+
return $field === 'id' || $field === 'wpage_id';
68+
}
69+
}
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<?php
2+
3+
/**
4+
* This file is part of ILIAS, a powerful learning management system
5+
* published by ILIAS open source e-Learning e.V.
6+
*
7+
* ILIAS is licensed with the GPL-3.0,
8+
* see https://www.gnu.org/licenses/gpl-3.0.en.html
9+
* You should have received a copy of said license along with the
10+
* source code, too.
11+
*
12+
* If this is not the case or you just want to try ILIAS, you'll find
13+
* us at:
14+
* https://www.ilias.de
15+
* https://github.com/ILIAS-eLearning
16+
*
17+
*********************************************************************/
18+
19+
declare(strict_types=1);
20+
21+
namespace ILIAS\Wiki\Page;
22+
23+
use ILIAS\ILIASObject\Properties\Translations\Translations;
24+
use ILIAS\Repository\RetrievalInterface;
25+
use ILIAS\Repository\Table\CommonTableBuilder;
26+
use ILIAS\Repository\Table\TableAdapterGUI;
27+
28+
class PageTemplateTableBuilder extends CommonTableBuilder
29+
{
30+
protected PageManager $pm;
31+
protected Translations $translations;
32+
33+
public function __construct(
34+
protected \ILIAS\Wiki\InternalDomainService $domain,
35+
protected \ILIAS\Wiki\InternalGUIService $gui,
36+
protected int $wiki_id,
37+
object $parent_gui,
38+
string $parent_cmd
39+
) {
40+
$ref_id = $this->gui->request()->getRefId();
41+
$this->translations = $this->domain->wiki()->translation($ref_id);
42+
$this->pm = $this->domain->page()->page($ref_id);
43+
44+
parent::__construct($parent_gui, $parent_cmd);
45+
}
46+
47+
protected function getId(): string
48+
{
49+
return 'wiki_page_templates_' . $this->wiki_id;
50+
}
51+
52+
protected function getTitle(): string
53+
{
54+
return '';
55+
}
56+
57+
protected function getRetrieval(): RetrievalInterface
58+
{
59+
return $this->domain->page()->pageTemplateRetrieval($this->wiki_id);
60+
}
61+
62+
protected function transformRow(array $data_row): array
63+
{
64+
$lng = $this->domain->lng();
65+
66+
return [
67+
'id' => $data_row['id'],
68+
'title' => $data_row['title'],
69+
'translations' => $this->translations->getContentTranslationActivated()
70+
? implode(', ', $this->pm->getLanguages((int) $data_row['wpage_id']))
71+
: '',
72+
'new_pages' => $data_row['new_pages'] ? $lng->txt('yes') : $lng->txt('no'),
73+
'add_to_page' => $data_row['add_to_page'] ? $lng->txt('yes') : $lng->txt('no')
74+
];
75+
}
76+
77+
protected function build(TableAdapterGUI $table): TableAdapterGUI
78+
{
79+
$lng = $this->domain->lng();
80+
81+
$table = $table
82+
->textColumn('title', $lng->txt('title'), true);
83+
84+
if ($this->translations->getContentTranslationActivated()) {
85+
$table = $table->textColumn(
86+
'translations',
87+
$lng->txt('wiki_translations')
88+
);
89+
}
90+
91+
return $table
92+
->textColumn('new_pages', $lng->txt('wiki_templ_new_pages'))
93+
->textColumn('add_to_page', $lng->txt('wiki_templ_add_to_page'))
94+
->singleAction('toggleNewPages', $lng->txt('wiki_templ_new_pages'))
95+
->singleAction('toggleAddToPage', $lng->txt('wiki_templ_add_to_page'))
96+
->multiAction(
97+
'confirmRemove',
98+
$lng->txt('wiki_remove_template_status'),
99+
true
100+
);
101+
}
102+
}

0 commit comments

Comments
 (0)