ILIAS  release_8 Revision v8.24
ilTaggingGUI Class Reference

Class ilTaggingGUI. More...

+ Collaboration diagram for ilTaggingGUI:

Public Member Functions

 __construct ()
 Constructor. More...
 
 executeCommand ()
 Execute command. More...
 
 setObject (int $a_obj_id, string $a_obj_type, int $a_sub_obj_id=0, string $a_sub_obj_type="")
 Set Object. More...
 
 setUserId (int $a_userid)
 
 getUserId ()
 
 setSaveCmd (string $a_savecmd)
 
 getSaveCmd ()
 
 setInputFieldName (string $a_inputfieldname)
 
 getInputFieldName ()
 
 getTaggingInputHTML ()
 
 saveInput ()
 
 isForbidden (string $a_tag)
 
 getAllUserTagsForObjectHTML ()
 
 getHTML ()
 Get HTML. More...
 
 saveJS ()
 Save JS. More...
 

Static Public Member Functions

static initJavascript (string $a_ajax_url, ilGlobalTemplateInterface $a_main_tpl=null)
 
static getListTagsJSCall (string $a_hash, string $a_update_code=null)
 

Protected Member Functions

 getTagsFromInput (string $input)
 

Protected Attributes

ilCtrl $ctrl
 
ilObjUser $user
 
ilLanguage $lng
 
ILIAS DI UIServices $ui
 
int $obj_id = 0
 
string $obj_type = ""
 
int $sub_obj_id = 0
 
string $sub_obj_type
 
array $forbidden = []
 
int $userid = 0
 
string $savecmd = ""
 
string $inputfieldname = ""
 
RequestInterface $request
 
string $mess = ""
 
string $requested_mess = ""
 

Private Attributes

ilGlobalTemplateInterface $main_tpl
 

Detailed Description

Class ilTaggingGUI.

User interface class for tagging engine.

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

Definition at line 28 of file class.ilTaggingGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilTaggingGUI::__construct ( )

Constructor.

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

51 {
52 global $DIC;
53 $this->main_tpl = $DIC->ui()->mainTemplate();
54
55 $this->ctrl = $DIC->ctrl();
56 $this->user = $DIC->user();
57 $this->lng = $DIC->language();
58 $this->ui = $DIC->ui();
59 $this->request = $DIC->http()->request();
60
61 $params = $this->request->getQueryParams();
62 $this->requested_mess = ($params["mess"] ?? "");
63 }
global $DIC
Definition: feed.php:28
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:33

References $DIC, $params, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ILIAS\Repository\ui(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilTaggingGUI::executeCommand ( )

Execute command.

Definition at line 69 of file class.ilTaggingGUI.php.

69 : void
70 {
71 $ilCtrl = $this->ctrl;
72
73 $next_class = $ilCtrl->getNextClass();
74 // PHP8 Review: 'switch' with single 'case'
75 switch ($next_class) {
76 default:
77 $cmd = $ilCtrl->getCmd();
78 $this->$cmd();
79 break;
80 }
81 }
getNextClass($a_gui_class=null)
@inheritDoc

References $ctrl, and ilCtrl\getNextClass().

+ Here is the call graph for this function:

◆ getAllUserTagsForObjectHTML()

ilTaggingGUI::getAllUserTagsForObjectHTML ( )

Definition at line 225 of file class.ilTaggingGUI.php.

225 : string
226 {
227 $ttpl = new ilTemplate("tpl.tag_cloud.html", true, true, "Services/Tagging");
229 $this->obj_id,
230 $this->obj_type,
231 $this->sub_obj_id,
232 $this->sub_obj_type
233 );
234
235 $max = 1;
236 foreach ($tags as $tag) {
237 $max = max($max, $tag["cnt"]);
238 }
239 reset($tags);
240 foreach ($tags as $tag) {
241 if (!$this->isForbidden($tag["tag"])) {
242 $ttpl->setCurrentBlock("unlinked_tag");
243 $ttpl->setVariable(
244 "REL_CLASS",
245 ilTagging::getRelevanceClass((int) $tag["cnt"], (int) $max)
246 );
247 $ttpl->setVariable("TAG_TITLE", $tag["tag"]);
248 $ttpl->parseCurrentBlock();
249 }
250 }
251
252 return $ttpl->get();
253 }
isForbidden(string $a_tag)
static getTagsForObject(int $a_obj_id, string $a_obj_type, int $a_sub_obj_id, string $a_sub_obj_type, bool $a_only_online=true)
static getRelevanceClass(int $cnt, int $max)
special template class to simplify handling of ITX/PEAR

References ilTagging\getRelevanceClass(), and ilTagging\getTagsForObject().

+ Here is the call graph for this function:

◆ getHTML()

ilTaggingGUI::getHTML ( )

Get HTML.

Definition at line 299 of file class.ilTaggingGUI.php.

299 : string
300 {
302 $ilCtrl = $this->ctrl;
303 $ui = $this->ui;
304
305 $lng->loadLanguageModule("tagging");
306 $tpl = new ilTemplate("tpl.edit_tags.html", true, true, "Services/Tagging");
307 $tpl->setVariable("TXT_TAGS", $lng->txt("tagging_tags"));
308
309 $mtxt = "";
310 $mtype = "";
311 $mess = $this->requested_mess != ""
312 ? $this->requested_mess
313 : $this->mess;
314 // PHP8 Review: 'switch' with single 'case'
315 switch ($mess) {
316 case "mod":
317 $mtype = "success";
318 $mtxt = $lng->txt("msg_obj_modified");
319 break;
320 }
321 if ($mtxt != "") {
322 $tpl->setVariable("MESS", ilUtil::getSystemMessageHTML($mtxt, $mtype));
323 } else {
324 $tpl->setVariable("MESS", "");
325 }
326
327 $title = ilObject::_lookupTitle($this->obj_id);
328 $icon = $ui->factory()->symbol()->icon()->custom(
329 ilObject::_getIcon($this->obj_id),
330 $title,
331 "medium"
332 );
333 $tpl->setVariable("ICON", $ui->renderer()->render($icon));
334 $tpl->setVariable("TXT_OBJ_TITLE", ilObject::_lookupTitle($this->obj_id));
336 $this->obj_id,
337 $this->obj_type,
338 $this->sub_obj_id,
339 $this->sub_obj_type,
340 $this->getUserId()
341 );
342 $tpl->setVariable(
343 "VAL_TAGS",
345 );
346 $tpl->setVariable("TXT_SAVE", $lng->txt("save"));
347 $tpl->setVariable("TXT_COMMA_SEPARATED", $lng->txt("comma_separated"));
348 $tpl->setVariable("CMD_SAVE", "saveJS");
349
350 $os = "ilTagging.cmdAjaxForm(event, '" .
351 $ilCtrl->getFormActionByClass("iltagginggui", "", "", true) .
352 "');";
353 $tpl->setVariable("ON_SUBMIT", $os);
354
355 $tags_set = new ilSetting("tags");
356 if ($tags_set->get("enable_all_users")) {
357 $tpl->setVariable("TAGS_TITLE", $lng->txt("tagging_my_tags"));
358
359 $all_obj_tags = ilTagging::_getListTagsForObjects(array($this->obj_id));
360 $all_obj_tags = $all_obj_tags[$this->obj_id] ?? null;
361 if (is_array($all_obj_tags) &&
362 sizeof($all_obj_tags) != sizeof($tags)) {
363 $tpl->setVariable("TITLE_OTHER", $lng->txt("tagging_other_users"));
364 $tpl->setCurrentBlock("tag_other_bl");
365 foreach ($all_obj_tags as $tag => $is_owner) {
366 if (!$is_owner) {
367 $tpl->setVariable("OTHER_TAG", $tag);
368 $tpl->parseCurrentBlock();
369 }
370 }
371 }
372 }
373
374 echo $tpl->get();
375 exit;
376 }
loadLanguageModule(string $a_module)
Load language module.
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 prepareFormOutput($a_str, bool $a_strip=false)
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ILIAS DI UIServices $ui
static getTagsForUserAndObject(int $a_obj_id, string $a_obj_type, int $a_sub_obj_id, string $a_sub_obj_type, int $a_user_id)
static _getListTagsForObjects(array $a_obj_ids, int $a_user_id=null)
Get tags for given object ids.
static getSystemMessageHTML(string $a_txt, string $a_type="info")
Get HTML for a system message.
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
exit
Definition: login.php:28

