4 require_once(
"./Services/COPage/classes/class.ilPCFileList.php");
5 require_once(
"./Services/COPage/classes/class.ilPageContentGUI.php");
27 $this->
setCharacteristics(array(
"FileListItem" => $this->lng->txt(
"cont_FileListItem")));
36 $next_class = $this->ctrl->getNextClass($this);
41 $cmd = $this->ctrl->getCmd();
60 if (
$_GET[
"subCmd"] ==
"insertNew")
62 $_SESSION[
"cont_file_insert"] =
"insertNew";
64 if (
$_GET[
"subCmd"] ==
"insertFromRepository")
66 $_SESSION[
"cont_file_insert"] =
"insertFromRepository";
68 if (
$_GET[
"subCmd"] ==
"insertFromWorkspace")
70 $_SESSION[
"cont_file_insert"] =
"insertFromWorkspace";
72 if ((
$_GET[
"subCmd"] ==
"") &&
$_SESSION[
"cont_file_insert"] !=
"")
77 switch (
$_GET[
"subCmd"])
79 case "insertFromWorkspace":
83 case "insertFromRepository":
93 $ilTabs->setSubTabActive(
"cont_new_file");
98 $this->tpl->setContent($form->getHTML());
112 $ilTabs->setSubTabActive(
"cont_file_from_repository");
117 $this->tpl->setContent($form->getHTML());
127 if ($a_cmd ==
"insert")
136 $ilTabs->setSubTabActive(
"cont_file_from_repository");
138 include_once
"./Services/COPage/classes/class.ilFileSelectorGUI.php";
142 if (
$_GET[
"expand"] ==
"")
144 $expanded = $tree->readRootId();
148 $expanded =
$_GET[
"expand"];
150 $exp->setExpand($expanded);
152 $exp->setTargetGet(
"sel_id");
154 $ilCtrl->setParameter($this,
"subCmd",
"insertFromRepository");
155 $exp->setParamsGet($this->ctrl->getParameterArray($this, $a_cmd));
158 $exp->setFiltered(
true);
160 $exp->addFilter(
"root");
161 $exp->addFilter(
"cat");
162 $exp->addFilter(
"grp");
163 $exp->addFilter(
"fold");
164 $exp->addFilter(
"crs");
165 $exp->addFilter(
"file");
167 $sel_types = array(
'file');
171 $tpl->setContent($exp->getOutput());
181 if ($a_cmd ==
"insert")
190 $ilTabs->setSubTabActive(
"cont_file_from_workspace");
193 include_once
"Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
197 include_once(
"./Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php");
201 include_once(
"./Services/PersonalWorkspace/classes/class.ilWorkspaceExplorer.php");
203 'filelist_wspexpand', $tree, $acc_handler);
204 $exp->setTargetGet(
'fl_wsp_id');
205 $exp->setFiltered(
false);
206 $exp->removeAllFormItemTypes();
209 $exp->setTypeClickable(
"file");
210 $ilCtrl->setParameter($this,
"subCmd",
"selectFile");
211 $exp->setCustomLinkTarget($ilCtrl->getLinkTarget($this, $a_cmd));
214 $exp->setFiltered(
true);
216 $exp->addFilter(
"wsrt");
217 $exp->addFilter(
"wfld");
218 $exp->addFilter(
"file");
221 $ilCtrl->setParameter($this,
"subCmd",
"insertFromWorkspace");
222 $exp->setParamsGet($ilCtrl->getParameterArray($this, $a_cmd));
224 if(
$_GET[
'filelist_wspexpand'] ==
'')
226 $expanded = $tree->readRootId();
230 $expanded =
$_GET[
'filelist_wspexpand'];
232 $exp->setExpand($expanded);
235 $tpl->setContent($exp->getOutput());
243 include_once(
"./Modules/File/classes/class.ilObjFile.php");
246 if(substr(
$_POST[
"file_ref_id"], 0, 4) ==
"wsp_")
251 else if (
$_POST[
"file_ref_id"] == 0)
254 $fileObj->setType(
"file");
255 $fileObj->setTitle($_FILES[
"file"][
"name"]);
256 $fileObj->setDescription(
"");
257 $fileObj->setFileName($_FILES[
"file"][
"name"]);
258 $fileObj->setFileType($_FILES[
"file"][
"type"]);
259 $fileObj->setFileSize($_FILES[
"file"][
"size"]);
260 $fileObj->setMode(
"filelist");
263 $fileObj->createDirectory();
264 $fileObj->raiseUploadError(
false);
265 $fileObj->getUploadFile($_FILES[
"file"][
"tmp_name"],
266 $_FILES[
"file"][
"name"]);
277 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
279 $this->content_obj->appendItem($fileObj->getId(), $fileObj->getFileName(),
280 $fileObj->getFileType());
282 $this->updated = $this->pg_obj->update();
283 if ($this->updated ===
true)
285 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
301 $this->tpl->setContent($form->getHTML());
313 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
316 if ($a_mode !=
"add_file")
325 require_once(
"Services/MetaData/classes/class.ilMDLanguageItem.php");
332 if (in_array($a_mode, array(
"create",
"add_file")))
339 else if (in_array($a_mode, array(
"select_file")))
344 if(isset(
$_GET[
"file_ref_id"]))
346 include_once(
"./Modules/File/classes/class.ilObjFile.php");
348 if (is_object($file_obj))
352 $hi->setValue((
int) $_GET[
"file_ref_id"]);
355 $ne->setValue($file_obj->getTitle());
358 else if(isset(
$_GET[
"fl_wsp_id"]))
361 include_once
"Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
365 include_once(
"./Modules/File/classes/class.ilObjFile.php");
366 $file_obj =
new ilObjFile($node[
"obj_id"],
false);
367 if (is_object($file_obj))
371 $hi->setValue(
"wsp_".(
int) $node[
"obj_id"]);
374 $ne->setValue($file_obj->getTitle());
376 $this->tpl->parseCurrentBlock();
386 $ti->setValue($this->content_obj->getListTitle());
387 $si->setValue($this->content_obj->getLanguage());
388 $form->addCommandButton(
"saveProperties", $lng->txt(
"save"));
389 $form->addCommandButton(
"cancelUpdate", $lng->txt(
"cancel"));
390 $form->setTitle($lng->txt(
"cont_edit_file_list_properties"));
397 $s_lang =
$_SESSION[
"il_text_lang_".$_GET[
"ref_id"]];
401 $s_lang = $ilUser->getLanguage();
403 $si->setValue($s_lang);
404 $form->addCommandButton(
"create_flst", $lng->txt(
"save"));
405 $form->addCommandButton(
"cancelCreate", $lng->txt(
"cancel"));
406 $form->setTitle($lng->txt(
"cont_insert_file_list"));
410 $form->addCommandButton(
"insertNewFileItem", $lng->txt(
"save"));
411 $form->addCommandButton(
"editFiles", $lng->txt(
"cancel"));
412 $form->setTitle($lng->txt(
"cont_insert_file_item"));
416 $form->setFormAction($ilCtrl->getFormAction($this));
429 $this->updated = $this->pg_obj->update();
430 if ($this->updated ===
true)
432 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
436 $this->pg_obj->addHierIDs();
450 $ilToolbar->addButton($lng->txt(
"cont_add_file"),
451 $ilCtrl->getLinkTarget($this,
"addFileItem"));
453 include_once(
"./Services/COPage/classes/class.ilPCFileListTableGUI.php");
455 $tpl->setContent($table_gui->getHTML());
469 $ilCtrl->setParameter($this,
"subCmd",
"insertNew");
470 $ilTabs->addSubTabTarget(
"cont_new_file",
471 $ilCtrl->getLinkTarget($this,
$cmd),
$cmd);
473 $ilCtrl->setParameter($this,
"subCmd",
"insertFromRepository");
474 $ilTabs->addSubTabTarget(
"cont_file_from_repository",
475 $ilCtrl->getLinkTarget($this,
$cmd),
$cmd);
476 $ilCtrl->setParameter($this,
"subCmd",
"");
478 if(!$ilSetting->get(
"disable_personal_workspace") &&
479 !$ilSetting->get(
"disable_wsp_files"))
481 $ilCtrl->setParameter($this,
"subCmd",
"insertFromWorkspace");
482 $ilTabs->addSubTabTarget(
"cont_file_from_workspace",
483 $ilCtrl->getLinkTarget($this,
$cmd),
$cmd);
484 $ilCtrl->setParameter($this,
"subCmd",
"");
489 $ilTabs->setBackTarget($lng->txt(
"pg"),
490 $this->ctrl->getParentReturn($this));
492 $ilTabs->addTarget(
"cont_ed_edit_files",
493 $ilCtrl->getLinkTarget($this,
"editFiles"),
"editFiles",
496 $ilTabs->addTarget(
"cont_ed_edit_prop",
497 $ilCtrl->getLinkTarget($this,
"edit"),
"edit",
511 $files = $this->content_obj->getFileList();
513 if (count($files) >= 1)
515 $ilCtrl->setParameterByClass(
"ilpcfileitemgui",
"hier_id",
516 $files[count($files) - 1][
"hier_id"]);
517 $ilCtrl->setParameterByClass(
"ilpcfileitemgui",
"pc_id",
518 $files[count($files) - 1][
"pc_id"]);
519 $ilCtrl->redirectByClass(
"ilpcfileitemgui",
"newItemAfter");
523 $ilCtrl->redirect($this,
"newFileItem");
534 if (is_array(
$_POST[
"fid"]))
537 foreach(
$_POST[
"fid"] as $k => $v)
541 $this->content_obj->deleteFileItems($ids);
543 $this->updated = $this->pg_obj->update();
544 $ilCtrl->redirect($this,
"editFiles");
554 if (is_array(
$_POST[
"position"]))
556 $this->content_obj->savePositions(
$_POST[
"position"]);
558 $this->updated = $this->pg_obj->update();
559 $ilCtrl->redirect($this,
"editFiles");
569 if (is_array(
$_POST[
"position"]))
571 $this->content_obj->savePositions(
$_POST[
"position"]);
573 if (is_array(
$_POST[
"class"]))
575 $this->content_obj->saveStyleClasses(
$_POST[
"class"]);
577 $this->updated = $this->pg_obj->update();
578 $ilCtrl->redirect($this,
"editFiles");
589 $classes = $this->content_obj->getAllClasses();
590 if (count($chars) > 1)
594 foreach ($classes as $class)
596 if ($class !=
"" && $class !=
"FileListItem")
620 if (
$_GET[
"subCmd"] ==
"insertNew")
622 $_SESSION[
"cont_file_insert"] =
"insertNew";
624 if (
$_GET[
"subCmd"] ==
"insertFromRepository")
626 $_SESSION[
"cont_file_insert"] =
"insertFromRepository";
628 if (
$_GET[
"subCmd"] ==
"insertFromWorkspace")
630 $_SESSION[
"cont_file_insert"] =
"insertFromWorkspace";
632 if ((
$_GET[
"subCmd"] ==
"") &&
$_SESSION[
"cont_file_insert"] !=
"")
637 switch (
$_GET[
"subCmd"])
639 case "insertFromWorkspace":
643 case "insertFromRepository":
653 $ilTabs->setSubTabActive(
"cont_new_file");
658 $this->tpl->setContent($form->getHTML());
671 if(isset(
$_GET[
"fl_wsp_id"]))
674 include_once
"Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
678 include_once(
"./Modules/File/classes/class.ilObjFile.php");
679 $file_obj =
new ilObjFile($node[
"obj_id"],
false);
682 else if ($a_file_ref_id == 0)
689 include_once(
"./Modules/File/classes/class.ilObjFile.php");
690 $file_obj =
new ilObjFile($a_file_ref_id);
692 if (is_object($file_obj))
694 $this->content_obj->appendItem($file_obj->getId(),
695 $file_obj->getTitle(), $file_obj->getFileType());
696 $this->updated = $this->pg_obj->update();
697 if ($this->updated ===
true)
700 $this->ctrl->redirect($this,
"editFiles");
704 $_GET[
"subCmd"] =
"-";
715 if ($_FILES[
"file"][
"name"] ==
"")
717 $_GET[
"subCmd"] =
"-";
721 include_once(
"./Modules/File/classes/class.ilObjFile.php");
723 $fileObj->setType(
"file");
724 $fileObj->setTitle($_FILES[
"file"][
"name"]);
725 $fileObj->setDescription(
"");
726 $fileObj->setFileName($_FILES[
"file"][
"name"]);
727 $fileObj->setFileType($_FILES[
"file"][
"type"]);
728 $fileObj->setFileSize($_FILES[
"file"][
"size"]);
729 $fileObj->setMode(
"filelist");
731 $fileObj->raiseUploadError(
false);
733 $fileObj->createDirectory();
734 $fileObj->getUploadFile($_FILES[
"file"][
"tmp_name"],
735 $_FILES[
"file"][
"name"]);
748 $ilTabs->addTarget(
"cont_back",
749 $this->ctrl->getParentReturn($this),
"",
754 $ilCtrl->setParameter($this,
"subCmd",
"insertNew");
755 $ilTabs->addSubTabTarget(
"cont_new_file",
756 $ilCtrl->getLinkTarget($this, $a_cmd), $a_cmd);
758 $ilCtrl->setParameter($this,
"subCmd",
"insertFromRepository");
759 $ilTabs->addSubTabTarget(
"cont_file_from_repository",
760 $ilCtrl->getLinkTarget($this, $a_cmd), $a_cmd);
761 $ilCtrl->setParameter($this,
"subCmd",
"");
763 if(!$ilSetting->get(
"disable_personal_workspace") &&
764 !$ilSetting->get(
"disable_wsp_files"))
766 $ilCtrl->setParameter($this,
"subCmd",
"insertFromWorkspace");
767 $ilTabs->addSubTabTarget(
"cont_file_from_workspace",
768 $ilCtrl->getLinkTarget($this, $a_cmd), $a_cmd);
769 $ilCtrl->setParameter($this,
"subCmd",
"");