ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 {
22  protected $access;
23 
27  protected $tabs;
28 
29 
34  public function __construct(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id = "")
35  {
36  global $DIC;
37 
38  $this->ctrl = $DIC->ctrl();
39  $this->access = $DIC->access();
40  $this->tabs = $DIC->tabs();
41  $this->tpl = $DIC["tpl"];
42  $this->lng = $DIC->language();
43  parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
44  }
45 
49  public function executeCommand()
50  {
51  // get next class that processes or forwards current command
52  $next_class = $this->ctrl->getNextClass($this);
53 
54  // get current command
55  $cmd = $this->ctrl->getCmd();
56 
57  switch ($next_class) {
58  default:
59  $ret = $this->$cmd();
60  break;
61  }
62 
63  return $ret;
64  }
65 
69  public function insert()
70  {
71  switch ($_GET["subCmd"]) {
72  case "selectPool":
73  $this->selectPool();
74  break;
75 
76  case "poolSelection":
77  $this->poolSelection();
78  break;
79 
80  default:
81  $this->insertFromPool($a_post_cmd, $a_submit_cmd);
82  break;
83  }
84  }
85 
89  public function insertFromPool($a_post_cmd = "edpost", $a_submit_cmd = "create_mob")
90  {
92  $ilAccess = $this->access;
93  $ilTabs = $this->tabs;
94  $tpl = $this->tpl;
95  $lng = $this->lng;
96 
97 
98  if ($_SESSION["cont_media_pool"] != "" &&
99  $ilAccess->checkAccess("write", "", $_SESSION["cont_media_pool"])
100  && ilObject::_lookupType(ilObject::_lookupObjId($_SESSION["cont_media_pool"])) == "mep") {
101  $html = "";
102  $tb = new ilToolbarGUI();
103 
104  $ilCtrl->setParameter($this, "subCmd", "poolSelection");
105 
106  $tb->addButton(
107  $lng->txt("cont_select_media_pool"),
108  $ilCtrl->getLinkTarget($this, "insert")
109  );
110  $html = $tb->getHTML();
111 
112  $ilCtrl->setParameter($this, "subCmd", "");
113 
114  include_once("./Modules/MediaPool/classes/class.ilObjMediaPool.php");
115  include_once("./Modules/MediaPool/classes/class.ilMediaPoolTableGUI.php");
116  $pool = new ilObjMediaPool($_SESSION["cont_media_pool"]);
117  $ilCtrl->setParameter($this, "subCmd", "insertFromPool");
118  $mpool_table = new ilMediaPoolTableGUI(
119  $this,
120  "insert",
121  $pool,
122  "mep_folder",
124  );
125  $mpool_table->setInsertCommand("create_incl");
126 
127  $html.= $mpool_table->getHTML();
128 
129  $tpl->setContent($html);
130  } else {
131  $this->poolSelection();
132  }
133  }
134 
138  public function poolSelection()
139  {
140  $tpl = $this->tpl;
142 
143  // $this->getTabs($ilTabs, true);
144  // $ilTabs->setSubTabActive("cont_mob_from_media_pool");
145 
146  include_once "./Services/COPage/classes/class.ilPoolSelectorGUI.php";
147  $ilCtrl->setParameter($this, "subCmd", "poolSelection");
148  $exp = new ilPoolSelectorGUI($this, "insert");
149 
150  // filter
151  $exp->setTypeWhiteList(array("root", "cat", "grp", "fold", "crs", "mep"));
152  $exp->setClickableTypes(array('mep'));
153 
154  if (!$exp->handleCommand()) {
155  $tpl->setContent($exp->getHTML());
156  }
157  }
158 
162  public function create()
163  {
165  $lng = $this->lng;
166 
167  if (is_array($_POST["id"])) {
168  for ($i = count($_POST["id"]) - 1; $i>=0; $i--) {
169  // similar code in ilpageeditorgui::insertFromClipboard
170  include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
171  include_once("./Services/COPage/classes/class.ilPCMediaObject.php");
172  $this->content_obj = new ilPCContentInclude($this->getPage());
173  $this->content_obj->create($this->pg_obj, $_GET["hier_id"], $this->pc_id);
174  $this->content_obj->setContentType("mep");
175  $this->content_obj->setContentId($_POST["id"][$i]);
176  }
177  $this->updated = $this->pg_obj->update();
178  }
179  if ($this->updated === true) {
180  $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
181  } else {
182  $this->insert();
183  }
184  }
185 
189  public function selectPool()
190  {
192 
193  $_SESSION["cont_media_pool"] = $_GET["pool_ref_id"];
194  $ilCtrl->setParameter($this, "subCmd", "insertFromPool");
195  $ilCtrl->redirect($this, "insert");
196  }
197 }
Class ilPCContentIncludeGUI.
$_SESSION["AccountId"]
global $DIC
Definition: saml.php:7
$_GET["client_id"]
insert()
Insert new resources component form.
__construct(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id="")
Constructor public.
global $ilCtrl
Definition: ilias.php:18
insertFromPool($a_post_cmd="edpost", $a_submit_cmd="create_mob")
Insert page snippet from media pool.
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
Class ilPCContentInclude.
static _lookupObjId($a_id)
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
create()
create new content include in dom and update page in db
Media pool object.
Select media pool for adding objects into pages.
$ret
Definition: parser.php:6
$i
Definition: disco.tpl.php:19
selectPool()
Select concrete pool.
$_POST["username"]
$html
Definition: example_001.php:87
TableGUI class for recent changes in wiki.