ILIAS  Release_4_4_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 
19 {
20  protected $path = "/";
21  protected $id = 0;
22  protected $is_dir;
23 
24 
25  function asyncDeleteItem()
26  {
27  global $tpl, $lng;
28  $response = new stdClass();
29  $response->success = null;
30  $response->message = null;
31  $response->content = null;
33  try
34  {
35  $node = $file_tree->getNodeFromId($_POST["id"]);
36  if(!$node)
37  {
39  }
40  else
41  {
42  $this->is_dir = $node->getIsDir();
43  }
44 
45  $this->path = $node->getPath();
46  $this->id = $node->getId();
47  if(!$this->is_dir)
48  {
49  $this->path = rtrim($this->path, "/");
50  }
51  $this->initDeleteItem();
52  $response->content = "<div id = 'cld_delete_item' >";
53  if($this->is_dir)
54  {
55  $response->content .= $tpl->getMessageHTML($lng->txt("cld_confirm_delete_folder"), "question");
56  }
57  else
58  {
59  $response->content .= $tpl->getMessageHTML($lng->txt("cld_confirm_delete_file"), "question");
60  }
61  $response->content .= $this->gui->getHTML();
62  $response->content .= "</div >";
63  $response->success = true;
64 
65  } catch (Exception $e)
66  {
67  $response->message = $tpl->getMessageHTML($e->getMessage(), "failure");
68  }
69  header('Content-type: application/json');
70  echo ilJsonUtil::encode($response);
71  exit;
72 
73  }
74 
75  public function initDeleteItem()
76  {
77  global $ilCtrl, $lng;
78 
79  include_once("Services/Utilities/classes/class.ilConfirmationTableGUI.php");
80  $this->gui = new ilConfirmationTableGUI(true);
81  $this->gui->setFormName("cld_delete_item");
82  $this->gui->getTemplateObject()->setVariable("ACTIONTARGET","cld_blank_target");
83 
84  $this->gui->addCommandButton('deleteItem', $lng->txt('confirm'));
85  $this->gui->addCommandButton('cancel', $lng->txt('cancel'));
86  $this->gui->setFormAction($ilCtrl->getFormAction($this));
87 
88  if($this->is_dir)
89  {
90  $item[] = array("var" => 'id', "id" => $this->id, "text" => basename($this->path), "img" => "/Modules/Cloud/templates/images/icon_folder.png");
91  }
92  else
93  {
94  $item[] = array("var" => 'id', "id" => $this->id, "text" => basename($this->path), "img" => "/Modules/Cloud/templates/images/icon_file.png");
95  }
96  $this->gui->setData($item);
97  }
98 
102  public function deleteItem()
103  {
104  global $tpl, $lng;
105 
106  $response = new stdClass();
107  $response->success = null;
108  $response->message = null;
109 
110  if (true)
111  {
112  try
113  {
115  $node = $file_tree->getNodeFromId($_POST["id"]);
116  $file_tree->deleteFromService($node->getId());
117  $response->message = $tpl->getMessageHTML($lng->txt("cld_file_deleted"), "success");
118  $response->success = true;
119  } catch (Exception $e)
120  {
121  $response->message = $tpl->getMessageHTML($e->getMessage(), "failure");
122  }
123  }
124  echo "<script language='javascript' type='text/javascript'>window.parent.il.CloudFileList.afterDeleteItem(" . ilJsonUtil::encode($response) . ");</script>";
125  exit;
126 
127  }
128 
132  public function cancel()
133  {
134  $response = new stdClass();
135  $response->status = "cancel";
136 
137  echo "<script language='javascript' type='text/javascript'>window.parent.il.CloudFileList.afterDeleteItem(" . ilJsonUtil::encode($response) . ");</script>";
138  exit;
139 
140  }
141 
142 }
143 
144 ?>