ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilTaggingGUI Class Reference

Class ilTaggingGUI. More...

+ Collaboration diagram for ilTaggingGUI:

Public Member Functions

 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)
 Init javascript. More...
 
static getListTagsJSCall ($a_hash, $a_update_code=null)
 Get tagging js call. More...
 

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.

Member Function Documentation

◆ executeCommand()

ilTaggingGUI::executeCommand ( )

Execute command.

Parameters

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

References $cmd, and $ilCtrl.

25  {
26  global $ilCtrl;
27 
28  $next_class = $ilCtrl->getNextClass();
29  switch($next_class)
30  {
31  default:
32  $cmd = $ilCtrl->getCmd();
33  $this->$cmd();
34  break;
35  }
36  }
$cmd
Definition: sahs_server.php:35
global $ilCtrl
Definition: ilias.php:18

◆ getAllUserTagsForObjectHTML()

ilTaggingGUI::getAllUserTagsForObjectHTML ( )

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

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

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

204  {
205  global $lng, $ilCtrl;
206 
207  $ttpl = new ilTemplate("tpl.tag_cloud.html", true, true, "Services/Tagging");
208  $tags = ilTagging::getTagsForObject($this->obj_id, $this->obj_type,
209  $this->sub_obj_id, $this->sub_obj_type);
210 
211  $max = 1;
212  foreach ($tags as $tag)
213  {
214  $max = max($max, $tag["cnt"]);
215  }
216  reset($tags);
217  foreach ($tags as $tag)
218  {
219  if (!$this->isForbidden($tag["tag"]))
220  {
221  $ttpl->setCurrentBlock("unlinked_tag");
222  $ttpl->setVariable("REL_CLASS",
223  ilTagging::getRelevanceClass($tag["cnt"], $max));
224  $ttpl->setVariable("TAG_TITLE", $tag["tag"]);
225  $ttpl->parseCurrentBlock();
226  }
227  }
228 
229  return $ttpl->get();
230  }
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.
isForbidden($a_tag)
Check whether a tag is forbiddens.
global $ilCtrl
Definition: ilias.php:18
special template class to simplify handling of ITX/PEAR
static getRelevanceClass($cnt, $max)
Get style class for tag relevance.
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:

◆ getHTML()

ilTaggingGUI::getHTML ( )

Get HTML.

Parameters

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

References $_GET, $ilCtrl, $img, $lng, $tpl, ilObject\_getIcon(), ilTagging\_getListTagsForObjects(), ilObject\_lookupTitle(), array, exit, ilTagging\getTagsForUserAndObject(), getUserId(), ilUtil\img(), and ilUtil\prepareFormOutput().

Referenced by saveJS().

286  {
287  global $lng, $ilCtrl;
288 
289  $lng->loadLanguageModule("tagging");
290  $tpl = new ilTemplate("tpl.edit_tags.html", true, true, "Services/Tagging");
291  $tpl->setVariable("TXT_TAGS", $lng->txt("tagging_tags"));
292 
293  switch($_GET["mess"] != "" ? $_GET["mess"] : $this->mess)
294  {
295  case "mod":
296  $mtype = "success";
297  $mtxt = $lng->txt("msg_obj_modified");
298  break;
299  }
300  if ($mtxt != "")
301  {
302  $tpl->setVariable("MESS", $tpl->getMessageHTML($mtxt, $mtype));
303  }
304  else
305  {
306  $tpl->setVariable("MESS", "");
307  }
308 
309  $img = ilUtil::img(ilObject::_getIcon($this->obj_id, "tiny"));
310  $tpl->setVariable("TXT_OBJ_TITLE", $img." ".ilObject::_lookupTitle($this->obj_id));
311  $tags = ilTagging::getTagsForUserAndObject($this->obj_id, $this->obj_type,
312  $this->sub_obj_id, $this->sub_obj_type, $this->getUserId());
313  $tpl->setVariable("VAL_TAGS",
314  ilUtil::prepareFormOutput(implode($tags, ", ")));
315  $tpl->setVariable("TXT_SAVE", $lng->txt("save"));
316  $tpl->setVariable("TXT_COMMA_SEPARATED", $lng->txt("comma_separated"));
317  $tpl->setVariable("CMD_SAVE", "saveJS");
318 
319  $os = "ilTagging.cmdAjaxForm(event, '".
320  $ilCtrl->getFormActionByClass("iltagginggui", "", "", true).
321  "');";
322  $tpl->setVariable("ON_SUBMIT", $os);
323 
324  $tags_set = new ilSetting("tags");
325  if($tags_set->get("enable_all_users"))
326  {
327  $tpl->setVariable("TAGS_TITLE", $lng->txt("tagging_my_tags"));
328 
329  $all_obj_tags = ilTagging::_getListTagsForObjects(array($this->obj_id));
330  $all_obj_tags = $all_obj_tags[$this->obj_id];
331  if(is_array($all_obj_tags) &&
332  sizeof($all_obj_tags) != sizeof($tags))
333  {
334  $tpl->setVariable("TITLE_OTHER", $lng->txt("tagging_other_users"));
335  $tpl->setCurrentBlock("tag_other_bl");
336  foreach($all_obj_tags as $tag => $is_owner)
337  {
338  if(!$is_owner)
339  {
340  $tpl->setVariable("OTHER_TAG", $tag);
341  $tpl->parseCurrentBlock();
342  }
343  }
344 
345  }
346  }
347 
348  echo $tpl->get();
349  exit;
350  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
ILIAS Setting Class.
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
$_GET["client_id"]
static _lookupTitle($a_id)
lookup object title
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.
getUserId()
Get User ID.
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
special template class to simplify handling of ITX/PEAR
Create styles array
The data for the language used.
static img($a_src, $a_alt="", $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
global $lng
Definition: privfeed.php:17
static _getListTagsForObjects(array $a_obj_ids, $a_user_id=null)
Get tags for given object ids.
+ 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 128 of file class.ilTaggingGUI.php.

Referenced by getTaggingInputHTML(), and saveInput().

129  {
130  return $this->inputfieldname;
131  }
+ 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 263 of file class.ilTaggingGUI.php.

References $tpl.

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

264  {
265  global $tpl;
266 
267  if ($a_update_code === null)
268  {
269  $a_update_code = "null";
270  }
271  else
272  {
273  $a_update_code = "'".$a_update_code."'";
274  }
275 
276  return "ilTagging.listTags(event, '".$a_hash."', ".$a_update_code.");";
277  }
global $tpl
Definition: ilias.php:8
+ Here is the caller graph for this function:

◆ getSaveCmd()

ilTaggingGUI::getSaveCmd ( )

Get Save Command.

Returns
string Save Command

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

109  {
110  return $this->savecmd;
111  }

◆ getTaggingInputHTML()

ilTaggingGUI::getTaggingInputHTML ( )

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

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

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

137  {
138  global $lng, $ilCtrl;
139 
140  $ttpl = new ilTemplate("tpl.tags_input.html", true, true, "Services/Tagging");
141  $tags = ilTagging::getTagsForUserAndObject($this->obj_id, $this->obj_type,
142  $this->sub_obj_id, $this->sub_obj_type, $this->getUserId());
143  $ttpl->setVariable("VAL_TAGS",
144  ilUtil::prepareFormOutput(implode($tags, ", ")));
145  $ttpl->setVariable("TXT_SAVE", $lng->txt("save"));
146  $ttpl->setVariable("TXT_COMMA_SEPARATED", $lng->txt("comma_separated"));
147  $ttpl->setVariable("CMD_SAVE", $this->savecmd);
148  $ttpl->setVariable("NAME_TAGS", $this->getInputFieldName());
149 
150  return $ttpl->get();
151  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
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.
getUserId()
Get User ID.
getInputFieldName()
Get Input Field Name.
global $ilCtrl
Definition: ilias.php:18
special template class to simplify handling of ITX/PEAR
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:

◆ getUserId()

ilTaggingGUI::getUserId ( )

Get User ID.

Returns
int User ID

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

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

89  {
90  return $this->userid;
91  }
+ Here is the caller graph for this function:

◆ initJavascript()

static ilTaggingGUI::initJavascript (   $a_ajax_url)
static

Init javascript.

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

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

Referenced by ilObjectListGUI\prepareJsLinks().

241  {
242  global $tpl, $lng;
243 
244  $lng->loadLanguageModule("tagging");
245  $lng->toJs("tagging_tags");
246 
247  include_once("./Services/YUI/classes/class.ilYuiUtil.php");
249  include_once("./Services/jQuery/classes/class.iljQueryUtil.php");
251  $tpl->addJavascript("./Services/Tagging/js/ilTagging.js");
252 
253  $tpl->addOnLoadCode("ilTagging.setAjaxUrl('".$a_ajax_url."');");
254  }
global $tpl
Definition: ilias.php:8
static initPanel($a_resize=false)
Init yui panel.
global $lng
Definition: privfeed.php:17
static initjQuery($a_tpl=null)
Init jQuery.
+ 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 186 of file class.ilTaggingGUI.php.

References array.

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

187  {
188  foreach ($this->forbidden as $f)
189  {
190  if (is_int(strpos(strtolower(
191  str_replace(array("+", "§", '"', "'", "*", "%", "&", "/", "\\", "(", ")", "=", ":", ";", ":", "-", "_", "\$",
192  "£". "!". "¨", "^", "`", "@", "<", ">"), "", $a_tag)), $f)))
193  {
194  return true;
195  }
196  }
197  return false;
198  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ saveInput()

ilTaggingGUI::saveInput ( )

Save Input.

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

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

157  {
158  global $lng;
159 
160  $input = ilUtil::stripSlashes($_POST[$this->getInputFieldName()]);
161  $input = str_replace("\r", "\n", $input);
162  $input = str_replace("\n\n", "\n", $input);
163  $input = str_replace("\n", ",", $input);
164  $itags = explode(",", $input);
165  $tags = array();
166  foreach($itags as $itag)
167  {
168  $itag = trim($itag);
169  if (!in_array($itag, $tags) && $itag != "")
170  {
171  if (!$this->isForbidden($itag))
172  {
173  $tags[] = $itag;
174  }
175  }
176  }
177 
178  ilTagging::writeTagsForUserAndObject($this->obj_id, $this->obj_type,
179  $this->sub_obj_id, $this->sub_obj_type, $this->getUserId(), $tags);
180  ilUtil::sendSuccess($lng->txt('msg_obj_modified'));
181  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
isForbidden($a_tag)
Check whether a tag is forbiddens.
getUserId()
Get User ID.
getInputFieldName()
Get Input Field Name.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
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.
$_POST["username"]
+ Here is the call graph for this function:

◆ saveJS()

ilTaggingGUI::saveJS ( )

Save JS.

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

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

356  {
357  $input = ilUtil::stripSlashes($_POST["tags"]);
358  $input = str_replace("\r", "\n", $input);
359  $input = str_replace("\n\n", "\n", $input);
360  $input = str_replace("\n", ",", $input);
361  $itags = explode(",", $input);
362  $tags = array();
363  foreach($itags as $itag)
364  {
365  $itag = trim($itag);
366  if (!in_array($itag, $tags) && $itag != "")
367  {
368  if (!$this->isForbidden($itag))
369  {
370  $tags[] = $itag;
371  }
372  }
373  }
374 
375  ilTagging::writeTagsForUserAndObject($this->obj_id, $this->obj_type,
376  $this->sub_obj_id, $this->sub_obj_type, $this->getUserId(), $tags);
377 
378  $this->mess = "mod";
379 
380  $this->getHTML();
381  }
isForbidden($a_tag)
Check whether a tag is forbiddens.
getUserId()
Get User ID.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
getHTML()
Get HTML.
Create styles array
The data for the language used.
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.
$_POST["username"]
+ 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 118 of file class.ilTaggingGUI.php.

Referenced by setObject().

119  {
120  $this->inputfieldname = $a_inputfieldname;
121  }
+ 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 47 of file class.ilTaggingGUI.php.

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

48  {
49  global $ilUser;
50 
51  $this->obj_id = $a_obj_id;
52  $this->obj_type = $a_obj_type;
53  $this->sub_obj_id = $a_sub_obj_id;
54  $this->sub_obj_type = $a_sub_obj_type;
55 
56  $this->setSaveCmd("saveTags");
57  $this->setUserId($ilUser->getId());
58  $this->setInputFieldName("il_tags");
59 
60  $tags_set = new ilSetting("tags");
61  $forbidden = $tags_set->get("forbidden_tags");
62  if ($forbidden != "")
63  {
64  $this->forbidden = unserialize($forbidden);
65  }
66  else
67  {
68  $this->forbidden = array();
69  }
70 
71  }
ILIAS Setting Class.
setSaveCmd($a_savecmd)
Set Save Command.
setUserId($a_userid)
Set User ID.
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
setInputFieldName($a_inputfieldname)
Set Input Field Name.
+ Here is the call graph for this function:

◆ setSaveCmd()

ilTaggingGUI::setSaveCmd (   $a_savecmd)

Set Save Command.

Parameters
string$a_savecmdSave Command

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

Referenced by setObject().

99  {
100  $this->savecmd = $a_savecmd;
101  }
+ Here is the caller graph for this function:

◆ setUserId()

ilTaggingGUI::setUserId (   $a_userid)

Set User ID.

Parameters
int$a_useridUser ID

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

Referenced by setObject().

79  {
80  $this->userid = $a_userid;
81  }
+ Here is the caller graph for this function:

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