ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilWebDAVMountInstructionsGUI Class Reference
+ Collaboration diagram for ilWebDAVMountInstructionsGUI:

Public Member Functions

 __construct (ilWebDAVBaseMountInstructions $mount_instruction, ilLanguage $lang, UIServices $ui, Services $http)
 
 buildGUIFromGivenMountInstructions (array $mount_instructions, bool $render_async=false)
 
 renderMountInstructionsContent ()
 

Protected Attributes

ilWebDAVUriBuilder $uri_builder
 
ilWebDAVBaseMountInstructions $mount_instruction
 
ilLanguage $lang
 
UIServices $ui
 
Services $http
 

Private Member Functions

 determineOSfromUserAgent ()
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilWebDAVMountInstructionsGUI::__construct ( ilWebDAVBaseMountInstructions  $mount_instruction,
ilLanguage  $lang,
UIServices  $ui,
Services  $http 
)

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

References $http, $lang, $mount_instruction, $ui, ILIAS\FileDelivery\http(), ILIAS\HTTP\Services\request(), and ILIAS\Repository\ui().

37  {
38  $this->uri_builder = new ilWebDAVUriBuilder($http->request());
39  $this->mount_instruction = $mount_instruction;
40  $this->lang = $lang;
41  $this->ui = $ui;
42  $this->http = $http;
43  }
ilWebDAVBaseMountInstructions $mount_instruction
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:

Member Function Documentation

◆ buildGUIFromGivenMountInstructions()

ilWebDAVMountInstructionsGUI::buildGUIFromGivenMountInstructions ( array  $mount_instructions,
bool  $render_async = false 
)
Parameters
mixed[]$mount_instructions

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

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

Referenced by renderMountInstructionsContent().

48  : string
49  {
50  $os = $this->determineOSfromUserAgent();
51 
52  $f = $this->ui->factory();
53  $r = $this->ui->renderer();
54 
55  $components = [];
56 
57  $js_function_legacy = $f->legacy('<script>'
58  . 'il.UI.showMountInstructions = function (e, id){'
59  . "obj = $(e['target']);"
60  . "obj.siblings().removeClass('engaged disabled ilSubmitInactive').attr('aria-pressed', 'false');"
61  . "obj.siblings().removeAttr('disabled');"
62  . "obj.addClass('engaged ilSubmitInactive').attr('aria-pressed', 'true');"
63  . '$(".instructions").hide();'
64  . '$("#"+id).show();}</script>');
65 
66  if (count($mount_instructions) === 1) {
67  $content = $f->legacy("<div class='instructions'>" . array_shift($mount_instructions) . "</div>");
68 
69  return $render_async ? $r->renderAsync($content) : $r->render($content);
70  }
71 
72  $view_control_actions = [];
73 
74  $selected = array_key_first($mount_instructions);
75 
76  foreach ($mount_instructions as $title => $text) {
77  foreach ($os as $os_string) {
78  if (stristr($title, $os_string) !== false) {
79  $selected = $title;
80  break 2;
81  }
82  }
83  }
84 
85  foreach ($mount_instructions as $title => $text) {
86  if ($title == $selected) {
87  $hidden = '';
88  } else {
89  $hidden = 'style="display: none;"';
90  }
91 
92  $legacy = $f->legacy("<div id='$title' class='instructions' $hidden>$text</div>")
93  ->withCustomSignal($title, "il.UI.showMountInstructions(event, '$title');");
94 
95  $view_control_actions[$title] = $legacy->getCustomSignal($title);
96 
97  $components[] = $legacy;
98  }
99 
100  $view_control = $f->viewControl()->mode($view_control_actions, "mount-instruction-buttons")->withActive($selected);
101 
102  // Add view control and legacy add the beginning of the array (so they will be rendered first)
103  $header_components = [
104  $f->legacy("<div class='webdav-view-control'>"),
105  $view_control,
106  $f->legacy("</div>"),
107  $js_function_legacy];
108 
109  $components = array_merge($header_components, $components);
110 
111  return $render_async ? $r->renderAsync($components) : $r->render($components);
112  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ determineOSfromUserAgent()

ilWebDAVMountInstructionsGUI::determineOSfromUserAgent ( )
private

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

References ILIAS\FileDelivery\http().

Referenced by buildGUIFromGivenMountInstructions().

131  : array
132  {
133  $ua = $this->http->request()->getHeader('User-Agent')[0];
134 
135  if (stristr($ua, 'windows') !== false
136  || strpos($ua, 'microsoft') !== false) {
137  return ['win'];
138  }
139 
140  if (stristr($ua, 'darwin') !== false
141  || stristr($ua, 'macintosh') !== false) {
142  return ['mac', 'osx'];
143  }
144 
145  if (stristr($ua, 'linux') !== false
146  || stristr($ua, 'solaris') !== false
147  || stristr($ua, 'aix') !== false
148  || stristr($ua, 'unix') !== false
149  || stristr($ua, 'gvfs') !== false // nautilus browser uses this ID
150  ) {
151  return ['linux'];
152  }
153 
154  return ['unknown'];
155  }
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 114 of file class.ilWebDAVMountInstructionsGUI.php.

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

114  : void
115  {
116  try {
117  $instructions = $this->mount_instruction->getMountInstructionsAsArray();
118  } catch (InvalidArgumentException $e) {
120  $instructions = $document_processor->processMountInstructions($this->lang->txt('webfolder_instructions_text'));
121  $instructions = $this->mount_instruction->getMountInstructionsAsArray($instructions);
122  if ($instructions == '' || $instructions == '-webfolder_instructions_text-') {
123  $instructions = ["<div class='alert alert-danger'>" . $this->lang->txt('error') . ": " . $this->lang->txt('webdav_missing_lang') . "</div>"];
124  }
125  }
126 
127  echo $this->buildGUIFromGivenMountInstructions($instructions, true);
128  exit;
129  }
exit
Definition: login.php:28
buildGUIFromGivenMountInstructions(array $mount_instructions, bool $render_async=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

Field Documentation

◆ $http

Services ilWebDAVMountInstructionsGUI::$http
protected

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

Referenced by __construct().

◆ $lang

ilLanguage ilWebDAVMountInstructionsGUI::$lang
protected

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

Referenced by __construct().

◆ $mount_instruction

ilWebDAVBaseMountInstructions ilWebDAVMountInstructionsGUI::$mount_instruction
protected

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

Referenced by __construct().

◆ $ui

UIServices ilWebDAVMountInstructionsGUI::$ui
protected

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

Referenced by __construct().

◆ $uri_builder

ilWebDAVUriBuilder ilWebDAVMountInstructionsGUI::$uri_builder
protected

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


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