ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilCloudPluginInitGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("class.ilCloudPluginGUI.php");
5 
17 
21  protected $gui_class = NULL;
25  protected $perm_upload_items = false;
29  protected $perm_create_folders = false;
33  protected $perm_delete_files = false;
37  protected $perm_delete_folders = false;
41  protected $perm_download = false;
45  protected $perm_files_visible = false;
49  protected $perm_folders_visible = false;
50 
51 
55  public function setGuiClass($gui_class) {
56  $this->gui_class = $gui_class;
57  }
58 
59 
63  public function getGuiClass() {
64  return $this->gui_class;
65  }
66 
67 
72  $this->perm_create_folders = $perm_create_folders;
73  }
74 
75 
79  public function getPermCreateFolders() {
81  }
82 
83 
88  $this->perm_delete_files = $perm_delete_files;
89  }
90 
91 
95  public function getPermDeleteFiles() {
97  }
98 
99 
104  $this->perm_delete_folders = $perm_delete_folders;
105  }
106 
107 
111  public function getPermDeleteFolders() {
113  }
114 
115 
119  public function setPermDownload($perm_download) {
120  $this->perm_download = $perm_download;
121  }
122 
123 
127  public function getPermDownload() {
128  return $this->perm_download;
129  }
130 
131 
136  $this->perm_files_visible = $perm_files_visible;
137  }
138 
139 
143  public function getPermFilesVisible() {
145  }
146 
147 
152  $this->perm_folders_visible = $perm_folders_visible;
153  }
154 
155 
159  public function getPermFoldersVisible() {
161  }
162 
163 
168  $this->perm_upload_items = $perm_upload_items;
169  }
170 
171 
175  public function getPermUploadItems() {
177  }
178 
179 
183  public function setTplFileTree($tpl_file_tree) {
184  $this->tpl_file_tree = $tpl_file_tree;
185  }
186 
187 
191  public function getTplFileTree() {
192  return $this->tpl_file_tree;
193  }
194 
195 
199  protected $tpl_file_tree = NULL;
200 
201 
213  global $ilTabs, $lng, $tpl;
214 
215  $ilTabs->activateTab("content");
216 
217  $this->setGuiClass($gui_class);
219  $this->setPermCreateFolders($perm_create_folder);
225 
226  try {
227  ilCloudConnector::checkServiceActive($this->getGUIClass()->object->getServiceName());
228  $this->beforeInitGUI();
229 
230  //if($this->getPluginObject()->getAsyncDrawing())
231  {
232  $tpl->addJavaScript("./Modules/Cloud/js/ilCloudFileList.js");
233  $tpl->addJavaScript("./Modules/Cloud/js/jquery.address.js");
234  $tpl->addJavascript("./Services/UIComponent/AdvancedSelectionList/js/AdvancedSelectionList.js");
235  $tpl->addCss("./Modules/Cloud/templates/css/cloud.css");
236 
237  include_once("./Services/YUI/classes/class.ilYuiUtil.php");
239 
240  $this->tpl_file_tree = new ilTemplate("tpl.cloud_file_tree.html", true, true, "Modules/Cloud");
241 
242  $file_tree = new ilCloudFileTree($this->getGUIClass()->object->getRootFolder(), $this->getGUIClass()->object->getRootId(), $this->getGUIClass()->object->getId(), $this->getGUIClass()->object->getServiceName());
243  $file_tree->storeFileTreeToSession();
244 
245  $this->addToolbar($file_tree->getRootNode());
246 
247  $this->tpl_file_tree->setVariable("ASYNC_GET_BLOCK", json_encode($this->getGUIClass()->ctrl->getLinkTargetByClass("ilobjcloudgui", "asyncGetBlock", true)));
248  $this->tpl_file_tree->setVariable("ASYNC_CREATE_FOLDER", json_encode($this->getGUIClass()->ctrl->getLinkTargetByClass("ilcloudplugincreatefoldergui", "asyncCreateFolder", true)));
249  $this->tpl_file_tree->setVariable("ASYNC_UPLOAD_FILE", json_encode($this->getGUIClass()->ctrl->getLinkTargetByClass("ilcloudpluginuploadgui", "asyncUploadFile", true)));
250  $this->tpl_file_tree->setVariable("ASYNC_DELETE_ITEM", json_encode($this->getGUIClass()->ctrl->getLinkTargetByClass("ilcloudplugindeletegui", "asyncDeleteItem", true)));
251  $this->tpl_file_tree->setVariable("ROOT_ID", json_encode($file_tree->getRootNode()->getId()));
252  $this->tpl_file_tree->setVariable("ROOT_PATH", json_encode($file_tree->getRootNode()->getPath()));
253  if (isset($_POST["path"])) {
254  $this->tpl_file_tree->setVariable("CURRENT_PATH", json_encode($_POST["path"]));
255  $file_tree->updateFileTree($_POST["path"]);
256  $node = $file_tree->getNodeFromPath($_POST["path"]);
257  $this->tpl_file_tree->setVariable("CURRENT_ID", json_encode($node->getId()));
258  } else {
259  $this->tpl_file_tree->setVariable("CURRENT_PATH", json_encode($file_tree->getRootNode()->getPath()));
260  $this->tpl_file_tree->setVariable("CURRENT_ID", json_encode($file_tree->getRootNode()->getID()));
261  }
262  $txt_max_file_size = $lng->txt("file_notice") . " "
263  . ilCloudConnector::getPluginClass($this->getGUIClass()->object->getServiceName(), $this->getGUIClass()->object->getId())
264  ->getMaxFileSize() . " MB";
265  $this->tpl_file_tree->setVariable("MAX_FILE_SIZE", json_encode($txt_max_file_size));
266  $this->beforeSetContent();
267  $tpl->setContent($this->tpl_file_tree->get());
268  $tpl->setPermanentLink("cld", $this->getGuiClass()->object->getRefId(), "_path__endPath");
269  }
270 
295  $this->afterInitGUI();
296  } catch (Exception $e) {
297  if ($e->getCode() == ilCloudException::AUTHENTICATION_FAILED) {
298  $this->getGUIClass()->object->setAuthComplete(false);
299  $this->getGUIClass()->object->doUpdate();
300  }
301  ilUtil::sendFailure($e->getMessage());
302  }
303  }
304 
305 
309  public function addToolbar($root_node) {
310  global $lng, $ilToolbar, $ilLog;
311 
312  $create_list_gui = ilCloudConnector::getItemCreationListGUIClass($this->getService());
313 
314  $list_gui_html = $create_list_gui->getGroupedListItemsHTML($this->getPermUploadItems(), $this->getPermCreateFolders());
315  if ($list_gui_html) {
316  //toolbar
317  $toolbar_locator = new ilLocatorGUI();
318  $toolbar_locator->addItem($this->getGuiClass()->object->getTitle(), ilCloudPluginFileTreeGUI::getLinkToFolder($root_node));
319  $ilToolbar->setId('xcld_toolbar');
320  $ilToolbar->addText("<div class='xcld_locator'>" . $toolbar_locator->getHtml() . "</div>");
321  $ilToolbar->addSeparator();
322 
323  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
324  $adv = new ilAdvancedSelectionListGUI();
325  $adv->setListTitle($lng->txt("cld_add_new_item"));
326 
327  $ilCloudGroupedListGUI = $create_list_gui->getGroupedListItems($this->getPermUploadItems(), $this->getPermCreateFolders());
328 
329  if ($ilCloudGroupedListGUI->hasItems()) {
330  $adv->setGroupedList($ilCloudGroupedListGUI);
331  }
332 
334  $ilToolbar->addText($adv->getHTML());
335  }
336  }
337 
338 
339  public function beforeInitGUI() { }
340 
341 
342  public function beforeSetContent() { }
343 
344 
345  public function afterInitGUI() { }
346 }
347 
348 ?>