ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilTaggingSlateContentGUI Class Reference

Tagging slate UI. More...

+ Inheritance diagram for ilTaggingSlateContentGUI:
+ Collaboration diagram for ilTaggingSlateContentGUI:

Public Member Functions

 __construct ()
 Constructor. More...
 
 executeCommand ()
 
 render ()
 Render. More...
 
 removeTagsWithoutAccess ()
 
 getNoTagsUsedMessage ()
 

Data Fields

const CURRENT_TAG_KEY = "tag_current_tag"
 

Protected Member Functions

 renderTagCloud ()
 
 renderResourcesForTag ()
 
 showResourcesForTag ()
 show resources More...
 
 showTagCloud ()
 Show tag cloud. More...
 
 getRepositoryTitle ()
 
 send (string $output)
 Send. More...
 
 setCurrentTag (string $tag)
 
 getCurrentTag ()
 
 clearCurrentTag ()
 

Protected Attributes

ilCtrl $ctrl
 
ilObjUser $user
 
ILIAS DI UIServices $ui
 
ilLanguage $lng
 
ilAccessHandler $access
 
ilTree $tree
 
ILIAS HTTP Services $http
 
string $requested_tag
 
ilSessionIStorage $store
 
array $tags
 

Private Attributes

ilGlobalTemplateInterface $main_tpl
 

Detailed Description

Tagging slate UI.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 29 of file class.ilTaggingSlateContentGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilTaggingSlateContentGUI::__construct ( )

Constructor.

Definition at line 48 of file class.ilTaggingSlateContentGUI.php.