References $lng, $tpl, ilObject\_getIcon(), ilTagging\_getListTagsForObjects(), ilObject\_lookupTitle(), exit, ilUtil\getSystemMessageHTML(), ilTagging\getTagsForUserAndObject(), and ilLegacyFormElementsUtil\prepareFormOutput().

+ Here is the call graph for this function:

◆ getInputFieldName()

ilTaggingGUI::getInputFieldName ( )

Definition at line 142 of file class.ilTaggingGUI.php.

142 : string
143 {
145 }

◆ getListTagsJSCall()

static ilTaggingGUI::getListTagsJSCall ( string  $a_hash,
string  $a_update_code = null 
)
static

Definition at line 284 of file class.ilTaggingGUI.php.

287 : string {
288 if ($a_update_code === null) {
289 $a_update_code = "null";
290 } else {
291 $a_update_code = "'" . $a_update_code . "'";
292 }
293 return "ilTagging.listTags(event, '" . $a_hash . "', " . $a_update_code . ");";
294 }

Referenced by ilObjectListGUI\determineProperties(), ilObjectListGUI\getHeaderAction(), and ilObjectListGUI\insertCommonSocialCommands().

+ Here is the caller graph for this function:

◆ getSaveCmd()

ilTaggingGUI::getSaveCmd ( )

Definition at line 132 of file class.ilTaggingGUI.php.

132 : string
133 {
134 return $this->savecmd;
135 }

◆ getTaggingInputHTML()

ilTaggingGUI::getTaggingInputHTML ( )

Definition at line 147 of file class.ilTaggingGUI.php.

147 : string
148 {
150
151 $ttpl = new ilTemplate("tpl.tags_input.html", true, true, "Services/Tagging");
153 $this->obj_id,
154 $this->obj_type,
155 $this->sub_obj_id,
156 $this->sub_obj_type,
157 $this->getUserId()
158 );
159 $ttpl->setVariable(
160 "VAL_TAGS",
162 );
163 $ttpl->setVariable("TAG_LABEL", $lng->txt("tagging_my_tags"));
164 $ttpl->setVariable("TXT_SAVE", $lng->txt("save"));
165 $ttpl->setVariable("TXT_COMMA_SEPARATED", $lng->txt("comma_separated"));
166 $ttpl->setVariable("CMD_SAVE", $this->savecmd);
167 $ttpl->setVariable("NAME_TAGS", $this->getInputFieldName());
168
169 return $ttpl->get();
170 }

References $lng, ilTagging\getTagsForUserAndObject(), and ilLegacyFormElementsUtil\prepareFormOutput().

+ Here is the call graph for this function:

◆ getTagsFromInput()

ilTaggingGUI::getTagsFromInput ( string  $input)
protected

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

172 : array
173 {
174 $input = ilUtil::stripSlashes($input);
175 $input = str_replace("\r", "\n", $input);
176 $input = str_replace("\n\n", "\n", $input);
177 $input = str_replace("\n", ",", $input);
178 $itags = explode(",", $input);
179 return $itags;
180 }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")

References ilUtil\stripSlashes().

+ Here is the call graph for this function:

◆ getUserId()

ilTaggingGUI::getUserId ( )

Definition at line 122 of file class.ilTaggingGUI.php.

122 : int
123 {
124 return $this->userid;
125 }

◆ initJavascript()

static ilTaggingGUI::initJavascript ( string  $a_ajax_url,
ilGlobalTemplateInterface  $a_main_tpl = null 
)
static

Definition at line 260 of file class.ilTaggingGUI.php.

263 : void {
264 global $DIC;
265
266 if ($a_main_tpl != null) {
267 $tpl = $a_main_tpl;
268 } else {
269 $tpl = $DIC["tpl"];
270 }
271
272 $lng = $DIC->language();
273
274 $lng->loadLanguageModule("tagging");
275 $lng->toJS("tagging_tags", $tpl);
276
278 $tpl->addJavaScript("./Services/Tagging/js/ilTagging.js");
279
280 $tpl->addOnLoadCode("ilTagging.setAjaxUrl('" . $a_ajax_url . "');");
281 }
toJS($a_lang_key, ilGlobalTemplateInterface $a_tpl=null)
Transfer text to Javascript.
static initjQuery(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template

References $tpl.

◆ isForbidden()

ilTaggingGUI::isForbidden ( string  $a_tag)

Definition at line 211 of file class.ilTaggingGUI.php.

211 : bool
212 {
213 foreach ($this->forbidden as $f) {
214 if (is_int(strpos(strtolower(
215 str_replace(array("+", "§", '"', "'", "*", "%", "&", "/", "\\", "(", ")", "=", ":", ";", ":", "-", "_", "\$",
216 "£" . "!" . "¨", "^", "`", "@", "<", ">"), "", $a_tag)
217 ), $f))) {
218 return true;
219 }
220 }
221 return false;
222 }

References Vendor\Package\$f.

◆ saveInput()

ilTaggingGUI::saveInput ( )

Definition at line 182 of file class.ilTaggingGUI.php.

182 : void
183 {
186 $body = $request->getParsedBody();
187
188 $itags = $this->getTagsFromInput($body[$this->getInputFieldName()]);
189 $tags = array();
190 foreach ($itags as $itag) {
191 $itag = trim($itag);
192 if (!in_array($itag, $tags) && $itag != "") {
193 if (!$this->isForbidden($itag)) {
194 $tags[] = $itag;
195 }
196 }
197 }
198
200 $this->obj_id,
201 $this->obj_type,
202 $this->sub_obj_id,
203 $this->sub_obj_type,
204 $this->getUserId(),
205 $tags
206 );
207 $this->main_tpl->setOnScreenMessage('success', $lng->txt('msg_obj_modified'));
208 }
RequestInterface $request
getTagsFromInput(string $input)
static writeTagsForUserAndObject(int $a_obj_id, string $a_obj_type, int $a_sub_obj_id, string $a_sub_obj_type, int $a_user_id, array $a_tags)

References $lng, and ilTagging\writeTagsForUserAndObject().

+ Here is the call graph for this function:

◆ saveJS()

ilTaggingGUI::saveJS ( )

Save JS.

Definition at line 381 of file class.ilTaggingGUI.php.

381 : void
382 {
384 $body = $request->getParsedBody();
385 $itags = $this->getTagsFromInput($body["tags"]);
386 $tags = array();
387 foreach ($itags as $itag) {
388 $itag = trim($itag);
389 if (!in_array($itag, $tags) && $itag != "") {
390 if (!$this->isForbidden($itag)) {
391 $tags[] = $itag;
392 }
393 }
394 }
395
397 $this->obj_id,
398 $this->obj_type,
399 $this->sub_obj_id,
400 $this->sub_obj_type,
401 $this->getUserId(),
402 $tags
403 );
404
405 $this->mess = "mod";
406
407 $this->getHTML();
408 }

References ilTagging\writeTagsForUserAndObject().

+ Here is the call graph for this function:

◆ setInputFieldName()

ilTaggingGUI::setInputFieldName ( string  $a_inputfieldname)

Definition at line 137 of file class.ilTaggingGUI.php.

137 : void
138 {
139 $this->inputfieldname = $a_inputfieldname;
140 }

◆ setObject()

ilTaggingGUI::setObject ( int  $a_obj_id,
string  $a_obj_type,
int  $a_sub_obj_id = 0,
string  $a_sub_obj_type = "" 
)

Set Object.

Parameters
int$a_obj_idObject ID
string$a_obj_typeObject Type
int$a_sub_obj_idSub-object ID
string$a_sub_obj_typeSub-object Type

Definition at line 91 of file class.ilTaggingGUI.php.

96 : void {
98
99 $this->obj_id = $a_obj_id;
100 $this->obj_type = $a_obj_type;
101 $this->sub_obj_id = $a_sub_obj_id;
102 $this->sub_obj_type = $a_sub_obj_type;
103
104 $this->setSaveCmd("saveTags");
105 $this->setUserId($ilUser->getId());
106 $this->setInputFieldName("il_tags");
107
108 $tags_set = new ilSetting("tags");
109 $forbidden = $tags_set->get("forbidden_tags");
110 if ($forbidden != "") {
111 $this->forbidden = unserialize((string) $forbidden, ['allowed_classes' => false]);
112 } else {
113 $this->forbidden = array();
114 }
115 }
setSaveCmd(string $a_savecmd)
setInputFieldName(string $a_inputfieldname)
setUserId(int $a_userid)
$ilUser
Definition: imgupload.php:34

◆ setSaveCmd()

ilTaggingGUI::setSaveCmd ( string  $a_savecmd)

Definition at line 127 of file class.ilTaggingGUI.php.

127 : void
128 {
129 $this->savecmd = $a_savecmd;
130 }

◆ setUserId()

ilTaggingGUI::setUserId ( int  $a_userid)

Definition at line 117 of file class.ilTaggingGUI.php.

117 : void
118 {
119 $this->userid = $a_userid;
120 }

Field Documentation

◆ $ctrl

ilCtrl ilTaggingGUI::$ctrl
protected

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

Referenced by executeCommand().

◆ $forbidden

array ilTaggingGUI::$forbidden = []
protected

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

◆ $inputfieldname

string ilTaggingGUI::$inputfieldname = ""
protected

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

◆ $lng

ilLanguage ilTaggingGUI::$lng
protected

Definition at line 32 of file class.ilTaggingGUI.php.

◆ $main_tpl

ilGlobalTemplateInterface ilTaggingGUI::$main_tpl
private

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

◆ $mess

string ilTaggingGUI::$mess = ""
protected

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

◆ $obj_id

int ilTaggingGUI::$obj_id = 0
protected

Definition at line 34 of file class.ilTaggingGUI.php.

◆ $obj_type

string ilTaggingGUI::$obj_type = ""
protected

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

◆ $request

RequestInterface ilTaggingGUI::$request
protected

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

◆ $requested_mess

string ilTaggingGUI::$requested_mess = ""
protected

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

◆ $savecmd

string ilTaggingGUI::$savecmd = ""
protected

Definition at line 40 of file class.ilTaggingGUI.php.

◆ $sub_obj_id

int ilTaggingGUI::$sub_obj_id = 0
protected

Definition at line 36 of file class.ilTaggingGUI.php.

◆ $sub_obj_type

string ilTaggingGUI::$sub_obj_type
protected

Definition at line 37 of file class.ilTaggingGUI.php.

◆ $ui

ILIAS DI UIServices ilTaggingGUI::$ui
protected

Definition at line 33 of file class.ilTaggingGUI.php.

◆ $user

ilObjUser ilTaggingGUI::$user
protected

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

◆ $userid

int ilTaggingGUI::$userid = 0
protected

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


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