diff --git a/components/ILIAS/Administration/GlobalScreen/classes/AdministrationMainBarProvider.php b/components/ILIAS/Administration/GlobalScreen/classes/AdministrationMainBarProvider.php
index 3f9baaa54ae2..660af1b3f27f 100755
--- a/components/ILIAS/Administration/GlobalScreen/classes/AdministrationMainBarProvider.php
+++ b/components/ILIAS/Administration/GlobalScreen/classes/AdministrationMainBarProvider.php
@@ -225,7 +225,7 @@ private function getGroups(): array
// admin menu layout
$layout = array(
"maintenance" =>
- array("adma", "serv", "cron", "bnmk", "lngf", "hlps", "wfe", 'fils', 'logs', 'sysc', "recf", "root"),
+ array("adma", "serv", "cron", "bnmk", "lngf", "hlps", "wfe", 'fils', 'qsts', 'logs', 'sysc', "recf", "root"),
"layout_and_navigation" =>
array("mme", "gsfo", "dshs", "stys", "adve", "stus"),
"repository_and_objects" =>
diff --git a/components/ILIAS/BackgroundTasks_/classes/Jobs/class.ilCollectFilesJob.php b/components/ILIAS/BackgroundTasks_/classes/Jobs/class.ilCollectFilesJob.php
index 3dae62a64972..140b8fced1f6 100755
--- a/components/ILIAS/BackgroundTasks_/classes/Jobs/class.ilCollectFilesJob.php
+++ b/components/ILIAS/BackgroundTasks_/classes/Jobs/class.ilCollectFilesJob.php
@@ -97,21 +97,37 @@ public function run(array $input, Observer $observer): Value
foreach ($object_ref_ids as $object_ref_id) {
$object = ilObjectFactory::getInstanceByRefId($object_ref_id);
+ if (!$object instanceof ilObject) {
+ continue;
+ }
+
$object_type = $object->getType();
$object_name = $object->getTitle();
- $object_temp_dir = ""; // empty as content will be added in recurseFolder and getFileDirs
+ $object_temp_dir = ''; // empty as content will be added in recurseFolder and getFileDirs
- if ($object_type === "fold" || $object_type === "crs") {
+ if (in_array($object_type, ['fold', 'crs', 'grp'], true)) {
$num_recursions = 0;
- $files_from_folder = $this->recurseFolder($object_ref_id, $object_name, $object_temp_dir, $num_recursions, $initiated_by_folder_action);
+ $files_from_folder = $this->recurseFolder(
+ $object_ref_id,
+ $object_name,
+ $object_temp_dir,
+ $num_recursions,
+ $initiated_by_folder_action
+ );
$files = array_merge($files, $files_from_folder);
- } elseif (($object_type === "file") && (($file_dirs = $this->getFileDirs(
- $object_ref_id,
- $object_name,
- $object_temp_dir
- )) !== false)) {
- $files[] = $file_dirs;
+ continue;
}
+
+ if ($object_type !== 'file') {
+ continue;
+ }
+
+ $file_dirs = $this->getFileDirs($object_ref_id, $object_name, $object_temp_dir);
+ if (!is_array($file_dirs)) {
+ continue;
+ }
+
+ $files[] = $file_dirs;
}
$this->logger->debug('Collected files:');
$this->logger->dump($files);
diff --git a/components/ILIAS/Blog/Contributor/ContributorGUI.php b/components/ILIAS/Blog/Contributor/ContributorGUI.php
new file mode 100644
index 000000000000..c2a277e0581e
--- /dev/null
+++ b/components/ILIAS/Blog/Contributor/ContributorGUI.php
@@ -0,0 +1,262 @@
+gui->ctrl();
+ $next_class = $ctrl->getNextClass($this);
+ $cmd = $ctrl->getCmd("contributors");
+
+ switch ($next_class) {
+ case strtolower(\ilRepositorySearchGUI::class):
+ $rep_search = new \ilRepositorySearchGUI();
+ $rep_search->setTitle($this->domain->lng()->txt("blog_add_contributor"));
+ $rep_search->setCallback($this, 'addContributor', $this->blog->getAllLocalRoles($this->node_id));
+ $ctrl->setReturn($this, 'contributors');
+ $ctrl->forwardCommand($rep_search);
+ break;
+
+ default:
+ if (method_exists($this, $cmd)) {
+ $this->$cmd();
+ }
+ break;
+ }
+ }
+
+ public function contributors(): void
+ {
+ $ilTabs = $this->gui->tabs();
+ $ilToolbar = $this->gui->toolbar();
+ $ilCtrl = $this->gui->ctrl();
+ $lng = $this->domain->lng();
+ $tpl = $this->gui->ui()->mainTemplate();
+
+ $ilTabs->activateTab("contributors");
+
+ $local_roles = $this->blog->getAllLocalRoles($this->node_id);
+
+ // add member
+ ilRepositorySearchGUI::fillAutoCompleteToolbar(
+ $this,
+ $ilToolbar,
+ array(
+ 'auto_complete_name' => $lng->txt('user'),
+ 'submit_name' => $lng->txt('add'),
+ 'add_search' => true,
+ 'add_from_container' => $this->node_id,
+ 'user_type' => $local_roles
+ ),
+ true
+ );
+
+ $other_roles = $this->blog->getRolesWithContributeOrRedact($this->node_id);
+ if ($other_roles) {
+ $tpl->setOnScreenMessage('info', sprintf($lng->txt("blog_contribute_other_roles"), implode(", ", $other_roles)));
+ }
+
+ $table = $this->gui->contributor()->contributorTableBuilder(
+ $this->blog->getAllLocalRoles($this->node_id),
+ $this,
+ "contributors"
+ )->getTable();
+
+ if ($table->handleCommand()) {
+ return;
+ }
+
+ $tpl->setContent($table->render());
+ }
+
+ /**
+ * Autocomplete submit
+ */
+ public function addUserFromAutoComplete(): void
+ {
+ $lng = $this->domain->lng();
+ $req = $this->gui->standardRequest();
+
+ $user_login = $req->getUserLogin();
+ $user_type = $req->getUserType();
+
+ if (trim($user_login) === '') {
+ $this->gui->ui()->mainTemplate()->setOnScreenMessage('failure', $lng->txt('msg_no_search_string'));
+ $this->contributors();
+ return;
+ }
+ $users = explode(',', $user_login);
+
+ $user_ids = array();
+ foreach ($users as $user) {
+ $user_id = ilObjUser::_lookupId($user);
+
+ if (!$user_id) {
+ $this->gui->ui()->mainTemplate()->setOnScreenMessage('failure', $lng->txt('user_not_known'));
+ $this->contributors();
+ return;
+ }
+
+ $user_ids[] = (int) $user_id;
+ }
+
+ $this->addContributor($user_ids, $user_type);
+ }
+
+ /**
+ * Centralized method to add contributors
+ */
+ public function addContributor(
+ array $a_user_ids = array(),
+ ?string $a_user_type = null
+ ): void {
+ $ilCtrl = $this->gui->ctrl();
+ $lng = $this->domain->lng();
+ $rbacreview = $this->domain->rbac()->review();
+ $rbacadmin = $this->domain->rbac()->admin();
+ $a_user_type = (int) $a_user_type;
+
+ if (empty($a_user_ids)) {
+ $a_user_ids = $this->gui->standardRequest()->getIds();
+ }
+
+ if (!count($a_user_ids) || !$a_user_type) {
+ $this->gui->ui()->mainTemplate()->setOnScreenMessage('failure', $lng->txt("no_checkbox"));
+ $this->contributors();
+ return;
+ }
+
+ // get contributor role
+ $local_roles = array_keys($this->blog->getAllLocalRoles($this->node_id));
+ if (!in_array($a_user_type, $local_roles)) {
+ $this->gui->ui()->mainTemplate()->setOnScreenMessage('failure', $lng->txt("missing_perm"));
+ $this->contributors();
+ return;
+ }
+
+ foreach ($a_user_ids as $user_id) {
+ $user_id = (int) $user_id;
+ $a_user_type = (int) $a_user_type;
+ if (!$rbacreview->isAssigned($user_id, $a_user_type)) {
+ $rbacadmin->assignUser($a_user_type, $user_id);
+ }
+ }
+
+ $this->gui->ui()->mainTemplate()->setOnScreenMessage('success', $lng->txt("settings_saved"), true);
+ $ilCtrl->redirect($this, "contributors");
+ }
+
+ /**
+ * Used in ContributorTableBuilder
+ */
+ public function confirmRemoveContributor(array $ids = []): void
+ {
+ if (empty($ids)) {
+ $ids = $this->gui->standardRequest()->getIds();
+ }
+ if (count($ids) === 0) {
+ $this->gui->ui()->mainTemplate()->setOnScreenMessage('failure', $this->domain->lng()->txt("select_one"), true);
+ $this->gui->ctrl()->redirect($this, "contributors");
+ }
+
+ $confirm = new ilConfirmationGUI();
+ $confirm->setHeaderText($this->domain->lng()->txt('blog_confirm_delete_contributors'));
+ $confirm->setFormAction($this->gui->ctrl()->getFormAction($this, 'removeContributor'));
+ $confirm->setConfirm($this->domain->lng()->txt('delete'), 'removeContributor');
+ $confirm->setCancel($this->domain->lng()->txt('cancel'), 'contributors');
+
+ foreach ($ids as $user_id) {
+ $confirm->addItem(
+ 'id[]',
+ (string) $user_id,
+ \ilUserUtil::getNamePresentation($user_id, false, false, "", true)
+ );
+ }
+
+ $this->gui->ui()->mainTemplate()->setContent($confirm->getHTML());
+ }
+
+ public function removeContributor(): void
+ {
+ $ilCtrl = $this->gui->ctrl();
+ $lng = $this->domain->lng();
+ $rbacadmin = $this->domain->rbac()->admin();
+
+ $ids = $this->gui->standardRequest()->getIds();
+
+ if (count($ids) === 0) {
+ $this->gui->ui()->mainTemplate()->setOnScreenMessage('failure', $lng->txt("select_one"), true);
+ $ilCtrl->redirect($this, "contributors");
+ }
+
+ // get contributor role
+ $local_roles = array_keys($this->blog->getAllLocalRoles($this->node_id));
+ if (!$local_roles) {
+ $this->gui->ui()->mainTemplate()->setOnScreenMessage('failure', $lng->txt("missing_perm"));
+ $this->contributors();
+ return;
+ }
+
+ foreach ($ids as $user_id) {
+ foreach ($local_roles as $role_id) {
+ $rbacadmin->deassignUser($role_id, $user_id);
+ }
+ }
+
+ $this->gui->ui()->mainTemplate()->setOnScreenMessage('success', $lng->txt("settings_saved"), true);
+ $this->gui->ctrl()->redirect($this, "contributors");
+ }
+
+ /**
+ * Used in ContributorTableBuilder
+ */
+ public function addContributorContainerAction(array $ids = []): void
+ {
+ if (empty($ids)) {
+ $ids = $this->gui->standardRequest()->getIds();
+ }
+
+ // This would typically add contributors from a container
+ // For now, redirecting back to contributors as this seems to be a placeholder action
+ $this->gui->ctrl()->redirect($this, "contributors");
+ }
+}
diff --git a/components/ILIAS/Blog/Contributor/Service/class.GUIService.php b/components/ILIAS/Blog/Contributor/Service/class.GUIService.php
index ef8de2f00f64..8007e5d6d2d8 100755
--- a/components/ILIAS/Blog/Contributor/Service/class.GUIService.php
+++ b/components/ILIAS/Blog/Contributor/Service/class.GUIService.php
@@ -57,4 +57,15 @@ public function contributorTableBuilder(
$parent_cmd
);
}
+
+ public function contributorGUI(int $node_id, \ilObjBlog $blog): ContributorGUI
+ {
+ return new ContributorGUI(
+ $this->data_service,
+ $this->domain_service,
+ $this->gui,
+ $node_id,
+ $blog
+ );
+ }
}
diff --git a/components/ILIAS/Blog/Export/BlogHtmlExport.php b/components/ILIAS/Blog/Export/BlogHtmlExport.php
index b94f698f5158..e23f6447c2da 100755
--- a/components/ILIAS/Blog/Export/BlogHtmlExport.php
+++ b/components/ILIAS/Blog/Export/BlogHtmlExport.php
@@ -56,11 +56,13 @@ public function __construct(
$this->blog_gui = $blog_gui;
/** @var \ilObjBlog $blog */
$blog = $blog_gui->getObject();
+ $this->blog = $blog;
+
+ $blog_service = $DIC->blog()->internal();
+
$this->collector = $DIC->export()->domain()->html()->collector($blog->getId());
$this->collector->init();
- $this->blog = $blog;
- //$this->export_dir = $exp_dir;
$this->sub_dir = $sub_dir;
$this->target_dir = $exp_dir . "/" . $sub_dir;
@@ -86,7 +88,7 @@ public function __construct(
} else {
$this->content_style_domain = $cs->domain()->styleForObjId($this->blog->getId());
}
- $this->posting_manager = $DIC->blog()->internal()->domain()->posting();
+ $this->posting_manager = $blog_service->domain()->posting();
}
protected function init(): void
{
@@ -339,8 +341,6 @@ public function buildExportLink(
protected function getInitialisedTemplate(
string $a_back_url = ""
): \ilGlobalPageTemplate {
- global $DIC;
-
$this->export_util->resetGlobalScreen();
$location_stylesheet = \ilUtil::getStyleSheetLocation();
@@ -350,13 +350,16 @@ protected function getInitialisedTemplate(
);
\ilPCQuestion::resetInitialState();
- $tabs = $DIC->tabs();
+ $tabs = $this->tabs;
$tabs->clearTargets();
$tabs->clearSubTabs();
if ($a_back_url) {
$tabs->setBackTarget($this->lng->txt("back"), $a_back_url);
}
- $tpl = new \ilGlobalPageTemplate($DIC->globalScreen(), $DIC->ui(), $DIC->http());
+
+ /** @var \ILIAS\DI\Container $DIC */
+ global $DIC;
+ $tpl = new \ilGlobalPageTemplate($this->global_screen, $DIC->ui(), $DIC->http());
$this->co_page_html_export->getPreparedMainTemplate($tpl);
diff --git a/components/ILIAS/Blog/Export/class.ilBlogDataSet.php b/components/ILIAS/Blog/Export/class.ilBlogDataSet.php
index b3aa993583a5..b8f8e9195cbe 100755
--- a/components/ILIAS/Blog/Export/class.ilBlogDataSet.php
+++ b/components/ILIAS/Blog/Export/class.ilBlogDataSet.php
@@ -44,13 +44,15 @@ public function __construct()
{
global $DIC;
parent::__construct();
+
+ $blog_service = $DIC->blog()->internal();
+
$this->content_style_domain = $DIC
->contentStyle()
->domain();
$this->notes = $DIC->notes();
- $this->reading_time = $DIC->blog()->internal()->domain()->readingTime();
- $this->blog_settings = $DIC->blog()->internal()->domain()->blogSettings();
- $this->service = $DIC->blog()->internal();
+ $this->reading_time = $blog_service->domain()->readingTime();
+ $this->blog_settings = $blog_service->domain()->blogSettings();
}
public function getSupportedVersions(): array
@@ -285,7 +287,7 @@ public function readData(
// keywords
foreach ($this->data as $idx => $item) {
- $blog_id = ilBlogPosting::lookupBlogId($item["Id"]);
+ $blog_id = $this->service->domain()->posting()->lookupBlogId((int) $item["Id"]);
$keywords = $this->service->domain()->posting()->getKeywords((int) $blog_id, (int) $item["Id"]);
if ($keywords) {
foreach ($keywords as $kidx => $keyword) {
diff --git a/components/ILIAS/Blog/Export/class.ilBlogExporter.php b/components/ILIAS/Blog/Export/class.ilBlogExporter.php
index ca20e3be90f0..4132a223fb5f 100755
--- a/components/ILIAS/Blog/Export/class.ilBlogExporter.php
+++ b/components/ILIAS/Blog/Export/class.ilBlogExporter.php
@@ -28,16 +28,23 @@ class ilBlogExporter extends ilXmlExporter
protected ilBlogDataSet $ds;
protected \ILIAS\Style\Content\DomainService $content_style_domain;
- public function init(): void
+ public function __construct()
{
global $DIC;
+ parent::__construct();
+ $blog_service = $DIC->blog()->internal();
- $this->ds = new ilBlogDataSet();
- $this->ds->setDSPrefix("ds");
$this->content_style_domain = $DIC
->contentStyle()
->domain();
- $this->posting_manager = $DIC->blog()->internal()->domain()->posting();
+ $this->posting_manager = $blog_service->domain()->posting();
+ }
+
+
+ public function init(): void
+ {
+ $this->ds = new ilBlogDataSet();
+ $this->ds->setDSPrefix("ds");
}
public function getXmlExportTailDependencies(
diff --git a/components/ILIAS/Blog/Export/class.ilBlogImporter.php b/components/ILIAS/Blog/Export/class.ilBlogImporter.php
index 4481de258d39..d0c21290b127 100755
--- a/components/ILIAS/Blog/Export/class.ilBlogImporter.php
+++ b/components/ILIAS/Blog/Export/class.ilBlogImporter.php
@@ -25,19 +25,23 @@
*/
class ilBlogImporter extends ilXmlImporter
{
+ protected \ILIAS\Blog\InternalService $blog_service;
protected ilBlogDataSet $ds;
protected \ILIAS\Style\Content\DomainService $content_style_domain;
- public function init(): void
+ public function __construct()
{
global $DIC;
-
- $this->ds = new ilBlogDataSet();
- $this->ds->setDSPrefix("ds");
$this->content_style_domain = $DIC
->contentStyle()
->domain();
+ $this->blog_service = $DIC->blog()->internal();
+ }
+ public function init(): void
+ {
+ $this->ds = new ilBlogDataSet();
+ $this->ds->setDSPrefix("ds");
$cop_config = $this->getImport()->getConfig("components/ILIAS/COPage");
$cop_config->setUpdateIfExists(true);
}
@@ -64,7 +68,7 @@ public function finalProcessing(
$blp_map = $a_mapping->getMappingsOfEntity("components/ILIAS/COPage", "pg");
foreach ($blp_map as $blp_id) {
$blp_id = (int) substr($blp_id, 4);
- $blog_id = ilBlogPosting::lookupBlogId($blp_id);
+ $blog_id = $this->blog_service->domain()->posting()->lookupBlogId($blp_id);
ilBlogPosting::_writeParentId("blp", $blp_id, (int) $blog_id);
}
diff --git a/components/ILIAS/Blog/Navigation/AuthorBlockGUI.php b/components/ILIAS/Blog/Navigation/AuthorBlockGUI.php
new file mode 100644
index 000000000000..6a88ce305357
--- /dev/null
+++ b/components/ILIAS/Blog/Navigation/AuthorBlockGUI.php
@@ -0,0 +1,122 @@
+domain = $domain;
+ $this->gui = $gui;
+ }
+
+ /**
+ * @param Posting[][] $items
+ */
+ public function render(
+ array $items,
+ string $list_cmd = "render",
+ bool $show_inactive = false
+ ): string {
+ $ctrl = $this->gui->ctrl();
+ $lng = $this->domain->lng();
+
+ $authors = array();
+ foreach ($items as $month => $month_items) {
+ foreach ($month_items as $item) {
+ $item_id = $item->getId();
+ if (($show_inactive || \ilBlogPosting::_lookupActive($item_id, "blp"))) {
+ $author_id = $item->getAuthor();
+ if ($author_id) {
+ $authors[] = $author_id;
+ }
+ foreach (\ilPageObject::getPageContributors("blp", $item_id) as $editor) {
+ $editor_id = (int) $editor["user_id"];
+ if ($editor_id !== $author_id) {
+ $authors[] = $editor_id;
+ }
+ }
+ }
+ }
+ }
+
+ $authors = array_unique($authors);
+
+ // filter out deleted users
+ $authors = array_filter($authors, function ($id) {
+ return \ilObject::_lookupType($id) == "usr";
+ });
+
+ if (count($authors) > 1) {
+ $list = array();
+ foreach ($authors as $user_id) {
+ if ($user_id) {
+ $ctrl->setParameterByClass(\ilObjBlogGUI::class, "ath", (string) $user_id);
+ $url = $ctrl->getLinkTargetByClass(\ilObjBlogGUI::class, $list_cmd);
+ $ctrl->setParameterByClass(\ilObjBlogGUI::class, "ath", "");
+
+ $base_name = \ilUserUtil::getNamePresentation($user_id);
+ if (str_starts_with($base_name, "[")) {
+ $name = \ilUserUtil::getNamePresentation($user_id, true);
+ $sort = $name;
+ } else {
+ $name = \ilUserUtil::getNamePresentation(
+ $user_id,
+ true,
+ false,
+ "",
+ false,
+ true,
+ false
+ );
+ $name_arr = \ilObjUser::_lookupName($user_id);
+ $sort = $name_arr["lastname"] . " " . $name_arr["firstname"];
+ }
+
+ $idx = trim(strip_tags((string) $sort)) . "///" . $user_id;
+ $list[$idx] = array($name, $url);
+ }
+ }
+ ksort($list);
+
+ $wtpl = new \ilTemplate("tpl.blog_list_navigation_authors.html", true, true, "components/ILIAS/Blog");
+
+ $wtpl->setCurrentBlock("author");
+ foreach ($list as $author) {
+ $wtpl->setVariable("TXT_AUTHOR", $author[0]);
+ $wtpl->setVariable("URL_AUTHOR", $author[1]);
+ $wtpl->parseCurrentBlock();
+ }
+
+ return $wtpl->get();
+ }
+ return "";
+ }
+}
diff --git a/components/ILIAS/Blog/Navigation/KeywordBlockGUI.php b/components/ILIAS/Blog/Navigation/KeywordBlockGUI.php
new file mode 100644
index 000000000000..7a177ae023da
--- /dev/null
+++ b/components/ILIAS/Blog/Navigation/KeywordBlockGUI.php
@@ -0,0 +1,138 @@
+domain = $domain;
+ $this->gui = $gui;
+ }
+
+ /**
+ * @param Posting[][] $items
+ */
+ public function render(
+ array $items,
+ string $list_cmd = "render",
+ bool $show_inactive = false,
+ string $link_template = "",
+ int $blpg = 0
+ ): string {
+ $ctrl = $this->gui->ctrl();
+ $lng = $this->domain->lng();
+
+ $keywords = $this->getKeywords($items, $show_inactive, $blpg);
+ if ($keywords) {
+ $wtpl = new \ilTemplate("tpl.blog_list_navigation_keywords.html", true, true, "components/ILIAS/Blog");
+
+ $max = max($keywords);
+
+ $wtpl->setCurrentBlock("keyword");
+ foreach ($keywords as $keyword => $counter) {
+ if (!$link_template) {
+ $ctrl->setParameterByClass(\ilObjBlogGUI::class, "kwd", urlencode((string) $keyword));
+ $url = $ctrl->getLinkTargetByClass(\ilObjBlogGUI::class, $list_cmd);
+ $ctrl->setParameterByClass(\ilObjBlogGUI::class, "kwd", "");
+ } else {
+ $url = $this->buildExportLink($link_template, "keyword", (string) $keyword);
+ }
+
+ $wtpl->setVariable("TXT_KEYWORD", (string) $keyword);
+ $wtpl->setVariable("CLASS_KEYWORD", \ilTagging::getRelevanceClass((int) $counter, (int) $max));
+ $wtpl->setVariable("URL_KEYWORD", $url);
+ $wtpl->parseCurrentBlock();
+ }
+
+ return $wtpl->get();
+ }
+ return "";
+ }
+
+ /**
+ * @param Posting[][] $items
+ */
+ protected function getKeywords(
+ array $items,
+ bool $show_inactive,
+ ?int $posting_id = null
+ ): array {
+ $keywords = array();
+ $posting_manager = $this->domain->posting();
+ $obj_id = \ilObject::_lookupObjId($this->gui->standardRequest()->getRefId());
+
+ if ($posting_id) {
+ foreach ($posting_manager->getKeywords($obj_id, $posting_id) as $keyword) {
+ if (isset($keywords[$keyword])) {
+ $keywords[$keyword]++;
+ } else {
+ $keywords[$keyword] = 1;
+ }
+ }
+ } else {
+ foreach ($items as $month => $month_items) {
+ foreach ($month_items as $item) {
+ $item_id = $item->getId();
+ if ($show_inactive || \ilBlogPosting::_lookupActive($item_id, "blp")) {
+ foreach ($posting_manager->getKeywords($obj_id, $item_id) as $keyword) {
+ if (isset($keywords[$keyword])) {
+ $keywords[$keyword]++;
+ } else {
+ $keywords[$keyword] = 1;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ $tmp = array();
+ foreach ($keywords as $keyword => $counter) {
+ $tmp[] = array("keyword" => $keyword, "counter" => $counter);
+ }
+ $tmp = \ilArrayUtil::sortArray($tmp, "keyword", "ASC");
+
+ $keywords = array();
+ foreach ($tmp as $item) {
+ $keywords[(string) $item["keyword"]] = $item["counter"];
+ }
+ return $keywords;
+ }
+
+ protected function buildExportLink(
+ string $template,
+ string $type,
+ string $id
+ ): string {
+ $blog_export = new \ILIAS\Blog\Export\BlogHtmlExport($this->gui->standardRequest()->getRefId());
+ return $blog_export->buildExportLink($template, $type, $id, []);
+ }
+}
diff --git a/components/ILIAS/Blog/Navigation/MonthBlockGUI.php b/components/ILIAS/Blog/Navigation/MonthBlockGUI.php
new file mode 100644
index 000000000000..1c948d4031b7
--- /dev/null
+++ b/components/ILIAS/Blog/Navigation/MonthBlockGUI.php
@@ -0,0 +1,253 @@
+domain = $domain;
+ $this->gui = $gui;
+ }
+
+ /**
+ * @param Posting[][] $items
+ */
+ public function render(
+ array $items,
+ string $list_cmd = "render",
+ string $posting_cmd = "preview",
+ ?string $link_template = null,
+ bool $show_inactive = false,
+ int $blpg = 0
+ ): string {
+ $ctrl = $this->gui->ctrl();
+ $lng = $this->domain->lng();
+ $settings = $this->domain->blogSettings()->getByObjId(
+ \ilObject::_lookupObjId($this->gui->standardRequest()->getRefId())
+ );
+
+ // gather page active status
+ foreach ($items as $month => $postings) {
+ foreach (array_keys($postings) as $id) {
+ $active = \ilBlogPosting::_lookupActive($id, "blp");
+ if (!$show_inactive && !$active) {
+ unset($items[$month][$id]);
+ }
+ }
+ if (!count($items[$month])) {
+ unset($items[$month]);
+ }
+ }
+
+ // list month (incl. postings)
+ if ($settings->getNavMode() === \ilObjBlog::NAV_MODE_LIST || $link_template) {
+ $max_months = $settings->getNavModeListMonths();
+
+ $wtpl = new \ilTemplate("tpl.blog_list_navigation_by_date.html", true, true, "components/ILIAS/Blog");
+
+ $ctrl->setParameterByClass(\ilObjBlogGUI::class, "blpg", "");
+
+ $counter = $mon_counter = $last_year = 0;
+ foreach ($items as $month => $postings) {
+ if (!$link_template && $max_months && $mon_counter >= $max_months) {
+ break;
+ }
+
+ $add_year = false;
+ $year = substr((string) $month, 0, 4);
+ if (!$last_year || $year != $last_year) {
+ $add_year = true;
+ $last_year = $year;
+ }
+
+ $mon_counter++;
+
+ $month_name = \ilCalendarUtil::_numericMonthToString((int) substr((string) $month, 5));
+ if (!$link_template) {
+ $ctrl->setParameterByClass(\ilObjBlogGUI::class, "bmn", $month);
+ $month_url = $ctrl->getLinkTargetByClass(\ilObjBlogGUI::class, $list_cmd);
+ } else {
+ $month_url = $this->buildExportLink($link_template, "list", (string) $month);
+ }
+
+ if ($mon_counter <= $settings->getNavModeListMonthsWithPostings()) {
+ if ($add_year) {
+ $wtpl->setCurrentBlock("navigation_year_details");
+ $wtpl->setVariable("YEAR", $year);
+ $wtpl->parseCurrentBlock();
+ }
+
+ foreach ($postings as $id => $posting) {
+ $counter++;
+ $caption = $posting->getTitle();
+
+ if (!$link_template) {
+ $ctrl->setParameterByClass(\ilBlogPostingGUI::class, "bmn", $month);
+ $ctrl->setParameterByClass(\ilBlogPostingGUI::class, "blpg", (string) $id);
+ $url = $ctrl->getLinkTargetByClass(\ilBlogPostingGUI::class, $posting_cmd);
+ } else {
+ $url = $this->buildExportLink($link_template, "posting", (string) $id);
+ }
+
+ if (!$posting->isActive()) {
+ $wtpl->setVariable("NAV_ITEM_DRAFT", $lng->txt("blog_draft"));
+ } elseif ($settings->getApproval() && !$posting->isApproved()) {
+ $wtpl->setVariable("NAV_ITEM_APPROVAL", $lng->txt("blog_needs_approval"));
+ }
+
+ $wtpl->setCurrentBlock("navigation_item");
+ $wtpl->setVariable("NAV_ITEM_URL", $url);
+ $wtpl->setVariable("NAV_ITEM_CAPTION", $caption);
+ $wtpl->parseCurrentBlock();
+ }
+
+ $wtpl->setCurrentBlock("navigation_month_details");
+ $wtpl->setVariable("NAV_MONTH", $month_name);
+ $wtpl->setVariable("URL_MONTH", $month_url);
+ $wtpl->parseCurrentBlock();
+ }
+ // summarized month
+ else {
+ if ($add_year) {
+ $wtpl->setCurrentBlock("navigation_year");
+ $wtpl->setVariable("YEAR", $year);
+ $wtpl->parseCurrentBlock();
+ }
+
+ $wtpl->setCurrentBlock("navigation_month");
+ $wtpl->setVariable("MONTH_NAME", $month_name);
+ $wtpl->setVariable("URL_MONTH", $month_url);
+ $wtpl->setVariable("MONTH_COUNT", (string) count($postings));
+ $wtpl->parseCurrentBlock();
+ }
+ }
+ if (!$link_template) {
+ $ctrl->setParameterByClass(\ilObjBlogGUI::class, "bmn", null);
+ $url = $ctrl->getLinkTargetByClass(\ilObjBlogGUI::class, $list_cmd);
+ } else {
+ $url = "index.html";
+ }
+
+ $wtpl->setVariable(
+ "STARTING_PAGE",
+ $this->gui->ui()->renderer()->render(
+ $this->gui->ui()->factory()->link()->standard(
+ $lng->txt("blog_starting_page"),
+ $url
+ )
+ )
+ );
+ $ctrl->setParameterByClass(\ilObjBlogGUI::class, "bmn", $this->gui->standardRequest()->getMonth());
+ $ctrl->setParameterByClass(\ilBlogPostingGUI::class, "bmn", "");
+ return $wtpl->get();
+ }
+ // single month
+ else {
+ $wtpl = new \ilTemplate("tpl.blog_list_navigation_month.html", true, true, "components/ILIAS/Blog");
+
+ $ctrl->setParameterByClass(\ilObjBlogGUI::class, "blpg", "");
+
+ $month_options = array();
+ foreach ($items as $month => $postings) {
+ $month_name = $this->gui->presentation()->util()->getMonthPresentation((string) $month);
+
+ $month_options[(string) $month] = $month_name;
+
+ if ($month == $this->gui->standardRequest()->getMonth()) {
+ if (!$link_template) {
+ $ctrl->setParameterByClass(\ilObjBlogGUI::class, "bmn", (string) $month);
+ $month_url = $ctrl->getLinkTargetByClass(\ilObjBlogGUI::class, $list_cmd);
+ } else {
+ $month_url = $this->buildExportLink($link_template, "list", (string) $month);
+ }
+
+ foreach ($postings as $id => $posting) {
+ $caption = $posting->getTitle();
+
+ if (!$link_template) {
+ $ctrl->setParameterByClass(\ilBlogPostingGUI::class, "bmn", (string) $month);
+ $ctrl->setParameterByClass(\ilBlogPostingGUI::class, "blpg", (string) $id);
+ $url = $ctrl->getLinkTargetByClass(\ilBlogPostingGUI::class, $posting_cmd);
+ } else {
+ $url = $this->buildExportLink($link_template, "posting", (string) $id);
+ }
+
+ if (!$posting->isActive()) {
+ $wtpl->setVariable("NAV_ITEM_DRAFT", $lng->txt("blog_draft"));
+ } elseif ($settings->getApproval() && !$posting->isApproved()) {
+ $wtpl->setVariable("NAV_ITEM_APPROVAL", $lng->txt("blog_needs_approval"));
+ }
+
+ $wtpl->setCurrentBlock("navigation_item");
+ $wtpl->setVariable("NAV_ITEM_URL", $url);
+ $wtpl->setVariable("NAV_ITEM_CAPTION", $caption);
+ $wtpl->parseCurrentBlock();
+ }
+
+ $wtpl->setCurrentBlock("navigation_month_details");
+ if ($blpg > 0) {
+ $wtpl->setVariable("NAV_MONTH", $month_name);
+ $wtpl->setVariable("URL_MONTH", $month_url);
+ }
+ $wtpl->parseCurrentBlock();
+ }
+ }
+
+ if ($blpg === 0) {
+ $wtpl->setCurrentBlock("option_bl");
+ foreach ($month_options as $value => $caption) {
+ $wtpl->setVariable("OPTION_VALUE", $value);
+ $wtpl->setVariable("OPTION_CAPTION", $caption);
+ if ($value == $this->gui->standardRequest()->getMonth()) {
+ $wtpl->setVariable("OPTION_SEL", ' selected="selected"');
+ }
+ $wtpl->parseCurrentBlock();
+ }
+
+ $wtpl->setVariable("FORM_ACTION", $ctrl->getFormActionByClass(\ilObjBlogGUI::class, $list_cmd));
+ }
+ }
+ $ctrl->setParameterByClass(\ilObjBlogGUI::class, "bmn", $this->gui->standardRequest()->getMonth());
+ $ctrl->setParameterByClass(\ilBlogPostingGUI::class, "bmn", "");
+ return $wtpl->get();
+ }
+
+ protected function buildExportLink(
+ string $template,
+ string $type,
+ string $id
+ ): string {
+ $blog_export = new \ILIAS\Blog\Export\BlogHtmlExport($this->gui->standardRequest()->getRefId());
+ // Note: this might need adjustment since the original used $this->getKeywords(false)
+ // For now we assume keywords are not needed for these links or handled elsewhere
+ return $blog_export->buildExportLink($template, $type, $id, []);
+ }
+}
diff --git a/components/ILIAS/Blog/Navigation/Service/class.GUIService.php b/components/ILIAS/Blog/Navigation/Service/class.GUIService.php
index e89279158f08..d420f56023c6 100755
--- a/components/ILIAS/Blog/Navigation/Service/class.GUIService.php
+++ b/components/ILIAS/Blog/Navigation/Service/class.GUIService.php
@@ -43,4 +43,28 @@ public function toolbarNavigationRenderer(
$this->gui
);
}
+
+ public function monthBlock(): MonthBlockGUI
+ {
+ return new MonthBlockGUI(
+ $this->domain,
+ $this->gui
+ );
+ }
+
+ public function authorBlock(): AuthorBlockGUI
+ {
+ return new AuthorBlockGUI(
+ $this->domain,
+ $this->gui
+ );
+ }
+
+ public function keywordBlock(): KeywordBlockGUI
+ {
+ return new KeywordBlockGUI(
+ $this->domain,
+ $this->gui
+ );
+ }
}
diff --git a/components/ILIAS/Blog/News/class.NewsManager.php b/components/ILIAS/Blog/News/class.NewsManager.php
index b6b863237105..59227a090de8 100644
--- a/components/ILIAS/Blog/News/class.NewsManager.php
+++ b/components/ILIAS/Blog/News/class.NewsManager.php
@@ -29,11 +29,15 @@
*/
class NewsManager
{
+ protected \ILIAS\Blog\Posting\Service\GUIService $posting_gui;
+
public function __construct(
protected InternalDataService $data,
protected InternalRepoService $repo,
- protected InternalDomainService $domain
+ protected InternalDomainService $domain,
+ \ILIAS\Blog\InternalGUIService $gui
) {
+ $this->posting_gui = $gui->posting();
}
/**
@@ -110,7 +114,7 @@ public function handle(\ilBlogPosting $page, bool $update = false): void
$news_item->setContentTextIsLangVar(false);
$news_item->setContent($content);
- $snippet = \ilBlogPostingGUI::getSnippet($page->getId());
+ $snippet = $this->posting_gui->getSnippet($page->getId());
$news_item->setContentLong($snippet);
if (!$news_item->getId()) {
diff --git a/components/ILIAS/Blog/PermanentLink/StaticUrlHandler.php b/components/ILIAS/Blog/PermanentLink/StaticUrlHandler.php
index f2e3ea3b9f5c..2a0261e113f7 100644
--- a/components/ILIAS/Blog/PermanentLink/StaticUrlHandler.php
+++ b/components/ILIAS/Blog/PermanentLink/StaticUrlHandler.php
@@ -29,6 +29,15 @@
class StaticURLHandler extends BaseHandler implements Handler
{
+ protected \ILIAS\Blog\InternalService $blog_service;
+
+ public function __construct()
+ {
+ global $DIC;
+ $this->blog_service = $DIC->blog()->internal();
+ parent::__construct();
+ }
+
public function getNamespace(): string
{
return 'blog';
@@ -36,12 +45,11 @@ public function getNamespace(): string
public function handle(Request $request, Context $context, Factory $response_factory): Response
{
- global $DIC;
-
- $ctrl = $DIC->ctrl();
- $access = $DIC->access();
+ $blog_service = $this->blog_service;
+ $ctrl = $blog_service->gui()->ctrl();
+ $access = $blog_service->domain()->access();
$uri = null;
- $blog_domain = $DIC->blog()->internal()->domain();
+ $blog_domain = $blog_service->domain();
$id = $request->getReferenceId()?->toInt() ?? 0;
$additional_params = $request->getAdditionalParameters() ?? [];
diff --git a/components/ILIAS/Blog/Posting/Service/class.GUIService.php b/components/ILIAS/Blog/Posting/Service/class.GUIService.php
new file mode 100644
index 000000000000..8e90ca73064a
--- /dev/null
+++ b/components/ILIAS/Blog/Posting/Service/class.GUIService.php
@@ -0,0 +1,83 @@
+postingGUI(0, null, $a_id);
+ return $bpgui->getSnippet(
+ $a_truncate,
+ $a_truncate_length,
+ $a_truncate_sign,
+ $a_include_picture,
+ $a_picture_width,
+ $a_picture_height,
+ $a_export_directory
+ );
+ }
+}
diff --git a/components/ILIAS/Blog/Posting/class.ilBlogPosting.php b/components/ILIAS/Blog/Posting/class.ilBlogPosting.php
index 9e50d67ba854..e30778d3d707 100755
--- a/components/ILIAS/Blog/Posting/class.ilBlogPosting.php
+++ b/components/ILIAS/Blog/Posting/class.ilBlogPosting.php
@@ -28,6 +28,7 @@
*/
class ilBlogPosting extends ilPageObject
{
+ protected \ILIAS\Blog\Posting\Service\GUIService $posting_gui;
protected string $title = "";
protected ?ilDateTime $created = null;
protected int $blog_node_id = 0;
@@ -45,6 +46,8 @@ public function afterConstructor(): void
$this->internal_data = $DIC->blog()->internal()->data();
$this->posting_manager = $DIC->blog()->internal()->domain()->posting();
$this->blog_domain = $DIC->blog()->internal()->domain();
+ $this->posting_gui = $DIC->blog()->internal()->gui()->posting();
+
}
public function getParentType(): string
@@ -254,27 +257,6 @@ public function unpublish(): void
);
}
- public static function lookupBlogId(
- int $a_posting_id
- ): ?int {
- global $DIC;
- return $DIC->blog()->internal()->domain()->posting()->lookupBlogId($a_posting_id);
- }
-
- /**
- * Checks whether a posting exists
- */
- public static function exists(
- int $a_blog_id,
- int $a_posting_id
- ): bool {
- global $DIC;
- return $DIC->blog()->internal()->domain()->posting()->exists(
- $a_blog_id,
- $a_posting_id
- );
- }
-
/**
* Set blog node id (needed for notification)
*/
@@ -288,7 +270,7 @@ public function setBlogNodeId(
public function getNotificationAbstract(): string
{
- $snippet = ilBlogPostingGUI::getSnippet($this->getId(), true);
+ $snippet = $this->posting_gui->getSnippet($this->getId(), true);
// making things more readable
$snippet = str_replace(array('
', '
', '
");
+ $snippet = strip_tags($this->gui->posting()->getSnippet($id), "
");
$snippet = str_replace("&", "&", $snippet);
$snippet = "";
diff --git a/components/ILIAS/Blog/Service/class.InternalDomainService.php b/components/ILIAS/Blog/Service/class.InternalDomainService.php
index 55b2141439c3..8aa784d42057 100755
--- a/components/ILIAS/Blog/Service/class.InternalDomainService.php
+++ b/components/ILIAS/Blog/Service/class.InternalDomainService.php
@@ -119,7 +119,8 @@ public function news(): NewsManager
return self::$instance["news"] ??= new NewsManager(
$this->data,
$this->repo,
- $this
+ $this,
+ $this->dic->blog()->internal()->gui()
);
}
diff --git a/components/ILIAS/Blog/Service/class.InternalGUIService.php b/components/ILIAS/Blog/Service/class.InternalGUIService.php
index 3d616e8ef350..ddc5461168db 100755
--- a/components/ILIAS/Blog/Service/class.InternalGUIService.php
+++ b/components/ILIAS/Blog/Service/class.InternalGUIService.php
@@ -25,6 +25,7 @@
use ILIAS\PermanentLink\PermanentLinkManager;
use ILIAS\Blog\ReadingTime\GUIService;
use ILIAS\Blog\RSS\RSSGUI;
+use ILIAS\Blog\Posting\Service\GUIService as PostingGUIService;
class InternalGUIService
{
@@ -42,10 +43,11 @@ public function __construct(
public function navigation(): Navigation\GUIService
{
- return new Navigation\GUIService(
- $this->domain_service,
- $this
- );
+ return self::$instance["navigation"] ??
+ self::$instance["navigation"] = new Navigation\GUIService(
+ $this->domain_service,
+ $this
+ );
}
public function presentation(): Presentation\GUIService
@@ -66,11 +68,12 @@ public function standardRequest(): StandardGUIRequest
public function contributor(): Contributor\GUIService
{
- return new Contributor\GUIService(
- $this->data_service,
- $this->domain_service,
- $this
- );
+ return self::$instance["contributor"] ??
+ self::$instance["contributor"] = new Contributor\GUIService(
+ $this->data_service,
+ $this->domain_service,
+ $this
+ );
}
public function exercise(): Exercise\GUIService
@@ -114,6 +117,15 @@ public function readingTime(): GUIService
);
}
+ public function posting(): PostingGUIService
+ {
+ return self::$instance["posting"] ??= new PostingGUIService(
+ $this->data_service,
+ $this->domain_service,
+ $this
+ );
+ }
+
public function rss(): RSSGUI
{
return self::$instance["rss"] ??= new RSSGUI(
diff --git a/components/ILIAS/Blog/Tasks/classes/class.ilBlogDraftsDerivedTaskProvider.php b/components/ILIAS/Blog/Tasks/classes/class.ilBlogDraftsDerivedTaskProvider.php
index 800be9b2ff13..49f0c0a3c3aa 100755
--- a/components/ILIAS/Blog/Tasks/classes/class.ilBlogDraftsDerivedTaskProvider.php
+++ b/components/ILIAS/Blog/Tasks/classes/class.ilBlogDraftsDerivedTaskProvider.php
@@ -37,8 +37,9 @@ public function __construct(
) {
global $DIC;
- $this->gui = $DIC->blog()->internal()->gui();
- $this->domain = $DIC->blog()->internal()->domain();
+ $service = $DIC->blog()->internal();
+ $this->gui = $service->gui();
+ $this->domain = $service->domain();
$this->taskService = $taskService;
$this->accessHandler = $accessHandler;
$this->lng = $lng;
diff --git a/components/ILIAS/Blog/classes/class.ilBlogNewsRendererGUI.php b/components/ILIAS/Blog/classes/class.ilBlogNewsRendererGUI.php
index 3275e896e556..32dfa9f6ddc2 100755
--- a/components/ILIAS/Blog/classes/class.ilBlogNewsRendererGUI.php
+++ b/components/ILIAS/Blog/classes/class.ilBlogNewsRendererGUI.php
@@ -18,17 +18,21 @@
declare(strict_types=1);
-/**
- * Blog news renderer
- * @author Alexander Killing