ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilCloudPluginDeleteGUI.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/Form/classes/class.ilPropertyFormGUI.php");
5 include_once("./Modules/Cloud/exceptions/class.ilCloudException.php");
6 
18 
22  protected $path = "/";
26  protected $id = 0;
30  protected $is_dir;
34  protected $gui;
35 
36 
40  public function asyncDeleteItem() {
41  global $tpl, $lng;
42  $response = new stdClass();
43  $response->success = null;
44  $response->message = null;
45  $response->content = null;
47  try {
48  $node = $file_tree->getNodeFromId($_POST["id"]);
49  if (!$node) {
51  } else {
52  $this->is_dir = $node->getIsDir();
53  }
54 
55  $this->path = $node->getPath();
56  $this->id = $node->getId();
57  if (!$this->is_dir) {
58  $this->path = rtrim($this->path, "/");
59  }
60  $this->initDeleteItem();
61  $response->content = "<div id = 'cld_delete_item' >";
62  if ($this->is_dir) {
63  $response->content .= $tpl->getMessageHTML($lng->txt("cld_confirm_delete_folder"), "question");
64  } else {
65  $response->content .= $tpl->getMessageHTML($lng->txt("cld_confirm_delete_file"), "question");
66  }
67  $response->content .= $this->gui->getHTML();
68  $response->content .= "</div >";
69  $response->success = true;
70  } catch (Exception $e) {
71  $response->message = $tpl->getMessageHTML($e->getMessage(), "failure");
72  }
73  header('Content-type: application/json');
74  echo ilJsonUtil::encode($response);
75  exit;
76  }
77 
78 
79  public function initDeleteItem() {
80  global $ilCtrl, $lng;
81 
82  include_once("Services/Utilities/classes/class.ilConfirmationTableGUI.php");
83  $this->gui = new ilConfirmationTableGUI(true);
84  $this->gui->setFormName("cld_delete_item");
85  $this->gui->getTemplateObject()->setVariable("ACTIONTARGET", "cld_blank_target");
86 
87  $this->gui->addCommandButton('deleteItem', $lng->txt('confirm'));
88  $this->gui->addCommandButton('cancel', $lng->txt('cancel'));
89  $this->gui->setFormAction($ilCtrl->getFormAction($this));
90 
91  if ($this->is_dir) {
92  $item[] = array(
93  "var" => 'id',
94  "id" => $this->id,
95  "text" => basename($this->path),
96  "img" => ilUtil::getImagePath('icon_dcl_fold.svg')
97  );
98  } else {
99  $item[] = array(
100  "var" => 'id',
101  "id" => $this->id,
102  "text" => basename($this->path),
103  "img" => ilUtil::getImagePath('icon_dcl_file.svg')
104  );
105  }
106  $this->gui->setData($item);
107  }
108 
109 
113  public function deleteItem() {
114  global $tpl, $lng;
115 
116  $response = new stdClass();
117  $response->success = null;
118  $response->message = null;
119 
120  if (true) {
121  try {
123  $node = $file_tree->getNodeFromId($_POST["id"]);
124  $file_tree->deleteFromService($node->getId());
125  $response->message = $tpl->getMessageHTML($lng->txt("cld_file_deleted"), "success");
126  $response->success = true;
127  } catch (Exception $e) {
128  $response->message = $tpl->getMessageHTML($e->getMessage(), "failure");
129  }
130  }
131  echo "<script language='javascript' type='text/javascript'>window.parent.il.CloudFileList.afterDeleteItem(" . ilJsonUtil::encode($response)
132  . ");</script>";
133  exit;
134  }
135 
136 
140  public function cancel() {
141  $response = new stdClass();
142  $response->status = "cancel";
143 
144  echo "<script language='javascript' type='text/javascript'>window.parent.il.CloudFileList.afterDeleteItem(" . ilJsonUtil::encode($response)
145  . ");</script>";
146  exit;
147  }
148 }
149 
150 ?>