ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 30 of file class.ilCloudPluginFileTreeGUI.php.

References setFileTree().

30  {
31  parent::__construct($plugin_service_class);
32  $this->setFileTree($file_tree);
33  }
setFileTree(ilCloudFileTree $file_tree)
+ 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 285 of file class.ilCloudPluginFileTreeGUI.php.

285  {
286  return str_replace('%2F', '/', rawurlencode($str));
287  }

◆ addDropZone()

ilCloudPluginFileTreeGUI::addDropZone ( )
protected

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

References $options, and ilJsonUtil\encode().

265  {
266  $options = new stdClass();
267  $options->dropZone = ".ilFileUploadDropZone_1";
268  $options->fileInput = "#ilFileUploadInput_1";
269  $options->submitButton = "uploadFiles";
270  $options->cancelButton = "cancelAll";
271  $options->dropArea = ".ilFileDropTarget";
272  $options->fileList = "#ilFileUploadList_1";
273  $options->fileSelectButton = "#ilFileUploadFileSelect_1";
274  echo "<script language='javascript' type='text/javascript'>var fileUpload1 = new ilFileUpload(1, " . ilJsonUtil::encode($options)
275  . ");</script>";
276  }
static encode($mixed, $suppress_native=false)
if(!is_array($argv)) $options
+ Here is the call graph for this function:

◆ formatBytes()

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

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

Referenced by getItemHtml().

198  {
199  if ($bytes >= 1073741824)
200  {
201  $bytes = number_format($bytes / 1073741824, $precision) . ' GB';
202  }
203  elseif ($bytes >= 1048576)
204  {
205  $bytes = number_format($bytes / 1048576, $precision) . ' MB';
206  }
207  elseif ($bytes >= 1024)
208  {
209  $bytes = number_format($bytes / 1024, $precision) . ' KB';
210  }
211  elseif ($bytes > 1)
212  {
213  $bytes = $bytes . ' bytes';
214  }
215  elseif ($bytes == 1)
216  {
217  $bytes = $bytes . ' byte';
218  }
219  else
220  {
221  $bytes = '0 bytes';
222  }
223 
224  return $bytes;
225  }
+ Here is the caller graph for this function:

◆ getFileTree()

ilCloudPluginFileTreeGUI::getFileTree ( )
Returns
ilCloudFileTree

Definition at line 49 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 66 of file class.ilCloudPluginFileTreeGUI.php.

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

66  {
67  global $DIC;
68  $lng = $DIC['lng'];
69 
70  $node = NULL;
71 
72  $node = $this->getFileTree()->getNodeFromId($id);
73  if (!$node) {
75  }
76  $tree_tpl = new ilTemplate("tpl.cloud_block.html", true, true, "Modules/Cloud/");
77 
78  if ($files_visible || $folders_visible) {
79  $tree_tpl->setVariable("NODE_ID", $node->getId());
80 
81  $block = new ilTemplate("tpl.container_list_block.html", true, true, "Services/Container/");
82 
83  if ($node->hasChildren()) {
84  $block->setVariable("BLOCK_HEADER_CONTENT", $lng->txt("content"));
85 
86  $children = $this->getFileTree()->getSortedListOfChildren($node);
87  foreach ($children as $path) {
88  $child_node = $this->getFileTree()->getNodeFromPath($path);
89  if (($child_node->getIsDir() && $folders_visible) || (!$child_node->getIsDir() && $files_visible)) {
90 
91  $block->setCurrentBlock("container_standard_row");
92  if ($child_node->getIsDir()) {
93  $block->setVariable("ROW_ID", "id=xcld_folder_" . $child_node->getId());
94  } else {
95  $block->setVariable("ROW_ID", "id=xcld_file_" . $child_node->getId());
96  }
97  $block->setVariable("BLOCK_ROW_CONTENT", $this->getItemHtml($child_node, $gui_class, $delete_files, $delete_folder, $download));
98  $block->parseCurrentBlock();
99  }
100  }
101  }
102  $this->setBlockVariablePlugin($block);
103  $tree_tpl->setVariable("CONTENT", $block->get());
104  } else {
105  // Nothing is visible
106  // $tree_tpl->setVariable("CONTENT", $lng->txt("file_folder_not_visible"));
107  }
108  $this->setTreeVariablePlugin($tree_tpl, $gui_class, $id, $delete_files, $delete_folder, $download, $files_visible, $folders_visible);
109 
110  return $tree_tpl->get();
111  }
$path
Definition: aliased.php:25
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
special template class to simplify handling of ITX/PEAR
global $lng
Definition: privfeed.php:17
global $DIC
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 141 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().

