4require_once(
"./Services/COPage/classes/class.ilPCFileList.php");
5require_once(
"./Services/COPage/classes/class.ilPageContentGUI.php");
49 public function __construct(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id =
"")
53 $this->
user = $DIC->user();
54 $this->tabs =
$DIC->tabs();
55 $this->ctrl =
$DIC->ctrl();
56 $this->tpl =
$DIC[
"tpl"];
57 $this->tree =
$DIC->repositoryTree();
58 $this->lng =
$DIC->language();
59 $this->toolbar =
$DIC->toolbar();
62 $this->
setCharacteristics(array(
"FileListItem" => $this->lng->txt(
"cont_FileListItem")));
71 $next_class = $this->ctrl->getNextClass($this);
76 $cmd = $this->ctrl->getCmd();
78 switch ($next_class) {
90 public function insert($a_form =
null)
95 if (
$_GET[
"subCmd"] ==
"insertNew") {
96 $_SESSION[
"cont_file_insert"] =
"insertNew";
98 if (
$_GET[
"subCmd"] ==
"insertFromRepository") {
99 $_SESSION[
"cont_file_insert"] =
"insertFromRepository";
101 if (
$_GET[
"subCmd"] ==
"insertFromWorkspace") {
102 $_SESSION[
"cont_file_insert"] =
"insertFromWorkspace";
104 if ((
$_GET[
"subCmd"] ==
"") &&
$_SESSION[
"cont_file_insert"] !=
"") {
108 switch (
$_GET[
"subCmd"]) {
109 case "insertFromWorkspace":
113 case "insertFromRepository":
123 $ilTabs->setSubTabActive(
"cont_new_file");
127 if ($a_form !=
null) {
132 $this->tpl->setContent($form->getHTML());
146 $ilTabs->setSubTabActive(
"cont_file_from_repository");
151 $this->tpl->setContent($form->getHTML());
163 if ($a_cmd ==
"insert") {
169 $ilTabs->setSubTabActive(
"cont_file_from_repository");
170 $ilCtrl->setParameter($this,
"subCmd",
"insertFromRepository");
172 include_once(
"./Services/COPage/classes/class.ilPCFileItemFileSelectorGUI.php");
180 if (!$exp->handleCommand()) {
181 $tpl->setContent($exp->getHTML());
196 if ($a_cmd ==
"insert") {
202 $ilTabs->setSubTabActive(
"cont_file_from_workspace");
204 include_once(
"./Services/PersonalWorkspace/classes/class.ilWorkspaceExplorerGUI.php");
206 $ilCtrl->setParameter($this,
"subCmd",
"selectFile");
207 $exp->setCustomLinkTarget($ilCtrl->getLinkTarget($this, $a_cmd));
208 $ilCtrl->setParameter($this,
"subCmd",
"insertFromWorkspace");
209 $exp->setTypeWhiteList(array(
"wsrt",
"wfld",
"file"));
210 $exp->setSelectableTypes(array(
"file"));
211 if ($exp->handleCommand()) {
214 $tpl->setContent($exp->getHTML());
224 include_once(
"./Modules/File/classes/class.ilObjFile.php");
226 $mode = (
$_POST[
"file_ref_id"] !=
"")
230 if (!$form->checkInput()) {
231 $form->setValuesByPost();
237 if (substr(
$_POST[
"file_ref_id"], 0, 4) ==
"wsp_") {
241 elseif (
$_POST[
"file_ref_id"] == 0) {
243 $fileObj->setType(
"file");
244 $fileObj->setTitle($_FILES[
"file"][
"name"]);
245 $fileObj->setDescription(
"");
246 $fileObj->setFileName($_FILES[
"file"][
"name"]);
247 $fileObj->setFileType($_FILES[
"file"][
"type"]);
248 $fileObj->setFileSize($_FILES[
"file"][
"size"]);
249 $fileObj->setMode(
"filelist");
252 $fileObj->createDirectory();
253 $fileObj->raiseUploadError(
false);
255 $upload =
$DIC->upload();
256 if ($upload->hasBeenProcessed() !==
true) {
260 $fileObj->getUploadFile(
261 $_FILES[
"file"][
"tmp_name"],
262 $_FILES[
"file"][
"name"]
273 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
275 $this->content_obj->appendItem(
277 $fileObj->getFileName(),
278 $fileObj->getFileType()
281 $this->updated = $this->pg_obj->update();
282 if ($this->updated ===
true) {
294 $this->pg_obj->stripHierIDs();
295 $this->pg_obj->addHierIDs();
296 $this->ctrl->setParameter($this,
"hier_id", $this->content_obj->readHierId());
297 $this->ctrl->setParameter($this,
"pc_id", $this->content_obj->readPCId());
298 $this->ctrl->redirect($this,
"editFiles");
309 $this->tpl->setContent($form->getHTML());
323 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
326 if ($a_mode !=
"add_file") {
329 $ti->setMaxLength(80);
334 require_once(
"Services/MetaData/classes/class.ilMDLanguageItem.php");
341 if (in_array($a_mode, array(
"create",
"add_file"))) {
344 $fi->setRequired(
true);
346 } elseif (in_array($a_mode, array(
"select_file"))) {
350 if (isset(
$_GET[
"file_ref_id"])) {
351 include_once(
"./Modules/File/classes/class.ilObjFile.php");
353 if (is_object($file_obj)) {
356 $hi->setValue((
int)
$_GET[
"file_ref_id"]);
359 $ne->setValue($file_obj->getTitle());
361 } elseif (isset(
$_GET[
"fl_wsp_id"])) {
363 include_once
"Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
365 $node =
$tree->getNodeData((
int)
$_GET[
"fl_wsp_id"]);
367 include_once(
"./Modules/File/classes/class.ilObjFile.php");
368 $file_obj =
new ilObjFile($node[
"obj_id"],
false);
369 if (is_object($file_obj)) {
372 $hi->setValue(
"wsp_" . (
int) $node[
"obj_id"]);
375 $ne->setValue($file_obj->getTitle());
377 $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"));
398 $s_lang =
$ilUser->getLanguage();
400 $si->setValue($s_lang);
401 $form->addCommandButton(
"create_flst",
$lng->txt(
"save"));
402 $form->addCommandButton(
"cancelCreate",
$lng->txt(
"cancel"));
403 $form->setTitle(
$lng->txt(
"cont_insert_file_list"));
407 $form->addCommandButton(
"insertNewFileItem",
$lng->txt(
"save"));
408 $form->addCommandButton(
"editFiles",
$lng->txt(
"cancel"));
409 $form->setTitle(
$lng->txt(
"cont_insert_file_item"));
413 $form->setFormAction($ilCtrl->getFormAction($this));
424 $this->content_obj->setListTitle(
428 $this->updated = $this->pg_obj->update();
429 if ($this->updated ===
true) {
430 $this->ctrl->returnToParent($this,
"jump" . $this->hier_id);
432 $this->pg_obj->addHierIDs();
449 $ilToolbar->addButton(
450 $lng->txt(
"cont_add_file"),
451 $ilCtrl->getLinkTarget($this,
"addFileItem")
454 include_once(
"./Services/COPage/classes/class.ilPCFileListTableGUI.php");
456 $tpl->setContent($table_gui->getHTML());
472 $ilCtrl->setParameter($this,
"subCmd",
"insertNew");
473 $ilTabs->addSubTabTarget(
475 $ilCtrl->getLinkTarget($this, $cmd),
479 $ilCtrl->setParameter($this,
"subCmd",
"insertFromRepository");
480 $ilTabs->addSubTabTarget(
481 "cont_file_from_repository",
482 $ilCtrl->getLinkTarget($this, $cmd),
485 $ilCtrl->setParameter($this,
"subCmd",
"");
487 if (!
$ilSetting->get(
"disable_personal_workspace") &&
489 $ilCtrl->setParameter($this,
"subCmd",
"insertFromWorkspace");
490 $ilTabs->addSubTabTarget(
491 "cont_file_from_workspace",
492 $ilCtrl->getLinkTarget($this, $cmd),
495 $ilCtrl->setParameter($this,
"subCmd",
"");
498 $ilTabs->setBackTarget(
500 $this->ctrl->getParentReturn($this)
504 "cont_ed_edit_files",
505 $ilCtrl->getLinkTarget($this,
"editFiles"),
512 $ilCtrl->getLinkTarget($this,
"edit"),
527 $files = $this->content_obj->getFileList();
529 if (count($files) >= 1) {
530 $ilCtrl->setParameterByClass(
533 $files[count($files) - 1][
"hier_id"]
535 $ilCtrl->setParameterByClass(
538 $files[count($files) - 1][
"pc_id"]
540 $ilCtrl->redirectByClass(
"ilpcfileitemgui",
"newItemAfter");
542 $ilCtrl->redirect($this,
"newFileItem");
553 if (is_array(
$_POST[
"fid"])) {
555 foreach (
$_POST[
"fid"] as $k => $v) {
558 $this->content_obj->deleteFileItems($ids);
560 $this->updated = $this->pg_obj->update();
561 $ilCtrl->redirect($this,
"editFiles");
571 if (is_array(
$_POST[
"position"])) {
572 $this->content_obj->savePositions(
$_POST[
"position"]);
574 $this->updated = $this->pg_obj->update();
575 $ilCtrl->redirect($this,
"editFiles");
585 if (is_array(
$_POST[
"position"])) {
586 $this->content_obj->savePositions(
$_POST[
"position"]);
588 if (is_array(
$_POST[
"class"])) {
589 $this->content_obj->saveStyleClasses(
$_POST[
"class"]);
591 $this->updated = $this->pg_obj->update();
592 $ilCtrl->redirect($this,
"editFiles");
603 $classes = $this->content_obj->getAllClasses();
604 if (count($chars) > 1) {
607 foreach ($classes as $class) {
608 if ($class !=
"" && $class !=
"FileListItem") {
631 if (
$_GET[
"subCmd"] ==
"insertNew") {
632 $_SESSION[
"cont_file_insert"] =
"insertNew";
634 if (
$_GET[
"subCmd"] ==
"insertFromRepository") {
635 $_SESSION[
"cont_file_insert"] =
"insertFromRepository";
637 if (
$_GET[
"subCmd"] ==
"insertFromWorkspace") {
638 $_SESSION[
"cont_file_insert"] =
"insertFromWorkspace";
640 if ((
$_GET[
"subCmd"] ==
"") &&
$_SESSION[
"cont_file_insert"] !=
"") {
644 switch (
$_GET[
"subCmd"]) {
645 case "insertFromWorkspace":
649 case "insertFromRepository":
659 $ilTabs->setSubTabActive(
"cont_new_file");
664 $this->tpl->setContent($form->getHTML());
677 if (isset(
$_GET[
"fl_wsp_id"])) {
679 include_once
"Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
681 $node =
$tree->getNodeData(
$_GET[
"fl_wsp_id"]);
683 include_once(
"./Modules/File/classes/class.ilObjFile.php");
684 $file_obj =
new ilObjFile($node[
"obj_id"],
false);
687 elseif ($a_file_ref_id == 0) {
692 include_once(
"./Modules/File/classes/class.ilObjFile.php");
693 $file_obj =
new ilObjFile($a_file_ref_id);
695 if (is_object($file_obj)) {
696 $this->content_obj->appendItem(
698 $file_obj->getTitle(),
699 $file_obj->getFileType()
701 $this->updated = $this->pg_obj->update();
702 if ($this->updated ===
true) {
704 $this->ctrl->redirect($this,
"editFiles");
708 $_GET[
"subCmd"] =
"-";
721 if ($_FILES[
"file"][
"name"] ==
"") {
722 $_GET[
"subCmd"] =
"-";
731 include_once(
"./Modules/File/classes/class.ilObjFile.php");
733 $fileObj->setType(
"file");
734 $fileObj->setTitle($_FILES[
"file"][
"name"]);
735 $fileObj->setDescription(
"");
736 $fileObj->setFileName($_FILES[
"file"][
"name"]);
737 $fileObj->setFileType($_FILES[
"file"][
"type"]);
738 $fileObj->setFileSize($_FILES[
"file"][
"size"]);
739 $fileObj->setMode(
"filelist");
742 $fileObj->createDirectory();
744 $upload =
$DIC->upload();
745 if ($upload->hasBeenProcessed() !==
true) {
749 $fileObj->getUploadFile(
750 $_FILES[
"file"][
"tmp_name"],
751 $_FILES[
"file"][
"name"]
769 $this->ctrl->getParentReturn($this),
775 $ilCtrl->setParameter($this,
"subCmd",
"insertNew");
776 $ilTabs->addSubTabTarget(
778 $ilCtrl->getLinkTarget($this, $a_cmd),
782 $ilCtrl->setParameter($this,
"subCmd",
"insertFromRepository");
783 $ilTabs->addSubTabTarget(
784 "cont_file_from_repository",
785 $ilCtrl->getLinkTarget($this, $a_cmd),
788 $ilCtrl->setParameter($this,
"subCmd",
"");
790 if (!
$ilSetting->get(
"disable_personal_workspace") &&
792 $ilCtrl->setParameter($this,
"subCmd",
"insertFromWorkspace");
793 $ilTabs->addSubTabTarget(
794 "cont_file_from_workspace",
795 $ilCtrl->getLinkTarget($this, $a_cmd),
798 $ilCtrl->setParameter($this,
"subCmd",
"");
An exception for terminatinating execution or to throw for unit testing.
This class represents a non editable value in a property form.
Select files for file list.
insertFromRepository($a_cmd="insert")
Insert file from repository.
executeCommand()
execute command
insert($a_form=null)
insert new file list form
setTabs($a_create=true)
Set Tabs.
addFileItem()
Add file item.
insertFromWorkspace($a_cmd="insert")
Insert file from personal workspace.
afterCreation()
After creation processing.
newFileItem()
New file item (called, if there is no file item in an existing)
__construct(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id="")
Constructor @access public.
setItemTabs($a_cmd="")
output tabs
initEditForm($a_mode="edit")
Init edit form.
savePositions()
Save positions of file items.
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
edit()
edit properties form
create()
create new file list in dom and update page in db
deleteFileItem()
Delete file items from list.
createFileItem()
insert new file item
insertNewFileItem($a_file_ref_id=0)
insert new file item after another item
TableGUI class for file list.
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
getCharacteristicsOfCurrentStyle($a_type)
Get characteristics of current style.
displayValidationError()
display validation errors
getCharacteristics()
Get characteristics.
setCharacteristics($a_chars)
Set Characteristics.
This class represents a text property in a property form.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
Explorer for selecting a personal workspace item.
Tree handler for personal workspace.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc