ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilTaggingSlateContentGUI Class Reference

Tagging slate UI. More...

+ Collaboration diagram for ilTaggingSlateContentGUI:

Public Member Functions

 __construct ()
 Constructor. More...
 
 executeCommand ()
 Execute command. More...
 
 render ()
 Render. More...
 
 removeTagsWithoutAccess ()
 Remove tasg without access. More...
 
 getNoTagsUsedMessage ()
 No tags used message box. More...
 

Data Fields

const CURRENT_TAG_KEY = "tag_current_tag"
 

Protected Member Functions

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

Protected Attributes

 $ctrl
 
 $user
 
 $ui
 
 $lng
 
 $access
 
 $tree
 
 $http
 
 $requested_tag
 
 $store
 

Detailed Description

Tagging slate UI.

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

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

Constructor & Destructor Documentation

◆ __construct()

ilTaggingSlateContentGUI::__construct ( )

Constructor.

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

References $DIC, getCurrentTag(), ilTagging\getTagsForUser(), ILIAS\FileDelivery\http(), ui(), and user().

66  {
67  global $DIC;
68 
69  $this->ctrl = $DIC->ctrl();
70  $this->user = $DIC->user();
71  $this->ui = $DIC->ui();
72  $this->lng = $DIC->language();
73  $this->access = $DIC->access();
74  $this->tree = $DIC->repositoryTree();
75  $this->http = $DIC->http();
76  $this->store = new ilSessionIStorage("tag");
77 
78  $this->lng->loadLanguageModule("tagging");
79 
80  $this->tags = ilTagging::getTagsForUser($this->user->getId(), 1000000);
81 
82  $this->requested_tag = str_replace("-->", "",
83  $this->http->request()->getQueryParams()["tag"]);
84  if ($this->requested_tag == "") {
85  $this->requested_tag = $this->getCurrentTag();
86  }
87  }
user()
Definition: user.php:4
static getTagsForUser($a_user_id, $a_max=0, $a_only_online=true)
Get tags for a user.
static http()
Fetches the global http state from ILIAS.
ui()
Definition: ui.php:5
$DIC
Definition: xapitoken.php:46
Session based immediate storage.
+ Here is the call graph for this function:

Member Function Documentation

◆ clearCurrentTag()

ilTaggingSlateContentGUI::clearCurrentTag ( )
protected

Clear current tag.

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

Referenced by renderTagCloud().

362  {
363  $this->store->set(self::CURRENT_TAG_KEY, "");
364  }
+ Here is the caller graph for this function:

◆ executeCommand()

ilTaggingSlateContentGUI::executeCommand ( )

Execute command.

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

References $ctrl.

93  {
95 
96  $next_class = $ctrl->getNextClass($this);
97  $cmd = $ctrl->getCmd();
98 
99  switch ($next_class) {
100  default:
101  if (in_array($cmd, array("showResourcesForTag", "showTagCloud"))) {
102  $this->$cmd();
103  }
104  }
105  }

◆ getCurrentTag()

ilTaggingSlateContentGUI::getCurrentTag ( )
protected

Get current tag.

Returns
string

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

Referenced by __construct(), and render().

354  {
355  return $this->store->get(self::CURRENT_TAG_KEY);
356  }
+ Here is the caller graph for this function:

◆ getNoTagsUsedMessage()

ilTaggingSlateContentGUI::getNoTagsUsedMessage ( )

No tags used message box.

Returns
ILIAS

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

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

Referenced by renderTagCloud().

298  {
299 
300  $txt = $this->lng->txt("no_tag_text_1") . "<br>";
301  $txt .= sprintf(
302  $this->lng->txt('no_tag_text_2'),
303  $this->getRepositoryTitle()
304  ) . "<br>";
305  $txt .= $this->lng->txt("no_tag_text_3");
306  $mbox = $this->ui->factory()->messageBox()->info($txt);
307  $mbox = $mbox->withLinks([$this->ui->factory()->link()->standard($this->getRepositoryTitle(), ilLink::_getStaticLink(1, 'root', true))]);
308 
309  return $mbox;
310  }
ui()
Definition: ui.php:5
$txt
Definition: error.php:13
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRepositoryTitle()

ilTaggingSlateContentGUI::getRepositoryTitle ( )
protected
Returns
string

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

References $nd.

Referenced by getNoTagsUsedMessage().

316  {
317  $nd = $this->tree->getNodeData($this->tree->getRootId());
318  $title = $nd['title'];
319 
320  if ($title == 'ILIAS') {
321  $title = $this->lng->txt('repository');
322  }
323 
324  return $title;
325  }
$nd
Definition: error.php:12
+ Here is the caller graph for this function:

◆ removeTagsWithoutAccess()

ilTaggingSlateContentGUI::removeTagsWithoutAccess ( )

Remove tasg without access.

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

