ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilWebDAVMountInstructionsGUI Class Reference

Class ilWebDAVMountInstructionsGUI. More...

+ Collaboration diagram for ilWebDAVMountInstructionsGUI:

Public Member Functions

 __construct (ilWebDAVBaseMountInstructions $a_mount_instruction)
 
 buildGUIFromGivenMountInstructions ($a_mount_instructions, $a_render_async=false)
 
 renderMountInstructionsContent ()
 

Protected Attributes

 $protocol_prefixes
 
 $base_url
 
 $ref_id
 
 $mount_instruction
 
 $il_lang
 
 $ui
 
 $http
 

Private Member Functions

 determineOSfromUserAgent ()
 

Detailed Description

Class ilWebDAVMountInstructionsGUI.

This class delivers or prints a representation of the mount instructions

Author
Raphael Heer rapha.nosp@m.el.h.nosp@m.eer@h.nosp@m.slu..nosp@m.ch $Id$

Definition at line 11 of file class.ilWebDAVMountInstructionsGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilWebDAVMountInstructionsGUI::__construct ( ilWebDAVBaseMountInstructions  $a_mount_instruction)

Definition at line 26 of file class.ilWebDAVMountInstructionsGUI.php.

References $DIC, ILIAS\FileDelivery\http(), and ui().

27  {
28  global $DIC;
29 
30  $this->uri_builder = new ilWebDAVUriBuilder($DIC->http()->request());
31  $this->mount_instruction = $a_mount_instruction;
32  $this->il_lang = $DIC->language();
33  $this->ui = $DIC->ui();
34  $this->http = $DIC->http();
35  }
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: goto.php:24
ui()
Definition: ui.php:5
+ Here is the call graph for this function:

Member Function Documentation

◆ buildGUIFromGivenMountInstructions()

ilWebDAVMountInstructionsGUI::buildGUIFromGivenMountInstructions (   $a_mount_instructions,
  $a_render_async = false 
)

Definition at line 37 of file class.ilWebDAVMountInstructionsGUI.php.

References Vendor\Package\$f, determineOSfromUserAgent(), and ui().

Referenced by renderMountInstructionsContent().

38  {
39  $os = $this->determineOSfromUserAgent();
40 
41  $f = $this->ui->factory();
42  $r = $this->ui->renderer();
43 
44  // List of all components to render
45  $comps = array();
46 
47  // This is an additional legacy component. It contains the java script function to substitute the shown instructions
48  $js_function_legacy = $f->legacy('<script>'
49  . 'il.UI.showMountInstructions = function (e, id){'
50  // e['target'] is the id for the button which was clicked (e.g. 'button#il_ui_fw_1234')
51  . "obj = $(e['target']);"
52  // Sets all buttons to the "unclicked" state
53  . "obj.siblings().removeClass('engaged disabled ilSubmitInactive').attr('aria-pressed', 'false');"
54  . "obj.siblings().removeAttr('disabled');"
55  // Sets the clicked button into the "clicked" state
56  . "obj.addClass('engaged ilSubmitInactive').attr('aria-pressed', 'true');"
57  // Hide all instruction divs at first
58  . '$(".instructions").hide();'
59  // Show the div which is given as an argument
60  . '$("#"+id).show();}</script>');
61 
62  /*
63  * The document might just contain a single entry, then we don't need a view control and just return it.
64  */
65  if (count($a_mount_instructions) === 1) {
66  $content = $f->legacy("<div class='instructions'>" . array_shift($a_mount_instructions) . "</div>");
67 
68  return $a_render_async ? $r->renderAsync($content) : $r->render($content);
69  }
70 
71  /*
72  * This is an associative array. The key is the title of the button, the value the used signal. E.g.:
73  * array(
74  * "WINDOWS" => signal_for_windows_legacy_component,
75  * "MAC" => signal_for_mac_legacy_component,
76  * "LINUX" => signal_for_linux_legacy_component);
77  */
78  $view_control_actions = array();
79 
80  /*
81  * If we can determine the os and we find a corresponding string in the
82  * title of the instructions we automatically set it.
83  */
84 
85  foreach ($a_mount_instructions as $key => $value) {
86  $selected = $a_mount_instructions[$key];
87  break;
88  }
89 
90 
91  foreach ($a_mount_instructions as $title => $text) {
92  foreach ($os as $os_string) {
93  if (stristr($title, $os_string) !== false) {
94  $selected = $title;
95  break 2;
96  }
97  }
98  }
99 
100  foreach ($a_mount_instructions as $title => $text) {
101  if ($title == $selected) {
102  $hidden = '';
103  } else {
104  $hidden = 'style="display: none;"';
105  }
106 
107  // Create legacy component for mount instructions. Mount instructions text is wrapped in a <div>-tag
108  $legacy = $f->legacy("<div id='$title' class='instructions' $hidden>$text</div>")
109  ->withCustomSignal($title, "il.UI.showMountInstructions(event, '$title');");
110 
111  // Add to the list of components to render
112  $comps[] = $legacy;
113 
114  // Add signal to the list for the view control
115  $view_control_actions[$title] = $legacy->getCustomSignal($title);
116  }
117 
118  $view_control = $f->viewControl()->mode($view_control_actions, "mount-instruction-buttons")->withActive($selected);
119 
120  // Add view control and legacy add the beginning of the array (so they will be rendered first)
121  $header_comps = array(
122  $f->legacy("<div class='webdav-view-control'>"),
123  $view_control,
124  $f->legacy("</div>"),
125  $js_function_legacy);
126 
127  $comps = array_merge($header_comps, $comps);
128 
129  return $a_render_async ? $r->renderAsync($comps) : $r->render($comps);
130  }
ui()
Definition: ui.php:5
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ determineOSfromUserAgent()

ilWebDAVMountInstructionsGUI::determineOSfromUserAgent ( )
private

Definition at line 149 of file class.ilWebDAVMountInstructionsGUI.php.

References ILIAS\FileDelivery\http().

Referenced by buildGUIFromGivenMountInstructions().

149  : array
150  {
151  $ua = $this->http->request()->getHeader('User-Agent')[0];
152 
153  if (stristr($ua, 'windows') !== false
154  || strpos($ua, 'microsoft') !== false) {
155  return ['win'];
156  }
157 
158  if (stristr($this->user_agent, 'darwin') !== false
159  || stristr($ua, 'macintosh') !== false) {
160  return ['mac', 'osx'];
161  }
162 
163  if (stristr($ua, 'linux') !== false
164  || stristr($ua, 'solaris') !== false
165  || stristr($ua, 'aix') !== false
166  || stristr($ua, 'unix') !== false
167  || stristr($ua, 'gvfs') !== false // nautilus browser uses this ID
168  ) {
169  return ['linux'];
170  }
171 
172  return ['unknown'];
173  }
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderMountInstructionsContent()

ilWebDAVMountInstructionsGUI::renderMountInstructionsContent ( )

Definition at line 132 of file class.ilWebDAVMountInstructionsGUI.php.

References Vendor\Package\$e, buildGUIFromGivenMountInstructions(), and exit.

133  {
134  try {
135  $instructions = $this->mount_instruction->getMountInstructionsAsArray();
136  } catch (InvalidArgumentException $e) {
138  $instructions = $document_processor->processMountInstructions($this->il_lang->txt('webfolder_instructions_text'));
139  $instructions = $this->mount_instruction->getMountInstructionsAsArray($instructions);
140  if ($instructions == '' || $instructions == '-webfolder_instructions_text-') {
141  $instructions = ["<div class='alert alert-danger'>" . $this->il_lang->txt('error') . ": " . $this->il_lang->txt('webdav_missing_lang') . "</div>"];
142  }
143  }
144 
145  echo $this->buildGUIFromGivenMountInstructions($instructions, true);
146  exit;
147  }
exit
Definition: login.php:29
buildGUIFromGivenMountInstructions($a_mount_instructions, $a_render_async=false)
+ Here is the call graph for this function:

Field Documentation

◆ $base_url

ilWebDAVMountInstructionsGUI::$base_url
protected

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

◆ $http

ilWebDAVMountInstructionsGUI::$http
protected

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

◆ $il_lang

ilWebDAVMountInstructionsGUI::$il_lang
protected

Definition at line 22 of file class.ilWebDAVMountInstructionsGUI.php.

◆ $mount_instruction

ilWebDAVMountInstructionsGUI::$mount_instruction
protected

Definition at line 21 of file class.ilWebDAVMountInstructionsGUI.php.

◆ $protocol_prefixes

ilWebDAVMountInstructionsGUI::$protocol_prefixes
protected

Definition at line 18 of file class.ilWebDAVMountInstructionsGUI.php.

◆ $ref_id

ilWebDAVMountInstructionsGUI::$ref_id
protected

Definition at line 20 of file class.ilWebDAVMountInstructionsGUI.php.

◆ $ui

ilWebDAVMountInstructionsGUI::$ui
protected

Definition at line 23 of file class.ilWebDAVMountInstructionsGUI.php.


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