ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilTaggingClassificationProvider Class Reference

Tag classification provider. More...

+ Inheritance diagram for ilTaggingClassificationProvider:
+ Collaboration diagram for ilTaggingClassificationProvider:

Public Member Functions

 render (array &$a_html, $a_parent_gui)
 Render HTML chunks. More...
 
 importPostData ($a_saved=null)
 Import post data. More...
 
 setSelection ($a_value)
 Set selection. More...
 
 getFilteredObjects ()
 Get filtered object ref ids. More...
 
 initListGUI (ilObjectListGUI $a_list_gui)
 Init list gui properties. More...
 
- Public Member Functions inherited from ilClassificationProvider
 __construct ($a_parent_ref_id, $a_parent_obj_id, $a_parent_obj_type)
 Constructor. More...
 
 render (array &$a_html, $a_parent_gui)
 Render HTML chunks. More...
 
 importPostData ($a_saved=null)
 Import post data. More...
 
 setSelection ($a_value)
 Set selection. More...
 
 getFilteredObjects ()
 Get filtered object ref ids. More...
 
 initListGUI (ilObjectListGUI $a_list_gui)
 Init list gui properties. More...
 

Static Public Member Functions

static isActive ($a_parent_ref_id, $a_parent_obj_id, $a_parent_obj_type)
 Is provider currently active? More...
 
- Static Public Member Functions inherited from ilClassificationProvider
static getValidProviders ($a_parent_ref_id, $a_parent_obj_id, $a_parent_obj_type)
 Get all valid providers (for parent container) More...
 
static isActive ($a_parent_ref_id, $a_parent_obj_id, $a_parent_obj_type)
 Is provider currently active? More...
 

Protected Member Functions

 init ()
 Instance initialisation. More...
 
 getSubTreeTags ()
 
 init ()
 Instance initialisation. More...
 

Protected Attributes

 $enable_all_users
 
 $selection
 
- Protected Attributes inherited from ilClassificationProvider
 $parent_ref_id
 
 $parent_obj_id
 
 $parent_type
 

Detailed Description

Tag classification provider.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 14 of file class.ilTaggingClassificationProvider.php.

Member Function Documentation

◆ getFilteredObjects()

ilTaggingClassificationProvider::getFilteredObjects ( )

Get filtered object ref ids.

Returns
array

Reimplemented from ilClassificationProvider.

Definition at line 169 of file class.ilTaggingClassificationProvider.php.

170 {
171 global $ilUser;
172
173 if(!$this->selection)
174 {
175 return;
176 }
177
178 include_once "Services/Tagging/classes/class.ilTagging.php";
179
180 $types = array("personal");
181 if($this->enable_all_users)
182 {
183 $types[] = "other";
184 }
185
186 $found = array();
187 foreach($types as $type)
188 {
189 if(is_array($this->selection[$type]))
190 {
191 $invert = ($type == "personal")
192 ? false
193 : true;
194
195 foreach($this->selection[$type] as $tag)
196 {
197 $found[$tag] = array_keys(ilTagging::_findObjectsByTag($tag, $ilUser->getId(), $invert));
198 }
199 }
200 }
201
202 /* OR
203 $res = array();
204 foreach($found as $tag => $ids)
205 {
206 $res = array_merge($res, $ids);
207 }
208 */
209
210 // AND
211 $res = null;
212 foreach($found as $tag => $ids)
213 {
214 if($res === null)
215 {
216 $res = $ids;
217 }
218 else
219 {
220 $res = array_intersect($res, $ids);
221 }
222 }
223
224 if(sizeof($res))
225 {
226 return array_unique($res);
227 }
228 }
static _findObjectsByTag($a_tag, $a_user_id=null, $a_invert=false)
Find all objects with given tag.
global $ilUser
Definition: imgupload.php:15

References $ilUser, $res, and ilTagging\_findObjectsByTag().

+ Here is the call graph for this function:

◆ getSubTreeTags()