References $access, $ctrl, $ilCtrl, $ilUser, $lng, $requested_tag, $type, $user, ilObject\_getAllReferences(), ilTagging\deleteTagOfObjectForUser(), and ilTagging\getObjectsForTagAndUser().

252  {
254  $ilAccess = $this->access;
256  $lng = $this->lng;
257  $tag = $this->requested_tag;
258 
259  // get resources
260  $objs = ilTagging::getObjectsForTagAndUser($ilUser->getId(), $tag);
261 
262  foreach ($objs as $key => $obj) {
263  $ref_ids = ilObject::_getAllReferences($obj["obj_id"]);
264  if (count($ref_ids) == 0) {
265  $inaccessible = true;
266  } else {
267  $inaccessible = false;
268  }
269  foreach ($ref_ids as $ref_id) {
270  $type = $obj["obj_type"];
271 
272  if ($type == "") {
273  $inaccessible = true;
274  continue;
275  }
276  if (!$ilAccess->checkAccess("visible", "", $ref_id) &&
277  !$ilAccess->checkAccess("read", "", $ref_id) &&
278  !$ilAccess->checkAccess("write", "", $ref_id)) {
279  $inaccessible = true;
280  }
281  if ($inaccessible) {
282  ilTagging::deleteTagOfObjectForUser($ilUser->getId(), $obj["obj_id"], $obj["obj_type"], $obj["sub_obj_id"], $obj["sub_obj_type"],$tag);
283  }
284  }
285  }
286 
287  ilUtil::sendSuccess($lng->txt("tag_tags_deleted"), true);
288 
289  $ilCtrl->returnToParent($this);
290  }
$type
static deleteTagOfObjectForUser($a_user_id, $a_obj_id, $a_obj_type, $a_sub_obj_id, $a_sub_obj_type, $a_tag)
Deletes tag of an object.
static _getAllReferences($a_id)
get all reference ids of object
global $ilCtrl
Definition: ilias.php:18
$ilUser
Definition: imgupload.php:18
static getObjectsForTagAndUser($a_user_id, $a_tag)
Get objects for tag and user.
+ Here is the call graph for this function:

◆ render()

ilTaggingSlateContentGUI::render ( )

Render.

Returns
string
Exceptions
ilTemplateException

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

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

113  {
114  if ($this->getCurrentTag() != "") {
115  $content = $this->renderResourcesForTag();
116  } else {
117  $content = $this->renderTagCloud();
118  }
119  return "<div id='il-tag-slate-container'>" . $content . "</div>";
120  }
+ Here is the call graph for this function:

◆ renderResourcesForTag()

ilTaggingSlateContentGUI::renderResourcesForTag ( )
protected

Render resources.

Returns
string

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

References $access, $ctrl, Vendor\Package\$f, $ilUser, $lng, $requested_tag, $type, $ui, $user, ilObject\_getAllReferences(), ilLink\_getLink(), ilObject\_lookupTitle(), ilTagging\getObjectsForTagAndUser(), ilUtil\secureString(), setCurrentTag(), ui(), and ILIAS\UI\Implementation\Component\withOnLoadCode().

Referenced by render(), and showResourcesForTag().

173  {
174  $ui = $this->ui;
175  $lng = $this->lng;
176  $ctrl = $this->ctrl;
179  $tag = $this->requested_tag;
180  $this->setCurrentTag($tag);
181 
182  // back button
183  $tag_cmd = $ctrl->getLinkTarget($this, "showTagCloud", "", true, false);
184  $back_button = $ui->factory()->button()->bulky($ui->factory()->symbol()->glyph()->back(), $lng->txt("back"), "#")->withOnLoadCode(function ($id) use ($tag_cmd) {
185  return
186  "$(\"#$id\").click(function() { il.Util.ajaxReplaceInner('$tag_cmd', 'il-tag-slate-container'); return false;});";
187  });
188 
189  // resource list
190  include_once("./Services/Tagging/classes/class.ilTagging.php");
191  $objs = ilTagging::getObjectsForTagAndUser($ilUser->getId(), $tag);
192 
193  $f = $this->ui->factory();
194  $item_groups = [];
195  $items = [];
196  foreach ($objs as $key => $obj) {
197  $ref_ids = ilObject::_getAllReferences($obj["obj_id"]);
198  foreach ($ref_ids as $ref_id) {
199  $type = $obj["obj_type"];
200 
201  if ($type == "" || (!$access->checkAccess("visible", "", $ref_id) &&
202  !$access->checkAccess("read", "", $ref_id))) {
203  continue;
204  }
205 
206  $title = ilObject::_lookupTitle($obj["obj_id"]);
207  $items[] = $f->item()->standard(
208  $f->link()->standard($title, ilLink::_getLink($ref_id))
209  )->withLeadIcon($f->symbol()->icon()->custom(ilObject::_getIcon($obj["obj_id"]), $title));
210  }
211  }
212  $item_groups[] = $f->item()->group(sprintf(
213  $lng->txt("tagging_resources_for_tag"),
214  "<i>" . ilUtil::secureString($tag) . "</i>"
215  ), $items);
216  $panel = $f->panel()->secondary()->listing("", $item_groups);
217 
218  $components = [$back_button, $panel];
219  if (count($items) == 0) {
220  $mbox = $f->messageBox()->info(
221  sprintf($lng->txt("tagging_no_obj_for_tag"), ilUtil::secureString($tag))
222  );
223  $components = [$back_button, $mbox];
224  }
225 
226  return $ui->renderer()->renderAsync($components);
227  }
setCurrentTag(string $tag)
Set current tag.
$type
static _lookupTitle($a_id)
lookup object title
static _getAllReferences($a_id)
get all reference ids of object
$ilUser
Definition: imgupload.php:18
ui()
Definition: ui.php:5
static getObjectsForTagAndUser($a_user_id, $a_tag)
Get objects for tag and user.
static secureString($a_str, $a_strip_html=true, $a_allow="")
Remove unsecure tags.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderTagCloud()

