ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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, ilTemplate $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
 

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 36 of file class.ilTaggingGUI.php.

References $DIC, and user().

37  {
38  global $DIC;
39 
40  $this->ctrl = $DIC->ctrl();
41  $this->user = $DIC->user();
42  $this->lng = $DIC->language();
43  }
global $DIC
Definition: saml.php:7
user()
Definition: user.php:4
+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilTaggingGUI::executeCommand ( )

Execute command.

Parameters

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

References $ctrl, and $ilCtrl.

53  {
55 
56  $next_class = $ilCtrl->getNextClass();
57  switch ($next_class) {
58  default:
59  $cmd = $ilCtrl->getCmd();
60  $this->$cmd();
61  break;
62  }
63  }
global $ilCtrl
Definition: ilias.php:18

◆ getAllUserTagsForObjectHTML()

ilTaggingGUI::getAllUserTagsForObjectHTML ( )

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

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

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

237  {
238  $lng = $this->lng;
240 
241  $ttpl = new ilTemplate("tpl.tag_cloud.html", true, true, "Services/Tagging");
243  $this->obj_id,
244  $this->obj_type,
245  $this->sub_obj_id,
246  $this->sub_obj_type
247  );
248 
249  $max = 1;
250  foreach ($tags as $tag) {
251  $max = max($max, $tag["cnt"]);
252  }
253  reset($tags);
254  foreach ($tags as $tag) {
255  if (!$this->isForbidden($tag["tag"])) {
256  $ttpl->setCurrentBlock("unlinked_tag");
257  $ttpl->setVariable(
258  "REL_CLASS",
259  ilTagging::getRelevanceClass($tag["cnt"], $max)
260  );
261  $ttpl->setVariable("TAG_TITLE", $tag["tag"]);
262  $ttpl->parseCurrentBlock();
263  }
264  }
265 
266  return $ttpl->get();
267  }
isForbidden($a_tag)
Check whether a tag is forbiddens.
global $ilCtrl
Definition: ilias.php:18
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.
$tags
Definition: croninfo.php:19
special template class to simplify handling of ITX/PEAR
static getRelevanceClass($cnt, $max)
Get style class for tag relevance.
if(function_exists('posix_getuid') &&posix_getuid()===0) if(!array_key_exists('t', $options)) $tag
Definition: cron.php:35
+ Here is the call graph for this function:

◆ getHTML()

ilTaggingGUI::getHTML ( )

Get HTML.

Parameters

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

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

Referenced by saveJS().

