ILIAS  release_8 Revision v8.25-1-g13de6a5eca6
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.

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 }
Session based immediate storage.
static getTagsForUser(int $a_user_id, int $a_max=0, bool $a_only_online=true)
global $DIC
Definition: feed.php:28
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:33
static http()
Fetches the global http state from ILIAS.

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().

+ Here is the call graph for this function:

Member Function Documentation

◆ clearCurrentTag()

ilTaggingSlateContentGUI::clearCurrentTag ( )
protected

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

323 : void
324 {
325 $this->store->set(self::CURRENT_TAG_KEY, "");
326 }

Referenced by renderTagCloud().

+ Here is the caller graph for this function:

◆ executeCommand()

ilTaggingSlateContentGUI::executeCommand ( )

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

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 }
getNextClass($a_gui_class=null)
@inheritDoc
getCmd(string $fallback_command=null)
@inheritDoc

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

+ Here is the call graph for this function:

◆ getCurrentTag()

ilTaggingSlateContentGUI::getCurrentTag ( )
protected

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

317 : string
318 {
319 // PHP8 Review: Type cast is unnecessary
320 return (string) $this->store->get(self::CURRENT_TAG_KEY);
321 }

Referenced by __construct(), and render().

+ Here is the caller graph for this function:

◆ getNoTagsUsedMessage()

ilTaggingSlateContentGUI::getNoTagsUsedMessage ( )

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

273 {
274 $txt = $this->lng->txt("no_tag_text_1") . "<br>";
275 $txt .= sprintf(
276 $this->lng->txt('no_tag_text_2'),
277 $this->getRepositoryTitle()
278 ) . "<br>";
279 $txt .= $this->lng->txt("no_tag_text_3");
280 $mbox = $this->ui->factory()->messageBox()->info($txt);
281 $mbox = $mbox->withLinks([$this->ui->factory()->link()->standard($this->getRepositoryTitle(), ilLink::_getStaticLink(1, 'root', true))]);
282
283 return $mbox;
284 }
$txt
Definition: error.php:13

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

Referenced by renderTagCloud().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRepositoryTitle()

ilTaggingSlateContentGUI::getRepositoryTitle ( )
protected

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

286 : string
287 {
288 $nd = $this->tree->getNodeData($this->tree->getRootId());
289 $title = $nd['title'];
290
291 if ($title === 'ILIAS') {
292 $title = $this->lng->txt('repository');
293 }
294
295 return $title;
296 }
$nd
Definition: error.php:12

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

+ Here is the call graph for this function:

◆ removeTagsWithoutAccess()

ilTaggingSlateContentGUI::removeTagsWithoutAccess ( )

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

228 : void
229 {
230 $ilCtrl = $this->ctrl;
231 $ilAccess = $this->access;
235
236 // get resources
237 $objs = ilTagging::getObjectsForTagAndUser($ilUser->getId(), $tag);
238
239 foreach ($objs as $key => $obj) {
240 $ref_ids = ilObject::_getAllReferences((int) $obj["obj_id"]);
241 if (count($ref_ids) == 0) {
242 $inaccessible = true;
243 } else {
244 $inaccessible = false;
245 }
246 foreach ($ref_ids as $ref_id) {
247 $type = $obj["obj_type"];
248
249 if ($type == "") {
250 $inaccessible = true;
251 continue;
252 }
253 if (!$ilAccess->checkAccess("visible", "", $ref_id) &&
254 !$ilAccess->checkAccess("read", "", $ref_id) &&
255 !$ilAccess->checkAccess("write", "", $ref_id)) {
256 $inaccessible = true;
257 }
258 if ($inaccessible) {
260 $ilUser->getId(),
261 (int) $obj["obj_id"],
262 (string) $obj["obj_type"],
263 (int) $obj["sub_obj_id"],
264 (string) $obj["sub_obj_type"],
265 $tag
266 );
267 }
268 }
269 }
270 }
static _getAllReferences(int $id)
get all reference ids for object ID
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)
static getObjectsForTagAndUser(int $a_user_id, string $a_tag)
$ilUser
Definition: imgupload.php:34
$ref_id
Definition: ltiauth.php:67
string $key
Consumer key/client ID value.
Definition: System.php:193
$type

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

Referenced by renderResourcesForTag().

+ 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.

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 }

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

+ Here is the call graph for this function:

◆ renderResourcesForTag()

ilTaggingSlateContentGUI::renderResourcesForTag ( )
protected

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

151 : string
152 {
153 $ui = $this->ui;
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 "$(\"#$id\").click(function() { il.Util.ajaxReplaceInner('$tag_cmd', 'il-tag-slate-container'); return false;});";
166 });
167
168 // resource list
169 $objs = ilTagging::getObjectsForTagAndUser($ilUser->getId(), $tag);
170
171 $f = $this->ui->factory();
172 $item_groups = [];
173 $items = [];
174 foreach ($objs as $key => $obj) {
175 $ref_ids = ilObject::_getAllReferences((int) $obj["obj_id"]);
176 foreach ($ref_ids as $ref_id) {
177 $type = $obj["obj_type"];
178
179 if ($type == "" || (!$access->checkAccess("visible", "", $ref_id) &&
180 !$access->checkAccess("read", "", $ref_id))) {
181 continue;
182 }
183
184 $title = ilObject::_lookupTitle((int) $obj["obj_id"]);
185 $items[] = $f->item()->standard(
186 $f->link()->standard($title, ilLink::_getLink($ref_id))
187 )->withLeadIcon($f->symbol()->icon()->custom(ilObject::_getIcon((int) $obj["obj_id"]), $title));
188 }
189 }
190 $item_groups[] = $f->item()->group(sprintf(
191 $lng->txt("tagging_resources_for_tag"),
192 "<i>" . ilUtil::secureString($tag) . "</i>"
193 ), $items);
194 $panel = $f->panel()->secondary()->listing("", $item_groups);
195
196 $components = [$back_button, $panel];
197 if (count($items) == 0) {
198 $mbox = $f->messageBox()->info(
199 sprintf($lng->txt("tagging_no_obj_for_tag"), ilUtil::secureString($tag))
200 );
202 $components = [$back_button, $mbox];
203 }
204
205 return $ui->renderer()->renderAsync($components);
206 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
getLinkTarget(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
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 _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
static _lookupTitle(int $obj_id)
static secureString(string $a_str, bool $a_strip_html=true, string $a_allow="")
if(isset($_FILES['img_file']) &&is_array($_FILES['img_file'])) $panel
Definition: imgupload.php:198
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)

References $access, $ctrl, Vendor\Package\$f, $id, $ilUser, ILIAS\LTI\ToolProvider\$key, $lng, $panel, $ref_id, $requested_tag, $type, $ui, $user, ilObject\_getAllReferences(), ilObject\_getIcon(), ilLink\_getLink(), ilObject\_lookupTitle(), ilRBACAccessHandler\checkAccess(), ilCtrl\getLinkTarget(), ilTagging\getObjectsForTagAndUser(), removeTagsWithoutAccess(), ilUtil\secureString(), setCurrentTag(), ilLanguage\txt(), and ILIAS\Repository\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

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

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 "Services/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.Util.ajaxReplaceInner('$list_cmd', 'il-tag-slate-container'); 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)
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 ILIAS\Repository\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
ResponseSendingException

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

303 : void
304 {
305 $this->http->saveResponse($this->http->response()->withBody(
306 Streams::ofString($output)
307 ));
308 $this->http->sendResponse();
309 $this->http->close();
310 }

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

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

312 : void
313 {
314 $this->store->set(self::CURRENT_TAG_KEY, $tag);
315 }

Referenced by renderResourcesForTag().

+ Here is the caller graph for this function:

◆ showResourcesForTag()

ilTaggingSlateContentGUI::showResourcesForTag ( )
protected

show resources

Exceptions
ResponseSendingException

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

212 : void
213 {
214 $this->send($this->renderResourcesForTag());
215 }

References renderResourcesForTag(), and send().

+ Here is the call graph for this function:

◆ showTagCloud()

ilTaggingSlateContentGUI::showTagCloud ( )
protected

Show tag cloud.

Exceptions
ResponseSendingException

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

221 : void
222 {
223 $this->send($this->renderTagCloud());
224 }

References renderTagCloud(), and send().

+ 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: