ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilTaggingGUI Class Reference

Class ilTaggingGUI. More...

+ Collaboration diagram for ilTaggingGUI:

Public Member Functions

 __construct ()
 Constructor. More...
 
 executeCommand ()
 Execute command. More...
 
 setObject ($a_obj_id, $a_obj_type, $a_sub_obj_id=0, $a_sub_obj_type="")
 Set Object. More...
 
 setUserId ($a_userid)
 Set User ID. More...
 
 getUserId ()
 Get User ID. More...
 
 setSaveCmd ($a_savecmd)
 Set Save Command. More...
 
 getSaveCmd ()
 Get Save Command. More...
 
 setInputFieldName ($a_inputfieldname)
 Set Input Field Name. More...
 
 getInputFieldName ()
 Get Input Field Name. More...
 
 getTaggingInputHTML ()
 Get Input HTML for Tagging of an object (and a user) More...
 
 saveInput ()
 Save Input. More...
 
 isForbidden ($a_tag)
 Check whether a tag is forbiddens. More...
 
 getAllUserTagsForObjectHTML ()
 Get Input HTML for Tagging of an object (and a user) More...
 
 getHTML ()
 Get HTML. More...
 
 saveJS ()
 Save JS. More...
 

Static Public Member Functions

static initJavascript ($a_ajax_url, ilGlobalTemplateInterface $a_main_tpl=null)
 Init javascript. More...
 
static getListTagsJSCall ($a_hash, $a_update_code=null)
 Get tagging js call. More...
 

Protected Attributes

 $ctrl
 
 $user
 
 $lng
 
 $ui
 

Detailed Description

Class ilTaggingGUI.

User interface class for tagging engine.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilTaggingGUI::__construct ( )

Constructor.

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

41 {
42 global $DIC;
43
44 $this->ctrl = $DIC->ctrl();
45 $this->user = $DIC->user();
46 $this->lng = $DIC->language();
47 $this->ui = $DIC->ui();
48 }
user()
Definition: user.php:4
ui()
Definition: ui.php:5
$DIC
Definition: xapitoken.php:46

References $DIC, ui(), and user().

+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilTaggingGUI::executeCommand ( )

Execute command.

Parameters

return

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

58 {
60
61 $next_class = $ilCtrl->getNextClass();
62 switch ($next_class) {
63 default:
64 $cmd = $ilCtrl->getCmd();
65 $this->$cmd();
66 break;
67 }
68 }
global $ilCtrl
Definition: ilias.php:18

References $ctrl, and $ilCtrl.

◆ getAllUserTagsForObjectHTML()

ilTaggingGUI::getAllUserTagsForObjectHTML ( )

Get Input HTML for Tagging of an object (and a user)

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

243 {
246
247 $ttpl = new ilTemplate("tpl.tag_cloud.html", true, true, "Services/Tagging");
249 $this->obj_id,
250 $this->obj_type,
251 $this->sub_obj_id,
252 $this->sub_obj_type
253 );
254
255 $max = 1;
256 foreach ($tags as $tag) {
257 $max = max($max, $tag["cnt"]);
258 }
259 reset($tags);
260 foreach ($tags as $tag) {
261 if (!$this->isForbidden($tag["tag"])) {
262 $ttpl->setCurrentBlock("unlinked_tag");
263 $ttpl->setVariable(
264 "REL_CLASS",
265 ilTagging::getRelevanceClass($tag["cnt"], $max)
266 );
267 $ttpl->setVariable("TAG_TITLE", $tag["tag"]);
268 $ttpl->parseCurrentBlock();
269 }
270 }
271
272 return $ttpl->get();
273 }
isForbidden($a_tag)
Check whether a tag is forbiddens.
static getRelevanceClass($cnt, $max)
Get style class for tag relevance.
static getTagsForObject( $a_obj_id, $a_obj_type, $a_sub_obj_id, $a_sub_obj_type, $a_only_online=true)
Get tags for an object.
special template class to simplify handling of ITX/PEAR

References $ctrl, $ilCtrl, $lng, ilTagging\getRelevanceClass(), ilTagging\getTagsForObject(), and isForbidden().

+ Here is the call graph for this function:

◆ getHTML()

ilTaggingGUI::getHTML ( )

Get HTML.

Parameters

return

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

336 {
339 $ui = $this->ui;
340
341 $lng->loadLanguageModule("tagging");
342 $tpl = new ilTemplate("tpl.edit_tags.html", true, true, "Services/Tagging");
343 $tpl->setVariable("TXT_TAGS", $lng->txt("tagging_tags"));
344
345 switch ($_GET["mess"] != "" ? $_GET["mess"] : $this->mess) {
346 case "mod":
347 $mtype = "success";
348 $mtxt = $lng->txt("msg_obj_modified");
349 break;
350 }
351 if ($mtxt != "") {
352 $tpl->setVariable("MESS", ilUtil::getSystemMessageHTML($mtxt, $mtype));
353 } else {
354 $tpl->setVariable("MESS", "");
355 }
356
357 $title = ilObject::_lookupTitle($this->obj_id);
358 $icon = $ui->factory()->symbol()->icon()->custom(
359 ilObject::_getIcon($this->obj_id),
360 $title,
361 "medium"
362 );
363 $tpl->setVariable("ICON", $ui->renderer()->render($icon));
364 $tpl->setVariable("TXT_OBJ_TITLE", ilObject::_lookupTitle($this->obj_id));
366 $this->obj_id,
367 $this->obj_type,
368 $this->sub_obj_id,
369 $this->sub_obj_type,
370 $this->getUserId()
371 );
372 $tpl->setVariable(
373 "VAL_TAGS",
374 ilUtil::prepareFormOutput(implode(", ", $tags))
375 );
376 $tpl->setVariable("TXT_SAVE", $lng->txt("save"));
377 $tpl->setVariable("TXT_COMMA_SEPARATED", $lng->txt("comma_separated"));
378 $tpl->setVariable("CMD_SAVE", "saveJS");
379
380 $os = "ilTagging.cmdAjaxForm(event, '" .
381 $ilCtrl->getFormActionByClass("iltagginggui", "", "", true) .
382 "');";
383 $tpl->setVariable("ON_SUBMIT", $os);
384
385 $tags_set = new ilSetting("tags");
386 if ($tags_set->get("enable_all_users")) {
387 $tpl->setVariable("TAGS_TITLE", $lng->txt("tagging_my_tags"));
388
389 $all_obj_tags = ilTagging::_getListTagsForObjects(array($this->obj_id));
390 $all_obj_tags = $all_obj_tags[$this->obj_id];
391 if (is_array($all_obj_tags) &&
392 sizeof($all_obj_tags) != sizeof($tags)) {
393 $tpl->setVariable("TITLE_OTHER", $lng->txt("tagging_other_users"));
394 $tpl->setCurrentBlock("tag_other_bl");
395 foreach ($all_obj_tags as $tag => $is_owner) {
396 if (!$is_owner) {
397 $tpl->setVariable("OTHER_TAG", $tag);
398 $tpl->parseCurrentBlock();
399 }
400 }
401 }
402 }
403
404 echo $tpl->get();
405 exit;
406 }
$_GET["client_id"]
static _lookupTitle($a_id)
lookup object title
ILIAS Setting Class.
getUserId()
Get User ID.
static getTagsForUserAndObject( $a_obj_id, $a_obj_type, $a_sub_obj_id, $a_sub_obj_type, $a_user_id)
Get tags for a user and an object.
static _getListTagsForObjects(array $a_obj_ids, $a_user_id=null)
Get tags for given object ids.
static getSystemMessageHTML($a_txt, $a_type="info")
Get HTML for a system message.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
exit
Definition: login.php:29
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl

References $_GET, $ctrl, $ilCtrl, $lng, $tpl, $ui, ilTagging\_getListTagsForObjects(), ilObject\_lookupTitle(), exit, ilUtil\getSystemMessageHTML(), ilTagging\getTagsForUserAndObject(), getUserId(), and ilUtil\prepareFormOutput().

Referenced by saveJS().

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

◆ getInputFieldName()

ilTaggingGUI::getInputFieldName ( )

Get Input Field Name.

Returns
string Input Field Name

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

157 {
158 return $this->inputfieldname;
159 }

Referenced by getTaggingInputHTML(), and saveInput().

+ Here is the caller graph for this function:

◆ getListTagsJSCall()

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

Get tagging js call.

Parameters
string$a_hash
string$a_update_code
Returns
string

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

315 {
316 global $DIC;
317
318 $tpl = $DIC["tpl"];
319
320 if ($a_update_code === null) {
321 $a_update_code = "null";
322 } else {
323 $a_update_code = "'" . $a_update_code . "'";
324 }
325
326 return "ilTagging.listTags(event, '" . $a_hash . "', " . $a_update_code . ");";
327 }

References $DIC, and $tpl.

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

+ Here is the caller graph for this function:

◆ getSaveCmd()

ilTaggingGUI::getSaveCmd ( )

Get Save Command.

Returns
string Save Command

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

137 {
138 return $this->savecmd;
139 }

◆ getTaggingInputHTML()

ilTaggingGUI::getTaggingInputHTML ( )

Get Input HTML for Tagging of an object (and a user)

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

165 {
168
169 $ttpl = new ilTemplate("tpl.tags_input.html", true, true, "Services/Tagging");
171 $this->obj_id,
172 $this->obj_type,
173 $this->sub_obj_id,
174 $this->sub_obj_type,
175 $this->getUserId()
176 );
177 $ttpl->setVariable(
178 "VAL_TAGS",
179 ilUtil::prepareFormOutput(implode(", ", $tags))
180 );
181 $ttpl->setVariable("TAG_LABEL", $lng->txt("tagging_my_tags"));
182 $ttpl->setVariable("TXT_SAVE", $lng->txt("save"));
183 $ttpl->setVariable("TXT_COMMA_SEPARATED", $lng->txt("comma_separated"));
184 $ttpl->setVariable("CMD_SAVE", $this->savecmd);
185 $ttpl->setVariable("NAME_TAGS", $this->getInputFieldName());
186
187 return $ttpl->get();
188 }
getInputFieldName()
Get Input Field Name.

References $ctrl, $ilCtrl, $lng, getInputFieldName(), ilTagging\getTagsForUserAndObject(), getUserId(), and ilUtil\prepareFormOutput().

+ Here is the call graph for this function:

◆ getUserId()

ilTaggingGUI::getUserId ( )

Get User ID.

Returns
int User ID

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

117 {
118 return $this->userid;
119 }

Referenced by getHTML(), getTaggingInputHTML(), saveInput(), and saveJS().

+ Here is the caller graph for this function:

◆ initJavascript()

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

Init javascript.

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

284 {
285 global $DIC;
286
287 if ($a_main_tpl != null) {
288 $tpl = $a_main_tpl;
289 } else {
290 $tpl = $DIC["tpl"];
291 }
292
293 $lng = $DIC->language();
294
295 $lng->loadLanguageModule("tagging");
296 $lng->toJs("tagging_tags", $tpl);
297
298 include_once("./Services/YUI/classes/class.ilYuiUtil.php");
300 include_once("./Services/jQuery/classes/class.iljQueryUtil.php");
302 $tpl->addJavascript("./Services/Tagging/js/ilTagging.js");
303
304 $tpl->addOnLoadCode("ilTagging.setAjaxUrl('" . $a_ajax_url . "');");
305 }
static initPanel($a_resize=false, ilGlobalTemplateInterface $a_main_tpl=null)
Init yui panel.
static initjQuery(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template

References $DIC, $lng, $tpl, iljQueryUtil\initjQuery(), and ilYuiUtil\initPanel().

Referenced by ilObjectListGUI\prepareJsLinks().

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

◆ isForbidden()

ilTaggingGUI::isForbidden (   $a_tag)

Check whether a tag is forbiddens.

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

227 {
228 foreach ($this->forbidden as $f) {
229 if (is_int(strpos(strtolower(
230 str_replace(array("+", "§", '"', "'", "*", "%", "&", "/", "\\", "(", ")", "=", ":", ";", ":", "-", "_", "\$",
231 "£" . "!" . "¨", "^", "`", "@", "<", ">"), "", $a_tag)
232 ), $f))) {
233 return true;
234 }
235 }
236 return false;
237 }

References Vendor\Package\$f.

Referenced by getAllUserTagsForObjectHTML(), saveInput(), and saveJS().

+ Here is the caller graph for this function:

◆ saveInput()

ilTaggingGUI::saveInput ( )

Save Input.

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

194 {
196
198 $input = str_replace("\r", "\n", $input);
199 $input = str_replace("\n\n", "\n", $input);
200 $input = str_replace("\n", ",", $input);
201 $itags = explode(",", $input);
202 $tags = array();
203 foreach ($itags as $itag) {
204 $itag = trim($itag);
205 if (!in_array($itag, $tags) && $itag != "") {
206 if (!$this->isForbidden($itag)) {
207 $tags[] = $itag;
208 }
209 }
210 }
211
213 $this->obj_id,
214 $this->obj_type,
215 $this->sub_obj_id,
216 $this->sub_obj_type,
217 $this->getUserId(),
218 $tags
219 );
220 ilUtil::sendSuccess($lng->txt('msg_obj_modified'));
221 }
$_POST["username"]
static writeTagsForUserAndObject( $a_obj_id, $a_obj_type, $a_sub_obj_id, $a_sub_obj_type, $a_user_id, $a_tags)
Write tags for a user and an object.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled

References $_POST, $lng, getInputFieldName(), getUserId(), isForbidden(), ilUtil\stripSlashes(), and ilTagging\writeTagsForUserAndObject().

+ Here is the call graph for this function:

◆ saveJS()

ilTaggingGUI::saveJS ( )

Save JS.

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

412 {
413 $input = ilUtil::stripSlashes($_POST["tags"]);
414 $input = str_replace("\r", "\n", $input);
415 $input = str_replace("\n\n", "\n", $input);
416 $input = str_replace("\n", ",", $input);
417 $itags = explode(",", $input);
418 $tags = array();
419 foreach ($itags as $itag) {
420 $itag = trim($itag);
421 if (!in_array($itag, $tags) && $itag != "") {
422 if (!$this->isForbidden($itag)) {
423 $tags[] = $itag;
424 }
425 }
426 }
427
429 $this->obj_id,
430 $this->obj_type,
431 $this->sub_obj_id,
432 $this->sub_obj_type,
433 $this->getUserId(),
434 $tags
435 );
436
437 $this->mess = "mod";
438
439 $this->getHTML();
440 }

References $_POST, getHTML(), getUserId(), isForbidden(), ilUtil\stripSlashes(), and ilTagging\writeTagsForUserAndObject().

+ Here is the call graph for this function:

◆ setInputFieldName()

ilTaggingGUI::setInputFieldName (   $a_inputfieldname)

Set Input Field Name.

Parameters
string$a_inputfieldnameInput Field Name

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

147 {
148 $this->inputfieldname = $a_inputfieldname;
149 }

Referenced by setObject().

+ Here is the caller graph for this function:

◆ setObject()

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

Set Object.

Parameters
int$a_obj_idObject ID
string$a_obj_typeObject Type
int$a_sub_obj_idSubobject ID
string$a_sub_obj_typeSubobject Type

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

80 {
82
83 $this->obj_id = $a_obj_id;
84 $this->obj_type = $a_obj_type;
85 $this->sub_obj_id = $a_sub_obj_id;
86 $this->sub_obj_type = $a_sub_obj_type;
87
88 $this->setSaveCmd("saveTags");
89 $this->setUserId($ilUser->getId());
90 $this->setInputFieldName("il_tags");
91
92 $tags_set = new ilSetting("tags");
93 $forbidden = $tags_set->get("forbidden_tags");
94 if ($forbidden != "") {
95 $this->forbidden = unserialize($forbidden);
96 } else {
97 $this->forbidden = array();
98 }
99 }
setSaveCmd($a_savecmd)
Set Save Command.
setInputFieldName($a_inputfieldname)
Set Input Field Name.
setUserId($a_userid)
Set User ID.
$ilUser
Definition: imgupload.php:18

References $ilUser, $user, setInputFieldName(), setSaveCmd(), and setUserId().

+ Here is the call graph for this function:

◆ setSaveCmd()

ilTaggingGUI::setSaveCmd (   $a_savecmd)

Set Save Command.

Parameters
string$a_savecmdSave Command

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

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

Referenced by setObject().

+ Here is the caller graph for this function:

◆ setUserId()

ilTaggingGUI::setUserId (   $a_userid)

Set User ID.

Parameters
int$a_useridUser ID

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

107 {
108 $this->userid = $a_userid;
109 }

Referenced by setObject().

+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilTaggingGUI::$ctrl
protected

◆ $lng

ilTaggingGUI::$lng
protected

◆ $ui

ilTaggingGUI::$ui
protected

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

Referenced by getHTML().

◆ $user

ilTaggingGUI::$user
protected

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

Referenced by setObject().


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