ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilObjBlogListGUI.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
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 {
73 
74  if ($cmd === "export"
76  && (bool) $this->settings->get('item_cmd_asynch')) {
77  $href = $this->getCommandLink("forwardExport");
78  $cmd = "forwardExport";
79  $onclick = "";
80  }
81  if ($cmd !== "export" || !ilObjBlogAccess::isCommentsExportPossible($this->obj_id)) {
82  parent::insertCommand($href, $text, $frame, $img, $cmd, $onclick);
83  return;
84  }
85 
86  // #11099
87  $chksum = md5($href . $text);
88  if ($href === "#" ||
89  !in_array($chksum, $this->prevent_duplicate_commands)) {
90  if ($href !== "#") {
91  $this->prevent_duplicate_commands[] = $chksum;
92  }
93 
94  $prevent_background_click = false;
95 
96  if (ilObjBlogAccess::isCommentsExportPossible($this->obj_id)) {
97  $comment_export_helper = new \ILIAS\Notes\Export\ExportHelperGUI();
98  $this->lng->loadLanguageModule("note");
99  $this->comment_modal = $comment_export_helper->getCommentIncludeModalDialog(
100  'HTML Export',
101  $this->lng->txt("note_html_export_include_comments"),
102  $ctrl->getLinkTargetByClass([ilRepositoryGUI::class, ilObjBlogGUI::class], "export"),
103  $ctrl->getLinkTargetByClass([ilRepositoryGUI::class, ilObjBlogGUI::class], "exportWithComments")
104  );
105  $signal = $this->comment_modal->getShowSignal()->getId();
106  $this->current_selection_list->addItem(
107  $text,
108  "",
109  $href,
110  $img,
111  $text,
112  $frame,
113  "",
114  $prevent_background_click,
115  "( function() { $(document).trigger('" . $signal . "', {'id': '" . $signal . "','triggerer':$(this), 'options': JSON.parse('[]')}); return false;})()"
116  );
117  }
118  }
119  }
120 
121  public function getListItemHTML(
122  int $ref_id,
123  int $obj_id,
124  string $title,
125  string $description,
126  bool $use_async = false,
127  bool $get_async_commands = false,
128  string $async_url = ""
129  ): string {
130  $html = parent::getListItemHTML(
131  $ref_id,
132  $obj_id,
133  $title,
134  $description,
135  $use_async,
136  $get_async_commands,
137  $async_url
138  );
139 
140  if (!is_null($this->comment_modal)) {
141  global $DIC;
142  $renderer = $DIC->ui()->renderer();
143  $html .= $renderer->render($this->comment_modal);
144  }
145  return $html;
146  }
147 }
This describes commonalities between the different modals.
Definition: Modal.php:34
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getListItemHTML(int $ref_id, int $obj_id, string $title, string $description, bool $use_async=false, bool $get_async_commands=false, string $async_url="")
global $DIC
Definition: feed.php:28
static isCommentsExportPossible(int $blog_id)
ilCtrlInterface $ctrl
insertCommand(string $href, string $text, string $frame="", string $img="", string $cmd="", string $onclick="")
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.
getCommandLink(string $cmd)
Get command link url.
Class ilObjBlogListGUI.