References $DIC, $params, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), getCurrentTag(), ilTagging\getTagsForUser(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\ui(), and ILIAS\Repository\user().

49  {
50  global $DIC;
51  $this->main_tpl = $DIC->ui()->mainTemplate();
52 
53  $this->ctrl = $DIC->ctrl();
54  $this->user = $DIC->user();
55  $this->ui = $DIC->ui();
56  $this->lng = $DIC->language();
57  $this->access = $DIC->access();
58  $this->tree = $DIC->repositoryTree();
59  $this->http = $DIC->http();
60  $this->store = new ilSessionIStorage("tag");
61 
62  $this->lng->loadLanguageModule("tagging");
63 
64  $this->tags = ilTagging::getTagsForUser($this->user->getId(), 1000000);
65 
66  $params = $this->http->request()->getQueryParams();
67  $this->requested_tag = str_replace(
68  "-->",
69  "",
70  $params["tag"] ?? ""
71  );
72  if ($this->requested_tag == "") {
73  $this->requested_tag = $this->getCurrentTag();
74  }
75  }
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:31
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:22
static getTagsForUser(int $a_user_id, int $a_max=0, bool $a_only_online=true)
Session based immediate storage.
+ Here is the call graph for this function:

Member Function Documentation

◆ clearCurrentTag()

ilTaggingSlateContentGUI::clearCurrentTag ( )
protected

Definition at line 328 of file class.ilTaggingSlateContentGUI.php.

Referenced by renderTagCloud().

328  : void
329  {
330  $this->store->set(self::CURRENT_TAG_KEY, "");
331  }
+ Here is the caller graph for this function:

◆ executeCommand()

ilTaggingSlateContentGUI::executeCommand ( )

Definition at line 77 of file class.ilTaggingSlateContentGUI.php.

References $ctrl, ilCtrl\getCmd(), and ilCtrl\getNextClass().

77  : void
78  {
80 
81  $next_class = $ctrl->getNextClass($this);
82  $cmd = $ctrl->getCmd();
83 
84  // PHP8 Review: 'switch' with single 'case'
85  switch ($next_class) {
86  default:
87  if (in_array($cmd, array("showResourcesForTag", "showTagCloud"))) {
88  $this->$cmd();
89  }
90  }
91  }
getCmd(?string $fallback_command=null)
getNextClass($a_gui_class=null)
+ Here is the call graph for this function:

◆ getCurrentTag()

ilTaggingSlateContentGUI::getCurrentTag ( )
protected

Definition at line 322 of file class.ilTaggingSlateContentGUI.php.

Referenced by __construct(), and render().

322  : string
323  {
324  // PHP8 Review: Type cast is unnecessary
325  return (string) $this->store->get(self::CURRENT_TAG_KEY);
326  }
+ Here is the caller graph for this function:

◆ getNoTagsUsedMessage()

ilTaggingSlateContentGUI::getNoTagsUsedMessage ( )

Definition at line 277 of file class.ilTaggingSlateContentGUI.php.

References $txt, ilLink\_getStaticLink(), getRepositoryTitle(), ILIAS\Repository\lng(), and ILIAS\Repository\ui().

Referenced by renderTagCloud().

278  {
279  $txt = $this->lng->txt("no_tag_text_1") . "<br>";
280  $txt .= sprintf(
281  $this->lng->txt('no_tag_text_2'),
282  $this->getRepositoryTitle()
283  ) . "<br>";
284  $txt .= $this->lng->txt("no_tag_text_3");
285  $mbox = $this->ui->factory()->messageBox()->info($txt);
286  $mbox = $mbox->withLinks([$this->ui->factory()->link()->standard($this->getRepositoryTitle(), ilLink::_getStaticLink(1, 'root', true))]);
287 
288  return $mbox;
289  }
$txt
Definition: error.php:31
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRepositoryTitle()

ilTaggingSlateContentGUI::getRepositoryTitle ( )
protected

Definition at line 291 of file class.ilTaggingSlateContentGUI.php.

References $nd, and ILIAS\Repository\lng().

Referenced by getNoTagsUsedMessage().

291  : string
292  {
293  $nd = $this->tree->getNodeData($this->tree->getRootId());
294  $title = $nd['title'];
295 
296  if ($title === 'ILIAS') {
297  $title = $this->lng->txt('repository');
298  }
299 
300  return $title;
301  }
$nd
Definition: error.php:30
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeTagsWithoutAccess()

ilTaggingSlateContentGUI::removeTagsWithoutAccess ( )

Definition at line 233 of file class.ilTaggingSlateContentGUI.php.

References $access, $ctrl, $lng, $ref_id, $requested_tag, $user, ilObject\_getAllReferences(), ilTagging\deleteTagOfObjectForUser(), ilTagging\getObjectsForTagAndUser(), and ILIAS\Repository\int().

Referenced by renderResourcesForTag().

233  : void
234  {
235  $ilCtrl = $this->ctrl;
236  $ilAccess = $this->access;
237  $ilUser = $this->user;
238  $lng = $this->lng;
239  $tag = $this->requested_tag;
240 
241  // get resources
242  $objs = ilTagging::getObjectsForTagAndUser($ilUser->getId(), $tag);
243 
244  foreach ($objs as $key => $obj) {
245  $ref_ids = ilObject::_getAllReferences((int) $obj["obj_id"]);
246  if (count($ref_ids) == 0) {
247  $inaccessible = true;
248  } else {
249  $inaccessible = false;
250  }
251  foreach ($ref_ids as $ref_id) {
252  $type = $obj["obj_type"];
253 
254  if ($type == "") {
255  $inaccessible = true;
256  continue;
257  }
258  if (!$ilAccess->checkAccess("visible", "", $ref_id) &&
259  !$ilAccess->checkAccess("read", "", $ref_id) &&
260  !$ilAccess->checkAccess("write", "", $ref_id)) {
261  $inaccessible = true;
262  }
263  if ($inaccessible) {
265  $ilUser->getId(),
266  (int) $obj["obj_id"],
267  (string) $obj["obj_type"],
268  (int) $obj["sub_obj_id"],
269  (string) $obj["sub_obj_type"],
270  $tag
271  );
272  }
273  }
274  }
275  }
static getObjectsForTagAndUser(int $a_user_id, string $a_tag)
static _getAllReferences(int $id)
get all reference ids for object ID
$ref_id
Definition: ltiauth.php:65
static deleteTagOfObjectForUser(int $a_user_id, int $a_obj_id, string $a_obj_type, int $a_sub_obj_id, string $a_sub_obj_type, string $a_tag)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ render()

ilTaggingSlateContentGUI::render ( )

Render.

Returns
string
Exceptions
ilTemplateException

Definition at line 98 of file class.ilTaggingSlateContentGUI.php.

References getCurrentTag(), renderResourcesForTag(), and renderTagCloud().

98  : string
99  {
100  if ($this->getCurrentTag() != "") {
101  $content = $this->renderResourcesForTag();
102  } else {
103  $content = $this->renderTagCloud();
104  }
105  return "<div id='il-tag-slate-container'>" . $content . "</div>";
106  }
+ Here is the call graph for this function:

◆ renderResourcesForTag()

ilTaggingSlateContentGUI::renderResourcesForTag ( )
protected

Definition at line 151 of file class.ilTaggingSlateContentGUI.php.

