ILIAS  Release_4_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  $tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
84  $tpl->setCurrentBlock("btn_cell");
85  $ilCtrl->setParameter($this, "subCmd", "poolSelection");
86  $tpl->setVariable("BTN_LINK",
87  $ilCtrl->getLinkTarget($this, "insert"));
88  $ilCtrl->setParameter($this, "subCmd", "");
89  $tpl->setVariable("BTN_TXT", $lng->txt("cont_select_media_pool"));
90  $tpl->parseCurrentBlock();
91 
92 // $this->getTabs($ilTabs, true);
93 // $ilTabs->setSubTabActive("cont_mob_from_media_pool");
94 
95  include_once("./Modules/MediaPool/classes/class.ilObjMediaPool.php");
96  include_once("./Modules/MediaPool/classes/class.ilMediaPoolTableGUI.php");
97  $pool = new ilObjMediaPool($_SESSION["cont_media_pool"]);
98  $ilCtrl->setParameter($this, "subCmd", "insertFromPool");
99  $mpool_table = new ilMediaPoolTableGUI($this, "insert", $pool, "mep_folder",
101  $mpool_table->setInsertCommand("create_incl");
102 
103  $tpl->setContent($mpool_table->getHTML());
104  }
105  else
106  {
107  $this->poolSelection();
108  }
109  }
110 
114  function poolSelection()
115  {
116  global $ilCtrl, $tree, $tpl, $ilTabs;
117 
118 // $this->getTabs($ilTabs, true);
119 // $ilTabs->setSubTabActive("cont_mob_from_media_pool");
120 
121  include_once "./Services/COPage/classes/class.ilPoolSelectorGUI.php";
122  $exp = new ilPoolSelectorGUI($this->ctrl->getLinkTarget($this, "insert"));
123  $exp->setContentGUIClass(get_class($this));
124  if ($_GET["expand"] == "")
125  {
126  $expanded = $tree->readRootId();
127  }
128  else
129  {
130  $expanded = $_GET["expand"];
131  }
132  $exp->setExpand($expanded);
133 
134  $exp->setTargetGet("sel_id");
135  $this->ctrl->setParameter($this, "target_type", $a_type);
136  $ilCtrl->setParameter($this, "subCmd", "poolSelection");
137  $exp->setParamsGet($this->ctrl->getParameterArray($this, "insert"));
138 
139  // filter
140  $exp->setFiltered(true);
141  $exp->setFilterMode(IL_FM_POSITIVE);
142  $exp->addFilter("root");
143  $exp->addFilter("cat");
144  $exp->addFilter("grp");
145  $exp->addFilter("fold");
146  $exp->addFilter("crs");
147  $exp->addFilter("mep");
148 
149  $sel_types = array('mep');
150 
151  $exp->setOutput(0);
152 
153  $tpl->setContent($exp->getOutput());
154  }
155 
159  function create()
160  {
161  global $ilCtrl, $lng;
162 
163  if (is_array($_POST["id"]))
164  {
165  for($i = count($_POST["id"]) - 1; $i>=0; $i--)
166  {
167  // similar code in ilpageeditorgui::insertFromClipboard
168  include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
169  include_once("./Services/COPage/classes/class.ilPCMediaObject.php");
170  $this->content_obj = new ilPCContentInclude($this->dom);
171  $this->content_obj->create($this->pg_obj, $_GET["hier_id"], $this->pc_id);
172  $this->content_obj->setContentType("mep");
173  $this->content_obj->setContentId($_POST["id"][$i]);
174  }
175  $this->updated = $this->pg_obj->update();
176  }
177  if ($this->updated === true)
178  {
179  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
180  }
181  else
182  {
183  $this->insert();
184  }
185  }
186 
190  function selectPool()
191  {
192  global $ilCtrl;
193 
194  $_SESSION["cont_media_pool"] = $_GET["pool_ref_id"];
195  $ilCtrl->setParameter($this, "subCmd", "insertFromPool");
196  $ilCtrl->redirect($this, "insert");
197  }
198 }
199 ?>