ILIAS  release_8 Revision v8.24
class.ilObjBlogListGUI.php
Go to the documentation of this file.
1<?php
2
20
26{
27 private ?Modal $comment_modal = null;
28
29 public function init(): void
30 {
31 $this->copy_enabled = true;
32 $this->delete_enabled = true;
33 $this->cut_enabled = true;
34 $this->subscribe_enabled = true;
35 $this->link_enabled = true; // #10498
36 $this->info_screen_enabled = true;
37 $this->type = "blog";
38 $this->gui_class_name = "ilobjbloggui";
39
40 // general commands array
41 $this->commands = ilObjBlogAccess::_getCommands();
42 }
43
44 public function getCommands(): array
45 {
46 $commands = parent::getCommands();
47
48 // #10182 - handle edit and contribute
49 $permissions = array();
50 foreach ($commands as $idx => $item) {
51 if ($item["lang_var"] === "edit" && $item["granted"]) {
52 $permissions[$item["permission"]] = $idx;
53 }
54 }
55 if (count($permissions) === 2) {
56 unset($commands[$permissions["contribute"]]);
57 }
58
59 return $commands;
60 }
61
62 public function insertCommand(
63 string $href,
64 string $text,
65 string $frame = "",
66 string $img = "",
67 string $cmd = "",
68 string $onclick = ""
69 ): void {
70 $ctrl = $this->ctrl;
71
72 if ($cmd === "export"
74 && (bool) $this->settings->get('item_cmd_asynch')) {
75 $href = $this->getCommandLink("forwardExport");
76 $cmd = "forwardExport";
77 $onclick = "";
78 }
79 if ($cmd !== "export" || !ilObjBlogAccess::isCommentsExportPossible($this->obj_id)) {
80 parent::insertCommand($href, $text, $frame, $img, $cmd, $onclick);
81 return;
82 }
83
84 // #11099
85 $chksum = md5($href . $text);
86 if ($href === "#" ||
87 !in_array($chksum, $this->prevent_duplicate_commands)) {
88 if ($href !== "#") {
89 $this->prevent_duplicate_commands[] = $chksum;
90 }
91
92 $prevent_background_click = false;
93
95 $comment_export_helper = new \ILIAS\Notes\Export\ExportHelperGUI();
96 $this->lng->loadLanguageModule("note");
97 $this->comment_modal = $comment_export_helper->getCommentIncludeModalDialog(
98 'HTML Export',
99 $this->lng->txt("note_html_export_include_comments"),
100 $ctrl->getLinkTargetByClass("ilobjbloggui", "export"),
101 $ctrl->getLinkTargetByClass("ilobjbloggui", "exportWithComments")
102 );
103 $signal = $this->comment_modal->getShowSignal()->getId();
104 $this->current_selection_list->addItem(
105 $text,
106 "",
107 $href,
108 $img,
109 $text,
110 $frame,
111 "",
112 $prevent_background_click,
113 "( function() { $(document).trigger('" . $signal . "', {'id': '" . $signal . "','triggerer':$(this), 'options': JSON.parse('[]')}); return false;})()"
114 );
115 }
116 }
117 }
118
119 public function getListItemHTML(
120 int $ref_id,
121 int $obj_id,
122 string $title,
123 string $description,
124 bool $use_async = false,
125 bool $get_async_commands = false,
126 string $async_url = ""
127 ): string {
128 $html = parent::getListItemHTML(
129 $ref_id,
130 $obj_id,
131 $title,
132 $description,
133 $use_async,
134 $get_async_commands,
135 $async_url
136 );
137
138 if (!is_null($this->comment_modal)) {
139 global $DIC;
140 $renderer = $DIC->ui()->renderer();
141 $html .= $renderer->render($this->comment_modal);
142 }
143 return $html;
144 }
145}
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)
getListItemHTML(int $ref_id, int $obj_id, string $title, string $description, bool $use_async=false, bool $get_async_commands=false, string $async_url="")
Get all item information (title, commands, description) in HTML.
ilCtrlInterface $ctrl
getCommandLink(string $cmd)
Get command link url.
global $DIC
Definition: feed.php:28
$img
Definition: imgupload.php:83
This describes commonalities between the different modals.
Definition: Modal.php:35
getLinkTargetByClass( $a_class, string $a_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
Returns a link target for the given information.
$ref_id
Definition: ltiauth.php:67