ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
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...
 
 initJavascript ($a_ajax_url)
 Init javascript. More...
 
 getListTagsJSCall ($a_hash, $a_update_code=null)
 Get tagging js call. More...
 
 getHTML ()
 Get HTML. More...
 
 saveJS ()
 Save JS. 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 200 of file class.ilTaggingGUI.php.

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

201  {
202  global $lng, $ilCtrl;
203 
204  $ttpl = new ilTemplate("tpl.tag_cloud.html", true, true, "Services/Tagging");
205  $tags = ilTagging::getTagsForObject($this->obj_id, $this->obj_type,
206  $this->sub_obj_id, $this->sub_obj_type);
207 
208  $max = 1;
209  foreach ($tags as $tag)
210  {
211  $max = max($max, $tag["cnt"]);
212  }
213  reset($tags);
214  foreach ($tags as $tag)
215  {
216  if (!$this->isForbidden($tag["tag"]))
217  {
218  $ttpl->setCurrentBlock("unlinked_tag");
219  $ttpl->setVariable("REL_CLASS",
220  ilTagging::getRelevanceClass($tag["cnt"], $max));
221  $ttpl->setVariable("TAG_TITLE", $tag["tag"]);
222  $ttpl->parseCurrentBlock();
223  }
224  }
225 
226  return $ttpl->get();
227  }
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:40
+ Here is the call graph for this function:

◆ getHTML()

ilTaggingGUI::getHTML ( )

Get HTML.

Parameters

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

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

Referenced by saveJS().

280  {
281  global $lng, $ilCtrl;
282 
283  $lng->loadLanguageModule("tagging");
284  $tpl = new ilTemplate("tpl.edit_tags.html", true, true, "Services/Tagging");
285  $tpl->setVariable("TXT_TAGS", $lng->txt("tagging_tags"));
286 
287  switch($_GET["mess"] != "" ? $_GET["mess"] : $this->mess)
288  {
289  case "mod":
290  $mtype = "success";
291  $mtxt = $lng->txt("msg_obj_modified");
292  break;
293  }
294  if ($mtxt != "")
295  {
296  $tpl->setVariable("MESS", $tpl->getMessageHTML($mtxt, $mtype));
297  }
298  else
299  {
300  $tpl->setVariable("MESS", "");
301  }
302 
303  $img = ilUtil::img(ilObject::_getIcon($this->obj_id, "tiny"));
304  $tpl->setVariable("TXT_OBJ_TITLE", $img." ".ilObject::_lookupTitle($this->obj_id));
305  $tags = ilTagging::getTagsForUserAndObject($this->obj_id, $this->obj_type,
306  $this->sub_obj_id, $this->sub_obj_type, $this->getUserId());
307  $tpl->setVariable("VAL_TAGS",
308  ilUtil::prepareFormOutput(implode($tags, " ")));
309  $tpl->setVariable("TXT_SAVE", $lng->txt("save"));
310  $tpl->setVariable("CMD_SAVE", "saveJS");
311 
312  $os = "ilTagging.cmdAjaxForm(event, '".
313  $ilCtrl->getFormActionByClass("iltagginggui", "", "", true).
314  "');";
315  $tpl->setVariable("ON_SUBMIT", $os);
316 
317  $tags_set = new ilSetting("tags");
318  if($tags_set->get("enable_all_users"))
319  {
320  $tpl->setVariable("TAGS_TITLE", $lng->txt("tagging_my_tags"));
321 
322  $all_obj_tags = ilTagging::_getListTagsForObjects(array($this->obj_id));
323  $all_obj_tags = $all_obj_tags[$this->obj_id];
324  if(is_array($all_obj_tags) &&
325  sizeof($all_obj_tags) != sizeof($tags))
326  {
327  $tpl->setVariable("TITLE_OTHER", $lng->txt("tagging_other_users"));
328  $tpl->setCurrentBlock("tag_other_bl");
329  foreach($all_obj_tags as $tag => $is_owner)
330  {
331  if(!$is_owner)
332  {
333  $tpl->setVariable("OTHER_TAG", $tag);
334  $tpl->parseCurrentBlock();
335  }
336  }
337 
338  }
339  }
340 
341  echo $tpl->get();
342  exit;
343  }
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.
exit
Definition: login.php:54
$_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
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:40
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()

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

Get tagging js call.

Parameters
string$a_hash
string$a_update_code
Returns
string

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

References $tpl.

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

258  {
259  global $tpl;
260 
261  if ($a_update_code === null)
262  {
263  $a_update_code = "null";
264  }
265  else
266  {
267  $a_update_code = "'".$a_update_code."'";
268  }
269 
270  return "ilTagging.listTags(event, '".$a_hash."', ".$a_update_code.");";
271  }
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("CMD_SAVE", $this->savecmd);
147  $ttpl->setVariable("NAME_TAGS", $this->getInputFieldName());
148 
149  return $ttpl->get();
150  }
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:40
+ 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()

ilTaggingGUI::initJavascript (   $a_ajax_url)

Init javascript.

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

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

Referenced by ilObjectListGUI\prepareJsLinks().

238  {
239  global $tpl;
240 
241  include_once("./Services/YUI/classes/class.ilYuiUtil.php");
243  include_once("./Services/jQuery/classes/class.iljQueryUtil.php");
245  $tpl->addJavascript("./Services/Tagging/js/ilTagging.js");
246 
247  $tpl->addOnLoadCode("ilTagging.setAjaxUrl('".$a_ajax_url."');");
248  }
global $tpl
Definition: ilias.php:8
static initPanel($a_resize=false)
Init yui panel.
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 183 of file class.ilTaggingGUI.php.

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

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

◆ saveInput()

ilTaggingGUI::saveInput ( )

Save Input.

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

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

156  {
157  global $lng;
158 
159  $input = ilUtil::stripSlashes($_POST[$this->getInputFieldName()]);
160  $input = str_replace(",", " ", $input);
161  $itags = explode(" ", $input);
162  $tags = array();
163  foreach($itags as $itag)
164  {
165  $itag = trim($itag);
166  if (!in_array($itag, $tags) && $itag != "")
167  {
168  if (!$this->isForbidden($itag))
169  {
170  $tags[] = $itag;
171  }
172  }
173  }
174 
175  ilTagging::writeTagsForUserAndObject($this->obj_id, $this->obj_type,
176  $this->sub_obj_id, $this->sub_obj_type, $this->getUserId(), $tags);
177  ilUtil::sendSuccess($lng->txt('msg_obj_modified'));
178  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$_POST['username']
Definition: cron.php:12
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
global $lng
Definition: privfeed.php:40
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.
+ Here is the call graph for this function:

◆ saveJS()

ilTaggingGUI::saveJS ( )

Save JS.

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

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

349  {
350  $input = ilUtil::stripSlashes($_POST["tags"]);
351  $input = str_replace(",", " ", $input);
352  $itags = explode(" ", $input);
353  $tags = array();
354  foreach($itags as $itag)
355  {
356  $itag = trim($itag);
357  if (!in_array($itag, $tags) && $itag != "")
358  {
359  if (!$this->isForbidden($itag))
360  {
361  $tags[] = $itag;
362  }
363  }
364  }
365 
366  ilTagging::writeTagsForUserAndObject($this->obj_id, $this->obj_type,
367  $this->sub_obj_id, $this->sub_obj_type, $this->getUserId(), $tags);
368 
369  $this->mess = "mod";
370 
371  $this->getHTML();
372  }
$_POST['username']
Definition: cron.php:12
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.
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.
+ 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, 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.
global $ilUser
Definition: imgupload.php:15
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: