ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 {
19 
23  protected $path = "/";
27  protected $id = 0;
31  protected $is_dir;
35  protected $gui;
36 
37 
41  public function asyncDeleteItem()
42  {
43  global $DIC;
44  $tpl = $DIC['tpl'];
45  $lng = $DIC['lng'];
46  $response = new stdClass();
47  $response->success = null;
48  $response->message = null;
49  $response->content = null;
51  try {
52  $node = $file_tree->getNodeFromId($_POST["id"]);
53  if (!$node) {
55  } else {
56  $this->is_dir = $node->getIsDir();
57  }
58 
59  $this->path = $node->getPath();
60  $this->id = $node->getId();
61  if (!$this->is_dir) {
62  $this->path = rtrim($this->path, "/");
63  }
64  $this->initDeleteItem();
65  $response->content = "<div id = 'cld_delete_item' >";
66  if ($this->is_dir) {
67  $response->content .= $tpl->getMessageHTML($lng->txt("cld_confirm_delete_folder"), "question");
68  } else {
69  $response->content .= $tpl->getMessageHTML($lng->txt("cld_confirm_delete_file"), "question");
70  }
71  $response->content .= $this->gui->getHTML();
72  $response->content .= "</div >";
73  $response->success = true;
74  } catch (Exception $e) {
75  $response->message = $tpl->getMessageHTML($e->getMessage(), "failure");
76  }
77  header('Content-type: application/json');
79  exit;
80  }
81 
82 
83  public function initDeleteItem()
84  {
85  global $DIC;
86  $ilCtrl = $DIC['ilCtrl'];
87  $lng = $DIC['lng'];
88 
89  include_once("Services/Utilities/classes/class.ilConfirmationTableGUI.php");
90  $this->gui = new ilConfirmationTableGUI(true);
91  $this->gui->setFormName("cld_delete_item");
92  $this->gui->getTemplateObject()->setVariable("ACTIONTARGET", "cld_blank_target");
93 
94  $this->gui->addCommandButton('deleteItem', $lng->txt('confirm'));
95  $this->gui->addCommandButton('cancel', $lng->txt('cancel'));
96  $this->gui->setFormAction($ilCtrl->getFormAction($this));
97 
98  if ($this->is_dir) {
99  $item[] = array(
100  "var" => 'id',
101  "id" => $this->id,
102  "text" => basename($this->path),
103  "img" => ilUtil::getImagePath('icon_dcl_fold.svg')
104  );
105  } else {
106  $item[] = array(
107  "var" => 'id',
108  "id" => $this->id,
109  "text" => basename($this->path),
110  "img" => ilUtil::getImagePath('icon_dcl_file.svg')
111  );
112  }
113  $this->gui->setData($item);
114  }
115 
116 
120  public function deleteItem()
121  {
122  global $DIC;
123  $tpl = $DIC['tpl'];
124  $lng = $DIC['lng'];
125 
126  $response = new stdClass();
127  $response->success = null;
128  $response->message = null;
129 
130  if (true) {
131  try {
133  $node = $file_tree->getNodeFromId($_POST["id"]);
134  $file_tree->deleteFromService($node->getId());
135  $response->message = $tpl->getMessageHTML($lng->txt("cld_file_deleted"), "success");
136  $response->success = true;
137  } catch (Exception $e) {
138  $response->message = $tpl->getMessageHTML($e->getMessage(), "failure");
139  }
140  }
141  echo "<script language='javascript' type='text/javascript'>window.parent.il.CloudFileList.afterDeleteItem(" . ilJsonUtil::encode($response)
142  . ");</script>";
143  exit;
144  }
145 
146 
150  public function cancel()
151  {
152  $response = new stdClass();
153  $response->status = "cancel";
154 
155  echo "<script language='javascript' type='text/javascript'>window.parent.il.CloudFileList.afterDeleteItem(" . ilJsonUtil::encode($response)
156  . ");</script>";
157  exit;
158  }
159 }
global $DIC
Definition: saml.php:7
$tpl
Definition: ilias.php:10
const ID_DOES_NOT_EXIST_IN_FILE_TREE_IN_SESSION
global $ilCtrl
Definition: ilias.php:18
static encode($mixed, $suppress_native=false)
$lng
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
asyncDeleteItem()
is called async and prints the content from the confirmation gui
exit
Definition: backend.php:16
Class ilCloudPluginDeleteGUI.
Class ilCloudException.
$response
$_POST["username"]
Class ilCloudPluginGUI.