141  {
142  global $DIC;
143  $ilCtrl = $DIC['ilCtrl'];
144 
145  $item = new ilTemplate("tpl.container_list_item.html", true, true, "Services/Container/");
146 
147  $action_list_gui = ilCloudConnector::getActionListGUIClass($this->getService());
148  $item->setVariable("COMMAND_SELECTION_LIST", $action_list_gui->getSelectionListItemsHTML($delete_files, $delete_folder, $node));
149 
150  $item->setVariable("DIV_CLASS", "ilContainerListItemOuter");
151  $item->touchBlock("d_1");
152 
153  include_once('./Services/Calendar/classes/class.ilDate.php');
155 
156  if ($node->getIconPath() != "") {
157  $item->setVariable("SRC_ICON", $node->getIconPath());
158  }
159 
160  // Folder with content
161  if ($node->getIsDir()) {
162  if ($node->getIconPath() == "") {
163  // $item->setVariable("SRC_ICON", "./Modules/Cloud/templates/images/icon_folder_b.png");
164  $item->setVariable("SRC_ICON", ilUtil::getImagePath('icon_dcl_fold.svg'));
165  }
166  $item->setVariable("TXT_DESC", '&nbsp;');
167  $item->setVariable("TXT_TITLE_LINKED", basename($node->getPath()));
168  $item->setVariable("HREF_TITLE_LINKED", $this->getLinkToFolder($node));
169  } // File
170  else {
171  if ($node->getIconPath() == "") {
172  // $item->setVariable("SRC_ICON", "./Modules/Cloud/templates/images/icon_file_b.png");
173  $item->setVariable("SRC_ICON", ilUtil::getImagePath('icon_dcl_file.svg'));
174  }
175 
176  $item->setVariable("TXT_DESC",
177  $this->formatBytes($node->getSize()) . "&nbsp;&nbsp;&nbsp;" . $modified);
178  if ($download) {
179  $item->setVariable("TXT_TITLE_LINKED", basename($node->getPath()));
180  $item->setVariable("HREF_TITLE_LINKED", $ilCtrl->getLinkTarget($gui_class, "getFile") . "&id=" . $node->getId());
181  } else {
182  $item->setVariable("TXT_TITLE", basename($node->getPath()));
183  }
184  }
185 
186  $this->setItemVariablePlugin($item, $node);
187 
188  return $item->get();
189  }
static getActionListGUIClass(ilCloudPluginService $plugin_service_class)
const IL_CAL_UNIX
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)
special template class to simplify handling of ITX/PEAR
static formatDate(ilDateTime $date)
Format a date public.
Date and time handling
static getLinkToFolder(ilCloudFileNode $node)
global $DIC
+ 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 260 of file class.ilCloudPluginFileTreeGUI.php.

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

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

260  {
261  return "#/open_folder?id_parent=" . $node->getParentId() . "&current_id=" . $node->getId() . "&current_path=" . self::_urlencode($node->getPath());
262  }
+ 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 240 of file class.ilCloudPluginFileTreeGUI.php.

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

240  {
241  static $ilLocator;
242 
243  if ($node == $this->getFileTree()->getRootNode()) {
244  $ilLocator = new ilLocatorGUI();
245  $ilLocator->addItem($this->getPluginObject()->getCloudModulObject()->getTitle(), ilCloudPluginFileTreeGUI::getLinkToFolder($node));
246  } else {
247  $this->getLocatorHtml($this->getFileTree()->getNodeFromId($node->getParentId()));
248  $ilLocator->addItem(basename($node->getPath()), $this->getLinkToFolder($node));
249  }
250 
251  return "<DIV class='xcld_locator' id='xcld_locator_" . $node->getId() . "'>" . $ilLocator->getHTML() . "</DIV>";
252  }
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 129 of file class.ilCloudPluginFileTreeGUI.php.

Referenced by getFolderHtml().

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

◆ setFileTree()

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

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

References $file_tree.

Referenced by __construct().

39  {
40  if ($file_tree) {
41  $this->file_tree = $file_tree;
42  }
43  }
+ Here is the caller graph for this function:

◆ setItemVariablePlugin()

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

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

Referenced by getItemHtml().

232 { }
+ 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 123 of file class.ilCloudPluginFileTreeGUI.php.

Referenced by getFolderHtml().

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

Field Documentation

◆ $file_tree

ilCloudPluginFileTreeGUI::$file_tree
protected

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

Referenced by getFileTree(), and setFileTree().


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