ILIAS  release_7 Revision v7.30-3-g800a261c036
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 64 of file class.ilTaggingSlateContentGUI.php.

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

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

+ Here is the call graph for this function:

Member Function Documentation

◆ clearCurrentTag()

ilTaggingSlateContentGUI::clearCurrentTag ( )
protected

Clear current tag.

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

366 {
367 $this->store->set(self::CURRENT_TAG_KEY, "");
368 }

Referenced by renderTagCloud().

+ Here is the caller graph for this function:

◆ executeCommand()

ilTaggingSlateContentGUI::executeCommand ( )

Execute command.

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

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

References $ctrl.

◆ getCurrentTag()

ilTaggingSlateContentGUI::getCurrentTag ( )
protected

Get current tag.

Returns
string

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

358 {
359 return $this->store->get(self::CURRENT_TAG_KEY);
360 }

Referenced by __construct(), and render().

+ Here is the caller graph for this function:

◆ getNoTagsUsedMessage()

ilTaggingSlateContentGUI::getNoTagsUsedMessage ( )

No tags used message box.

Returns
ILIAS\UI\Component\MessageBox\MessageBox

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

302 {
303 $txt = $this->lng->txt("no_tag_text_1") . "<br>";
304 $txt .= sprintf(
305 $this->lng->txt('no_tag_text_2'),
306 $this->getRepositoryTitle()
307 ) . "<br>";
308 $txt .= $this->lng->txt("no_tag_text_3");
309 $mbox = $this->ui->factory()->messageBox()->info($txt);
310 $mbox = $mbox->withLinks([$this->ui->factory()->link()->standard($this->getRepositoryTitle(), ilLink::_getStaticLink(1, 'root', true))]);
311
312 return $mbox;
313 }
$txt
Definition: error.php:13

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

Referenced by renderTagCloud().

+ 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 318 of file class.ilTaggingSlateContentGUI.php.

319 {
320 $nd = $this->tree->getNodeData($this->tree->getRootId());
321 $title = $nd['title'];
322
323 if ($title == 'ILIAS') {
324 $title = $this->lng->txt('repository');
325 }
326
327 return $title;
328 }
$nd
Definition: error.php:12

References $nd.

◆ removeTagsWithoutAccess()

ilTaggingSlateContentGUI::removeTagsWithoutAccess ( )

Remove tasg without access.

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

256 {
257 $ilCtrl = $this->ctrl;
258 $ilAccess = $this->access;
262
263 // get resources
264 $objs = ilTagging::getObjectsForTagAndUser($ilUser->getId(), $tag);
265
266 foreach ($objs as $key => $obj) {
267 $ref_ids = ilObject::_getAllReferences($obj["obj_id"]);
268 if (count($ref_ids) == 0) {
269 $inaccessible = true;
270 } else {
271 $inaccessible = false;
272 }
273 foreach ($ref_ids as $ref_id) {
274 $type = $obj["obj_type"];
275
276 if ($type == "") {
277 $inaccessible = true;
278 continue;
279 }
280 if (!$ilAccess->checkAccess("visible", "", $ref_id) &&
281 !$ilAccess->checkAccess("read", "", $ref_id) &&
282 !$ilAccess->checkAccess("write", "", $ref_id)) {
283 $inaccessible = true;
284 }
285 if ($inaccessible) {
286 ilTagging::deleteTagOfObjectForUser($ilUser->getId(), $obj["obj_id"], $obj["obj_type"], $obj["sub_obj_id"], $obj["sub_obj_type"], $tag);
287 }
288 }
289 }
290
291 ilUtil::sendSuccess($lng->txt("tag_tags_deleted"), true);
292
293 $ilCtrl->returnToParent($this);
294 }
static _getAllReferences($a_id)
get all reference ids of object
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 getObjectsForTagAndUser($a_user_id, $a_tag)
Get objects for tag and user.
$ilUser
Definition: imgupload.php:18
$type

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

+ Here is the call graph for this function:

◆ render()

ilTaggingSlateContentGUI::render ( )

Render.

Returns
string
Exceptions
ilTemplateException

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

115 {
116 if ($this->getCurrentTag() != "") {
117 $content = $this->renderResourcesForTag();
118 } else {
119 $content = $this->renderTagCloud();
120 }
121 return "<div id='il-tag-slate-container'>" . $content . "</div>";
122 }

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

+ Here is the call graph for this function:

◆ renderResourcesForTag()

ilTaggingSlateContentGUI::renderResourcesForTag ( )
protected

Render resources.

Returns
string

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

