ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilPCContentIncludeGUI.php
Go to the documentation of this file.
1 <?php
2 
26 {
28  protected ilTabsGUI $tabs;
29 
30 
31  public function __construct(
32  ilPageObject $a_pg_obj,
33  ?ilPageContent $a_content_obj,
34  string $a_hier_id,
35  string $a_pc_id = ""
36  ) {
37  global $DIC;
38 
39  $this->ctrl = $DIC->ctrl();
40  $this->access = $DIC->access();
41  $this->tabs = $DIC->tabs();
42  $this->tpl = $DIC["tpl"];
43  $this->lng = $DIC->language();
44  parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
45  }
46 
47  public function executeCommand(): void
48  {
49  // get next class that processes or forwards current command
50  $next_class = $this->ctrl->getNextClass($this);
51 
52  // get current command
53  $cmd = $this->ctrl->getCmd();
54 
55  switch ($next_class) {
56  default:
57  $this->$cmd();
58  break;
59  }
60  }
61 
65  public function insert(): void
66  {
67  switch ($this->sub_command) {
68  case "selectPool":
69  $this->selectPool();
70  break;
71 
72  case "poolSelection":
73  $this->poolSelection();
74  break;
75 
76  default:
77  $this->insertFromPool();
78  break;
79  }
80  }
81 
85  public function insertFromPool(): void
86  {
87  $ilCtrl = $this->ctrl;
88  $ilAccess = $this->access;
89  $tpl = $this->tpl;
90  $lng = $this->lng;
91 
92  if ($this->edit_repo->getMediaPool() > 0 &&
93  $ilAccess->checkAccess("write", "", $this->edit_repo->getMediaPool())
94  && ilObject::_lookupType(ilObject::_lookupObjId($this->edit_repo->getMediaPool())) == "mep") {
95  $tb = new ilToolbarGUI();
96 
97  $ilCtrl->setParameter($this, "subCmd", "poolSelection");
98 
99  $tb->addButton(
100  $lng->txt("cont_select_media_pool"),
101  $ilCtrl->getLinkTarget($this, "insert")
102  );
103  $html = $tb->getHTML();
104 
105  $ilCtrl->setParameter($this, "subCmd", "");
106 
107  $pool = new ilObjMediaPool($this->edit_repo->getMediaPool());
108  $ilCtrl->setParameter($this, "subCmd", "insertFromPool");
109  $mpool_table = new ilMediaPoolTableGUI(
110  $this,
111  "insert",
112  $pool,
113  "mep_folder",
115  );
116  $mpool_table->setInsertCommand("create_incl");
117 
118  $html .= $mpool_table->getHTML();
119 
120  $tpl->setContent($html);
121  } else {
122  $this->poolSelection();
123  }
124  }
125 
129  public function poolSelection(): void
130  {
131  $tpl = $this->tpl;
132  $ilCtrl = $this->ctrl;
133 
134  $ilCtrl->setParameter($this, "subCmd", "poolSelection");
135  $exp = new ilPoolSelectorGUI($this, "insert");
136 
137  // filter
138  $exp->setTypeWhiteList(array("root", "cat", "grp", "fold", "crs", "mep"));
139  $exp->setClickableTypes(array('mep'));
140 
141  if (!$exp->handleCommand()) {
142  $tpl->setContent($exp->getHTML());
143  }
144  }
145 
149  public function create(): void
150  {
151  $ids = $this->request->getIntArray("id");
152  if (count($ids) > 0) {
153  for ($i = count($ids) - 1; $i >= 0; $i--) {
154  // similar code in ilpageeditorgui::insertFromClipboard
155  $this->content_obj = new ilPCContentInclude($this->getPage());
156  $this->content_obj->create(
157  $this->pg_obj,
158  $this->request->getHierId(),
160  );
161  $this->content_obj->setContentType("mep");
162  $this->content_obj->setContentId($ids[$i]);
163  }
164  $this->updated = $this->pg_obj->update();
165  }
166  if ($this->updated === true) {
167  $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
168  } else {
169  $this->insert();
170  }
171  }
172 
176  public function selectPool(): void
177  {
178  $ilCtrl = $this->ctrl;
179 
180  $this->edit_repo->setMediaPool($this->request->getInt("pool_ref_id"));
181  $ilCtrl->setParameter($this, "subCmd", "insertFromPool");
182  $ilCtrl->redirect($this, "insert");
183  }
184 }
insertFromPool()
Insert page snippet from media pool.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
insert()
Insert new resources component form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupObjId(int $ref_id)
global $DIC
Definition: feed.php:28
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setContent(string $a_html)
Sets content for standard template.
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
ilGlobalTemplateInterface $tpl
create()
create new content include in dom and update page in db
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(ilPageObject $a_pg_obj, ?ilPageContent $a_content_obj, string $a_hier_id, string $a_pc_id="")
selectPool()
Select concrete pool.
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
static _lookupType(int $id, bool $reference=false)
TableGUI class for recent changes in wiki.
$i
Definition: metadata.php:41