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