ILIAS  Release_4_4_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 
54  public function setGuiClass($gui_class)
55  {
56  $this->gui_class = $gui_class;
57  }
58 
62  public function getGuiClass()
63  {
64  return $this->gui_class;
65  }
66 
71  {
72  $this->perm_create_folders = $perm_create_folders;
73  }
74 
78  public function getPermCreateFolders()
79  {
81  }
82 
87  {
88  $this->perm_delete_files = $perm_delete_files;
89  }
90 
94  public function getPermDeleteFiles()
95  {
97  }
98 
103  {
104  $this->perm_delete_folders = $perm_delete_folders;
105  }
106 
110  public function getPermDeleteFolders()
111  {
113  }
114 
119  {
120  $this->perm_download = $perm_download;
121  }
122 
126  public function getPermDownload()
127  {
128  return $this->perm_download;
129  }
130 
135  {
136  $this->perm_files_visible = $perm_files_visible;
137  }
138 
142  public function getPermFilesVisible()
143  {
145  }
146 
151  {
152  $this->perm_folders_visible = $perm_folders_visible;
153  }
154 
158  public function getPermFoldersVisible()
159  {
161  }
162 
167  {
168  $this->perm_upload_items = $perm_upload_items;
169  }
170 
174  public function getPermUploadItems()
175  {
177  }
178 
183  {
184  $this->tpl_file_tree = $tpl_file_tree;
185  }
186 
190  public function getTplFileTree()
191  {
192  return $this->tpl_file_tree;
193  }
194 
195 
196 
200  protected $tpl_file_tree = null;
201 
203  {
204  global $ilTabs, $lng, $tpl;
205 
206  $ilTabs->activateTab("content");
207 
208  $this->setGuiClass($gui_class);
210  $this->setPermCreateFolders($perm_create_folder);
216 
217  try
218  {
219  ilCloudConnector::checkServiceActive($this->getGUIClass()->object->getServiceName());
220  $this->beforeInitGUI();
221 
222  //if($this->getPluginObject()->getAsyncDrawing())
223  {
224  $tpl->addJavaScript("./Modules/Cloud/js/ilCloudFileList.js");
225  $tpl->addJavaScript("./Modules/Cloud/js/jquery.address.js");
226  $tpl->addJavascript("./Services/UIComponent/AdvancedSelectionList/js/AdvancedSelectionList.js");
227  $tpl->addCss("./Modules/Cloud/templates/css/cloud.css");
228 
229  include_once("./Services/YUI/classes/class.ilYuiUtil.php");
231 
232 
233  $this->tpl_file_tree = new ilTemplate("tpl.cloud_file_tree.html", true, true, "Modules/Cloud");
234 
235  $file_tree = new ilCloudFileTree($this->getGUIClass()->object->getRootFolder(), $this->getGUIClass()->object->getRootId(), $this->getGUIClass()->object->getId(), $this->getGUIClass()->object->getServiceName());
236  $file_tree->storeFileTreeToSession();
237 
238  $this->addToolbar($file_tree->getRootNode());
239 
240  $this->tpl_file_tree->setVariable("ASYNC_GET_BLOCK", json_encode($this->getGUIClass()->ctrl->getLinkTargetByClass("ilobjcloudgui", "asyncGetBlock", true)));
241  $this->tpl_file_tree->setVariable("ASYNC_CREATE_FOLDER", json_encode($this->getGUIClass()->ctrl->getLinkTargetByClass("ilcloudplugincreatefoldergui", "asyncCreateFolder", true)));
242  $this->tpl_file_tree->setVariable("ASYNC_UPLOAD_FILE", json_encode($this->getGUIClass()->ctrl->getLinkTargetByClass("ilcloudpluginuploadgui", "asyncUploadFile", true)));
243  $this->tpl_file_tree->setVariable("ASYNC_DELETE_ITEM", json_encode($this->getGUIClass()->ctrl->getLinkTargetByClass("ilcloudplugindeletegui", "asyncDeleteItem", true)));
244  $this->tpl_file_tree->setVariable("ROOT_ID", json_encode($file_tree->getRootNode()->getId()));
245  $this->tpl_file_tree->setVariable("ROOT_PATH", json_encode($file_tree->getRootNode()->getPath()));
246  if(isset($_POST["path"]))
247  {
248  $this->tpl_file_tree->setVariable("CURRENT_PATH", json_encode($_POST["path"]));
249  $file_tree->updateFileTree($_POST["path"]);
250  $node = $file_tree->getNodeFromPath($_POST["path"]);
251  $this->tpl_file_tree->setVariable("CURRENT_ID", json_encode($node->getId()));
252  }
253  else
254  {
255  $this->tpl_file_tree->setVariable("CURRENT_PATH", json_encode($file_tree->getRootNode()->getPath()));
256  $this->tpl_file_tree->setVariable("CURRENT_ID", json_encode($file_tree->getRootNode()->getID()));
257  }
258  $txt_max_file_size = $lng->txt("file_notice") . " " . ilCloudConnector::getPluginClass($this->getGUIClass()->object->getServiceName(), $this->getGUIClass()->object->getId())->getMaxFileSize() . " MB";
259  $this->tpl_file_tree->setVariable("MAX_FILE_SIZE", json_encode($txt_max_file_size));
260  $this->beforeSetContent();
261  $tpl->setContent($this->tpl_file_tree->get());
262  $tpl->setPermanentLink("cld", $this->getGuiClass()->object->getRefId(),"_path__endPath");
263  }
264 
265 
266 
291  $this->afterInitGUI();
292 
293 
294  } catch (Exception $e)
295  {
296  if($e->getCode() == ilCloudException::AUTHENTICATION_FAILED)
297  {
298  $this->getGUIClass()->object->setAuthComplete(false);
299  $this->getGUIClass()->object->doUpdate();
300 
301 
302  }
303  ilUtil::sendFailure($e->getMessage());
304  }
305  }
306 
307  function addToolbar($root_node)
308  {
309  global $lng, $ilToolbar, $tpl;
310 
311  $create_list_gui = ilCloudConnector::getItemCreationListGUIClass($this->getService());
312 
313  $list_gui_html = $create_list_gui->getGroupedListItemsHTML($this->getPermUploadItems(), $this->getPermCreateFolders());
314 
315  if($list_gui_html)
316  {
317  // toolbar
318  $ov_id = "il_add_new_cld_item_v";
319  $ov_trigger_id = $ov_id ."_tr";
320  $toolbar_locator = new ilLocatorGUI();
321  $toolbar_locator->addItem($this->getGuiClass()->object->getTitle(), ilCloudPluginFileTreeGUI::getLinkToFolder($root_node));
322  $ilToolbar->setId('xcld_toolbar');
323  $ilToolbar->addText("<div class='xcld_locator'>". $toolbar_locator->getHtml()."</div>");
324  $ilToolbar->addSeparator();
325  $ilToolbar->addButton($lng->txt("cld_add_new_item"), "#", "", "", "", $ov_trigger_id, 'submit emphsubmit');
326  include_once "Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php";
327  $ov = new ilOverlayGUI($ov_id);
328  $ov->add();
329  $ov->addTrigger($ov_trigger_id, "click", $ov_trigger_id, false, "tl", "tr");
330  $tpl->setVariable("SELECT_OBJTYPE_REPOS", '<div id="' . $ov_id . '" class="ilOverlay ilNoDisplay">'.$list_gui_html.'</div>');
331  }
332  }
333 
334  public function beforeInitGUI(){}
335  public function beforeSetContent(){}
336  public function afterInitGUI(){}
337 }
338 ?>