ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.InternalGUIService.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Notes;
22 
26 
31 {
33 
36 
37  public function __construct(
39  InternalDataService $data_service,
40  InternalDomainService $domain_service
41  ) {
42  $this->data_service = $data_service;
43  $this->domain_service = $domain_service;
44  $this->initGUIServices($DIC);
45  }
46 
47  public function standardRequest(): StandardGUIRequest
48  {
49  return new StandardGUIRequest(
50  $this->http(),
51  $this->domain_service->refinery()
52  );
53  }
54 
55  public function initJavascript(
56  string $ajax_url = "",
57  ?\ilGlobalTemplateInterface $main_tpl = null
58  ): void {
59  $tpl = $main_tpl ?? $this->mainTemplate();
60  $lng = $this->domain_service->lng();
61  $ctrl = $this->ctrl();
62  // temporary patch to make this work...
63  global $DIC;
64  $ref_id = $DIC->repository()->internal()->gui()->standardRequest()->getRefId();
65  $type = \ilObject::_lookupType($ref_id, true);
66  if ($ajax_url === "") {
67  $path = ["ilcommonactiondispatchergui", "ilnotegui"];
68  $ajax_url = $this->ctrl()->getLinkTargetByClass(
69  $path,
70  "",
71  "",
72  true,
73  false
74  );
75  }
76  $lng->loadLanguageModule("notes");
77 
78  $lng->toJS(array("private_notes", "notes_public_comments", "cancel", "notes_messages"), $tpl);
79  $tpl->addJavaScript("assets/js/ilNotes.js");
80  //$tpl->addJavaScript("../components/ILIAS/Notes/resources/ilNotes.js");
81 
82  $modal_template = $this->getModalTemplate();
83 
84  $tpl->addOnLoadCode("ilNotes.setAjaxUrl('" . $ajax_url . "');");
85  $tpl->addOnLoadCode('ilNotes.setModalTemplate("' . addslashes(json_encode($modal_template["template"])) . '");');
86  $tpl->addOnLoadCode("ilNotes.setShowSignal('" . $modal_template["show"] . "');");
87  $tpl->addOnLoadCode("ilNotes.setCloseSignal('" . $modal_template["close"] . "');");
88  }
89 
90  public function getModalTemplate(): array
91  {
92  $ui = $this->ui();
93  $modal = $ui->factory()->modal()->roundtrip('#notes_title#', $ui->factory()->legacy()->content(''));
94  $modalt["show"] = $modal->getShowSignal()->getId();
95  $modalt["close"] = $modal->getCloseSignal()->getId();
96  $modalt["template"] = $ui->renderer()->renderAsync($modal);
97 
98  return $modalt;
99  }
100 
101  public function print(): PrintProcessGUI
102  {
104  return new PrintProcessGUI(
105  $provider,
106  $this->http(),
107  $this->ui(),
108  $this->domain_service->lng()
109  );
110  }
111 
112  public function getCommentsGUI(
113  $rep_obj_id,
114  int $obj_id,
115  string $obj_type,
116  int $news_id = 0,
117  bool $include_subs = false,
118  bool $ajax = true,
119  string $search_text = ""
120  ): \ilCommentGUI {
121  return new \ilCommentGUI(
122  $rep_obj_id,
123  $obj_id,
124  $obj_type,
125  $include_subs,
126  $news_id,
127  $ajax,
128  $search_text
129  );
130  }
131 
132  public function getMessagesGUI(
133  int $recipient,
134  int $rep_obj_id,
135  int $obj_id,
136  string $obj_type
137  ): \ilMessageGUI {
138  return new \ilMessageGUI(
139  $recipient,
140  $rep_obj_id,
141  $obj_id,
142  $obj_type
143  );
144  }
145 }
initGUIServices(\ILIAS\DI\Container $DIC)
$path
Definition: ltiservices.php:29
Repository internal data service.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$provider
Definition: ltitoken.php:80
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ref_id
Definition: ltiauth.php:65
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:22
__construct(Container $DIC, InternalDataService $data_service, InternalDomainService $domain_service)
Comment GUI.
global $lng
Definition: privfeed.php:31
initJavascript(string $ajax_url="", ?\ilGlobalTemplateInterface $main_tpl=null)
getMessagesGUI(int $recipient, int $rep_obj_id, int $obj_id, string $obj_type)
getCommentsGUI( $rep_obj_id, int $obj_id, string $obj_type, int $news_id=0, bool $include_subs=false, bool $ajax=true, string $search_text="")
Message GUI.
static _lookupType(int $id, bool $reference=false)
mainTemplate()