177 {
178 $ui = $this->ui;
184 $this->setCurrentTag($tag);
185
186 // back button
187 $tag_cmd = $ctrl->getLinkTarget($this, "showTagCloud", "", true, false);
188 $back_button = $ui->factory()->button()->bulky($ui->factory()->symbol()->glyph()->back(), $lng->txt("back"), "#")->withOnLoadCode(function ($id) use ($tag_cmd) {
189 return
190 "$(\"#$id\").click(function() { il.Util.ajaxReplaceInner('$tag_cmd', 'il-tag-slate-container'); return false;});";
191 });
192
193 // resource list
194 include_once("./Services/Tagging/classes/class.ilTagging.php");
195 $objs = ilTagging::getObjectsForTagAndUser($ilUser->getId(), $tag);
196
197 $f = $this->ui->factory();
198 $item_groups = [];
199 $items = [];
200 foreach ($objs as $key => $obj) {
201 $ref_ids = ilObject::_getAllReferences($obj["obj_id"]);
202 foreach ($ref_ids as $ref_id) {
203 $type = $obj["obj_type"];
204
205 if ($type == "" || (!$access->checkAccess("visible", "", $ref_id) &&
206 !$access->checkAccess("read", "", $ref_id))) {
207 continue;
208 }
209
210 $title = ilObject::_lookupTitle($obj["obj_id"]);
211 $items[] = $f->item()->standard(
212 $f->link()->standard($title, ilLink::_getLink($ref_id))
213 )->withLeadIcon($f->symbol()->icon()->custom(ilObject::_getIcon($obj["obj_id"]), $title));
214 }
215 }
216 $item_groups[] = $f->item()->group(sprintf(
217 $lng->txt("tagging_resources_for_tag"),
218 "<i>" . ilUtil::secureString($tag) . "</i>"
219 ), $items);
220 $panel = $f->panel()->secondary()->listing("", $item_groups);
221
222 $components = [$back_button, $panel];
223 if (count($items) == 0) {
224 $mbox = $f->messageBox()->info(
225 sprintf($lng->txt("tagging_no_obj_for_tag"), ilUtil::secureString($tag))
226 );
227 $components = [$back_button, $mbox];
228 }
229
230 return $ui->renderer()->renderAsync($components);
231 }
static _lookupTitle($a_id)
lookup object title
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
setCurrentTag(string $tag)
Set current tag.
static secureString($a_str, $a_strip_html=true, $a_allow="")
Remove unsecure tags.
if(isset($_FILES['img_file']) &&is_array($_FILES['img_file'])) $panel
Definition: imgupload.php:138

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

Referenced by render(), and showResourcesForTag().

+ 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 130 of file class.ilTaggingSlateContentGUI.php.

130 : string
131 {
132 $ilCtrl = $this->ctrl;
133 $this->clearCurrentTag();
134
135 $tpl = new ilTemplate(
136 "tpl.tag_cloud.html",
137 true,
138 true,
139 "Services/Tagging"
140 );
141 $max = 1;
142 foreach ($this->tags as $tag) {
143 $max = max($tag["cnt"], $max);
144 }
145 reset($this->tags);
146
147 if (count($this->tags) > 0) {
148 foreach ($this->tags as $tag) {
149 $tpl->setCurrentBlock("linked_tag");
150 $ilCtrl->setParameter($this, "tag", rawurlencode($tag["tag"]));
151 $list_cmd = $ilCtrl->getLinkTarget($this, "showResourcesForTag");
152 $tpl->setVariable(
153 "ON_CLICK",
154 "il.Util.ajaxReplaceInner('$list_cmd', 'il-tag-slate-container'); return false;"
155 );
156 $tpl->setVariable("TAG_TITLE", $tag["tag"]);
157 $tpl->setVariable("HREF_TAG", "#");
158 $tpl->setVariable(
159 "REL_CLASS",
160 ilTagging::getRelevanceClass($tag["cnt"], $max)
161 );
162 $tpl->parseCurrentBlock();
163 }
164 return $tpl->get();
165 } else {
166 return $this->ui->renderer()->render($this->getNoTagsUsedMessage());
167 }
168 }
getNoTagsUsedMessage()
No tags used message box.
static getRelevanceClass($cnt, $max)
Get style class for tag relevance.
special template class to simplify handling of ITX/PEAR
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41

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

Referenced by render(), and showTagCloud().

+ 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

ILIAS\HTTP\Response\Sender\ResponseSendingException

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

336 {
337 $this->http->saveResponse($this->http->response()->withBody(
338 Streams::ofString($output)
339 ));
340 $this->http->sendResponse();
341 $this->http->close();
342 }

References ILIAS\FileDelivery\http().

Referenced by showResourcesForTag(), and showTagCloud().

+ 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 348 of file class.ilTaggingSlateContentGUI.php.

349 {
350 $this->store->set(self::CURRENT_TAG_KEY, $tag);
351 }

Referenced by renderResourcesForTag().

+ Here is the caller graph for this function:

◆ showResourcesForTag()

ilTaggingSlateContentGUI::showResourcesForTag ( )
protected

show resources

Exceptions

ILIAS\HTTP\Response\Sender\ResponseSendingException

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

239 {
240 $this->send($this->renderResourcesForTag());
241 }

References renderResourcesForTag(), and send().

+ Here is the call graph for this function:

◆ showTagCloud()

ilTaggingSlateContentGUI::showTagCloud ( )
protected

Show tag cloud.

Exceptions
ilTemplateException

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

247 {
248 $this->send($this->renderTagCloud());
249 }

References renderTagCloud(), and send().

+ 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 49 of file class.ilTaggingSlateContentGUI.php.

◆ $lng

ilTaggingSlateContentGUI::$lng
protected

◆ $requested_tag

ilTaggingSlateContentGUI::$requested_tag
protected

◆ $store

ilTaggingSlateContentGUI::$store
protected

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

◆ $tree

ilTaggingSlateContentGUI::$tree
protected

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

◆ $ui

ilTaggingSlateContentGUI::$ui
protected

Definition at line 29 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 14 of file class.ilTaggingSlateContentGUI.php.


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