ilTaggingClassificationProvider::getSubTreeTags ( )
protected

Definition at line 230 of file class.ilTaggingClassificationProvider.php.

231 {
232 global $tree, $ilUser;
233
234 $sub_ids = array();
235 foreach($tree->getSubTree($tree->getNodeData($this->parent_ref_id)) as $sub_item)
236 {
237 if($sub_item["ref_id"] != $this->parent_ref_id &&
238 $sub_item["type"] != "rolf" &&
239 !$tree->isDeleted($sub_item["ref_id"]))
240 {
241 $sub_ids[$sub_item["obj_id"]] = $sub_item["type"];
242 }
243 }
244
245 if($sub_ids)
246 {
247 $only_user = $this->enable_all_users
248 ? null
249 : $ilUser->getId();
250
251 include_once "Services/Tagging/classes/class.ilTagging.php";
252 return ilTagging::_getTagCloudForObjects($sub_ids, $only_user, $ilUser->getId());
253 }
254 }
static _getTagCloudForObjects(array $a_obj_ids, $a_user_id=null, $a_divide=false)
Count tags for given object ids.

References $ilUser, and ilTagging\_getTagCloudForObjects().

Referenced by importPostData(), and render().

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

◆ importPostData()

ilTaggingClassificationProvider::importPostData (   $a_saved = null)

Import post data.

Parameters
mixed$a_saved
Returns
mixed

Reimplemented from ilClassificationProvider.

Definition at line 115 of file class.ilTaggingClassificationProvider.php.

116 {
117 $type = trim($_REQUEST["tag_type"]);
118 $tag_code = trim($_REQUEST["tag"]); // using codes to avoid encoding issues
119 if($type && $tag_code)
120 {
121 // code to tag
122 $found = null;
123 foreach($this->getSubTreeTags() as $tags)
124 {
125 foreach(array_keys($tags) as $tag)
126 {
127 if(md5($tag) == $tag_code)
128 {
129 $found = $tag;
130 break(2);
131 }
132 }
133 }
134 if($found)
135 {
136 /* single select
137 if(is_array($a_saved[$type]) &&
138 in_array($found, $a_saved[$type]))
139 {
140 return;
141 }
142 return array($type=>array($found));
143 */
144 // multi select
145 if(is_array($a_saved[$type]) &&
146 in_array($found, $a_saved[$type]))
147 {
148 $key = array_search($found, $a_saved[$type]);
149 unset($a_saved[$type][$key]);
150 if(!sizeof($a_saved[$type]))
151 {
152 unset($a_saved[$type]);
153 }
154 }
155 else
156 {
157 $a_saved[$type][] = $found;
158 }
159 }
160 return $a_saved;
161 }
162 }
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7

References $_REQUEST, and getSubTreeTags().

+ Here is the call graph for this function:

◆ init()

ilTaggingClassificationProvider::init ( )
protected

Instance initialisation.

Reimplemented from ilClassificationProvider.

Definition at line 19 of file class.ilTaggingClassificationProvider.php.

20 {
21 $tags_set = new ilSetting("tags");
22 $this->enable_all_users = (bool)$tags_set->get("enable_all_users", false);
23 }
ILIAS Setting Class.

◆ initListGUI()

ilTaggingClassificationProvider::initListGUI ( ilObjectListGUI  $a_list_gui)

Init list gui properties.

Parameters
ilObjectListGUI$a_list_gui

Reimplemented from ilClassificationProvider.

Definition at line 256 of file class.ilTaggingClassificationProvider.php.

257 {
258 $a_list_gui->enableTags(true);
259 }
enableTags($a_value)
Toogle tags action status.

References ilObjectListGUI\enableTags().

+ Here is the call graph for this function:

◆ isActive()

static ilTaggingClassificationProvider::isActive (   $a_parent_ref_id,
  $a_parent_obj_id,
  $a_parent_obj_type 
)
static

Is provider currently active?

Parameters
int$a_parent_ref_id
int$a_parent_obj_id
string$a_parent_obj_type
Returns
bool

Reimplemented from ilClassificationProvider.

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

26 {
27 global $ilUser;
28
29 // we currently only check for the parent object setting
30 // might change later on (parent containers)
31 include_once "Services/Object/classes/class.ilObjectServiceSettingsGUI.php";
33 $a_parent_obj_id,
35 false
36 );
37
38 if($valid)
39 {
40 $tags_set = new ilSetting("tags");
41 if(!$tags_set->get("enable_all_users", false) &&
42 $ilUser->getId() == ANONYMOUS_USER_ID)
43 {
44 $valid = false;
45 }
46 }
47
48 return $valid;
49 }
_lookupContainerSetting($a_id, $a_keyword, $a_default_value=NULL)
Lookup a container setting.
$valid

References $ilUser, $valid, ilContainer\_lookupContainerSetting(), and ilObjectServiceSettingsGUI\TAG_CLOUD.

Referenced by ilClassificationProvider\getValidProviders().

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

◆ render()

ilTaggingClassificationProvider::render ( array &  $a_html,
  $a_parent_gui 
)

Render HTML chunks.

Parameters
array$a_html
object$a_parent_gui

Reimplemented from ilClassificationProvider.

Definition at line 51 of file class.ilTaggingClassificationProvider.php.

52 {
53 global $lng;
54
55 $all_tags = $this->getSubTreeTags();
56 if($all_tags)
57 {
58 // see ilPDTaggingBlockGUI::getTagCloud();
59
60 $map = array(
61 "personal" => $lng->txt("tagging_my_tags"),
62 "other" => $lng->txt("tagging_other_users")
63 );
64 foreach($map as $type => $title)
65 {
66 $tags = $all_tags[$type];
67 if($tags)
68 {
69 $max = 1;
70 foreach($tags as $tag => $counter)
71 {
72 $max = max($counter, $max);
73 }
74 reset($tags);
75
76 $tpl = new ilTemplate("tpl.tag_cloud_block.html", true, true, "Services/Tagging");
77
78 $tpl->setCurrentBlock("tag_bl");
79 foreach($tags as $tag => $counter)
80 {
81 $tpl->setVariable("TAG_TYPE", $type);
82 $tpl->setVariable("TAG_TITLE", $tag);
83 $tpl->setVariable("TAG_CODE", md5($tag));
84 $tpl->setVariable("REL_CLASS",
85 ilTagging::getRelevanceClass($counter, $max));
86 if(is_array($this->selection[$type]) &&
87 in_array($tag, $this->selection[$type]))
88 {
89 $tpl->setVariable("HIGHL_CLASS", ' ilHighlighted');
90 }
91
92 $tpl->parseCurrentBlock();
93 }
94
95 $a_html[] = array(
96 "title" => $title,
97 "html" => $tpl->get()
98 );
99 }
100 }
101
102 /*
103 if($this->selection)
104 {
105 $a_html[] = array(
106 "title" => "Related Tags",
107 "html" => ":TODO:"
108 );
109 }
110 */
111 }
112 }
global $tpl
Definition: ilias.php:8
static getRelevanceClass($cnt, $max)
Get style class for tag relevance.
special template class to simplify handling of ITX/PEAR
global $lng
Definition: privfeed.php:40

References $lng, $tpl, ilTagging\getRelevanceClass(), and getSubTreeTags().

+ Here is the call graph for this function:

◆ setSelection()

ilTaggingClassificationProvider::setSelection (   $a_value)

Set selection.

Parameters
mixed$a_value

Reimplemented from ilClassificationProvider.

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

165 {
166 $this->selection = $a_value;
167 }

Field Documentation

◆ $enable_all_users

ilTaggingClassificationProvider::$enable_all_users
protected

Definition at line 16 of file class.ilTaggingClassificationProvider.php.

◆ $selection

ilTaggingClassificationProvider::$selection
protected

Definition at line 17 of file class.ilTaggingClassificationProvider.php.


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