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

Class ilPCResourcesGUI. More...

+ Inheritance diagram for ilPCResourcesGUI:
+ Collaboration diagram for ilPCResourcesGUI:

Public Member Functions

 ilPCResourcesGUI (&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id="")
 Constructor @access public. More...
 
executeCommand ()
 execute command More...
 
 insert ()
 Insert new resources component form. More...
 
 edit ($a_insert=false)
 Edit resources form. More...
 
 create ()
 Create new Resources Component. More...
 
 update ()
 Update Resources Component. More...
 
- Public Member Functions inherited from ilPageContentGUI
 ilPageContentGUI ($a_pg_obj, $a_content_obj, $a_hier_id=0, $a_pc_id="")
 Constructor @access public. More...
 
 setContentObject ($a_val)
 Set content object. More...
 
 getContentObject ()
 Get content object. More...
 
 setPage ($a_val)
 Set page. More...
 
 getPage ()
 Get page. More...
 
 setPageConfig ($a_val)
 Set Page Config. More...
 
 getPageConfig ()
 Get Page Config. More...
 
 setStyleId ($a_styleid)
 Set Style Id. More...
 
 getStyleId ()
 Get Style Id. More...
 
 getStyle ()
 Get style object. More...
 
 setCharacteristics ($a_chars)
 Set Characteristics. More...
 
 getCharacteristics ()
 Get characteristics. More...
 
 getHierId ()
 get hierarchical id in dom object More...
 
 setHierId ($a_hier_id)
 get hierarchical id in dom object More...
 
 getBBMenu ($a_ta_name="par_content")
 Get the bb menu incl. More...
 
 delete ()
 delete content element More...
 
 moveAfter ()
 move content element after another element More...
 
 moveBefore ()
 move content element before another element More...
 
 splitPage ()
 split page to new page at specified position More...
 
 splitPageNext ()
 split page to next page at specified position More...
 
 displayValidationError ()
 display validation errors More...
 
 cancelCreate ()
 cancel creating page content More...
 
 cancelUpdate ()
 cancel update More...
 
 cancel ()
 Cancel. More...
 
 deactivate ()
 gui function set enabled if is not enabled and vice versa More...
 
 cut ()
 Cut single element. More...
 
 copy ()
 Copy single element. More...
 
 getTemplateOptions ($a_type)
 Get table templates. More...
 

Static Public Member Functions

static insertResourcesIntoPageContent ($a_content)
 Insert resources. More...
 
- Static Public Member Functions inherited from ilPageContentGUI
static _getCommonBBButtons ()
 Get common bb buttons. More...
 

Additional Inherited Members

- Data Fields inherited from ilPageContentGUI
 $content_obj
 
 $ilias
 
 $tpl
 
 $lng
 
 $ctrl
 
 $pg_obj
 
 $hier_id
 
 $dom
 
 $updated
 
 $target_script
 
 $return_location
 
 $page_config = null
 
- Static Public Attributes inherited from ilPageContentGUI
static $style_selector_reset = "margin-top:2px; margin-bottom:2px; text-indent:0px; position:static; float:none; width: auto;"
 
- Protected Member Functions inherited from ilPageContentGUI
 getCharacteristicsOfCurrentStyle ($a_type)
 Get characteristics of current style. More...
 
- Protected Attributes inherited from ilPageContentGUI
 $log
 
- Static Protected Attributes inherited from ilPageContentGUI
static $common_bb_buttons
 

Detailed Description

Class ilPCResourcesGUI.

User Interface for Resources Component Editing

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

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

Member Function Documentation

◆ create()

ilPCResourcesGUI::create ( )

Create new Resources Component.

Definition at line 184 of file class.ilPCResourcesGUI.php.

185 {
186 $this->content_obj = new ilPCResources($this->getPage());
187 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
188
189 if ($_POST["res_type"] != "itgr")
190 {
191 $this->content_obj->setResourceListType(ilUtil::stripSlashes($_POST["type"]));
192 }
193 else
194 {
195 $this->content_obj->setItemGroupRefId(ilUtil::stripSlashes($_POST["itgr"]));
196 }
197 $this->updated = $this->pg_obj->update();
198 if ($this->updated === true)
199 {
200 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
201 }
202 else
203 {
204 $this->insert();
205 }
206 }
insert()
Insert new resources component form.
Class ilPCResources.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
$_POST['username']
Definition: cron.php:12

References $_POST, ilPageContentGUI\getPage(), insert(), and ilUtil\stripSlashes().

+ Here is the call graph for this function:

◆ edit()

ilPCResourcesGUI::edit (   $a_insert = false)

Edit resources form.

Definition at line 64 of file class.ilPCResourcesGUI.php.

65 {
66 global $ilCtrl, $tpl, $lng, $objDefinition;
67
69
70 // edit form
71 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
72 $form = new ilPropertyFormGUI();
73 $form->setFormAction($ilCtrl->getFormAction($this));
74 if ($a_insert)
75 {
76 $form->setTitle($this->lng->txt("cont_insert_resources"));
77 }
78 else
79 {
80 $form->setTitle($this->lng->txt("cont_update_resources"));
81 }
82
83 // count number of existing objects per type and collect item groups
84 $ref_id = (int) $_GET["ref_id"];
85 $childs = $this->rep_tree->getChilds($ref_id);
86 $type_counts = array();
87 $item_groups = array();
88 foreach ($childs as $c)
89 {
90 // see bug #12471
91 //echo "<br>-".$c["type"]."-".$objDefinition->getGroupOfObj($c["type"])."-";
92 $key = ($objDefinition->getGroupOfObj($c["type"]) != "")
93 ? $objDefinition->getGroupOfObj($c["type"])
94 : $c["type"];
95 $type_counts[$key] += 1;
96 if ($c["type"] == "itgr")
97 {
98 $item_groups[$c["ref_id"]] = $c["title"];
99 }
100 }
101
102 if (count($item_groups) > 0)
103 {
104 // radio group for type selection
105 $radg = new ilRadioGroupInputGUI($lng->txt("cont_resources"), "res_type");
106 if (!$a_insert && $this->content_obj->getMainType() == "ItemGroup")
107 {
108 $radg->setValue("itgr");
109 }
110 else
111 {
112 $radg->setValue("by_type");
113 }
114
115 $op_type = new ilRadioOption($lng->txt("cont_resources_of_type"), "by_type", "");
116 $radg->addOption($op_type);
117 $op_itemgroup = new ilRadioOption($lng->txt("obj_itgr"), "itgr", "");
118 $radg->addOption($op_itemgroup);
119 $form->addItem($radg);
120 }
121
122 // type selection
123 $type_prop = new ilSelectInputGUI($this->lng->txt("cont_type"),
124 "type");
125 $obj_id = ilObject::_lookupObjId($_GET["ref_id"]);
126 $obj_type = ilObject::_lookupType($obj_id);
127 $sub_objs = $objDefinition->getGroupedRepositoryObjectTypes($obj_type);
128 $types = array();
129 foreach($sub_objs as $k => $so)
130 {
131 if ($k != "itgr")
132 {
133 $types[$k] = $this->lng->txt("objs_".$k)." (".(int) $type_counts[$k].")";
134 }
135 }
136 $type_prop->setOptions($types);
137 $selected = ($a_insert)
138 ? ""
139 : $this->content_obj->getResourceListType();
140 $type_prop->setValue($selected);
141 if (count($item_groups) > 0)
142 {
143 $op_type->addSubItem($type_prop);
144 }
145 else
146 {
147 $form->addItem($type_prop);
148 }
149
150 if (count($item_groups) > 0)
151 {
152 // item groups
153 $options = $item_groups;
154 $si = new ilSelectInputGUI($this->lng->txt("obj_itgr"), "itgr");
155 $si->setOptions($options);
156 $selected = ($a_insert)
157 ? ""
158 : $this->content_obj->getItemGroupRefId();
159 $op_itemgroup->addSubItem($si);
160 }
161
162
163 // save/cancel buttons
164 if ($a_insert)
165 {
166 $form->addCommandButton("create_resources", $lng->txt("save"));
167 $form->addCommandButton("cancelCreate", $lng->txt("cancel"));
168 }
169 else
170 {
171 $form->addCommandButton("update_resources", $lng->txt("save"));
172 $form->addCommandButton("cancelUpdate", $lng->txt("cancel"));
173 }
174 $html = $form->getHTML();
175 $tpl->setContent($html);
176 return $ret;
177
178 }
$_GET["client_id"]
static _lookupObjId($a_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
displayValidationError()
display validation errors
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
This class represents a selection list property in a property form.
$html
Definition: example_001.php:87
global $ilCtrl
Definition: ilias.php:18
$ref_id
Definition: sahs_server.php:39
if(!is_array($argv)) $options

References $_GET, $html, $ilCtrl, ilPageContentGUI\$lng, $options, $ref_id, $ret, $si, ilPageContentGUI\$tpl, ilObject\_lookupObjId(), ilObject\_lookupType(), and ilPageContentGUI\displayValidationError().

Referenced by insert(), and update().

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

◆ executeCommand()

& ilPCResourcesGUI::executeCommand ( )

execute command

Definition at line 35 of file class.ilPCResourcesGUI.php.

36 {
37 // get next class that processes or forwards current command
38 $next_class = $this->ctrl->getNextClass($this);
39
40 // get current command
41 $cmd = $this->ctrl->getCmd();
42
43 switch($next_class)
44 {
45 default:
46 $ret =& $this->$cmd();
47 break;
48 }
49
50 return $ret;
51 }
$cmd
Definition: sahs_server.php:35

References $cmd, and $ret.

◆ ilPCResourcesGUI()

ilPCResourcesGUI::ilPCResourcesGUI ( $a_pg_obj,
$a_content_obj,
  $a_hier_id,
  $a_pc_id = "" 
)

Constructor @access public.

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

25 {
26 global $tree;
27
28 $this->rep_tree = $tree;
29 parent::ilPageContentGUI($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
30 }

◆ insert()

ilPCResourcesGUI::insert ( )

Insert new resources component form.

Definition at line 56 of file class.ilPCResourcesGUI.php.

57 {
58 $this->edit(true);
59 }
edit($a_insert=false)
Edit resources form.

References edit().

Referenced by create().

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

◆ insertResourcesIntoPageContent()

static ilPCResourcesGUI::insertResourcesIntoPageContent (   $a_content)
static

Insert resources.

Parameters

return

Definition at line 239 of file class.ilPCResourcesGUI.php.

240 {
241 global $objDefinition, $tree, $lng;
242
243 $ref_id = (int) $_GET["ref_id"];
244 $obj_id = (int) ilObject::_lookupObjId($ref_id);
245 $obj_type = ilObject::_lookupType($obj_id);
246
247 // determine type -> group
248 $type_to_grp = array();
249 $type_grps =
250 $objDefinition->getGroupedRepositoryObjectTypes($obj_type);
251 foreach ($type_grps as $grp => $def)
252 {
253 foreach ($def["objs"] as $t)
254 {
255 $type_to_grp[$t] = $grp;
256 }
257 }
258
259 $childs = $tree->getChilds($ref_id);
260 $childs_by_type = array();
261 $item_groups = array();
262 foreach ($childs as $child)
263 {
264 $childs_by_type[$type_to_grp[$child["type"]]][] = $child;
265 if ($child["type"] == "itgr")
266 {
267 $item_groups[(int) $child["ref_id"]] = $child["title"];
268 }
269 }
270
271 // handle "by type" lists
272 foreach ($type_grps as $type => $v)
273 {
274 if (is_int(strpos($a_content, "[list-".$type."]")))
275 {
276 // render block
277 $tpl = new ilTemplate("tpl.resource_block.html", true, true, "Services/COPage");
278 $cnt = 0;
279
280 if (is_array($childs_by_type[$type]) && count($childs_by_type[$type]) > 0)
281 {
282 foreach ($childs_by_type[$type] as $child)
283 {
284 $tpl->setCurrentBlock("row");
285 $tpl->setVariable("IMG", ilUtil::img(ilObject::_getIcon($child["obj_id"], "small")));
286 $tpl->setVariable("TITLE", $child["title"]);
287 $tpl->parseCurrentBlock();
288 $cnt++;
289 }
290 $tpl->setVariable("HEADER", $lng->txt("objs_".$type));
291 $a_content = str_replace("[list-".$type."]", $tpl->get(), $a_content);
292 }
293 else
294 {
295 $tpl->setCurrentBlock("row");
296 $tpl->setVariable("TITLE", $lng->txt("no_items"));
297 $tpl->parseCurrentBlock();
298 $tpl->setVariable("HEADER", $lng->txt("objs_".$type));
299 $a_content = str_replace("[list-".$type."]", $tpl->get(), $a_content);
300 }
301 }
302 }
303
304 // handle item groups
305 while (eregi("\[(item-group-([0-9]*))\]", $a_content, $found))
306 {
307 $itgr_ref_id = (int) $found[2];
308
309 // check whether this item group is child -> insert editing html
310 if (isset($item_groups[$itgr_ref_id]))
311 {
312 include_once("./Modules/ItemGroup/classes/class.ilItemGroupItems.php");
313 $itgr_items = new ilItemGroupItems($itgr_ref_id);
314 $items = $itgr_items->getValidItems();
315
316 // render block
317 $tpl = new ilTemplate("tpl.resource_block.html", true, true, "Services/COPage");
318 foreach ($items as $it_ref_id)
319 {
320 $it_obj_id = ilObject::_lookupObjId($it_ref_id);
321 $it_title = ilObject::_lookupTitle($it_obj_id);
322 $it_type = ilObject::_lookupType($it_obj_id);
323
324 // TODO: Handle this switch by module.xml definitions
325 if(in_array($it_type, array("catr", "crsr", "grpr")))
326 {
327 include_once('./Services/ContainerReference/classes/class.ilContainerReference.php');
328 $it_title = ilContainerReference::_lookupTitle($it_obj_id);
329 }
330
331
332 $tpl->setCurrentBlock("row");
333 $tpl->setVariable("IMG", ilUtil::img(ilObject::_getIcon($it_obj_id, "small")));
334 $tpl->setVariable("TITLE", $it_title);
335 $tpl->parseCurrentBlock();
336 }
337 $tpl->setVariable("HEADER", $item_groups[$itgr_ref_id]);
338 $html = $tpl->get();
339 }
340 else
341 {
342 $html = "<i>".$lng->txt("cont_element_refers_removed_itgr")."</i>";
343 }
344 $a_content = eregi_replace("\[".$found[1]."\]", $html, $a_content);
345 }
346
347
348 return $a_content;
349 }
static _lookupTitle($a_obj_id)
Overwitten from base class.
static _lookupTitle($a_id)
lookup object title
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
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.

References $_GET, $html, ilPageContentGUI\$lng, $ref_id, $t, ilPageContentGUI\$tpl, ilObject\_getIcon(), ilObject\_lookupObjId(), ilObject\_lookupTitle(), ilContainerReference\_lookupTitle(), ilObject\_lookupType(), and ilUtil\img().

Referenced by ilPageObjectGUI\insertResources().

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

◆ update()

ilPCResourcesGUI::update ( )

Update Resources Component.

Definition at line 211 of file class.ilPCResourcesGUI.php.

212 {
213 if ($_POST["res_type"] != "itgr")
214 {
215 $this->content_obj->setResourceListType(ilUtil::stripSlashes($_POST["type"]));
216 }
217 else
218 {
219 $this->content_obj->setItemGroupRefId(ilUtil::stripSlashes($_POST["itgr"]));
220 }
221 $this->updated = $this->pg_obj->update();
222 if ($this->updated === true)
223 {
224 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
225 }
226 else
227 {
228 $this->pg_obj->addHierIDs();
229 $this->edit();
230 }
231 }

References $_POST, edit(), and ilUtil\stripSlashes().

+ Here is the call graph for this function:

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