ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilCloudPluginCreateFolderGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("./Services/JSON/classes/class.ilJsonUtil.php");
5include_once("./Modules/Cloud/exceptions/class.ilCloudException.php");
6
20{
21
23 {
24 global $DIC;
25 $tpl = $DIC['tpl'];
26 $response = new stdClass();
27 $response->success = null;
28 $response->error = null;
29 $response->message = null;
30
31 try
32 {
33 $this->initCreateFolder();
34 $response->content = $this->form->getHTML();
35 $response->success = true;
36
37 } catch (Exception $e)
38 {
39 $response->message = $tpl->getMessageHTML($e->getMessage(), "failure");
40 }
41 header('Content-type: application/json');
42 echo ilJsonUtil::encode($response);
43 exit;
44 }
45
51 public function initCreateFolder()
52 {
53 global $DIC;
54 $ilCtrl = $DIC['ilCtrl'];
55 $lng = $DIC['lng'];
56
57 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
58 $this->form = new ilPropertyFormGUI();
59 $this->form->setId("cld_create_folder");
60
61 $name = new ilTextInputGUI($lng->txt("cld_folder_name"), "folder_name");
62 $name->setRequired(true);
63 $this->form->addItem($name);
64
65 // folder id
66 $id = new ilHiddenInputGUI("parent_folder_id");
67 $id->setValue($_POST["id"]);
68 $this->form->addItem($id);
69
70
71 $this->form->addCommandButton("createFolder", $lng->txt("cld_create_folder"));
72 $this->form->addCommandButton("cancel", $lng->txt("cancel"));
73
74 $this->form->setTitle($lng->txt("cld_create_folder"));
75 $this->form->setFormAction($ilCtrl->getFormAction($this));
76 $this->form->setTarget("cld_blank_target");
77
78 }
79
83 public function createFolder()
84 {
85 global $DIC;
86 $tpl = $DIC['tpl'];
87 $lng = $DIC['lng'];
88
89 $response = new stdClass();
90 $response->success = null;
91 $response->message = null;
92 $response->folder_id = null;
93 try
94 {
95 $response->status = "done";
96 include_once("class.ilCloudFileTree.php");
98 $new_node = $file_tree->addFolderToService($_POST["parent_folder_id"], $_POST["folder_name"]);
99 $response->folder_id = $new_node->getId();
100 $response->folder_path = $new_node->getPath();
101 $response->success = true;
102 $response->message = $tpl->getMessageHTML($lng->txt("cld_folder_created"), "success");
103 } catch(Exception $e)
104 {
105 $response->message = $tpl->getMessageHTML($e->getMessage(), "failure");
106 }
107 echo "<script language='javascript' type='text/javascript'>window.parent.il.CloudFileList.afterCreateFolder(" . ilJsonUtil::encode($response) . ");</script>";
108 exit;
109
110 }
111
115 public function cancel()
116 {
117 $response = new stdClass();
118 $response->status = "cancel";
119
120 echo "<script language='javascript' type='text/javascript'>window.parent.il.CloudFileList.afterCreateFolder(".ilJsonUtil::encode($response).");</script>";
121 exit;
122
123 }
124}
125
126?>
global $tpl
Definition: ilias.php:8
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
Class ilCloudPluginCreateFolderGUI.
Class ilCloudPluginGUI.
This class represents a hidden form property in a property form.
static encode($mixed, $suppress_native=false)
This class represents a property form user interface.
This class represents a text property in a property form.
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17
global $DIC