ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 $DIC;
214  $ilTabs = $DIC['ilTabs'];
215  $lng = $DIC['lng'];
216  $tpl = $DIC['tpl'];
217 
218  $ilTabs->activateTab("content");
219 
220  $this->setGuiClass($gui_class);
222  $this->setPermCreateFolders($perm_create_folder);
228 
229  try {
230  ilCloudConnector::checkServiceActive($this->getGUIClass()->object->getServiceName());
231  $this->beforeInitGUI();
232 
233  //if($this->getPluginObject()->getAsyncDrawing())
234  {
235  $tpl->addJavaScript("./Modules/Cloud/js/ilCloudFileList.js");
236  $tpl->addJavaScript("./Modules/Cloud/js/jquery.address.js");
237  $tpl->addJavascript("./Services/UIComponent/AdvancedSelectionList/js/AdvancedSelectionList.js");
238  $tpl->addCss("./Modules/Cloud/templates/css/cloud.css");
239 
240  include_once("./Services/YUI/classes/class.ilYuiUtil.php");
242 
243  $this->tpl_file_tree = new ilTemplate("tpl.cloud_file_tree.html", true, true, "Modules/Cloud");
244 
245  $file_tree = new ilCloudFileTree($this->getGUIClass()->object->getRootFolder(), $this->getGUIClass()->object->getRootId(), $this->getGUIClass()->object->getId(), $this->getGUIClass()->object->getServiceName());
246  $file_tree->storeFileTreeToSession();
247 
248  $this->addToolbar($file_tree->getRootNode());
249 
250  $this->tpl_file_tree->setVariable("ASYNC_GET_BLOCK", json_encode($this->getGUIClass()->getCtrl()->getLinkTargetByClass("ilobjcloudgui", "asyncGetBlock", true)));
251  $this->tpl_file_tree->setVariable("ASYNC_CREATE_FOLDER", json_encode($this->getGUIClass()->getCtrl()->getLinkTargetByClass("ilcloudplugincreatefoldergui", "asyncCreateFolder", true)));
252  $this->tpl_file_tree->setVariable("ASYNC_UPLOAD_FILE", json_encode($this->getGUIClass()->getCtrl()->getLinkTargetByClass("ilcloudpluginuploadgui", "asyncUploadFile", true)));
253  $this->tpl_file_tree->setVariable("ASYNC_DELETE_ITEM", json_encode($this->getGUIClass()->getCtrl()->getLinkTargetByClass("ilcloudplugindeletegui", "asyncDeleteItem", true)));
254  $this->tpl_file_tree->setVariable("ROOT_ID", json_encode($file_tree->getRootNode()->getId()));
255  $this->tpl_file_tree->setVariable("ROOT_PATH", json_encode($file_tree->getRootNode()->getPath()));
256  if (isset($_POST["path"])) {
257  $this->tpl_file_tree->setVariable("CURRENT_PATH", json_encode($_POST["path"]));
258  $file_tree->updateFileTree($_POST["path"]);
259  $node = $file_tree->getNodeFromPath($_POST["path"]);
260  $this->tpl_file_tree->setVariable("CURRENT_ID", json_encode($node->getId()));
261  } else {
262  $this->tpl_file_tree->setVariable("CURRENT_PATH", json_encode($file_tree->getRootNode()->getPath()));
263  $this->tpl_file_tree->setVariable("CURRENT_ID", json_encode($file_tree->getRootNode()->getID()));
264  }
265  $txt_max_file_size = $lng->txt("file_notice") . " "
266  . ilCloudConnector::getPluginClass($this->getGUIClass()->object->getServiceName(), $this->getGUIClass()->object->getId())
267  ->getMaxFileSize() . " MB";
268  $this->tpl_file_tree->setVariable("MAX_FILE_SIZE", json_encode($txt_max_file_size));
269  $this->beforeSetContent();
270  $tpl->setContent($this->tpl_file_tree->get());
271  $tpl->setPermanentLink("cld", $this->getGuiClass()->object->getRefId(), "_path__endPath");
272  }
273 
298  $this->afterInitGUI();
299  } catch (Exception $e) {
300  if ($e->getCode() == ilCloudException::AUTHENTICATION_FAILED) {
301  $this->getGUIClass()->object->setAuthComplete(false);
302  $this->getGUIClass()->object->doUpdate();
303  }
304  ilUtil::sendFailure($e->getMessage());
305  }
306  }
307 
308 
312  public function addToolbar($root_node) {
313  global $DIC;
314  $lng = $DIC['lng'];
315  $ilToolbar = $DIC['ilToolbar'];
316  $ilLog = $DIC['ilLog'];
317 
318  $create_list_gui = ilCloudConnector::getItemCreationListGUIClass($this->getService());
319 
320  $list_gui_html = $create_list_gui->getGroupedListItemsHTML($this->getPermUploadItems(), $this->getPermCreateFolders());
321  if ($list_gui_html) {
322  //toolbar
323  $toolbar_locator = new ilLocatorGUI();
324  $toolbar_locator->addItem($this->getGuiClass()->object->getTitle(), ilCloudPluginFileTreeGUI::getLinkToFolder($root_node));
325  $ilToolbar->setId('xcld_toolbar');
326  $ilToolbar->addText("<div class='xcld_locator'>" . $toolbar_locator->getHtml() . "</div>");
327  $ilToolbar->addSeparator();
328 
329  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
330  $adv = new ilAdvancedSelectionListGUI();
331  $adv->setListTitle($lng->txt("cld_add_new_item"));
332 
333  $ilCloudGroupedListGUI = $create_list_gui->getGroupedListItems($this->getPermUploadItems(), $this->getPermCreateFolders());
334 
335  if ($ilCloudGroupedListGUI->hasItems()) {
336  $adv->setGroupedList($ilCloudGroupedListGUI);
337  }
338 
340  $ilToolbar->addText($adv->getHTML());
341  }
342  }
343 
344 
345  public function beforeInitGUI() { }
346 
347 
348  public function beforeSetContent() { }
349 
350 
351  public function afterInitGUI() { }
352 }
setPermDeleteFolders($perm_delete_folders)
static initConnection()
Init YUI Connection module.
setPermDeleteFiles($perm_delete_files)
ilCloudFileTree class
initGUI(ilObjCloudGUI $gui_class, $perm_create_folder, $perm_upload_items, $perm_delete_files, $perm_delete_folders, $perm_download, $perm_files_visible, $perm_folders_visible)
Class ilObjCloudGUI.
global $tpl
Definition: ilias.php:8
locator handling class
setPermFilesVisible($perm_files_visible)
setPermCreateFolders($perm_create_folders)
Class ilCloudPluginInitGUI.
special template class to simplify handling of ITX/PEAR
static getPluginClass($service_name, $obj_id)
static checkServiceActive($name)
static getLinkToFolder(ilCloudFileNode $node)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
User interface class for advanced drop-down selection lists.
Create new PHPExcel object
obj_idprivate
global $lng
Definition: privfeed.php:17
global $DIC
static getItemCreationListGUIClass(ilCloudPluginService $plugin_service_class)
$_POST["username"]
setPermFoldersVisible($perm_folders_visible)
setPermUploadItems($perm_upload_items)
Class ilCloudPluginGUI.