330  {
331  $lng = $this->lng;
333 
334  $lng->loadLanguageModule("tagging");
335  $tpl = new ilTemplate("tpl.edit_tags.html", true, true, "Services/Tagging");
336  $tpl->setVariable("TXT_TAGS", $lng->txt("tagging_tags"));
337 
338  switch ($_GET["mess"] != "" ? $_GET["mess"] : $this->mess) {
339  case "mod":
340  $mtype = "success";
341  $mtxt = $lng->txt("msg_obj_modified");
342  break;
343  }
344  if ($mtxt != "") {
345  $tpl->setVariable("MESS", $tpl->getMessageHTML($mtxt, $mtype));
346  } else {
347  $tpl->setVariable("MESS", "");
348  }
349 
350  $img = ilUtil::img(ilObject::_getIcon($this->obj_id, "tiny"));
351  $tpl->setVariable("TXT_OBJ_TITLE", $img . " " . ilObject::_lookupTitle($this->obj_id));
353  $this->obj_id,
354  $this->obj_type,
355  $this->sub_obj_id,
356  $this->sub_obj_type,
357  $this->getUserId()
358  );
359  $tpl->setVariable(
360  "VAL_TAGS",
361  ilUtil::prepareFormOutput(implode($tags, ", "))
362  );
363  $tpl->setVariable("TXT_SAVE", $lng->txt("save"));
364  $tpl->setVariable("TXT_COMMA_SEPARATED", $lng->txt("comma_separated"));
365  $tpl->setVariable("CMD_SAVE", "saveJS");
366 
367  $os = "ilTagging.cmdAjaxForm(event, '" .
368  $ilCtrl->getFormActionByClass("iltagginggui", "", "", true) .
369  "');";
370  $tpl->setVariable("ON_SUBMIT", $os);
371 
372  $tags_set = new ilSetting("tags");
373  if ($tags_set->get("enable_all_users")) {
374  $tpl->setVariable("TAGS_TITLE", $lng->txt("tagging_my_tags"));
375 
376  $all_obj_tags = ilTagging::_getListTagsForObjects(array($this->obj_id));
377  $all_obj_tags = $all_obj_tags[$this->obj_id];
378  if (is_array($all_obj_tags) &&
379  sizeof($all_obj_tags) != sizeof($tags)) {
380  $tpl->setVariable("TITLE_OTHER", $lng->txt("tagging_other_users"));
381  $tpl->setCurrentBlock("tag_other_bl");
382  foreach ($all_obj_tags as $tag => $is_owner) {
383  if (!$is_owner) {
384  $tpl->setVariable("OTHER_TAG", $tag);
385  $tpl->parseCurrentBlock();
386  }
387  }
388  }
389  }
390 
391  echo $tpl->get();
392  exit;
393  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
$_GET["client_id"]
$tpl
Definition: ilias.php:10
static _lookupTitle($a_id)
lookup object title
getUserId()
Get User ID.
global $ilCtrl
Definition: ilias.php:18
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.
$tags
Definition: croninfo.php:19
foreach($metaentries['hosted'] as $index=> $entity) foreach($metaentries['remote'] as $key=> $set) $mtype
special template class to simplify handling of ITX/PEAR
static img($a_src, $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
exit
Definition: backend.php:16
static _getListTagsForObjects(array $a_obj_ids, $a_user_id=null)
Get tags for given object ids.
if(function_exists('posix_getuid') &&posix_getuid()===0) if(!array_key_exists('t', $options)) $tag
Definition: cron.php:35
+ 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 151 of file class.ilTaggingGUI.php.

Referenced by getTaggingInputHTML(), and saveInput().

152  {
153  return $this->inputfieldname;
154  }
+ 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 308 of file class.ilTaggingGUI.php.

References $DIC, and $tpl.

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

309  {
310  global $DIC;
311 
312  $tpl = $DIC["tpl"];
313 
314  if ($a_update_code === null) {
315  $a_update_code = "null";
316  } else {
317  $a_update_code = "'" . $a_update_code . "'";
318  }
319 
320  return "ilTagging.listTags(event, '" . $a_hash . "', " . $a_update_code . ");";
321  }
global $DIC
Definition: saml.php:7
$tpl
Definition: ilias.php:10
+ Here is the caller graph for this function:

◆ getSaveCmd()

ilTaggingGUI::getSaveCmd ( )

Get Save Command.

Returns
string Save Command

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

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

◆ getTaggingInputHTML()

ilTaggingGUI::getTaggingInputHTML ( )

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

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

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

160  {
161  $lng = $this->lng;
163 
164  $ttpl = new ilTemplate("tpl.tags_input.html", true, true, "Services/Tagging");
166  $this->obj_id,
167  $this->obj_type,
168  $this->sub_obj_id,
169  $this->sub_obj_type,
170  $this->getUserId()
171  );
172  $ttpl->setVariable(
173  "VAL_TAGS",
174  ilUtil::prepareFormOutput(implode($tags, ", "))
175  );
176  $ttpl->setVariable("TXT_SAVE", $lng->txt("save"));
177  $ttpl->setVariable("TXT_COMMA_SEPARATED", $lng->txt("comma_separated"));
178  $ttpl->setVariable("CMD_SAVE", $this->savecmd);
179  $ttpl->setVariable("NAME_TAGS", $this->getInputFieldName());
180 
181  return $ttpl->get();
182  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
getUserId()
Get User ID.
getInputFieldName()
Get Input Field Name.
global $ilCtrl
Definition: ilias.php:18
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.
$tags
Definition: croninfo.php:19
special template class to simplify handling of ITX/PEAR
+ Here is the call graph for this function:

◆ getUserId()

ilTaggingGUI::getUserId ( )

Get User ID.

Returns
int User ID

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

References $userid.

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

112  {
113  return $this->userid;
114  }
if(empty($userids)) $userid
+ Here is the caller graph for this function:

◆ initJavascript()

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

Init javascript.

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

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

Referenced by ilObjectListGUI\prepareJsLinks().

278  {
279  global $DIC;
280 
281  if ($a_main_tpl != null) {
282  $tpl = $a_main_tpl;
283  } else {
284  $tpl = $DIC["tpl"];
285  }
286 
287  $lng = $DIC->language();
288 
289  $lng->loadLanguageModule("tagging");
290  $lng->toJs("tagging_tags", $tpl);
291 
292  include_once("./Services/YUI/classes/class.ilYuiUtil.php");
293  ilYuiUtil::initPanel(false, $tpl);
294  include_once("./Services/jQuery/classes/class.iljQueryUtil.php");
296  $tpl->addJavascript("./Services/Tagging/js/ilTagging.js");
297 
298  $tpl->addOnLoadCode("ilTagging.setAjaxUrl('" . $a_ajax_url . "');");
299  }
global $DIC
Definition: saml.php:7
$tpl
Definition: ilias.php:10
static initjQuery($a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
static initPanel($a_resize=false, ilTemplate $a_main_tpl=null)
Init yui panel.
+ 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 220 of file class.ilTaggingGUI.php.

References $f.

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

221  {
222  foreach ($this->forbidden as $f) {
223  if (is_int(strpos(strtolower(
224  str_replace(array("+", "§", '"', "'", "*", "%", "&", "/", "\\", "(", ")", "=", ":", ";", ":", "-", "_", "\$",
225  "£" . "!" . "¨", "^", "`", "@", "<", ">"), "", $a_tag)
226  ), $f))) {
227  return true;
228  }
229  }
230  return false;
231  }
+ Here is the caller graph for this function:

◆ saveInput()

ilTaggingGUI::saveInput ( )

Save Input.

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

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

188  {
189  $lng = $this->lng;
190 
192  $input = str_replace("\r", "\n", $input);
193  $input = str_replace("\n\n", "\n", $input);
194  $input = str_replace("\n", ",", $input);
195  $itags = explode(",", $input);
196  $tags = array();
197  foreach ($itags as $itag) {
198  $itag = trim($itag);
199  if (!in_array($itag, $tags) && $itag != "") {
200  if (!$this->isForbidden($itag)) {
201  $tags[] = $itag;
202  }
203  }
204  }
205 
207  $this->obj_id,
208  $this->obj_type,
209  $this->sub_obj_id,
210  $this->sub_obj_type,
211  $this->getUserId(),
212  $tags
213  );
214  ilUtil::sendSuccess($lng->txt('msg_obj_modified'));
215  }
isForbidden($a_tag)
Check whether a tag is forbiddens.
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.
getUserId()
Get User ID.
getInputFieldName()
Get Input Field Name.
$tags
Definition: croninfo.php:19
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
$_POST["username"]
+ Here is the call graph for this function:

◆ saveJS()

ilTaggingGUI::saveJS ( )

Save JS.

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

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

399  {
401  $input = str_replace("\r", "\n", $input);
402  $input = str_replace("\n\n", "\n", $input);
403  $input = str_replace("\n", ",", $input);
404  $itags = explode(",", $input);
405  $tags = array();
406  foreach ($itags as $itag) {
407  $itag = trim($itag);
408  if (!in_array($itag, $tags) && $itag != "") {
409  if (!$this->isForbidden($itag)) {
410  $tags[] = $itag;
411  }
412  }
413  }
414 
416  $this->obj_id,
417  $this->obj_type,
418  $this->sub_obj_id,
419  $this->sub_obj_type,
420  $this->getUserId(),
421  $tags
422  );
423 
424  $this->mess = "mod";
425 
426  $this->getHTML();
427  }
isForbidden($a_tag)
Check whether a tag is forbiddens.
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.
getUserId()
Get User ID.
$tags
Definition: croninfo.php:19
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
getHTML()
Get HTML.
$_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 141 of file class.ilTaggingGUI.php.

Referenced by setObject().

142  {
143  $this->inputfieldname = $a_inputfieldname;
144  }
+ 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 74 of file class.ilTaggingGUI.php.

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

75  {
77 
78  $this->obj_id = $a_obj_id;
79  $this->obj_type = $a_obj_type;
80  $this->sub_obj_id = $a_sub_obj_id;
81  $this->sub_obj_type = $a_sub_obj_type;
82 
83  $this->setSaveCmd("saveTags");
84  $this->setUserId($ilUser->getId());
85  $this->setInputFieldName("il_tags");
86 
87  $tags_set = new ilSetting("tags");
88  $forbidden = $tags_set->get("forbidden_tags");
89  if ($forbidden != "") {
90  $this->forbidden = unserialize($forbidden);
91  } else {
92  $this->forbidden = array();
93  }
94  }
setSaveCmd($a_savecmd)
Set Save Command.
setUserId($a_userid)
Set User ID.
$ilUser
Definition: imgupload.php:18
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 121 of file class.ilTaggingGUI.php.

Referenced by setObject().

122  {
123  $this->savecmd = $a_savecmd;
124  }
+ Here is the caller graph for this function:

◆ setUserId()

ilTaggingGUI::setUserId (   $a_userid)

Set User ID.

Parameters
int$a_useridUser ID

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

Referenced by setObject().

102  {
103  $this->userid = $a_userid;
104  }
+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilTaggingGUI::$ctrl
protected

◆ $lng

ilTaggingGUI::$lng
protected

◆ $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: