19 declare(strict_types=1);
32 protected \ILIAS\Notes\DomainService
$notes;
35 protected InternalDataService
$data,
37 protected InternalGUIService $gui,
38 protected int $obj_id,
39 protected bool $in_repository
41 $this->notes = $domain->notes();
42 $this->global_settings = $domain->settings();
43 $this->reading_time_gui = $gui->readingTime()->settingsGUI($obj_id);
48 $ctrl = $this->gui->ctrl();
49 $next_class = $ctrl->getNextClass($this);
50 $cmd = $ctrl->getCmd(
"edit");
52 switch ($next_class) {
54 if (in_array($cmd, [
"edit",
"save"])) {
60 protected function edit(): void
62 $mt = $this->gui->ui()->mainTemplate();
64 $mt->setContent($form->render());
69 $settings = $this->domain->blogSettings()->getByObjId($this->obj_id);
71 $lng = $this->domain->lng();
72 $form = $this->gui->form(self::class,
"save")
73 ->section(
"general",
$lng->txt(
"blog_edit"))
79 if ($this->in_repository) {
80 $form = $form->checkbox(
82 $lng->txt(
"blog_enable_approval"),
83 $lng->txt(
"blog_enable_approval_info"),
84 $settings->getApproval()
88 $form = $form->checkbox(
90 $lng->txt(
"blog_enable_notes"),
92 $this->notes->commentsActive($this->obj_id)
95 if ($this->global_settings->get(
'enable_global_profiles')) {
96 $form = $form->checkbox(
98 $lng->txt(
"blog_enable_rss"),
99 "blog_enable_rss_info",
104 $form = $form->section(
"availibility",
$lng->txt(
"rep_activation_availability"))
107 $form = $form->section(
"nav",
$lng->txt(
"blog_settings_navigation"))
108 ->
switch(
"nav_mode",
$lng->txt(
"blog_nav_mode"),
"", (string) $settings->getNavMode())
111 $lng->txt(
"blog_nav_mode_month_list"),
112 $lng->txt(
"blog_nav_mode_month_list_info")
116 $lng->txt(
"blog_nav_mode_month_list_num_month"),
117 $lng->txt(
"blog_nav_mode_month_list_num_month_info"),
118 (
int) $settings->getNavModeListMonths(),
122 "nav_list_mon_with_post",
123 $lng->txt(
"blog_nav_mode_month_list_num_month_with_post"),
124 $lng->txt(
"blog_nav_mode_month_list_num_month_with_post_info"),
125 (
int) $settings->getNavModeListMonthsWithPostings()
129 $lng->txt(
"blog_nav_mode_month_single"),
130 $lng->txt(
"blog_nav_mode_month_single_info")
134 if ($this->in_repository) {
135 $form = $form->checkbox(
137 $lng->txt(
"blog_enable_nav_authors"),
138 $lng->txt(
"blog_enable_nav_authors_info"),
139 $settings->getAuthors()
146 $lng->txt(
"blog_enable_keywords"),
147 $lng->txt(
"blog_enable_keywords_info"),
148 $settings->getKeywords()
150 ->section(
"presentation",
$lng->txt(
"blog_presentation_frame"));
152 if ($this->in_repository) {
153 $form = $form->addStdTile(
159 $info = ($this->in_repository)
160 ?
$lng->txt(
"blog_profile_picture_repository_info")
163 $form = $form->checkbox(
165 $lng->txt(
"blog_profile_picture"),
167 $settings->getProfilePicture()
170 $form = $this->reading_time_gui->addSettingToFormAdapter($form);
173 ->section(
"pres_overview",
$lng->txt(
"blog_presentation_overview"))
176 $lng->txt(
"blog_list_num_postings"),
177 $lng->txt(
"blog_list_num_postings_info"),
178 (
int) $settings->getOverviewPostings()
182 $lng->txt(
"blog_abstract_shorten"),
184 $settings->getAbstractShorten()
188 $lng->txt(
"blog_abstract_shorten_length"),
189 $lng->txt(
"blog_abstract_shorten_characters"),
190 $settings->getAbstractShortenLength()
195 $lng->txt(
"blog_abstract_image"),
196 $lng->txt(
"blog_abstract_image_info"),
197 $settings->getAbstractImage()
201 $lng->txt(
"blog_abstract_image_width"),
202 $lng->txt(
"blog_abstract_image_pixels"),
203 $settings->getAbstractImageWidth(),
208 $lng->txt(
"blog_abstract_image_height"),
209 $lng->txt(
"blog_abstract_image_pixels"),
210 $settings->getAbstractImageHeight(),
218 protected function save(): void
220 $mt = $this->gui->ui()->mainTemplate();
222 $ctrl = $this->gui->ctrl();
223 $lng = $this->domain->lng();
225 $old_settings = $this->domain->blogSettings()->getByObjId($this->obj_id);
227 if ($form->isValid()) {
228 $form->saveStdTitleAndDescription(
241 $this->notes->activateComments($this->obj_id, (
bool) $form->getData(
"notes"));
243 $this->reading_time_gui->saveSettingFromFormAdapter($form);
245 $settings = $this->data->settings(
247 (
bool) $form->getData(
"ppic"),
250 $this->global_settings->get(
'enable_global_profiles')
251 ? (bool) $form->getData(
"ppic")
254 ? (bool) $form->getData(
"approval")
256 (bool) $form->getData(
"abss"),
257 (bool) $form->getData(
"abss")
258 ? (
int) $form->getData(
"abssl")
260 (bool) $form->getData(
"absi"),
261 (bool) $form->getData(
"absi")
262 ? (
int) $form->getData(
"absiw")
264 (bool) $form->getData(
"absi")
265 ? (
int) $form->getData(
"absih")
267 (bool) $form->getData(
"keywords"),
269 ? (bool) $form->getData(
"nav_authors")
271 (
int) $form->getData(
"nav_mode"),
273 ? (
int) $form->getData(
"nav_list_mon_with_post")
276 ? (
int) $form->getData(
"nav_list_mon")
278 (
int) $form->getData(
"ov_list_post_num"),
279 $old_settings->getOrder()
282 $this->domain->blogSettings()->update($settings);
284 $mt->setOnScreenMessage(
"success",
$lng->txt(
"msg_obj_modified"),
true);
285 $ctrl->redirectByClass(self::class,
"edit");
287 $mt = $this->gui->ui()->mainTemplate();
288 $mt->setContent($form->render());
ILIAS Notes DomainService $notes
__construct(protected InternalDataService $data, protected InternalDomainService $domain, protected InternalGUIService $gui, protected int $obj_id, protected bool $in_repository)
ilSetting $global_settings
ILIAS Blog ReadingTime BlogSettingsGUI $reading_time_gui