30 protected \ILIAS\COPage\InternalDomainService
$domain;
46 $this->
user = $DIC->user();
47 $this->
tabs = $DIC->tabs();
48 $this->
ctrl = $DIC->ctrl();
49 $this->tpl =
$DIC[
"tpl"];
50 $this->tree =
$DIC->repositoryTree();
51 $this->
lng = $DIC->language();
52 $this->
toolbar = $DIC->toolbar();
54 $this->domain =
$DIC->copage()->internal()->domain();
57 $this->requested_file_ref_id = $this->request->getString(
"file_ref_id");
66 $next_class = $this->
ctrl->getNextClass($this);
71 $cmd = $this->
ctrl->getCmd();
73 switch ($next_class) {
88 if (in_array(
$sub_command, [
"insertNew",
"insertFromRepository",
"insertFromWorkspace"])) {
92 if ((
$sub_command ==
"") && $this->edit_repo->getSubCmd() !=
"") {
97 case "insertFromWorkspace":
101 case "insertFromRepository":
111 $ilTabs->setSubTabActive(
"cont_new_file");
115 if ($a_form !=
null) {
120 $this->tpl->setContent($form->getHTML());
129 $ilTabs->setSubTabActive(
"cont_file_from_repository");
134 $this->tpl->setContent($form->getHTML());
146 if ($a_cmd ==
"insert") {
152 $ilTabs->setSubTabActive(
"cont_file_from_repository");
153 $ilCtrl->setParameter($this,
"subCmd",
"insertFromRepository");
162 if (!$exp->handleCommand()) {
171 string $a_cmd =
"insert"
173 $ilTabs = $this->
tabs;
178 if ($a_cmd ==
"insert") {
184 $ilTabs->setSubTabActive(
"cont_file_from_workspace");
187 $ilCtrl->setParameter($this,
"subCmd",
"selectFile");
188 $exp->setCustomLinkTarget($ilCtrl->getLinkTarget($this, $a_cmd));
189 $ilCtrl->setParameter($this,
"subCmd",
"insertFromWorkspace");
190 $exp->setTypeWhiteList(array(
"wsrt",
"wfld",
"file"));
191 $exp->setSelectableTypes(array(
"file"));
192 if ($exp->handleCommand()) {
205 $mode = ($this->requested_file_ref_id !=
"")
208 $form = $this->initEditForm($mode);
209 if (!$form->checkInput()) {
210 $form->setValuesByPost();
211 $this->insert($form);
216 if (substr($this->requested_file_ref_id, 0, 4) ==
"wsp_") {
217 $fileObj =
new ilObjFile(substr($this->requested_file_ref_id, 4),
false);
220 elseif ($this->requested_file_ref_id ==
"") {
222 $fileObj->setType(
"file");
223 $fileObj->setTitle($_FILES[
"file"][
"name"]);
224 $fileObj->setDescription(
"");
225 $fileObj->setFileName($_FILES[
"file"][
"name"]);
226 $fileObj->setMode(
"filelist");
230 $upload =
$DIC->upload();
231 if ($upload->hasBeenProcessed() !==
true) {
235 $fileObj->getUploadFile(
236 $_FILES[
"file"][
"tmp_name"],
237 $_FILES[
"file"][
"name"]
242 $fileObj =
new ilObjFile($this->requested_file_ref_id);
244 $this->setCurrentTextLang($form->getInput(
"flst_language"));
247 $this->content_obj =
new ilPCFileList($this->getPage());
248 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
249 $this->content_obj->setListTitle(
250 $form->getInput(
"flst_title"),
251 $form->getInput(
"flst_language")
253 $this->content_obj->appendItem(
255 $fileObj->getFileName(),
256 $fileObj->getFileType()
259 $this->updated = $this->pg_obj->update();
260 if ($this->updated ===
true) {
261 $this->afterCreation();
269 $this->pg_obj->stripHierIDs();
270 $this->pg_obj->addHierIDs();
271 $this->
ctrl->setParameter($this,
"hier_id", $this->content_obj->readHierId());
272 $this->
ctrl->setParameter($this,
"pc_id", $this->content_obj->readPCId());
273 $this->
ctrl->redirect($this,
"editFiles");
286 $this->setTabs(
false);
288 $form = $this->initEditForm();
289 $this->tpl->setContent($form->getHTML());
298 $ilCtrl = $this->ctrl;
299 $ilUser = $this->user;
305 if ($a_mode !=
"add_file") {
308 $ti->setMaxLength(80);
314 foreach ($this->lom_services->dataHelper()->getAllLanguages() as $language) {
315 $languages[$language->value()] = $language->presentableLabel();
318 $si->setOptions($languages);
322 if (in_array($a_mode, array(
"create",
"add_file"))) {
325 $fi->setRequired(
true);
327 } elseif (in_array($a_mode, array(
"select_file"))) {
331 $file_ref_id = (
int) $this->requested_file_ref_id;
332 $fl_wsp_id = $this->request->getInt(
"fl_wsp_id");
334 if ($file_ref_id > 0) {
336 if (is_object($file_obj)) {
339 $hi->setValue($file_ref_id);
342 $ne->setValue($file_obj->getTitle());
344 } elseif ($fl_wsp_id > 0) {
349 $file_obj =
new ilObjFile($node[
"obj_id"],
false);
350 if (is_object($file_obj)) {
353 $hi->setValue(
"wsp_" . (
int) $node[
"obj_id"]);
356 $ne->setValue($file_obj->getTitle());
358 $this->tpl->parseCurrentBlock();
367 $ti->setValue($this->content_obj->getListTitle());
368 $si->setValue($this->content_obj->getLanguage());
369 $form->addCommandButton(
"saveProperties",
$lng->txt(
"save"));
370 $form->addCommandButton(
"cancelUpdate",
$lng->txt(
"cancel"));
371 $form->setTitle(
$lng->txt(
"cont_edit_file_list_properties"));
376 if ($this->getCurrentTextLang() !=
"") {
377 $s_lang = $this->getCurrentTextLang();
379 $s_lang = $ilUser->getLanguage();
381 $si->setValue($s_lang);
382 $form->addCommandButton(
"create",
$lng->txt(
"save"));
383 $form->addCommandButton(
"cancelCreate",
$lng->txt(
"cancel"));
384 $form->setTitle(
$lng->txt(
"cont_insert_file_list"));
388 $form->addCommandButton(
"insertNewFileItem",
$lng->txt(
"save"));
389 $form->addCommandButton(
"editFiles",
$lng->txt(
"cancel"));
390 $form->setTitle(
$lng->txt(
"cont_insert_file_item"));
394 $form->setFormAction($ilCtrl->getFormAction($this));
405 $form = $this->initEditForm(
"edit");
407 $this->content_obj->setListTitle(
408 $form->getInput(
"flst_title"),
409 $form->getInput(
"flst_language")
411 $this->updated = $this->pg_obj->update();
412 if ($this->updated ===
true) {
413 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"msg_obj_modified"),
true);
414 $this->
ctrl->redirect($this,
"editProperties");
416 $this->pg_obj->addHierIDs();
424 public function editFiles(): void
427 $ilToolbar = $this->toolbar;
428 $ilCtrl = $this->ctrl;
431 $this->setTabs(
false);
432 $this->
tabs->activateTab(
"cont_ed_edit_files");
434 $ilToolbar->addButton(
435 $lng->txt(
"cont_add_file"),
436 $ilCtrl->getLinkTarget($this,
"addFileItem")
440 $fl = $this->content_obj;
441 $table = $this->getFileListTable();
442 if ($table->handleCommand()) {
445 $tpl->setContent($table->render());
451 $fl = $this->content_obj;
452 return $this->gui->pc()->fileListTableBuilder($fl, $this,
"editFiles")->
getTable();
458 public function setTabs(
bool $a_create =
true): void
460 $ilTabs = $this->tabs;
461 $ilCtrl = $this->ctrl;
468 $ilCtrl->setParameter($this,
"subCmd",
"insertNew");
469 $ilTabs->addSubTabTarget(
471 $ilCtrl->getLinkTarget($this, $cmd),
475 $ilCtrl->setParameter($this,
"subCmd",
"insertFromRepository");
476 $ilTabs->addSubTabTarget(
477 "cont_file_from_repository",
478 $ilCtrl->getLinkTarget($this, $cmd),
481 $ilCtrl->setParameter($this,
"subCmd",
"");
483 if (!
$ilSetting->get(
"disable_personal_workspace") &&
485 $ilCtrl->setParameter($this,
"subCmd",
"insertFromWorkspace");
486 $ilTabs->addSubTabTarget(
487 "cont_file_from_workspace",
488 $ilCtrl->getLinkTarget($this, $cmd),
491 $ilCtrl->setParameter($this,
"subCmd",
"");
494 $ilTabs->setBackTarget(
496 $this->ctrl->getParentReturn($this)
500 "cont_ed_edit_files",
501 $ilCtrl->getLinkTarget($this,
"editFiles"),
508 $ilCtrl->getLinkTarget($this,
"editProperties"),
521 $ilCtrl = $this->ctrl;
523 $files = $this->content_obj->getFileList();
525 if (count($files) >= 1) {
526 $ilCtrl->setParameterByClass(
529 $files[count($files) - 1][
"hier_id"]
531 $ilCtrl->setParameterByClass(
534 $files[count($files) - 1][
"pc_id"]
536 $ilCtrl->redirectByClass(
"ilpcfileitemgui",
"newItemAfter");
538 $ilCtrl->redirect($this,
"newFileItem");
547 $table = $this->getFileListTable();
548 $ids = $table->getItemIds();
549 if (count($ids) > 0) {
550 $this->content_obj->deleteFileItems($ids);
552 $this->updated = $this->pg_obj->update();
553 $this->
ctrl->redirect($this,
"editFiles");
558 $table = $this->getFileListTable();
559 $ids = $table->getItemIds();
561 if (count($ids) === 0) {
562 $this->
ctrl->redirect($this,
"editFiles");
565 $retrieval = $this->domain->pc()->fileListRetrieval($this->content_obj);
566 $data = $retrieval->getData([]);
567 foreach (
$data as $row) {
568 if (in_array($row[
"id"], $ids)) {
569 $items[$row[
"id"]] = $row[
"file_name"];
573 $table->renderDeletionConfirmation(
574 $this->
lng->txt(
"delete"),
575 $this->lng->txt(
"cont_delete_file_item_confirm"),
586 $ilCtrl = $this->ctrl;
587 $table = $this->getFileListTable();
588 $pos = $table->getData();
589 if (is_array($pos) && count($pos) > 0) {
590 $this->content_obj->savePositions($pos);
592 $this->updated = $this->pg_obj->update();
593 $ilCtrl->redirect($this,
"editFiles");
598 $form = $this->getEditStyleForm(
$id);
600 $this->gui->modal(
$lng->txt(
"copg_edit_style_class"))
608 $lng->loadLanguageModule(
"style");
609 $lng->loadLanguageModule(
"copg");
611 $this->
ctrl->setParameterByClass(self::class,
"file_item_id",
$id);
612 $retrieval = $this->domain->pc()->fileListRetrieval($this->content_obj);
613 $options = $this->getCharacteristics();
614 $data = $retrieval->getData([]);
616 foreach (
$data as $row) {
617 if ($row[
"id"] ==
$id && isset(
$options[$row[
"class"]])) {
618 $value = $row[
"class"];
621 return $this->gui->form([self::class],
"saveStyleClass")
622 ->select(
"class",
$lng->txt(
"sty_class"),
$options,
"", $value)
628 $file_item_id = $this->request->getString(
"file_item_id");
629 $form = $this->getEditStyleForm($file_item_id);
630 if ($form->isValid()) {
631 $class = $form->getData(
"class");
632 $this->content_obj->saveStyleClass(
636 $this->updated = $this->pg_obj->update();
637 $this->
ctrl->redirect($this,
"editFiles");
646 $ilCtrl = $this->ctrl;
648 $pos = $this->request->getIntArray(
"position");
649 $class = $this->request->getStringArray(
"class");
650 if (count($pos) > 0) {
651 $this->content_obj->savePositions($pos);
653 if (count($class) > 0) {
654 $this->content_obj->saveStyleClasses($class);
656 $this->updated = $this->pg_obj->update();
657 $ilCtrl->redirect($this,
"editFiles");
666 $chars = $this->getCharacteristics();
668 $classes = $this->content_obj->getAllClasses();
669 if (count($chars) > 1) {
672 foreach ($classes as $class) {
673 if ($class !=
"" && $class !=
"FileListItem") {
691 $ilTabs = $this->tabs;
693 $sub_command = $this->sub_command;
694 if (in_array($sub_command, [
"insertNew",
"insertFromRepository",
"insertFromWorkspace"])) {
695 $this->edit_repo->setSubCmd($sub_command);
698 if (($sub_command ==
"") && $this->edit_repo->getSubCmd() !=
"") {
699 $sub_command = $this->edit_repo->getSubCmd();
702 switch ($sub_command) {
703 case "insertFromWorkspace":
704 $this->insertFromWorkspace(
"newFileItem");
707 case "insertFromRepository":
708 $this->insertFromRepository(
"newFileItem");
712 $this->insertNewFileItem($this->requested_file_ref_id);
716 $this->setItemTabs(
"newFileItem");
717 $ilTabs->setSubTabActive(
"cont_new_file");
719 $this->displayValidationError();
721 $form = $this->initEditForm(
"add_file");
722 $this->tpl->setContent($form->getHTML());
732 $ilUser = $this->user;
734 $fl_wsp_id = $this->request->getInt(
"fl_wsp_id");
737 if ($fl_wsp_id > 0) {
742 $file_obj =
new ilObjFile($node[
"obj_id"],
false);
745 elseif ($a_file_ref_id == 0) {
746 $file_obj = $this->createFileItem();
750 $file_obj =
new ilObjFile($a_file_ref_id);
752 if (is_object($file_obj)) {
753 $this->content_obj->appendItem(
755 $file_obj->getTitle(),
756 $file_obj->getFileType()
758 $this->updated = $this->pg_obj->update();
759 if ($this->updated ===
true) {
761 $this->
ctrl->redirect($this,
"editFiles");
765 $this->newFileItem();
777 if ($_FILES[
"file"][
"name"] ==
"") {
781 $form = $this->initEditForm();
786 $fileObj->setType(
"file");
787 $fileObj->setTitle($_FILES[
"file"][
"name"]);
788 $fileObj->setDescription(
"");
789 $fileObj->setFileName($_FILES[
"file"][
"name"]);
790 $fileObj->setMode(
"filelist");
794 $upload =
$DIC->upload();
795 if ($upload->hasBeenProcessed() !==
true) {
799 $fileObj->getUploadFile(
800 $_FILES[
"file"][
"tmp_name"],
801 $_FILES[
"file"][
"name"]
813 $ilTabs = $this->tabs;
814 $ilCtrl = $this->ctrl;
819 $this->
ctrl->getParentReturn($this),
825 $ilCtrl->setParameter($this,
"subCmd",
"insertNew");
826 $ilTabs->addSubTabTarget(
828 $ilCtrl->getLinkTarget($this, $a_cmd),
832 $ilCtrl->setParameter($this,
"subCmd",
"insertFromRepository");
833 $ilTabs->addSubTabTarget(
834 "cont_file_from_repository",
835 $ilCtrl->getLinkTarget($this, $a_cmd),
838 $ilCtrl->setParameter($this,
"subCmd",
"");
840 if (!
$ilSetting->get(
"disable_personal_workspace") &&
842 $ilCtrl->setParameter($this,
"subCmd",
"insertFromWorkspace");
843 $ilTabs->addSubTabTarget(
844 "cont_file_from_workspace",
845 $ilCtrl->getLinkTarget($this, $a_cmd),
848 $ilCtrl->setParameter($this,
"subCmd",
"");
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a non editable value in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
initEditForm(string $a_mode="edit")
Init edit form.
insertNewFileItem(int $a_file_ref_id=0)
insert new file item after another item
executeCommand()
execute command
getEditStyleForm(string $id)
addFileItem()
Add file item.
newFileItem()
New file item (called, if there is no file item in an existing)
setTabs(bool $a_create=true)
Set Tabs.
insert(?ilPropertyFormGUI $a_form=null)
insert new file list form
confirmDeletionFileItem()
setItemTabs(string $a_cmd="")
output tabs
savePositions()
Save positions of file items.
editProperties()
edit properties form
savePositionsAndClasses()
Save positions of file items and style classes.
checkStyleSelection()
Checks whether style selection shoudl be available or not.
saveProperties()
save table properties in db and return to page edit screen
insertFromWorkspace(string $a_cmd="insert")
Insert file from personal workspace.
__construct(ilPageObject $a_pg_obj, ?ilPageContent $a_content_obj, string $a_hier_id, string $a_pc_id="")
create()
create new file list in dom and update page in db
ILIAS COPage InternalDomainService $domain
editStyleClass(string $id)
deleteFileItem()
Delete file items from list.
createFileItem()
insert new file item
string $requested_file_ref_id
insertFromRepository(string $a_cmd="insert")
Insert file from repository.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
getCharacteristicsOfCurrentStyle(array $a_type)
Get characteristics of current style and call setCharacteristics, if style is given.
ilGlobalTemplateInterface $tpl
setCharacteristics(array $a_chars)
Content object of ilPageObject (see ILIAS DTD).
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a text property in a property form.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
getNodeData(int $a_node_id, ?int $a_tree_pk=null)
get all information of a node.
Explorer for selecting a personal workspace item.
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.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc