ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
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 
4 include_once("./Services/JSON/classes/class.ilJsonUtil.php");
5 include_once("./Modules/Cloud/exceptions/class.ilCloudException.php");
6 
20 {
21 
22  function asyncCreateFolder()
23  {
24  global $tpl;
25  $response = new stdClass();
26  $response->success = null;
27  $response->error = null;
28  $response->message = null;
29 
30  try
31  {
32  $this->initCreateFolder();
33  $response->content = $this->form->getHTML();
34  $response->success = true;
35 
36  } catch (Exception $e)
37  {
38  $response->message = $tpl->getMessageHTML($e->getMessage(), "failure");
39  }
40  header('Content-type: application/json');
41  echo ilJsonUtil::encode($response);
42  exit;
43  }
44 
50  public function initCreateFolder()
51  {
52  global $ilCtrl, $lng;
53 
54  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
55  $this->form = new ilPropertyFormGUI();
56  $this->form->setId("cld_create_folder");
57 
58  $name = new ilTextInputGUI($lng->txt("cld_folder_name"), "folder_name");
59  $name->setRequired(true);
60  $this->form->addItem($name);
61 
62  // folder id
63  $id = new ilHiddenInputGUI("parent_folder_id");
64  $id->setValue($_POST["id"]);
65  $this->form->addItem($id);
66 
67 
68  $this->form->addCommandButton("createFolder", $lng->txt("cld_create_folder"));
69  $this->form->addCommandButton("cancel", $lng->txt("cancel"));
70 
71  $this->form->setTitle($lng->txt("cld_create_folder"));
72  $this->form->setFormAction($ilCtrl->getFormAction($this));
73  $this->form->setTarget("cld_blank_target");
74 
75  }
76 
80  public function createFolder()
81  {
82  global $tpl, $lng;
83 
84  $response = new stdClass();
85  $response->success = null;
86  $response->message = null;
87  $response->folder_id = null;
88  try
89  {
90  $response->status = "done";
91  include_once("class.ilCloudFileTree.php");
93  $new_node = $file_tree->addFolderToService($_POST["parent_folder_id"], $_POST["folder_name"]);
94  $response->folder_id = $new_node->getId();
95  $response->folder_path = $new_node->getPath();
96  $response->success = true;
97  $response->message = $tpl->getMessageHTML($lng->txt("cld_folder_created"), "success");
98  } catch(Exception $e)
99  {
100  $response->message = $tpl->getMessageHTML($e->getMessage(), "failure");
101  }
102  echo "<script language='javascript' type='text/javascript'>window.parent.il.CloudFileList.afterCreateFolder(" . ilJsonUtil::encode($response) . ");</script>";
103  exit;
104 
105  }
106 
110  public function cancel()
111  {
112  $response = new stdClass();
113  $response->status = "cancel";
114 
115  echo "<script language='javascript' type='text/javascript'>window.parent.il.CloudFileList.afterCreateFolder(".ilJsonUtil::encode($response).");</script>";
116  exit;
117 
118  }
119 }
120 
121 ?>
Class ilCloudPluginCreateFolderGUI.
exit
Definition: login.php:54
$_POST['username']
Definition: cron.php:12
This class represents a property form user interface.
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
This class represents a hidden form property in a property form.
static encode($mixed, $suppress_native=false)
This class represents a text property in a property form.
global $lng
Definition: privfeed.php:40
setRequired($a_required)
Set Required.
Class ilCloudPluginGUI.