ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
class.ilWikiImportantPagesBlockGUI.php
Go to the documentation of this file.
1<?php
2
25{
26 public static string $block_type = "wikiimppages";
27 protected \ILIAS\Wiki\Navigation\ImportantPageManager $imp_pages;
28 protected \ILIAS\Wiki\WikiGUIRequest $wiki_request;
29 protected \ILIAS\Wiki\InternalGUIService $gui;
30 protected \ILIAS\Wiki\Wiki\DomainService $wiki_manager;
31 protected string $lang;
32 protected \ILIAS\Wiki\Page\PageManager $pm;
33 protected \ILIAS\Wiki\InternalDomainService $domain;
34 protected \ILIAS\Wiki\InternalService $service;
35 protected bool $export = false;
36
37 public function __construct()
38 {
39 global $DIC;
40
41 $this->service = $DIC->wiki()->internal();
42
43 $this->domain = $this->service->domain();
44 $this->gui = $this->service->gui();
45 $this->wiki_request = $this->gui->request();
46
47 $ref_id = $this->wiki_request->getRefId();
48 $this->pm = $this->domain->page()->page($ref_id);
49 $this->wiki_manager = $this->domain->wiki();
50 $this->imp_pages = $this->domain->importantPage($ref_id);
51 $this->lang = $this->wiki_request->getTranslation();
52
53 $this->ctrl = $this->gui->ctrl();
54 $this->lng = $this->domain->lng();
55 $this->access = $this->domain->access();
56
58
59 $this->lng->loadLanguageModule("wiki");
60 $this->setEnableNumInfo(false);
61
62 $this->setTitle($this->lng->txt("wiki_navigation"));
63 $this->allow_moving = false;
64 $this->gui = $DIC->wiki()->internal()->gui();
65 }
66
67 public function getBlockType(): string
68 {
69 return self::$block_type;
70 }
71
72 protected function isRepositoryObject(): bool
73 {
74 return false;
75 }
76
77 public function executeCommand(): mixed
78 {
79 $ilCtrl = $this->ctrl;
80
81 $next_class = $ilCtrl->getNextClass();
82 $cmd = $ilCtrl->getCmd("getHTML");
83
84 switch ($next_class) {
85 default:
86 return $this->$cmd();
87 }
88 }
89
90 public function getHTML(bool $a_export = false): string
91 {
92 $ilCtrl = $this->ctrl;
94
95 $this->export = $a_export;
96
97 if (!$this->export && ilWikiPerm::check("edit_wiki_navigation", $this->requested_ref_id)) {
98 $this->addBlockCommand(
99 $ilCtrl->getLinkTargetByClass("ilobjwikigui", "editImportantPages"),
100 $lng->txt("edit")
101 );
102 }
103
104 return parent::getHTML();
105 }
106 protected function getLegacyContent(): string
107 {
108 $ilCtrl = $this->ctrl;
109 $cpar[1] = 0;
110
111 $listing = $this->gui->listing();
112
113 $cnt = 1;
114 $start_page_id = $this->wiki_manager->getStartingPageId($this->requested_ref_id);
115
116 if ($this->pm->exists($start_page_id, $this->lang)) {
117 $title = $this->pm->getTitle($start_page_id, $this->lang);
118 if (!$this->export) {
119 $listing->node($this->ui->factory()->link()->standard(
120 $title,
121 $this->pm->getPermaLink($start_page_id, $this->lang)
122 ), "1", "0");
123 } else {
124 $listing->node($this->ui->factory()->link()->standard(
125 $title,
126 "index.html"
127 ), "1", "0");
128 }
129 }
130
131 $cpar[0] = 1;
132
133 foreach ($this->imp_pages->getList() as $p) {
134 if ($this->pm->exists($p->getId(), $this->lang)) {
135 $cnt++;
136 $title = $this->pm->getTitle($p->getId(), $this->lang);
137 if (!$this->export) {
138 $listing->node($this->ui->factory()->link()->standard(
139 $title,
140 $this->pm->getPermaLink($p->getId(), $this->lang)
141 ), (string) $cnt, (string) ($cpar[$p->getIndent() - 1] ?? 0));
142 } else {
143 $listing->node($this->ui->factory()->link()->standard(
144 $title,
145 "wpg_" . $p->getId() . ".html"
146 ), (string) $cnt, (string) ($cpar[$p->getIndent() - 1] ?? 0));
147 }
148 $cpar[$p->getIndent()] = $cnt;
149 }
150 }
151
152 return $listing->render();
153 }
154}
This class represents a block method of a block.
ilLanguage $lng
setTitle(string $a_title)
addBlockCommand(string $a_href, string $a_text, string $a_onclick="", ?RoundTrip $modal=null)
setEnableNumInfo(bool $a_enablenuminfo)
getNextClass($a_gui_class=null)
@inheritDoc
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ILIAS Wiki Navigation ImportantPageManager $imp_pages
isRepositoryObject()
Returns whether block has a corresponding repository object.
ILIAS Wiki InternalDomainService $domain
static check(string $a_perm, int $a_ref_id, string $a_cmd="")
$ref_id
Definition: ltiauth.php:66
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26