ilTaggingSlateContentGUI::renderTagCloud ( )
protected

Get tag cloud.

Returns
string
Exceptions
ilTemplateException

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

References $ctrl, $ilCtrl, $tpl, clearCurrentTag(), getNoTagsUsedMessage(), ilTagging\getRelevanceClass(), and ui().

Referenced by render(), and showTagCloud().

128  : string
129  {
131  $this->clearCurrentTag();
132 
133  $tpl = new ilTemplate(
134  "tpl.tag_cloud.html",
135  true,
136  true,
137  "Services/Tagging"
138  );
139  $max = 1;
140  foreach ($this->tags as $tag) {
141  $max = max($tag["cnt"], $max);
142  }
143  reset($this->tags);
144 
145  if (count($this->tags) > 0) {
146  foreach ($this->tags as $tag) {
147  $tpl->setCurrentBlock("linked_tag");
148  $ilCtrl->setParameter($this, "tag", rawurlencode($tag["tag"]));
149  $list_cmd = $ilCtrl->getLinkTarget($this, "showResourcesForTag");
150  $tpl->setVariable("ON_CLICK",
151  "il.Util.ajaxReplaceInner('$list_cmd', 'il-tag-slate-container'); return false;");
152  $tpl->setVariable("TAG_TITLE", $tag["tag"]);
153  $tpl->setVariable("HREF_TAG", "#");
154  $tpl->setVariable(
155  "REL_CLASS",
156  ilTagging::getRelevanceClass($tag["cnt"], $max)
157  );
158  $tpl->parseCurrentBlock();
159  }
160  return $tpl->get();
161  } else {
162  return $this->ui->renderer()->render($this->getNoTagsUsedMessage());
163  }
164  }
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
getNoTagsUsedMessage()
No tags used message box.
global $ilCtrl
Definition: ilias.php:18
ui()
Definition: ui.php:5
static getRelevanceClass($cnt, $max)
Get style class for tag relevance.
+ 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

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

References ILIAS\FileDelivery\http().

Referenced by showResourcesForTag(), and showTagCloud().

333  {
334  $this->http->saveResponse($this->http->response()->withBody(
335  Streams::ofString($output)));
336  $this->http->sendResponse();
337  $this->http->close();
338  }
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

Set current tag.

Parameters
string

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

Referenced by renderResourcesForTag().

345  {
346  $this->store->set(self::CURRENT_TAG_KEY, $tag);
347  }
+ Here is the caller graph for this function:

◆ showResourcesForTag()

ilTaggingSlateContentGUI::showResourcesForTag ( )
protected

show resources

Exceptions

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

References renderResourcesForTag(), and send().

235  {
236  $this->send($this->renderResourcesForTag());
237  }
+ Here is the call graph for this function:

◆ showTagCloud()

ilTaggingSlateContentGUI::showTagCloud ( )
protected

Show tag cloud.

Exceptions
ilTemplateException

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

References renderTagCloud(), and send().

243  {
244  $this->send($this->renderTagCloud());
245  }
+ Here is the call graph for this function:

Field Documentation

◆ $access

ilTaggingSlateContentGUI::$access
protected

◆ $ctrl

ilTaggingSlateContentGUI::$ctrl
protected

◆ $http

ilTaggingSlateContentGUI::$http
protected

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

◆ $lng

ilTaggingSlateContentGUI::$lng
protected

◆ $requested_tag

ilTaggingSlateContentGUI::$requested_tag
protected

◆ $store

ilTaggingSlateContentGUI::$store
protected

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

◆ $tree

ilTaggingSlateContentGUI::$tree
protected

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

◆ $ui

ilTaggingSlateContentGUI::$ui
protected

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

Referenced by renderResourcesForTag().

◆ $user

ilTaggingSlateContentGUI::$user
protected

◆ CURRENT_TAG_KEY

const ilTaggingSlateContentGUI::CURRENT_TAG_KEY = "tag_current_tag"

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


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