ILIAS  trunk Revision v12.0_alpha-1329-g1094ddb0c33
class.ilObjBlogListGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
28{
29 private ?Modal $comment_modal = null;
30
31 public function init(): void
32 {
33 $this->copy_enabled = true;
34 $this->delete_enabled = true;
35 $this->cut_enabled = true;
36 $this->subscribe_enabled = true;
37 $this->link_enabled = true; // #10498
38 $this->info_screen_enabled = true;
39 $this->type = "blog";
40 $this->gui_class_name = "ilobjbloggui";
41
42 // general commands array
43 $this->commands = ilObjBlogAccess::_getCommands();
44 }
45
46 public function getCommands(): array
47 {
48 $commands = parent::getCommands();
49
50 // #10182 - handle edit and contribute
51 $permissions = array();
52 foreach ($commands as $idx => $item) {
53 if ($item["lang_var"] === "edit" && $item["granted"]) {
54 $permissions[$item["permission"]] = $idx;
55 }
56 }
57 if (count($permissions) === 2) {
58 unset($commands[$permissions["contribute"]]);
59 }
60
61 return $commands;
62 }
63
64 public function insertCommand(
65 string $href,
66 string $text,
67 string $frame = "",
68 string $img = "",
69 string $cmd = "",
70 string $onclick = ""
71 ): void {
72 global $DIC;
73
74 $tpl = $this->ui->mainTemplate();
76 if ($cmd === "export"
78 && (bool) $this->settings->get('item_cmd_asynch')) {
79 $href = $this->getCommandLink("forwardExport");
80 $cmd = "forwardExport";
81 $onclick = "";
82 }
83 if ($cmd !== "export" || !ilObjBlogAccess::isCommentsExportPossible($this->obj_id)) {
84 parent::insertCommand($href, $text, $frame, $img, $cmd, $onclick);
85 return;
86 }
87
88 // #11099
89 $chksum = md5($href . $text);
90 if ($href === "#" ||
91 !in_array($chksum, $this->prevent_duplicate_commands)) {
92 if ($href !== "#") {
93 $this->prevent_duplicate_commands[] = $chksum;
94 }
95
96 $prevent_background_click = false;
97
99
100 $modal = $this->getModalTemplate();
101 $signal = $modal["show"];
102 $tpl->addJavaScript('assets/js/blog.js');
103 $tpl->addOnLoadCode('il.blog.setModalTemplate("' . $signal . '", "' . addslashes(json_encode($modal["template"])) . '");');
104
105
106 $action = $this->ui->factory()
107 ->button()
108 ->shy($text, "#");
109
110 $action = $action->withOnLoadCode(function ($id) use ($onclick, $signal): string {
111 return "document.getElementById('$id').addEventListener('click', (event) => {event.preventDefault(); il.blog.showModal('$signal');});";
112 });
113 $this->current_actions[] = $action;
114 }
115 }
116 }
117
118
119 public function getModalTemplate(): array
120 {
121 $ctrl = $this->ctrl;
122 $ui = $this->ui;
123
124 $comment_export_helper = new \ILIAS\Notes\Export\ExportHelperGUI();
125 $this->lng->loadLanguageModule("note");
126 $modal = $comment_export_helper->getCommentIncludeModalDialog(
127 'HTML Export',
128 $this->lng->txt("note_html_export_include_comments"),
129 $ctrl->getLinkTargetByClass([ilRepositoryGUI::class, ilObjBlogGUI::class], "export"),
130 $ctrl->getLinkTargetByClass([ilRepositoryGUI::class, ilObjBlogGUI::class], "exportWithComments")
131 );
132
133 $modalt["show"] = $modal->getShowSignal()->getId();
134 $modalt["close"] = $modal->getCloseSignal()->getId();
135 $modalt["template"] = $ui->renderer()->renderAsync($modal);
136
137 return $modalt;
138 }
139
140}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static _getCommands()
get commands
static isCommentsExportPossible(int $blog_id)
Class ilObjBlogListGUI.
insertCommand(string $href, string $text, string $frame="", string $img="", string $cmd="", string $onclick="")
insert command button
getCommands()
get all current commands for a specific ref id (in the permission context of the current user)
ilCtrlInterface $ctrl
getCommandLink(string $cmd)
Get command link url.
This describes commonalities between the different modals.
Definition: Modal.php:35
global $DIC
Definition: shib_login.php:26
$text
Definition: xapiexit.php:21