ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilTaggingGUI Class Reference

Class ilTaggingGUI. More...

+ Collaboration diagram for ilTaggingGUI:

Public Member Functions

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

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

ilTaggingGUI::executeCommand ( )

Execute command.

Parameters
@return

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

References $cmd, and $ilCtrl.

{
global $ilCtrl;
$next_class = $ilCtrl->getNextClass();
switch($next_class)
{
default:
$cmd = $ilCtrl->getCmd();
$this->$cmd();
break;
}
}
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\calculateFontSize(), ilTagging\getTagsForObject(), and isForbidden().

{
global $lng, $ilCtrl;
$ttpl = new ilTemplate("tpl.tag_cloud.html", true, true, "Services/Tagging");
$tags = ilTagging::getTagsForObject($this->obj_id, $this->obj_type,
$this->sub_obj_id, $this->sub_obj_type);
$max = 1;
foreach ($tags as $tag)
{
$max = max($max, $tag["cnt"]);
}
reset($tags);
foreach ($tags as $tag)
{
if (!$this->isForbidden($tag["tag"]))
{
$ttpl->setCurrentBlock("unlinked_tag");
$ttpl->setVariable("FONT_SIZE", ilTagging::calculateFontSize($tag["cnt"], $max)."%");
$ttpl->setVariable("TAG_TITLE", $tag["tag"]);
$ttpl->parseCurrentBlock();
}
}
return $ttpl->get();
}

+ Here is the call graph for this function:

ilTaggingGUI::getHTML ( )

Get HTML.

Parameters
@return

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

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

Referenced by saveJS().

{
global $lng, $ilCtrl;
$lng->loadLanguageModule("tagging");
$tpl = new ilTemplate("tpl.edit_tags.html", true, true, "Services/Tagging");
$tpl->setVariable("TXT_TAGS", $lng->txt("tagging_tags"));
switch($_GET["mess"] != "" ? $_GET["mess"] : $this->mess)
{
case "mod":
$mtype = "success";
$mtxt = $lng->txt("msg_obj_modified");
break;
}
if ($mtxt != "")
{
$tpl->setVariable("MESS", $tpl->getMessageHTML($mtxt, $mtype));
}
else
{
$tpl->setVariable("MESS", "");
}
$img = ilUtil::img(ilObject::_getIcon($this->obj_id, "tiny"));
$tpl->setVariable("TXT_OBJ_TITLE", $img." ".ilObject::_lookupTitle($this->obj_id));
$tags = ilTagging::getTagsForUserAndObject($this->obj_id, $this->obj_type,
$this->sub_obj_id, $this->sub_obj_type, $this->getUserId());
$tpl->setVariable("VAL_TAGS",
ilUtil::prepareFormOutput(implode($tags, " ")));
$tpl->setVariable("TXT_SAVE", $lng->txt("save"));
$tpl->setVariable("CMD_SAVE", "saveJS");
$os = "ilTagging.cmdAjaxForm(event, '".
$ilCtrl->getFormActionByClass("iltagginggui", "", "", true).
"');";
$tpl->setVariable("ON_SUBMIT", $os);
echo $tpl->get();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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().

{
return $this->inputfieldname;
}

+ Here is the caller graph for this function:

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

References $tpl.

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

{
global $tpl;
if ($a_update_code === null)
{
$a_update_code = "null";
}
else
{
$a_update_code = "'".$a_update_code."'";
}
return "ilTagging.listTags(event, '".$a_hash."', ".$a_update_code.");";
}

+ Here is the caller graph for this function:

ilTaggingGUI::getSaveCmd ( )

Get Save Command.

Returns
string Save Command

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

{
return $this->savecmd;
}
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().

{
global $lng, $ilCtrl;
$ttpl = new ilTemplate("tpl.tags_input.html", true, true, "Services/Tagging");
$tags = ilTagging::getTagsForUserAndObject($this->obj_id, $this->obj_type,
$this->sub_obj_id, $this->sub_obj_type, $this->getUserId());
$ttpl->setVariable("VAL_TAGS",
ilUtil::prepareFormOutput(implode($tags, " ")));
$ttpl->setVariable("TXT_SAVE", $lng->txt("save"));
$ttpl->setVariable("CMD_SAVE", $this->savecmd);
$ttpl->setVariable("NAME_TAGS", $this->getInputFieldName());
return $ttpl->get();
}

+ Here is the call graph for this function:

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().

{
return $this->userid;
}

+ Here is the caller graph for this function:

ilTaggingGUI::initJavascript (   $a_ajax_url)

Init javascript.

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

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

Referenced by ilObjectListGUI\prepareJsLinks().

{
global $tpl;
include_once("./Services/YUI/classes/class.ilYuiUtil.php");
include_once("./Services/jQuery/classes/class.iljQueryUtil.php");
$tpl->addJavascript("./Services/Tagging/js/ilTagging.js");
$tpl->addOnLoadCode("ilTagging.setAjaxUrl('".$a_ajax_url."');");
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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().

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

+ Here is the caller graph for this function:

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().

{
global $lng;
$input = str_replace(",", " ", $input);
$itags = explode(" ", $input);
$tags = array();
foreach($itags as $itag)
{
$itag = trim($itag);
if (!in_array($itag, $tags) && $itag != "")
{
if (!$this->isForbidden($itag))
{
$tags[] = $itag;
}
}
}
ilTagging::writeTagsForUserAndObject($this->obj_id, $this->obj_type,
$this->sub_obj_id, $this->sub_obj_type, $this->getUserId(), $tags);
ilUtil::sendSuccess($lng->txt('msg_obj_modified'));
}

+ Here is the call graph for this function:

ilTaggingGUI::saveJS ( )

Save JS.

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

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

{
$input = ilUtil::stripSlashes($_POST["tags"]);
$input = str_replace(",", " ", $input);
$itags = explode(" ", $input);
$tags = array();
foreach($itags as $itag)
{
$itag = trim($itag);
if (!in_array($itag, $tags) && $itag != "")
{
if (!$this->isForbidden($itag))
{
$tags[] = $itag;
}
}
}
ilTagging::writeTagsForUserAndObject($this->obj_id, $this->obj_type,
$this->sub_obj_id, $this->sub_obj_type, $this->getUserId(), $tags);
$this->mess = "mod";
$this->getHTML();
}

+ Here is the call graph for this function:

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().

{
$this->inputfieldname = $a_inputfieldname;
}

+ Here is the caller graph for this function:

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().

{
global $ilUser;
$this->obj_id = $a_obj_id;
$this->obj_type = $a_obj_type;
$this->sub_obj_id = $a_sub_obj_id;
$this->sub_obj_type = $a_sub_obj_type;
$this->setSaveCmd("saveTags");
$this->setUserId($ilUser->getId());
$this->setInputFieldName("il_tags");
$tags_set = new ilSetting("tags");
$forbidden = $tags_set->get("forbidden_tags");
if ($forbidden != "")
{
$this->forbidden = unserialize($forbidden);
}
else
{
$this->forbidden = array();
}
}

+ Here is the call graph for this function:

ilTaggingGUI::setSaveCmd (   $a_savecmd)

Set Save Command.

Parameters
string$a_savecmdSave Command

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

Referenced by setObject().

{
$this->savecmd = $a_savecmd;
}

+ Here is the caller graph for this function:

ilTaggingGUI::setUserId (   $a_userid)

Set User ID.

Parameters
int$a_useridUser ID

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

Referenced by setObject().

{
$this->userid = $a_userid;
}

+ Here is the caller graph for this function:


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