ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilAsyncNotifications.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
29 {
33  protected bool $js_init;
34 
38  protected ?string $content_container_id;
39 
43  protected string $js_path;
44 
48  protected array $js_config;
49 
50  public function __construct(string $content_container_id = null)
51  {
52  $this->js_init = false;
53  $this->js_path = "./Modules/StudyProgramme/templates/js/";
54  $this->content_container_id = $content_container_id ?? "ilContentContainer";
55  }
56 
60  public function initJs(): void
61  {
62  global $DIC;
63  $tpl = $DIC['tpl'];
64 
65  if (!$this->js_init) {
66  $tpl->addJavaScript($this->getJsPath() . 'ilStudyProgramme.js');
67 
68  // TODO: DW -> refactor ilUtil
69  $templates['info'] = ilUtil::getSystemMessageHTML("[MESSAGE]");
70  $templates['success'] = ilUtil::getSystemMessageHTML("[MESSAGE]", 'success');
71  $templates['failure'] = ilUtil::getSystemMessageHTML("[MESSAGE]", 'failure');
72  $templates['question'] = ilUtil::getSystemMessageHTML("[MESSAGE]", 'question');
73 
74  $this->addJsConfig('templates', $templates);
75 
76  $tpl->addOnLoadCode(
77  "$('#" .
78  $this->content_container_id .
79  "').study_programme_notifications(" .
80  json_encode($this->js_config, JSON_THROW_ON_ERROR) .
81  ");"
82  );
83 
84  $this->js_init = true;
85  }
86  }
87 
91  public function getHTML(): void
92  {
93  $this->initJs();
94  }
95 
99  public function getContentContainerId(): ?string
100  {
102  }
103 
107  public function setContentContainerId(?string $content_container_id): void
108  {
109  $this->content_container_id = $content_container_id;
110  }
111 
115  public function getJsPath(): string
116  {
117  return $this->js_path;
118  }
119 
123  public function setJsPath(string $js_path): void
124  {
125  $this->js_path = $js_path;
126  }
127 
133  public function getJsConfig($key)
134  {
135  return $this->js_config[$key];
136  }
137 
144  public function addJsConfig($key, $value): void
145  {
146  $this->js_config[$key] = $value;
147  }
148 }
addJsConfig($key, $value)
Sets Jquery settings for the plugin.
static getSystemMessageHTML(string $a_txt, string $a_type="info")
Get HTML for a system message.
setJsPath(string $js_path)
Sets the path for the java scripts.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(string $content_container_id=null)
getJsConfig($key)
Gets a setting of the jquery-plugin config.
global $DIC
Definition: feed.php:28
getContentContainerId()
Gets the target container for the notification.
getJsPath()
Return the path for the java scripts.
setContentContainerId(?string $content_container_id)
Sets the target container for the notification.
getHTML()
Returns the component (returns the js tag)
string $key
Consumer key/client ID value.
Definition: System.php:193
initJs()
Setup the message templates and add the js onload code.
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41