ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilPCResourcesGUI Class Reference

Class ilPCResourcesGUI. More...

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

Public Member Functions

 __construct (&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id="")
 Constructor 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
 __construct ($a_pg_obj, $a_content_obj, $a_hier_id=0, $a_pc_id="")
 Constructor 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 (see also ilContainerContentGUI::determinePageEmbeddedBlocks for presentation) More...
 
- Static Public Member Functions inherited from ilPageContentGUI
static _getCommonBBButtons ()
 Get common bb buttons. More...
 

Protected Attributes

 $rep_tree
 
 $obj_definition
 
- Protected Attributes inherited from ilPageContentGUI
 $error
 
 $log
 

Additional Inherited Members

- Data Fields inherited from ilPageContentGUI
 $content_obj
 
 $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...
 
- 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.

Constructor & Destructor Documentation

◆ __construct()

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

Constructor public.

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

References $DIC, and $tree.

35  {
36  global $DIC;
37 
38  $this->ctrl = $DIC->ctrl();
39  $this->tpl = $DIC["tpl"];
40  $this->lng = $DIC->language();
41  $this->obj_definition = $DIC["objDefinition"];
42  $tree = $DIC->repositoryTree();
43 
44  $this->rep_tree = $tree;
45  parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
46  }
global $DIC
Definition: saml.php:7

Member Function Documentation

◆ create()

ilPCResourcesGUI::create ( )

Create new Resources Component.

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

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

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

◆ edit()

ilPCResourcesGUI::edit (   $a_insert = false)

Edit resources form.

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

References $_GET, $c, ilPageContentGUI\$ctrl, $form, $html, $ilCtrl, $key, ilPageContentGUI\$lng, $obj_definition, PHPMailer\PHPMailer\$options, $ret, $si, ilPageContentGUI\$tpl, ilObject\_lookupObjId(), ilObject\_lookupType(), ilPageContentGUI\displayValidationError(), ilObjectPlugin\getPluginObjectByType(), and ilRadioGroupInputGUI\setValue().

Referenced by insert(), and update().

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

◆ executeCommand()

ilPCResourcesGUI::executeCommand ( )

execute command

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

References $ret.

52  {
53  // get next class that processes or forwards current command
54  $next_class = $this->ctrl->getNextClass($this);
55 
56  // get current command
57  $cmd = $this->ctrl->getCmd();
58 
59  switch ($next_class) {
60  default:
61  $ret = $this->$cmd();
62  break;
63  }
64 
65  return $ret;
66  }
$ret
Definition: parser.php:6

◆ insert()

ilPCResourcesGUI::insert ( )

Insert new resources component form.

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

References edit().

Referenced by create().

72  {
73  $this->edit(true);
74  }
edit($a_insert=false)
Edit resources form.
+ 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 (see also ilContainerContentGUI::determinePageEmbeddedBlocks for presentation)

Parameters

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

References $_GET, $a_content, $def, $DIC, $html, ilPageContentGUI\$lng, $t, ilPageContentGUI\$tpl, $tree, $type, ilObject\_lookupObjId(), ilContainerReference\_lookupTitle(), ilObject\_lookupTitle(), ilObject\_lookupType(), and ilUtil\img().

Referenced by ilPageObjectGUI\insertResources().

234  {
235  global $DIC;
236 
237  $objDefinition = $DIC["objDefinition"];
238  $tree = $DIC->repositoryTree();
239  $lng = $DIC->language();
240 
241  $ref_id = (int) $_GET["ref_id"];
242  $obj_id = (int) ilObject::_lookupObjId($ref_id);
243  $obj_type = ilObject::_lookupType($obj_id);
244 
245  // determine type -> group
246  $type_to_grp = array();
247  $type_grps =
248  $objDefinition->getGroupedRepositoryObjectTypes($obj_type);
249  foreach ($type_grps as $grp => $def) {
250  foreach ($def["objs"] as $t) {
251  $type_to_grp[$t] = $grp;
252  }
253  }
254 
255  $childs = $tree->getChilds($ref_id);
256  $childs_by_type = array();
257  $item_groups = array();
258  foreach ($childs as $child) {
259  $childs_by_type[$type_to_grp[$child["type"]]][] = $child;
260  if ($child["type"] == "itgr") {
261  $item_groups[(int) $child["ref_id"]] = $child["title"];
262  }
263  }
264 
265  // handle "by type" lists
266  foreach ($type_grps as $type => $v) {
267  if (is_int(strpos($a_content, "[list-" . $type . "]"))) {
268  // render block
269  $tpl = new ilTemplate("tpl.resource_block.html", true, true, "Services/COPage");
270  $cnt = 0;
271 
272  if (is_array($childs_by_type[$type]) && count($childs_by_type[$type]) > 0) {
273  foreach ($childs_by_type[$type] as $child) {
274  $tpl->setCurrentBlock("row");
275  $tpl->setVariable("IMG", ilUtil::img(ilObject::_getIcon($child["obj_id"], "small")));
276  $tpl->setVariable("TITLE", $child["title"]);
277  $tpl->parseCurrentBlock();
278  $cnt++;
279  }
280  $tpl->setVariable("HEADER", $lng->txt("objs_" . $type));
281  $a_content = str_replace("[list-" . $type . "]", $tpl->get(), $a_content);
282  } else {
283  $tpl->setCurrentBlock("row");
284  $tpl->setVariable("TITLE", $lng->txt("no_items"));
285  $tpl->parseCurrentBlock();
286  $tpl->setVariable("HEADER", $lng->txt("objs_" . $type));
287  $a_content = str_replace("[list-" . $type . "]", $tpl->get(), $a_content);
288  }
289  }
290  }
291 
292  // handle item groups
293  while (preg_match('/\[(item-group-([0-9]*))\]/i', $a_content, $found)) {
294  $itgr_ref_id = (int) $found[2];
295 
296  // check whether this item group is child -> insert editing html
297  if (isset($item_groups[$itgr_ref_id])) {
298  include_once("./Modules/ItemGroup/classes/class.ilItemGroupItems.php");
299  $itgr_items = new ilItemGroupItems($itgr_ref_id);
300  $items = $itgr_items->getValidItems();
301 
302  // render block
303  $tpl = new ilTemplate("tpl.resource_block.html", true, true, "Services/COPage");
304  foreach ($items as $it_ref_id) {
305  $it_obj_id = ilObject::_lookupObjId($it_ref_id);
306  $it_title = ilObject::_lookupTitle($it_obj_id);
307  $it_type = ilObject::_lookupType($it_obj_id);
308 
309  // TODO: Handle this switch by module.xml definitions
310  if (in_array($it_type, array("catr", "crsr", "grpr"))) {
311  include_once('./Services/ContainerReference/classes/class.ilContainerReference.php');
312  $it_title = ilContainerReference::_lookupTitle($it_obj_id);
313  }
314 
315 
316  $tpl->setCurrentBlock("row");
317  $tpl->setVariable("IMG", ilUtil::img(ilObject::_getIcon($it_obj_id, "small")));
318  $tpl->setVariable("TITLE", $it_title);
319  $tpl->parseCurrentBlock();
320  }
321  $tpl->setVariable("HEADER", $item_groups[$itgr_ref_id]);
322  $html = $tpl->get();
323  } else {
324  $html = "<i>" . $lng->txt("cont_element_refers_removed_itgr") . "</i>";
325  }
326  $a_content = preg_replace('/\[' . $found[1] . '\]/i', $html, $a_content);
327  }
328 
329 
330  return $a_content;
331  }
$type
global $DIC
Definition: saml.php:7
$_GET["client_id"]
static _lookupTitle($a_id)
lookup object title
static _lookupTitle($a_obj_id)
Overwitten from base class.
$a_content
Definition: workflow.php:93
static _lookupObjId($a_id)
special template class to simplify handling of ITX/PEAR
Item group items.
static img($a_src, $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
static _lookupType($a_id, $a_reference=false)
lookup object type
$def
Definition: croninfo.php:21
$html
Definition: example_001.php:87
+ 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.

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

212  {
213  if ($_POST["res_type"] != "itgr") {
214  $this->content_obj->setResourceListType(ilUtil::stripSlashes($_POST["type"]));
215  } else {
216  $this->content_obj->setItemGroupRefId(ilUtil::stripSlashes($_POST["itgr"]));
217  }
218  $this->updated = $this->pg_obj->update();
219  if ($this->updated === true) {
220  $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
221  } else {
222  $this->pg_obj->addHierIDs();
223  $this->edit();
224  }
225  }
edit($a_insert=false)
Edit resources form.
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:

Field Documentation

◆ $obj_definition

ilPCResourcesGUI::$obj_definition
protected

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

Referenced by edit().

◆ $rep_tree

ilPCResourcesGUI::$rep_tree
protected

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


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