19 declare(strict_types=1);
36 protected int $obj_id,
39 $this->global_settings = $this->domain->settings();
44 $ctrl = $this->gui->ctrl();
45 $next_class = $ctrl->getNextClass($this);
46 $cmd = $ctrl->getCmd(
"edit");
48 switch ($next_class) {
50 if (in_array($cmd, [
"edit",
"save"])) {
56 protected function edit(): void
58 $mt = $this->gui->ui()->mainTemplate();
60 $mt->setContent($form->render());
65 $settings = $this->domain->wikiSettings()->getById($this->obj_id);
66 $start_page_options = $this->domain->wikiSettings()->getStartPageOptions($this->ref_id);
67 $start_page_id = $this->domain->wikiSettings()->getStartPageId($settings);
69 $lng = $this->domain->lng();
70 $lng->loadLanguageModule(
"rating");
73 ->form(self::class,
"save")
74 ->section(
"general",
$lng->txt(
"wiki_settings"))
78 $lng->txt(
"wiki_introduction"),
80 (string) $settings->getIntroduction()
84 $lng->txt(
"wiki_start_page"),
87 $start_page_id ? (string) $start_page_id :
null 89 ->section(
"avail",
$lng->txt(
"rep_activation_availability"))
91 ->addStdAvailability($this->ref_id)
92 ->section(
"presentation",
$lng->txt(
"obj_presentation"))
96 $lng->txt(
"wiki_page_toc"),
97 $lng->txt(
"wiki_page_toc_info"),
98 (bool) $settings->getPageToc()
105 $lng->txt(
"wiki_link_md_values"),
106 $lng->txt(
"wiki_link_md_values_info"),
107 (bool) $settings->getLinkMetadataValues()
112 ->addAdditionalFeatures(
120 $lng->txt(
"rating_activate_rating"),
121 $lng->txt(
"rating_activate_rating_info"),
122 (bool) $settings->getRatingOverall()
126 $lng->txt(
"wiki_activate_rating"),
128 (bool) $settings->getRating()
132 $lng->txt(
"wiki_activate_new_page_rating"),
134 (bool) $settings->getRatingForNewPages()
138 $lng->txt(
"wiki_activate_extended_rating"),
140 (bool) $settings->getRatingCategories()
144 if (!$this->global_settings->get(
"disable_comments")) {
148 $lng->txt(
"wiki_public_comments"),
150 (bool) $settings->getPublicNotes()
157 protected function save(): void
159 $mt = $this->gui->ui()->mainTemplate();
161 $ctrl = $this->gui->ctrl();
162 $lng = $this->domain->lng();
164 $old_settings = $this->domain->wikiSettings()->getById($this->obj_id);
166 if ($form->isValid()) {
168 $form->saveStdTitleAndDescription($this->obj_id,
"wiki");
169 $form->saveStdTile($this->obj_id,
"wiki");
170 $form->saveOnline($this->obj_id,
"wiki");
171 $form->saveStdAvailability($this->ref_id);
172 $form->saveAdditionalFeatures(
179 $link_md_values = $old_settings->getLinkMetadataValues();
181 $link_md_values = (bool) $form->getData(
"link_md_values");
184 $settings = $this->data->settings(
187 $old_settings->getShortTitle(),
188 (bool) $form->getData(
"rating_overall"),
189 (bool) $form->getData(
"rating"),
190 $old_settings->getRatingAsBlock(),
191 (bool) $form->getData(
"rating_new"),
192 (bool) $form->getData(
"rating_ext"),
193 (bool) $form->getData(
"public_notes"),
194 $form->getData(
"introduction"),
195 (bool) $form->getData(
"page_toc"),
197 $old_settings->getEmptyPageTemplate()
199 $this->domain->wikiSettings()->update($settings);
201 $mt->setOnScreenMessage(
"success",
$lng->txt(
"msg_obj_modified"),
true);
202 $ctrl->redirectByClass(self::class,
"edit");
204 $mt = $this->gui->ui()->mainTemplate();
205 $mt->setContent($form->render());
Wiki internal data service.
__construct(protected InternalDataService $data, protected InternalDomainService $domain, protected InternalGUIService $gui, protected int $obj_id, protected int $ref_id)
static lookupTitle(int $a_page_id, string $lang="-")
static _getSelectedRecordsByObject(string $a_obj_type, int $a_id, string $a_sub_type="", bool $is_ref_id=true)
ilSetting $global_settings
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null