References $access, $components, $ctrl, Vendor\Package\$f, $id, $lng, $ref_id, $requested_tag, $ui, $user, ilObject\_getAllReferences(), ilObject\_getIcon(), ilObject\_lookupTitle(), ilCtrl\getLinkTarget(), ilTagging\getObjectsForTagAndUser(), removeTagsWithoutAccess(), ilUtil\secureString(), setCurrentTag(), ILIAS\Repository\ui(), and ILIAS\UI\Implementation\Component\withOnLoadCode().

Referenced by render(), and showResourcesForTag().

151  : string
152  {
153  $ui = $this->ui;
154  $lng = $this->lng;
155  $ctrl = $this->ctrl;
157  $ilUser = $this->user;
158  $tag = $this->requested_tag;
159  $this->setCurrentTag($tag);
160 
161  // back button
162  $tag_cmd = $ctrl->getLinkTarget($this, "showTagCloud", "", true, false);
163  $back_button = $ui->factory()->button()->bulky($ui->factory()->symbol()->glyph()->back(), $lng->txt("back"), "#")->withOnLoadCode(function ($id) use ($tag_cmd) {
164  return
165  "document.getElementById('$id').addEventListener('click', function() {
166  const el = document.getElementById('il-tag-slate-container');
167  if (el) {
168  il.repository.core.fetchReplaceInner(el, '$tag_cmd');
169  return false;
170  }});";
171  });
172 
173  // resource list
174  $objs = ilTagging::getObjectsForTagAndUser($ilUser->getId(), $tag);
175 
176  $f = $this->ui->factory();
177  $item_groups = [];
178  $items = [];
179  foreach ($objs as $key => $obj) {
180  $ref_ids = ilObject::_getAllReferences((int) $obj["obj_id"]);
181  foreach ($ref_ids as $ref_id) {
182  $type = $obj["obj_type"];
183 
184  if ($type == "" || (!$access->checkAccess("visible", "", $ref_id) &&
185  !$access->checkAccess("read", "", $ref_id))) {
186  continue;
187  }
188 
189  $title = ilObject::_lookupTitle((int) $obj["obj_id"]);
190  $items[] = $f->item()->standard(
191  $f->link()->standard($title, ilLink::_getLink($ref_id))
192  )->withLeadIcon($f->symbol()->icon()->custom(ilObject::_getIcon((int) $obj["obj_id"]), $title));
193  }
194  }
195  $item_groups[] = $f->item()->group(sprintf(
196  $lng->txt("tagging_resources_for_tag"),
197  "<i>" . ilUtil::secureString($tag) . "</i>"
198  ), $items);
199  $panel = $f->panel()->secondary()->listing("", $item_groups);
200 
201  $components = [$back_button, $panel];
202  if (count($items) == 0) {
203  $mbox = $f->messageBox()->info(
204  sprintf($lng->txt("tagging_no_obj_for_tag"), ilUtil::secureString($tag))
205  );
206  $this->removeTagsWithoutAccess();
207  $components = [$back_button, $mbox];
208  }
209 
210  return $ui->renderer()->renderAsync($components);
211  }
static getObjectsForTagAndUser(int $a_user_id, string $a_tag)
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static secureString(string $a_str, bool $a_strip_html=true, string $a_allow="")
checkAccess(string $a_permission, string $a_cmd, int $a_ref_id, string $a_type="", ?int $a_obj_id=null, ?int $a_tree_id=null)
check access for an object (provide $a_type and $a_obj_id if available for better performance) ...
static _getAllReferences(int $id)
get all reference ids for object ID
getLinkTarget(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
$components
$ref_id
Definition: ltiauth.php:65
static _lookupTitle(int $obj_id)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderTagCloud()

ilTaggingSlateContentGUI::renderTagCloud ( )
protected

Definition at line 109 of file class.ilTaggingSlateContentGUI.php.

References $ctrl, clearCurrentTag(), getNoTagsUsedMessage(), ilTagging\getRelevanceClass(), and ILIAS\Repository\ui().

Referenced by render(), and showTagCloud().

109  : string
110  {
111  $ilCtrl = $this->ctrl;
112  $this->clearCurrentTag();
113 
114  $tpl = new ilTemplate(
115  "tpl.tag_cloud.html",
116  true,
117  true,
118  "components/ILIAS/Tagging"
119  );
120  $max = 1;
121  foreach ($this->tags as $tag) {
122  $max = max($tag["cnt"], $max);
123  }
124  reset($this->tags);
125 
126  if (count($this->tags) > 0) {
127  foreach ($this->tags as $tag) {
128  $tpl->setCurrentBlock("linked_tag");
129  $ilCtrl->setParameter($this, "tag", rawurlencode($tag["tag"]));
130  $list_cmd = $ilCtrl->getLinkTarget($this, "showResourcesForTag");
131  $tpl->setVariable(
132  "ON_CLICK",
133  "il.repository.core.fetchReplaceInner(document.getElementById('il-tag-slate-container'), '$list_cmd'); return false;"
134  );
135  $tpl->setVariable("TAG_TITLE", $tag["tag"]);
136  $tpl->setVariable("HREF_TAG", "#");
137  $tpl->setVariable(
138  "REL_CLASS",
139  ilTagging::getRelevanceClass((int) $tag["cnt"], (int) $max)
140  );
141  $tpl->parseCurrentBlock();
142  }
143  return $tpl->get();
144  }
145 
146  return $this->ui->renderer()->render($this->getNoTagsUsedMessage());
147  }
static getRelevanceClass(int $cnt, int $max)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ send()

ilTaggingSlateContentGUI::send ( string  $output)
protected

Send.

Parameters
string$output
Exceptions
ResponseSendingException

Definition at line 308 of file class.ilTaggingSlateContentGUI.php.

References ILIAS\FileDelivery\http().

Referenced by showResourcesForTag(), and showTagCloud().

308  : void
309  {
310  $this->http->saveResponse($this->http->response()->withBody(
311  Streams::ofString($output)
312  ));
313  $this->http->sendResponse();
314  $this->http->close();
315  }
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCurrentTag()

ilTaggingSlateContentGUI::setCurrentTag ( string  $tag)
protected

Definition at line 317 of file class.ilTaggingSlateContentGUI.php.

Referenced by renderResourcesForTag().

317  : void
318  {
319  $this->store->set(self::CURRENT_TAG_KEY, $tag);
320  }
+ Here is the caller graph for this function:

◆ showResourcesForTag()

ilTaggingSlateContentGUI::showResourcesForTag ( )
protected

show resources

Exceptions
ResponseSendingException

Definition at line 217 of file class.ilTaggingSlateContentGUI.php.

References renderResourcesForTag(), and send().

217  : void
218  {
219  $this->send($this->renderResourcesForTag());
220  }
+ Here is the call graph for this function:

◆ showTagCloud()

ilTaggingSlateContentGUI::showTagCloud ( )
protected

Show tag cloud.

Exceptions
ResponseSendingException

Definition at line 226 of file class.ilTaggingSlateContentGUI.php.

References renderTagCloud(), and send().

226  : void
227  {
228  $this->send($this->renderTagCloud());
229  }
+ Here is the call graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilTaggingSlateContentGUI::$access
protected

◆ $ctrl

ilCtrl ilTaggingSlateContentGUI::$ctrl
protected

◆ $http

ILIAS HTTP Services ilTaggingSlateContentGUI::$http
protected

Definition at line 39 of file class.ilTaggingSlateContentGUI.php.

◆ $lng

ilLanguage ilTaggingSlateContentGUI::$lng
protected

◆ $main_tpl

ilGlobalTemplateInterface ilTaggingSlateContentGUI::$main_tpl
private

Definition at line 43 of file class.ilTaggingSlateContentGUI.php.

◆ $requested_tag

string ilTaggingSlateContentGUI::$requested_tag
protected

◆ $store

ilSessionIStorage ilTaggingSlateContentGUI::$store
protected

Definition at line 41 of file class.ilTaggingSlateContentGUI.php.

◆ $tags

array ilTaggingSlateContentGUI::$tags
protected

Definition at line 42 of file class.ilTaggingSlateContentGUI.php.

◆ $tree

ilTree ilTaggingSlateContentGUI::$tree
protected

Definition at line 38 of file class.ilTaggingSlateContentGUI.php.

◆ $ui

ILIAS DI UIServices ilTaggingSlateContentGUI::$ui
protected

Definition at line 35 of file class.ilTaggingSlateContentGUI.php.

Referenced by renderResourcesForTag().

◆ $user

ilObjUser ilTaggingSlateContentGUI::$user
protected

◆ CURRENT_TAG_KEY

const ilTaggingSlateContentGUI::CURRENT_TAG_KEY = "tag_current_tag"

Definition at line 31 of file class.ilTaggingSlateContentGUI.php.


The documentation for this class was generated from the following file: