ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 $ctrl = $this->ctrl;
73 if ($cmd === "export"
75 && (bool) $this->settings->get('item_cmd_asynch')) {
76 $href = $this->getCommandLink("forwardExport");
77 $cmd = "forwardExport";
78 $onclick = "";
79 }
80 if ($cmd !== "export" || !ilObjBlogAccess::isCommentsExportPossible($this->obj_id)) {
81 parent::insertCommand($href, $text, $frame, $img, $cmd, $onclick);
82 return;
83 }
84
85 // #11099
86 $chksum = md5($href . $text);
87 if ($href === "#" ||
88 !in_array($chksum, $this->prevent_duplicate_commands)) {
89 if ($href !== "#") {
90 $this->prevent_duplicate_commands[] = $chksum;
91 }
92
93 $prevent_background_click = false;
94
96 $comment_export_helper = new \ILIAS\Notes\Export\ExportHelperGUI();
97 $this->lng->loadLanguageModule("note");
98 $this->comment_modal = $comment_export_helper->getCommentIncludeModalDialog(
99 'HTML Export',
100 $this->lng->txt("note_html_export_include_comments"),
101 $ctrl->getLinkTargetByClass([ilRepositoryGUI::class, ilObjBlogGUI::class], "export"),
102 $ctrl->getLinkTargetByClass([ilRepositoryGUI::class, ilObjBlogGUI::class], "exportWithComments")
103 );
104 $signal = $this->comment_modal->getShowSignal()->getId();
105 /*$this->current_selection_list->addItem(
106 $text,
107 "",
108 $href,
109 $img,
110 $text,
111 $frame,
112 "",
113 $prevent_background_click,
114 "( function() { $(document).trigger('" . $signal . "', {'id': '" . $signal . "','triggerer':$(this), 'options': JSON.parse('[]')}); return false;})()"
115 );*/
116
117 $action = $this->ui->factory()
118 ->button()
119 ->shy($text, $href);
120
121 if ($frame !== '') {
122 $action = $this->ui->factory()->link()->standard($text, $href)->withOpenInNewViewport(true);
123 }
124
125 $action = $action->withAdditionalOnLoadCode(function ($id) use ($onclick, $signal): string {
126 return "$('#$id').click(( function() { $(document).trigger('" . $signal . "', {'id': '" . $signal . "','triggerer':$(this), 'options': JSON.parse('[]')}); return false;})());";
127 });
128 $this->current_actions[] = $action;
129 }
130 }
131 }
132}
$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
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.