ILIAS  trunk Revision v12.0_alpha-1540-g00f839d5fa1
ILIAS\WebDAV\Mount\InstructionsGUI Class Reference
+ Collaboration diagram for ILIAS\WebDAV\Mount\InstructionsGUI:

Public Member Functions

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

Private Member Functions

 determineOSfromUserAgent ()
 

Detailed Description

Definition at line 28 of file InstructionsGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\WebDAV\Mount\InstructionsGUI::__construct ( protected BaseInstructions  $mount_instruction,
protected ilLanguage  $lang,
protected UIServices  $ui,
protected Services  $http 
)

Definition at line 30 of file InstructionsGUI.php.

35 {
36 }

Member Function Documentation

◆ buildGUIFromGivenMountInstructions()

ILIAS\WebDAV\Mount\InstructionsGUI::buildGUIFromGivenMountInstructions ( array  $mount_instructions,
bool  $render_async = false 
)
Parameters
mixed[]$mount_instructions

Definition at line 41 of file InstructionsGUI.php.

41 : string
42 {
43 $os = $this->determineOSfromUserAgent();
44
45 $f = $this->ui->factory();
46 $r = $this->ui->renderer();
47
48 $components = [];
49
50 $js_function_legacy = $f->legacy()->content(
51 '<script>'
52 . 'il.UI.showMountInstructions = function (e, id){'
53 . "obj = $(e['target']);"
54 . "obj.siblings().removeClass('engaged disabled ilSubmitInactive').attr('aria-pressed', 'false');"
55 . "obj.siblings().removeAttr('disabled');"
56 . "obj.addClass('engaged ilSubmitInactive').attr('aria-pressed', 'true');"
57 . '$(".instructions").hide();'
58 . '$("#"+id).show();}</script>'
59 );
60
61 if (count($mount_instructions) === 1) {
62 $content = $f->legacy()->content("<div class='instructions'>" . array_shift($mount_instructions) . "</div>");
63
64 return $render_async ? $r->renderAsync($content) : $r->render($content);
65 }
66
67 $view_control_actions = [];
68
69 $selected = array_key_first($mount_instructions);
70
71 foreach ($mount_instructions as $title => $text) {
72 foreach ($os as $os_string) {
73 if (stripos((string) $title, (string) $os_string) !== false) {
74 $selected = $title;
75 break 2;
76 }
77 }
78 }
79
80 foreach ($mount_instructions as $title => $text) {
81 $hidden = $title === $selected ? '' : 'style="display: none;"';
82
83 $legacy = $f->legacy()->content("<div id='$title' class='instructions' $hidden>$text</div>")
84 ->withCustomSignal($title, "il.UI.showMountInstructions(event, '$title');");
85
86 $view_control_actions[$title] = $legacy->getCustomSignal($title);
87
88 $components[] = $legacy;
89 }
90
91 $view_control = $f->viewControl()->mode($view_control_actions, 'mount-instruction-buttons')->withActive(
92 $selected
93 );
94
95 $header_components = [
96 $f->legacy()->content("<div class='webdav-view-control'>"),
97 $view_control,
98 $f->legacy()->content('</div>'),
99 $js_function_legacy,
100 ];
101
102 $components = array_merge($header_components, $components);
103
104 return $render_async ? $r->renderAsync($components) : $r->render($components);
105 }
$components
$text
Definition: xapiexit.php:21

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

Referenced by ILIAS\WebDAV\Mount\InstructionsGUI\renderMountInstructionsContent().

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

◆ determineOSfromUserAgent()

ILIAS\WebDAV\Mount\InstructionsGUI::determineOSfromUserAgent ( )
private

Definition at line 131 of file InstructionsGUI.php.

131 : array
132 {
133 $ua = $this->http->request()->getHeader('User-Agent')[0] ?? '';
134
135 if (stripos($ua, 'windows') !== false || str_contains($ua, 'microsoft')) {
136 return ['win'];
137 }
138
139 if (stripos($ua, 'darwin') !== false || stripos($ua, 'macintosh') !== false) {
140 return ['mac', 'osx'];
141 }
142
143 if (stripos($ua, 'linux') !== false
144 || stripos($ua, 'solaris') !== false
145 || stripos($ua, 'aix') !== false
146 || stripos($ua, 'unix') !== false
147 || stripos($ua, 'gvfs') !== false // nautilus browser uses this ID
148 ) {
149 return ['linux'];
150 }
151
152 return ['unknown'];
153 }
static http()
Fetches the global http state from ILIAS.

References ILIAS\FileDelivery\http().

Referenced by ILIAS\WebDAV\Mount\InstructionsGUI\buildGUIFromGivenMountInstructions().

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

◆ renderMountInstructionsContent()

ILIAS\WebDAV\Mount\InstructionsGUI::renderMountInstructionsContent ( )

Definition at line 107 of file InstructionsGUI.php.

107 : void
108 {
109 try {
110 $instructions = $this->mount_instruction->getMountInstructionsAsArray();
111 } catch (InvalidArgumentException) {
112 $document_processor = new HtmlDocumentProcessor(
113 new DocumentPurifier()
114 );
115 $instructions = $document_processor->processMountInstructions(
116 $this->lang->txt('webfolder_instructions_text')
117 );
118 $instructions = $this->mount_instruction->getMountInstructionsAsArray($instructions);
119 if ($instructions === '-webfolder_instructions_text-') {
120 $instructions = [
121 "<div class='alert alert-danger'>" . $this->lang->txt('error')
122 . ': ' . $this->lang->txt('webdav_missing_lang') . '</div>',
123 ];
124 }
125 }
126
127 echo $this->buildGUIFromGivenMountInstructions($instructions, true);
128 exit;
129 }
buildGUIFromGivenMountInstructions(array $mount_instructions, bool $render_async=false)
exit

References ILIAS\WebDAV\Mount\InstructionsGUI\buildGUIFromGivenMountInstructions(), and exit.

+ Here is the call graph for this function:

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