ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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.

30 {
31 parent::__construct($plugin_service_class);
32 $this->setFileTree($file_tree);
33 }
setFileTree(ilCloudFileTree $file_tree)

References setFileTree().

+ 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 283 of file class.ilCloudPluginFileTreeGUI.php.

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

Referenced by getLinkToFolder().

+ Here is the caller graph for this function:

◆ addDropZone()

ilCloudPluginFileTreeGUI::addDropZone ( )
protected

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

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

References $options, and ilJsonUtil\encode().

+ Here is the call graph for this function:

◆ formatBytes()

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

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

196 {
197 if ($bytes >= 1073741824)
198 {
199 $bytes = number_format($bytes / 1073741824, $precision) . ' GB';
200 }
201 elseif ($bytes >= 1048576)
202 {
203 $bytes = number_format($bytes / 1048576, $precision) . ' MB';
204 }
205 elseif ($bytes >= 1024)
206 {
207 $bytes = number_format($bytes / 1024, $precision) . ' KB';
208 }
209 elseif ($bytes > 1)
210 {
211 $bytes = $bytes . ' bytes';
212 }
213 elseif ($bytes == 1)
214 {
215 $bytes = $bytes . ' byte';
216 }
217 else
218 {
219 $bytes = '0 bytes';
220 }
221
222 return $bytes;
223 }

Referenced by getItemHtml().

+ 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.

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

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

+ 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 140 of file class.ilCloudPluginFileTreeGUI.php.

140 {
141 global $ilCtrl;
142
143 $item = new ilTemplate("tpl.container_list_item.html", true, true, "Services/Container/");
144
145 $action_list_gui = ilCloudConnector::getActionListGUIClass($this->getService());
146 $item->setVariable("COMMAND_SELECTION_LIST", $action_list_gui->getSelectionListItemsHTML($delete_files, $delete_folder, $node));
147
148 $item->setVariable("DIV_CLASS", "ilContainerListItemOuter");
149 $item->touchBlock("d_1");
150
151 include_once('./Services/Calendar/classes/class.ilDate.php');
153
154 if ($node->getIconPath() != "") {
155 $item->setVariable("SRC_ICON", $node->getIconPath());
156 }
157
158 // Folder with content
159 if ($node->getIsDir()) {
160 if ($node->getIconPath() == "") {
161 // $item->setVariable("SRC_ICON", "./Modules/Cloud/templates/images/icon_folder_b.png");
162 $item->setVariable("SRC_ICON", ilUtil::getImagePath('icon_dcl_fold.svg'));
163 }
164 $item->setVariable("TXT_DESC", '&nbsp;');
165 $item->setVariable("TXT_TITLE_LINKED", basename($node->getPath()));
166 $item->setVariable("HREF_TITLE_LINKED", $this->getLinkToFolder($node));
167 } // File
168 else {
169 if ($node->getIconPath() == "") {
170 // $item->setVariable("SRC_ICON", "./Modules/Cloud/templates/images/icon_file_b.png");
171 $item->setVariable("SRC_ICON", ilUtil::getImagePath('icon_dcl_file.svg'));
172 }
173
174 $item->setVariable("TXT_DESC",
175 $this->formatBytes($node->getSize()) . "&nbsp;&nbsp;&nbsp;" . $modified);
176 if ($download) {
177 $item->setVariable("TXT_TITLE_LINKED", basename($node->getPath()));
178 $item->setVariable("HREF_TITLE_LINKED", $ilCtrl->getLinkTarget($gui_class, "getFile") . "&id=" . $node->getId());
179 } else {
180 $item->setVariable("TXT_TITLE", basename($node->getPath()));
181 }
182 }
183
184 $this->setItemVariablePlugin($item, $node);
185
186 return $item->get();
187 }
const IL_CAL_UNIX
static getActionListGUIClass(ilCloudPluginService $plugin_service_class)
static getLinkToFolder(ilCloudFileNode $node)
setItemVariablePlugin(ilTemplate $item, ilCloudFileNode $node)
static formatDate(ilDateTime $date)
Format a date @access public.
@classDescription Date and time handling
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
global $ilCtrl
Definition: ilias.php:18

References $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().

+ 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 258 of file class.ilCloudPluginFileTreeGUI.php.

258 {
259 return "#/open_folder?id_parent=" . $node->getParentId() . "&current_id=" . $node->getId() . "&current_path=" . self::_urlencode($node->getPath());
260 }
static _urlencode($str)
urlencode without encoding slashes

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

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

+ 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 238 of file class.ilCloudPluginFileTreeGUI.php.

238 {
239 global $ilLocator;
240
241 if ($node == $this->getFileTree()->getRootNode()) {
242 $ilLocator = new ilLocatorGUI();
243 $ilLocator->addItem($this->getPluginObject()->getCloudModulObject()->getTitle(), ilCloudPluginFileTreeGUI::getLinkToFolder($node));
244 } else {
245 $this->getLocatorHtml($this->getFileTree()->getNodeFromId($node->getParentId()));
246 $ilLocator->addItem(basename($node->getPath()), $this->getLinkToFolder($node));
247 }
248
249 return "<DIV class='xcld_locator' id='xcld_locator_" . $node->getId() . "'>" . $ilLocator->getHTML() . "</DIV>";
250 }
locator handling class

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

Referenced by getLocatorHtml().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setBlockVariablePlugin()

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

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

128{ }

Referenced by getFolderHtml().

+ 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.

39 {
40 if ($file_tree) {
41 $this->file_tree = $file_tree;
42 }
43 }

References $file_tree.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setItemVariablePlugin()

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

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

230{ }

Referenced by getItemHtml().

+ 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 122 of file class.ilCloudPluginFileTreeGUI.php.

122{ }

Referenced by getFolderHtml().

+ 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: