ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPCContentIncludeGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once("./Services/COPage/classes/class.ilPCContentInclude.php");
5 require_once("./Services/COPage/classes/class.ilPageContentGUI.php");
6 
18 {
19 
24  function ilPCContentIncludeGUI(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id = "")
25  {
26  parent::ilPageContentGUI($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
27  }
28 
32  function &executeCommand()
33  {
34  // get next class that processes or forwards current command
35  $next_class = $this->ctrl->getNextClass($this);
36 
37  // get current command
38  $cmd = $this->ctrl->getCmd();
39 
40  switch($next_class)
41  {
42  default:
43  $ret =& $this->$cmd();
44  break;
45  }
46 
47  return $ret;
48  }
49 
53  function insert()
54  {
55  switch ($_GET["subCmd"])
56  {
57  case "selectPool":
58  $this->selectPool();
59  break;
60 
61  case "poolSelection":
62  $this->poolSelection();
63  break;
64 
65  default:
66  $this->insertFromPool($a_post_cmd, $a_submit_cmd);
67  break;
68  }
69  }
70 
74  function insertFromPool($a_post_cmd = "edpost", $a_submit_cmd = "create_mob")
75  {
76  global $ilCtrl, $ilAccess, $ilTabs, $tpl, $lng;
77 
78 
79  if ($_SESSION["cont_media_pool"] != "" &&
80  $ilAccess->checkAccess("write", "", $_SESSION["cont_media_pool"])
81  && ilObject::_lookupType(ilObject::_lookupObjId($_SESSION["cont_media_pool"])) == "mep")
82  {
83  $html = "";
84  $tb = new ilToolbarGUI();
85 
86  $ilCtrl->setParameter($this, "subCmd", "poolSelection");
87 
88  $tb->addButton($lng->txt("cont_select_media_pool"),
89  $ilCtrl->getLinkTarget($this, "insert"));
90  $html = $tb->getHTML();
91 
92  $ilCtrl->setParameter($this, "subCmd", "");
93 
94  include_once("./Modules/MediaPool/classes/class.ilObjMediaPool.php");
95  include_once("./Modules/MediaPool/classes/class.ilMediaPoolTableGUI.php");
96  $pool = new ilObjMediaPool($_SESSION["cont_media_pool"]);
97  $ilCtrl->setParameter($this, "subCmd", "insertFromPool");
98  $mpool_table = new ilMediaPoolTableGUI($this, "insert", $pool, "mep_folder",
100  $mpool_table->setInsertCommand("create_incl");
101 
102  $html.= $mpool_table->getHTML();
103 
104  $tpl->setContent($html);
105  }
106  else
107  {
108  $this->poolSelection();
109  }
110  }
111 
115  function poolSelection()
116  {
117  global $tpl, $ilCtrl;
118 
119 // $this->getTabs($ilTabs, true);
120 // $ilTabs->setSubTabActive("cont_mob_from_media_pool");
121 
122  include_once "./Services/COPage/classes/class.ilPoolSelectorGUI.php";
123  $ilCtrl->setParameter($this, "subCmd", "poolSelection");
124  $exp = new ilPoolSelectorGUI($this, "insert");
125 
126  // filter
127  $exp->setTypeWhiteList(array("root", "cat", "grp", "fold", "crs", "mep"));
128  $exp->setClickableTypes(array('mep'));
129 
130  if (!$exp->handleCommand())
131  {
132  $tpl->setContent($exp->getHTML());
133  }
134  }
135 
139  function create()
140  {
141  global $ilCtrl, $lng;
142 
143  if (is_array($_POST["id"]))
144  {
145  for($i = count($_POST["id"]) - 1; $i>=0; $i--)
146  {
147  // similar code in ilpageeditorgui::insertFromClipboard
148  include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
149  include_once("./Services/COPage/classes/class.ilPCMediaObject.php");
150  $this->content_obj = new ilPCContentInclude($this->getPage());
151  $this->content_obj->create($this->pg_obj, $_GET["hier_id"], $this->pc_id);
152  $this->content_obj->setContentType("mep");
153  $this->content_obj->setContentId($_POST["id"][$i]);
154  }
155  $this->updated = $this->pg_obj->update();
156  }
157  if ($this->updated === true)
158  {
159  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
160  }
161  else
162  {
163  $this->insert();
164  }
165  }
166 
170  function selectPool()
171  {
172  global $ilCtrl;
173 
174  $_SESSION["cont_media_pool"] = $_GET["pool_ref_id"];
175  $ilCtrl->setParameter($this, "subCmd", "insertFromPool");
176  $ilCtrl->redirect($this, "insert");
177  }
178 }
179 ?>