ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilWebDAVMountInstructionsGUI Class Reference
+ Collaboration diagram for ilWebDAVMountInstructionsGUI:

Public Member Functions

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

Protected Attributes

ilWebDAVUriBuilder $uri_builder
 
Services $http
 

Private Member Functions

 determineOSfromUserAgent ()
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

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

38 {
39 $this->uri_builder = new ilWebDAVUriBuilder($http->request());
40 $this->http = $http;
41 }
static http()
Fetches the global http state from ILIAS.

References $http, ILIAS\FileDelivery\http(), and ILIAS\HTTP\Services\request().

+ 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 46 of file class.ilWebDAVMountInstructionsGUI.php.

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

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

Referenced by renderMountInstructionsContent().

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

◆ determineOSfromUserAgent()

ilWebDAVMountInstructionsGUI::determineOSfromUserAgent ( )
private

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

138 : array
139 {
140 $ua = $this->http->request()->getHeader('User-Agent')[0];
141
142 if (stristr($ua, 'windows') !== false
143 || str_contains($ua, 'microsoft')) {
144 return ['win'];
145 }
146
147 if (stristr($ua, 'darwin') !== false
148 || stristr($ua, 'macintosh') !== false) {
149 return ['mac', 'osx'];
150 }
151
152 if (stristr($ua, 'linux') !== false
153 || stristr($ua, 'solaris') !== false
154 || stristr($ua, 'aix') !== false
155 || stristr($ua, 'unix') !== false
156 || stristr($ua, 'gvfs') !== false // nautilus browser uses this ID
157 ) {
158 return ['linux'];
159 }
160
161 return ['unknown'];
162 }

References ILIAS\FileDelivery\http().

Referenced by buildGUIFromGivenMountInstructions().

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

◆ renderMountInstructionsContent()

ilWebDAVMountInstructionsGUI::renderMountInstructionsContent ( )

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

113 : void
114 {
115 try {
116 $instructions = $this->mount_instruction->getMountInstructionsAsArray();
117 } catch (InvalidArgumentException) {
118 $document_processor = new ilWebDAVMountInstructionsHtmlDocumentProcessor(
120 );
121 $instructions = $document_processor->processMountInstructions(
122 $this->lang->txt('webfolder_instructions_text')
123 );
124 $instructions = $this->mount_instruction->getMountInstructionsAsArray($instructions);
125 if ($instructions == '' || $instructions == '-webfolder_instructions_text-') {
126 $instructions = [
127 "<div class='alert alert-danger'>" . $this->lang->txt(
128 'error'
129 ) . ": " . $this->lang->txt('webdav_missing_lang') . "</div>"
130 ];
131 }
132 }
133
134 echo $this->buildGUIFromGivenMountInstructions($instructions, true);
135 exit;
136 }
buildGUIFromGivenMountInstructions(array $mount_instructions, bool $render_async=false)
exit

References buildGUIFromGivenMountInstructions(), and exit.

+ Here is the call graph for this function:

Field Documentation

◆ $http

Services ilWebDAVMountInstructionsGUI::$http
protected

Definition at line 31 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: