ILIAS  release_7 Revision v7.30-3-g800a261c036
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
4require_once("./Services/COPage/classes/class.ilPCContentInclude.php");
5require_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 {
91 $ilCtrl = $this->ctrl;
92 $ilAccess = $this->access;
93 $ilTabs = $this->tabs;
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 {
141 $ilCtrl = $this->ctrl;
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 {
164 $ilCtrl = $this->ctrl;
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 {
191 $ilCtrl = $this->ctrl;
192
193 $_SESSION["cont_media_pool"] = $_GET["pool_ref_id"];
194 $ilCtrl->setParameter($this, "subCmd", "insertFromPool");
195 $ilCtrl->redirect($this, "insert");
196 }
197}
$_GET["client_id"]
$_POST["username"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
TableGUI class for recent changes in wiki.
Media pool object.
static _lookupObjId($a_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
Class ilPCContentIncludeGUI.
__construct(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id="")
Constructor @access public.
create()
create new content include in dom and update page in db
insert()
Insert new resources component form.
selectPool()
Select concrete pool.
insertFromPool($a_post_cmd="edpost", $a_submit_cmd="create_mob")
Insert page snippet from media pool.
Class ilPCContentInclude.
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
Select media pool for adding objects into pages.
global $DIC
Definition: goto.php:24
$i
Definition: metadata.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$ret
Definition: parser.php:6