ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilCloudPluginFileTreeGUI Class Reference

Class ilCloudFileTree. More...

+ Inheritance diagram for ilCloudPluginFileTreeGUI:
+ Collaboration diagram for ilCloudPluginFileTreeGUI:

Public Member Functions

 __construct ($plugin_service_class, ilCloudFileTree $file_tree)
 
 setFileTree (ilCloudFileTree $file_tree)
 
 getFileTree ()
 
 getFolderHtml (ilObjCloudGUI $gui_class, $id, $delete_files=false, $delete_folder=false, $download=false, $files_visible=false, $folders_visible=false)
 
 setTreeVariablePlugin (ilTemplate $tree_tpl, ilObjCloudGUI $gui_class, $id, $delete_files=false, $delete_folder=false, $download=false, $files_visible=false, $folders_visible=false)
 
 getItemHtml (ilCloudFileNode $node, ilObjCloudGUI $gui_class, $delete_files=false, $delete_folder=false, $download=false)
 
 getLocatorHtml (ilCloudFileNode $node)
 
- Public Member Functions inherited from ilCloudPluginGUI
 __construct ($plugin_service_class)
 
 getPluginObject ()
 
 getPluginHookObject ()
 
 getAdminConfigObject ()
 
 getService ()
 
 txt ($var="")
 
 executeCommand ()
 

Static Public Member Functions

static getLinkToFolder (ilCloudFileNode $node)
 

Protected Member Functions

 setBlockVariablePlugin (ilTemplate $block)
 
 formatBytes ($bytes, $precision=2)
 
 setItemVariablePlugin (ilTemplate $item, ilCloudFileNode $node)
 
 addDropZone ()
 

Static Protected Member Functions

static _urlencode ($str)
 urlencode without encoding slashes More...
 

Protected Attributes

 $file_tree
 
- Protected Attributes inherited from ilCloudPluginGUI
 $service = null
 

Detailed Description

Class ilCloudFileTree.

Class for drawing the file tree.

Author
Timon Amstutz timon.nosp@m..ams.nosp@m.tutz@.nosp@m.ilub.nosp@m..unib.nosp@m.e.ch
Version
$Id$

Definition at line 19 of file class.ilCloudPluginFileTreeGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilCloudPluginFileTreeGUI::__construct (   $plugin_service_class,
ilCloudFileTree  $file_tree 
)
Parameters
ilCloudFileTree$file_tree

Definition at line 31 of file class.ilCloudPluginFileTreeGUI.php.

References ILIAS\GlobalScreen\Provider\__construct(), and setFileTree().

32  {
33  parent::__construct($plugin_service_class);
34  $this->setFileTree($file_tree);
35  }
setFileTree(ilCloudFileTree $file_tree)
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ _urlencode()

static ilCloudPluginFileTreeGUI::_urlencode (   $str)
staticprotected

urlencode without encoding slashes

Parameters
$str
Returns
mixed

Definition at line 299 of file class.ilCloudPluginFileTreeGUI.php.

300  {
301  return str_replace('%2F', '/', rawurlencode($str));
302  }

◆ addDropZone()

ilCloudPluginFileTreeGUI::addDropZone ( )
protected

Definition at line 277 of file class.ilCloudPluginFileTreeGUI.php.

References ilJsonUtil\encode().

278  {
279  $options = new stdClass();
280  $options->dropZone = ".ilFileUploadDropZone_1";
281  $options->fileInput = "#ilFileUploadInput_1";
282  $options->submitButton = "uploadFiles";
283  $options->cancelButton = "cancelAll";
284  $options->dropArea = ".ilFileDropTarget";
285  $options->fileList = "#ilFileUploadList_1";
286  $options->fileSelectButton = "#ilFileUploadFileSelect_1";
287  echo "<script language='javascript' type='text/javascript'>var fileUpload1 = new ilFileUpload(1, " . ilJsonUtil::encode($options)
288  . ");</script>";
289  }
static encode($mixed, $suppress_native=false)
+ Here is the call graph for this function:

◆ formatBytes()

ilCloudPluginFileTreeGUI::formatBytes (   $bytes,
  $precision = 2 
)
protected
Parameters
$bytes
int$precision
Returns
string

Definition at line 216 of file class.ilCloudPluginFileTreeGUI.php.

Referenced by getItemHtml().

217  {
218  if ($bytes >= 1073741824) {
219  $bytes = number_format($bytes / 1073741824, $precision) . ' GB';
220  } elseif ($bytes >= 1048576) {
221  $bytes = number_format($bytes / 1048576, $precision) . ' MB';
222  } elseif ($bytes >= 1024) {
223  $bytes = number_format($bytes / 1024, $precision) . ' KB';
224  } elseif ($bytes > 1) {
225  $bytes = $bytes . ' bytes';
226  } elseif ($bytes == 1) {
227  $bytes = $bytes . ' byte';
228  } else {
229  $bytes = '0 bytes';
230  }
231 
232  return $bytes;
233  }
+ Here is the caller graph for this function:

◆ getFileTree()

ilCloudPluginFileTreeGUI::getFileTree ( )
Returns
ilCloudFileTree

Definition at line 52 of file class.ilCloudPluginFileTreeGUI.php.

References $file_tree.

Referenced by getFolderHtml(), and getLocatorHtml().

+ Here is the caller graph for this function:

◆ getFolderHtml()

ilCloudPluginFileTreeGUI::getFolderHtml ( ilObjCloudGUI  $gui_class,
  $id,
  $delete_files = false,
  $delete_folder = false,
  $download = false,
  $files_visible = false,
  $folders_visible = false 
)
Parameters
ilObjCloudGUI$gui_class
$id
bool$delete_files
bool$delete_folder
bool$download
bool$files_visible
bool$folders_visible
Returns
string
Exceptions
ilCloudException

Definition at line 70 of file class.ilCloudPluginFileTreeGUI.php.

References $DIC, $lng, getFileTree(), getItemHtml(), ilCloudException\ID_DOES_NOT_EXIST_IN_FILE_TREE_IN_SESSION, setBlockVariablePlugin(), and setTreeVariablePlugin().

71  {
72  global $DIC;
73  $lng = $DIC['lng'];
74 
75  $node = null;
76 
77  $node = $this->getFileTree()->getNodeFromId($id);
78  if (!$node) {
80  }
81  $tree_tpl = new ilTemplate("tpl.cloud_block.html", true, true, "Modules/Cloud/");
82 
83  if ($files_visible || $folders_visible) {
84  $tree_tpl->setVariable("NODE_ID", $node->getId());
85 
86  $block = new ilTemplate("tpl.container_list_block.html", true, true, "Services/Container/");
87 
88  if ($node->hasChildren()) {
89  $block->setVariable("BLOCK_HEADER_CONTENT", $lng->txt("content"));
90 
91  $children = $this->getFileTree()->getSortedListOfChildren($node);
92  foreach ($children as $path) {
93  $child_node = $this->getFileTree()->getNodeFromPath($path);
94  if (($child_node->getIsDir() && $folders_visible) || (!$child_node->getIsDir() && $files_visible)) {
95  $block->setCurrentBlock("container_standard_row");
96  if ($child_node->getIsDir()) {
97  $block->setVariable("ROW_ID", "id=xcld_folder_" . $child_node->getId());
98  } else {
99  $block->setVariable("ROW_ID", "id=xcld_file_" . $child_node->getId());
100  }
101  $block->setVariable("BLOCK_ROW_CONTENT", $this->getItemHtml($child_node, $gui_class, $delete_files, $delete_folder, $download));
102  $block->parseCurrentBlock();
103  }
104  }
105  }
106  $this->setBlockVariablePlugin($block);
107  $tree_tpl->setVariable("CONTENT", $block->get());
108  } else {
109  // Nothing is visible
110  // $tree_tpl->setVariable("CONTENT", $lng->txt("file_folder_not_visible"));
111  }
112  $this->setTreeVariablePlugin($tree_tpl, $gui_class, $id, $delete_files, $delete_folder, $download, $files_visible, $folders_visible);
113 
114  return $tree_tpl->get();
115  }
setTreeVariablePlugin(ilTemplate $tree_tpl, ilObjCloudGUI $gui_class, $id, $delete_files=false, $delete_folder=false, $download=false, $files_visible=false, $folders_visible=false)
const ID_DOES_NOT_EXIST_IN_FILE_TREE_IN_SESSION
$lng
$DIC
Definition: xapitoken.php:46
getItemHtml(ilCloudFileNode $node, ilObjCloudGUI $gui_class, $delete_files=false, $delete_folder=false, $download=false)
Class ilCloudException.
+ Here is the call graph for this function:

◆ getItemHtml()

ilCloudPluginFileTreeGUI::getItemHtml ( ilCloudFileNode  $node,
ilObjCloudGUI  $gui_class,
  $delete_files = false,
  $delete_folder = false,
  $download = false 
)
Parameters
ilCloudFileNode$node
ilObjCloudGUI$gui_class
bool$delete_files
bool$delete_folder
bool$download
Returns
string

Definition at line 157 of file class.ilCloudPluginFileTreeGUI.php.

References $DIC, $ilCtrl, formatBytes(), ilDatePresentation\formatDate(), ilCloudConnector\getActionListGUIClass(), ilCloudFileNode\getIconPath(), ilCloudFileNode\getId(), ilUtil\getImagePath(), ilCloudFileNode\getIsDir(), getLinkToFolder(), ilCloudFileNode\getModified(), ilCloudFileNode\getPath(), ilCloudPluginGUI\getService(), ilCloudFileNode\getSize(), IL_CAL_UNIX, and setItemVariablePlugin().

Referenced by getFolderHtml().

158  {
159  global $DIC;
160  $ilCtrl = $DIC['ilCtrl'];
161 
162  $item = new ilTemplate("tpl.container_list_item.html", true, true, "Services/Container/");
163 
164  $action_list_gui = ilCloudConnector::getActionListGUIClass($this->getService());
165  $item->setVariable("COMMAND_SELECTION_LIST", $action_list_gui->getSelectionListItemsHTML($delete_files, $delete_folder, $node));
166 
167  $item->setVariable("DIV_CLASS", "ilContainerListItemOuter");
168  $item->touchBlock("d_1");
169 
170  include_once('./Services/Calendar/classes/class.ilDate.php');
172 
173  if ($node->getIconPath() != "") {
174  $item->setVariable("SRC_ICON", $node->getIconPath());
175  }
176 
177  // Folder with content
178  if ($node->getIsDir()) {
179  if ($node->getIconPath() == "") {
180  // $item->setVariable("SRC_ICON", "./Modules/Cloud/templates/images/icon_folder_b.png");
181  $item->setVariable("SRC_ICON", ilUtil::getImagePath('icon_dcl_fold.svg'));
182  }
183  $item->setVariable("TXT_TITLE_LINKED", htmlspecialchars(basename($node->getPath())));
184  $item->setVariable("HREF_TITLE_LINKED", $this->getLinkToFolder($node));
185  } // File
186  else {
187  if ($node->getIconPath() == "") {
188  // $item->setVariable("SRC_ICON", "./Modules/Cloud/templates/images/icon_file_b.png");
189  $item->setVariable("SRC_ICON", ilUtil::getImagePath('icon_dcl_file.svg'));
190  }
191 
192  $item->setVariable(
193  "TXT_DESC",
194  $this->formatBytes($node->getSize()) . "&nbsp;&nbsp;&nbsp;" . $modified
195  );
196  if ($download) {
197  $item->setVariable("TXT_TITLE_LINKED", htmlspecialchars(basename($node->getPath())));
198  $item->setVariable("HREF_TITLE_LINKED", $ilCtrl->getLinkTarget($gui_class, "getFile") . "&id=" . $node->getId());
199  } else {
200  $item->setVariable("TXT_TITLE", htmlspecialchars(basename($node->getPath())));
201  }
202  }
203 
204  $this->setItemVariablePlugin($item, $node);
205 
206  return $item->get();
207  }
static getActionListGUIClass(ilCloudPluginService $plugin_service_class)
const IL_CAL_UNIX
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
global $ilCtrl
Definition: ilias.php:18
setItemVariablePlugin(ilTemplate $item, ilCloudFileNode $node)
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static getLinkToFolder(ilCloudFileNode $node)
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLinkToFolder()

static ilCloudPluginFileTreeGUI::getLinkToFolder ( ilCloudFileNode  $node)
static
Parameters
ilCloudFileNode$node
Returns
string

Definition at line 271 of file class.ilCloudPluginFileTreeGUI.php.

References ilCloudFileNode\getId(), ilCloudFileNode\getParentId(), and ilCloudFileNode\getPath().

Referenced by ilCloudPluginInitGUI\addToolbar(), getItemHtml(), and getLocatorHtml().

272  {
273  return "#/open_folder?id_parent=" . $node->getParentId() . "&current_id=" . $node->getId() . "&current_path=" . self::_urlencode($node->getPath());
274  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLocatorHtml()

ilCloudPluginFileTreeGUI::getLocatorHtml ( ilCloudFileNode  $node)
Parameters
ilCloudFileNode$node
Returns
string

Definition at line 250 of file class.ilCloudPluginFileTreeGUI.php.

References getFileTree(), ilCloudFileNode\getId(), getLinkToFolder(), ilCloudFileNode\getParentId(), ilCloudFileNode\getPath(), and ilCloudPluginGUI\getPluginObject().

251  {
252  static $ilLocator;
253 
254  if ($node == $this->getFileTree()->getRootNode()) {
255  $ilLocator = new ilLocatorGUI();
256  $ilLocator->addItem($this->getPluginObject()->getCloudModulObject()->getTitle(), ilCloudPluginFileTreeGUI::getLinkToFolder($node));
257  } else {
258  $this->getLocatorHtml($this->getFileTree()->getNodeFromId($node->getParentId()));
259  $ilLocator->addItem(htmlspecialchars(basename($node->getPath())), $this->getLinkToFolder($node));
260  }
261 
262  return "<DIV class='xcld_locator' id='xcld_locator_" . $node->getId() . "'>" . $ilLocator->getHTML() . "</DIV>";
263  }
locator handling class
static getLinkToFolder(ilCloudFileNode $node)
+ Here is the call graph for this function:

◆ setBlockVariablePlugin()

ilCloudPluginFileTreeGUI::setBlockVariablePlugin ( ilTemplate  $block)
protected
Parameters
ilTemplate$block

Definition at line 143 of file class.ilCloudPluginFileTreeGUI.php.

Referenced by getFolderHtml().

144  {
145  }
+ Here is the caller graph for this function:

◆ setFileTree()

ilCloudPluginFileTreeGUI::setFileTree ( ilCloudFileTree  $file_tree)
Parameters
ilCloudFileTree$file_tree

Definition at line 41 of file class.ilCloudPluginFileTreeGUI.php.

References $file_tree.

Referenced by __construct().

42  {
43  if ($file_tree) {
44  $this->file_tree = $file_tree;
45  }
46  }
+ Here is the caller graph for this function:

◆ setItemVariablePlugin()

ilCloudPluginFileTreeGUI::setItemVariablePlugin ( ilTemplate  $item,
ilCloudFileNode  $node 
)
protected
Parameters
ilTemplate$item
ilCloudFileNode$node

Definition at line 240 of file class.ilCloudPluginFileTreeGUI.php.

Referenced by getItemHtml().

241  {
242  }
+ Here is the caller graph for this function:

◆ setTreeVariablePlugin()

ilCloudPluginFileTreeGUI::setTreeVariablePlugin ( ilTemplate  $tree_tpl,
ilObjCloudGUI  $gui_class,
  $id,
  $delete_files = false,
  $delete_folder = false,
  $download = false,
  $files_visible = false,
  $folders_visible = false 
)
Parameters
ilObjCloudGUI$gui_class
$id
bool$delete_files
bool$delete_folder
bool$download
bool$files_visible
bool$folders_visible

Definition at line 127 of file class.ilCloudPluginFileTreeGUI.php.

Referenced by getFolderHtml().

136  {
137  }
+ Here is the caller graph for this function:

Field Documentation

◆ $file_tree

ilCloudPluginFileTreeGUI::$file_tree
protected

Definition at line 25 of file class.ilCloudPluginFileTreeGUI.php.

Referenced by getFileTree(), and setFileTree().


The documentation for this class was generated from the following file: